]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* BGP VTY interface. |
896014f4 DL |
2 | * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro |
3 | * | |
4 | * This file is part of GNU Zebra. | |
5 | * | |
6 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
7 | * under the terms of the GNU General Public License as published by the | |
8 | * Free Software Foundation; either version 2, or (at your option) any | |
9 | * later version. | |
10 | * | |
11 | * GNU Zebra is distributed in the hope that it will be useful, but | |
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License along | |
17 | * with this program; see the file COPYING; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | */ | |
718e3744 | 20 | |
21 | #include <zebra.h> | |
22 | ||
23 | #include "command.h" | |
afec25d9 | 24 | #include "lib/json.h" |
ec0ab544 | 25 | #include "lib/zclient.h" |
718e3744 | 26 | #include "prefix.h" |
27 | #include "plist.h" | |
28 | #include "buffer.h" | |
29 | #include "linklist.h" | |
30 | #include "stream.h" | |
31 | #include "thread.h" | |
32 | #include "log.h" | |
3b8b1855 | 33 | #include "memory.h" |
fc7948fa | 34 | #include "memory_vty.h" |
4bf6a362 | 35 | #include "hash.h" |
3f9c7369 | 36 | #include "queue.h" |
039f3a34 | 37 | #include "filter.h" |
5d5ba018 | 38 | #include "frrstr.h" |
718e3744 | 39 | |
40 | #include "bgpd/bgpd.h" | |
48ecf8f5 | 41 | #include "bgpd/bgp_attr_evpn.h" |
4bf6a362 | 42 | #include "bgpd/bgp_advertise.h" |
718e3744 | 43 | #include "bgpd/bgp_attr.h" |
44 | #include "bgpd/bgp_aspath.h" | |
45 | #include "bgpd/bgp_community.h" | |
4bf6a362 | 46 | #include "bgpd/bgp_ecommunity.h" |
57d187bc | 47 | #include "bgpd/bgp_lcommunity.h" |
4bf6a362 | 48 | #include "bgpd/bgp_damp.h" |
718e3744 | 49 | #include "bgpd/bgp_debug.h" |
14454c9f | 50 | #include "bgpd/bgp_errors.h" |
e0701b79 | 51 | #include "bgpd/bgp_fsm.h" |
4bf6a362 | 52 | #include "bgpd/bgp_nexthop.h" |
718e3744 | 53 | #include "bgpd/bgp_open.h" |
4bf6a362 | 54 | #include "bgpd/bgp_regex.h" |
718e3744 | 55 | #include "bgpd/bgp_route.h" |
c016b6c7 | 56 | #include "bgpd/bgp_mplsvpn.h" |
718e3744 | 57 | #include "bgpd/bgp_zebra.h" |
fee0f4c6 | 58 | #include "bgpd/bgp_table.h" |
94f2b392 | 59 | #include "bgpd/bgp_vty.h" |
165b5fff | 60 | #include "bgpd/bgp_mpath.h" |
cb1faec9 | 61 | #include "bgpd/bgp_packet.h" |
3f9c7369 | 62 | #include "bgpd/bgp_updgrp.h" |
c43ed2e4 | 63 | #include "bgpd/bgp_bfd.h" |
555e09d4 | 64 | #include "bgpd/bgp_io.h" |
94c2f693 | 65 | #include "bgpd/bgp_evpn.h" |
dcc68b5e | 66 | #include "bgpd/bgp_addpath.h" |
48ecf8f5 | 67 | #include "bgpd/bgp_mac.h" |
718e3744 | 68 | |
d62a17ae | 69 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
70 | struct prefix *range, int exact); | |
71 | ||
72 | static enum node_type bgp_node_type(afi_t afi, safi_t safi) | |
73 | { | |
74 | switch (afi) { | |
75 | case AFI_IP: | |
76 | switch (safi) { | |
77 | case SAFI_UNICAST: | |
78 | return BGP_IPV4_NODE; | |
79 | break; | |
80 | case SAFI_MULTICAST: | |
81 | return BGP_IPV4M_NODE; | |
82 | break; | |
83 | case SAFI_LABELED_UNICAST: | |
84 | return BGP_IPV4L_NODE; | |
85 | break; | |
86 | case SAFI_MPLS_VPN: | |
87 | return BGP_VPNV4_NODE; | |
88 | break; | |
7c40bf39 | 89 | case SAFI_FLOWSPEC: |
90 | return BGP_FLOWSPECV4_NODE; | |
5c525538 RW |
91 | default: |
92 | /* not expected */ | |
93 | return BGP_IPV4_NODE; | |
94 | break; | |
d62a17ae | 95 | } |
96 | break; | |
97 | case AFI_IP6: | |
98 | switch (safi) { | |
99 | case SAFI_UNICAST: | |
100 | return BGP_IPV6_NODE; | |
101 | break; | |
102 | case SAFI_MULTICAST: | |
103 | return BGP_IPV6M_NODE; | |
104 | break; | |
105 | case SAFI_LABELED_UNICAST: | |
106 | return BGP_IPV6L_NODE; | |
107 | break; | |
108 | case SAFI_MPLS_VPN: | |
109 | return BGP_VPNV6_NODE; | |
110 | break; | |
7c40bf39 | 111 | case SAFI_FLOWSPEC: |
112 | return BGP_FLOWSPECV6_NODE; | |
5c525538 RW |
113 | default: |
114 | /* not expected */ | |
115 | return BGP_IPV4_NODE; | |
116 | break; | |
d62a17ae | 117 | } |
118 | break; | |
119 | case AFI_L2VPN: | |
120 | return BGP_EVPN_NODE; | |
121 | break; | |
122 | case AFI_MAX: | |
123 | // We should never be here but to clarify the switch statement.. | |
124 | return BGP_IPV4_NODE; | |
125 | break; | |
126 | } | |
127 | ||
128 | // Impossible to happen | |
129 | return BGP_IPV4_NODE; | |
f51bae9c | 130 | } |
20eb8864 | 131 | |
718e3744 | 132 | /* Utility function to get address family from current node. */ |
d62a17ae | 133 | afi_t bgp_node_afi(struct vty *vty) |
134 | { | |
135 | afi_t afi; | |
136 | switch (vty->node) { | |
137 | case BGP_IPV6_NODE: | |
138 | case BGP_IPV6M_NODE: | |
139 | case BGP_IPV6L_NODE: | |
140 | case BGP_VPNV6_NODE: | |
7c40bf39 | 141 | case BGP_FLOWSPECV6_NODE: |
d62a17ae | 142 | afi = AFI_IP6; |
143 | break; | |
144 | case BGP_EVPN_NODE: | |
145 | afi = AFI_L2VPN; | |
146 | break; | |
147 | default: | |
148 | afi = AFI_IP; | |
149 | break; | |
150 | } | |
151 | return afi; | |
718e3744 | 152 | } |
153 | ||
154 | /* Utility function to get subsequent address family from current | |
155 | node. */ | |
d62a17ae | 156 | safi_t bgp_node_safi(struct vty *vty) |
157 | { | |
158 | safi_t safi; | |
159 | switch (vty->node) { | |
160 | case BGP_VPNV4_NODE: | |
161 | case BGP_VPNV6_NODE: | |
162 | safi = SAFI_MPLS_VPN; | |
163 | break; | |
164 | case BGP_IPV4M_NODE: | |
165 | case BGP_IPV6M_NODE: | |
166 | safi = SAFI_MULTICAST; | |
167 | break; | |
168 | case BGP_EVPN_NODE: | |
169 | safi = SAFI_EVPN; | |
170 | break; | |
171 | case BGP_IPV4L_NODE: | |
172 | case BGP_IPV6L_NODE: | |
173 | safi = SAFI_LABELED_UNICAST; | |
174 | break; | |
7c40bf39 | 175 | case BGP_FLOWSPECV4_NODE: |
176 | case BGP_FLOWSPECV6_NODE: | |
177 | safi = SAFI_FLOWSPEC; | |
178 | break; | |
d62a17ae | 179 | default: |
180 | safi = SAFI_UNICAST; | |
181 | break; | |
182 | } | |
183 | return safi; | |
718e3744 | 184 | } |
185 | ||
55f91488 QY |
186 | /** |
187 | * Converts an AFI in string form to afi_t | |
188 | * | |
189 | * @param afi string, one of | |
190 | * - "ipv4" | |
191 | * - "ipv6" | |
81cf0de5 | 192 | * - "l2vpn" |
55f91488 QY |
193 | * @return the corresponding afi_t |
194 | */ | |
d62a17ae | 195 | afi_t bgp_vty_afi_from_str(const char *afi_str) |
196 | { | |
197 | afi_t afi = AFI_MAX; /* unknown */ | |
198 | if (strmatch(afi_str, "ipv4")) | |
199 | afi = AFI_IP; | |
200 | else if (strmatch(afi_str, "ipv6")) | |
201 | afi = AFI_IP6; | |
81cf0de5 CS |
202 | else if (strmatch(afi_str, "l2vpn")) |
203 | afi = AFI_L2VPN; | |
d62a17ae | 204 | return afi; |
205 | } | |
206 | ||
207 | int argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, | |
208 | afi_t *afi) | |
209 | { | |
210 | int ret = 0; | |
211 | if (argv_find(argv, argc, "ipv4", index)) { | |
212 | ret = 1; | |
213 | if (afi) | |
214 | *afi = AFI_IP; | |
215 | } else if (argv_find(argv, argc, "ipv6", index)) { | |
216 | ret = 1; | |
217 | if (afi) | |
218 | *afi = AFI_IP6; | |
219 | } | |
220 | return ret; | |
46f296b4 LB |
221 | } |
222 | ||
375a2e67 | 223 | /* supports <unicast|multicast|vpn|labeled-unicast> */ |
d62a17ae | 224 | safi_t bgp_vty_safi_from_str(const char *safi_str) |
225 | { | |
226 | safi_t safi = SAFI_MAX; /* unknown */ | |
227 | if (strmatch(safi_str, "multicast")) | |
228 | safi = SAFI_MULTICAST; | |
229 | else if (strmatch(safi_str, "unicast")) | |
230 | safi = SAFI_UNICAST; | |
231 | else if (strmatch(safi_str, "vpn")) | |
232 | safi = SAFI_MPLS_VPN; | |
81cf0de5 CS |
233 | else if (strmatch(safi_str, "evpn")) |
234 | safi = SAFI_EVPN; | |
d62a17ae | 235 | else if (strmatch(safi_str, "labeled-unicast")) |
236 | safi = SAFI_LABELED_UNICAST; | |
7c40bf39 | 237 | else if (strmatch(safi_str, "flowspec")) |
238 | safi = SAFI_FLOWSPEC; | |
d62a17ae | 239 | return safi; |
240 | } | |
241 | ||
242 | int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, | |
243 | safi_t *safi) | |
244 | { | |
245 | int ret = 0; | |
246 | if (argv_find(argv, argc, "unicast", index)) { | |
247 | ret = 1; | |
248 | if (safi) | |
249 | *safi = SAFI_UNICAST; | |
250 | } else if (argv_find(argv, argc, "multicast", index)) { | |
251 | ret = 1; | |
252 | if (safi) | |
253 | *safi = SAFI_MULTICAST; | |
254 | } else if (argv_find(argv, argc, "labeled-unicast", index)) { | |
255 | ret = 1; | |
256 | if (safi) | |
257 | *safi = SAFI_LABELED_UNICAST; | |
258 | } else if (argv_find(argv, argc, "vpn", index)) { | |
259 | ret = 1; | |
260 | if (safi) | |
261 | *safi = SAFI_MPLS_VPN; | |
7c40bf39 | 262 | } else if (argv_find(argv, argc, "flowspec", index)) { |
263 | ret = 1; | |
264 | if (safi) | |
265 | *safi = SAFI_FLOWSPEC; | |
d62a17ae | 266 | } |
267 | return ret; | |
46f296b4 LB |
268 | } |
269 | ||
7eeee51e | 270 | /* |
f212a857 | 271 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 272 | * |
f212a857 DS |
273 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
274 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
275 | * to appropriate values for the calling function. This is to allow the |
276 | * calling function to make decisions appropriate for the show command | |
277 | * that is being parsed. | |
278 | * | |
279 | * The show commands are generally of the form: | |
d62a17ae | 280 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> |
281 | * [<unicast|multicast|vpn|labeled-unicast>]] ..." | |
7eeee51e DS |
282 | * |
283 | * Since we use argv_find if the show command in particular doesn't have: | |
284 | * [ip] | |
18c57037 | 285 | * [<view|vrf> VIEWVRFNAME] |
375a2e67 | 286 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] |
7eeee51e DS |
287 | * The command parsing should still be ok. |
288 | * | |
289 | * vty -> The vty for the command so we can output some useful data in | |
290 | * the event of a parse error in the vrf. | |
291 | * argv -> The command tokens | |
292 | * argc -> How many command tokens we have | |
d62a17ae | 293 | * idx -> The current place in the command, generally should be 0 for this |
294 | * function | |
7eeee51e DS |
295 | * afi -> The parsed afi if it was included in the show command, returned here |
296 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 297 | * bgp -> Pointer to the bgp data structure we need to fill in. |
7eeee51e DS |
298 | * |
299 | * The function returns the correct location in the parse tree for the | |
300 | * last token found. | |
0e37c258 DS |
301 | * |
302 | * Returns 0 for failure to parse correctly, else the idx position of where | |
303 | * it found the last token. | |
7eeee51e | 304 | */ |
d62a17ae | 305 | int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, |
306 | struct cmd_token **argv, int argc, | |
307 | int *idx, afi_t *afi, safi_t *safi, | |
9f049418 | 308 | struct bgp **bgp, bool use_json) |
d62a17ae | 309 | { |
310 | char *vrf_name = NULL; | |
311 | ||
312 | assert(afi); | |
313 | assert(safi); | |
314 | assert(bgp); | |
315 | ||
316 | if (argv_find(argv, argc, "ip", idx)) | |
317 | *afi = AFI_IP; | |
318 | ||
9a8bdf1c | 319 | if (argv_find(argv, argc, "view", idx)) |
d62a17ae | 320 | vrf_name = argv[*idx + 1]->arg; |
9a8bdf1c PG |
321 | else if (argv_find(argv, argc, "vrf", idx)) { |
322 | vrf_name = argv[*idx + 1]->arg; | |
323 | if (strmatch(vrf_name, VRF_DEFAULT_NAME)) | |
324 | vrf_name = NULL; | |
325 | } | |
326 | if (vrf_name) { | |
d62a17ae | 327 | if (strmatch(vrf_name, "all")) |
328 | *bgp = NULL; | |
329 | else { | |
330 | *bgp = bgp_lookup_by_name(vrf_name); | |
331 | if (!*bgp) { | |
ca61fd25 DS |
332 | if (use_json) |
333 | vty_out(vty, "{}\n"); | |
334 | else | |
335 | vty_out(vty, "View/Vrf %s is unknown\n", | |
336 | vrf_name); | |
d62a17ae | 337 | *idx = 0; |
338 | return 0; | |
339 | } | |
340 | } | |
341 | } else { | |
342 | *bgp = bgp_get_default(); | |
343 | if (!*bgp) { | |
ca61fd25 DS |
344 | if (use_json) |
345 | vty_out(vty, "{}\n"); | |
346 | else | |
347 | vty_out(vty, | |
348 | "Default BGP instance not found\n"); | |
d62a17ae | 349 | *idx = 0; |
350 | return 0; | |
351 | } | |
352 | } | |
353 | ||
354 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
355 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
356 | ||
357 | *idx += 1; | |
358 | return *idx; | |
359 | } | |
360 | ||
361 | static int peer_address_self_check(struct bgp *bgp, union sockunion *su) | |
362 | { | |
363 | struct interface *ifp = NULL; | |
364 | ||
365 | if (su->sa.sa_family == AF_INET) | |
366 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); | |
367 | else if (su->sa.sa_family == AF_INET6) | |
368 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, | |
369 | su->sin6.sin6_scope_id, | |
370 | bgp->vrf_id); | |
371 | ||
372 | if (ifp) | |
373 | return 1; | |
374 | ||
375 | return 0; | |
718e3744 | 376 | } |
377 | ||
378 | /* Utility function for looking up peer from VTY. */ | |
f14e6fdb DS |
379 | /* This is used only for configuration, so disallow if attempted on |
380 | * a dynamic neighbor. | |
381 | */ | |
d62a17ae | 382 | static struct peer *peer_lookup_vty(struct vty *vty, const char *ip_str) |
383 | { | |
384 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
385 | int ret; | |
386 | union sockunion su; | |
387 | struct peer *peer; | |
388 | ||
389 | if (!bgp) { | |
390 | return NULL; | |
391 | } | |
392 | ||
393 | ret = str2sockunion(ip_str, &su); | |
394 | if (ret < 0) { | |
395 | peer = peer_lookup_by_conf_if(bgp, ip_str); | |
396 | if (!peer) { | |
397 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) | |
398 | == NULL) { | |
399 | vty_out(vty, | |
400 | "%% Malformed address or name: %s\n", | |
401 | ip_str); | |
402 | return NULL; | |
403 | } | |
404 | } | |
405 | } else { | |
406 | peer = peer_lookup(bgp, &su); | |
407 | if (!peer) { | |
408 | vty_out(vty, | |
409 | "%% Specify remote-as or peer-group commands first\n"); | |
410 | return NULL; | |
411 | } | |
412 | if (peer_dynamic_neighbor(peer)) { | |
413 | vty_out(vty, | |
414 | "%% Operation not allowed on a dynamic neighbor\n"); | |
415 | return NULL; | |
416 | } | |
417 | } | |
418 | return peer; | |
718e3744 | 419 | } |
420 | ||
421 | /* Utility function for looking up peer or peer group. */ | |
f14e6fdb DS |
422 | /* This is used only for configuration, so disallow if attempted on |
423 | * a dynamic neighbor. | |
424 | */ | |
d62a17ae | 425 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) |
426 | { | |
427 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
428 | int ret; | |
429 | union sockunion su; | |
430 | struct peer *peer = NULL; | |
431 | struct peer_group *group = NULL; | |
432 | ||
433 | if (!bgp) { | |
434 | return NULL; | |
435 | } | |
436 | ||
437 | ret = str2sockunion(peer_str, &su); | |
438 | if (ret == 0) { | |
439 | /* IP address, locate peer. */ | |
440 | peer = peer_lookup(bgp, &su); | |
441 | } else { | |
442 | /* Not IP, could match either peer configured on interface or a | |
443 | * group. */ | |
444 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
445 | if (!peer) | |
446 | group = peer_group_lookup(bgp, peer_str); | |
447 | } | |
448 | ||
449 | if (peer) { | |
450 | if (peer_dynamic_neighbor(peer)) { | |
451 | vty_out(vty, | |
452 | "%% Operation not allowed on a dynamic neighbor\n"); | |
453 | return NULL; | |
454 | } | |
455 | ||
456 | return peer; | |
457 | } | |
458 | ||
459 | if (group) | |
460 | return group->conf; | |
461 | ||
462 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); | |
463 | ||
464 | return NULL; | |
465 | } | |
466 | ||
467 | int bgp_vty_return(struct vty *vty, int ret) | |
468 | { | |
469 | const char *str = NULL; | |
470 | ||
471 | switch (ret) { | |
472 | case BGP_ERR_INVALID_VALUE: | |
473 | str = "Invalid value"; | |
474 | break; | |
475 | case BGP_ERR_INVALID_FLAG: | |
476 | str = "Invalid flag"; | |
477 | break; | |
478 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
479 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
480 | break; | |
481 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
482 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
483 | break; | |
484 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
485 | str = "Specify remote-as or peer-group remote AS first"; | |
486 | break; | |
487 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
488 | str = "Cannot change the peer-group. Deconfigure first"; | |
489 | break; | |
490 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
491 | str = "Peer is not a member of this peer-group"; | |
492 | break; | |
493 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
494 | str = "Prefix/distribute list can not co-exist"; | |
495 | break; | |
496 | case BGP_ERR_NOT_INTERNAL_PEER: | |
497 | str = "Invalid command. Not an internal neighbor"; | |
498 | break; | |
499 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
500 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
501 | break; | |
502 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
503 | str = "Local-AS allowed only for EBGP peers"; | |
504 | break; | |
505 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
506 | str = "Cannot have local-as same as BGP AS number"; | |
507 | break; | |
508 | case BGP_ERR_TCPSIG_FAILED: | |
509 | str = "Error while applying TCP-Sig to session(s)"; | |
510 | break; | |
511 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
512 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
513 | break; | |
514 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
515 | str = "ttl-security only allowed for EBGP peers"; | |
516 | break; | |
517 | case BGP_ERR_AS_OVERRIDE: | |
518 | str = "as-override cannot be configured for IBGP peers"; | |
519 | break; | |
520 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
521 | str = "Invalid limit for number of dynamic neighbors"; | |
522 | break; | |
523 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
524 | str = "Dynamic neighbor listen range already exists"; | |
525 | break; | |
526 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
527 | str = "Operation not allowed on a dynamic neighbor"; | |
528 | break; | |
529 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
530 | str = "Operation not allowed on a directly connected neighbor"; | |
531 | break; | |
532 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
533 | str = "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'"; | |
534 | break; | |
535 | } | |
536 | if (str) { | |
537 | vty_out(vty, "%% %s\n", str); | |
538 | return CMD_WARNING_CONFIG_FAILED; | |
539 | } | |
540 | return CMD_SUCCESS; | |
718e3744 | 541 | } |
542 | ||
7aafcaca | 543 | /* BGP clear sort. */ |
d62a17ae | 544 | enum clear_sort { |
545 | clear_all, | |
546 | clear_peer, | |
547 | clear_group, | |
548 | clear_external, | |
549 | clear_as | |
7aafcaca DS |
550 | }; |
551 | ||
d62a17ae | 552 | static void bgp_clear_vty_error(struct vty *vty, struct peer *peer, afi_t afi, |
553 | safi_t safi, int error) | |
554 | { | |
555 | switch (error) { | |
556 | case BGP_ERR_AF_UNCONFIGURED: | |
557 | vty_out(vty, | |
558 | "%%BGP: Enable %s address family for the neighbor %s\n", | |
559 | afi_safi_print(afi, safi), peer->host); | |
560 | break; | |
561 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
562 | vty_out(vty, | |
563 | "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n", | |
564 | peer->host); | |
565 | break; | |
566 | default: | |
567 | break; | |
568 | } | |
7aafcaca DS |
569 | } |
570 | ||
571 | /* `clear ip bgp' functions. */ | |
d62a17ae | 572 | static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
573 | enum clear_sort sort, enum bgp_clear_type stype, | |
574 | const char *arg) | |
575 | { | |
576 | int ret; | |
3ae8bfa5 | 577 | bool found = false; |
d62a17ae | 578 | struct peer *peer; |
579 | struct listnode *node, *nnode; | |
580 | ||
581 | /* Clear all neighbors. */ | |
582 | /* | |
583 | * Pass along pointer to next node to peer_clear() when walking all | |
3ae8bfa5 PM |
584 | * nodes on the BGP instance as that may get freed if it is a |
585 | * doppelganger | |
d62a17ae | 586 | */ |
587 | if (sort == clear_all) { | |
588 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
3ae8bfa5 PM |
589 | if (!peer->afc[afi][safi]) |
590 | continue; | |
591 | ||
d62a17ae | 592 | if (stype == BGP_CLEAR_SOFT_NONE) |
593 | ret = peer_clear(peer, &nnode); | |
d62a17ae | 594 | else |
3ae8bfa5 | 595 | ret = peer_clear_soft(peer, afi, safi, stype); |
d62a17ae | 596 | |
597 | if (ret < 0) | |
598 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
599 | else |
600 | found = true; | |
04b6bdc0 | 601 | } |
d62a17ae | 602 | |
603 | /* This is to apply read-only mode on this clear. */ | |
604 | if (stype == BGP_CLEAR_SOFT_NONE) | |
605 | bgp->update_delay_over = 0; | |
606 | ||
3ae8bfa5 | 607 | if (!found) |
3702f84d | 608 | vty_out(vty, "%%BGP: No %s peer configured\n", |
3ae8bfa5 PM |
609 | afi_safi_print(afi, safi)); |
610 | ||
d62a17ae | 611 | return CMD_SUCCESS; |
7aafcaca DS |
612 | } |
613 | ||
3ae8bfa5 | 614 | /* Clear specified neighbor. */ |
d62a17ae | 615 | if (sort == clear_peer) { |
616 | union sockunion su; | |
d62a17ae | 617 | |
618 | /* Make sockunion for lookup. */ | |
619 | ret = str2sockunion(arg, &su); | |
620 | if (ret < 0) { | |
621 | peer = peer_lookup_by_conf_if(bgp, arg); | |
622 | if (!peer) { | |
623 | peer = peer_lookup_by_hostname(bgp, arg); | |
624 | if (!peer) { | |
625 | vty_out(vty, | |
626 | "Malformed address or name: %s\n", | |
627 | arg); | |
628 | return CMD_WARNING; | |
629 | } | |
630 | } | |
631 | } else { | |
632 | peer = peer_lookup(bgp, &su); | |
633 | if (!peer) { | |
634 | vty_out(vty, | |
635 | "%%BGP: Unknown neighbor - \"%s\"\n", | |
636 | arg); | |
637 | return CMD_WARNING; | |
638 | } | |
639 | } | |
7aafcaca | 640 | |
3ae8bfa5 PM |
641 | if (!peer->afc[afi][safi]) |
642 | ret = BGP_ERR_AF_UNCONFIGURED; | |
643 | else if (stype == BGP_CLEAR_SOFT_NONE) | |
d62a17ae | 644 | ret = peer_clear(peer, NULL); |
645 | else | |
646 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 647 | |
d62a17ae | 648 | if (ret < 0) |
649 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
7aafcaca | 650 | |
d62a17ae | 651 | return CMD_SUCCESS; |
7aafcaca | 652 | } |
7aafcaca | 653 | |
3ae8bfa5 | 654 | /* Clear all neighbors belonging to a specific peer-group. */ |
d62a17ae | 655 | if (sort == clear_group) { |
656 | struct peer_group *group; | |
7aafcaca | 657 | |
d62a17ae | 658 | group = peer_group_lookup(bgp, arg); |
659 | if (!group) { | |
660 | vty_out(vty, "%%BGP: No such peer-group %s\n", arg); | |
661 | return CMD_WARNING; | |
662 | } | |
663 | ||
664 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
d62a17ae | 665 | if (!peer->afc[afi][safi]) |
666 | continue; | |
667 | ||
3ae8bfa5 PM |
668 | if (stype == BGP_CLEAR_SOFT_NONE) |
669 | ret = peer_clear(peer, NULL); | |
670 | else | |
671 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 672 | |
d62a17ae | 673 | if (ret < 0) |
674 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
675 | else |
676 | found = true; | |
d62a17ae | 677 | } |
3ae8bfa5 PM |
678 | |
679 | if (!found) | |
680 | vty_out(vty, | |
681 | "%%BGP: No %s peer belonging to peer-group %s is configured\n", | |
682 | afi_safi_print(afi, safi), arg); | |
683 | ||
d62a17ae | 684 | return CMD_SUCCESS; |
7aafcaca | 685 | } |
7aafcaca | 686 | |
3ae8bfa5 | 687 | /* Clear all external (eBGP) neighbors. */ |
d62a17ae | 688 | if (sort == clear_external) { |
689 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
690 | if (peer->sort == BGP_PEER_IBGP) | |
691 | continue; | |
7aafcaca | 692 | |
3ae8bfa5 PM |
693 | if (!peer->afc[afi][safi]) |
694 | continue; | |
695 | ||
d62a17ae | 696 | if (stype == BGP_CLEAR_SOFT_NONE) |
697 | ret = peer_clear(peer, &nnode); | |
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 external %s peer is configured\n", | |
710 | afi_safi_print(afi, safi)); | |
711 | ||
d62a17ae | 712 | return CMD_SUCCESS; |
713 | } | |
714 | ||
3ae8bfa5 | 715 | /* Clear all neighbors belonging to a specific AS. */ |
d62a17ae | 716 | if (sort == clear_as) { |
3ae8bfa5 | 717 | as_t as = strtoul(arg, NULL, 10); |
d62a17ae | 718 | |
719 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
720 | if (peer->as != as) | |
721 | continue; | |
722 | ||
3ae8bfa5 PM |
723 | if (!peer->afc[afi][safi]) |
724 | ret = BGP_ERR_AF_UNCONFIGURED; | |
725 | else if (stype == BGP_CLEAR_SOFT_NONE) | |
d62a17ae | 726 | ret = peer_clear(peer, &nnode); |
727 | else | |
728 | ret = peer_clear_soft(peer, afi, safi, stype); | |
729 | ||
730 | if (ret < 0) | |
731 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
732 | else |
733 | found = true; | |
d62a17ae | 734 | } |
3ae8bfa5 PM |
735 | |
736 | if (!found) | |
d62a17ae | 737 | vty_out(vty, |
3ae8bfa5 PM |
738 | "%%BGP: No %s peer is configured with AS %s\n", |
739 | afi_safi_print(afi, safi), arg); | |
740 | ||
d62a17ae | 741 | return CMD_SUCCESS; |
742 | } | |
743 | ||
744 | return CMD_SUCCESS; | |
745 | } | |
746 | ||
747 | static int bgp_clear_vty(struct vty *vty, const char *name, afi_t afi, | |
748 | safi_t safi, enum clear_sort sort, | |
749 | enum bgp_clear_type stype, const char *arg) | |
750 | { | |
751 | struct bgp *bgp; | |
752 | ||
753 | /* BGP structure lookup. */ | |
754 | if (name) { | |
755 | bgp = bgp_lookup_by_name(name); | |
756 | if (bgp == NULL) { | |
757 | vty_out(vty, "Can't find BGP instance %s\n", name); | |
758 | return CMD_WARNING; | |
759 | } | |
760 | } else { | |
761 | bgp = bgp_get_default(); | |
762 | if (bgp == NULL) { | |
763 | vty_out(vty, "No BGP process is configured\n"); | |
764 | return CMD_WARNING; | |
765 | } | |
766 | } | |
767 | ||
768 | return bgp_clear(vty, bgp, afi, safi, sort, stype, arg); | |
7aafcaca DS |
769 | } |
770 | ||
771 | /* clear soft inbound */ | |
d62a17ae | 772 | static void bgp_clear_star_soft_in(struct vty *vty, const char *name) |
7aafcaca | 773 | { |
d62a17ae | 774 | bgp_clear_vty(vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
775 | BGP_CLEAR_SOFT_IN, NULL); | |
776 | bgp_clear_vty(vty, name, AFI_IP6, SAFI_UNICAST, clear_all, | |
777 | BGP_CLEAR_SOFT_IN, NULL); | |
7aafcaca DS |
778 | } |
779 | ||
780 | /* clear soft outbound */ | |
d62a17ae | 781 | static void bgp_clear_star_soft_out(struct vty *vty, const char *name) |
7aafcaca | 782 | { |
d62a17ae | 783 | bgp_clear_vty(vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
784 | BGP_CLEAR_SOFT_OUT, NULL); | |
785 | bgp_clear_vty(vty, name, AFI_IP6, SAFI_UNICAST, clear_all, | |
786 | BGP_CLEAR_SOFT_OUT, NULL); | |
7aafcaca DS |
787 | } |
788 | ||
789 | ||
f787d7a0 | 790 | #ifndef VTYSH_EXTRACT_PL |
2e4c2296 | 791 | #include "bgpd/bgp_vty_clippy.c" |
f787d7a0 DL |
792 | #endif |
793 | ||
718e3744 | 794 | /* BGP global configuration. */ |
bee57a7a | 795 | #if (CONFDATE > 20190601) |
1cc40660 DS |
796 | CPP_NOTICE("bgpd: time to remove deprecated bgp multiple-instance") |
797 | CPP_NOTICE("This includes BGP_OPT_MULTIPLE_INSTANCE") | |
798 | #endif | |
799 | DEFUN_HIDDEN (bgp_multiple_instance_func, | |
800 | bgp_multiple_instance_cmd, | |
801 | "bgp multiple-instance", | |
802 | BGP_STR | |
803 | "Enable bgp multiple instance\n") | |
718e3744 | 804 | { |
d62a17ae | 805 | bgp_option_set(BGP_OPT_MULTIPLE_INSTANCE); |
806 | return CMD_SUCCESS; | |
718e3744 | 807 | } |
808 | ||
1cc40660 | 809 | DEFUN_HIDDEN (no_bgp_multiple_instance, |
718e3744 | 810 | no_bgp_multiple_instance_cmd, |
811 | "no bgp multiple-instance", | |
812 | NO_STR | |
813 | BGP_STR | |
814 | "BGP multiple instance\n") | |
815 | { | |
d62a17ae | 816 | int ret; |
718e3744 | 817 | |
1cc40660 DS |
818 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); |
819 | vty_out(vty, "if you are using this please let the developers know\n"); | |
b7cd3069 | 820 | zlog_info("Deprecated option: `bgp multiple-instance` being used"); |
d62a17ae | 821 | ret = bgp_option_unset(BGP_OPT_MULTIPLE_INSTANCE); |
822 | if (ret < 0) { | |
823 | vty_out(vty, "%% There are more than two BGP instances\n"); | |
824 | return CMD_WARNING_CONFIG_FAILED; | |
825 | } | |
826 | return CMD_SUCCESS; | |
718e3744 | 827 | } |
828 | ||
8029b216 AK |
829 | DEFUN_HIDDEN (bgp_local_mac, |
830 | bgp_local_mac_cmd, | |
093e3f23 | 831 | "bgp local-mac vni " CMD_VNI_RANGE " mac WORD seq (0-4294967295)", |
8029b216 AK |
832 | BGP_STR |
833 | "Local MAC config\n" | |
834 | "VxLAN Network Identifier\n" | |
835 | "VNI number\n" | |
836 | "local mac\n" | |
837 | "mac address\n" | |
838 | "mac-mobility sequence\n" | |
839 | "seq number\n") | |
840 | { | |
841 | int rv; | |
842 | vni_t vni; | |
843 | struct ethaddr mac; | |
844 | struct ipaddr ip; | |
845 | uint32_t seq; | |
846 | struct bgp *bgp; | |
847 | ||
848 | vni = strtoul(argv[3]->arg, NULL, 10); | |
849 | if (!prefix_str2mac(argv[5]->arg, &mac)) { | |
850 | vty_out(vty, "%% Malformed MAC address\n"); | |
851 | return CMD_WARNING; | |
852 | } | |
853 | memset(&ip, 0, sizeof(ip)); | |
854 | seq = strtoul(argv[7]->arg, NULL, 10); | |
855 | ||
856 | bgp = bgp_get_default(); | |
857 | if (!bgp) { | |
858 | vty_out(vty, "Default BGP instance is not there\n"); | |
859 | return CMD_WARNING; | |
860 | } | |
861 | ||
862 | rv = bgp_evpn_local_macip_add(bgp, vni, &mac, &ip, 0 /* flags */, seq); | |
863 | if (rv < 0) { | |
864 | vty_out(vty, "Internal error\n"); | |
865 | return CMD_WARNING; | |
866 | } | |
867 | ||
868 | return CMD_SUCCESS; | |
869 | } | |
870 | ||
871 | DEFUN_HIDDEN (no_bgp_local_mac, | |
872 | no_bgp_local_mac_cmd, | |
093e3f23 | 873 | "no bgp local-mac vni " CMD_VNI_RANGE " mac WORD", |
8029b216 AK |
874 | NO_STR |
875 | BGP_STR | |
876 | "Local MAC config\n" | |
877 | "VxLAN Network Identifier\n" | |
878 | "VNI number\n" | |
879 | "local mac\n" | |
880 | "mac address\n") | |
881 | { | |
882 | int rv; | |
883 | vni_t vni; | |
884 | struct ethaddr mac; | |
885 | struct ipaddr ip; | |
886 | struct bgp *bgp; | |
887 | ||
888 | vni = strtoul(argv[4]->arg, NULL, 10); | |
889 | if (!prefix_str2mac(argv[6]->arg, &mac)) { | |
890 | vty_out(vty, "%% Malformed MAC address\n"); | |
891 | return CMD_WARNING; | |
892 | } | |
893 | memset(&ip, 0, sizeof(ip)); | |
894 | ||
895 | bgp = bgp_get_default(); | |
896 | if (!bgp) { | |
897 | vty_out(vty, "Default BGP instance is not there\n"); | |
898 | return CMD_WARNING; | |
899 | } | |
900 | ||
ec0ab544 | 901 | rv = bgp_evpn_local_macip_del(bgp, vni, &mac, &ip, ZEBRA_NEIGH_ACTIVE); |
8029b216 AK |
902 | if (rv < 0) { |
903 | vty_out(vty, "Internal error\n"); | |
904 | return CMD_WARNING; | |
905 | } | |
906 | ||
907 | return CMD_SUCCESS; | |
908 | } | |
909 | ||
bee57a7a | 910 | #if (CONFDATE > 20190601) |
798467a2 DS |
911 | CPP_NOTICE("bgpd: time to remove deprecated cli bgp config-type cisco") |
912 | CPP_NOTICE("This includes BGP_OPT_CISCO_CONFIG") | |
913 | #endif | |
914 | DEFUN_HIDDEN (bgp_config_type, | |
915 | bgp_config_type_cmd, | |
916 | "bgp config-type <cisco|zebra>", | |
917 | BGP_STR | |
918 | "Configuration type\n" | |
919 | "cisco\n" | |
920 | "zebra\n") | |
718e3744 | 921 | { |
d62a17ae | 922 | int idx = 0; |
798467a2 DS |
923 | if (argv_find(argv, argc, "cisco", &idx)) { |
924 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
925 | vty_out(vty, "if you are using this please let the developers know!\n"); | |
b7cd3069 | 926 | zlog_info("Deprecated option: `bgp config-type cisco` being used"); |
d62a17ae | 927 | bgp_option_set(BGP_OPT_CONFIG_CISCO); |
798467a2 | 928 | } else |
d62a17ae | 929 | bgp_option_unset(BGP_OPT_CONFIG_CISCO); |
718e3744 | 930 | |
d62a17ae | 931 | return CMD_SUCCESS; |
718e3744 | 932 | } |
933 | ||
798467a2 DS |
934 | DEFUN_HIDDEN (no_bgp_config_type, |
935 | no_bgp_config_type_cmd, | |
936 | "no bgp config-type [<cisco|zebra>]", | |
937 | NO_STR | |
938 | BGP_STR | |
939 | "Display configuration type\n" | |
940 | "cisco\n" | |
941 | "zebra\n") | |
718e3744 | 942 | { |
d62a17ae | 943 | bgp_option_unset(BGP_OPT_CONFIG_CISCO); |
944 | return CMD_SUCCESS; | |
718e3744 | 945 | } |
946 | ||
813d4307 | 947 | |
718e3744 | 948 | DEFUN (no_synchronization, |
949 | no_synchronization_cmd, | |
950 | "no synchronization", | |
951 | NO_STR | |
952 | "Perform IGP synchronization\n") | |
953 | { | |
d62a17ae | 954 | return CMD_SUCCESS; |
718e3744 | 955 | } |
956 | ||
957 | DEFUN (no_auto_summary, | |
958 | no_auto_summary_cmd, | |
959 | "no auto-summary", | |
960 | NO_STR | |
961 | "Enable automatic network number summarization\n") | |
962 | { | |
d62a17ae | 963 | return CMD_SUCCESS; |
718e3744 | 964 | } |
3d515fd9 | 965 | |
718e3744 | 966 | /* "router bgp" commands. */ |
505e5056 | 967 | DEFUN_NOSH (router_bgp, |
f412b39a | 968 | router_bgp_cmd, |
18c57037 | 969 | "router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 970 | ROUTER_STR |
971 | BGP_STR | |
31500417 DW |
972 | AS_STR |
973 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 974 | { |
d62a17ae | 975 | int idx_asn = 2; |
976 | int idx_view_vrf = 3; | |
977 | int idx_vrf = 4; | |
ecec9495 | 978 | int is_new_bgp = 0; |
d62a17ae | 979 | int ret; |
980 | as_t as; | |
981 | struct bgp *bgp; | |
982 | const char *name = NULL; | |
983 | enum bgp_instance_type inst_type; | |
984 | ||
985 | // "router bgp" without an ASN | |
986 | if (argc == 2) { | |
987 | // Pending: Make VRF option available for ASN less config | |
988 | bgp = bgp_get_default(); | |
989 | ||
990 | if (bgp == NULL) { | |
991 | vty_out(vty, "%% No BGP process is configured\n"); | |
992 | return CMD_WARNING_CONFIG_FAILED; | |
993 | } | |
994 | ||
995 | if (listcount(bm->bgp) > 1) { | |
996c9314 | 996 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 997 | return CMD_WARNING_CONFIG_FAILED; |
998 | } | |
999 | } | |
1000 | ||
1001 | // "router bgp X" | |
1002 | else { | |
1003 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
1004 | ||
1005 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; | |
1006 | if (argc > 3) { | |
1007 | name = argv[idx_vrf]->arg; | |
1008 | ||
9a8bdf1c PG |
1009 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) { |
1010 | if (strmatch(name, VRF_DEFAULT_NAME)) | |
1011 | name = NULL; | |
1012 | else | |
1013 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
1014 | } else if (!strcmp(argv[idx_view_vrf]->text, "view")) | |
d62a17ae | 1015 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
1016 | } | |
1017 | ||
ecec9495 AD |
1018 | if (inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
1019 | is_new_bgp = (bgp_lookup(as, name) == NULL); | |
1020 | ||
d62a17ae | 1021 | ret = bgp_get(&bgp, &as, name, inst_type); |
1022 | switch (ret) { | |
1023 | case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET: | |
1024 | vty_out(vty, | |
1025 | "Please specify 'bgp multiple-instance' first\n"); | |
1026 | return CMD_WARNING_CONFIG_FAILED; | |
1027 | case BGP_ERR_AS_MISMATCH: | |
1028 | vty_out(vty, "BGP is already running; AS is %u\n", as); | |
1029 | return CMD_WARNING_CONFIG_FAILED; | |
1030 | case BGP_ERR_INSTANCE_MISMATCH: | |
1031 | vty_out(vty, | |
1032 | "BGP instance name and AS number mismatch\n"); | |
1033 | vty_out(vty, | |
1034 | "BGP instance is already running; AS is %u\n", | |
1035 | as); | |
1036 | return CMD_WARNING_CONFIG_FAILED; | |
1037 | } | |
1038 | ||
3bd70bf8 PZ |
1039 | /* |
1040 | * If we just instantiated the default instance, complete | |
1041 | * any pending VRF-VPN leaking that was configured via | |
1042 | * earlier "router bgp X vrf FOO" blocks. | |
1043 | */ | |
ecec9495 | 1044 | if (is_new_bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
3bd70bf8 PZ |
1045 | vpn_leak_postchange_all(); |
1046 | ||
d62a17ae | 1047 | /* Pending: handle when user tries to change a view to vrf n vv. |
1048 | */ | |
1049 | } | |
1050 | ||
0b5131c9 MK |
1051 | /* unset the auto created flag as the user config is now present */ |
1052 | UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO); | |
d62a17ae | 1053 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); |
1054 | ||
1055 | return CMD_SUCCESS; | |
718e3744 | 1056 | } |
1057 | ||
718e3744 | 1058 | /* "no router bgp" commands. */ |
1059 | DEFUN (no_router_bgp, | |
1060 | no_router_bgp_cmd, | |
18c57037 | 1061 | "no router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 1062 | NO_STR |
1063 | ROUTER_STR | |
1064 | BGP_STR | |
31500417 DW |
1065 | AS_STR |
1066 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1067 | { |
d62a17ae | 1068 | int idx_asn = 3; |
1069 | int idx_vrf = 5; | |
1070 | as_t as; | |
1071 | struct bgp *bgp; | |
1072 | const char *name = NULL; | |
718e3744 | 1073 | |
d62a17ae | 1074 | // "no router bgp" without an ASN |
1075 | if (argc == 3) { | |
1076 | // Pending: Make VRF option available for ASN less config | |
1077 | bgp = bgp_get_default(); | |
718e3744 | 1078 | |
d62a17ae | 1079 | if (bgp == NULL) { |
1080 | vty_out(vty, "%% No BGP process is configured\n"); | |
1081 | return CMD_WARNING_CONFIG_FAILED; | |
1082 | } | |
7fb21a9f | 1083 | |
d62a17ae | 1084 | if (listcount(bm->bgp) > 1) { |
996c9314 | 1085 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1086 | return CMD_WARNING_CONFIG_FAILED; |
1087 | } | |
0b5131c9 MK |
1088 | |
1089 | if (bgp->l3vni) { | |
1090 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
1091 | bgp->l3vni); | |
1092 | return CMD_WARNING_CONFIG_FAILED; | |
1093 | } | |
d62a17ae | 1094 | } else { |
1095 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
7fb21a9f | 1096 | |
d62a17ae | 1097 | if (argc > 4) |
1098 | name = argv[idx_vrf]->arg; | |
7fb21a9f | 1099 | |
d62a17ae | 1100 | /* Lookup bgp structure. */ |
1101 | bgp = bgp_lookup(as, name); | |
1102 | if (!bgp) { | |
1103 | vty_out(vty, "%% Can't find BGP instance\n"); | |
1104 | return CMD_WARNING_CONFIG_FAILED; | |
1105 | } | |
0b5131c9 MK |
1106 | |
1107 | if (bgp->l3vni) { | |
1108 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
1109 | bgp->l3vni); | |
1110 | return CMD_WARNING_CONFIG_FAILED; | |
1111 | } | |
d62a17ae | 1112 | } |
718e3744 | 1113 | |
d62a17ae | 1114 | bgp_delete(bgp); |
718e3744 | 1115 | |
d62a17ae | 1116 | return CMD_SUCCESS; |
718e3744 | 1117 | } |
1118 | ||
6b0655a2 | 1119 | |
718e3744 | 1120 | /* BGP router-id. */ |
1121 | ||
f787d7a0 | 1122 | DEFPY (bgp_router_id, |
718e3744 | 1123 | bgp_router_id_cmd, |
1124 | "bgp router-id A.B.C.D", | |
1125 | BGP_STR | |
1126 | "Override configured router identifier\n" | |
1127 | "Manually configured router identifier\n") | |
1128 | { | |
d62a17ae | 1129 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1130 | bgp_router_id_static_set(bgp, router_id); | |
1131 | return CMD_SUCCESS; | |
718e3744 | 1132 | } |
1133 | ||
f787d7a0 | 1134 | DEFPY (no_bgp_router_id, |
718e3744 | 1135 | no_bgp_router_id_cmd, |
31500417 | 1136 | "no bgp router-id [A.B.C.D]", |
718e3744 | 1137 | NO_STR |
1138 | BGP_STR | |
31500417 DW |
1139 | "Override configured router identifier\n" |
1140 | "Manually configured router identifier\n") | |
718e3744 | 1141 | { |
d62a17ae | 1142 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1143 | |
d62a17ae | 1144 | if (router_id_str) { |
1145 | if (!IPV4_ADDR_SAME(&bgp->router_id_static, &router_id)) { | |
1146 | vty_out(vty, "%% BGP router-id doesn't match\n"); | |
1147 | return CMD_WARNING_CONFIG_FAILED; | |
1148 | } | |
e018c7cc | 1149 | } |
718e3744 | 1150 | |
d62a17ae | 1151 | router_id.s_addr = 0; |
1152 | bgp_router_id_static_set(bgp, router_id); | |
718e3744 | 1153 | |
d62a17ae | 1154 | return CMD_SUCCESS; |
718e3744 | 1155 | } |
1156 | ||
6b0655a2 | 1157 | |
718e3744 | 1158 | /* BGP Cluster ID. */ |
718e3744 | 1159 | DEFUN (bgp_cluster_id, |
1160 | bgp_cluster_id_cmd, | |
838758ac | 1161 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", |
718e3744 | 1162 | BGP_STR |
1163 | "Configure Route-Reflector Cluster-id\n" | |
838758ac DW |
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 | int idx_ipv4 = 2; | |
1169 | int ret; | |
1170 | struct in_addr cluster; | |
718e3744 | 1171 | |
d62a17ae | 1172 | ret = inet_aton(argv[idx_ipv4]->arg, &cluster); |
1173 | if (!ret) { | |
1174 | vty_out(vty, "%% Malformed bgp cluster identifier\n"); | |
1175 | return CMD_WARNING_CONFIG_FAILED; | |
1176 | } | |
718e3744 | 1177 | |
d62a17ae | 1178 | bgp_cluster_id_set(bgp, &cluster); |
1179 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1180 | |
d62a17ae | 1181 | return CMD_SUCCESS; |
718e3744 | 1182 | } |
1183 | ||
718e3744 | 1184 | DEFUN (no_bgp_cluster_id, |
1185 | no_bgp_cluster_id_cmd, | |
c7178fe7 | 1186 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", |
718e3744 | 1187 | NO_STR |
1188 | BGP_STR | |
838758ac DW |
1189 | "Configure Route-Reflector Cluster-id\n" |
1190 | "Route-Reflector Cluster-id in IP address format\n" | |
1191 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1192 | { |
d62a17ae | 1193 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1194 | bgp_cluster_id_unset(bgp); | |
1195 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1196 | |
d62a17ae | 1197 | return CMD_SUCCESS; |
718e3744 | 1198 | } |
1199 | ||
718e3744 | 1200 | DEFUN (bgp_confederation_identifier, |
1201 | bgp_confederation_identifier_cmd, | |
9ccf14f7 | 1202 | "bgp confederation identifier (1-4294967295)", |
718e3744 | 1203 | "BGP specific commands\n" |
1204 | "AS confederation parameters\n" | |
1205 | "AS number\n" | |
1206 | "Set routing domain confederation AS\n") | |
1207 | { | |
d62a17ae | 1208 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1209 | int idx_number = 3; | |
1210 | as_t as; | |
718e3744 | 1211 | |
d62a17ae | 1212 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 1213 | |
d62a17ae | 1214 | bgp_confederation_id_set(bgp, as); |
718e3744 | 1215 | |
d62a17ae | 1216 | return CMD_SUCCESS; |
718e3744 | 1217 | } |
1218 | ||
1219 | DEFUN (no_bgp_confederation_identifier, | |
1220 | no_bgp_confederation_identifier_cmd, | |
838758ac | 1221 | "no bgp confederation identifier [(1-4294967295)]", |
718e3744 | 1222 | NO_STR |
1223 | "BGP specific commands\n" | |
1224 | "AS confederation parameters\n" | |
3a2d747c QY |
1225 | "AS number\n" |
1226 | "Set routing domain confederation AS\n") | |
718e3744 | 1227 | { |
d62a17ae | 1228 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1229 | bgp_confederation_id_unset(bgp); | |
718e3744 | 1230 | |
d62a17ae | 1231 | return CMD_SUCCESS; |
718e3744 | 1232 | } |
1233 | ||
718e3744 | 1234 | DEFUN (bgp_confederation_peers, |
1235 | bgp_confederation_peers_cmd, | |
12dcf78e | 1236 | "bgp confederation peers (1-4294967295)...", |
718e3744 | 1237 | "BGP specific commands\n" |
1238 | "AS confederation parameters\n" | |
1239 | "Peer ASs in BGP confederation\n" | |
1240 | AS_STR) | |
1241 | { | |
d62a17ae | 1242 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1243 | int idx_asn = 3; | |
1244 | as_t as; | |
1245 | int i; | |
718e3744 | 1246 | |
d62a17ae | 1247 | for (i = idx_asn; i < argc; i++) { |
1248 | as = strtoul(argv[i]->arg, NULL, 10); | |
718e3744 | 1249 | |
d62a17ae | 1250 | if (bgp->as == as) { |
1251 | vty_out(vty, | |
1252 | "%% Local member-AS not allowed in confed peer list\n"); | |
1253 | continue; | |
1254 | } | |
718e3744 | 1255 | |
d62a17ae | 1256 | bgp_confederation_peers_add(bgp, as); |
1257 | } | |
1258 | return CMD_SUCCESS; | |
718e3744 | 1259 | } |
1260 | ||
1261 | DEFUN (no_bgp_confederation_peers, | |
1262 | no_bgp_confederation_peers_cmd, | |
e83a9414 | 1263 | "no bgp confederation peers (1-4294967295)...", |
718e3744 | 1264 | NO_STR |
1265 | "BGP specific commands\n" | |
1266 | "AS confederation parameters\n" | |
1267 | "Peer ASs in BGP confederation\n" | |
1268 | AS_STR) | |
1269 | { | |
d62a17ae | 1270 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1271 | int idx_asn = 4; | |
1272 | as_t as; | |
1273 | int i; | |
718e3744 | 1274 | |
d62a17ae | 1275 | for (i = idx_asn; i < argc; i++) { |
1276 | as = strtoul(argv[i]->arg, NULL, 10); | |
0b2aa3a0 | 1277 | |
d62a17ae | 1278 | bgp_confederation_peers_remove(bgp, as); |
1279 | } | |
1280 | return CMD_SUCCESS; | |
718e3744 | 1281 | } |
6b0655a2 | 1282 | |
5e242b0d DS |
1283 | /** |
1284 | * Central routine for maximum-paths configuration. | |
1285 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1286 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1287 | */ | |
d62a17ae | 1288 | static int bgp_maxpaths_config_vty(struct vty *vty, int peer_type, |
d7c0a89a | 1289 | const char *mpaths, uint16_t options, |
d62a17ae | 1290 | int set) |
1291 | { | |
1292 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
d7c0a89a | 1293 | uint16_t maxpaths = 0; |
d62a17ae | 1294 | int ret; |
1295 | afi_t afi; | |
1296 | safi_t safi; | |
1297 | ||
1298 | afi = bgp_node_afi(vty); | |
1299 | safi = bgp_node_safi(vty); | |
1300 | ||
1301 | if (set) { | |
1302 | maxpaths = strtol(mpaths, NULL, 10); | |
1303 | if (maxpaths > multipath_num) { | |
1304 | vty_out(vty, | |
1305 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", | |
1306 | maxpaths, multipath_num); | |
1307 | return CMD_WARNING_CONFIG_FAILED; | |
1308 | } | |
1309 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1310 | options); | |
1311 | } else | |
1312 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1313 | ||
1314 | if (ret < 0) { | |
1315 | vty_out(vty, | |
1316 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", | |
1317 | (set == 1) ? "" : "un", | |
1318 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1319 | maxpaths, afi, safi); | |
1320 | return CMD_WARNING_CONFIG_FAILED; | |
1321 | } | |
1322 | ||
1323 | bgp_recalculate_all_bestpaths(bgp); | |
1324 | ||
1325 | return CMD_SUCCESS; | |
165b5fff JB |
1326 | } |
1327 | ||
abc920f8 DS |
1328 | DEFUN (bgp_maxmed_admin, |
1329 | bgp_maxmed_admin_cmd, | |
1330 | "bgp max-med administrative ", | |
1331 | BGP_STR | |
1332 | "Advertise routes with max-med\n" | |
1333 | "Administratively applied, for an indefinite period\n") | |
1334 | { | |
d62a17ae | 1335 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1336 | |
d62a17ae | 1337 | bgp->v_maxmed_admin = 1; |
1338 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1339 | |
d62a17ae | 1340 | bgp_maxmed_update(bgp); |
abc920f8 | 1341 | |
d62a17ae | 1342 | return CMD_SUCCESS; |
abc920f8 DS |
1343 | } |
1344 | ||
1345 | DEFUN (bgp_maxmed_admin_medv, | |
1346 | bgp_maxmed_admin_medv_cmd, | |
4668a151 | 1347 | "bgp max-med administrative (0-4294967295)", |
abc920f8 DS |
1348 | BGP_STR |
1349 | "Advertise routes with max-med\n" | |
1350 | "Administratively applied, for an indefinite period\n" | |
1351 | "Max MED value to be used\n") | |
1352 | { | |
d62a17ae | 1353 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1354 | int idx_number = 3; | |
abc920f8 | 1355 | |
d62a17ae | 1356 | bgp->v_maxmed_admin = 1; |
1357 | bgp->maxmed_admin_value = strtoul(argv[idx_number]->arg, NULL, 10); | |
abc920f8 | 1358 | |
d62a17ae | 1359 | bgp_maxmed_update(bgp); |
abc920f8 | 1360 | |
d62a17ae | 1361 | return CMD_SUCCESS; |
abc920f8 DS |
1362 | } |
1363 | ||
1364 | DEFUN (no_bgp_maxmed_admin, | |
1365 | no_bgp_maxmed_admin_cmd, | |
4668a151 | 1366 | "no bgp max-med administrative [(0-4294967295)]", |
abc920f8 DS |
1367 | NO_STR |
1368 | BGP_STR | |
1369 | "Advertise routes with max-med\n" | |
838758ac DW |
1370 | "Administratively applied, for an indefinite period\n" |
1371 | "Max MED value to be used\n") | |
abc920f8 | 1372 | { |
d62a17ae | 1373 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1374 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; | |
1375 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1376 | bgp_maxmed_update(bgp); | |
abc920f8 | 1377 | |
d62a17ae | 1378 | return CMD_SUCCESS; |
abc920f8 DS |
1379 | } |
1380 | ||
abc920f8 DS |
1381 | DEFUN (bgp_maxmed_onstartup, |
1382 | bgp_maxmed_onstartup_cmd, | |
4668a151 | 1383 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", |
abc920f8 DS |
1384 | BGP_STR |
1385 | "Advertise routes with max-med\n" | |
1386 | "Effective on a startup\n" | |
1387 | "Time (seconds) period for max-med\n" | |
1388 | "Max MED value to be used\n") | |
1389 | { | |
d62a17ae | 1390 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1391 | int idx = 0; | |
4668a151 | 1392 | |
d62a17ae | 1393 | argv_find(argv, argc, "(5-86400)", &idx); |
1394 | bgp->v_maxmed_onstartup = strtoul(argv[idx]->arg, NULL, 10); | |
1395 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
1396 | bgp->maxmed_onstartup_value = strtoul(argv[idx]->arg, NULL, 10); | |
1397 | else | |
1398 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
4668a151 | 1399 | |
d62a17ae | 1400 | bgp_maxmed_update(bgp); |
abc920f8 | 1401 | |
d62a17ae | 1402 | return CMD_SUCCESS; |
abc920f8 DS |
1403 | } |
1404 | ||
1405 | DEFUN (no_bgp_maxmed_onstartup, | |
1406 | no_bgp_maxmed_onstartup_cmd, | |
4668a151 | 1407 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", |
abc920f8 DS |
1408 | NO_STR |
1409 | BGP_STR | |
1410 | "Advertise routes with max-med\n" | |
838758ac DW |
1411 | "Effective on a startup\n" |
1412 | "Time (seconds) period for max-med\n" | |
1413 | "Max MED value to be used\n") | |
abc920f8 | 1414 | { |
d62a17ae | 1415 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1416 | |
d62a17ae | 1417 | /* Cancel max-med onstartup if its on */ |
1418 | if (bgp->t_maxmed_onstartup) { | |
1419 | THREAD_TIMER_OFF(bgp->t_maxmed_onstartup); | |
1420 | bgp->maxmed_onstartup_over = 1; | |
1421 | } | |
abc920f8 | 1422 | |
d62a17ae | 1423 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; |
1424 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1425 | |
d62a17ae | 1426 | bgp_maxmed_update(bgp); |
abc920f8 | 1427 | |
d62a17ae | 1428 | return CMD_SUCCESS; |
abc920f8 DS |
1429 | } |
1430 | ||
d62a17ae | 1431 | static int bgp_update_delay_config_vty(struct vty *vty, const char *delay, |
1432 | const char *wait) | |
f188f2c4 | 1433 | { |
d62a17ae | 1434 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d7c0a89a QY |
1435 | uint16_t update_delay; |
1436 | uint16_t establish_wait; | |
f188f2c4 | 1437 | |
d62a17ae | 1438 | update_delay = strtoul(delay, NULL, 10); |
f188f2c4 | 1439 | |
d62a17ae | 1440 | if (!wait) /* update-delay <delay> */ |
1441 | { | |
1442 | bgp->v_update_delay = update_delay; | |
1443 | bgp->v_establish_wait = bgp->v_update_delay; | |
1444 | return CMD_SUCCESS; | |
1445 | } | |
f188f2c4 | 1446 | |
d62a17ae | 1447 | /* update-delay <delay> <establish-wait> */ |
1448 | establish_wait = atoi(wait); | |
1449 | if (update_delay < establish_wait) { | |
1450 | vty_out(vty, | |
1451 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1452 | return CMD_WARNING_CONFIG_FAILED; | |
1453 | } | |
f188f2c4 | 1454 | |
d62a17ae | 1455 | bgp->v_update_delay = update_delay; |
1456 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 1457 | |
d62a17ae | 1458 | return CMD_SUCCESS; |
f188f2c4 DS |
1459 | } |
1460 | ||
d62a17ae | 1461 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 1462 | { |
d62a17ae | 1463 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 1464 | |
d62a17ae | 1465 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
1466 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 1467 | |
d62a17ae | 1468 | return CMD_SUCCESS; |
f188f2c4 DS |
1469 | } |
1470 | ||
2b791107 | 1471 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 1472 | { |
d62a17ae | 1473 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
1474 | vty_out(vty, " update-delay %d", bgp->v_update_delay); | |
1475 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1476 | vty_out(vty, " %d", bgp->v_establish_wait); | |
1477 | vty_out(vty, "\n"); | |
1478 | } | |
f188f2c4 DS |
1479 | } |
1480 | ||
1481 | ||
1482 | /* Update-delay configuration */ | |
1483 | DEFUN (bgp_update_delay, | |
1484 | bgp_update_delay_cmd, | |
6147e2c6 | 1485 | "update-delay (0-3600)", |
f188f2c4 DS |
1486 | "Force initial delay for best-path and updates\n" |
1487 | "Seconds\n") | |
1488 | { | |
d62a17ae | 1489 | int idx_number = 1; |
1490 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); | |
f188f2c4 DS |
1491 | } |
1492 | ||
1493 | DEFUN (bgp_update_delay_establish_wait, | |
1494 | bgp_update_delay_establish_wait_cmd, | |
6147e2c6 | 1495 | "update-delay (0-3600) (1-3600)", |
f188f2c4 DS |
1496 | "Force initial delay for best-path and updates\n" |
1497 | "Seconds\n" | |
f188f2c4 DS |
1498 | "Seconds\n") |
1499 | { | |
d62a17ae | 1500 | int idx_number = 1; |
1501 | int idx_number_2 = 2; | |
1502 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, | |
1503 | argv[idx_number_2]->arg); | |
f188f2c4 DS |
1504 | } |
1505 | ||
1506 | /* Update-delay deconfiguration */ | |
1507 | DEFUN (no_bgp_update_delay, | |
1508 | no_bgp_update_delay_cmd, | |
838758ac DW |
1509 | "no update-delay [(0-3600) [(1-3600)]]", |
1510 | NO_STR | |
f188f2c4 | 1511 | "Force initial delay for best-path and updates\n" |
838758ac | 1512 | "Seconds\n" |
7111c1a0 | 1513 | "Seconds\n") |
f188f2c4 | 1514 | { |
d62a17ae | 1515 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
1516 | } |
1517 | ||
5e242b0d | 1518 | |
d62a17ae | 1519 | static int bgp_wpkt_quanta_config_vty(struct vty *vty, const char *num, |
1520 | char set) | |
cb1faec9 | 1521 | { |
d62a17ae | 1522 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
cb1faec9 | 1523 | |
555e09d4 QY |
1524 | if (set) { |
1525 | uint32_t quanta = strtoul(num, NULL, 10); | |
1526 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, | |
1527 | memory_order_relaxed); | |
1528 | } else { | |
1529 | atomic_store_explicit(&bgp->wpkt_quanta, BGP_WRITE_PACKET_MAX, | |
1530 | memory_order_relaxed); | |
1531 | } | |
1532 | ||
1533 | return CMD_SUCCESS; | |
1534 | } | |
1535 | ||
1536 | static int bgp_rpkt_quanta_config_vty(struct vty *vty, const char *num, | |
1537 | char set) | |
1538 | { | |
1539 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1540 | ||
1541 | if (set) { | |
1542 | uint32_t quanta = strtoul(num, NULL, 10); | |
1543 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, | |
1544 | memory_order_relaxed); | |
1545 | } else { | |
1546 | atomic_store_explicit(&bgp->rpkt_quanta, BGP_READ_PACKET_MAX, | |
1547 | memory_order_relaxed); | |
1548 | } | |
cb1faec9 | 1549 | |
d62a17ae | 1550 | return CMD_SUCCESS; |
cb1faec9 DS |
1551 | } |
1552 | ||
2b791107 | 1553 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 1554 | { |
555e09d4 QY |
1555 | uint32_t quanta = |
1556 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
1557 | if (quanta != BGP_WRITE_PACKET_MAX) | |
152456fe | 1558 | vty_out(vty, " write-quanta %d\n", quanta); |
cb1faec9 DS |
1559 | } |
1560 | ||
555e09d4 QY |
1561 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) |
1562 | { | |
1563 | uint32_t quanta = | |
1564 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
1565 | if (quanta != BGP_READ_PACKET_MAX) | |
152456fe | 1566 | vty_out(vty, " read-quanta %d\n", quanta); |
555e09d4 | 1567 | } |
cb1faec9 | 1568 | |
555e09d4 | 1569 | /* Packet quanta configuration */ |
cb1faec9 DS |
1570 | DEFUN (bgp_wpkt_quanta, |
1571 | bgp_wpkt_quanta_cmd, | |
555e09d4 | 1572 | "write-quanta (1-10)", |
cb1faec9 DS |
1573 | "How many packets to write to peer socket per run\n" |
1574 | "Number of packets\n") | |
1575 | { | |
d62a17ae | 1576 | int idx_number = 1; |
1577 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
cb1faec9 DS |
1578 | } |
1579 | ||
cb1faec9 DS |
1580 | DEFUN (no_bgp_wpkt_quanta, |
1581 | no_bgp_wpkt_quanta_cmd, | |
555e09d4 | 1582 | "no write-quanta (1-10)", |
d7fa34c1 | 1583 | NO_STR |
555e09d4 | 1584 | "How many packets to write to peer socket per I/O cycle\n" |
cb1faec9 DS |
1585 | "Number of packets\n") |
1586 | { | |
d62a17ae | 1587 | int idx_number = 2; |
1588 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
cb1faec9 DS |
1589 | } |
1590 | ||
555e09d4 QY |
1591 | DEFUN (bgp_rpkt_quanta, |
1592 | bgp_rpkt_quanta_cmd, | |
1593 | "read-quanta (1-10)", | |
1594 | "How many packets to read from peer socket per I/O cycle\n" | |
1595 | "Number of packets\n") | |
1596 | { | |
1597 | int idx_number = 1; | |
1598 | return bgp_rpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
1599 | } | |
1600 | ||
1601 | DEFUN (no_bgp_rpkt_quanta, | |
1602 | no_bgp_rpkt_quanta_cmd, | |
1603 | "no read-quanta (1-10)", | |
1604 | NO_STR | |
1605 | "How many packets to read from peer socket per I/O cycle\n" | |
1606 | "Number of packets\n") | |
1607 | { | |
1608 | int idx_number = 2; | |
1609 | return bgp_rpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
1610 | } | |
1611 | ||
2b791107 | 1612 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 1613 | { |
37a333fe | 1614 | if (!bgp->heuristic_coalesce) |
d62a17ae | 1615 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); |
3f9c7369 DS |
1616 | } |
1617 | ||
1618 | ||
1619 | DEFUN (bgp_coalesce_time, | |
1620 | bgp_coalesce_time_cmd, | |
6147e2c6 | 1621 | "coalesce-time (0-4294967295)", |
3f9c7369 DS |
1622 | "Subgroup coalesce timer\n" |
1623 | "Subgroup coalesce timer value (in ms)\n") | |
1624 | { | |
d62a17ae | 1625 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1626 | |
d62a17ae | 1627 | int idx = 0; |
1628 | argv_find(argv, argc, "(0-4294967295)", &idx); | |
37a333fe | 1629 | bgp->heuristic_coalesce = false; |
d62a17ae | 1630 | bgp->coalesce_time = strtoul(argv[idx]->arg, NULL, 10); |
1631 | return CMD_SUCCESS; | |
3f9c7369 DS |
1632 | } |
1633 | ||
1634 | DEFUN (no_bgp_coalesce_time, | |
1635 | no_bgp_coalesce_time_cmd, | |
6147e2c6 | 1636 | "no coalesce-time (0-4294967295)", |
3a2d747c | 1637 | NO_STR |
3f9c7369 DS |
1638 | "Subgroup coalesce timer\n" |
1639 | "Subgroup coalesce timer value (in ms)\n") | |
1640 | { | |
d62a17ae | 1641 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1642 | |
37a333fe | 1643 | bgp->heuristic_coalesce = true; |
d62a17ae | 1644 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; |
1645 | return CMD_SUCCESS; | |
3f9c7369 DS |
1646 | } |
1647 | ||
5e242b0d DS |
1648 | /* Maximum-paths configuration */ |
1649 | DEFUN (bgp_maxpaths, | |
1650 | bgp_maxpaths_cmd, | |
6319fd63 | 1651 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), |
5e242b0d DS |
1652 | "Forward packets over multiple paths\n" |
1653 | "Number of paths\n") | |
1654 | { | |
d62a17ae | 1655 | int idx_number = 1; |
1656 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, | |
1657 | argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
1658 | } |
1659 | ||
d62a17ae | 1660 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
1661 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1662 | "Forward packets over multiple paths\n" | |
1663 | "Number of paths\n") | |
596c17ba | 1664 | |
165b5fff JB |
1665 | DEFUN (bgp_maxpaths_ibgp, |
1666 | bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1667 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), |
165b5fff JB |
1668 | "Forward packets over multiple paths\n" |
1669 | "iBGP-multipath\n" | |
1670 | "Number of paths\n") | |
1671 | { | |
d62a17ae | 1672 | int idx_number = 2; |
1673 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, | |
1674 | argv[idx_number]->arg, 0, 1); | |
5e242b0d | 1675 | } |
165b5fff | 1676 | |
d62a17ae | 1677 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
1678 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1679 | "Forward packets over multiple paths\n" | |
1680 | "iBGP-multipath\n" | |
1681 | "Number of paths\n") | |
596c17ba | 1682 | |
5e242b0d DS |
1683 | DEFUN (bgp_maxpaths_ibgp_cluster, |
1684 | bgp_maxpaths_ibgp_cluster_cmd, | |
6319fd63 | 1685 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", |
5e242b0d DS |
1686 | "Forward packets over multiple paths\n" |
1687 | "iBGP-multipath\n" | |
1688 | "Number of paths\n" | |
1689 | "Match the cluster length\n") | |
1690 | { | |
d62a17ae | 1691 | int idx_number = 2; |
1692 | return bgp_maxpaths_config_vty( | |
1693 | vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
1694 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); | |
165b5fff JB |
1695 | } |
1696 | ||
d62a17ae | 1697 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
1698 | "maximum-paths ibgp " CMD_RANGE_STR( | |
1699 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
1700 | "Forward packets over multiple paths\n" | |
1701 | "iBGP-multipath\n" | |
1702 | "Number of paths\n" | |
1703 | "Match the cluster length\n") | |
596c17ba | 1704 | |
165b5fff JB |
1705 | DEFUN (no_bgp_maxpaths, |
1706 | no_bgp_maxpaths_cmd, | |
6319fd63 | 1707 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", |
165b5fff JB |
1708 | NO_STR |
1709 | "Forward packets over multiple paths\n" | |
1710 | "Number of paths\n") | |
1711 | { | |
d62a17ae | 1712 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
1713 | } |
1714 | ||
d62a17ae | 1715 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
996c9314 | 1716 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 1717 | "Forward packets over multiple paths\n" |
1718 | "Number of paths\n") | |
596c17ba | 1719 | |
165b5fff JB |
1720 | DEFUN (no_bgp_maxpaths_ibgp, |
1721 | no_bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1722 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", |
165b5fff JB |
1723 | NO_STR |
1724 | "Forward packets over multiple paths\n" | |
1725 | "iBGP-multipath\n" | |
838758ac DW |
1726 | "Number of paths\n" |
1727 | "Match the cluster length\n") | |
165b5fff | 1728 | { |
d62a17ae | 1729 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1730 | } |
1731 | ||
d62a17ae | 1732 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
1733 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
1734 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
1735 | NO_STR | |
1736 | "Forward packets over multiple paths\n" | |
1737 | "iBGP-multipath\n" | |
1738 | "Number of paths\n" | |
1739 | "Match the cluster length\n") | |
596c17ba | 1740 | |
2b791107 | 1741 | void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, afi_t afi, |
60466a63 | 1742 | safi_t safi) |
165b5fff | 1743 | { |
d62a17ae | 1744 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) { |
d62a17ae | 1745 | vty_out(vty, " maximum-paths %d\n", |
1746 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
1747 | } | |
165b5fff | 1748 | |
d62a17ae | 1749 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) { |
d62a17ae | 1750 | vty_out(vty, " maximum-paths ibgp %d", |
1751 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
1752 | if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, | |
1753 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1754 | vty_out(vty, " equal-cluster-length"); | |
1755 | vty_out(vty, "\n"); | |
1756 | } | |
165b5fff | 1757 | } |
6b0655a2 | 1758 | |
718e3744 | 1759 | /* BGP timers. */ |
1760 | ||
1761 | DEFUN (bgp_timers, | |
1762 | bgp_timers_cmd, | |
6147e2c6 | 1763 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1764 | "Adjust routing timers\n" |
1765 | "BGP timers\n" | |
1766 | "Keepalive interval\n" | |
1767 | "Holdtime\n") | |
1768 | { | |
d62a17ae | 1769 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1770 | int idx_number = 2; | |
1771 | int idx_number_2 = 3; | |
1772 | unsigned long keepalive = 0; | |
1773 | unsigned long holdtime = 0; | |
718e3744 | 1774 | |
d62a17ae | 1775 | keepalive = strtoul(argv[idx_number]->arg, NULL, 10); |
1776 | holdtime = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
718e3744 | 1777 | |
d62a17ae | 1778 | /* Holdtime value check. */ |
1779 | if (holdtime < 3 && holdtime != 0) { | |
1780 | vty_out(vty, | |
1781 | "%% hold time value must be either 0 or greater than 3\n"); | |
1782 | return CMD_WARNING_CONFIG_FAILED; | |
1783 | } | |
718e3744 | 1784 | |
d62a17ae | 1785 | bgp_timers_set(bgp, keepalive, holdtime); |
718e3744 | 1786 | |
d62a17ae | 1787 | return CMD_SUCCESS; |
718e3744 | 1788 | } |
1789 | ||
1790 | DEFUN (no_bgp_timers, | |
1791 | no_bgp_timers_cmd, | |
838758ac | 1792 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1793 | NO_STR |
1794 | "Adjust routing timers\n" | |
838758ac DW |
1795 | "BGP timers\n" |
1796 | "Keepalive interval\n" | |
1797 | "Holdtime\n") | |
718e3744 | 1798 | { |
d62a17ae | 1799 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1800 | bgp_timers_unset(bgp); | |
718e3744 | 1801 | |
d62a17ae | 1802 | return CMD_SUCCESS; |
718e3744 | 1803 | } |
1804 | ||
6b0655a2 | 1805 | |
718e3744 | 1806 | DEFUN (bgp_client_to_client_reflection, |
1807 | bgp_client_to_client_reflection_cmd, | |
1808 | "bgp client-to-client reflection", | |
1809 | "BGP specific commands\n" | |
1810 | "Configure client to client route reflection\n" | |
1811 | "reflection of routes allowed\n") | |
1812 | { | |
d62a17ae | 1813 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1814 | bgp_flag_unset(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1815 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1816 | |
d62a17ae | 1817 | return CMD_SUCCESS; |
718e3744 | 1818 | } |
1819 | ||
1820 | DEFUN (no_bgp_client_to_client_reflection, | |
1821 | no_bgp_client_to_client_reflection_cmd, | |
1822 | "no bgp client-to-client reflection", | |
1823 | NO_STR | |
1824 | "BGP specific commands\n" | |
1825 | "Configure client to client route reflection\n" | |
1826 | "reflection of routes allowed\n") | |
1827 | { | |
d62a17ae | 1828 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1829 | bgp_flag_set(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1830 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1831 | |
d62a17ae | 1832 | return CMD_SUCCESS; |
718e3744 | 1833 | } |
1834 | ||
1835 | /* "bgp always-compare-med" configuration. */ | |
1836 | DEFUN (bgp_always_compare_med, | |
1837 | bgp_always_compare_med_cmd, | |
1838 | "bgp always-compare-med", | |
1839 | "BGP specific commands\n" | |
1840 | "Allow comparing MED from different neighbors\n") | |
1841 | { | |
d62a17ae | 1842 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1843 | bgp_flag_set(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1844 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1845 | |
d62a17ae | 1846 | return CMD_SUCCESS; |
718e3744 | 1847 | } |
1848 | ||
1849 | DEFUN (no_bgp_always_compare_med, | |
1850 | no_bgp_always_compare_med_cmd, | |
1851 | "no bgp always-compare-med", | |
1852 | NO_STR | |
1853 | "BGP specific commands\n" | |
1854 | "Allow comparing MED from different neighbors\n") | |
1855 | { | |
d62a17ae | 1856 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1857 | bgp_flag_unset(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1858 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1859 | |
d62a17ae | 1860 | return CMD_SUCCESS; |
718e3744 | 1861 | } |
6b0655a2 | 1862 | |
718e3744 | 1863 | /* "bgp deterministic-med" configuration. */ |
1864 | DEFUN (bgp_deterministic_med, | |
1865 | bgp_deterministic_med_cmd, | |
1866 | "bgp deterministic-med", | |
1867 | "BGP specific commands\n" | |
1868 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1869 | { | |
d62a17ae | 1870 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1475ac87 | 1871 | |
d62a17ae | 1872 | if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { |
1873 | bgp_flag_set(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1874 | bgp_recalculate_all_bestpaths(bgp); | |
1875 | } | |
7aafcaca | 1876 | |
d62a17ae | 1877 | return CMD_SUCCESS; |
718e3744 | 1878 | } |
1879 | ||
1880 | DEFUN (no_bgp_deterministic_med, | |
1881 | no_bgp_deterministic_med_cmd, | |
1882 | "no bgp deterministic-med", | |
1883 | NO_STR | |
1884 | "BGP specific commands\n" | |
1885 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1886 | { | |
d62a17ae | 1887 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1888 | int bestpath_per_as_used; | |
1889 | afi_t afi; | |
1890 | safi_t safi; | |
1891 | struct peer *peer; | |
1892 | struct listnode *node, *nnode; | |
1893 | ||
1894 | if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { | |
1895 | bestpath_per_as_used = 0; | |
1896 | ||
1897 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
05c7a1cc | 1898 | FOREACH_AFI_SAFI (afi, safi) |
dcc68b5e MS |
1899 | if (bgp_addpath_dmed_required( |
1900 | peer->addpath_type[afi][safi])) { | |
05c7a1cc QY |
1901 | bestpath_per_as_used = 1; |
1902 | break; | |
1903 | } | |
d62a17ae | 1904 | |
1905 | if (bestpath_per_as_used) | |
1906 | break; | |
1907 | } | |
1908 | ||
1909 | if (bestpath_per_as_used) { | |
1910 | vty_out(vty, | |
1911 | "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n"); | |
1912 | return CMD_WARNING_CONFIG_FAILED; | |
1913 | } else { | |
1914 | bgp_flag_unset(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1915 | bgp_recalculate_all_bestpaths(bgp); | |
1916 | } | |
1917 | } | |
1918 | ||
1919 | return CMD_SUCCESS; | |
718e3744 | 1920 | } |
538621f2 | 1921 | |
1922 | /* "bgp graceful-restart" configuration. */ | |
1923 | DEFUN (bgp_graceful_restart, | |
1924 | bgp_graceful_restart_cmd, | |
1925 | "bgp graceful-restart", | |
1926 | "BGP specific commands\n" | |
1927 | "Graceful restart capability parameters\n") | |
1928 | { | |
d62a17ae | 1929 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1930 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
1931 | return CMD_SUCCESS; | |
538621f2 | 1932 | } |
1933 | ||
1934 | DEFUN (no_bgp_graceful_restart, | |
1935 | no_bgp_graceful_restart_cmd, | |
1936 | "no bgp graceful-restart", | |
1937 | NO_STR | |
1938 | "BGP specific commands\n" | |
1939 | "Graceful restart capability parameters\n") | |
1940 | { | |
d62a17ae | 1941 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1942 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
1943 | return CMD_SUCCESS; | |
538621f2 | 1944 | } |
1945 | ||
93406d87 | 1946 | DEFUN (bgp_graceful_restart_stalepath_time, |
1947 | bgp_graceful_restart_stalepath_time_cmd, | |
6147e2c6 | 1948 | "bgp graceful-restart stalepath-time (1-3600)", |
93406d87 | 1949 | "BGP specific commands\n" |
1950 | "Graceful restart capability parameters\n" | |
1951 | "Set the max time to hold onto restarting peer's stale paths\n" | |
1952 | "Delay value (seconds)\n") | |
1953 | { | |
d62a17ae | 1954 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1955 | int idx_number = 3; | |
d7c0a89a | 1956 | uint32_t stalepath; |
93406d87 | 1957 | |
d62a17ae | 1958 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
1959 | bgp->stalepath_time = stalepath; | |
1960 | return CMD_SUCCESS; | |
93406d87 | 1961 | } |
1962 | ||
eb6f1b41 PG |
1963 | DEFUN (bgp_graceful_restart_restart_time, |
1964 | bgp_graceful_restart_restart_time_cmd, | |
6147e2c6 | 1965 | "bgp graceful-restart restart-time (1-3600)", |
eb6f1b41 PG |
1966 | "BGP specific commands\n" |
1967 | "Graceful restart capability parameters\n" | |
1968 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
1969 | "Delay value (seconds)\n") | |
1970 | { | |
d62a17ae | 1971 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1972 | int idx_number = 3; | |
d7c0a89a | 1973 | uint32_t restart; |
eb6f1b41 | 1974 | |
d62a17ae | 1975 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
1976 | bgp->restart_time = restart; | |
1977 | return CMD_SUCCESS; | |
eb6f1b41 PG |
1978 | } |
1979 | ||
93406d87 | 1980 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
1981 | no_bgp_graceful_restart_stalepath_time_cmd, | |
838758ac | 1982 | "no bgp graceful-restart stalepath-time [(1-3600)]", |
93406d87 | 1983 | NO_STR |
1984 | "BGP specific commands\n" | |
1985 | "Graceful restart capability parameters\n" | |
838758ac DW |
1986 | "Set the max time to hold onto restarting peer's stale paths\n" |
1987 | "Delay value (seconds)\n") | |
93406d87 | 1988 | { |
d62a17ae | 1989 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 1990 | |
d62a17ae | 1991 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
1992 | return CMD_SUCCESS; | |
93406d87 | 1993 | } |
1994 | ||
eb6f1b41 PG |
1995 | DEFUN (no_bgp_graceful_restart_restart_time, |
1996 | no_bgp_graceful_restart_restart_time_cmd, | |
838758ac | 1997 | "no bgp graceful-restart restart-time [(1-3600)]", |
eb6f1b41 PG |
1998 | NO_STR |
1999 | "BGP specific commands\n" | |
2000 | "Graceful restart capability parameters\n" | |
838758ac DW |
2001 | "Set the time to wait to delete stale routes before a BGP open message is received\n" |
2002 | "Delay value (seconds)\n") | |
eb6f1b41 | 2003 | { |
d62a17ae | 2004 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 2005 | |
d62a17ae | 2006 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
2007 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2008 | } |
2009 | ||
43fc21b3 JC |
2010 | DEFUN (bgp_graceful_restart_preserve_fw, |
2011 | bgp_graceful_restart_preserve_fw_cmd, | |
2012 | "bgp graceful-restart preserve-fw-state", | |
2013 | "BGP specific commands\n" | |
2014 | "Graceful restart capability parameters\n" | |
2015 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
2016 | { | |
d62a17ae | 2017 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2018 | bgp_flag_set(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
2019 | return CMD_SUCCESS; | |
43fc21b3 JC |
2020 | } |
2021 | ||
2022 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
2023 | no_bgp_graceful_restart_preserve_fw_cmd, | |
2024 | "no bgp graceful-restart preserve-fw-state", | |
2025 | NO_STR | |
2026 | "BGP specific commands\n" | |
2027 | "Graceful restart capability parameters\n" | |
2028 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
2029 | { | |
d62a17ae | 2030 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2031 | bgp_flag_unset(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
2032 | return CMD_SUCCESS; | |
43fc21b3 JC |
2033 | } |
2034 | ||
7f323236 DW |
2035 | static void bgp_redistribute_redo(struct bgp *bgp) |
2036 | { | |
2037 | afi_t afi; | |
2038 | int i; | |
2039 | struct list *red_list; | |
2040 | struct listnode *node; | |
2041 | struct bgp_redist *red; | |
2042 | ||
a4d82a8a PZ |
2043 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { |
2044 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
7f323236 | 2045 | |
a4d82a8a PZ |
2046 | red_list = bgp->redist[afi][i]; |
2047 | if (!red_list) | |
2048 | continue; | |
7f323236 | 2049 | |
a4d82a8a | 2050 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { |
7f323236 DW |
2051 | bgp_redistribute_resend(bgp, afi, i, |
2052 | red->instance); | |
2053 | } | |
2054 | } | |
2055 | } | |
2056 | } | |
2057 | ||
2058 | /* "bgp graceful-shutdown" configuration */ | |
2059 | DEFUN (bgp_graceful_shutdown, | |
2060 | bgp_graceful_shutdown_cmd, | |
2061 | "bgp graceful-shutdown", | |
2062 | BGP_STR | |
2063 | "Graceful shutdown parameters\n") | |
2064 | { | |
2065 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2066 | ||
2067 | if (!bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
2068 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
2069 | bgp_static_redo_import_check(bgp); | |
2070 | bgp_redistribute_redo(bgp); | |
2071 | bgp_clear_star_soft_out(vty, bgp->name); | |
2072 | bgp_clear_star_soft_in(vty, bgp->name); | |
2073 | } | |
2074 | ||
2075 | return CMD_SUCCESS; | |
2076 | } | |
2077 | ||
2078 | DEFUN (no_bgp_graceful_shutdown, | |
2079 | no_bgp_graceful_shutdown_cmd, | |
2080 | "no bgp graceful-shutdown", | |
2081 | NO_STR | |
2082 | BGP_STR | |
2083 | "Graceful shutdown parameters\n") | |
2084 | { | |
2085 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2086 | ||
2087 | if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
2088 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
2089 | bgp_static_redo_import_check(bgp); | |
2090 | bgp_redistribute_redo(bgp); | |
2091 | bgp_clear_star_soft_out(vty, bgp->name); | |
2092 | bgp_clear_star_soft_in(vty, bgp->name); | |
2093 | } | |
2094 | ||
2095 | return CMD_SUCCESS; | |
2096 | } | |
2097 | ||
718e3744 | 2098 | /* "bgp fast-external-failover" configuration. */ |
2099 | DEFUN (bgp_fast_external_failover, | |
2100 | bgp_fast_external_failover_cmd, | |
2101 | "bgp fast-external-failover", | |
2102 | BGP_STR | |
2103 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2104 | { | |
d62a17ae | 2105 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2106 | bgp_flag_unset(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
2107 | return CMD_SUCCESS; | |
718e3744 | 2108 | } |
2109 | ||
2110 | DEFUN (no_bgp_fast_external_failover, | |
2111 | no_bgp_fast_external_failover_cmd, | |
2112 | "no bgp fast-external-failover", | |
2113 | NO_STR | |
2114 | BGP_STR | |
2115 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2116 | { | |
d62a17ae | 2117 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2118 | bgp_flag_set(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
2119 | return CMD_SUCCESS; | |
718e3744 | 2120 | } |
6b0655a2 | 2121 | |
718e3744 | 2122 | /* "bgp enforce-first-as" configuration. */ |
ec4f0750 | 2123 | #if CONFDATE > 20190517 |
47cbc09b PM |
2124 | CPP_NOTICE("bgpd: remove deprecated '[no] bgp enforce-first-as' commands") |
2125 | #endif | |
2126 | ||
f07e1c4f QY |
2127 | DEFUN_HIDDEN (bgp_enforce_first_as, |
2128 | bgp_enforce_first_as_cmd, | |
2129 | "[no] bgp enforce-first-as", | |
2130 | NO_STR | |
2131 | BGP_STR | |
2132 | "Enforce the first AS for EBGP routes\n") | |
718e3744 | 2133 | { |
d62a17ae | 2134 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2135 | |
f07e1c4f QY |
2136 | if (strmatch(argv[0]->text, "no")) |
2137 | bgp_flag_unset(bgp, BGP_FLAG_ENFORCE_FIRST_AS); | |
2138 | else | |
2139 | bgp_flag_set(bgp, BGP_FLAG_ENFORCE_FIRST_AS); | |
7aafcaca | 2140 | |
d62a17ae | 2141 | return CMD_SUCCESS; |
718e3744 | 2142 | } |
6b0655a2 | 2143 | |
718e3744 | 2144 | /* "bgp bestpath compare-routerid" configuration. */ |
2145 | DEFUN (bgp_bestpath_compare_router_id, | |
2146 | bgp_bestpath_compare_router_id_cmd, | |
2147 | "bgp bestpath compare-routerid", | |
2148 | "BGP specific commands\n" | |
2149 | "Change the default bestpath selection\n" | |
2150 | "Compare router-id for identical EBGP paths\n") | |
2151 | { | |
d62a17ae | 2152 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2153 | bgp_flag_set(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
2154 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2155 | |
d62a17ae | 2156 | return CMD_SUCCESS; |
718e3744 | 2157 | } |
2158 | ||
2159 | DEFUN (no_bgp_bestpath_compare_router_id, | |
2160 | no_bgp_bestpath_compare_router_id_cmd, | |
2161 | "no bgp bestpath compare-routerid", | |
2162 | NO_STR | |
2163 | "BGP specific commands\n" | |
2164 | "Change the default bestpath selection\n" | |
2165 | "Compare router-id for identical EBGP paths\n") | |
2166 | { | |
d62a17ae | 2167 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2168 | bgp_flag_unset(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
2169 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2170 | |
d62a17ae | 2171 | return CMD_SUCCESS; |
718e3744 | 2172 | } |
6b0655a2 | 2173 | |
718e3744 | 2174 | /* "bgp bestpath as-path ignore" configuration. */ |
2175 | DEFUN (bgp_bestpath_aspath_ignore, | |
2176 | bgp_bestpath_aspath_ignore_cmd, | |
2177 | "bgp bestpath as-path ignore", | |
2178 | "BGP specific commands\n" | |
2179 | "Change the default bestpath selection\n" | |
2180 | "AS-path attribute\n" | |
2181 | "Ignore as-path length in selecting a route\n") | |
2182 | { | |
d62a17ae | 2183 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2184 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2185 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2186 | |
d62a17ae | 2187 | return CMD_SUCCESS; |
718e3744 | 2188 | } |
2189 | ||
2190 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
2191 | no_bgp_bestpath_aspath_ignore_cmd, | |
2192 | "no bgp bestpath as-path ignore", | |
2193 | NO_STR | |
2194 | "BGP specific commands\n" | |
2195 | "Change the default bestpath selection\n" | |
2196 | "AS-path attribute\n" | |
2197 | "Ignore as-path length in selecting a route\n") | |
2198 | { | |
d62a17ae | 2199 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2200 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2201 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2202 | |
d62a17ae | 2203 | return CMD_SUCCESS; |
718e3744 | 2204 | } |
6b0655a2 | 2205 | |
6811845b | 2206 | /* "bgp bestpath as-path confed" configuration. */ |
2207 | DEFUN (bgp_bestpath_aspath_confed, | |
2208 | bgp_bestpath_aspath_confed_cmd, | |
2209 | "bgp bestpath as-path confed", | |
2210 | "BGP specific commands\n" | |
2211 | "Change the default bestpath selection\n" | |
2212 | "AS-path attribute\n" | |
2213 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2214 | { | |
d62a17ae | 2215 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2216 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_CONFED); | |
2217 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2218 | |
d62a17ae | 2219 | return CMD_SUCCESS; |
6811845b | 2220 | } |
2221 | ||
2222 | DEFUN (no_bgp_bestpath_aspath_confed, | |
2223 | no_bgp_bestpath_aspath_confed_cmd, | |
2224 | "no bgp bestpath as-path confed", | |
2225 | NO_STR | |
2226 | "BGP specific commands\n" | |
2227 | "Change the default bestpath selection\n" | |
2228 | "AS-path attribute\n" | |
2229 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2230 | { | |
d62a17ae | 2231 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2232 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_CONFED); | |
2233 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2234 | |
d62a17ae | 2235 | return CMD_SUCCESS; |
6811845b | 2236 | } |
6b0655a2 | 2237 | |
2fdd455c PM |
2238 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
2239 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
2240 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2241 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2242 | "BGP specific commands\n" |
2243 | "Change the default bestpath selection\n" | |
2244 | "AS-path attribute\n" | |
2245 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2246 | "Generate an AS_SET\n" |
16fc1eec DS |
2247 | "Do not generate an AS_SET\n") |
2248 | { | |
d62a17ae | 2249 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2250 | int idx = 0; | |
2251 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
219178b6 | 2252 | |
d62a17ae | 2253 | /* no-as-set is now the default behavior so we can silently |
2254 | * ignore it */ | |
2255 | if (argv_find(argv, argc, "as-set", &idx)) | |
2256 | bgp_flag_set(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2257 | else | |
2258 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
219178b6 | 2259 | |
d62a17ae | 2260 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2261 | |
d62a17ae | 2262 | return CMD_SUCCESS; |
16fc1eec DS |
2263 | } |
2264 | ||
219178b6 DW |
2265 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
2266 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2267 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2268 | NO_STR |
2269 | "BGP specific commands\n" | |
2270 | "Change the default bestpath selection\n" | |
2271 | "AS-path attribute\n" | |
2272 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2273 | "Generate an AS_SET\n" |
16fc1eec DS |
2274 | "Do not generate an AS_SET\n") |
2275 | { | |
d62a17ae | 2276 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2277 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
2278 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2279 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2280 | |
d62a17ae | 2281 | return CMD_SUCCESS; |
2fdd455c | 2282 | } |
6b0655a2 | 2283 | |
848973c7 | 2284 | /* "bgp log-neighbor-changes" configuration. */ |
2285 | DEFUN (bgp_log_neighbor_changes, | |
2286 | bgp_log_neighbor_changes_cmd, | |
2287 | "bgp log-neighbor-changes", | |
2288 | "BGP specific commands\n" | |
2289 | "Log neighbor up/down and reset reason\n") | |
2290 | { | |
d62a17ae | 2291 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2292 | bgp_flag_set(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2293 | return CMD_SUCCESS; | |
848973c7 | 2294 | } |
2295 | ||
2296 | DEFUN (no_bgp_log_neighbor_changes, | |
2297 | no_bgp_log_neighbor_changes_cmd, | |
2298 | "no bgp log-neighbor-changes", | |
2299 | NO_STR | |
2300 | "BGP specific commands\n" | |
2301 | "Log neighbor up/down and reset reason\n") | |
2302 | { | |
d62a17ae | 2303 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2304 | bgp_flag_unset(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2305 | return CMD_SUCCESS; | |
848973c7 | 2306 | } |
6b0655a2 | 2307 | |
718e3744 | 2308 | /* "bgp bestpath med" configuration. */ |
2309 | DEFUN (bgp_bestpath_med, | |
2310 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 2311 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2312 | "BGP specific commands\n" |
2313 | "Change the default bestpath selection\n" | |
2314 | "MED attribute\n" | |
2315 | "Compare MED among confederation paths\n" | |
838758ac DW |
2316 | "Treat missing MED as the least preferred one\n" |
2317 | "Treat missing MED as the least preferred one\n" | |
2318 | "Compare MED among confederation paths\n") | |
718e3744 | 2319 | { |
d62a17ae | 2320 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6cbd1915 | 2321 | |
d62a17ae | 2322 | int idx = 0; |
2323 | if (argv_find(argv, argc, "confed", &idx)) | |
2324 | bgp_flag_set(bgp, BGP_FLAG_MED_CONFED); | |
2325 | idx = 0; | |
2326 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2327 | bgp_flag_set(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
e52702f2 | 2328 | |
d62a17ae | 2329 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2330 | |
d62a17ae | 2331 | return CMD_SUCCESS; |
718e3744 | 2332 | } |
2333 | ||
718e3744 | 2334 | DEFUN (no_bgp_bestpath_med, |
2335 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2336 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2337 | NO_STR |
2338 | "BGP specific commands\n" | |
2339 | "Change the default bestpath selection\n" | |
2340 | "MED attribute\n" | |
2341 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2342 | "Treat missing MED as the least preferred one\n" |
2343 | "Treat missing MED as the least preferred one\n" | |
2344 | "Compare MED among confederation paths\n") | |
718e3744 | 2345 | { |
d62a17ae | 2346 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
e52702f2 | 2347 | |
d62a17ae | 2348 | int idx = 0; |
2349 | if (argv_find(argv, argc, "confed", &idx)) | |
2350 | bgp_flag_unset(bgp, BGP_FLAG_MED_CONFED); | |
2351 | idx = 0; | |
2352 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2353 | bgp_flag_unset(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
718e3744 | 2354 | |
d62a17ae | 2355 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2356 | |
d62a17ae | 2357 | return CMD_SUCCESS; |
718e3744 | 2358 | } |
2359 | ||
718e3744 | 2360 | /* "no bgp default ipv4-unicast". */ |
2361 | DEFUN (no_bgp_default_ipv4_unicast, | |
2362 | no_bgp_default_ipv4_unicast_cmd, | |
2363 | "no bgp default ipv4-unicast", | |
2364 | NO_STR | |
2365 | "BGP specific commands\n" | |
2366 | "Configure BGP defaults\n" | |
2367 | "Activate ipv4-unicast for a peer by default\n") | |
2368 | { | |
d62a17ae | 2369 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2370 | bgp_flag_set(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2371 | return CMD_SUCCESS; | |
718e3744 | 2372 | } |
2373 | ||
2374 | DEFUN (bgp_default_ipv4_unicast, | |
2375 | bgp_default_ipv4_unicast_cmd, | |
2376 | "bgp default ipv4-unicast", | |
2377 | "BGP specific commands\n" | |
2378 | "Configure BGP defaults\n" | |
2379 | "Activate ipv4-unicast for a peer by default\n") | |
2380 | { | |
d62a17ae | 2381 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2382 | bgp_flag_unset(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2383 | return CMD_SUCCESS; | |
718e3744 | 2384 | } |
6b0655a2 | 2385 | |
04b6bdc0 DW |
2386 | /* Display hostname in certain command outputs */ |
2387 | DEFUN (bgp_default_show_hostname, | |
2388 | bgp_default_show_hostname_cmd, | |
2389 | "bgp default show-hostname", | |
2390 | "BGP specific commands\n" | |
2391 | "Configure BGP defaults\n" | |
0437e105 | 2392 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 2393 | { |
d62a17ae | 2394 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2395 | bgp_flag_set(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2396 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2397 | } |
2398 | ||
2399 | DEFUN (no_bgp_default_show_hostname, | |
2400 | no_bgp_default_show_hostname_cmd, | |
2401 | "no bgp default show-hostname", | |
2402 | NO_STR | |
2403 | "BGP specific commands\n" | |
2404 | "Configure BGP defaults\n" | |
0437e105 | 2405 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 2406 | { |
d62a17ae | 2407 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2408 | bgp_flag_unset(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2409 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2410 | } |
2411 | ||
8233ef81 | 2412 | /* "bgp network import-check" configuration. */ |
718e3744 | 2413 | DEFUN (bgp_network_import_check, |
2414 | bgp_network_import_check_cmd, | |
5623e905 | 2415 | "bgp network import-check", |
718e3744 | 2416 | "BGP specific commands\n" |
2417 | "BGP network command\n" | |
5623e905 | 2418 | "Check BGP network route exists in IGP\n") |
718e3744 | 2419 | { |
d62a17ae | 2420 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2421 | if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2422 | bgp_flag_set(bgp, BGP_FLAG_IMPORT_CHECK); | |
2423 | bgp_static_redo_import_check(bgp); | |
2424 | } | |
078430f6 | 2425 | |
d62a17ae | 2426 | return CMD_SUCCESS; |
718e3744 | 2427 | } |
2428 | ||
d62a17ae | 2429 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
2430 | "bgp network import-check exact", | |
2431 | "BGP specific commands\n" | |
2432 | "BGP network command\n" | |
2433 | "Check BGP network route exists in IGP\n" | |
2434 | "Match route precisely\n") | |
8233ef81 | 2435 | |
718e3744 | 2436 | DEFUN (no_bgp_network_import_check, |
2437 | no_bgp_network_import_check_cmd, | |
5623e905 | 2438 | "no bgp network import-check", |
718e3744 | 2439 | NO_STR |
2440 | "BGP specific commands\n" | |
2441 | "BGP network command\n" | |
2442 | "Check BGP network route exists in IGP\n") | |
2443 | { | |
d62a17ae | 2444 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2445 | if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2446 | bgp_flag_unset(bgp, BGP_FLAG_IMPORT_CHECK); | |
2447 | bgp_static_redo_import_check(bgp); | |
2448 | } | |
5623e905 | 2449 | |
d62a17ae | 2450 | return CMD_SUCCESS; |
718e3744 | 2451 | } |
6b0655a2 | 2452 | |
718e3744 | 2453 | DEFUN (bgp_default_local_preference, |
2454 | bgp_default_local_preference_cmd, | |
6147e2c6 | 2455 | "bgp default local-preference (0-4294967295)", |
718e3744 | 2456 | "BGP specific commands\n" |
2457 | "Configure BGP defaults\n" | |
2458 | "local preference (higher=more preferred)\n" | |
2459 | "Configure default local preference value\n") | |
2460 | { | |
d62a17ae | 2461 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2462 | int idx_number = 3; | |
d7c0a89a | 2463 | uint32_t local_pref; |
718e3744 | 2464 | |
d62a17ae | 2465 | local_pref = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 2466 | |
d62a17ae | 2467 | bgp_default_local_preference_set(bgp, local_pref); |
2468 | bgp_clear_star_soft_in(vty, bgp->name); | |
718e3744 | 2469 | |
d62a17ae | 2470 | return CMD_SUCCESS; |
718e3744 | 2471 | } |
2472 | ||
2473 | DEFUN (no_bgp_default_local_preference, | |
2474 | no_bgp_default_local_preference_cmd, | |
838758ac | 2475 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 2476 | NO_STR |
2477 | "BGP specific commands\n" | |
2478 | "Configure BGP defaults\n" | |
838758ac DW |
2479 | "local preference (higher=more preferred)\n" |
2480 | "Configure default local preference value\n") | |
718e3744 | 2481 | { |
d62a17ae | 2482 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2483 | bgp_default_local_preference_unset(bgp); | |
2484 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2485 | |
d62a17ae | 2486 | return CMD_SUCCESS; |
718e3744 | 2487 | } |
2488 | ||
6b0655a2 | 2489 | |
3f9c7369 DS |
2490 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
2491 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 2492 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
2493 | "BGP specific commands\n" |
2494 | "Configure BGP defaults\n" | |
2495 | "subgroup-pkt-queue-max\n" | |
2496 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 2497 | { |
d62a17ae | 2498 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2499 | int idx_number = 3; | |
d7c0a89a | 2500 | uint32_t max_size; |
8bd9d948 | 2501 | |
d62a17ae | 2502 | max_size = strtoul(argv[idx_number]->arg, NULL, 10); |
3f9c7369 | 2503 | |
d62a17ae | 2504 | bgp_default_subgroup_pkt_queue_max_set(bgp, max_size); |
3f9c7369 | 2505 | |
d62a17ae | 2506 | return CMD_SUCCESS; |
3f9c7369 DS |
2507 | } |
2508 | ||
2509 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
2510 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 2511 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
2512 | NO_STR |
2513 | "BGP specific commands\n" | |
2514 | "Configure BGP defaults\n" | |
838758ac DW |
2515 | "subgroup-pkt-queue-max\n" |
2516 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 2517 | { |
d62a17ae | 2518 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2519 | bgp_default_subgroup_pkt_queue_max_unset(bgp); | |
2520 | return CMD_SUCCESS; | |
8bd9d948 DS |
2521 | } |
2522 | ||
813d4307 | 2523 | |
8bd9d948 DS |
2524 | DEFUN (bgp_rr_allow_outbound_policy, |
2525 | bgp_rr_allow_outbound_policy_cmd, | |
2526 | "bgp route-reflector allow-outbound-policy", | |
2527 | "BGP specific commands\n" | |
2528 | "Allow modifications made by out route-map\n" | |
2529 | "on ibgp neighbors\n") | |
2530 | { | |
d62a17ae | 2531 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2532 | |
d62a17ae | 2533 | if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2534 | bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2535 | update_group_announce_rrclients(bgp); | |
2536 | bgp_clear_star_soft_out(vty, bgp->name); | |
2537 | } | |
8bd9d948 | 2538 | |
d62a17ae | 2539 | return CMD_SUCCESS; |
8bd9d948 DS |
2540 | } |
2541 | ||
2542 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
2543 | no_bgp_rr_allow_outbound_policy_cmd, | |
2544 | "no bgp route-reflector allow-outbound-policy", | |
2545 | NO_STR | |
2546 | "BGP specific commands\n" | |
2547 | "Allow modifications made by out route-map\n" | |
2548 | "on ibgp neighbors\n") | |
2549 | { | |
d62a17ae | 2550 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2551 | |
d62a17ae | 2552 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2553 | bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2554 | update_group_announce_rrclients(bgp); | |
2555 | bgp_clear_star_soft_out(vty, bgp->name); | |
2556 | } | |
8bd9d948 | 2557 | |
d62a17ae | 2558 | return CMD_SUCCESS; |
8bd9d948 DS |
2559 | } |
2560 | ||
f14e6fdb DS |
2561 | DEFUN (bgp_listen_limit, |
2562 | bgp_listen_limit_cmd, | |
9ccf14f7 | 2563 | "bgp listen limit (1-5000)", |
f14e6fdb DS |
2564 | "BGP specific commands\n" |
2565 | "Configure BGP defaults\n" | |
2566 | "maximum number of BGP Dynamic Neighbors that can be created\n" | |
2567 | "Configure Dynamic Neighbors listen limit value\n") | |
2568 | { | |
d62a17ae | 2569 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2570 | int idx_number = 3; | |
2571 | int listen_limit; | |
f14e6fdb | 2572 | |
d62a17ae | 2573 | listen_limit = strtoul(argv[idx_number]->arg, NULL, 10); |
f14e6fdb | 2574 | |
d62a17ae | 2575 | bgp_listen_limit_set(bgp, listen_limit); |
f14e6fdb | 2576 | |
d62a17ae | 2577 | return CMD_SUCCESS; |
f14e6fdb DS |
2578 | } |
2579 | ||
2580 | DEFUN (no_bgp_listen_limit, | |
2581 | no_bgp_listen_limit_cmd, | |
838758ac | 2582 | "no bgp listen limit [(1-5000)]", |
f14e6fdb DS |
2583 | "BGP specific commands\n" |
2584 | "Configure BGP defaults\n" | |
2585 | "unset maximum number of BGP Dynamic Neighbors that can be created\n" | |
838758ac DW |
2586 | "Configure Dynamic Neighbors listen limit value to default\n" |
2587 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 2588 | { |
d62a17ae | 2589 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2590 | bgp_listen_limit_unset(bgp); | |
2591 | return CMD_SUCCESS; | |
f14e6fdb DS |
2592 | } |
2593 | ||
2594 | ||
20eb8864 | 2595 | /* |
2596 | * Check if this listen range is already configured. Check for exact | |
2597 | * match or overlap based on input. | |
2598 | */ | |
d62a17ae | 2599 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
2600 | struct prefix *range, int exact) | |
2601 | { | |
2602 | struct listnode *node, *nnode; | |
2603 | struct listnode *node1, *nnode1; | |
2604 | struct peer_group *group; | |
2605 | struct prefix *lr; | |
2606 | afi_t afi; | |
2607 | int match; | |
2608 | ||
2609 | afi = family2afi(range->family); | |
2610 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2611 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
2612 | lr)) { | |
2613 | if (exact) | |
2614 | match = prefix_same(range, lr); | |
2615 | else | |
2616 | match = (prefix_match(range, lr) | |
2617 | || prefix_match(lr, range)); | |
2618 | if (match) | |
2619 | return group; | |
2620 | } | |
2621 | } | |
2622 | ||
2623 | return NULL; | |
20eb8864 | 2624 | } |
2625 | ||
f14e6fdb DS |
2626 | DEFUN (bgp_listen_range, |
2627 | bgp_listen_range_cmd, | |
9ccf14f7 | 2628 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
f14e6fdb | 2629 | "BGP specific commands\n" |
d7fa34c1 QY |
2630 | "Configure BGP dynamic neighbors listen range\n" |
2631 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
2632 | NEIGHBOR_ADDR_STR |
2633 | "Member of the peer-group\n" | |
2634 | "Peer-group name\n") | |
f14e6fdb | 2635 | { |
d62a17ae | 2636 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2637 | struct prefix range; | |
2638 | struct peer_group *group, *existing_group; | |
2639 | afi_t afi; | |
2640 | int ret; | |
2641 | int idx = 0; | |
2642 | ||
2643 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2644 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2645 | char *prefix = argv[idx]->arg; | |
2646 | argv_find(argv, argc, "WORD", &idx); | |
2647 | char *peergroup = argv[idx]->arg; | |
2648 | ||
2649 | /* Convert IP prefix string to struct prefix. */ | |
2650 | ret = str2prefix(prefix, &range); | |
2651 | if (!ret) { | |
2652 | vty_out(vty, "%% Malformed listen range\n"); | |
2653 | return CMD_WARNING_CONFIG_FAILED; | |
2654 | } | |
2655 | ||
2656 | afi = family2afi(range.family); | |
2657 | ||
2658 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2659 | vty_out(vty, | |
2660 | "%% Malformed listen range (link-local address)\n"); | |
2661 | return CMD_WARNING_CONFIG_FAILED; | |
2662 | } | |
2663 | ||
2664 | apply_mask(&range); | |
2665 | ||
2666 | /* Check if same listen range is already configured. */ | |
2667 | existing_group = listen_range_exists(bgp, &range, 1); | |
2668 | if (existing_group) { | |
2669 | if (strcmp(existing_group->name, peergroup) == 0) | |
2670 | return CMD_SUCCESS; | |
2671 | else { | |
2672 | vty_out(vty, | |
2673 | "%% Same listen range is attached to peer-group %s\n", | |
2674 | existing_group->name); | |
2675 | return CMD_WARNING_CONFIG_FAILED; | |
2676 | } | |
2677 | } | |
2678 | ||
2679 | /* Check if an overlapping listen range exists. */ | |
2680 | if (listen_range_exists(bgp, &range, 0)) { | |
2681 | vty_out(vty, | |
2682 | "%% Listen range overlaps with existing listen range\n"); | |
2683 | return CMD_WARNING_CONFIG_FAILED; | |
2684 | } | |
2685 | ||
2686 | group = peer_group_lookup(bgp, peergroup); | |
2687 | if (!group) { | |
2688 | vty_out(vty, "%% Configure the peer-group first\n"); | |
2689 | return CMD_WARNING_CONFIG_FAILED; | |
2690 | } | |
2691 | ||
2692 | ret = peer_group_listen_range_add(group, &range); | |
2693 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
2694 | } |
2695 | ||
2696 | DEFUN (no_bgp_listen_range, | |
2697 | no_bgp_listen_range_cmd, | |
d7fa34c1 QY |
2698 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
2699 | NO_STR | |
f14e6fdb | 2700 | "BGP specific commands\n" |
d7fa34c1 QY |
2701 | "Unconfigure BGP dynamic neighbors listen range\n" |
2702 | "Unconfigure BGP dynamic neighbors listen range\n" | |
2703 | NEIGHBOR_ADDR_STR | |
2704 | "Member of the peer-group\n" | |
2705 | "Peer-group name\n") | |
f14e6fdb | 2706 | { |
d62a17ae | 2707 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2708 | struct prefix range; | |
2709 | struct peer_group *group; | |
2710 | afi_t afi; | |
2711 | int ret; | |
2712 | int idx = 0; | |
2713 | ||
2714 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2715 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2716 | char *prefix = argv[idx]->arg; | |
2717 | argv_find(argv, argc, "WORD", &idx); | |
2718 | char *peergroup = argv[idx]->arg; | |
2719 | ||
2720 | /* Convert IP prefix string to struct prefix. */ | |
2721 | ret = str2prefix(prefix, &range); | |
2722 | if (!ret) { | |
2723 | vty_out(vty, "%% Malformed listen range\n"); | |
2724 | return CMD_WARNING_CONFIG_FAILED; | |
2725 | } | |
2726 | ||
2727 | afi = family2afi(range.family); | |
2728 | ||
2729 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2730 | vty_out(vty, | |
2731 | "%% Malformed listen range (link-local address)\n"); | |
2732 | return CMD_WARNING_CONFIG_FAILED; | |
2733 | } | |
2734 | ||
2735 | apply_mask(&range); | |
2736 | ||
2737 | group = peer_group_lookup(bgp, peergroup); | |
2738 | if (!group) { | |
2739 | vty_out(vty, "%% Peer-group does not exist\n"); | |
2740 | return CMD_WARNING_CONFIG_FAILED; | |
2741 | } | |
2742 | ||
2743 | ret = peer_group_listen_range_del(group, &range); | |
2744 | return bgp_vty_return(vty, ret); | |
2745 | } | |
2746 | ||
2b791107 | 2747 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 2748 | { |
2749 | struct peer_group *group; | |
2750 | struct listnode *node, *nnode, *rnode, *nrnode; | |
2751 | struct prefix *range; | |
2752 | afi_t afi; | |
2753 | char buf[PREFIX2STR_BUFFER]; | |
2754 | ||
2755 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
2756 | vty_out(vty, " bgp listen limit %d\n", | |
2757 | bgp->dynamic_neighbors_limit); | |
2758 | ||
2759 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2760 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
2761 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
2762 | nrnode, range)) { | |
2763 | prefix2str(range, buf, sizeof(buf)); | |
2764 | vty_out(vty, | |
2765 | " bgp listen range %s peer-group %s\n", | |
2766 | buf, group->name); | |
2767 | } | |
2768 | } | |
2769 | } | |
f14e6fdb DS |
2770 | } |
2771 | ||
2772 | ||
907f92c8 DS |
2773 | DEFUN (bgp_disable_connected_route_check, |
2774 | bgp_disable_connected_route_check_cmd, | |
2775 | "bgp disable-ebgp-connected-route-check", | |
2776 | "BGP specific commands\n" | |
2777 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2778 | { | |
d62a17ae | 2779 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2780 | bgp_flag_set(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2781 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2782 | |
d62a17ae | 2783 | return CMD_SUCCESS; |
907f92c8 DS |
2784 | } |
2785 | ||
2786 | DEFUN (no_bgp_disable_connected_route_check, | |
2787 | no_bgp_disable_connected_route_check_cmd, | |
2788 | "no bgp disable-ebgp-connected-route-check", | |
2789 | NO_STR | |
2790 | "BGP specific commands\n" | |
2791 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2792 | { | |
d62a17ae | 2793 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2794 | bgp_flag_unset(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2795 | bgp_clear_star_soft_in(vty, bgp->name); | |
2796 | ||
2797 | return CMD_SUCCESS; | |
2798 | } | |
2799 | ||
2800 | ||
2801 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, | |
2802 | const char *as_str, afi_t afi, safi_t safi) | |
2803 | { | |
2804 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2805 | int ret; | |
2806 | as_t as; | |
2807 | int as_type = AS_SPECIFIED; | |
2808 | union sockunion su; | |
2809 | ||
2810 | if (as_str[0] == 'i') { | |
2811 | as = 0; | |
2812 | as_type = AS_INTERNAL; | |
2813 | } else if (as_str[0] == 'e') { | |
2814 | as = 0; | |
2815 | as_type = AS_EXTERNAL; | |
2816 | } else { | |
2817 | /* Get AS number. */ | |
2818 | as = strtoul(as_str, NULL, 10); | |
2819 | } | |
2820 | ||
2821 | /* If peer is peer group, call proper function. */ | |
2822 | ret = str2sockunion(peer_str, &su); | |
2823 | if (ret < 0) { | |
2824 | /* Check for peer by interface */ | |
2825 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type, afi, | |
2826 | safi); | |
2827 | if (ret < 0) { | |
2828 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); | |
2829 | if (ret < 0) { | |
2830 | vty_out(vty, | |
d762bcc3 DS |
2831 | "%% Create the peer-group or interface first or specify \"interface\" keyword\n"); |
2832 | vty_out(vty, "%% if using an unnumbered interface neighbor\n"); | |
d62a17ae | 2833 | return CMD_WARNING_CONFIG_FAILED; |
2834 | } | |
2835 | return CMD_SUCCESS; | |
2836 | } | |
2837 | } else { | |
2838 | if (peer_address_self_check(bgp, &su)) { | |
2839 | vty_out(vty, | |
2840 | "%% Can not configure the local system as neighbor\n"); | |
2841 | return CMD_WARNING_CONFIG_FAILED; | |
2842 | } | |
2843 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type, afi, safi); | |
2844 | } | |
2845 | ||
2846 | /* This peer belongs to peer group. */ | |
2847 | switch (ret) { | |
2848 | case BGP_ERR_PEER_GROUP_MEMBER: | |
2849 | vty_out(vty, | |
2850 | "%% Peer-group AS %u. Cannot configure remote-as for member\n", | |
2851 | as); | |
2852 | return CMD_WARNING_CONFIG_FAILED; | |
2853 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
2854 | vty_out(vty, | |
2855 | "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external\n", | |
2856 | as, as_str); | |
2857 | return CMD_WARNING_CONFIG_FAILED; | |
2858 | } | |
2859 | return bgp_vty_return(vty, ret); | |
718e3744 | 2860 | } |
2861 | ||
f26845f9 QY |
2862 | DEFUN (bgp_default_shutdown, |
2863 | bgp_default_shutdown_cmd, | |
2864 | "[no] bgp default shutdown", | |
2865 | NO_STR | |
2866 | BGP_STR | |
2867 | "Configure BGP defaults\n" | |
b012cbe2 | 2868 | "Apply administrative shutdown to newly configured peers\n") |
f26845f9 QY |
2869 | { |
2870 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2871 | bgp->autoshutdown = !strmatch(argv[0]->text, "no"); | |
2872 | return CMD_SUCCESS; | |
2873 | } | |
2874 | ||
718e3744 | 2875 | DEFUN (neighbor_remote_as, |
2876 | neighbor_remote_as_cmd, | |
3a2d747c | 2877 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2878 | NEIGHBOR_STR |
2879 | NEIGHBOR_ADDR_STR2 | |
2880 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 2881 | AS_STR |
3a2d747c QY |
2882 | "Internal BGP peer\n" |
2883 | "External BGP peer\n") | |
718e3744 | 2884 | { |
d62a17ae | 2885 | int idx_peer = 1; |
2886 | int idx_remote_as = 3; | |
2887 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, | |
2888 | argv[idx_remote_as]->arg, AFI_IP, | |
2889 | SAFI_UNICAST); | |
2890 | } | |
2891 | ||
2892 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, | |
2893 | afi_t afi, safi_t safi, int v6only, | |
2894 | const char *peer_group_name, | |
2895 | const char *as_str) | |
2896 | { | |
2897 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2898 | as_t as = 0; | |
2899 | int as_type = AS_UNSPECIFIED; | |
2900 | struct peer *peer; | |
2901 | struct peer_group *group; | |
2902 | int ret = 0; | |
2903 | union sockunion su; | |
2904 | ||
2905 | group = peer_group_lookup(bgp, conf_if); | |
2906 | ||
2907 | if (group) { | |
2908 | vty_out(vty, "%% Name conflict with peer-group \n"); | |
2909 | return CMD_WARNING_CONFIG_FAILED; | |
2910 | } | |
2911 | ||
2912 | if (as_str) { | |
2913 | if (as_str[0] == 'i') { | |
2914 | as_type = AS_INTERNAL; | |
2915 | } else if (as_str[0] == 'e') { | |
2916 | as_type = AS_EXTERNAL; | |
2917 | } else { | |
2918 | /* Get AS number. */ | |
2919 | as = strtoul(as_str, NULL, 10); | |
2920 | as_type = AS_SPECIFIED; | |
2921 | } | |
2922 | } | |
2923 | ||
2924 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
2925 | if (peer) { | |
2926 | if (as_str) | |
cc4d4ce8 | 2927 | ret = peer_remote_as(bgp, NULL, conf_if, &as, as_type, |
d62a17ae | 2928 | afi, safi); |
2929 | } else { | |
2930 | if (bgp_flag_check(bgp, BGP_FLAG_NO_DEFAULT_IPV4) | |
2931 | && afi == AFI_IP && safi == SAFI_UNICAST) | |
2932 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
2933 | as_type, 0, 0, NULL); | |
2934 | else | |
2935 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
2936 | as_type, afi, safi, NULL); | |
2937 | ||
2938 | if (!peer) { | |
2939 | vty_out(vty, "%% BGP failed to create peer\n"); | |
2940 | return CMD_WARNING_CONFIG_FAILED; | |
2941 | } | |
2942 | ||
2943 | if (v6only) | |
527de3dc | 2944 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 2945 | |
2946 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
2947 | * this | |
2948 | * any unnumbered peer in order to not worry about run-time | |
2949 | * transitions | |
2950 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
2951 | * address | |
2952 | * gets deleted later etc.) | |
2953 | */ | |
2954 | if (peer->ifp) | |
2955 | bgp_zebra_initiate_radv(bgp, peer); | |
2956 | } | |
2957 | ||
2958 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
2959 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
2960 | if (v6only) | |
527de3dc | 2961 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 2962 | else |
527de3dc | 2963 | peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 2964 | |
2965 | /* v6only flag changed. Reset bgp seesion */ | |
2966 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2967 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
2968 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2969 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2970 | } else | |
2971 | bgp_session_reset(peer); | |
2972 | } | |
2973 | ||
9fb964de PM |
2974 | if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) { |
2975 | SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE); | |
2976 | SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE); | |
2977 | UNSET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE); | |
2978 | } | |
d62a17ae | 2979 | |
2980 | if (peer_group_name) { | |
2981 | group = peer_group_lookup(bgp, peer_group_name); | |
2982 | if (!group) { | |
2983 | vty_out(vty, "%% Configure the peer-group first\n"); | |
2984 | return CMD_WARNING_CONFIG_FAILED; | |
2985 | } | |
2986 | ||
2987 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
2988 | } | |
2989 | ||
2990 | return bgp_vty_return(vty, ret); | |
a80beece DS |
2991 | } |
2992 | ||
4c48cf63 DW |
2993 | DEFUN (neighbor_interface_config, |
2994 | neighbor_interface_config_cmd, | |
31500417 | 2995 | "neighbor WORD interface [peer-group WORD]", |
4c48cf63 DW |
2996 | NEIGHBOR_STR |
2997 | "Interface name or neighbor tag\n" | |
31500417 DW |
2998 | "Enable BGP on interface\n" |
2999 | "Member of the peer-group\n" | |
16cedbb0 | 3000 | "Peer-group name\n") |
4c48cf63 | 3001 | { |
d62a17ae | 3002 | int idx_word = 1; |
3003 | int idx_peer_group_word = 4; | |
31500417 | 3004 | |
d62a17ae | 3005 | if (argc > idx_peer_group_word) |
3006 | return peer_conf_interface_get( | |
3007 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
3008 | argv[idx_peer_group_word]->arg, NULL); | |
3009 | else | |
3010 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3011 | SAFI_UNICAST, 0, NULL, NULL); | |
4c48cf63 DW |
3012 | } |
3013 | ||
4c48cf63 DW |
3014 | DEFUN (neighbor_interface_config_v6only, |
3015 | neighbor_interface_config_v6only_cmd, | |
31500417 | 3016 | "neighbor WORD interface v6only [peer-group WORD]", |
4c48cf63 DW |
3017 | NEIGHBOR_STR |
3018 | "Interface name or neighbor tag\n" | |
3019 | "Enable BGP on interface\n" | |
31500417 DW |
3020 | "Enable BGP with v6 link-local only\n" |
3021 | "Member of the peer-group\n" | |
16cedbb0 | 3022 | "Peer-group name\n") |
4c48cf63 | 3023 | { |
d62a17ae | 3024 | int idx_word = 1; |
3025 | int idx_peer_group_word = 5; | |
31500417 | 3026 | |
d62a17ae | 3027 | if (argc > idx_peer_group_word) |
3028 | return peer_conf_interface_get( | |
3029 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
3030 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 3031 | |
d62a17ae | 3032 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, |
3033 | SAFI_UNICAST, 1, NULL, NULL); | |
4c48cf63 DW |
3034 | } |
3035 | ||
a80beece | 3036 | |
b3a39dc5 DD |
3037 | DEFUN (neighbor_interface_config_remote_as, |
3038 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 3039 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
3040 | NEIGHBOR_STR |
3041 | "Interface name or neighbor tag\n" | |
3042 | "Enable BGP on interface\n" | |
3a2d747c | 3043 | "Specify a BGP neighbor\n" |
d7fa34c1 | 3044 | AS_STR |
3a2d747c QY |
3045 | "Internal BGP peer\n" |
3046 | "External BGP peer\n") | |
b3a39dc5 | 3047 | { |
d62a17ae | 3048 | int idx_word = 1; |
3049 | int idx_remote_as = 4; | |
3050 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3051 | SAFI_UNICAST, 0, NULL, | |
3052 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
3053 | } |
3054 | ||
3055 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
3056 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 3057 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
3058 | NEIGHBOR_STR |
3059 | "Interface name or neighbor tag\n" | |
3a2d747c | 3060 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 3061 | "Enable BGP on interface\n" |
3a2d747c | 3062 | "Specify a BGP neighbor\n" |
d7fa34c1 | 3063 | AS_STR |
3a2d747c QY |
3064 | "Internal BGP peer\n" |
3065 | "External BGP peer\n") | |
b3a39dc5 | 3066 | { |
d62a17ae | 3067 | int idx_word = 1; |
3068 | int idx_remote_as = 5; | |
3069 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3070 | SAFI_UNICAST, 1, NULL, | |
3071 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
3072 | } |
3073 | ||
718e3744 | 3074 | DEFUN (neighbor_peer_group, |
3075 | neighbor_peer_group_cmd, | |
3076 | "neighbor WORD peer-group", | |
3077 | NEIGHBOR_STR | |
a80beece | 3078 | "Interface name or neighbor tag\n" |
718e3744 | 3079 | "Configure peer-group\n") |
3080 | { | |
d62a17ae | 3081 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3082 | int idx_word = 1; | |
3083 | struct peer *peer; | |
3084 | struct peer_group *group; | |
718e3744 | 3085 | |
d62a17ae | 3086 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
3087 | if (peer) { | |
3088 | vty_out(vty, "%% Name conflict with interface: \n"); | |
3089 | return CMD_WARNING_CONFIG_FAILED; | |
3090 | } | |
718e3744 | 3091 | |
d62a17ae | 3092 | group = peer_group_get(bgp, argv[idx_word]->arg); |
3093 | if (!group) { | |
3094 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
3095 | return CMD_WARNING_CONFIG_FAILED; | |
3096 | } | |
718e3744 | 3097 | |
d62a17ae | 3098 | return CMD_SUCCESS; |
718e3744 | 3099 | } |
3100 | ||
3101 | DEFUN (no_neighbor, | |
3102 | no_neighbor_cmd, | |
dab8cd00 | 3103 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 3104 | NO_STR |
3105 | NEIGHBOR_STR | |
3a2d747c QY |
3106 | NEIGHBOR_ADDR_STR2 |
3107 | "Specify a BGP neighbor\n" | |
3108 | AS_STR | |
3109 | "Internal BGP peer\n" | |
3110 | "External BGP peer\n") | |
718e3744 | 3111 | { |
d62a17ae | 3112 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3113 | int idx_peer = 2; | |
3114 | int ret; | |
3115 | union sockunion su; | |
3116 | struct peer_group *group; | |
3117 | struct peer *peer; | |
3118 | struct peer *other; | |
3119 | ||
3120 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
3121 | if (ret < 0) { | |
3122 | /* look up for neighbor by interface name config. */ | |
3123 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3124 | if (peer) { | |
3125 | /* Request zebra to terminate IPv6 RAs on this | |
3126 | * interface. */ | |
3127 | if (peer->ifp) | |
3128 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
3129 | peer_delete(peer); | |
3130 | return CMD_SUCCESS; | |
3131 | } | |
f14e6fdb | 3132 | |
d62a17ae | 3133 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); |
3134 | if (group) | |
3135 | peer_group_delete(group); | |
3136 | else { | |
3137 | vty_out(vty, "%% Create the peer-group first\n"); | |
3138 | return CMD_WARNING_CONFIG_FAILED; | |
3139 | } | |
3140 | } else { | |
3141 | peer = peer_lookup(bgp, &su); | |
3142 | if (peer) { | |
3143 | if (peer_dynamic_neighbor(peer)) { | |
3144 | vty_out(vty, | |
3145 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3146 | return CMD_WARNING_CONFIG_FAILED; | |
3147 | } | |
3148 | ||
3149 | other = peer->doppelganger; | |
3150 | peer_delete(peer); | |
3151 | if (other && other->status != Deleted) | |
3152 | peer_delete(other); | |
3153 | } | |
1ff9a340 | 3154 | } |
718e3744 | 3155 | |
d62a17ae | 3156 | return CMD_SUCCESS; |
718e3744 | 3157 | } |
3158 | ||
a80beece DS |
3159 | DEFUN (no_neighbor_interface_config, |
3160 | no_neighbor_interface_config_cmd, | |
31500417 | 3161 | "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
3162 | NO_STR |
3163 | NEIGHBOR_STR | |
3164 | "Interface name\n" | |
31500417 DW |
3165 | "Configure BGP on interface\n" |
3166 | "Enable BGP with v6 link-local only\n" | |
3167 | "Member of the peer-group\n" | |
16cedbb0 | 3168 | "Peer-group name\n" |
3a2d747c QY |
3169 | "Specify a BGP neighbor\n" |
3170 | AS_STR | |
3171 | "Internal BGP peer\n" | |
3172 | "External BGP peer\n") | |
a80beece | 3173 | { |
d62a17ae | 3174 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3175 | int idx_word = 2; | |
3176 | struct peer *peer; | |
3177 | ||
3178 | /* look up for neighbor by interface name config. */ | |
3179 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3180 | if (peer) { | |
3181 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
3182 | if (peer->ifp) | |
3183 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
3184 | peer_delete(peer); | |
3185 | } else { | |
3186 | vty_out(vty, "%% Create the bgp interface first\n"); | |
3187 | return CMD_WARNING_CONFIG_FAILED; | |
3188 | } | |
3189 | return CMD_SUCCESS; | |
a80beece DS |
3190 | } |
3191 | ||
718e3744 | 3192 | DEFUN (no_neighbor_peer_group, |
3193 | no_neighbor_peer_group_cmd, | |
3194 | "no neighbor WORD peer-group", | |
3195 | NO_STR | |
3196 | NEIGHBOR_STR | |
3197 | "Neighbor tag\n" | |
3198 | "Configure peer-group\n") | |
3199 | { | |
d62a17ae | 3200 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3201 | int idx_word = 2; | |
3202 | struct peer_group *group; | |
718e3744 | 3203 | |
d62a17ae | 3204 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
3205 | if (group) | |
3206 | peer_group_delete(group); | |
3207 | else { | |
3208 | vty_out(vty, "%% Create the peer-group first\n"); | |
3209 | return CMD_WARNING_CONFIG_FAILED; | |
3210 | } | |
3211 | return CMD_SUCCESS; | |
718e3744 | 3212 | } |
3213 | ||
a80beece DS |
3214 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
3215 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 3216 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3217 | NO_STR |
3218 | NEIGHBOR_STR | |
a80beece | 3219 | "Interface name or neighbor tag\n" |
718e3744 | 3220 | "Specify a BGP neighbor\n" |
3a2d747c QY |
3221 | AS_STR |
3222 | "Internal BGP peer\n" | |
3223 | "External BGP peer\n") | |
718e3744 | 3224 | { |
d62a17ae | 3225 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3226 | int idx_word = 2; | |
3227 | struct peer_group *group; | |
3228 | struct peer *peer; | |
3229 | ||
3230 | /* look up for neighbor by interface name config. */ | |
3231 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3232 | if (peer) { | |
3233 | peer_as_change(peer, 0, AS_SPECIFIED); | |
3234 | return CMD_SUCCESS; | |
3235 | } | |
3236 | ||
3237 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3238 | if (group) | |
3239 | peer_group_remote_as_delete(group); | |
3240 | else { | |
3241 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
3242 | return CMD_WARNING_CONFIG_FAILED; | |
3243 | } | |
3244 | return CMD_SUCCESS; | |
718e3744 | 3245 | } |
6b0655a2 | 3246 | |
718e3744 | 3247 | DEFUN (neighbor_local_as, |
3248 | neighbor_local_as_cmd, | |
9ccf14f7 | 3249 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 3250 | NEIGHBOR_STR |
3251 | NEIGHBOR_ADDR_STR2 | |
3252 | "Specify a local-as number\n" | |
3253 | "AS number used as local AS\n") | |
3254 | { | |
d62a17ae | 3255 | int idx_peer = 1; |
3256 | int idx_number = 3; | |
3257 | struct peer *peer; | |
3258 | int ret; | |
3259 | as_t as; | |
718e3744 | 3260 | |
d62a17ae | 3261 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3262 | if (!peer) | |
3263 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3264 | |
d62a17ae | 3265 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3266 | ret = peer_local_as_set(peer, as, 0, 0); | |
3267 | return bgp_vty_return(vty, ret); | |
718e3744 | 3268 | } |
3269 | ||
3270 | DEFUN (neighbor_local_as_no_prepend, | |
3271 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 3272 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 3273 | NEIGHBOR_STR |
3274 | NEIGHBOR_ADDR_STR2 | |
3275 | "Specify a local-as number\n" | |
3276 | "AS number used as local AS\n" | |
3277 | "Do not prepend local-as to updates from ebgp peers\n") | |
3278 | { | |
d62a17ae | 3279 | int idx_peer = 1; |
3280 | int idx_number = 3; | |
3281 | struct peer *peer; | |
3282 | int ret; | |
3283 | as_t as; | |
718e3744 | 3284 | |
d62a17ae | 3285 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3286 | if (!peer) | |
3287 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3288 | |
d62a17ae | 3289 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3290 | ret = peer_local_as_set(peer, as, 1, 0); | |
3291 | return bgp_vty_return(vty, ret); | |
718e3744 | 3292 | } |
3293 | ||
9d3f9705 AC |
3294 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
3295 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 3296 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
3297 | NEIGHBOR_STR |
3298 | NEIGHBOR_ADDR_STR2 | |
3299 | "Specify a local-as number\n" | |
3300 | "AS number used as local AS\n" | |
3301 | "Do not prepend local-as to updates from ebgp peers\n" | |
3302 | "Do not prepend local-as to updates from ibgp peers\n") | |
3303 | { | |
d62a17ae | 3304 | int idx_peer = 1; |
3305 | int idx_number = 3; | |
3306 | struct peer *peer; | |
3307 | int ret; | |
3308 | as_t as; | |
9d3f9705 | 3309 | |
d62a17ae | 3310 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3311 | if (!peer) | |
3312 | return CMD_WARNING_CONFIG_FAILED; | |
9d3f9705 | 3313 | |
d62a17ae | 3314 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3315 | ret = peer_local_as_set(peer, as, 1, 1); | |
3316 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
3317 | } |
3318 | ||
718e3744 | 3319 | DEFUN (no_neighbor_local_as, |
3320 | no_neighbor_local_as_cmd, | |
a636c635 | 3321 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 3322 | NO_STR |
3323 | NEIGHBOR_STR | |
3324 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
3325 | "Specify a local-as number\n" |
3326 | "AS number used as local AS\n" | |
3327 | "Do not prepend local-as to updates from ebgp peers\n" | |
3328 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 3329 | { |
d62a17ae | 3330 | int idx_peer = 2; |
3331 | struct peer *peer; | |
3332 | int ret; | |
718e3744 | 3333 | |
d62a17ae | 3334 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3335 | if (!peer) | |
3336 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3337 | |
d62a17ae | 3338 | ret = peer_local_as_unset(peer); |
3339 | return bgp_vty_return(vty, ret); | |
718e3744 | 3340 | } |
3341 | ||
718e3744 | 3342 | |
3f9c7369 DS |
3343 | DEFUN (neighbor_solo, |
3344 | neighbor_solo_cmd, | |
9ccf14f7 | 3345 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3346 | NEIGHBOR_STR |
3347 | NEIGHBOR_ADDR_STR2 | |
3348 | "Solo peer - part of its own update group\n") | |
3349 | { | |
d62a17ae | 3350 | int idx_peer = 1; |
3351 | struct peer *peer; | |
3352 | int ret; | |
3f9c7369 | 3353 | |
d62a17ae | 3354 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3355 | if (!peer) | |
3356 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3357 | |
d62a17ae | 3358 | ret = update_group_adjust_soloness(peer, 1); |
3359 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3360 | } |
3361 | ||
3362 | DEFUN (no_neighbor_solo, | |
3363 | no_neighbor_solo_cmd, | |
9ccf14f7 | 3364 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3365 | NO_STR |
3366 | NEIGHBOR_STR | |
3367 | NEIGHBOR_ADDR_STR2 | |
3368 | "Solo peer - part of its own update group\n") | |
3369 | { | |
d62a17ae | 3370 | int idx_peer = 2; |
3371 | struct peer *peer; | |
3372 | int ret; | |
3f9c7369 | 3373 | |
d62a17ae | 3374 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3375 | if (!peer) | |
3376 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3377 | |
d62a17ae | 3378 | ret = update_group_adjust_soloness(peer, 0); |
3379 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3380 | } |
3381 | ||
0df7c91f PJ |
3382 | DEFUN (neighbor_password, |
3383 | neighbor_password_cmd, | |
9ccf14f7 | 3384 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
3385 | NEIGHBOR_STR |
3386 | NEIGHBOR_ADDR_STR2 | |
3387 | "Set a password\n" | |
3388 | "The password\n") | |
3389 | { | |
d62a17ae | 3390 | int idx_peer = 1; |
3391 | int idx_line = 3; | |
3392 | struct peer *peer; | |
3393 | int ret; | |
0df7c91f | 3394 | |
d62a17ae | 3395 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3396 | if (!peer) | |
3397 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3398 | |
d62a17ae | 3399 | ret = peer_password_set(peer, argv[idx_line]->arg); |
3400 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
3401 | } |
3402 | ||
3403 | DEFUN (no_neighbor_password, | |
3404 | no_neighbor_password_cmd, | |
a636c635 | 3405 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
3406 | NO_STR |
3407 | NEIGHBOR_STR | |
3408 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
3409 | "Set a password\n" |
3410 | "The password\n") | |
0df7c91f | 3411 | { |
d62a17ae | 3412 | int idx_peer = 2; |
3413 | struct peer *peer; | |
3414 | int ret; | |
0df7c91f | 3415 | |
d62a17ae | 3416 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3417 | if (!peer) | |
3418 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3419 | |
d62a17ae | 3420 | ret = peer_password_unset(peer); |
3421 | return bgp_vty_return(vty, ret); | |
0df7c91f | 3422 | } |
6b0655a2 | 3423 | |
718e3744 | 3424 | DEFUN (neighbor_activate, |
3425 | neighbor_activate_cmd, | |
9ccf14f7 | 3426 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3427 | NEIGHBOR_STR |
3428 | NEIGHBOR_ADDR_STR2 | |
3429 | "Enable the Address Family for this Neighbor\n") | |
3430 | { | |
d62a17ae | 3431 | int idx_peer = 1; |
3432 | int ret; | |
3433 | struct peer *peer; | |
718e3744 | 3434 | |
d62a17ae | 3435 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3436 | if (!peer) | |
3437 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3438 | |
d62a17ae | 3439 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3440 | return bgp_vty_return(vty, ret); | |
718e3744 | 3441 | } |
3442 | ||
d62a17ae | 3443 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
3444 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3445 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3446 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3447 | |
718e3744 | 3448 | DEFUN (no_neighbor_activate, |
3449 | no_neighbor_activate_cmd, | |
9ccf14f7 | 3450 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3451 | NO_STR |
3452 | NEIGHBOR_STR | |
3453 | NEIGHBOR_ADDR_STR2 | |
3454 | "Enable the Address Family for this Neighbor\n") | |
3455 | { | |
d62a17ae | 3456 | int idx_peer = 2; |
3457 | int ret; | |
3458 | struct peer *peer; | |
718e3744 | 3459 | |
d62a17ae | 3460 | /* Lookup peer. */ |
3461 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3462 | if (!peer) | |
3463 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3464 | |
d62a17ae | 3465 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3466 | return bgp_vty_return(vty, ret); | |
718e3744 | 3467 | } |
6b0655a2 | 3468 | |
d62a17ae | 3469 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
3470 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3471 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3472 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3473 | |
718e3744 | 3474 | DEFUN (neighbor_set_peer_group, |
3475 | neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3476 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3477 | NEIGHBOR_STR |
a80beece | 3478 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3479 | "Member of the peer-group\n" |
16cedbb0 | 3480 | "Peer-group name\n") |
718e3744 | 3481 | { |
d62a17ae | 3482 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3483 | int idx_peer = 1; | |
3484 | int idx_word = 3; | |
3485 | int ret; | |
3486 | as_t as; | |
3487 | union sockunion su; | |
3488 | struct peer *peer; | |
3489 | struct peer_group *group; | |
3490 | ||
d62a17ae | 3491 | ret = str2sockunion(argv[idx_peer]->arg, &su); |
3492 | if (ret < 0) { | |
3493 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3494 | if (!peer) { | |
3495 | vty_out(vty, "%% Malformed address or name: %s\n", | |
3496 | argv[idx_peer]->arg); | |
3497 | return CMD_WARNING_CONFIG_FAILED; | |
3498 | } | |
3499 | } else { | |
3500 | if (peer_address_self_check(bgp, &su)) { | |
3501 | vty_out(vty, | |
3502 | "%% Can not configure the local system as neighbor\n"); | |
3503 | return CMD_WARNING_CONFIG_FAILED; | |
3504 | } | |
3505 | ||
3506 | /* Disallow for dynamic neighbor. */ | |
3507 | peer = peer_lookup(bgp, &su); | |
3508 | if (peer && peer_dynamic_neighbor(peer)) { | |
3509 | vty_out(vty, | |
3510 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3511 | return CMD_WARNING_CONFIG_FAILED; | |
3512 | } | |
3513 | } | |
3514 | ||
3515 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3516 | if (!group) { | |
3517 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3518 | return CMD_WARNING_CONFIG_FAILED; | |
3519 | } | |
3520 | ||
3521 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
3522 | ||
3523 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { | |
3524 | vty_out(vty, | |
3525 | "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", | |
3526 | as); | |
3527 | return CMD_WARNING_CONFIG_FAILED; | |
3528 | } | |
3529 | ||
3530 | return bgp_vty_return(vty, ret); | |
3531 | } | |
3532 | ||
3533 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
3534 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", | |
3535 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3536 | "Member of the peer-group\n" | |
3537 | "Peer-group name\n") | |
596c17ba | 3538 | |
718e3744 | 3539 | DEFUN (no_neighbor_set_peer_group, |
3540 | no_neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3541 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3542 | NO_STR |
3543 | NEIGHBOR_STR | |
a80beece | 3544 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3545 | "Member of the peer-group\n" |
16cedbb0 | 3546 | "Peer-group name\n") |
718e3744 | 3547 | { |
d62a17ae | 3548 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3549 | int idx_peer = 2; | |
3550 | int idx_word = 4; | |
3551 | int ret; | |
3552 | struct peer *peer; | |
3553 | struct peer_group *group; | |
3554 | ||
3555 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); | |
3556 | if (!peer) | |
3557 | return CMD_WARNING_CONFIG_FAILED; | |
3558 | ||
3559 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3560 | if (!group) { | |
3561 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3562 | return CMD_WARNING_CONFIG_FAILED; | |
3563 | } | |
718e3744 | 3564 | |
827ed707 | 3565 | ret = peer_delete(peer); |
718e3744 | 3566 | |
d62a17ae | 3567 | return bgp_vty_return(vty, ret); |
718e3744 | 3568 | } |
6b0655a2 | 3569 | |
d62a17ae | 3570 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
3571 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", | |
3572 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3573 | "Member of the peer-group\n" | |
3574 | "Peer-group name\n") | |
596c17ba | 3575 | |
d62a17ae | 3576 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 3577 | uint32_t flag, int set) |
718e3744 | 3578 | { |
d62a17ae | 3579 | int ret; |
3580 | struct peer *peer; | |
718e3744 | 3581 | |
d62a17ae | 3582 | peer = peer_and_group_lookup_vty(vty, ip_str); |
3583 | if (!peer) | |
3584 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3585 | |
7ebe625c QY |
3586 | /* |
3587 | * If 'neighbor <interface>', then this is for directly connected peers, | |
3588 | * we should not accept disable-connected-check. | |
3589 | */ | |
3590 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
3591 | vty_out(vty, | |
3592 | "%s is directly connected peer, cannot accept disable-" | |
3593 | "connected-check\n", | |
3594 | ip_str); | |
3595 | return CMD_WARNING_CONFIG_FAILED; | |
3596 | } | |
3597 | ||
d62a17ae | 3598 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
3599 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 3600 | |
d62a17ae | 3601 | if (set) |
3602 | ret = peer_flag_set(peer, flag); | |
3603 | else | |
3604 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 3605 | |
d62a17ae | 3606 | return bgp_vty_return(vty, ret); |
718e3744 | 3607 | } |
3608 | ||
47cbc09b | 3609 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint32_t flag) |
718e3744 | 3610 | { |
d62a17ae | 3611 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 3612 | } |
3613 | ||
d62a17ae | 3614 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 3615 | uint32_t flag) |
718e3744 | 3616 | { |
d62a17ae | 3617 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 3618 | } |
3619 | ||
3620 | /* neighbor passive. */ | |
3621 | DEFUN (neighbor_passive, | |
3622 | neighbor_passive_cmd, | |
9ccf14f7 | 3623 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3624 | NEIGHBOR_STR |
3625 | NEIGHBOR_ADDR_STR2 | |
3626 | "Don't send open messages to this neighbor\n") | |
3627 | { | |
d62a17ae | 3628 | int idx_peer = 1; |
3629 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3630 | } |
3631 | ||
3632 | DEFUN (no_neighbor_passive, | |
3633 | no_neighbor_passive_cmd, | |
9ccf14f7 | 3634 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3635 | NO_STR |
3636 | NEIGHBOR_STR | |
3637 | NEIGHBOR_ADDR_STR2 | |
3638 | "Don't send open messages to this neighbor\n") | |
3639 | { | |
d62a17ae | 3640 | int idx_peer = 2; |
3641 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3642 | } |
6b0655a2 | 3643 | |
718e3744 | 3644 | /* neighbor shutdown. */ |
73d70fa6 DL |
3645 | DEFUN (neighbor_shutdown_msg, |
3646 | neighbor_shutdown_msg_cmd, | |
3647 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
718e3744 | 3648 | NEIGHBOR_STR |
3649 | NEIGHBOR_ADDR_STR2 | |
73d70fa6 DL |
3650 | "Administratively shut down this neighbor\n" |
3651 | "Add a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3652 | "Shutdown message\n") | |
718e3744 | 3653 | { |
d62a17ae | 3654 | int idx_peer = 1; |
73d70fa6 | 3655 | |
d62a17ae | 3656 | if (argc >= 5) { |
3657 | struct peer *peer = | |
3658 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3659 | char *message; | |
73d70fa6 | 3660 | |
d62a17ae | 3661 | if (!peer) |
3662 | return CMD_WARNING_CONFIG_FAILED; | |
3663 | message = argv_concat(argv, argc, 4); | |
3664 | peer_tx_shutdown_message_set(peer, message); | |
3665 | XFREE(MTYPE_TMP, message); | |
3666 | } | |
73d70fa6 | 3667 | |
d62a17ae | 3668 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 3669 | } |
3670 | ||
d62a17ae | 3671 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
3672 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3673 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3674 | "Administratively shut down this neighbor\n") | |
73d70fa6 DL |
3675 | |
3676 | DEFUN (no_neighbor_shutdown_msg, | |
3677 | no_neighbor_shutdown_msg_cmd, | |
3678 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
3679 | NO_STR | |
3680 | NEIGHBOR_STR | |
3681 | NEIGHBOR_ADDR_STR2 | |
3682 | "Administratively shut down this neighbor\n" | |
3683 | "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3684 | "Shutdown message\n") | |
718e3744 | 3685 | { |
d62a17ae | 3686 | int idx_peer = 2; |
73d70fa6 | 3687 | |
d62a17ae | 3688 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
3689 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 3690 | } |
6b0655a2 | 3691 | |
d62a17ae | 3692 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
3693 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3694 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3695 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 3696 | |
718e3744 | 3697 | /* neighbor capability dynamic. */ |
3698 | DEFUN (neighbor_capability_dynamic, | |
3699 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3700 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3701 | NEIGHBOR_STR |
3702 | NEIGHBOR_ADDR_STR2 | |
3703 | "Advertise capability to the peer\n" | |
3704 | "Advertise dynamic capability to this neighbor\n") | |
3705 | { | |
d62a17ae | 3706 | int idx_peer = 1; |
3707 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3708 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3709 | } |
3710 | ||
3711 | DEFUN (no_neighbor_capability_dynamic, | |
3712 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3713 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3714 | NO_STR |
3715 | NEIGHBOR_STR | |
3716 | NEIGHBOR_ADDR_STR2 | |
3717 | "Advertise capability to the peer\n" | |
3718 | "Advertise dynamic capability to this neighbor\n") | |
3719 | { | |
d62a17ae | 3720 | int idx_peer = 2; |
3721 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3722 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3723 | } |
6b0655a2 | 3724 | |
718e3744 | 3725 | /* neighbor dont-capability-negotiate */ |
3726 | DEFUN (neighbor_dont_capability_negotiate, | |
3727 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3728 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3729 | NEIGHBOR_STR |
3730 | NEIGHBOR_ADDR_STR2 | |
3731 | "Do not perform capability negotiation\n") | |
3732 | { | |
d62a17ae | 3733 | int idx_peer = 1; |
3734 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3735 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3736 | } |
3737 | ||
3738 | DEFUN (no_neighbor_dont_capability_negotiate, | |
3739 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3740 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3741 | NO_STR |
3742 | NEIGHBOR_STR | |
3743 | NEIGHBOR_ADDR_STR2 | |
3744 | "Do not perform capability negotiation\n") | |
3745 | { | |
d62a17ae | 3746 | int idx_peer = 2; |
3747 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3748 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3749 | } |
6b0655a2 | 3750 | |
8a92a8a0 DS |
3751 | /* neighbor capability extended next hop encoding */ |
3752 | DEFUN (neighbor_capability_enhe, | |
3753 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3754 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3755 | NEIGHBOR_STR |
3756 | NEIGHBOR_ADDR_STR2 | |
3757 | "Advertise capability to the peer\n" | |
3758 | "Advertise extended next-hop capability to the peer\n") | |
3759 | { | |
d62a17ae | 3760 | int idx_peer = 1; |
3761 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3762 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3763 | } |
3764 | ||
3765 | DEFUN (no_neighbor_capability_enhe, | |
3766 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3767 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3768 | NO_STR |
3769 | NEIGHBOR_STR | |
3770 | NEIGHBOR_ADDR_STR2 | |
3771 | "Advertise capability to the peer\n" | |
3772 | "Advertise extended next-hop capability to the peer\n") | |
3773 | { | |
d62a17ae | 3774 | int idx_peer = 2; |
3775 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3776 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3777 | } |
3778 | ||
d62a17ae | 3779 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3780 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 3781 | int set) |
718e3744 | 3782 | { |
d62a17ae | 3783 | int ret; |
3784 | struct peer *peer; | |
718e3744 | 3785 | |
d62a17ae | 3786 | peer = peer_and_group_lookup_vty(vty, peer_str); |
3787 | if (!peer) | |
3788 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3789 | |
d62a17ae | 3790 | if (set) |
3791 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
3792 | else | |
3793 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 3794 | |
d62a17ae | 3795 | return bgp_vty_return(vty, ret); |
718e3744 | 3796 | } |
3797 | ||
d62a17ae | 3798 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3799 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 3800 | { |
d62a17ae | 3801 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 3802 | } |
3803 | ||
d62a17ae | 3804 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3805 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 3806 | { |
d62a17ae | 3807 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 3808 | } |
6b0655a2 | 3809 | |
718e3744 | 3810 | /* neighbor capability orf prefix-list. */ |
3811 | DEFUN (neighbor_capability_orf_prefix, | |
3812 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3813 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3814 | NEIGHBOR_STR |
3815 | NEIGHBOR_ADDR_STR2 | |
3816 | "Advertise capability to the peer\n" | |
3817 | "Advertise ORF capability to the peer\n" | |
3818 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3819 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3820 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3821 | "Capability to SEND the ORF to this neighbor\n") | |
3822 | { | |
d62a17ae | 3823 | int idx_peer = 1; |
3824 | int idx_send_recv = 5; | |
d7c0a89a | 3825 | uint16_t flag = 0; |
d62a17ae | 3826 | |
3827 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3828 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3829 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3830 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3831 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3832 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3833 | else { | |
3834 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3835 | return CMD_WARNING_CONFIG_FAILED; | |
3836 | } | |
3837 | ||
3838 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3839 | bgp_node_safi(vty), flag); | |
3840 | } | |
3841 | ||
3842 | ALIAS_HIDDEN( | |
3843 | neighbor_capability_orf_prefix, | |
3844 | neighbor_capability_orf_prefix_hidden_cmd, | |
3845 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3846 | 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 | DEFUN (no_neighbor_capability_orf_prefix, |
3855 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3856 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3857 | NO_STR |
3858 | NEIGHBOR_STR | |
3859 | NEIGHBOR_ADDR_STR2 | |
3860 | "Advertise capability to the peer\n" | |
3861 | "Advertise ORF capability to the peer\n" | |
3862 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3863 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3864 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3865 | "Capability to SEND the ORF to this neighbor\n") | |
3866 | { | |
d62a17ae | 3867 | int idx_peer = 2; |
3868 | int idx_send_recv = 6; | |
d7c0a89a | 3869 | uint16_t flag = 0; |
d62a17ae | 3870 | |
3871 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3872 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3873 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3874 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3875 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3876 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3877 | else { | |
3878 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3879 | return CMD_WARNING_CONFIG_FAILED; | |
3880 | } | |
3881 | ||
3882 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3883 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3884 | flag); | |
3885 | } | |
3886 | ||
3887 | ALIAS_HIDDEN( | |
3888 | no_neighbor_capability_orf_prefix, | |
3889 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
3890 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3891 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3892 | "Advertise capability to the peer\n" | |
3893 | "Advertise ORF capability to the peer\n" | |
3894 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3895 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3896 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3897 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 3898 | |
718e3744 | 3899 | /* neighbor next-hop-self. */ |
3900 | DEFUN (neighbor_nexthop_self, | |
3901 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3902 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3903 | NEIGHBOR_STR |
3904 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3905 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3906 | { |
d62a17ae | 3907 | int idx_peer = 1; |
3908 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3909 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 3910 | } |
9e7a53c1 | 3911 | |
d62a17ae | 3912 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
3913 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3914 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3915 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 3916 | |
a538debe DS |
3917 | /* neighbor next-hop-self. */ |
3918 | DEFUN (neighbor_nexthop_self_force, | |
3919 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 3920 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3921 | NEIGHBOR_STR |
3922 | NEIGHBOR_ADDR_STR2 | |
3923 | "Disable the next hop calculation for this neighbor\n" | |
3924 | "Set the next hop to self for reflected routes\n") | |
3925 | { | |
d62a17ae | 3926 | int idx_peer = 1; |
3927 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3928 | bgp_node_safi(vty), | |
3929 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 3930 | } |
3931 | ||
d62a17ae | 3932 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
3933 | neighbor_nexthop_self_force_hidden_cmd, | |
3934 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3935 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3936 | "Disable the next hop calculation for this neighbor\n" | |
3937 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 3938 | |
718e3744 | 3939 | DEFUN (no_neighbor_nexthop_self, |
3940 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3941 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3942 | NO_STR |
3943 | NEIGHBOR_STR | |
3944 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3945 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3946 | { |
d62a17ae | 3947 | int idx_peer = 2; |
3948 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3949 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3950 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 3951 | } |
6b0655a2 | 3952 | |
d62a17ae | 3953 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
3954 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3955 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3956 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 3957 | |
88b8ed8d | 3958 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 3959 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 3960 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3961 | NO_STR |
3962 | NEIGHBOR_STR | |
3963 | NEIGHBOR_ADDR_STR2 | |
3964 | "Disable the next hop calculation for this neighbor\n" | |
3965 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 3966 | { |
d62a17ae | 3967 | int idx_peer = 2; |
3968 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3969 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3970 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 3971 | } |
a538debe | 3972 | |
d62a17ae | 3973 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
3974 | no_neighbor_nexthop_self_force_hidden_cmd, | |
3975 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3976 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3977 | "Disable the next hop calculation for this neighbor\n" | |
3978 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 3979 | |
c7122e14 DS |
3980 | /* neighbor as-override */ |
3981 | DEFUN (neighbor_as_override, | |
3982 | neighbor_as_override_cmd, | |
9ccf14f7 | 3983 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3984 | NEIGHBOR_STR |
3985 | NEIGHBOR_ADDR_STR2 | |
3986 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3987 | { | |
d62a17ae | 3988 | int idx_peer = 1; |
3989 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3990 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
3991 | } |
3992 | ||
d62a17ae | 3993 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
3994 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
3995 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3996 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 3997 | |
c7122e14 DS |
3998 | DEFUN (no_neighbor_as_override, |
3999 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 4000 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
4001 | NO_STR |
4002 | NEIGHBOR_STR | |
4003 | NEIGHBOR_ADDR_STR2 | |
4004 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
4005 | { | |
d62a17ae | 4006 | int idx_peer = 2; |
4007 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4008 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4009 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
4010 | } |
4011 | ||
d62a17ae | 4012 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
4013 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
4014 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4015 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 4016 | |
718e3744 | 4017 | /* neighbor remove-private-AS. */ |
4018 | DEFUN (neighbor_remove_private_as, | |
4019 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4020 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4021 | NEIGHBOR_STR |
4022 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4023 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4024 | { |
d62a17ae | 4025 | int idx_peer = 1; |
4026 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4027 | bgp_node_safi(vty), | |
4028 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4029 | } |
4030 | ||
d62a17ae | 4031 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
4032 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4033 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4034 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4035 | |
5000f21c DS |
4036 | DEFUN (neighbor_remove_private_as_all, |
4037 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 4038 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4039 | NEIGHBOR_STR |
4040 | NEIGHBOR_ADDR_STR2 | |
4041 | "Remove private ASNs in outbound updates\n" | |
efd7904e | 4042 | "Apply to all AS numbers\n") |
5000f21c | 4043 | { |
d62a17ae | 4044 | int idx_peer = 1; |
4045 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4046 | bgp_node_safi(vty), | |
4047 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
4048 | } |
4049 | ||
d62a17ae | 4050 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
4051 | neighbor_remove_private_as_all_hidden_cmd, | |
4052 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4053 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4054 | "Remove private ASNs in outbound updates\n" | |
4055 | "Apply to all AS numbers") | |
596c17ba | 4056 | |
5000f21c DS |
4057 | DEFUN (neighbor_remove_private_as_replace_as, |
4058 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 4059 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4060 | NEIGHBOR_STR |
4061 | NEIGHBOR_ADDR_STR2 | |
4062 | "Remove private ASNs in outbound updates\n" | |
4063 | "Replace private ASNs with our ASN in outbound updates\n") | |
4064 | { | |
d62a17ae | 4065 | int idx_peer = 1; |
4066 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4067 | bgp_node_safi(vty), | |
4068 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
4069 | } |
4070 | ||
d62a17ae | 4071 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
4072 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
4073 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4074 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4075 | "Remove private ASNs in outbound updates\n" | |
4076 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4077 | |
5000f21c DS |
4078 | DEFUN (neighbor_remove_private_as_all_replace_as, |
4079 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 4080 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4081 | NEIGHBOR_STR |
4082 | NEIGHBOR_ADDR_STR2 | |
4083 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4084 | "Apply to all AS numbers\n" |
5000f21c DS |
4085 | "Replace private ASNs with our ASN in outbound updates\n") |
4086 | { | |
d62a17ae | 4087 | int idx_peer = 1; |
4088 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4089 | bgp_node_safi(vty), | |
4090 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
4091 | } |
4092 | ||
d62a17ae | 4093 | ALIAS_HIDDEN( |
4094 | neighbor_remove_private_as_all_replace_as, | |
4095 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4096 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4097 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4098 | "Remove private ASNs in outbound updates\n" | |
4099 | "Apply to all AS numbers\n" | |
4100 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4101 | |
718e3744 | 4102 | DEFUN (no_neighbor_remove_private_as, |
4103 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4104 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4105 | NO_STR |
4106 | NEIGHBOR_STR | |
4107 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4108 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4109 | { |
d62a17ae | 4110 | int idx_peer = 2; |
4111 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4112 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4113 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4114 | } |
6b0655a2 | 4115 | |
d62a17ae | 4116 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
4117 | no_neighbor_remove_private_as_hidden_cmd, | |
4118 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4119 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4120 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4121 | |
88b8ed8d | 4122 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 4123 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 4124 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4125 | NO_STR |
4126 | NEIGHBOR_STR | |
4127 | NEIGHBOR_ADDR_STR2 | |
4128 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4129 | "Apply to all AS numbers\n") |
88b8ed8d | 4130 | { |
d62a17ae | 4131 | int idx_peer = 2; |
4132 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4133 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4134 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 4135 | } |
5000f21c | 4136 | |
d62a17ae | 4137 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
4138 | no_neighbor_remove_private_as_all_hidden_cmd, | |
4139 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4140 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4141 | "Remove private ASNs in outbound updates\n" | |
4142 | "Apply to all AS numbers\n") | |
596c17ba | 4143 | |
88b8ed8d | 4144 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 4145 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 4146 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4147 | NO_STR |
4148 | NEIGHBOR_STR | |
4149 | NEIGHBOR_ADDR_STR2 | |
4150 | "Remove private ASNs in outbound updates\n" | |
4151 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 4152 | { |
d62a17ae | 4153 | int idx_peer = 2; |
4154 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4155 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4156 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 4157 | } |
5000f21c | 4158 | |
d62a17ae | 4159 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
4160 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
4161 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4162 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4163 | "Remove private ASNs in outbound updates\n" | |
4164 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4165 | |
88b8ed8d | 4166 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 4167 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 4168 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4169 | NO_STR |
4170 | NEIGHBOR_STR | |
4171 | NEIGHBOR_ADDR_STR2 | |
4172 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4173 | "Apply to all AS numbers\n" |
5000f21c | 4174 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 4175 | { |
d62a17ae | 4176 | int idx_peer = 2; |
4177 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4178 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4179 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 4180 | } |
5000f21c | 4181 | |
d62a17ae | 4182 | ALIAS_HIDDEN( |
4183 | no_neighbor_remove_private_as_all_replace_as, | |
4184 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4185 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4186 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4187 | "Remove private ASNs in outbound updates\n" | |
4188 | "Apply to all AS numbers\n" | |
4189 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4190 | |
5000f21c | 4191 | |
718e3744 | 4192 | /* neighbor send-community. */ |
4193 | DEFUN (neighbor_send_community, | |
4194 | neighbor_send_community_cmd, | |
9ccf14f7 | 4195 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4196 | NEIGHBOR_STR |
4197 | NEIGHBOR_ADDR_STR2 | |
4198 | "Send Community attribute to this neighbor\n") | |
4199 | { | |
d62a17ae | 4200 | int idx_peer = 1; |
27c05d4d | 4201 | |
d62a17ae | 4202 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4203 | bgp_node_safi(vty), | |
4204 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4205 | } |
4206 | ||
d62a17ae | 4207 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
4208 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4209 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4210 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4211 | |
718e3744 | 4212 | DEFUN (no_neighbor_send_community, |
4213 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 4214 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4215 | NO_STR |
4216 | NEIGHBOR_STR | |
4217 | NEIGHBOR_ADDR_STR2 | |
4218 | "Send Community attribute to this neighbor\n") | |
4219 | { | |
d62a17ae | 4220 | int idx_peer = 2; |
27c05d4d | 4221 | |
d62a17ae | 4222 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
4223 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4224 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4225 | } |
6b0655a2 | 4226 | |
d62a17ae | 4227 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
4228 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4229 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4230 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4231 | |
718e3744 | 4232 | /* neighbor send-community extended. */ |
4233 | DEFUN (neighbor_send_community_type, | |
4234 | neighbor_send_community_type_cmd, | |
57d187bc | 4235 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4236 | NEIGHBOR_STR |
4237 | NEIGHBOR_ADDR_STR2 | |
4238 | "Send Community attribute to this neighbor\n" | |
4239 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4240 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4241 | "Send Extended Community attributes\n" |
57d187bc JS |
4242 | "Send Standard Community attributes\n" |
4243 | "Send Large Community attributes\n") | |
718e3744 | 4244 | { |
27c05d4d | 4245 | int idx_peer = 1; |
d7c0a89a | 4246 | uint32_t flag = 0; |
27c05d4d | 4247 | const char *type = argv[argc - 1]->text; |
d62a17ae | 4248 | |
27c05d4d | 4249 | if (strmatch(type, "standard")) { |
d62a17ae | 4250 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
27c05d4d | 4251 | } else if (strmatch(type, "extended")) { |
d62a17ae | 4252 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); |
27c05d4d | 4253 | } else if (strmatch(type, "large")) { |
d62a17ae | 4254 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); |
27c05d4d | 4255 | } else if (strmatch(type, "both")) { |
d62a17ae | 4256 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4257 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
27c05d4d | 4258 | } else { /* if (strmatch(type, "all")) */ |
d62a17ae | 4259 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4260 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4261 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4262 | } | |
4263 | ||
27c05d4d | 4264 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
d62a17ae | 4265 | bgp_node_safi(vty), flag); |
4266 | } | |
4267 | ||
4268 | ALIAS_HIDDEN( | |
4269 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
4270 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4271 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4272 | "Send Community attribute to this neighbor\n" | |
4273 | "Send Standard and Extended Community attributes\n" | |
4274 | "Send Standard, Large and Extended Community attributes\n" | |
4275 | "Send Extended Community attributes\n" | |
4276 | "Send Standard Community attributes\n" | |
4277 | "Send Large Community attributes\n") | |
596c17ba | 4278 | |
718e3744 | 4279 | DEFUN (no_neighbor_send_community_type, |
4280 | no_neighbor_send_community_type_cmd, | |
57d187bc | 4281 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4282 | NO_STR |
4283 | NEIGHBOR_STR | |
4284 | NEIGHBOR_ADDR_STR2 | |
4285 | "Send Community attribute to this neighbor\n" | |
4286 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4287 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4288 | "Send Extended Community attributes\n" |
57d187bc JS |
4289 | "Send Standard Community attributes\n" |
4290 | "Send Large Community attributes\n") | |
718e3744 | 4291 | { |
d62a17ae | 4292 | int idx_peer = 2; |
27c05d4d | 4293 | uint32_t flag = 0; |
d62a17ae | 4294 | const char *type = argv[argc - 1]->text; |
4295 | ||
27c05d4d PM |
4296 | if (strmatch(type, "standard")) { |
4297 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4298 | } else if (strmatch(type, "extended")) { | |
4299 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4300 | } else if (strmatch(type, "large")) { | |
4301 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4302 | } else if (strmatch(type, "both")) { | |
4303 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4304 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4305 | } else { /* if (strmatch(type, "all")) */ | |
4306 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4307 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4308 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4309 | } | |
4310 | ||
4311 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4312 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4313 | flag); | |
d62a17ae | 4314 | } |
4315 | ||
4316 | ALIAS_HIDDEN( | |
4317 | no_neighbor_send_community_type, | |
4318 | no_neighbor_send_community_type_hidden_cmd, | |
4319 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4320 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4321 | "Send Community attribute to this neighbor\n" | |
4322 | "Send Standard and Extended Community attributes\n" | |
4323 | "Send Standard, Large and Extended Community attributes\n" | |
4324 | "Send Extended Community attributes\n" | |
4325 | "Send Standard Community attributes\n" | |
4326 | "Send Large Community attributes\n") | |
596c17ba | 4327 | |
718e3744 | 4328 | /* neighbor soft-reconfig. */ |
4329 | DEFUN (neighbor_soft_reconfiguration, | |
4330 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4331 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4332 | NEIGHBOR_STR |
4333 | NEIGHBOR_ADDR_STR2 | |
4334 | "Per neighbor soft reconfiguration\n" | |
4335 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4336 | { | |
d62a17ae | 4337 | int idx_peer = 1; |
4338 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4339 | bgp_node_safi(vty), | |
4340 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4341 | } |
4342 | ||
d62a17ae | 4343 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
4344 | neighbor_soft_reconfiguration_hidden_cmd, | |
4345 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4346 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4347 | "Per neighbor soft reconfiguration\n" | |
4348 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4349 | |
718e3744 | 4350 | DEFUN (no_neighbor_soft_reconfiguration, |
4351 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4352 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4353 | NO_STR |
4354 | NEIGHBOR_STR | |
4355 | NEIGHBOR_ADDR_STR2 | |
4356 | "Per neighbor soft reconfiguration\n" | |
4357 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4358 | { | |
d62a17ae | 4359 | int idx_peer = 2; |
4360 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4361 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4362 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4363 | } |
6b0655a2 | 4364 | |
d62a17ae | 4365 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
4366 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
4367 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4368 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4369 | "Per neighbor soft reconfiguration\n" | |
4370 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4371 | |
718e3744 | 4372 | DEFUN (neighbor_route_reflector_client, |
4373 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4374 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4375 | NEIGHBOR_STR |
4376 | NEIGHBOR_ADDR_STR2 | |
4377 | "Configure a neighbor as Route Reflector client\n") | |
4378 | { | |
d62a17ae | 4379 | int idx_peer = 1; |
4380 | struct peer *peer; | |
718e3744 | 4381 | |
4382 | ||
d62a17ae | 4383 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4384 | if (!peer) | |
4385 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4386 | |
d62a17ae | 4387 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4388 | bgp_node_safi(vty), | |
4389 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4390 | } |
4391 | ||
d62a17ae | 4392 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
4393 | neighbor_route_reflector_client_hidden_cmd, | |
4394 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4395 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4396 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4397 | |
718e3744 | 4398 | DEFUN (no_neighbor_route_reflector_client, |
4399 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4400 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4401 | NO_STR |
4402 | NEIGHBOR_STR | |
4403 | NEIGHBOR_ADDR_STR2 | |
4404 | "Configure a neighbor as Route Reflector client\n") | |
4405 | { | |
d62a17ae | 4406 | int idx_peer = 2; |
4407 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4408 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4409 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4410 | } |
6b0655a2 | 4411 | |
d62a17ae | 4412 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
4413 | no_neighbor_route_reflector_client_hidden_cmd, | |
4414 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4415 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4416 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4417 | |
718e3744 | 4418 | /* neighbor route-server-client. */ |
4419 | DEFUN (neighbor_route_server_client, | |
4420 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 4421 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4422 | NEIGHBOR_STR |
4423 | NEIGHBOR_ADDR_STR2 | |
4424 | "Configure a neighbor as Route Server client\n") | |
4425 | { | |
d62a17ae | 4426 | int idx_peer = 1; |
4427 | struct peer *peer; | |
2a3d5731 | 4428 | |
d62a17ae | 4429 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4430 | if (!peer) | |
4431 | return CMD_WARNING_CONFIG_FAILED; | |
4432 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4433 | bgp_node_safi(vty), | |
4434 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 4435 | } |
4436 | ||
d62a17ae | 4437 | ALIAS_HIDDEN(neighbor_route_server_client, |
4438 | neighbor_route_server_client_hidden_cmd, | |
4439 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4440 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4441 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4442 | |
718e3744 | 4443 | DEFUN (no_neighbor_route_server_client, |
4444 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 4445 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4446 | NO_STR |
4447 | NEIGHBOR_STR | |
4448 | NEIGHBOR_ADDR_STR2 | |
4449 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 4450 | { |
d62a17ae | 4451 | int idx_peer = 2; |
4452 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4453 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4454 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 4455 | } |
6b0655a2 | 4456 | |
d62a17ae | 4457 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
4458 | no_neighbor_route_server_client_hidden_cmd, | |
4459 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4460 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4461 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4462 | |
fee0f4c6 | 4463 | DEFUN (neighbor_nexthop_local_unchanged, |
4464 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4465 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4466 | NEIGHBOR_STR |
4467 | NEIGHBOR_ADDR_STR2 | |
4468 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
4469 | "Leave link-local nexthop unchanged for this peer\n") | |
4470 | { | |
d62a17ae | 4471 | int idx_peer = 1; |
4472 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4473 | bgp_node_safi(vty), | |
4474 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 4475 | } |
6b0655a2 | 4476 | |
fee0f4c6 | 4477 | DEFUN (no_neighbor_nexthop_local_unchanged, |
4478 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4479 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4480 | NO_STR |
4481 | NEIGHBOR_STR | |
4482 | NEIGHBOR_ADDR_STR2 | |
4483 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
4484 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 4485 | { |
d62a17ae | 4486 | int idx_peer = 2; |
4487 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4488 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4489 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 4490 | } |
6b0655a2 | 4491 | |
718e3744 | 4492 | DEFUN (neighbor_attr_unchanged, |
4493 | neighbor_attr_unchanged_cmd, | |
a8206004 | 4494 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
718e3744 | 4495 | NEIGHBOR_STR |
4496 | NEIGHBOR_ADDR_STR2 | |
4497 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4498 | "As-path attribute\n" | |
4499 | "Nexthop attribute\n" | |
a8206004 | 4500 | "Med attribute\n") |
718e3744 | 4501 | { |
d62a17ae | 4502 | int idx = 0; |
8eeb0335 DW |
4503 | char *peer_str = argv[1]->arg; |
4504 | struct peer *peer; | |
d7c0a89a | 4505 | uint16_t flags = 0; |
8eeb0335 DW |
4506 | afi_t afi = bgp_node_afi(vty); |
4507 | safi_t safi = bgp_node_safi(vty); | |
4508 | ||
4509 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
4510 | if (!peer) | |
4511 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4512 | |
4513 | if (argv_find(argv, argc, "as-path", &idx)) | |
4514 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4515 | idx = 0; | |
4516 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4517 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4518 | idx = 0; | |
4519 | if (argv_find(argv, argc, "med", &idx)) | |
4520 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4521 | ||
8eeb0335 DW |
4522 | /* no flags means all of them! */ |
4523 | if (!flags) { | |
d62a17ae | 4524 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); |
4525 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4526 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 | 4527 | } else { |
a4d82a8a PZ |
4528 | if (!CHECK_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED) |
4529 | && peer_af_flag_check(peer, afi, safi, | |
4530 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
8eeb0335 DW |
4531 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4532 | PEER_FLAG_AS_PATH_UNCHANGED); | |
4533 | } | |
4534 | ||
a4d82a8a PZ |
4535 | if (!CHECK_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED) |
4536 | && peer_af_flag_check(peer, afi, safi, | |
4537 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
8eeb0335 DW |
4538 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4539 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
4540 | } | |
4541 | ||
a4d82a8a PZ |
4542 | if (!CHECK_FLAG(flags, PEER_FLAG_MED_UNCHANGED) |
4543 | && peer_af_flag_check(peer, afi, safi, | |
4544 | PEER_FLAG_MED_UNCHANGED)) { | |
8eeb0335 DW |
4545 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4546 | PEER_FLAG_MED_UNCHANGED); | |
4547 | } | |
d62a17ae | 4548 | } |
4549 | ||
8eeb0335 | 4550 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, flags); |
d62a17ae | 4551 | } |
4552 | ||
4553 | ALIAS_HIDDEN( | |
4554 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
4555 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4556 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4557 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4558 | "As-path attribute\n" | |
4559 | "Nexthop attribute\n" | |
4560 | "Med attribute\n") | |
596c17ba | 4561 | |
718e3744 | 4562 | DEFUN (no_neighbor_attr_unchanged, |
4563 | no_neighbor_attr_unchanged_cmd, | |
a8206004 | 4564 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
e52702f2 | 4565 | NO_STR |
718e3744 | 4566 | NEIGHBOR_STR |
4567 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
4568 | "BGP attribute is propagated unchanged to this neighbor\n" |
4569 | "As-path attribute\n" | |
40e718b5 | 4570 | "Nexthop attribute\n" |
a8206004 | 4571 | "Med attribute\n") |
718e3744 | 4572 | { |
d62a17ae | 4573 | int idx = 0; |
4574 | char *peer = argv[2]->arg; | |
d7c0a89a | 4575 | uint16_t flags = 0; |
d62a17ae | 4576 | |
4577 | if (argv_find(argv, argc, "as-path", &idx)) | |
4578 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4579 | idx = 0; | |
4580 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4581 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4582 | idx = 0; | |
4583 | if (argv_find(argv, argc, "med", &idx)) | |
4584 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4585 | ||
4586 | if (!flags) // no flags means all of them! | |
4587 | { | |
4588 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4589 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4590 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4591 | } | |
4592 | ||
4593 | return peer_af_flag_unset_vty(vty, peer, bgp_node_afi(vty), | |
4594 | bgp_node_safi(vty), flags); | |
4595 | } | |
4596 | ||
4597 | ALIAS_HIDDEN( | |
4598 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
4599 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4600 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4601 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4602 | "As-path attribute\n" | |
4603 | "Nexthop attribute\n" | |
4604 | "Med attribute\n") | |
718e3744 | 4605 | |
718e3744 | 4606 | /* EBGP multihop configuration. */ |
d62a17ae | 4607 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, |
4608 | const char *ttl_str) | |
718e3744 | 4609 | { |
d62a17ae | 4610 | struct peer *peer; |
4611 | unsigned int ttl; | |
718e3744 | 4612 | |
d62a17ae | 4613 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4614 | if (!peer) | |
4615 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4616 | |
d62a17ae | 4617 | if (peer->conf_if) |
4618 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
63fa10b5 | 4619 | |
d62a17ae | 4620 | if (!ttl_str) |
4621 | ttl = MAXTTL; | |
4622 | else | |
4623 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 4624 | |
d62a17ae | 4625 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 4626 | } |
4627 | ||
d62a17ae | 4628 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 4629 | { |
d62a17ae | 4630 | struct peer *peer; |
718e3744 | 4631 | |
d62a17ae | 4632 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4633 | if (!peer) | |
4634 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4635 | |
d62a17ae | 4636 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 4637 | } |
4638 | ||
4639 | /* neighbor ebgp-multihop. */ | |
4640 | DEFUN (neighbor_ebgp_multihop, | |
4641 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 4642 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 4643 | NEIGHBOR_STR |
4644 | NEIGHBOR_ADDR_STR2 | |
4645 | "Allow EBGP neighbors not on directly connected networks\n") | |
4646 | { | |
d62a17ae | 4647 | int idx_peer = 1; |
4648 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4649 | } |
4650 | ||
4651 | DEFUN (neighbor_ebgp_multihop_ttl, | |
4652 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 4653 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 4654 | NEIGHBOR_STR |
4655 | NEIGHBOR_ADDR_STR2 | |
4656 | "Allow EBGP neighbors not on directly connected networks\n" | |
4657 | "maximum hop count\n") | |
4658 | { | |
d62a17ae | 4659 | int idx_peer = 1; |
4660 | int idx_number = 3; | |
4661 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
4662 | argv[idx_number]->arg); | |
718e3744 | 4663 | } |
4664 | ||
4665 | DEFUN (no_neighbor_ebgp_multihop, | |
4666 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 4667 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 4668 | NO_STR |
4669 | NEIGHBOR_STR | |
4670 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4671 | "Allow EBGP neighbors not on directly connected networks\n" |
4672 | "maximum hop count\n") | |
718e3744 | 4673 | { |
d62a17ae | 4674 | int idx_peer = 2; |
4675 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 4676 | } |
4677 | ||
6b0655a2 | 4678 | |
6ffd2079 | 4679 | /* disable-connected-check */ |
4680 | DEFUN (neighbor_disable_connected_check, | |
4681 | neighbor_disable_connected_check_cmd, | |
7ebe625c | 4682 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4683 | NEIGHBOR_STR |
7ebe625c | 4684 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
4685 | "one-hop away EBGP peer using loopback address\n" |
4686 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4687 | { |
d62a17ae | 4688 | int idx_peer = 1; |
4689 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4690 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4691 | } |
4692 | ||
4693 | DEFUN (no_neighbor_disable_connected_check, | |
4694 | no_neighbor_disable_connected_check_cmd, | |
7ebe625c | 4695 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4696 | NO_STR |
4697 | NEIGHBOR_STR | |
7ebe625c | 4698 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
4699 | "one-hop away EBGP peer using loopback address\n" |
4700 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4701 | { |
d62a17ae | 4702 | int idx_peer = 2; |
4703 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4704 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4705 | } |
4706 | ||
47cbc09b PM |
4707 | |
4708 | /* enforce-first-as */ | |
4709 | DEFUN (neighbor_enforce_first_as, | |
4710 | neighbor_enforce_first_as_cmd, | |
4711 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
4712 | NEIGHBOR_STR | |
4713 | NEIGHBOR_ADDR_STR2 | |
4714 | "Enforce the first AS for EBGP routes\n") | |
4715 | { | |
4716 | int idx_peer = 1; | |
4717 | ||
4718 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4719 | PEER_FLAG_ENFORCE_FIRST_AS); | |
4720 | } | |
4721 | ||
4722 | DEFUN (no_neighbor_enforce_first_as, | |
4723 | no_neighbor_enforce_first_as_cmd, | |
4724 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
4725 | NO_STR | |
4726 | NEIGHBOR_STR | |
4727 | NEIGHBOR_ADDR_STR2 | |
4728 | "Enforce the first AS for EBGP routes\n") | |
4729 | { | |
4730 | int idx_peer = 2; | |
4731 | ||
4732 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4733 | PEER_FLAG_ENFORCE_FIRST_AS); | |
4734 | } | |
4735 | ||
4736 | ||
718e3744 | 4737 | DEFUN (neighbor_description, |
4738 | neighbor_description_cmd, | |
e961923c | 4739 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 4740 | NEIGHBOR_STR |
4741 | NEIGHBOR_ADDR_STR2 | |
4742 | "Neighbor specific description\n" | |
4743 | "Up to 80 characters describing this neighbor\n") | |
4744 | { | |
d62a17ae | 4745 | int idx_peer = 1; |
4746 | int idx_line = 3; | |
4747 | struct peer *peer; | |
4748 | char *str; | |
718e3744 | 4749 | |
d62a17ae | 4750 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4751 | if (!peer) | |
4752 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4753 | |
d62a17ae | 4754 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 4755 | |
d62a17ae | 4756 | peer_description_set(peer, str); |
718e3744 | 4757 | |
d62a17ae | 4758 | XFREE(MTYPE_TMP, str); |
718e3744 | 4759 | |
d62a17ae | 4760 | return CMD_SUCCESS; |
718e3744 | 4761 | } |
4762 | ||
4763 | DEFUN (no_neighbor_description, | |
4764 | no_neighbor_description_cmd, | |
a14810f4 | 4765 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", |
718e3744 | 4766 | NO_STR |
4767 | NEIGHBOR_STR | |
4768 | NEIGHBOR_ADDR_STR2 | |
a14810f4 | 4769 | "Neighbor specific description\n") |
718e3744 | 4770 | { |
d62a17ae | 4771 | int idx_peer = 2; |
4772 | struct peer *peer; | |
718e3744 | 4773 | |
d62a17ae | 4774 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4775 | if (!peer) | |
4776 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4777 | |
d62a17ae | 4778 | peer_description_unset(peer); |
718e3744 | 4779 | |
d62a17ae | 4780 | return CMD_SUCCESS; |
718e3744 | 4781 | } |
4782 | ||
a14810f4 PM |
4783 | ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd, |
4784 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
4785 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4786 | "Neighbor specific description\n" | |
4787 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 4788 | |
718e3744 | 4789 | /* Neighbor update-source. */ |
d62a17ae | 4790 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, |
4791 | const char *source_str) | |
4792 | { | |
4793 | struct peer *peer; | |
4794 | struct prefix p; | |
a14810f4 | 4795 | union sockunion su; |
d62a17ae | 4796 | |
4797 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
4798 | if (!peer) | |
4799 | return CMD_WARNING_CONFIG_FAILED; | |
4800 | ||
4801 | if (peer->conf_if) | |
4802 | return CMD_WARNING; | |
4803 | ||
4804 | if (source_str) { | |
a14810f4 | 4805 | if (str2sockunion(source_str, &su) == 0) |
d62a17ae | 4806 | peer_update_source_addr_set(peer, &su); |
4807 | else { | |
4808 | if (str2prefix(source_str, &p)) { | |
4809 | vty_out(vty, | |
4810 | "%% Invalid update-source, remove prefix length \n"); | |
4811 | return CMD_WARNING_CONFIG_FAILED; | |
4812 | } else | |
4813 | peer_update_source_if_set(peer, source_str); | |
4814 | } | |
4815 | } else | |
4816 | peer_update_source_unset(peer); | |
4817 | ||
4818 | return CMD_SUCCESS; | |
4819 | } | |
4820 | ||
4821 | #define BGP_UPDATE_SOURCE_HELP_STR \ | |
4822 | "IPv4 address\n" \ | |
4823 | "IPv6 address\n" \ | |
4824 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 4825 | |
718e3744 | 4826 | DEFUN (neighbor_update_source, |
4827 | neighbor_update_source_cmd, | |
9ccf14f7 | 4828 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 4829 | NEIGHBOR_STR |
4830 | NEIGHBOR_ADDR_STR2 | |
4831 | "Source of routing updates\n" | |
369688c0 | 4832 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 4833 | { |
d62a17ae | 4834 | int idx_peer = 1; |
4835 | int idx_peer_2 = 3; | |
4836 | return peer_update_source_vty(vty, argv[idx_peer]->arg, | |
4837 | argv[idx_peer_2]->arg); | |
718e3744 | 4838 | } |
4839 | ||
4840 | DEFUN (no_neighbor_update_source, | |
4841 | no_neighbor_update_source_cmd, | |
c7178fe7 | 4842 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 4843 | NO_STR |
4844 | NEIGHBOR_STR | |
4845 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
4846 | "Source of routing updates\n" |
4847 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 4848 | { |
d62a17ae | 4849 | int idx_peer = 2; |
4850 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4851 | } |
6b0655a2 | 4852 | |
d62a17ae | 4853 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
4854 | afi_t afi, safi_t safi, | |
4855 | const char *rmap, int set) | |
718e3744 | 4856 | { |
d62a17ae | 4857 | int ret; |
4858 | struct peer *peer; | |
1de27621 | 4859 | struct route_map *route_map; |
718e3744 | 4860 | |
d62a17ae | 4861 | peer = peer_and_group_lookup_vty(vty, peer_str); |
4862 | if (!peer) | |
4863 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4864 | |
1de27621 DA |
4865 | if (set) { |
4866 | route_map = route_map_lookup_warn_noexist(vty, rmap); | |
4867 | ret = peer_default_originate_set(peer, afi, safi, | |
4868 | rmap, route_map); | |
4869 | } else | |
d62a17ae | 4870 | ret = peer_default_originate_unset(peer, afi, safi); |
718e3744 | 4871 | |
d62a17ae | 4872 | return bgp_vty_return(vty, ret); |
718e3744 | 4873 | } |
4874 | ||
4875 | /* neighbor default-originate. */ | |
4876 | DEFUN (neighbor_default_originate, | |
4877 | neighbor_default_originate_cmd, | |
9ccf14f7 | 4878 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 4879 | NEIGHBOR_STR |
4880 | NEIGHBOR_ADDR_STR2 | |
4881 | "Originate default route to this neighbor\n") | |
4882 | { | |
d62a17ae | 4883 | int idx_peer = 1; |
4884 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
4885 | bgp_node_afi(vty), | |
4886 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 4887 | } |
4888 | ||
d62a17ae | 4889 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
4890 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
4891 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4892 | "Originate default route to this neighbor\n") | |
596c17ba | 4893 | |
718e3744 | 4894 | DEFUN (neighbor_default_originate_rmap, |
4895 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 4896 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 4897 | NEIGHBOR_STR |
4898 | NEIGHBOR_ADDR_STR2 | |
4899 | "Originate default route to this neighbor\n" | |
4900 | "Route-map to specify criteria to originate default\n" | |
4901 | "route-map name\n") | |
4902 | { | |
d62a17ae | 4903 | int idx_peer = 1; |
4904 | int idx_word = 4; | |
4905 | return peer_default_originate_set_vty( | |
4906 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
4907 | argv[idx_word]->arg, 1); | |
718e3744 | 4908 | } |
4909 | ||
d62a17ae | 4910 | ALIAS_HIDDEN( |
4911 | neighbor_default_originate_rmap, | |
4912 | neighbor_default_originate_rmap_hidden_cmd, | |
4913 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
4914 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4915 | "Originate default route to this neighbor\n" | |
4916 | "Route-map to specify criteria to originate default\n" | |
4917 | "route-map name\n") | |
596c17ba | 4918 | |
718e3744 | 4919 | DEFUN (no_neighbor_default_originate, |
4920 | no_neighbor_default_originate_cmd, | |
a636c635 | 4921 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 4922 | NO_STR |
4923 | NEIGHBOR_STR | |
4924 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4925 | "Originate default route to this neighbor\n" |
4926 | "Route-map to specify criteria to originate default\n" | |
4927 | "route-map name\n") | |
718e3744 | 4928 | { |
d62a17ae | 4929 | int idx_peer = 2; |
4930 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
4931 | bgp_node_afi(vty), | |
4932 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 4933 | } |
4934 | ||
d62a17ae | 4935 | ALIAS_HIDDEN( |
4936 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
4937 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
4938 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4939 | "Originate default route to this neighbor\n" | |
4940 | "Route-map to specify criteria to originate default\n" | |
4941 | "route-map name\n") | |
596c17ba | 4942 | |
6b0655a2 | 4943 | |
718e3744 | 4944 | /* Set neighbor's BGP port. */ |
d62a17ae | 4945 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, |
4946 | const char *port_str) | |
4947 | { | |
4948 | struct peer *peer; | |
d7c0a89a | 4949 | uint16_t port; |
d62a17ae | 4950 | struct servent *sp; |
4951 | ||
4952 | peer = peer_lookup_vty(vty, ip_str); | |
4953 | if (!peer) | |
4954 | return CMD_WARNING_CONFIG_FAILED; | |
4955 | ||
4956 | if (!port_str) { | |
4957 | sp = getservbyname("bgp", "tcp"); | |
4958 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
4959 | } else { | |
4960 | port = strtoul(port_str, NULL, 10); | |
4961 | } | |
718e3744 | 4962 | |
d62a17ae | 4963 | peer_port_set(peer, port); |
718e3744 | 4964 | |
d62a17ae | 4965 | return CMD_SUCCESS; |
718e3744 | 4966 | } |
4967 | ||
f418446b | 4968 | /* Set specified peer's BGP port. */ |
718e3744 | 4969 | DEFUN (neighbor_port, |
4970 | neighbor_port_cmd, | |
9ccf14f7 | 4971 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 4972 | NEIGHBOR_STR |
4973 | NEIGHBOR_ADDR_STR | |
4974 | "Neighbor's BGP port\n" | |
4975 | "TCP port number\n") | |
4976 | { | |
d62a17ae | 4977 | int idx_ip = 1; |
4978 | int idx_number = 3; | |
4979 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
4980 | argv[idx_number]->arg); | |
718e3744 | 4981 | } |
4982 | ||
4983 | DEFUN (no_neighbor_port, | |
4984 | no_neighbor_port_cmd, | |
9ccf14f7 | 4985 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 4986 | NO_STR |
4987 | NEIGHBOR_STR | |
4988 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
4989 | "Neighbor's BGP port\n" |
4990 | "TCP port number\n") | |
718e3744 | 4991 | { |
d62a17ae | 4992 | int idx_ip = 2; |
4993 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 4994 | } |
4995 | ||
6b0655a2 | 4996 | |
718e3744 | 4997 | /* neighbor weight. */ |
d62a17ae | 4998 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
4999 | safi_t safi, const char *weight_str) | |
718e3744 | 5000 | { |
d62a17ae | 5001 | int ret; |
5002 | struct peer *peer; | |
5003 | unsigned long weight; | |
718e3744 | 5004 | |
d62a17ae | 5005 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5006 | if (!peer) | |
5007 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5008 | |
d62a17ae | 5009 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 5010 | |
d62a17ae | 5011 | ret = peer_weight_set(peer, afi, safi, weight); |
5012 | return bgp_vty_return(vty, ret); | |
718e3744 | 5013 | } |
5014 | ||
d62a17ae | 5015 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5016 | safi_t safi) | |
718e3744 | 5017 | { |
d62a17ae | 5018 | int ret; |
5019 | struct peer *peer; | |
718e3744 | 5020 | |
d62a17ae | 5021 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5022 | if (!peer) | |
5023 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5024 | |
d62a17ae | 5025 | ret = peer_weight_unset(peer, afi, safi); |
5026 | return bgp_vty_return(vty, ret); | |
718e3744 | 5027 | } |
5028 | ||
5029 | DEFUN (neighbor_weight, | |
5030 | neighbor_weight_cmd, | |
9ccf14f7 | 5031 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 5032 | NEIGHBOR_STR |
5033 | NEIGHBOR_ADDR_STR2 | |
5034 | "Set default weight for routes from this neighbor\n" | |
5035 | "default weight\n") | |
5036 | { | |
d62a17ae | 5037 | int idx_peer = 1; |
5038 | int idx_number = 3; | |
5039 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5040 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 5041 | } |
5042 | ||
d62a17ae | 5043 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
5044 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
5045 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5046 | "Set default weight for routes from this neighbor\n" | |
5047 | "default weight\n") | |
596c17ba | 5048 | |
718e3744 | 5049 | DEFUN (no_neighbor_weight, |
5050 | no_neighbor_weight_cmd, | |
9ccf14f7 | 5051 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 5052 | NO_STR |
5053 | NEIGHBOR_STR | |
5054 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5055 | "Set default weight for routes from this neighbor\n" |
5056 | "default weight\n") | |
718e3744 | 5057 | { |
d62a17ae | 5058 | int idx_peer = 2; |
5059 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, | |
5060 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 5061 | } |
5062 | ||
d62a17ae | 5063 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
5064 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
5065 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5066 | "Set default weight for routes from this neighbor\n" | |
5067 | "default weight\n") | |
596c17ba | 5068 | |
6b0655a2 | 5069 | |
718e3744 | 5070 | /* Override capability negotiation. */ |
5071 | DEFUN (neighbor_override_capability, | |
5072 | neighbor_override_capability_cmd, | |
9ccf14f7 | 5073 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5074 | NEIGHBOR_STR |
5075 | NEIGHBOR_ADDR_STR2 | |
5076 | "Override capability negotiation result\n") | |
5077 | { | |
d62a17ae | 5078 | int idx_peer = 1; |
5079 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5080 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5081 | } |
5082 | ||
5083 | DEFUN (no_neighbor_override_capability, | |
5084 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 5085 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5086 | NO_STR |
5087 | NEIGHBOR_STR | |
5088 | NEIGHBOR_ADDR_STR2 | |
5089 | "Override capability negotiation result\n") | |
5090 | { | |
d62a17ae | 5091 | int idx_peer = 2; |
5092 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5093 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5094 | } |
6b0655a2 | 5095 | |
718e3744 | 5096 | DEFUN (neighbor_strict_capability, |
5097 | neighbor_strict_capability_cmd, | |
9fb964de | 5098 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5099 | NEIGHBOR_STR |
9fb964de | 5100 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5101 | "Strict capability negotiation match\n") |
5102 | { | |
9fb964de PM |
5103 | int idx_peer = 1; |
5104 | ||
5105 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5106 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5107 | } |
5108 | ||
5109 | DEFUN (no_neighbor_strict_capability, | |
5110 | no_neighbor_strict_capability_cmd, | |
9fb964de | 5111 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5112 | NO_STR |
5113 | NEIGHBOR_STR | |
9fb964de | 5114 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5115 | "Strict capability negotiation match\n") |
5116 | { | |
9fb964de PM |
5117 | int idx_peer = 2; |
5118 | ||
5119 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5120 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5121 | } |
6b0655a2 | 5122 | |
d62a17ae | 5123 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
5124 | const char *keep_str, const char *hold_str) | |
718e3744 | 5125 | { |
d62a17ae | 5126 | int ret; |
5127 | struct peer *peer; | |
d7c0a89a QY |
5128 | uint32_t keepalive; |
5129 | uint32_t holdtime; | |
718e3744 | 5130 | |
d62a17ae | 5131 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5132 | if (!peer) | |
5133 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5134 | |
d62a17ae | 5135 | keepalive = strtoul(keep_str, NULL, 10); |
5136 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 5137 | |
d62a17ae | 5138 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 5139 | |
d62a17ae | 5140 | return bgp_vty_return(vty, ret); |
718e3744 | 5141 | } |
6b0655a2 | 5142 | |
d62a17ae | 5143 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5144 | { |
d62a17ae | 5145 | int ret; |
5146 | struct peer *peer; | |
718e3744 | 5147 | |
d62a17ae | 5148 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5149 | if (!peer) | |
5150 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5151 | |
d62a17ae | 5152 | ret = peer_timers_unset(peer); |
718e3744 | 5153 | |
d62a17ae | 5154 | return bgp_vty_return(vty, ret); |
718e3744 | 5155 | } |
5156 | ||
5157 | DEFUN (neighbor_timers, | |
5158 | neighbor_timers_cmd, | |
9ccf14f7 | 5159 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 5160 | NEIGHBOR_STR |
5161 | NEIGHBOR_ADDR_STR2 | |
5162 | "BGP per neighbor timers\n" | |
5163 | "Keepalive interval\n" | |
5164 | "Holdtime\n") | |
5165 | { | |
d62a17ae | 5166 | int idx_peer = 1; |
5167 | int idx_number = 3; | |
5168 | int idx_number_2 = 4; | |
5169 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
5170 | argv[idx_number]->arg, | |
5171 | argv[idx_number_2]->arg); | |
718e3744 | 5172 | } |
5173 | ||
5174 | DEFUN (no_neighbor_timers, | |
5175 | no_neighbor_timers_cmd, | |
9ccf14f7 | 5176 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 5177 | NO_STR |
5178 | NEIGHBOR_STR | |
5179 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5180 | "BGP per neighbor timers\n" |
5181 | "Keepalive interval\n" | |
5182 | "Holdtime\n") | |
718e3744 | 5183 | { |
d62a17ae | 5184 | int idx_peer = 2; |
5185 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5186 | } |
6b0655a2 | 5187 | |
813d4307 | 5188 | |
d62a17ae | 5189 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, |
5190 | const char *time_str) | |
718e3744 | 5191 | { |
d62a17ae | 5192 | int ret; |
5193 | struct peer *peer; | |
d7c0a89a | 5194 | uint32_t connect; |
718e3744 | 5195 | |
d62a17ae | 5196 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5197 | if (!peer) | |
5198 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5199 | |
d62a17ae | 5200 | connect = strtoul(time_str, NULL, 10); |
718e3744 | 5201 | |
d62a17ae | 5202 | ret = peer_timers_connect_set(peer, connect); |
718e3744 | 5203 | |
d62a17ae | 5204 | return bgp_vty_return(vty, ret); |
718e3744 | 5205 | } |
5206 | ||
d62a17ae | 5207 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5208 | { |
d62a17ae | 5209 | int ret; |
5210 | struct peer *peer; | |
718e3744 | 5211 | |
d62a17ae | 5212 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5213 | if (!peer) | |
5214 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5215 | |
d62a17ae | 5216 | ret = peer_timers_connect_unset(peer); |
718e3744 | 5217 | |
d62a17ae | 5218 | return bgp_vty_return(vty, ret); |
718e3744 | 5219 | } |
5220 | ||
5221 | DEFUN (neighbor_timers_connect, | |
5222 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 5223 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 5224 | NEIGHBOR_STR |
966f821c | 5225 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5226 | "BGP per neighbor timers\n" |
5227 | "BGP connect timer\n" | |
5228 | "Connect timer\n") | |
5229 | { | |
d62a17ae | 5230 | int idx_peer = 1; |
5231 | int idx_number = 4; | |
5232 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
5233 | argv[idx_number]->arg); | |
718e3744 | 5234 | } |
5235 | ||
5236 | DEFUN (no_neighbor_timers_connect, | |
5237 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 5238 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 5239 | NO_STR |
5240 | NEIGHBOR_STR | |
966f821c | 5241 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5242 | "BGP per neighbor timers\n" |
8334fd5a DW |
5243 | "BGP connect timer\n" |
5244 | "Connect timer\n") | |
718e3744 | 5245 | { |
d62a17ae | 5246 | int idx_peer = 2; |
5247 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5248 | } |
5249 | ||
6b0655a2 | 5250 | |
d62a17ae | 5251 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
5252 | const char *time_str, int set) | |
718e3744 | 5253 | { |
d62a17ae | 5254 | int ret; |
5255 | struct peer *peer; | |
d7c0a89a | 5256 | uint32_t routeadv = 0; |
718e3744 | 5257 | |
d62a17ae | 5258 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5259 | if (!peer) | |
5260 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5261 | |
d62a17ae | 5262 | if (time_str) |
5263 | routeadv = strtoul(time_str, NULL, 10); | |
718e3744 | 5264 | |
d62a17ae | 5265 | if (set) |
5266 | ret = peer_advertise_interval_set(peer, routeadv); | |
5267 | else | |
5268 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 5269 | |
d62a17ae | 5270 | return bgp_vty_return(vty, ret); |
718e3744 | 5271 | } |
5272 | ||
5273 | DEFUN (neighbor_advertise_interval, | |
5274 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5275 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 5276 | NEIGHBOR_STR |
966f821c | 5277 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5278 | "Minimum interval between sending BGP routing updates\n" |
5279 | "time in seconds\n") | |
5280 | { | |
d62a17ae | 5281 | int idx_peer = 1; |
5282 | int idx_number = 3; | |
5283 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
5284 | argv[idx_number]->arg, 1); | |
718e3744 | 5285 | } |
5286 | ||
5287 | DEFUN (no_neighbor_advertise_interval, | |
5288 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5289 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 5290 | NO_STR |
5291 | NEIGHBOR_STR | |
966f821c | 5292 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
5293 | "Minimum interval between sending BGP routing updates\n" |
5294 | "time in seconds\n") | |
718e3744 | 5295 | { |
d62a17ae | 5296 | int idx_peer = 2; |
5297 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 5298 | } |
5299 | ||
6b0655a2 | 5300 | |
518f0eb1 DS |
5301 | /* Time to wait before processing route-map updates */ |
5302 | DEFUN (bgp_set_route_map_delay_timer, | |
5303 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 5304 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
5305 | SET_STR |
5306 | "BGP route-map delay timer\n" | |
5307 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 5308 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 5309 | { |
d62a17ae | 5310 | int idx_number = 3; |
d7c0a89a | 5311 | uint32_t rmap_delay_timer; |
d62a17ae | 5312 | |
5313 | if (argv[idx_number]->arg) { | |
5314 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
5315 | bm->rmap_update_timer = rmap_delay_timer; | |
5316 | ||
5317 | /* if the dynamic update handling is being disabled, and a timer | |
5318 | * is | |
5319 | * running, stop the timer and act as if the timer has already | |
5320 | * fired. | |
5321 | */ | |
5322 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
5323 | BGP_TIMER_OFF(bm->t_rmap_update); | |
5324 | thread_execute(bm->master, bgp_route_map_update_timer, | |
5325 | NULL, 0); | |
5326 | } | |
5327 | return CMD_SUCCESS; | |
5328 | } else { | |
5329 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
5330 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 5331 | } |
518f0eb1 DS |
5332 | } |
5333 | ||
5334 | DEFUN (no_bgp_set_route_map_delay_timer, | |
5335 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 5336 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 5337 | NO_STR |
3a2d747c | 5338 | BGP_STR |
518f0eb1 | 5339 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
5340 | "Reset to default time to wait for processing route-map changes\n" |
5341 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 5342 | { |
518f0eb1 | 5343 | |
d62a17ae | 5344 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 5345 | |
d62a17ae | 5346 | return CMD_SUCCESS; |
518f0eb1 DS |
5347 | } |
5348 | ||
f414725f | 5349 | |
718e3744 | 5350 | /* neighbor interface */ |
d62a17ae | 5351 | static int peer_interface_vty(struct vty *vty, const char *ip_str, |
5352 | const char *str) | |
718e3744 | 5353 | { |
d62a17ae | 5354 | struct peer *peer; |
718e3744 | 5355 | |
d62a17ae | 5356 | peer = peer_lookup_vty(vty, ip_str); |
5357 | if (!peer || peer->conf_if) { | |
5358 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
5359 | return CMD_WARNING_CONFIG_FAILED; | |
5360 | } | |
718e3744 | 5361 | |
d62a17ae | 5362 | if (str) |
5363 | peer_interface_set(peer, str); | |
5364 | else | |
5365 | peer_interface_unset(peer); | |
718e3744 | 5366 | |
d62a17ae | 5367 | return CMD_SUCCESS; |
718e3744 | 5368 | } |
5369 | ||
5370 | DEFUN (neighbor_interface, | |
5371 | neighbor_interface_cmd, | |
9ccf14f7 | 5372 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 5373 | NEIGHBOR_STR |
5374 | NEIGHBOR_ADDR_STR | |
5375 | "Interface\n" | |
5376 | "Interface name\n") | |
5377 | { | |
d62a17ae | 5378 | int idx_ip = 1; |
5379 | int idx_word = 3; | |
5380 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); | |
718e3744 | 5381 | } |
5382 | ||
5383 | DEFUN (no_neighbor_interface, | |
5384 | no_neighbor_interface_cmd, | |
9ccf14f7 | 5385 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 5386 | NO_STR |
5387 | NEIGHBOR_STR | |
16cedbb0 | 5388 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5389 | "Interface\n" |
5390 | "Interface name\n") | |
5391 | { | |
d62a17ae | 5392 | int idx_peer = 2; |
5393 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5394 | } |
6b0655a2 | 5395 | |
718e3744 | 5396 | DEFUN (neighbor_distribute_list, |
5397 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 5398 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5399 | NEIGHBOR_STR |
5400 | NEIGHBOR_ADDR_STR2 | |
5401 | "Filter updates to/from this neighbor\n" | |
5402 | "IP access-list number\n" | |
5403 | "IP access-list number (expanded range)\n" | |
5404 | "IP Access-list name\n" | |
5405 | "Filter incoming updates\n" | |
5406 | "Filter outgoing updates\n") | |
5407 | { | |
d62a17ae | 5408 | int idx_peer = 1; |
5409 | int idx_acl = 3; | |
5410 | int direct, ret; | |
5411 | struct peer *peer; | |
a8206004 | 5412 | |
d62a17ae | 5413 | const char *pstr = argv[idx_peer]->arg; |
5414 | const char *acl = argv[idx_acl]->arg; | |
5415 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5416 | |
d62a17ae | 5417 | peer = peer_and_group_lookup_vty(vty, pstr); |
5418 | if (!peer) | |
5419 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5420 | |
d62a17ae | 5421 | /* Check filter direction. */ |
5422 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5423 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5424 | direct, acl); | |
a8206004 | 5425 | |
d62a17ae | 5426 | return bgp_vty_return(vty, ret); |
718e3744 | 5427 | } |
5428 | ||
d62a17ae | 5429 | ALIAS_HIDDEN( |
5430 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
5431 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5432 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5433 | "Filter updates to/from this neighbor\n" | |
5434 | "IP access-list number\n" | |
5435 | "IP access-list number (expanded range)\n" | |
5436 | "IP Access-list name\n" | |
5437 | "Filter incoming updates\n" | |
5438 | "Filter outgoing updates\n") | |
596c17ba | 5439 | |
718e3744 | 5440 | DEFUN (no_neighbor_distribute_list, |
5441 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 5442 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5443 | NO_STR |
5444 | NEIGHBOR_STR | |
5445 | NEIGHBOR_ADDR_STR2 | |
5446 | "Filter updates to/from this neighbor\n" | |
5447 | "IP access-list number\n" | |
5448 | "IP access-list number (expanded range)\n" | |
5449 | "IP Access-list name\n" | |
5450 | "Filter incoming updates\n" | |
5451 | "Filter outgoing updates\n") | |
5452 | { | |
d62a17ae | 5453 | int idx_peer = 2; |
5454 | int direct, ret; | |
5455 | struct peer *peer; | |
a8206004 | 5456 | |
d62a17ae | 5457 | const char *pstr = argv[idx_peer]->arg; |
5458 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5459 | |
d62a17ae | 5460 | peer = peer_and_group_lookup_vty(vty, pstr); |
5461 | if (!peer) | |
5462 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5463 | |
d62a17ae | 5464 | /* Check filter direction. */ |
5465 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5466 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5467 | direct); | |
a8206004 | 5468 | |
d62a17ae | 5469 | return bgp_vty_return(vty, ret); |
718e3744 | 5470 | } |
6b0655a2 | 5471 | |
d62a17ae | 5472 | ALIAS_HIDDEN( |
5473 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
5474 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5475 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5476 | "Filter updates to/from this neighbor\n" | |
5477 | "IP access-list number\n" | |
5478 | "IP access-list number (expanded range)\n" | |
5479 | "IP Access-list name\n" | |
5480 | "Filter incoming updates\n" | |
5481 | "Filter outgoing updates\n") | |
596c17ba | 5482 | |
718e3744 | 5483 | /* Set prefix list to the peer. */ |
d62a17ae | 5484 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
5485 | afi_t afi, safi_t safi, | |
5486 | const char *name_str, | |
5487 | const char *direct_str) | |
718e3744 | 5488 | { |
d62a17ae | 5489 | int ret; |
d62a17ae | 5490 | int direct = FILTER_IN; |
cf9ac8bf | 5491 | struct peer *peer; |
718e3744 | 5492 | |
d62a17ae | 5493 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5494 | if (!peer) | |
5495 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5496 | |
d62a17ae | 5497 | /* Check filter direction. */ |
5498 | if (strncmp(direct_str, "i", 1) == 0) | |
5499 | direct = FILTER_IN; | |
5500 | else if (strncmp(direct_str, "o", 1) == 0) | |
5501 | direct = FILTER_OUT; | |
718e3744 | 5502 | |
d62a17ae | 5503 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 5504 | |
d62a17ae | 5505 | return bgp_vty_return(vty, ret); |
718e3744 | 5506 | } |
5507 | ||
d62a17ae | 5508 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, |
5509 | afi_t afi, safi_t safi, | |
5510 | const char *direct_str) | |
718e3744 | 5511 | { |
d62a17ae | 5512 | int ret; |
5513 | struct peer *peer; | |
5514 | int direct = FILTER_IN; | |
718e3744 | 5515 | |
d62a17ae | 5516 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5517 | if (!peer) | |
5518 | return CMD_WARNING_CONFIG_FAILED; | |
e52702f2 | 5519 | |
d62a17ae | 5520 | /* Check filter direction. */ |
5521 | if (strncmp(direct_str, "i", 1) == 0) | |
5522 | direct = FILTER_IN; | |
5523 | else if (strncmp(direct_str, "o", 1) == 0) | |
5524 | direct = FILTER_OUT; | |
718e3744 | 5525 | |
d62a17ae | 5526 | ret = peer_prefix_list_unset(peer, afi, safi, direct); |
718e3744 | 5527 | |
d62a17ae | 5528 | return bgp_vty_return(vty, ret); |
718e3744 | 5529 | } |
5530 | ||
5531 | DEFUN (neighbor_prefix_list, | |
5532 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 5533 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5534 | NEIGHBOR_STR |
5535 | NEIGHBOR_ADDR_STR2 | |
5536 | "Filter updates to/from this neighbor\n" | |
5537 | "Name of a prefix list\n" | |
5538 | "Filter incoming updates\n" | |
5539 | "Filter outgoing updates\n") | |
5540 | { | |
d62a17ae | 5541 | int idx_peer = 1; |
5542 | int idx_word = 3; | |
5543 | int idx_in_out = 4; | |
5544 | return peer_prefix_list_set_vty( | |
5545 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5546 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5547 | } |
5548 | ||
d62a17ae | 5549 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
5550 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5551 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5552 | "Filter updates to/from this neighbor\n" | |
5553 | "Name of a prefix list\n" | |
5554 | "Filter incoming updates\n" | |
5555 | "Filter outgoing updates\n") | |
596c17ba | 5556 | |
718e3744 | 5557 | DEFUN (no_neighbor_prefix_list, |
5558 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 5559 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5560 | NO_STR |
5561 | NEIGHBOR_STR | |
5562 | NEIGHBOR_ADDR_STR2 | |
5563 | "Filter updates to/from this neighbor\n" | |
5564 | "Name of a prefix list\n" | |
5565 | "Filter incoming updates\n" | |
5566 | "Filter outgoing updates\n") | |
5567 | { | |
d62a17ae | 5568 | int idx_peer = 2; |
5569 | int idx_in_out = 5; | |
5570 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
5571 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5572 | argv[idx_in_out]->arg); | |
718e3744 | 5573 | } |
6b0655a2 | 5574 | |
d62a17ae | 5575 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, |
5576 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5577 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5578 | "Filter updates to/from this neighbor\n" | |
5579 | "Name of a prefix list\n" | |
5580 | "Filter incoming updates\n" | |
5581 | "Filter outgoing updates\n") | |
596c17ba | 5582 | |
d62a17ae | 5583 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5584 | safi_t safi, const char *name_str, | |
5585 | const char *direct_str) | |
718e3744 | 5586 | { |
d62a17ae | 5587 | int ret; |
5588 | struct peer *peer; | |
5589 | int direct = FILTER_IN; | |
718e3744 | 5590 | |
d62a17ae | 5591 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5592 | if (!peer) | |
5593 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5594 | |
d62a17ae | 5595 | /* Check filter direction. */ |
5596 | if (strncmp(direct_str, "i", 1) == 0) | |
5597 | direct = FILTER_IN; | |
5598 | else if (strncmp(direct_str, "o", 1) == 0) | |
5599 | direct = FILTER_OUT; | |
718e3744 | 5600 | |
d62a17ae | 5601 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 5602 | |
d62a17ae | 5603 | return bgp_vty_return(vty, ret); |
718e3744 | 5604 | } |
5605 | ||
d62a17ae | 5606 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5607 | safi_t safi, const char *direct_str) | |
718e3744 | 5608 | { |
d62a17ae | 5609 | int ret; |
5610 | struct peer *peer; | |
5611 | int direct = FILTER_IN; | |
718e3744 | 5612 | |
d62a17ae | 5613 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5614 | if (!peer) | |
5615 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5616 | |
d62a17ae | 5617 | /* Check filter direction. */ |
5618 | if (strncmp(direct_str, "i", 1) == 0) | |
5619 | direct = FILTER_IN; | |
5620 | else if (strncmp(direct_str, "o", 1) == 0) | |
5621 | direct = FILTER_OUT; | |
718e3744 | 5622 | |
d62a17ae | 5623 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 5624 | |
d62a17ae | 5625 | return bgp_vty_return(vty, ret); |
718e3744 | 5626 | } |
5627 | ||
5628 | DEFUN (neighbor_filter_list, | |
5629 | neighbor_filter_list_cmd, | |
9ccf14f7 | 5630 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5631 | NEIGHBOR_STR |
5632 | NEIGHBOR_ADDR_STR2 | |
5633 | "Establish BGP filters\n" | |
5634 | "AS path access-list name\n" | |
5635 | "Filter incoming routes\n" | |
5636 | "Filter outgoing routes\n") | |
5637 | { | |
d62a17ae | 5638 | int idx_peer = 1; |
5639 | int idx_word = 3; | |
5640 | int idx_in_out = 4; | |
5641 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5642 | bgp_node_safi(vty), argv[idx_word]->arg, | |
5643 | argv[idx_in_out]->arg); | |
718e3744 | 5644 | } |
5645 | ||
d62a17ae | 5646 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
5647 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5648 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5649 | "Establish BGP filters\n" | |
5650 | "AS path access-list name\n" | |
5651 | "Filter incoming routes\n" | |
5652 | "Filter outgoing routes\n") | |
596c17ba | 5653 | |
718e3744 | 5654 | DEFUN (no_neighbor_filter_list, |
5655 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 5656 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5657 | NO_STR |
5658 | NEIGHBOR_STR | |
5659 | NEIGHBOR_ADDR_STR2 | |
5660 | "Establish BGP filters\n" | |
5661 | "AS path access-list name\n" | |
5662 | "Filter incoming routes\n" | |
5663 | "Filter outgoing routes\n") | |
5664 | { | |
d62a17ae | 5665 | int idx_peer = 2; |
5666 | int idx_in_out = 5; | |
5667 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
5668 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5669 | argv[idx_in_out]->arg); | |
718e3744 | 5670 | } |
6b0655a2 | 5671 | |
d62a17ae | 5672 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
5673 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5674 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5675 | "Establish BGP filters\n" | |
5676 | "AS path access-list name\n" | |
5677 | "Filter incoming routes\n" | |
5678 | "Filter outgoing routes\n") | |
596c17ba | 5679 | |
718e3744 | 5680 | /* Set route-map to the peer. */ |
d62a17ae | 5681 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
5682 | afi_t afi, safi_t safi, const char *name_str, | |
5683 | const char *direct_str) | |
718e3744 | 5684 | { |
d62a17ae | 5685 | int ret; |
5686 | struct peer *peer; | |
5687 | int direct = RMAP_IN; | |
1de27621 | 5688 | struct route_map *route_map; |
718e3744 | 5689 | |
d62a17ae | 5690 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5691 | if (!peer) | |
5692 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5693 | |
d62a17ae | 5694 | /* Check filter direction. */ |
5695 | if (strncmp(direct_str, "in", 2) == 0) | |
5696 | direct = RMAP_IN; | |
5697 | else if (strncmp(direct_str, "o", 1) == 0) | |
5698 | direct = RMAP_OUT; | |
718e3744 | 5699 | |
1de27621 DA |
5700 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
5701 | ret = peer_route_map_set(peer, afi, safi, direct, name_str, route_map); | |
718e3744 | 5702 | |
d62a17ae | 5703 | return bgp_vty_return(vty, ret); |
718e3744 | 5704 | } |
5705 | ||
d62a17ae | 5706 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, |
5707 | afi_t afi, safi_t safi, | |
5708 | const char *direct_str) | |
718e3744 | 5709 | { |
d62a17ae | 5710 | int ret; |
5711 | struct peer *peer; | |
5712 | int direct = RMAP_IN; | |
718e3744 | 5713 | |
d62a17ae | 5714 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5715 | if (!peer) | |
5716 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5717 | |
d62a17ae | 5718 | /* Check filter direction. */ |
5719 | if (strncmp(direct_str, "in", 2) == 0) | |
5720 | direct = RMAP_IN; | |
5721 | else if (strncmp(direct_str, "o", 1) == 0) | |
5722 | direct = RMAP_OUT; | |
718e3744 | 5723 | |
d62a17ae | 5724 | ret = peer_route_map_unset(peer, afi, safi, direct); |
718e3744 | 5725 | |
d62a17ae | 5726 | return bgp_vty_return(vty, ret); |
718e3744 | 5727 | } |
5728 | ||
5729 | DEFUN (neighbor_route_map, | |
5730 | neighbor_route_map_cmd, | |
9ccf14f7 | 5731 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5732 | NEIGHBOR_STR |
5733 | NEIGHBOR_ADDR_STR2 | |
5734 | "Apply route map to neighbor\n" | |
5735 | "Name of route map\n" | |
5736 | "Apply map to incoming routes\n" | |
2a3d5731 | 5737 | "Apply map to outbound routes\n") |
718e3744 | 5738 | { |
d62a17ae | 5739 | int idx_peer = 1; |
5740 | int idx_word = 3; | |
5741 | int idx_in_out = 4; | |
5742 | return peer_route_map_set_vty( | |
5743 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5744 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5745 | } |
5746 | ||
d62a17ae | 5747 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
5748 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5749 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5750 | "Apply route map to neighbor\n" | |
5751 | "Name of route map\n" | |
5752 | "Apply map to incoming routes\n" | |
5753 | "Apply map to outbound routes\n") | |
596c17ba | 5754 | |
718e3744 | 5755 | DEFUN (no_neighbor_route_map, |
5756 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 5757 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5758 | NO_STR |
5759 | NEIGHBOR_STR | |
5760 | NEIGHBOR_ADDR_STR2 | |
5761 | "Apply route map to neighbor\n" | |
5762 | "Name of route map\n" | |
5763 | "Apply map to incoming routes\n" | |
2a3d5731 | 5764 | "Apply map to outbound routes\n") |
718e3744 | 5765 | { |
d62a17ae | 5766 | int idx_peer = 2; |
5767 | int idx_in_out = 5; | |
5768 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
5769 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5770 | argv[idx_in_out]->arg); | |
718e3744 | 5771 | } |
6b0655a2 | 5772 | |
d62a17ae | 5773 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, |
5774 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5775 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5776 | "Apply route map to neighbor\n" | |
5777 | "Name of route map\n" | |
5778 | "Apply map to incoming routes\n" | |
5779 | "Apply map to outbound routes\n") | |
596c17ba | 5780 | |
718e3744 | 5781 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 5782 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
5783 | afi_t afi, safi_t safi, | |
5784 | const char *name_str) | |
718e3744 | 5785 | { |
d62a17ae | 5786 | int ret; |
5787 | struct peer *peer; | |
1de27621 | 5788 | struct route_map *route_map; |
718e3744 | 5789 | |
d62a17ae | 5790 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5791 | if (!peer) | |
5792 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5793 | |
1de27621 DA |
5794 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
5795 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str, route_map); | |
718e3744 | 5796 | |
d62a17ae | 5797 | return bgp_vty_return(vty, ret); |
718e3744 | 5798 | } |
5799 | ||
5800 | /* Unset route-map from the peer. */ | |
d62a17ae | 5801 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
5802 | afi_t afi, safi_t safi) | |
718e3744 | 5803 | { |
d62a17ae | 5804 | int ret; |
5805 | struct peer *peer; | |
718e3744 | 5806 | |
d62a17ae | 5807 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5808 | if (!peer) | |
5809 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5810 | |
d62a17ae | 5811 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 5812 | |
d62a17ae | 5813 | return bgp_vty_return(vty, ret); |
718e3744 | 5814 | } |
5815 | ||
5816 | DEFUN (neighbor_unsuppress_map, | |
5817 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5818 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5819 | NEIGHBOR_STR |
5820 | NEIGHBOR_ADDR_STR2 | |
5821 | "Route-map to selectively unsuppress suppressed routes\n" | |
5822 | "Name of route map\n") | |
5823 | { | |
d62a17ae | 5824 | int idx_peer = 1; |
5825 | int idx_word = 3; | |
5826 | return peer_unsuppress_map_set_vty( | |
5827 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5828 | argv[idx_word]->arg); | |
718e3744 | 5829 | } |
5830 | ||
d62a17ae | 5831 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
5832 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5833 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5834 | "Route-map to selectively unsuppress suppressed routes\n" | |
5835 | "Name of route map\n") | |
596c17ba | 5836 | |
718e3744 | 5837 | DEFUN (no_neighbor_unsuppress_map, |
5838 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5839 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5840 | NO_STR |
5841 | NEIGHBOR_STR | |
5842 | NEIGHBOR_ADDR_STR2 | |
5843 | "Route-map to selectively unsuppress suppressed routes\n" | |
5844 | "Name of route map\n") | |
5845 | { | |
d62a17ae | 5846 | int idx_peer = 2; |
5847 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
5848 | bgp_node_afi(vty), | |
5849 | bgp_node_safi(vty)); | |
718e3744 | 5850 | } |
6b0655a2 | 5851 | |
d62a17ae | 5852 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
5853 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5854 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5855 | "Route-map to selectively unsuppress suppressed routes\n" | |
5856 | "Name of route map\n") | |
596c17ba | 5857 | |
d62a17ae | 5858 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
5859 | afi_t afi, safi_t safi, | |
5860 | const char *num_str, | |
5861 | const char *threshold_str, int warning, | |
5862 | const char *restart_str) | |
718e3744 | 5863 | { |
d62a17ae | 5864 | int ret; |
5865 | struct peer *peer; | |
d7c0a89a QY |
5866 | uint32_t max; |
5867 | uint8_t threshold; | |
5868 | uint16_t restart; | |
718e3744 | 5869 | |
d62a17ae | 5870 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5871 | if (!peer) | |
5872 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5873 | |
d62a17ae | 5874 | max = strtoul(num_str, NULL, 10); |
5875 | if (threshold_str) | |
5876 | threshold = atoi(threshold_str); | |
5877 | else | |
5878 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 5879 | |
d62a17ae | 5880 | if (restart_str) |
5881 | restart = atoi(restart_str); | |
5882 | else | |
5883 | restart = 0; | |
0a486e5f | 5884 | |
d62a17ae | 5885 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, |
5886 | restart); | |
718e3744 | 5887 | |
d62a17ae | 5888 | return bgp_vty_return(vty, ret); |
718e3744 | 5889 | } |
5890 | ||
d62a17ae | 5891 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, |
5892 | afi_t afi, safi_t safi) | |
718e3744 | 5893 | { |
d62a17ae | 5894 | int ret; |
5895 | struct peer *peer; | |
718e3744 | 5896 | |
d62a17ae | 5897 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5898 | if (!peer) | |
5899 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5900 | |
d62a17ae | 5901 | ret = peer_maximum_prefix_unset(peer, afi, safi); |
718e3744 | 5902 | |
d62a17ae | 5903 | return bgp_vty_return(vty, ret); |
718e3744 | 5904 | } |
5905 | ||
5906 | /* Maximum number of prefix configuration. prefix count is different | |
5907 | for each peer configuration. So this configuration can be set for | |
5908 | each peer configuration. */ | |
5909 | DEFUN (neighbor_maximum_prefix, | |
5910 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 5911 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 5912 | NEIGHBOR_STR |
5913 | NEIGHBOR_ADDR_STR2 | |
5914 | "Maximum number of prefix accept from this peer\n" | |
5915 | "maximum no. of prefix limit\n") | |
5916 | { | |
d62a17ae | 5917 | int idx_peer = 1; |
5918 | int idx_number = 3; | |
5919 | return peer_maximum_prefix_set_vty( | |
5920 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5921 | argv[idx_number]->arg, NULL, 0, NULL); | |
718e3744 | 5922 | } |
5923 | ||
d62a17ae | 5924 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
5925 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", | |
5926 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5927 | "Maximum number of prefix accept from this peer\n" | |
5928 | "maximum no. of prefix limit\n") | |
596c17ba | 5929 | |
e0701b79 | 5930 | DEFUN (neighbor_maximum_prefix_threshold, |
5931 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 5932 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 5933 | NEIGHBOR_STR |
5934 | NEIGHBOR_ADDR_STR2 | |
5935 | "Maximum number of prefix accept from this peer\n" | |
5936 | "maximum no. of prefix limit\n" | |
5937 | "Threshold value (%) at which to generate a warning msg\n") | |
5938 | { | |
d62a17ae | 5939 | int idx_peer = 1; |
5940 | int idx_number = 3; | |
5941 | int idx_number_2 = 4; | |
5942 | return peer_maximum_prefix_set_vty( | |
5943 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5944 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL); | |
0a486e5f | 5945 | } |
e0701b79 | 5946 | |
d62a17ae | 5947 | ALIAS_HIDDEN( |
5948 | neighbor_maximum_prefix_threshold, | |
5949 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
5950 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", | |
5951 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5952 | "Maximum number of prefix accept from this peer\n" | |
5953 | "maximum no. of prefix limit\n" | |
5954 | "Threshold value (%) at which to generate a warning msg\n") | |
596c17ba | 5955 | |
718e3744 | 5956 | DEFUN (neighbor_maximum_prefix_warning, |
5957 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 5958 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 5959 | NEIGHBOR_STR |
5960 | NEIGHBOR_ADDR_STR2 | |
5961 | "Maximum number of prefix accept from this peer\n" | |
5962 | "maximum no. of prefix limit\n" | |
5963 | "Only give warning message when limit is exceeded\n") | |
5964 | { | |
d62a17ae | 5965 | int idx_peer = 1; |
5966 | int idx_number = 3; | |
5967 | return peer_maximum_prefix_set_vty( | |
5968 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5969 | argv[idx_number]->arg, NULL, 1, NULL); | |
718e3744 | 5970 | } |
5971 | ||
d62a17ae | 5972 | ALIAS_HIDDEN( |
5973 | neighbor_maximum_prefix_warning, | |
5974 | neighbor_maximum_prefix_warning_hidden_cmd, | |
5975 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", | |
5976 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5977 | "Maximum number of prefix accept from this peer\n" | |
5978 | "maximum no. of prefix limit\n" | |
5979 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 5980 | |
e0701b79 | 5981 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
5982 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 5983 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 5984 | NEIGHBOR_STR |
5985 | NEIGHBOR_ADDR_STR2 | |
5986 | "Maximum number of prefix accept from this peer\n" | |
5987 | "maximum no. of prefix limit\n" | |
5988 | "Threshold value (%) at which to generate a warning msg\n" | |
5989 | "Only give warning message when limit is exceeded\n") | |
5990 | { | |
d62a17ae | 5991 | int idx_peer = 1; |
5992 | int idx_number = 3; | |
5993 | int idx_number_2 = 4; | |
5994 | return peer_maximum_prefix_set_vty( | |
5995 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5996 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 5997 | } |
5998 | ||
d62a17ae | 5999 | ALIAS_HIDDEN( |
6000 | neighbor_maximum_prefix_threshold_warning, | |
6001 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
6002 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", | |
6003 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6004 | "Maximum number of prefix accept from this peer\n" | |
6005 | "maximum no. of prefix limit\n" | |
6006 | "Threshold value (%) at which to generate a warning msg\n" | |
6007 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6008 | |
0a486e5f | 6009 | DEFUN (neighbor_maximum_prefix_restart, |
6010 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 6011 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 6012 | NEIGHBOR_STR |
6013 | NEIGHBOR_ADDR_STR2 | |
6014 | "Maximum number of prefix accept from this peer\n" | |
6015 | "maximum no. of prefix limit\n" | |
6016 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 6017 | "Restart interval in minutes\n") |
0a486e5f | 6018 | { |
d62a17ae | 6019 | int idx_peer = 1; |
6020 | int idx_number = 3; | |
6021 | int idx_number_2 = 5; | |
6022 | return peer_maximum_prefix_set_vty( | |
6023 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6024 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 6025 | } |
6026 | ||
d62a17ae | 6027 | ALIAS_HIDDEN( |
6028 | neighbor_maximum_prefix_restart, | |
6029 | neighbor_maximum_prefix_restart_hidden_cmd, | |
6030 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", | |
6031 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6032 | "Maximum number of prefix accept from this peer\n" | |
6033 | "maximum no. of prefix limit\n" | |
6034 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 6035 | "Restart interval in minutes\n") |
596c17ba | 6036 | |
0a486e5f | 6037 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
6038 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 6039 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 6040 | NEIGHBOR_STR |
6041 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6042 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 6043 | "maximum no. of prefix limit\n" |
6044 | "Threshold value (%) at which to generate a warning msg\n" | |
6045 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6046 | "Restart interval in minutes\n") |
0a486e5f | 6047 | { |
d62a17ae | 6048 | int idx_peer = 1; |
6049 | int idx_number = 3; | |
6050 | int idx_number_2 = 4; | |
6051 | int idx_number_3 = 6; | |
6052 | return peer_maximum_prefix_set_vty( | |
6053 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6054 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
6055 | argv[idx_number_3]->arg); | |
6056 | } | |
6057 | ||
6058 | ALIAS_HIDDEN( | |
6059 | neighbor_maximum_prefix_threshold_restart, | |
6060 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
6061 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", | |
6062 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6063 | "Maximum number of prefixes to accept from this peer\n" | |
6064 | "maximum no. of prefix limit\n" | |
6065 | "Threshold value (%) at which to generate a warning msg\n" | |
6066 | "Restart bgp connection after limit is exceeded\n" | |
6067 | "Restart interval in minutes\n") | |
596c17ba | 6068 | |
718e3744 | 6069 | DEFUN (no_neighbor_maximum_prefix, |
6070 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 6071 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 6072 | NO_STR |
6073 | NEIGHBOR_STR | |
6074 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6075 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
6076 | "maximum no. of prefix limit\n" |
6077 | "Threshold value (%) at which to generate a warning msg\n" | |
6078 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6079 | "Restart interval in minutes\n" |
31500417 | 6080 | "Only give warning message when limit is exceeded\n") |
718e3744 | 6081 | { |
d62a17ae | 6082 | int idx_peer = 2; |
6083 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, | |
6084 | bgp_node_afi(vty), | |
6085 | bgp_node_safi(vty)); | |
718e3744 | 6086 | } |
e52702f2 | 6087 | |
d62a17ae | 6088 | ALIAS_HIDDEN( |
6089 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
6090 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", | |
6091 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6092 | "Maximum number of prefixes to accept from this peer\n" | |
6093 | "maximum no. of prefix limit\n" | |
6094 | "Threshold value (%) at which to generate a warning msg\n" | |
6095 | "Restart bgp connection after limit is exceeded\n" | |
6096 | "Restart interval in minutes\n" | |
6097 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6098 | |
718e3744 | 6099 | |
718e3744 | 6100 | /* "neighbor allowas-in" */ |
6101 | DEFUN (neighbor_allowas_in, | |
6102 | neighbor_allowas_in_cmd, | |
fd8503f5 | 6103 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6104 | NEIGHBOR_STR |
6105 | NEIGHBOR_ADDR_STR2 | |
31500417 | 6106 | "Accept as-path with my AS present in it\n" |
0437e105 | 6107 | "Number of occurences of AS number\n" |
fd8503f5 | 6108 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 6109 | { |
d62a17ae | 6110 | int idx_peer = 1; |
6111 | int idx_number_origin = 3; | |
6112 | int ret; | |
6113 | int origin = 0; | |
6114 | struct peer *peer; | |
6115 | int allow_num = 0; | |
6116 | ||
6117 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6118 | if (!peer) | |
6119 | return CMD_WARNING_CONFIG_FAILED; | |
6120 | ||
6121 | if (argc <= idx_number_origin) | |
6122 | allow_num = 3; | |
6123 | else { | |
6124 | if (argv[idx_number_origin]->type == WORD_TKN) | |
6125 | origin = 1; | |
6126 | else | |
6127 | allow_num = atoi(argv[idx_number_origin]->arg); | |
6128 | } | |
6129 | ||
6130 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6131 | allow_num, origin); | |
6132 | ||
6133 | return bgp_vty_return(vty, ret); | |
6134 | } | |
6135 | ||
6136 | ALIAS_HIDDEN( | |
6137 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
6138 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6139 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6140 | "Accept as-path with my AS present in it\n" | |
0437e105 | 6141 | "Number of occurences of AS number\n" |
d62a17ae | 6142 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 6143 | |
718e3744 | 6144 | DEFUN (no_neighbor_allowas_in, |
6145 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 6146 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6147 | NO_STR |
6148 | NEIGHBOR_STR | |
6149 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 6150 | "allow local ASN appears in aspath attribute\n" |
0437e105 | 6151 | "Number of occurences of AS number\n" |
fd8503f5 | 6152 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 6153 | { |
d62a17ae | 6154 | int idx_peer = 2; |
6155 | int ret; | |
6156 | struct peer *peer; | |
718e3744 | 6157 | |
d62a17ae | 6158 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6159 | if (!peer) | |
6160 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6161 | |
d62a17ae | 6162 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
6163 | bgp_node_safi(vty)); | |
718e3744 | 6164 | |
d62a17ae | 6165 | return bgp_vty_return(vty, ret); |
718e3744 | 6166 | } |
6b0655a2 | 6167 | |
d62a17ae | 6168 | ALIAS_HIDDEN( |
6169 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
6170 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6171 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6172 | "allow local ASN appears in aspath attribute\n" | |
0437e105 | 6173 | "Number of occurences of AS number\n" |
d62a17ae | 6174 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 6175 | |
fa411a21 NH |
6176 | DEFUN (neighbor_ttl_security, |
6177 | neighbor_ttl_security_cmd, | |
7ebe625c | 6178 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 | 6179 | NEIGHBOR_STR |
7ebe625c | 6180 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6181 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
6182 | "Specify the maximum number of hops to the BGP peer\n" |
6183 | "Number of hops to BGP peer\n") | |
fa411a21 | 6184 | { |
d62a17ae | 6185 | int idx_peer = 1; |
6186 | int idx_number = 4; | |
6187 | struct peer *peer; | |
6188 | int gtsm_hops; | |
6189 | ||
6190 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6191 | if (!peer) | |
6192 | return CMD_WARNING_CONFIG_FAILED; | |
6193 | ||
6194 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); | |
6195 | ||
7ebe625c QY |
6196 | /* |
6197 | * If 'neighbor swpX', then this is for directly connected peers, | |
6198 | * we should not accept a ttl-security hops value greater than 1. | |
6199 | */ | |
6200 | if (peer->conf_if && (gtsm_hops > 1)) { | |
6201 | vty_out(vty, | |
6202 | "%s is directly connected peer, hops cannot exceed 1\n", | |
6203 | argv[idx_peer]->arg); | |
6204 | return CMD_WARNING_CONFIG_FAILED; | |
6205 | } | |
6206 | ||
d62a17ae | 6207 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
6208 | } |
6209 | ||
6210 | DEFUN (no_neighbor_ttl_security, | |
6211 | no_neighbor_ttl_security_cmd, | |
7ebe625c | 6212 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
6213 | NO_STR |
6214 | NEIGHBOR_STR | |
7ebe625c | 6215 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6216 | "BGP ttl-security parameters\n" |
3a2d747c QY |
6217 | "Specify the maximum number of hops to the BGP peer\n" |
6218 | "Number of hops to BGP peer\n") | |
fa411a21 | 6219 | { |
d62a17ae | 6220 | int idx_peer = 2; |
6221 | struct peer *peer; | |
fa411a21 | 6222 | |
d62a17ae | 6223 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6224 | if (!peer) | |
6225 | return CMD_WARNING_CONFIG_FAILED; | |
fa411a21 | 6226 | |
d62a17ae | 6227 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 6228 | } |
6b0655a2 | 6229 | |
adbac85e DW |
6230 | DEFUN (neighbor_addpath_tx_all_paths, |
6231 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6232 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6233 | NEIGHBOR_STR |
6234 | NEIGHBOR_ADDR_STR2 | |
6235 | "Use addpath to advertise all paths to a neighbor\n") | |
6236 | { | |
d62a17ae | 6237 | int idx_peer = 1; |
6238 | struct peer *peer; | |
adbac85e | 6239 | |
d62a17ae | 6240 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6241 | if (!peer) | |
6242 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 6243 | |
dcc68b5e MS |
6244 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
6245 | BGP_ADDPATH_ALL); | |
6246 | return CMD_SUCCESS; | |
adbac85e DW |
6247 | } |
6248 | ||
d62a17ae | 6249 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
6250 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
6251 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6252 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6253 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6254 | |
adbac85e DW |
6255 | DEFUN (no_neighbor_addpath_tx_all_paths, |
6256 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6257 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6258 | NO_STR |
6259 | NEIGHBOR_STR | |
6260 | NEIGHBOR_ADDR_STR2 | |
6261 | "Use addpath to advertise all paths to a neighbor\n") | |
6262 | { | |
d62a17ae | 6263 | int idx_peer = 2; |
dcc68b5e MS |
6264 | struct peer *peer; |
6265 | ||
6266 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6267 | if (!peer) | |
6268 | return CMD_WARNING_CONFIG_FAILED; | |
6269 | ||
6270 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
6271 | != BGP_ADDPATH_ALL) { | |
6272 | vty_out(vty, | |
6273 | "%% Peer not currently configured to transmit all paths."); | |
6274 | return CMD_WARNING_CONFIG_FAILED; | |
6275 | } | |
6276 | ||
6277 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6278 | BGP_ADDPATH_NONE); | |
6279 | ||
6280 | return CMD_SUCCESS; | |
adbac85e DW |
6281 | } |
6282 | ||
d62a17ae | 6283 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
6284 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
6285 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6286 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6287 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6288 | |
06370dac DW |
6289 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
6290 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6291 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6292 | NEIGHBOR_STR |
6293 | NEIGHBOR_ADDR_STR2 | |
6294 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6295 | { | |
d62a17ae | 6296 | int idx_peer = 1; |
6297 | struct peer *peer; | |
06370dac | 6298 | |
d62a17ae | 6299 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6300 | if (!peer) | |
6301 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 6302 | |
dcc68b5e MS |
6303 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
6304 | BGP_ADDPATH_BEST_PER_AS); | |
6305 | ||
6306 | return CMD_SUCCESS; | |
06370dac DW |
6307 | } |
6308 | ||
d62a17ae | 6309 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
6310 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6311 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6312 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6313 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 6314 | |
06370dac DW |
6315 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
6316 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6317 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6318 | NO_STR |
6319 | NEIGHBOR_STR | |
6320 | NEIGHBOR_ADDR_STR2 | |
6321 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6322 | { | |
d62a17ae | 6323 | int idx_peer = 2; |
dcc68b5e MS |
6324 | struct peer *peer; |
6325 | ||
6326 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6327 | if (!peer) | |
6328 | return CMD_WARNING_CONFIG_FAILED; | |
6329 | ||
6330 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
6331 | != BGP_ADDPATH_BEST_PER_AS) { | |
6332 | vty_out(vty, | |
6333 | "%% Peer not currently configured to transmit all best path per as."); | |
6334 | return CMD_WARNING_CONFIG_FAILED; | |
6335 | } | |
6336 | ||
6337 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6338 | BGP_ADDPATH_NONE); | |
6339 | ||
6340 | return CMD_SUCCESS; | |
06370dac DW |
6341 | } |
6342 | ||
d62a17ae | 6343 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
6344 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6345 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6346 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6347 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 6348 | |
b9c7bc5a PZ |
6349 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
6350 | struct ecommunity **list) | |
ddb5b488 | 6351 | { |
b9c7bc5a PZ |
6352 | struct ecommunity *ecom = NULL; |
6353 | struct ecommunity *ecomadd; | |
ddb5b488 | 6354 | |
b9c7bc5a | 6355 | for (; argc; --argc, ++argv) { |
ddb5b488 | 6356 | |
b9c7bc5a PZ |
6357 | ecomadd = ecommunity_str2com(argv[0]->arg, |
6358 | ECOMMUNITY_ROUTE_TARGET, 0); | |
6359 | if (!ecomadd) { | |
6360 | vty_out(vty, "Malformed community-list value\n"); | |
6361 | if (ecom) | |
6362 | ecommunity_free(&ecom); | |
6363 | return CMD_WARNING_CONFIG_FAILED; | |
6364 | } | |
ddb5b488 | 6365 | |
b9c7bc5a PZ |
6366 | if (ecom) { |
6367 | ecommunity_merge(ecom, ecomadd); | |
6368 | ecommunity_free(&ecomadd); | |
6369 | } else { | |
6370 | ecom = ecomadd; | |
6371 | } | |
6372 | } | |
6373 | ||
6374 | if (*list) { | |
6375 | ecommunity_free(&*list); | |
ddb5b488 | 6376 | } |
b9c7bc5a PZ |
6377 | *list = ecom; |
6378 | ||
6379 | return CMD_SUCCESS; | |
ddb5b488 PZ |
6380 | } |
6381 | ||
0ca70ba5 DS |
6382 | /* |
6383 | * v2vimport is true if we are handling a `import vrf ...` command | |
6384 | */ | |
6385 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 6386 | { |
0ca70ba5 DS |
6387 | afi_t afi; |
6388 | ||
ddb5b488 | 6389 | switch (vty->node) { |
b9c7bc5a | 6390 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
6391 | afi = AFI_IP; |
6392 | break; | |
b9c7bc5a | 6393 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
6394 | afi = AFI_IP6; |
6395 | break; | |
ddb5b488 PZ |
6396 | default: |
6397 | vty_out(vty, | |
b9c7bc5a | 6398 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 6399 | return AFI_MAX; |
ddb5b488 | 6400 | } |
69b07479 | 6401 | |
0ca70ba5 DS |
6402 | if (!v2vimport) { |
6403 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6404 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
6405 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6406 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
6407 | vty_out(vty, | |
6408 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
6409 | return AFI_MAX; | |
6410 | } | |
6411 | } else { | |
6412 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6413 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
6414 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6415 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
6416 | vty_out(vty, | |
6417 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
6418 | return AFI_MAX; | |
6419 | } | |
6420 | } | |
6421 | return afi; | |
ddb5b488 PZ |
6422 | } |
6423 | ||
b9c7bc5a PZ |
6424 | DEFPY (af_rd_vpn_export, |
6425 | af_rd_vpn_export_cmd, | |
6426 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
6427 | NO_STR | |
ddb5b488 | 6428 | "Specify route distinguisher\n" |
b9c7bc5a PZ |
6429 | "Between current address-family and vpn\n" |
6430 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6431 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") |
6432 | { | |
6433 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6434 | struct prefix_rd prd; | |
6435 | int ret; | |
ddb5b488 | 6436 | afi_t afi; |
b9c7bc5a PZ |
6437 | int idx = 0; |
6438 | int yes = 1; | |
ddb5b488 | 6439 | |
b9c7bc5a | 6440 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6441 | yes = 0; |
b9c7bc5a PZ |
6442 | |
6443 | if (yes) { | |
6444 | ret = str2prefix_rd(rd_str, &prd); | |
6445 | if (!ret) { | |
6446 | vty_out(vty, "%% Malformed rd\n"); | |
6447 | return CMD_WARNING_CONFIG_FAILED; | |
6448 | } | |
ddb5b488 PZ |
6449 | } |
6450 | ||
0ca70ba5 | 6451 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6452 | if (afi == AFI_MAX) |
6453 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6454 | |
69b07479 DS |
6455 | /* |
6456 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6457 | */ | |
6458 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6459 | bgp_get_default(), bgp); | |
ddb5b488 | 6460 | |
69b07479 DS |
6461 | if (yes) { |
6462 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
6463 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6464 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
6465 | } else { | |
6466 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
6467 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
ddb5b488 PZ |
6468 | } |
6469 | ||
69b07479 DS |
6470 | /* post-change: re-export vpn routes */ |
6471 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6472 | bgp_get_default(), bgp); | |
6473 | ||
ddb5b488 PZ |
6474 | return CMD_SUCCESS; |
6475 | } | |
6476 | ||
b9c7bc5a PZ |
6477 | ALIAS (af_rd_vpn_export, |
6478 | af_no_rd_vpn_export_cmd, | |
6479 | "no rd vpn export", | |
ddb5b488 | 6480 | NO_STR |
b9c7bc5a PZ |
6481 | "Specify route distinguisher\n" |
6482 | "Between current address-family and vpn\n" | |
6483 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6484 | |
b9c7bc5a PZ |
6485 | DEFPY (af_label_vpn_export, |
6486 | af_label_vpn_export_cmd, | |
e70e9f8e | 6487 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 6488 | NO_STR |
ddb5b488 | 6489 | "label value for VRF\n" |
b9c7bc5a PZ |
6490 | "Between current address-family and vpn\n" |
6491 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
6492 | "Label Value <0-1048575>\n" |
6493 | "Automatically assign a label\n") | |
ddb5b488 PZ |
6494 | { |
6495 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 6496 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 6497 | afi_t afi; |
b9c7bc5a PZ |
6498 | int idx = 0; |
6499 | int yes = 1; | |
6500 | ||
6501 | if (argv_find(argv, argc, "no", &idx)) | |
d555f3e9 | 6502 | yes = 0; |
ddb5b488 | 6503 | |
21a16cc2 PZ |
6504 | /* If "no ...", squash trailing parameter */ |
6505 | if (!yes) | |
6506 | label_auto = NULL; | |
6507 | ||
e70e9f8e PZ |
6508 | if (yes) { |
6509 | if (!label_auto) | |
6510 | label = label_val; /* parser should force unsigned */ | |
6511 | } | |
ddb5b488 | 6512 | |
0ca70ba5 | 6513 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6514 | if (afi == AFI_MAX) |
6515 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 6516 | |
e70e9f8e | 6517 | |
69b07479 DS |
6518 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
6519 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
6520 | /* no change */ | |
6521 | return CMD_SUCCESS; | |
e70e9f8e | 6522 | |
69b07479 DS |
6523 | /* |
6524 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6525 | */ | |
6526 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6527 | bgp_get_default(), bgp); | |
6528 | ||
6529 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
6530 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
6531 | ||
6532 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
6533 | ||
6534 | /* | |
6535 | * label has previously been automatically | |
6536 | * assigned by labelpool: release it | |
6537 | * | |
6538 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
6539 | * means the automatic assignment is in flight | |
6540 | * and therefore the labelpool callback must | |
6541 | * detect that the auto label is not needed. | |
6542 | */ | |
6543 | ||
6544 | bgp_lp_release(LP_TYPE_VRF, | |
6545 | &bgp->vpn_policy[afi], | |
6546 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 6547 | } |
69b07479 DS |
6548 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
6549 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
6550 | } | |
ddb5b488 | 6551 | |
69b07479 DS |
6552 | bgp->vpn_policy[afi].tovpn_label = label; |
6553 | if (label_auto) { | |
6554 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6555 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
6556 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
6557 | vpn_leak_label_callback); | |
ddb5b488 PZ |
6558 | } |
6559 | ||
69b07479 DS |
6560 | /* post-change: re-export vpn routes */ |
6561 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6562 | bgp_get_default(), bgp); | |
6563 | ||
ddb5b488 PZ |
6564 | return CMD_SUCCESS; |
6565 | } | |
6566 | ||
b9c7bc5a PZ |
6567 | ALIAS (af_label_vpn_export, |
6568 | af_no_label_vpn_export_cmd, | |
6569 | "no label vpn export", | |
6570 | NO_STR | |
6571 | "label value for VRF\n" | |
6572 | "Between current address-family and vpn\n" | |
6573 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6574 | |
b9c7bc5a PZ |
6575 | DEFPY (af_nexthop_vpn_export, |
6576 | af_nexthop_vpn_export_cmd, | |
6577 | "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str", | |
6578 | NO_STR | |
ddb5b488 | 6579 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
6580 | "Between current address-family and vpn\n" |
6581 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6582 | "IPv4 prefix\n" |
6583 | "IPv6 prefix\n") | |
6584 | { | |
6585 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
ddb5b488 | 6586 | afi_t afi; |
ddb5b488 | 6587 | struct prefix p; |
b9c7bc5a PZ |
6588 | int idx = 0; |
6589 | int yes = 1; | |
ddb5b488 | 6590 | |
b9c7bc5a | 6591 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6592 | yes = 0; |
b9c7bc5a PZ |
6593 | |
6594 | if (yes) { | |
6595 | if (!sockunion2hostprefix(nexthop_str, &p)) | |
6596 | return CMD_WARNING_CONFIG_FAILED; | |
6597 | } | |
ddb5b488 | 6598 | |
0ca70ba5 | 6599 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6600 | if (afi == AFI_MAX) |
6601 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6602 | |
69b07479 DS |
6603 | /* |
6604 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6605 | */ | |
6606 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6607 | bgp_get_default(), bgp); | |
ddb5b488 | 6608 | |
69b07479 DS |
6609 | if (yes) { |
6610 | bgp->vpn_policy[afi].tovpn_nexthop = p; | |
6611 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6612 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
6613 | } else { | |
6614 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
6615 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
ddb5b488 PZ |
6616 | } |
6617 | ||
69b07479 DS |
6618 | /* post-change: re-export vpn routes */ |
6619 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6620 | bgp_get_default(), bgp); | |
6621 | ||
ddb5b488 PZ |
6622 | return CMD_SUCCESS; |
6623 | } | |
6624 | ||
b9c7bc5a PZ |
6625 | ALIAS (af_nexthop_vpn_export, |
6626 | af_no_nexthop_vpn_export_cmd, | |
6627 | "no nexthop vpn export", | |
ddb5b488 | 6628 | NO_STR |
b9c7bc5a PZ |
6629 | "Specify next hop to use for VRF advertised prefixes\n" |
6630 | "Between current address-family and vpn\n" | |
6631 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6632 | |
b9c7bc5a | 6633 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 6634 | { |
b9c7bc5a PZ |
6635 | if (!strcmp(dstr, "import")) { |
6636 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
6637 | } else if (!strcmp(dstr, "export")) { | |
6638 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
6639 | } else if (!strcmp(dstr, "both")) { | |
6640 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
6641 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
6642 | } else { | |
6643 | vty_out(vty, "%% direction parse error\n"); | |
6644 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6645 | } |
ddb5b488 PZ |
6646 | return CMD_SUCCESS; |
6647 | } | |
6648 | ||
b9c7bc5a PZ |
6649 | DEFPY (af_rt_vpn_imexport, |
6650 | af_rt_vpn_imexport_cmd, | |
6651 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
6652 | NO_STR | |
6653 | "Specify route target list\n" | |
ddb5b488 | 6654 | "Specify route target list\n" |
b9c7bc5a PZ |
6655 | "Between current address-family and vpn\n" |
6656 | "For routes leaked from vpn to current address-family: match any\n" | |
6657 | "For routes leaked from current address-family to vpn: set\n" | |
6658 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
6659 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
6660 | { | |
6661 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6662 | int ret; | |
6663 | struct ecommunity *ecom = NULL; | |
6664 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
6665 | vpn_policy_direction_t dir; |
6666 | afi_t afi; | |
6667 | int idx = 0; | |
b9c7bc5a | 6668 | int yes = 1; |
ddb5b488 | 6669 | |
b9c7bc5a | 6670 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6671 | yes = 0; |
b9c7bc5a | 6672 | |
0ca70ba5 | 6673 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6674 | if (afi == AFI_MAX) |
6675 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6676 | |
b9c7bc5a | 6677 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
6678 | if (ret != CMD_SUCCESS) |
6679 | return ret; | |
6680 | ||
b9c7bc5a PZ |
6681 | if (yes) { |
6682 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
6683 | vty_out(vty, "%% Missing RTLIST\n"); | |
6684 | return CMD_WARNING_CONFIG_FAILED; | |
6685 | } | |
6686 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
6687 | if (ret != CMD_SUCCESS) { | |
6688 | return ret; | |
6689 | } | |
ddb5b488 PZ |
6690 | } |
6691 | ||
69b07479 DS |
6692 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
6693 | if (!dodir[dir]) | |
ddb5b488 | 6694 | continue; |
ddb5b488 | 6695 | |
69b07479 | 6696 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 6697 | |
69b07479 DS |
6698 | if (yes) { |
6699 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
6700 | ecommunity_free( | |
6701 | &bgp->vpn_policy[afi].rtlist[dir]); | |
6702 | bgp->vpn_policy[afi].rtlist[dir] = | |
6703 | ecommunity_dup(ecom); | |
6704 | } else { | |
6705 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
6706 | ecommunity_free( | |
6707 | &bgp->vpn_policy[afi].rtlist[dir]); | |
6708 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 6709 | } |
69b07479 DS |
6710 | |
6711 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 6712 | } |
69b07479 | 6713 | |
d555f3e9 PZ |
6714 | if (ecom) |
6715 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
6716 | |
6717 | return CMD_SUCCESS; | |
6718 | } | |
6719 | ||
b9c7bc5a PZ |
6720 | ALIAS (af_rt_vpn_imexport, |
6721 | af_no_rt_vpn_imexport_cmd, | |
6722 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
6723 | NO_STR |
6724 | "Specify route target list\n" | |
b9c7bc5a PZ |
6725 | "Specify route target list\n" |
6726 | "Between current address-family and vpn\n" | |
6727 | "For routes leaked from vpn to current address-family\n" | |
6728 | "For routes leaked from current address-family to vpn\n" | |
6729 | "both import and export\n") | |
6730 | ||
6731 | DEFPY (af_route_map_vpn_imexport, | |
6732 | af_route_map_vpn_imexport_cmd, | |
6733 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
6734 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
6735 | NO_STR | |
ddb5b488 | 6736 | "Specify route map\n" |
b9c7bc5a PZ |
6737 | "Between current address-family and vpn\n" |
6738 | "For routes leaked from vpn to current address-family\n" | |
6739 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6740 | "name of route-map\n") |
6741 | { | |
6742 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6743 | int ret; | |
6744 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
6745 | vpn_policy_direction_t dir; |
6746 | afi_t afi; | |
ddb5b488 | 6747 | int idx = 0; |
b9c7bc5a | 6748 | int yes = 1; |
ddb5b488 | 6749 | |
b9c7bc5a | 6750 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6751 | yes = 0; |
b9c7bc5a | 6752 | |
0ca70ba5 | 6753 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6754 | if (afi == AFI_MAX) |
6755 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6756 | |
b9c7bc5a | 6757 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
6758 | if (ret != CMD_SUCCESS) |
6759 | return ret; | |
6760 | ||
69b07479 DS |
6761 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
6762 | if (!dodir[dir]) | |
ddb5b488 | 6763 | continue; |
ddb5b488 | 6764 | |
69b07479 | 6765 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 6766 | |
69b07479 DS |
6767 | if (yes) { |
6768 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6769 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6770 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6771 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
6772 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
6773 | bgp->vpn_policy[afi].rmap[dir] = | |
1de27621 | 6774 | route_map_lookup_warn_noexist(vty, rmap_str); |
69b07479 DS |
6775 | if (!bgp->vpn_policy[afi].rmap[dir]) |
6776 | return CMD_SUCCESS; | |
6777 | } else { | |
6778 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6779 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6780 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6781 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
6782 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
ddb5b488 | 6783 | } |
69b07479 DS |
6784 | |
6785 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 PZ |
6786 | } |
6787 | ||
6788 | return CMD_SUCCESS; | |
6789 | } | |
6790 | ||
b9c7bc5a PZ |
6791 | ALIAS (af_route_map_vpn_imexport, |
6792 | af_no_route_map_vpn_imexport_cmd, | |
6793 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
6794 | NO_STR |
6795 | "Specify route map\n" | |
b9c7bc5a PZ |
6796 | "Between current address-family and vpn\n" |
6797 | "For routes leaked from vpn to current address-family\n" | |
6798 | "For routes leaked from current address-family to vpn\n") | |
6799 | ||
bb4f6190 DS |
6800 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
6801 | "[no] import vrf route-map RMAP$rmap_str", | |
6802 | NO_STR | |
6803 | "Import routes from another VRF\n" | |
6804 | "Vrf routes being filtered\n" | |
6805 | "Specify route map\n" | |
6806 | "name of route-map\n") | |
6807 | { | |
6808 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
bb4f6190 DS |
6809 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; |
6810 | afi_t afi; | |
6811 | int idx = 0; | |
6812 | int yes = 1; | |
6813 | struct bgp *bgp_default; | |
6814 | ||
6815 | if (argv_find(argv, argc, "no", &idx)) | |
6816 | yes = 0; | |
6817 | ||
0ca70ba5 | 6818 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
6819 | if (afi == AFI_MAX) |
6820 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
6821 | |
6822 | bgp_default = bgp_get_default(); | |
6823 | if (!bgp_default) { | |
6824 | int32_t ret; | |
6825 | as_t as = bgp->as; | |
6826 | ||
6827 | /* Auto-create assuming the same AS */ | |
6828 | ret = bgp_get(&bgp_default, &as, NULL, | |
6829 | BGP_INSTANCE_TYPE_DEFAULT); | |
6830 | ||
6831 | if (ret) { | |
6832 | vty_out(vty, | |
6833 | "VRF default is not configured as a bgp instance\n"); | |
6834 | return CMD_WARNING; | |
6835 | } | |
6836 | } | |
6837 | ||
69b07479 | 6838 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 6839 | |
69b07479 DS |
6840 | if (yes) { |
6841 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6842 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6843 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6844 | bgp->vpn_policy[afi].rmap_name[dir] = | |
6845 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
6846 | bgp->vpn_policy[afi].rmap[dir] = | |
1de27621 | 6847 | route_map_lookup_warn_noexist(vty, rmap_str); |
69b07479 DS |
6848 | if (!bgp->vpn_policy[afi].rmap[dir]) |
6849 | return CMD_SUCCESS; | |
6850 | } else { | |
6851 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6852 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6853 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6854 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
6855 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
bb4f6190 DS |
6856 | } |
6857 | ||
69b07479 DS |
6858 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
6859 | ||
bb4f6190 DS |
6860 | return CMD_SUCCESS; |
6861 | } | |
6862 | ||
6863 | ALIAS(af_import_vrf_route_map, af_no_import_vrf_route_map_cmd, | |
6864 | "no import vrf route-map", | |
6865 | NO_STR | |
6866 | "Import routes from another VRF\n" | |
6867 | "Vrf routes being filtered\n" | |
6868 | "Specify route map\n") | |
6869 | ||
4d1b335c DA |
6870 | DEFPY(bgp_imexport_vrf, bgp_imexport_vrf_cmd, |
6871 | "[no] import vrf VIEWVRFNAME$import_name", | |
6872 | NO_STR | |
6873 | "Import routes from another VRF\n" | |
6874 | "VRF to import from\n" | |
6875 | "The name of the VRF\n") | |
12a844a5 DS |
6876 | { |
6877 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6878 | struct listnode *node; | |
79ef8664 DS |
6879 | struct bgp *vrf_bgp, *bgp_default; |
6880 | int32_t ret = 0; | |
6881 | as_t as = bgp->as; | |
12a844a5 DS |
6882 | bool remove = false; |
6883 | int32_t idx = 0; | |
6884 | char *vname; | |
a8dadcf6 | 6885 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; |
12a844a5 DS |
6886 | safi_t safi; |
6887 | afi_t afi; | |
6888 | ||
867f0cca | 6889 | if (import_name == NULL) { |
6890 | vty_out(vty, "%% Missing import name\n"); | |
6891 | return CMD_WARNING; | |
6892 | } | |
6893 | ||
12a844a5 DS |
6894 | if (argv_find(argv, argc, "no", &idx)) |
6895 | remove = true; | |
6896 | ||
0ca70ba5 DS |
6897 | afi = vpn_policy_getafi(vty, bgp, true); |
6898 | if (afi == AFI_MAX) | |
6899 | return CMD_WARNING_CONFIG_FAILED; | |
6900 | ||
12a844a5 DS |
6901 | safi = bgp_node_safi(vty); |
6902 | ||
25679caa | 6903 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) |
5742e42b | 6904 | && (strcmp(import_name, VRF_DEFAULT_NAME) == 0)) |
25679caa DS |
6905 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { |
6906 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
6907 | remove ? "unimport" : "import", import_name); | |
6908 | return CMD_WARNING; | |
6909 | } | |
6910 | ||
79ef8664 DS |
6911 | bgp_default = bgp_get_default(); |
6912 | if (!bgp_default) { | |
6913 | /* Auto-create assuming the same AS */ | |
6914 | ret = bgp_get(&bgp_default, &as, NULL, | |
6915 | BGP_INSTANCE_TYPE_DEFAULT); | |
6916 | ||
6917 | if (ret) { | |
6918 | vty_out(vty, | |
6919 | "VRF default is not configured as a bgp instance\n"); | |
6920 | return CMD_WARNING; | |
6921 | } | |
6922 | } | |
6923 | ||
12a844a5 DS |
6924 | vrf_bgp = bgp_lookup_by_name(import_name); |
6925 | if (!vrf_bgp) { | |
5742e42b | 6926 | if (strcmp(import_name, VRF_DEFAULT_NAME) == 0) |
79ef8664 DS |
6927 | vrf_bgp = bgp_default; |
6928 | else | |
0fb8d6e6 DS |
6929 | /* Auto-create assuming the same AS */ |
6930 | ret = bgp_get(&vrf_bgp, &as, import_name, bgp_type); | |
a8dadcf6 | 6931 | |
6e2c7fe6 | 6932 | if (ret) { |
020a3f60 DS |
6933 | vty_out(vty, |
6934 | "VRF %s is not configured as a bgp instance\n", | |
6e2c7fe6 DS |
6935 | import_name); |
6936 | return CMD_WARNING; | |
6937 | } | |
12a844a5 DS |
6938 | } |
6939 | ||
12a844a5 | 6940 | if (remove) { |
44338987 | 6941 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 | 6942 | } else { |
44338987 | 6943 | /* Already importing from "import_vrf"? */ |
12a844a5 DS |
6944 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, |
6945 | vname)) { | |
6946 | if (strcmp(vname, import_name) == 0) | |
6947 | return CMD_WARNING; | |
6948 | } | |
6949 | ||
44338987 | 6950 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 DS |
6951 | } |
6952 | ||
6953 | return CMD_SUCCESS; | |
6954 | } | |
6955 | ||
b9c7bc5a PZ |
6956 | /* This command is valid only in a bgp vrf instance or the default instance */ |
6957 | DEFPY (bgp_imexport_vpn, | |
6958 | bgp_imexport_vpn_cmd, | |
6959 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
6960 | NO_STR |
6961 | "Import routes to this address-family\n" | |
6962 | "Export routes from this address-family\n" | |
6963 | "to/from default instance VPN RIB\n") | |
ddb5b488 PZ |
6964 | { |
6965 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 6966 | int previous_state; |
ddb5b488 | 6967 | afi_t afi; |
b9c7bc5a | 6968 | safi_t safi; |
ddb5b488 | 6969 | int idx = 0; |
b9c7bc5a PZ |
6970 | int yes = 1; |
6971 | int flag; | |
6972 | vpn_policy_direction_t dir; | |
ddb5b488 | 6973 | |
b9c7bc5a | 6974 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6975 | yes = 0; |
ddb5b488 | 6976 | |
b9c7bc5a PZ |
6977 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && |
6978 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
ddb5b488 | 6979 | |
b9c7bc5a PZ |
6980 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); |
6981 | return CMD_WARNING_CONFIG_FAILED; | |
6982 | } | |
ddb5b488 | 6983 | |
b9c7bc5a PZ |
6984 | afi = bgp_node_afi(vty); |
6985 | safi = bgp_node_safi(vty); | |
6986 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { | |
6987 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
6988 | return CMD_WARNING_CONFIG_FAILED; | |
6989 | } | |
ddb5b488 | 6990 | |
b9c7bc5a PZ |
6991 | if (!strcmp(direction_str, "import")) { |
6992 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; | |
6993 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
6994 | } else if (!strcmp(direction_str, "export")) { | |
6995 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; | |
6996 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
6997 | } else { | |
6998 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
6999 | return CMD_WARNING_CONFIG_FAILED; | |
7000 | } | |
7001 | ||
7002 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 | 7003 | |
b9c7bc5a PZ |
7004 | if (yes) { |
7005 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
7006 | if (!previous_state) { | |
7007 | /* trigger export current vrf */ | |
ddb5b488 PZ |
7008 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
7009 | } | |
b9c7bc5a PZ |
7010 | } else { |
7011 | if (previous_state) { | |
7012 | /* trigger un-export current vrf */ | |
7013 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
7014 | } | |
7015 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 PZ |
7016 | } |
7017 | ||
7018 | return CMD_SUCCESS; | |
7019 | } | |
7020 | ||
301ad80a PG |
7021 | DEFPY (af_routetarget_import, |
7022 | af_routetarget_import_cmd, | |
7023 | "[no] <rt|route-target> redirect import RTLIST...", | |
7024 | NO_STR | |
7025 | "Specify route target list\n" | |
7026 | "Specify route target list\n" | |
7027 | "Flow-spec redirect type route target\n" | |
7028 | "Import routes to this address-family\n" | |
7029 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") | |
7030 | { | |
7031 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7032 | int ret; | |
7033 | struct ecommunity *ecom = NULL; | |
301ad80a PG |
7034 | afi_t afi; |
7035 | int idx = 0; | |
7036 | int yes = 1; | |
7037 | ||
7038 | if (argv_find(argv, argc, "no", &idx)) | |
7039 | yes = 0; | |
7040 | ||
0ca70ba5 | 7041 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7042 | if (afi == AFI_MAX) |
7043 | return CMD_WARNING_CONFIG_FAILED; | |
7044 | ||
301ad80a PG |
7045 | if (yes) { |
7046 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
7047 | vty_out(vty, "%% Missing RTLIST\n"); | |
7048 | return CMD_WARNING_CONFIG_FAILED; | |
7049 | } | |
7050 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
7051 | if (ret != CMD_SUCCESS) | |
7052 | return ret; | |
7053 | } | |
69b07479 DS |
7054 | |
7055 | if (yes) { | |
7056 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
7057 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 7058 | .import_redirect_rtlist); |
69b07479 DS |
7059 | bgp->vpn_policy[afi].import_redirect_rtlist = |
7060 | ecommunity_dup(ecom); | |
7061 | } else { | |
7062 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
7063 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 7064 | .import_redirect_rtlist); |
69b07479 | 7065 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 7066 | } |
69b07479 | 7067 | |
301ad80a PG |
7068 | if (ecom) |
7069 | ecommunity_free(&ecom); | |
7070 | ||
7071 | return CMD_SUCCESS; | |
7072 | } | |
7073 | ||
505e5056 | 7074 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 7075 | address_family_ipv4_safi_cmd, |
7076 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
7077 | "Enter Address Family command mode\n" | |
7078 | "Address Family\n" | |
7079 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
718e3744 | 7080 | { |
f51bae9c | 7081 | |
d62a17ae | 7082 | if (argc == 3) { |
2131d5cf | 7083 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7084 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
7085 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
7086 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 7087 | && safi != SAFI_EVPN) { |
31947174 MK |
7088 | vty_out(vty, |
7089 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
7090 | return CMD_WARNING_CONFIG_FAILED; |
7091 | } | |
d62a17ae | 7092 | vty->node = bgp_node_type(AFI_IP, safi); |
7093 | } else | |
7094 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 7095 | |
d62a17ae | 7096 | return CMD_SUCCESS; |
718e3744 | 7097 | } |
7098 | ||
505e5056 | 7099 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 7100 | address_family_ipv6_safi_cmd, |
7101 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
7102 | "Enter Address Family command mode\n" | |
7103 | "Address Family\n" | |
7104 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
25ffbdc1 | 7105 | { |
d62a17ae | 7106 | if (argc == 3) { |
2131d5cf | 7107 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7108 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
7109 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
7110 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 7111 | && safi != SAFI_EVPN) { |
31947174 MK |
7112 | vty_out(vty, |
7113 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
7114 | return CMD_WARNING_CONFIG_FAILED; |
7115 | } | |
d62a17ae | 7116 | vty->node = bgp_node_type(AFI_IP6, safi); |
7117 | } else | |
7118 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 7119 | |
d62a17ae | 7120 | return CMD_SUCCESS; |
25ffbdc1 | 7121 | } |
718e3744 | 7122 | |
d6902373 | 7123 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 7124 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 7125 | address_family_vpnv4_cmd, |
8334fd5a | 7126 | "address-family vpnv4 [unicast]", |
718e3744 | 7127 | "Enter Address Family command mode\n" |
8c3deaae | 7128 | "Address Family\n" |
3a2d747c | 7129 | "Address Family modifier\n") |
718e3744 | 7130 | { |
d62a17ae | 7131 | vty->node = BGP_VPNV4_NODE; |
7132 | return CMD_SUCCESS; | |
718e3744 | 7133 | } |
7134 | ||
505e5056 | 7135 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 7136 | address_family_vpnv6_cmd, |
8334fd5a | 7137 | "address-family vpnv6 [unicast]", |
8ecd3266 | 7138 | "Enter Address Family command mode\n" |
8c3deaae | 7139 | "Address Family\n" |
3a2d747c | 7140 | "Address Family modifier\n") |
8ecd3266 | 7141 | { |
d62a17ae | 7142 | vty->node = BGP_VPNV6_NODE; |
7143 | return CMD_SUCCESS; | |
8ecd3266 | 7144 | } |
c016b6c7 | 7145 | #endif |
d6902373 | 7146 | |
505e5056 | 7147 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 7148 | address_family_evpn_cmd, |
7111c1a0 | 7149 | "address-family l2vpn evpn", |
4e0b7b6d | 7150 | "Enter Address Family command mode\n" |
7111c1a0 QY |
7151 | "Address Family\n" |
7152 | "Address Family modifier\n") | |
4e0b7b6d | 7153 | { |
2131d5cf | 7154 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7155 | vty->node = BGP_EVPN_NODE; |
7156 | return CMD_SUCCESS; | |
4e0b7b6d PG |
7157 | } |
7158 | ||
505e5056 | 7159 | DEFUN_NOSH (exit_address_family, |
718e3744 | 7160 | exit_address_family_cmd, |
7161 | "exit-address-family", | |
7162 | "Exit from Address Family configuration mode\n") | |
7163 | { | |
d62a17ae | 7164 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
7165 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
7166 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
7167 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
7168 | || vty->node == BGP_EVPN_NODE |
7169 | || vty->node == BGP_FLOWSPECV4_NODE | |
7170 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 7171 | vty->node = BGP_NODE; |
7172 | return CMD_SUCCESS; | |
718e3744 | 7173 | } |
6b0655a2 | 7174 | |
8ad7271d | 7175 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 7176 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
7177 | const char *ip_str, afi_t afi, safi_t safi, | |
7178 | struct prefix_rd *prd) | |
7179 | { | |
7180 | int ret; | |
7181 | struct prefix match; | |
7182 | struct bgp_node *rn; | |
7183 | struct bgp_node *rm; | |
7184 | struct bgp *bgp; | |
7185 | struct bgp_table *table; | |
7186 | struct bgp_table *rib; | |
7187 | ||
7188 | /* BGP structure lookup. */ | |
7189 | if (view_name) { | |
7190 | bgp = bgp_lookup_by_name(view_name); | |
7191 | if (bgp == NULL) { | |
7192 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
7193 | view_name); | |
7194 | return CMD_WARNING; | |
7195 | } | |
7196 | } else { | |
7197 | bgp = bgp_get_default(); | |
7198 | if (bgp == NULL) { | |
7199 | vty_out(vty, "%% No BGP process is configured\n"); | |
7200 | return CMD_WARNING; | |
7201 | } | |
7202 | } | |
7203 | ||
7204 | /* Check IP address argument. */ | |
7205 | ret = str2prefix(ip_str, &match); | |
7206 | if (!ret) { | |
7207 | vty_out(vty, "%% address is malformed\n"); | |
7208 | return CMD_WARNING; | |
7209 | } | |
7210 | ||
7211 | match.family = afi2family(afi); | |
7212 | rib = bgp->rib[afi][safi]; | |
7213 | ||
7214 | if (safi == SAFI_MPLS_VPN) { | |
7215 | for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) { | |
7216 | if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0) | |
7217 | continue; | |
7218 | ||
67009e22 DS |
7219 | table = bgp_node_get_bgp_table_info(rn); |
7220 | if (table != NULL) { | |
7221 | ||
d62a17ae | 7222 | if ((rm = bgp_node_match(table, &match)) |
7223 | != NULL) { | |
7224 | if (rm->p.prefixlen | |
7225 | == match.prefixlen) { | |
343cdb61 | 7226 | SET_FLAG(rm->flags, |
d62a17ae | 7227 | BGP_NODE_USER_CLEAR); |
7228 | bgp_process(bgp, rm, afi, safi); | |
7229 | } | |
7230 | bgp_unlock_node(rm); | |
7231 | } | |
7232 | } | |
7233 | } | |
7234 | } else { | |
7235 | if ((rn = bgp_node_match(rib, &match)) != NULL) { | |
7236 | if (rn->p.prefixlen == match.prefixlen) { | |
7237 | SET_FLAG(rn->flags, BGP_NODE_USER_CLEAR); | |
7238 | bgp_process(bgp, rn, afi, safi); | |
7239 | } | |
7240 | bgp_unlock_node(rn); | |
7241 | } | |
7242 | } | |
7243 | ||
7244 | return CMD_SUCCESS; | |
8ad7271d DS |
7245 | } |
7246 | ||
b09b5ae0 | 7247 | /* one clear bgp command to rule them all */ |
718e3744 | 7248 | DEFUN (clear_ip_bgp_all, |
7249 | clear_ip_bgp_all_cmd, | |
fd5e7b70 | 7250 | "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 WORD> [<soft [<in|out>]|in [prefix-filter]|out>]", |
718e3744 | 7251 | CLEAR_STR |
7252 | IP_STR | |
7253 | BGP_STR | |
838758ac | 7254 | BGP_INSTANCE_HELP_STR |
510afcd6 | 7255 | BGP_AFI_HELP_STR |
fd5e7b70 | 7256 | "Address Family\n" |
510afcd6 | 7257 | BGP_SAFI_WITH_LABEL_HELP_STR |
fd5e7b70 | 7258 | "Address Family modifier\n" |
b09b5ae0 DW |
7259 | "Clear all peers\n" |
7260 | "BGP neighbor address to clear\n" | |
a80beece | 7261 | "BGP IPv6 neighbor to clear\n" |
838758ac | 7262 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
7263 | "Clear peers with the AS number\n" |
7264 | "Clear all external peers\n" | |
718e3744 | 7265 | "Clear all members of peer-group\n" |
b09b5ae0 | 7266 | "BGP peer-group name\n" |
b09b5ae0 DW |
7267 | BGP_SOFT_STR |
7268 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
7269 | BGP_SOFT_OUT_STR |
7270 | BGP_SOFT_IN_STR | |
7271 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 7272 | BGP_SOFT_OUT_STR) |
718e3744 | 7273 | { |
d62a17ae | 7274 | char *vrf = NULL; |
7275 | ||
7276 | afi_t afi = AFI_IP6; | |
7277 | safi_t safi = SAFI_UNICAST; | |
7278 | enum clear_sort clr_sort = clear_peer; | |
7279 | enum bgp_clear_type clr_type; | |
7280 | char *clr_arg = NULL; | |
7281 | ||
7282 | int idx = 0; | |
7283 | ||
7284 | /* clear [ip] bgp */ | |
7285 | if (argv_find(argv, argc, "ip", &idx)) | |
7286 | afi = AFI_IP; | |
7287 | ||
9a8bdf1c PG |
7288 | /* [<vrf> VIEWVRFNAME] */ |
7289 | if (argv_find(argv, argc, "vrf", &idx)) { | |
7290 | vrf = argv[idx + 1]->arg; | |
7291 | idx += 2; | |
7292 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
7293 | vrf = NULL; | |
7294 | } else if (argv_find(argv, argc, "view", &idx)) { | |
7295 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 7296 | vrf = argv[idx + 1]->arg; |
7297 | idx += 2; | |
7298 | } | |
d62a17ae | 7299 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
7300 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
7301 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
7302 | ||
7303 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */ | |
7304 | if (argv_find(argv, argc, "*", &idx)) { | |
7305 | clr_sort = clear_all; | |
7306 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
7307 | clr_sort = clear_peer; | |
7308 | clr_arg = argv[idx]->arg; | |
7309 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
7310 | clr_sort = clear_peer; | |
7311 | clr_arg = argv[idx]->arg; | |
7312 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
7313 | clr_sort = clear_group; | |
7314 | idx++; | |
7315 | clr_arg = argv[idx]->arg; | |
7316 | } else if (argv_find(argv, argc, "WORD", &idx)) { | |
7317 | clr_sort = clear_peer; | |
7318 | clr_arg = argv[idx]->arg; | |
7319 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { | |
7320 | clr_sort = clear_as; | |
7321 | clr_arg = argv[idx]->arg; | |
7322 | } else if (argv_find(argv, argc, "external", &idx)) { | |
7323 | clr_sort = clear_external; | |
7324 | } | |
7325 | ||
7326 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
7327 | if (argv_find(argv, argc, "soft", &idx)) { | |
7328 | if (argv_find(argv, argc, "in", &idx) | |
7329 | || argv_find(argv, argc, "out", &idx)) | |
7330 | clr_type = strmatch(argv[idx]->text, "in") | |
7331 | ? BGP_CLEAR_SOFT_IN | |
7332 | : BGP_CLEAR_SOFT_OUT; | |
7333 | else | |
7334 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
7335 | } else if (argv_find(argv, argc, "in", &idx)) { | |
7336 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
7337 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
7338 | : BGP_CLEAR_SOFT_IN; | |
7339 | } else if (argv_find(argv, argc, "out", &idx)) { | |
7340 | clr_type = BGP_CLEAR_SOFT_OUT; | |
7341 | } else | |
7342 | clr_type = BGP_CLEAR_SOFT_NONE; | |
7343 | ||
7344 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); | |
838758ac | 7345 | } |
01080f7c | 7346 | |
8ad7271d DS |
7347 | DEFUN (clear_ip_bgp_prefix, |
7348 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 7349 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
7350 | CLEAR_STR |
7351 | IP_STR | |
7352 | BGP_STR | |
838758ac | 7353 | BGP_INSTANCE_HELP_STR |
8ad7271d | 7354 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7355 | "IPv4 prefix\n") |
8ad7271d | 7356 | { |
d62a17ae | 7357 | char *vrf = NULL; |
7358 | char *prefix = NULL; | |
8ad7271d | 7359 | |
d62a17ae | 7360 | int idx = 0; |
01080f7c | 7361 | |
d62a17ae | 7362 | /* [<view|vrf> VIEWVRFNAME] */ |
9a8bdf1c PG |
7363 | if (argv_find(argv, argc, "vrf", &idx)) { |
7364 | vrf = argv[idx + 1]->arg; | |
7365 | idx += 2; | |
7366 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
7367 | vrf = NULL; | |
7368 | } else if (argv_find(argv, argc, "view", &idx)) { | |
7369 | /* [<view> VIEWVRFNAME] */ | |
7370 | vrf = argv[idx + 1]->arg; | |
7371 | idx += 2; | |
7372 | } | |
0c7b1b01 | 7373 | |
d62a17ae | 7374 | prefix = argv[argc - 1]->arg; |
8ad7271d | 7375 | |
d62a17ae | 7376 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 7377 | } |
8ad7271d | 7378 | |
b09b5ae0 DW |
7379 | DEFUN (clear_bgp_ipv6_safi_prefix, |
7380 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 7381 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 7382 | CLEAR_STR |
3a2d747c | 7383 | IP_STR |
718e3744 | 7384 | BGP_STR |
8c3deaae | 7385 | "Address Family\n" |
46f296b4 | 7386 | BGP_SAFI_HELP_STR |
b09b5ae0 | 7387 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7388 | "IPv6 prefix\n") |
718e3744 | 7389 | { |
9b475e76 PG |
7390 | int idx_safi = 0; |
7391 | int idx_ipv6_prefix = 0; | |
7392 | safi_t safi = SAFI_UNICAST; | |
7393 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
7394 | argv[idx_ipv6_prefix]->arg : NULL; | |
7395 | ||
7396 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 7397 | return bgp_clear_prefix( |
9b475e76 PG |
7398 | vty, NULL, prefix, AFI_IP6, |
7399 | safi, NULL); | |
838758ac | 7400 | } |
01080f7c | 7401 | |
b09b5ae0 DW |
7402 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
7403 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 7404 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 7405 | CLEAR_STR |
3a2d747c | 7406 | IP_STR |
718e3744 | 7407 | BGP_STR |
838758ac | 7408 | BGP_INSTANCE_HELP_STR |
8c3deaae | 7409 | "Address Family\n" |
46f296b4 | 7410 | BGP_SAFI_HELP_STR |
b09b5ae0 | 7411 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7412 | "IPv6 prefix\n") |
718e3744 | 7413 | { |
9b475e76 | 7414 | int idx_safi = 0; |
9a8bdf1c | 7415 | int idx_vrfview = 0; |
9b475e76 PG |
7416 | int idx_ipv6_prefix = 0; |
7417 | safi_t safi = SAFI_UNICAST; | |
7418 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
7419 | argv[idx_ipv6_prefix]->arg : NULL; | |
9a8bdf1c | 7420 | char *vrfview = NULL; |
9b475e76 | 7421 | |
9a8bdf1c PG |
7422 | /* [<view|vrf> VIEWVRFNAME] */ |
7423 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
7424 | vrfview = argv[idx_vrfview + 1]->arg; | |
7425 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
7426 | vrfview = NULL; | |
7427 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
7428 | /* [<view> VIEWVRFNAME] */ | |
7429 | vrfview = argv[idx_vrfview + 1]->arg; | |
7430 | } | |
9b475e76 PG |
7431 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); |
7432 | ||
d62a17ae | 7433 | return bgp_clear_prefix( |
9b475e76 PG |
7434 | vty, vrfview, prefix, |
7435 | AFI_IP6, safi, NULL); | |
718e3744 | 7436 | } |
7437 | ||
b09b5ae0 DW |
7438 | DEFUN (show_bgp_views, |
7439 | show_bgp_views_cmd, | |
d6e3c605 | 7440 | "show [ip] bgp views", |
b09b5ae0 | 7441 | SHOW_STR |
d6e3c605 | 7442 | IP_STR |
01080f7c | 7443 | BGP_STR |
b09b5ae0 | 7444 | "Show the defined BGP views\n") |
01080f7c | 7445 | { |
d62a17ae | 7446 | struct list *inst = bm->bgp; |
7447 | struct listnode *node; | |
7448 | struct bgp *bgp; | |
01080f7c | 7449 | |
d62a17ae | 7450 | if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE)) { |
7451 | vty_out(vty, "BGP Multiple Instance is not enabled\n"); | |
7452 | return CMD_WARNING; | |
7453 | } | |
e52702f2 | 7454 | |
d62a17ae | 7455 | vty_out(vty, "Defined BGP views:\n"); |
7456 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
7457 | /* Skip VRFs. */ | |
7458 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
7459 | continue; | |
7460 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
7461 | bgp->as); | |
7462 | } | |
e52702f2 | 7463 | |
d62a17ae | 7464 | return CMD_SUCCESS; |
e0081f70 ML |
7465 | } |
7466 | ||
8386ac43 | 7467 | DEFUN (show_bgp_vrfs, |
7468 | show_bgp_vrfs_cmd, | |
d6e3c605 | 7469 | "show [ip] bgp vrfs [json]", |
8386ac43 | 7470 | SHOW_STR |
d6e3c605 | 7471 | IP_STR |
8386ac43 | 7472 | BGP_STR |
7473 | "Show BGP VRFs\n" | |
9973d184 | 7474 | JSON_STR) |
8386ac43 | 7475 | { |
fe1dc5a3 | 7476 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 7477 | struct list *inst = bm->bgp; |
7478 | struct listnode *node; | |
7479 | struct bgp *bgp; | |
9f049418 | 7480 | bool uj = use_json(argc, argv); |
d62a17ae | 7481 | json_object *json = NULL; |
7482 | json_object *json_vrfs = NULL; | |
7483 | int count = 0; | |
d62a17ae | 7484 | |
7485 | if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE)) { | |
7486 | vty_out(vty, "BGP Multiple Instance is not enabled\n"); | |
7487 | return CMD_WARNING; | |
7488 | } | |
7489 | ||
7490 | if (uj) { | |
7491 | json = json_object_new_object(); | |
7492 | json_vrfs = json_object_new_object(); | |
7493 | } | |
7494 | ||
7495 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
7496 | const char *name, *type; | |
7497 | struct peer *peer; | |
7fe96307 | 7498 | struct listnode *node2, *nnode2; |
d62a17ae | 7499 | int peers_cfg, peers_estb; |
7500 | json_object *json_vrf = NULL; | |
d62a17ae | 7501 | |
7502 | /* Skip Views. */ | |
7503 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
7504 | continue; | |
7505 | ||
7506 | count++; | |
7507 | if (!uj && count == 1) | |
fe1dc5a3 MK |
7508 | vty_out(vty, |
7509 | "%4s %-5s %-16s %9s %10s %-37s %-10s %-15s\n", | |
a4d82a8a PZ |
7510 | "Type", "Id", "routerId", "#PeersVfg", |
7511 | "#PeersEstb", "Name", "L3-VNI", "Rmac"); | |
d62a17ae | 7512 | |
7513 | peers_cfg = peers_estb = 0; | |
7514 | if (uj) | |
7515 | json_vrf = json_object_new_object(); | |
7516 | ||
7517 | ||
7fe96307 | 7518 | for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { |
d62a17ae | 7519 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
7520 | continue; | |
7521 | peers_cfg++; | |
7522 | if (peer->status == Established) | |
7523 | peers_estb++; | |
7524 | } | |
7525 | ||
7526 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
5742e42b | 7527 | name = VRF_DEFAULT_NAME; |
d62a17ae | 7528 | type = "DFLT"; |
7529 | } else { | |
7530 | name = bgp->name; | |
7531 | type = "VRF"; | |
7532 | } | |
7533 | ||
a8bf7d9c | 7534 | |
d62a17ae | 7535 | if (uj) { |
a4d82a8a PZ |
7536 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
7537 | ? -1 | |
7538 | : (int64_t)bgp->vrf_id; | |
d62a17ae | 7539 | json_object_string_add(json_vrf, "type", type); |
7540 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
7541 | json_object_string_add(json_vrf, "routerId", | |
7542 | inet_ntoa(bgp->router_id)); | |
7543 | json_object_int_add(json_vrf, "numConfiguredPeers", | |
7544 | peers_cfg); | |
7545 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
7546 | peers_estb); | |
7547 | ||
fe1dc5a3 | 7548 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
7549 | json_object_string_add( |
7550 | json_vrf, "rmac", | |
7551 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
d62a17ae | 7552 | json_object_object_add(json_vrfs, name, json_vrf); |
7553 | } else | |
fe1dc5a3 MK |
7554 | vty_out(vty, |
7555 | "%4s %-5d %-16s %9u %10u %-37s %-10u %-15s\n", | |
a4d82a8a PZ |
7556 | type, |
7557 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
7558 | : (int)bgp->vrf_id, | |
7559 | inet_ntoa(bgp->router_id), peers_cfg, | |
7560 | peers_estb, name, bgp->l3vni, | |
fe1dc5a3 | 7561 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); |
d62a17ae | 7562 | } |
7563 | ||
7564 | if (uj) { | |
7565 | json_object_object_add(json, "vrfs", json_vrfs); | |
7566 | ||
7567 | json_object_int_add(json, "totalVrfs", count); | |
7568 | ||
996c9314 LB |
7569 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
7570 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 7571 | json_object_free(json); |
7572 | } else { | |
7573 | if (count) | |
7574 | vty_out(vty, | |
7575 | "\nTotal number of VRFs (including default): %d\n", | |
7576 | count); | |
7577 | } | |
7578 | ||
7579 | return CMD_SUCCESS; | |
8386ac43 | 7580 | } |
7581 | ||
48ecf8f5 DS |
7582 | DEFUN (show_bgp_mac_hash, |
7583 | show_bgp_mac_hash_cmd, | |
7584 | "show bgp mac hash", | |
7585 | SHOW_STR | |
7586 | BGP_STR | |
7587 | "Mac Address\n" | |
7588 | "Mac Address database\n") | |
7589 | { | |
7590 | bgp_mac_dump_table(vty); | |
7591 | ||
7592 | return CMD_SUCCESS; | |
7593 | } | |
acf71666 MK |
7594 | |
7595 | static void show_tip_entry(struct hash_backet *backet, void *args) | |
7596 | { | |
0291c246 | 7597 | struct vty *vty = (struct vty *)args; |
60466a63 | 7598 | struct tip_addr *tip = (struct tip_addr *)backet->data; |
acf71666 | 7599 | |
60466a63 | 7600 | vty_out(vty, "addr: %s, count: %d\n", inet_ntoa(tip->addr), |
acf71666 MK |
7601 | tip->refcnt); |
7602 | } | |
7603 | ||
7604 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
7605 | { | |
7606 | vty_out(vty, "self nexthop database:\n"); | |
af97a18b | 7607 | bgp_nexthop_show_address_hash(vty, bgp); |
acf71666 MK |
7608 | |
7609 | vty_out(vty, "Tunnel-ip database:\n"); | |
7610 | hash_iterate(bgp->tip_hash, | |
7611 | (void (*)(struct hash_backet *, void *))show_tip_entry, | |
7612 | vty); | |
7613 | } | |
7614 | ||
15c81ca4 DS |
7615 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
7616 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
7617 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
7618 | "martian next-hops\n" |
7619 | "martian next-hop database\n") | |
acf71666 | 7620 | { |
0291c246 | 7621 | struct bgp *bgp = NULL; |
15c81ca4 | 7622 | int idx = 0; |
9a8bdf1c PG |
7623 | char *name = NULL; |
7624 | ||
7625 | /* [<vrf> VIEWVRFNAME] */ | |
7626 | if (argv_find(argv, argc, "vrf", &idx)) { | |
7627 | name = argv[idx + 1]->arg; | |
7628 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
7629 | name = NULL; | |
7630 | } else if (argv_find(argv, argc, "view", &idx)) | |
7631 | /* [<view> VIEWVRFNAME] */ | |
7632 | name = argv[idx + 1]->arg; | |
7633 | if (name) | |
7634 | bgp = bgp_lookup_by_name(name); | |
15c81ca4 DS |
7635 | else |
7636 | bgp = bgp_get_default(); | |
acf71666 | 7637 | |
acf71666 MK |
7638 | if (!bgp) { |
7639 | vty_out(vty, "%% No BGP process is configured\n"); | |
7640 | return CMD_WARNING; | |
7641 | } | |
7642 | bgp_show_martian_nexthops(vty, bgp); | |
7643 | ||
7644 | return CMD_SUCCESS; | |
7645 | } | |
7646 | ||
f412b39a | 7647 | DEFUN (show_bgp_memory, |
4bf6a362 | 7648 | show_bgp_memory_cmd, |
7fa12b13 | 7649 | "show [ip] bgp memory", |
4bf6a362 | 7650 | SHOW_STR |
3a2d747c | 7651 | IP_STR |
4bf6a362 PJ |
7652 | BGP_STR |
7653 | "Global BGP memory statistics\n") | |
7654 | { | |
d62a17ae | 7655 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
7656 | unsigned long count; | |
7657 | ||
7658 | /* RIB related usage stats */ | |
7659 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
7660 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
7661 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7662 | count * sizeof(struct bgp_node))); | |
7663 | ||
7664 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
7665 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
7666 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
4b7e6066 | 7667 | count * sizeof(struct bgp_path_info))); |
d62a17ae | 7668 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) |
7669 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
7670 | count, | |
4b7e6066 DS |
7671 | mtype_memstr( |
7672 | memstrbuf, sizeof(memstrbuf), | |
7673 | count * sizeof(struct bgp_path_info_extra))); | |
d62a17ae | 7674 | |
7675 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
7676 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
7677 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7678 | count * sizeof(struct bgp_static))); | |
7679 | ||
7680 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
7681 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
7682 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7683 | count * sizeof(struct bpacket))); | |
7684 | ||
7685 | /* Adj-In/Out */ | |
7686 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
7687 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
7688 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7689 | count * sizeof(struct bgp_adj_in))); | |
7690 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
7691 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
7692 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7693 | count * sizeof(struct bgp_adj_out))); | |
7694 | ||
7695 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
7696 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
7697 | count, | |
7698 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7699 | count * sizeof(struct bgp_nexthop_cache))); | |
7700 | ||
7701 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
7702 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
7703 | count, | |
7704 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7705 | count * sizeof(struct bgp_damp_info))); | |
7706 | ||
7707 | /* Attributes */ | |
7708 | count = attr_count(); | |
7709 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
7710 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7711 | count * sizeof(struct attr))); | |
7712 | ||
7713 | if ((count = attr_unknown_count())) | |
7714 | vty_out(vty, "%ld unknown attributes\n", count); | |
7715 | ||
7716 | /* AS_PATH attributes */ | |
7717 | count = aspath_count(); | |
7718 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
7719 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7720 | count * sizeof(struct aspath))); | |
7721 | ||
7722 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
7723 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
7724 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7725 | count * sizeof(struct assegment))); | |
7726 | ||
7727 | /* Other attributes */ | |
7728 | if ((count = community_count())) | |
7729 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
7730 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7731 | count * sizeof(struct community))); | |
d62a17ae | 7732 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
7733 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
7734 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7735 | count * sizeof(struct ecommunity))); | |
d62a17ae | 7736 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
7737 | vty_out(vty, | |
7738 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
7739 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7740 | count * sizeof(struct lcommunity))); | |
d62a17ae | 7741 | |
7742 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
7743 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
7744 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7745 | count * sizeof(struct cluster_list))); | |
7746 | ||
7747 | /* Peer related usage */ | |
7748 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
7749 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
7750 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7751 | count * sizeof(struct peer))); | |
7752 | ||
7753 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
7754 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
7755 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7756 | count * sizeof(struct peer_group))); | |
7757 | ||
7758 | /* Other */ | |
7759 | if ((count = mtype_stats_alloc(MTYPE_HASH))) | |
7760 | vty_out(vty, "%ld hash tables, using %s of memory\n", count, | |
7761 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7762 | count * sizeof(struct hash))); | |
7763 | if ((count = mtype_stats_alloc(MTYPE_HASH_BACKET))) | |
7764 | vty_out(vty, "%ld hash buckets, using %s of memory\n", count, | |
7765 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7766 | count * sizeof(struct hash_backet))); | |
7767 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) | |
7768 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
7769 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7770 | count * sizeof(regex_t))); | |
d62a17ae | 7771 | return CMD_SUCCESS; |
4bf6a362 | 7772 | } |
fee0f4c6 | 7773 | |
57a9c8a8 DS |
7774 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
7775 | { | |
7776 | json_object *bestpath = json_object_new_object(); | |
7777 | ||
7778 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_IGNORE)) | |
7779 | json_object_string_add(bestpath, "asPath", "ignore"); | |
7780 | ||
7781 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_CONFED)) | |
7782 | json_object_string_add(bestpath, "asPath", "confed"); | |
7783 | ||
7784 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { | |
a4d82a8a PZ |
7785 | if (bgp_flag_check(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) |
7786 | json_object_string_add(bestpath, "multiPathRelax", | |
57a9c8a8 DS |
7787 | "as-set"); |
7788 | else | |
a4d82a8a | 7789 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
7790 | "true"); |
7791 | } else | |
a4d82a8a | 7792 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 DS |
7793 | |
7794 | if (bgp_flag_check(bgp, BGP_FLAG_COMPARE_ROUTER_ID)) | |
7795 | json_object_string_add(bestpath, "compareRouterId", "true"); | |
7796 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED) | |
7797 | || bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
7798 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 7799 | json_object_string_add(bestpath, "med", "confed"); |
57a9c8a8 DS |
7800 | if (bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) |
7801 | json_object_string_add(bestpath, "med", | |
7802 | "missing-as-worst"); | |
7803 | else | |
7804 | json_object_string_add(bestpath, "med", "true"); | |
7805 | } | |
7806 | ||
7807 | json_object_object_add(json, "bestPath", bestpath); | |
7808 | } | |
7809 | ||
718e3744 | 7810 | /* Show BGP peer's summary information. */ |
d62a17ae | 7811 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
9f049418 | 7812 | bool use_json, json_object *json) |
d62a17ae | 7813 | { |
7814 | struct peer *peer; | |
7815 | struct listnode *node, *nnode; | |
7816 | unsigned int count = 0, dn_count = 0; | |
7817 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
7818 | char neighbor_buf[VTY_BUFSIZ]; | |
7819 | int neighbor_col_default_width = 16; | |
7820 | int len; | |
7821 | int max_neighbor_width = 0; | |
7822 | int pfx_rcd_safi; | |
7823 | json_object *json_peer = NULL; | |
7824 | json_object *json_peers = NULL; | |
50e05855 | 7825 | struct peer_af *paf; |
d62a17ae | 7826 | |
7827 | /* labeled-unicast routes are installed in the unicast table so in order | |
7828 | * to | |
7829 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
7830 | */ | |
7831 | if (safi == SAFI_LABELED_UNICAST) | |
7832 | pfx_rcd_safi = SAFI_UNICAST; | |
7833 | else | |
7834 | pfx_rcd_safi = safi; | |
7835 | ||
7836 | if (use_json) { | |
7837 | if (json == NULL) | |
7838 | json = json_object_new_object(); | |
7839 | ||
7840 | json_peers = json_object_new_object(); | |
7841 | } else { | |
7842 | /* Loop over all neighbors that will be displayed to determine | |
7843 | * how many | |
7844 | * characters are needed for the Neighbor column | |
7845 | */ | |
7846 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
7847 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
7848 | continue; | |
7849 | ||
7850 | if (peer->afc[afi][safi]) { | |
7851 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
7852 | if (peer_dynamic_neighbor(peer)) | |
7853 | dn_flag[0] = '*'; | |
7854 | ||
7855 | if (peer->hostname | |
7856 | && bgp_flag_check(bgp, | |
7857 | BGP_FLAG_SHOW_HOSTNAME)) | |
7858 | sprintf(neighbor_buf, "%s%s(%s) ", | |
7859 | dn_flag, peer->hostname, | |
7860 | peer->host); | |
7861 | else | |
7862 | sprintf(neighbor_buf, "%s%s ", dn_flag, | |
7863 | peer->host); | |
7864 | ||
7865 | len = strlen(neighbor_buf); | |
7866 | ||
7867 | if (len > max_neighbor_width) | |
7868 | max_neighbor_width = len; | |
7869 | } | |
7870 | } | |
f933309e | 7871 | |
d62a17ae | 7872 | /* Originally we displayed the Neighbor column as 16 |
7873 | * characters wide so make that the default | |
7874 | */ | |
7875 | if (max_neighbor_width < neighbor_col_default_width) | |
7876 | max_neighbor_width = neighbor_col_default_width; | |
7877 | } | |
f933309e | 7878 | |
d62a17ae | 7879 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
7880 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
7881 | continue; | |
7882 | ||
ea47320b DL |
7883 | if (!peer->afc[afi][safi]) |
7884 | continue; | |
d62a17ae | 7885 | |
ea47320b DL |
7886 | if (!count) { |
7887 | unsigned long ents; | |
7888 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 7889 | int64_t vrf_id_ui; |
d62a17ae | 7890 | |
a4d82a8a PZ |
7891 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
7892 | ? -1 | |
7893 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
7894 | |
7895 | /* Usage summary and header */ | |
7896 | if (use_json) { | |
7897 | json_object_string_add( | |
7898 | json, "routerId", | |
7899 | inet_ntoa(bgp->router_id)); | |
60466a63 QY |
7900 | json_object_int_add(json, "as", bgp->as); |
7901 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
7902 | json_object_string_add( |
7903 | json, "vrfName", | |
7904 | (bgp->inst_type | |
7905 | == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 7906 | ? VRF_DEFAULT_NAME |
ea47320b DL |
7907 | : bgp->name); |
7908 | } else { | |
7909 | vty_out(vty, | |
7910 | "BGP router identifier %s, local AS number %u vrf-id %d", | |
60466a63 | 7911 | inet_ntoa(bgp->router_id), bgp->as, |
a4d82a8a PZ |
7912 | bgp->vrf_id == VRF_UNKNOWN |
7913 | ? -1 | |
7914 | : (int)bgp->vrf_id); | |
ea47320b DL |
7915 | vty_out(vty, "\n"); |
7916 | } | |
d62a17ae | 7917 | |
ea47320b | 7918 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 7919 | if (use_json) { |
ea47320b | 7920 | json_object_int_add( |
60466a63 | 7921 | json, "updateDelayLimit", |
ea47320b | 7922 | bgp->v_update_delay); |
d62a17ae | 7923 | |
ea47320b DL |
7924 | if (bgp->v_update_delay |
7925 | != bgp->v_establish_wait) | |
d62a17ae | 7926 | json_object_int_add( |
7927 | json, | |
ea47320b DL |
7928 | "updateDelayEstablishWait", |
7929 | bgp->v_establish_wait); | |
d62a17ae | 7930 | |
60466a63 | 7931 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
7932 | json_object_string_add( |
7933 | json, | |
7934 | "updateDelayFirstNeighbor", | |
7935 | bgp->update_delay_begin_time); | |
7936 | json_object_boolean_true_add( | |
7937 | json, | |
7938 | "updateDelayInProgress"); | |
7939 | } else { | |
7940 | if (bgp->update_delay_over) { | |
d62a17ae | 7941 | json_object_string_add( |
7942 | json, | |
7943 | "updateDelayFirstNeighbor", | |
7944 | bgp->update_delay_begin_time); | |
ea47320b | 7945 | json_object_string_add( |
d62a17ae | 7946 | json, |
ea47320b DL |
7947 | "updateDelayBestpathResumed", |
7948 | bgp->update_delay_end_time); | |
7949 | json_object_string_add( | |
d62a17ae | 7950 | json, |
ea47320b DL |
7951 | "updateDelayZebraUpdateResume", |
7952 | bgp->update_delay_zebra_resume_time); | |
7953 | json_object_string_add( | |
7954 | json, | |
7955 | "updateDelayPeerUpdateResume", | |
7956 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 7957 | } |
ea47320b DL |
7958 | } |
7959 | } else { | |
7960 | vty_out(vty, | |
7961 | "Read-only mode update-delay limit: %d seconds\n", | |
7962 | bgp->v_update_delay); | |
7963 | if (bgp->v_update_delay | |
7964 | != bgp->v_establish_wait) | |
d62a17ae | 7965 | vty_out(vty, |
ea47320b DL |
7966 | " Establish wait: %d seconds\n", |
7967 | bgp->v_establish_wait); | |
d62a17ae | 7968 | |
60466a63 | 7969 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
7970 | vty_out(vty, |
7971 | " First neighbor established: %s\n", | |
7972 | bgp->update_delay_begin_time); | |
7973 | vty_out(vty, | |
7974 | " Delay in progress\n"); | |
7975 | } else { | |
7976 | if (bgp->update_delay_over) { | |
d62a17ae | 7977 | vty_out(vty, |
7978 | " First neighbor established: %s\n", | |
7979 | bgp->update_delay_begin_time); | |
7980 | vty_out(vty, | |
ea47320b DL |
7981 | " Best-paths resumed: %s\n", |
7982 | bgp->update_delay_end_time); | |
7983 | vty_out(vty, | |
7984 | " zebra update resumed: %s\n", | |
7985 | bgp->update_delay_zebra_resume_time); | |
7986 | vty_out(vty, | |
7987 | " peers update resumed: %s\n", | |
7988 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 7989 | } |
7990 | } | |
7991 | } | |
ea47320b | 7992 | } |
d62a17ae | 7993 | |
ea47320b DL |
7994 | if (use_json) { |
7995 | if (bgp_maxmed_onstartup_configured(bgp) | |
7996 | && bgp->maxmed_active) | |
7997 | json_object_boolean_true_add( | |
60466a63 | 7998 | json, "maxMedOnStartup"); |
ea47320b DL |
7999 | if (bgp->v_maxmed_admin) |
8000 | json_object_boolean_true_add( | |
60466a63 | 8001 | json, "maxMedAdministrative"); |
d62a17ae | 8002 | |
ea47320b DL |
8003 | json_object_int_add( |
8004 | json, "tableVersion", | |
60466a63 | 8005 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 8006 | |
60466a63 QY |
8007 | ents = bgp_table_count(bgp->rib[afi][safi]); |
8008 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
8009 | json_object_int_add( |
8010 | json, "ribMemory", | |
8011 | ents * sizeof(struct bgp_node)); | |
d62a17ae | 8012 | |
ea47320b | 8013 | ents = listcount(bgp->peer); |
60466a63 QY |
8014 | json_object_int_add(json, "peerCount", ents); |
8015 | json_object_int_add(json, "peerMemory", | |
8016 | ents * sizeof(struct peer)); | |
d62a17ae | 8017 | |
ea47320b DL |
8018 | if ((ents = listcount(bgp->group))) { |
8019 | json_object_int_add( | |
60466a63 | 8020 | json, "peerGroupCount", ents); |
ea47320b DL |
8021 | json_object_int_add( |
8022 | json, "peerGroupMemory", | |
996c9314 LB |
8023 | ents * sizeof(struct |
8024 | peer_group)); | |
ea47320b | 8025 | } |
d62a17ae | 8026 | |
ea47320b DL |
8027 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
8028 | BGP_CONFIG_DAMPENING)) | |
8029 | json_object_boolean_true_add( | |
60466a63 | 8030 | json, "dampeningEnabled"); |
ea47320b DL |
8031 | } else { |
8032 | if (bgp_maxmed_onstartup_configured(bgp) | |
8033 | && bgp->maxmed_active) | |
d62a17ae | 8034 | vty_out(vty, |
ea47320b DL |
8035 | "Max-med on-startup active\n"); |
8036 | if (bgp->v_maxmed_admin) | |
d62a17ae | 8037 | vty_out(vty, |
ea47320b | 8038 | "Max-med administrative active\n"); |
d62a17ae | 8039 | |
60466a63 QY |
8040 | vty_out(vty, "BGP table version %" PRIu64 "\n", |
8041 | bgp_table_version(bgp->rib[afi][safi])); | |
d62a17ae | 8042 | |
60466a63 | 8043 | ents = bgp_table_count(bgp->rib[afi][safi]); |
ea47320b DL |
8044 | vty_out(vty, |
8045 | "RIB entries %ld, using %s of memory\n", | |
8046 | ents, | |
996c9314 LB |
8047 | mtype_memstr(memstrbuf, |
8048 | sizeof(memstrbuf), | |
8049 | ents * sizeof(struct | |
8050 | bgp_node))); | |
ea47320b DL |
8051 | |
8052 | /* Peer related usage */ | |
8053 | ents = listcount(bgp->peer); | |
60466a63 | 8054 | vty_out(vty, "Peers %ld, using %s of memory\n", |
ea47320b DL |
8055 | ents, |
8056 | mtype_memstr( | |
60466a63 QY |
8057 | memstrbuf, sizeof(memstrbuf), |
8058 | ents * sizeof(struct peer))); | |
ea47320b DL |
8059 | |
8060 | if ((ents = listcount(bgp->group))) | |
d62a17ae | 8061 | vty_out(vty, |
ea47320b | 8062 | "Peer groups %ld, using %s of memory\n", |
d62a17ae | 8063 | ents, |
8064 | mtype_memstr( | |
8065 | memstrbuf, | |
8066 | sizeof(memstrbuf), | |
996c9314 LB |
8067 | ents * sizeof(struct |
8068 | peer_group))); | |
d62a17ae | 8069 | |
ea47320b DL |
8070 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
8071 | BGP_CONFIG_DAMPENING)) | |
60466a63 | 8072 | vty_out(vty, "Dampening enabled.\n"); |
ea47320b | 8073 | vty_out(vty, "\n"); |
d62a17ae | 8074 | |
ea47320b DL |
8075 | /* Subtract 8 here because 'Neighbor' is |
8076 | * 8 characters */ | |
8077 | vty_out(vty, "Neighbor"); | |
60466a63 QY |
8078 | vty_out(vty, "%*s", max_neighbor_width - 8, |
8079 | " "); | |
ea47320b DL |
8080 | vty_out(vty, |
8081 | "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n"); | |
d62a17ae | 8082 | } |
ea47320b | 8083 | } |
d62a17ae | 8084 | |
ea47320b | 8085 | count++; |
d62a17ae | 8086 | |
ea47320b DL |
8087 | if (use_json) { |
8088 | json_peer = json_object_new_object(); | |
d62a17ae | 8089 | |
b4e9dcba DD |
8090 | if (peer_dynamic_neighbor(peer)) { |
8091 | dn_count++; | |
60466a63 QY |
8092 | json_object_boolean_true_add(json_peer, |
8093 | "dynamicPeer"); | |
b4e9dcba | 8094 | } |
d62a17ae | 8095 | |
ea47320b | 8096 | if (peer->hostname) |
60466a63 | 8097 | json_object_string_add(json_peer, "hostname", |
ea47320b | 8098 | peer->hostname); |
d62a17ae | 8099 | |
ea47320b | 8100 | if (peer->domainname) |
60466a63 QY |
8101 | json_object_string_add(json_peer, "domainname", |
8102 | peer->domainname); | |
d62a17ae | 8103 | |
60466a63 | 8104 | json_object_int_add(json_peer, "remoteAs", peer->as); |
ea47320b | 8105 | json_object_int_add(json_peer, "version", 4); |
60466a63 | 8106 | json_object_int_add(json_peer, "msgRcvd", |
0112e9e0 | 8107 | PEER_TOTAL_RX(peer)); |
60466a63 | 8108 | json_object_int_add(json_peer, "msgSent", |
0112e9e0 | 8109 | PEER_TOTAL_TX(peer)); |
ea47320b DL |
8110 | |
8111 | json_object_int_add(json_peer, "tableVersion", | |
8112 | peer->version[afi][safi]); | |
8113 | json_object_int_add(json_peer, "outq", | |
8114 | peer->obuf->count); | |
8115 | json_object_int_add(json_peer, "inq", 0); | |
60466a63 QY |
8116 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, |
8117 | use_json, json_peer); | |
50e05855 AD |
8118 | |
8119 | /* | |
8120 | * Adding "pfxRcd" field to match with the corresponding | |
8121 | * CLI. "prefixReceivedCount" will be deprecated in | |
8122 | * future. | |
8123 | */ | |
60466a63 QY |
8124 | json_object_int_add(json_peer, "prefixReceivedCount", |
8125 | peer->pcount[afi][pfx_rcd_safi]); | |
50e05855 AD |
8126 | json_object_int_add(json_peer, "pfxRcd", |
8127 | peer->pcount[afi][pfx_rcd_safi]); | |
8128 | ||
8129 | paf = peer_af_find(peer, afi, pfx_rcd_safi); | |
8130 | if (paf && PAF_SUBGRP(paf)) | |
8131 | json_object_int_add(json_peer, | |
8132 | "pfxSnt", | |
8133 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 8134 | |
ea47320b | 8135 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) |
60466a63 | 8136 | json_object_string_add(json_peer, "state", |
ea47320b | 8137 | "Idle (Admin)"); |
9199a725 TM |
8138 | else if (peer->afc_recv[afi][safi]) |
8139 | json_object_string_add( | |
8140 | json_peer, "state", | |
8141 | lookup_msg(bgp_status_msg, peer->status, | |
8142 | NULL)); | |
60466a63 QY |
8143 | else if (CHECK_FLAG(peer->sflags, |
8144 | PEER_STATUS_PREFIX_OVERFLOW)) | |
8145 | json_object_string_add(json_peer, "state", | |
ea47320b DL |
8146 | "Idle (PfxCt)"); |
8147 | else | |
8148 | json_object_string_add( | |
8149 | json_peer, "state", | |
60466a63 QY |
8150 | lookup_msg(bgp_status_msg, peer->status, |
8151 | NULL)); | |
ea47320b DL |
8152 | |
8153 | if (peer->conf_if) | |
60466a63 | 8154 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
8155 | "interface"); |
8156 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
8157 | json_object_string_add(json_peer, "idType", |
8158 | "ipv4"); | |
ea47320b | 8159 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
8160 | json_object_string_add(json_peer, "idType", |
8161 | "ipv6"); | |
d62a17ae | 8162 | |
ea47320b DL |
8163 | json_object_object_add(json_peers, peer->host, |
8164 | json_peer); | |
8165 | } else { | |
8166 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
8167 | if (peer_dynamic_neighbor(peer)) { | |
8168 | dn_count++; | |
8169 | dn_flag[0] = '*'; | |
8170 | } | |
d62a17ae | 8171 | |
ea47320b | 8172 | if (peer->hostname |
60466a63 | 8173 | && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) |
ea47320b | 8174 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
60466a63 | 8175 | peer->hostname, peer->host); |
ea47320b | 8176 | else |
60466a63 | 8177 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
ea47320b DL |
8178 | |
8179 | /* pad the neighbor column with spaces */ | |
8180 | if (len < max_neighbor_width) | |
60466a63 QY |
8181 | vty_out(vty, "%*s", max_neighbor_width - len, |
8182 | " "); | |
ea47320b | 8183 | |
86a55b99 | 8184 | vty_out(vty, "4 %10u %7u %7u %8" PRIu64 " %4d %4zd %8s", |
0112e9e0 QY |
8185 | peer->as, PEER_TOTAL_RX(peer), |
8186 | PEER_TOTAL_TX(peer), peer->version[afi][safi], | |
8187 | 0, peer->obuf->count, | |
d62a17ae | 8188 | peer_uptime(peer->uptime, timebuf, |
ea47320b | 8189 | BGP_UPTIME_LEN, 0, NULL)); |
d62a17ae | 8190 | |
ea47320b | 8191 | if (peer->status == Established) |
2f8f4f10 | 8192 | if (peer->afc_recv[afi][safi]) |
95077abf | 8193 | vty_out(vty, " %12ld", |
a4d82a8a PZ |
8194 | peer->pcount[afi] |
8195 | [pfx_rcd_safi]); | |
95077abf DW |
8196 | else |
8197 | vty_out(vty, " NoNeg"); | |
ea47320b | 8198 | else { |
60466a63 | 8199 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) |
ea47320b | 8200 | vty_out(vty, " Idle (Admin)"); |
60466a63 QY |
8201 | else if (CHECK_FLAG( |
8202 | peer->sflags, | |
8203 | PEER_STATUS_PREFIX_OVERFLOW)) | |
ea47320b | 8204 | vty_out(vty, " Idle (PfxCt)"); |
d62a17ae | 8205 | else |
ea47320b | 8206 | vty_out(vty, " %12s", |
60466a63 QY |
8207 | lookup_msg(bgp_status_msg, |
8208 | peer->status, NULL)); | |
d62a17ae | 8209 | } |
ea47320b | 8210 | vty_out(vty, "\n"); |
d62a17ae | 8211 | } |
8212 | } | |
f933309e | 8213 | |
d62a17ae | 8214 | if (use_json) { |
8215 | json_object_object_add(json, "peers", json_peers); | |
8216 | ||
8217 | json_object_int_add(json, "totalPeers", count); | |
8218 | json_object_int_add(json, "dynamicPeers", dn_count); | |
8219 | ||
57a9c8a8 DS |
8220 | bgp_show_bestpath_json(bgp, json); |
8221 | ||
996c9314 LB |
8222 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
8223 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 8224 | json_object_free(json); |
8225 | } else { | |
8226 | if (count) | |
8227 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
8228 | else { | |
d6ceaca3 | 8229 | vty_out(vty, "No %s neighbor is configured\n", |
8230 | afi_safi_print(afi, safi)); | |
d62a17ae | 8231 | } |
b05a1c8b | 8232 | |
d6ceaca3 | 8233 | if (dn_count) { |
d62a17ae | 8234 | vty_out(vty, "* - dynamic neighbor\n"); |
8235 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
8236 | dn_count, bgp->dynamic_neighbors_limit); | |
8237 | } | |
8238 | } | |
1ff9a340 | 8239 | |
d62a17ae | 8240 | return CMD_SUCCESS; |
718e3744 | 8241 | } |
8242 | ||
d62a17ae | 8243 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
9f049418 | 8244 | int safi, bool use_json, |
d62a17ae | 8245 | json_object *json) |
8246 | { | |
8247 | int is_first = 1; | |
8248 | int afi_wildcard = (afi == AFI_MAX); | |
8249 | int safi_wildcard = (safi == SAFI_MAX); | |
8250 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 8251 | bool nbr_output = false; |
d62a17ae | 8252 | |
8253 | if (use_json && is_wildcard) | |
8254 | vty_out(vty, "{\n"); | |
8255 | if (afi_wildcard) | |
8256 | afi = 1; /* AFI_IP */ | |
8257 | while (afi < AFI_MAX) { | |
8258 | if (safi_wildcard) | |
8259 | safi = 1; /* SAFI_UNICAST */ | |
8260 | while (safi < SAFI_MAX) { | |
318cac96 | 8261 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 8262 | nbr_output = true; |
d62a17ae | 8263 | if (is_wildcard) { |
8264 | /* | |
8265 | * So limit output to those afi/safi | |
8266 | * pairs that | |
8267 | * actualy have something interesting in | |
8268 | * them | |
8269 | */ | |
8270 | if (use_json) { | |
8271 | json = json_object_new_object(); | |
8272 | ||
8273 | if (!is_first) | |
8274 | vty_out(vty, ",\n"); | |
8275 | else | |
8276 | is_first = 0; | |
8277 | ||
8278 | vty_out(vty, "\"%s\":", | |
8279 | afi_safi_json(afi, | |
8280 | safi)); | |
8281 | } else { | |
8282 | vty_out(vty, "\n%s Summary:\n", | |
8283 | afi_safi_print(afi, | |
8284 | safi)); | |
8285 | } | |
8286 | } | |
8287 | bgp_show_summary(vty, bgp, afi, safi, use_json, | |
8288 | json); | |
8289 | } | |
8290 | safi++; | |
d62a17ae | 8291 | if (!safi_wildcard) |
8292 | safi = SAFI_MAX; | |
8293 | } | |
8294 | afi++; | |
ee851c8c | 8295 | if (!afi_wildcard) |
d62a17ae | 8296 | afi = AFI_MAX; |
8297 | } | |
8298 | ||
8299 | if (use_json && is_wildcard) | |
8300 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
8301 | else if (!nbr_output) { |
8302 | if (use_json) | |
8303 | vty_out(vty, "{}\n"); | |
8304 | else | |
8305 | vty_out(vty, "%% No BGP neighbors found\n"); | |
8306 | } | |
d62a17ae | 8307 | } |
8308 | ||
8309 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
9f049418 | 8310 | safi_t safi, bool use_json) |
d62a17ae | 8311 | { |
8312 | struct listnode *node, *nnode; | |
8313 | struct bgp *bgp; | |
8314 | json_object *json = NULL; | |
8315 | int is_first = 1; | |
9f049418 | 8316 | bool nbr_output = false; |
d62a17ae | 8317 | |
8318 | if (use_json) | |
8319 | vty_out(vty, "{\n"); | |
8320 | ||
8321 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 8322 | nbr_output = true; |
d62a17ae | 8323 | if (use_json) { |
8324 | json = json_object_new_object(); | |
8325 | ||
8326 | if (!is_first) | |
8327 | vty_out(vty, ",\n"); | |
8328 | else | |
8329 | is_first = 0; | |
8330 | ||
8331 | vty_out(vty, "\"%s\":", | |
8332 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 8333 | ? VRF_DEFAULT_NAME |
d62a17ae | 8334 | : bgp->name); |
8335 | } else { | |
8336 | vty_out(vty, "\nInstance %s:\n", | |
8337 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 8338 | ? VRF_DEFAULT_NAME |
d62a17ae | 8339 | : bgp->name); |
8340 | } | |
8341 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, json); | |
8342 | } | |
8343 | ||
8344 | if (use_json) | |
8345 | vty_out(vty, "}\n"); | |
9f049418 DS |
8346 | else if (!nbr_output) |
8347 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 8348 | } |
8349 | ||
8350 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
9f049418 | 8351 | safi_t safi, bool use_json) |
d62a17ae | 8352 | { |
8353 | struct bgp *bgp; | |
8354 | ||
8355 | if (name) { | |
8356 | if (strmatch(name, "all")) { | |
8357 | bgp_show_all_instances_summary_vty(vty, afi, safi, | |
8358 | use_json); | |
8359 | return CMD_SUCCESS; | |
8360 | } else { | |
8361 | bgp = bgp_lookup_by_name(name); | |
8362 | ||
8363 | if (!bgp) { | |
8364 | if (use_json) | |
8365 | vty_out(vty, "{}\n"); | |
8366 | else | |
8367 | vty_out(vty, | |
ca61fd25 | 8368 | "%% BGP instance not found\n"); |
d62a17ae | 8369 | return CMD_WARNING; |
8370 | } | |
8371 | ||
8372 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, | |
8373 | NULL); | |
8374 | return CMD_SUCCESS; | |
8375 | } | |
8376 | } | |
8377 | ||
8378 | bgp = bgp_get_default(); | |
8379 | ||
8380 | if (bgp) | |
8381 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, NULL); | |
9f049418 | 8382 | else { |
ca61fd25 DS |
8383 | if (use_json) |
8384 | vty_out(vty, "{}\n"); | |
8385 | else | |
8386 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
8387 | return CMD_WARNING; |
8388 | } | |
d62a17ae | 8389 | |
8390 | return CMD_SUCCESS; | |
4fb25c53 DW |
8391 | } |
8392 | ||
716b2d8a | 8393 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 8394 | DEFUN (show_ip_bgp_summary, |
718e3744 | 8395 | show_ip_bgp_summary_cmd, |
dd6bd0f1 | 8396 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] summary [json]", |
718e3744 | 8397 | SHOW_STR |
8398 | IP_STR | |
8399 | BGP_STR | |
8386ac43 | 8400 | BGP_INSTANCE_HELP_STR |
46f296b4 | 8401 | BGP_AFI_HELP_STR |
dd6bd0f1 | 8402 | BGP_SAFI_WITH_LABEL_HELP_STR |
b05a1c8b | 8403 | "Summary of BGP neighbor status\n" |
9973d184 | 8404 | JSON_STR) |
718e3744 | 8405 | { |
d62a17ae | 8406 | char *vrf = NULL; |
8407 | afi_t afi = AFI_MAX; | |
8408 | safi_t safi = SAFI_MAX; | |
8409 | ||
8410 | int idx = 0; | |
8411 | ||
8412 | /* show [ip] bgp */ | |
8413 | if (argv_find(argv, argc, "ip", &idx)) | |
8414 | afi = AFI_IP; | |
9a8bdf1c PG |
8415 | /* [<vrf> VIEWVRFNAME] */ |
8416 | if (argv_find(argv, argc, "vrf", &idx)) { | |
8417 | vrf = argv[idx + 1]->arg; | |
8418 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
8419 | vrf = NULL; | |
8420 | } else if (argv_find(argv, argc, "view", &idx)) | |
8421 | /* [<view> VIEWVRFNAME] */ | |
8422 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 8423 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
8424 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
8425 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
8426 | } | |
8427 | ||
9f049418 | 8428 | bool uj = use_json(argc, argv); |
d62a17ae | 8429 | |
8430 | return bgp_show_summary_vty(vty, vrf, afi, safi, uj); | |
8431 | } | |
8432 | ||
8433 | const char *afi_safi_print(afi_t afi, safi_t safi) | |
8434 | { | |
8435 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
8436 | return "IPv4 Unicast"; | |
8437 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
8438 | return "IPv4 Multicast"; | |
8439 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
8440 | return "IPv4 Labeled Unicast"; | |
8441 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
8442 | return "IPv4 VPN"; | |
8443 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
8444 | return "IPv4 Encap"; | |
7c40bf39 | 8445 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) |
8446 | return "IPv4 Flowspec"; | |
d62a17ae | 8447 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
8448 | return "IPv6 Unicast"; | |
8449 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
8450 | return "IPv6 Multicast"; | |
8451 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
8452 | return "IPv6 Labeled Unicast"; | |
8453 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
8454 | return "IPv6 VPN"; | |
8455 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
8456 | return "IPv6 Encap"; | |
7c40bf39 | 8457 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) |
8458 | return "IPv6 Flowspec"; | |
d62a17ae | 8459 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) |
8460 | return "L2VPN EVPN"; | |
8461 | else | |
8462 | return "Unknown"; | |
538621f2 | 8463 | } |
8464 | ||
b9f77ec8 DS |
8465 | /* |
8466 | * Please note that we have intentionally camelCased | |
8467 | * the return strings here. So if you want | |
8468 | * to use this function, please ensure you | |
8469 | * are doing this within json output | |
8470 | */ | |
d62a17ae | 8471 | const char *afi_safi_json(afi_t afi, safi_t safi) |
8472 | { | |
8473 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
8474 | return "ipv4Unicast"; | |
8475 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
8476 | return "ipv4Multicast"; | |
8477 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
8478 | return "ipv4LabeledUnicast"; | |
8479 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
8480 | return "ipv4Vpn"; | |
8481 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
8482 | return "ipv4Encap"; | |
7c40bf39 | 8483 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) |
8484 | return "ipv4Flowspec"; | |
d62a17ae | 8485 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
8486 | return "ipv6Unicast"; | |
8487 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
8488 | return "ipv6Multicast"; | |
8489 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
8490 | return "ipv6LabeledUnicast"; | |
8491 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
8492 | return "ipv6Vpn"; | |
8493 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
8494 | return "ipv6Encap"; | |
7c40bf39 | 8495 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) |
8496 | return "ipv6Flowspec"; | |
d62a17ae | 8497 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) |
8498 | return "l2VpnEvpn"; | |
8499 | else | |
8500 | return "Unknown"; | |
27162734 LB |
8501 | } |
8502 | ||
718e3744 | 8503 | /* Show BGP peer's information. */ |
d62a17ae | 8504 | enum show_type { show_all, show_peer }; |
8505 | ||
8506 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
8507 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
8508 | uint16_t adv_smcap, uint16_t adv_rmcap, |
8509 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 8510 | bool use_json, json_object *json_pref) |
d62a17ae | 8511 | { |
8512 | /* Send-Mode */ | |
8513 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
8514 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
8515 | if (use_json) { | |
8516 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
8517 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8518 | json_object_string_add(json_pref, "sendMode", | |
8519 | "advertisedAndReceived"); | |
8520 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
8521 | json_object_string_add(json_pref, "sendMode", | |
8522 | "advertised"); | |
8523 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8524 | json_object_string_add(json_pref, "sendMode", | |
8525 | "received"); | |
8526 | } else { | |
8527 | vty_out(vty, " Send-mode: "); | |
8528 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
8529 | vty_out(vty, "advertised"); | |
8530 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8531 | vty_out(vty, "%sreceived", | |
8532 | CHECK_FLAG(p->af_cap[afi][safi], | |
8533 | adv_smcap) | |
8534 | ? ", " | |
8535 | : ""); | |
8536 | vty_out(vty, "\n"); | |
8537 | } | |
8538 | } | |
8539 | ||
8540 | /* Receive-Mode */ | |
8541 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
8542 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
8543 | if (use_json) { | |
8544 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
8545 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8546 | json_object_string_add(json_pref, "recvMode", | |
8547 | "advertisedAndReceived"); | |
8548 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
8549 | json_object_string_add(json_pref, "recvMode", | |
8550 | "advertised"); | |
8551 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8552 | json_object_string_add(json_pref, "recvMode", | |
8553 | "received"); | |
8554 | } else { | |
8555 | vty_out(vty, " Receive-mode: "); | |
8556 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
8557 | vty_out(vty, "advertised"); | |
8558 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8559 | vty_out(vty, "%sreceived", | |
8560 | CHECK_FLAG(p->af_cap[afi][safi], | |
8561 | adv_rmcap) | |
8562 | ? ", " | |
8563 | : ""); | |
8564 | vty_out(vty, "\n"); | |
8565 | } | |
8566 | } | |
8567 | } | |
8568 | ||
8569 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, | |
9f049418 | 8570 | safi_t safi, bool use_json, |
d62a17ae | 8571 | json_object *json_neigh) |
8572 | { | |
0291c246 MK |
8573 | struct bgp_filter *filter; |
8574 | struct peer_af *paf; | |
8575 | char orf_pfx_name[BUFSIZ]; | |
8576 | int orf_pfx_count; | |
8577 | json_object *json_af = NULL; | |
8578 | json_object *json_prefA = NULL; | |
8579 | json_object *json_prefB = NULL; | |
8580 | json_object *json_addr = NULL; | |
d62a17ae | 8581 | |
8582 | if (use_json) { | |
8583 | json_addr = json_object_new_object(); | |
8584 | json_af = json_object_new_object(); | |
8585 | filter = &p->filter[afi][safi]; | |
8586 | ||
8587 | if (peer_group_active(p)) | |
8588 | json_object_string_add(json_addr, "peerGroupMember", | |
8589 | p->group->name); | |
8590 | ||
8591 | paf = peer_af_find(p, afi, safi); | |
8592 | if (paf && PAF_SUBGRP(paf)) { | |
8593 | json_object_int_add(json_addr, "updateGroupId", | |
8594 | PAF_UPDGRP(paf)->id); | |
8595 | json_object_int_add(json_addr, "subGroupId", | |
8596 | PAF_SUBGRP(paf)->id); | |
8597 | json_object_int_add(json_addr, "packetQueueLength", | |
8598 | bpacket_queue_virtual_length(paf)); | |
8599 | } | |
8600 | ||
8601 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8602 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8603 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8604 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8605 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8606 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8607 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
8608 | json_object_int_add(json_af, "orfType", | |
8609 | ORF_TYPE_PREFIX); | |
8610 | json_prefA = json_object_new_object(); | |
8611 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
8612 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
8613 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8614 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
8615 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
8616 | use_json, json_prefA); | |
8617 | json_object_object_add(json_af, "orfPrefixList", | |
8618 | json_prefA); | |
8619 | } | |
8620 | ||
8621 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8622 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8623 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8624 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8625 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8626 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8627 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
8628 | json_object_int_add(json_af, "orfOldType", | |
8629 | ORF_TYPE_PREFIX_OLD); | |
8630 | json_prefB = json_object_new_object(); | |
8631 | bgp_show_peer_afi_orf_cap( | |
8632 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
8633 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8634 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
8635 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
8636 | json_prefB); | |
8637 | json_object_object_add(json_af, "orfOldPrefixList", | |
8638 | json_prefB); | |
8639 | } | |
8640 | ||
8641 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8642 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8643 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8644 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8645 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8646 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8647 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8648 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8649 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
8650 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8651 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
8652 | json_object_object_add(json_addr, "afDependentCap", | |
8653 | json_af); | |
8654 | else | |
8655 | json_object_free(json_af); | |
8656 | ||
8657 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
8658 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
8659 | NULL, afi, orf_pfx_name, use_json); | |
8660 | ||
8661 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8662 | PEER_STATUS_ORF_PREFIX_SEND) | |
8663 | || orf_pfx_count) { | |
8664 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8665 | PEER_STATUS_ORF_PREFIX_SEND)) | |
8666 | json_object_boolean_true_add(json_neigh, | |
8667 | "orfSent"); | |
8668 | if (orf_pfx_count) | |
8669 | json_object_int_add(json_addr, "orfRecvCounter", | |
8670 | orf_pfx_count); | |
8671 | } | |
8672 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8673 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
8674 | json_object_string_add( | |
8675 | json_addr, "orfFirstUpdate", | |
8676 | "deferredUntilORFOrRouteRefreshRecvd"); | |
8677 | ||
8678 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8679 | PEER_FLAG_REFLECTOR_CLIENT)) | |
8680 | json_object_boolean_true_add(json_addr, | |
8681 | "routeReflectorClient"); | |
8682 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8683 | PEER_FLAG_RSERVER_CLIENT)) | |
8684 | json_object_boolean_true_add(json_addr, | |
8685 | "routeServerClient"); | |
8686 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
8687 | json_object_boolean_true_add(json_addr, | |
8688 | "inboundSoftConfigPermit"); | |
8689 | ||
8690 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8691 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
8692 | json_object_boolean_true_add( | |
8693 | json_addr, | |
8694 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
8695 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8696 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
8697 | json_object_boolean_true_add( | |
8698 | json_addr, | |
8699 | "privateAsNumsReplacedInUpdatesToNbr"); | |
8700 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8701 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
8702 | json_object_boolean_true_add( | |
8703 | json_addr, | |
8704 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
8705 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8706 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
8707 | json_object_boolean_true_add( | |
8708 | json_addr, | |
8709 | "privateAsNumsRemovedInUpdatesToNbr"); | |
8710 | ||
dcc68b5e MS |
8711 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
8712 | json_object_boolean_true_add( | |
8713 | json_addr, | |
8714 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
8715 | ->type_json_name); | |
d62a17ae | 8716 | |
8717 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
8718 | json_object_string_add(json_addr, | |
8719 | "overrideASNsInOutboundUpdates", | |
8720 | "ifAspathEqualRemoteAs"); | |
8721 | ||
8722 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
8723 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8724 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
8725 | json_object_boolean_true_add(json_addr, | |
8726 | "routerAlwaysNextHop"); | |
8727 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8728 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
8729 | json_object_boolean_true_add( | |
8730 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
8731 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8732 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
8733 | json_object_boolean_true_add( | |
8734 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
8735 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
8736 | json_object_boolean_true_add( | |
8737 | json_addr, "unchangedMedPropogatedToNbr"); | |
8738 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
8739 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8740 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
8741 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8742 | PEER_FLAG_SEND_COMMUNITY) | |
8743 | && CHECK_FLAG(p->af_flags[afi][safi], | |
8744 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
8745 | json_object_string_add(json_addr, | |
8746 | "commAttriSentToNbr", | |
8747 | "extendedAndStandard"); | |
8748 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8749 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
8750 | json_object_string_add(json_addr, | |
8751 | "commAttriSentToNbr", | |
8752 | "extended"); | |
8753 | else | |
8754 | json_object_string_add(json_addr, | |
8755 | "commAttriSentToNbr", | |
8756 | "standard"); | |
8757 | } | |
8758 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8759 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
8760 | if (p->default_rmap[afi][safi].name) | |
8761 | json_object_string_add( | |
8762 | json_addr, "defaultRouteMap", | |
8763 | p->default_rmap[afi][safi].name); | |
8764 | ||
8765 | if (paf && PAF_SUBGRP(paf) | |
8766 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
8767 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
8768 | json_object_boolean_true_add(json_addr, | |
8769 | "defaultSent"); | |
8770 | else | |
8771 | json_object_boolean_true_add(json_addr, | |
8772 | "defaultNotSent"); | |
8773 | } | |
8774 | ||
dff8f48d | 8775 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 8776 | if (is_evpn_enabled()) |
60466a63 QY |
8777 | json_object_boolean_true_add( |
8778 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
8779 | } |
8780 | ||
d62a17ae | 8781 | if (filter->plist[FILTER_IN].name |
8782 | || filter->dlist[FILTER_IN].name | |
8783 | || filter->aslist[FILTER_IN].name | |
8784 | || filter->map[RMAP_IN].name) | |
8785 | json_object_boolean_true_add(json_addr, | |
8786 | "inboundPathPolicyConfig"); | |
8787 | if (filter->plist[FILTER_OUT].name | |
8788 | || filter->dlist[FILTER_OUT].name | |
8789 | || filter->aslist[FILTER_OUT].name | |
8790 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
8791 | json_object_boolean_true_add( | |
8792 | json_addr, "outboundPathPolicyConfig"); | |
8793 | ||
8794 | /* prefix-list */ | |
8795 | if (filter->plist[FILTER_IN].name) | |
8796 | json_object_string_add(json_addr, | |
8797 | "incomingUpdatePrefixFilterList", | |
8798 | filter->plist[FILTER_IN].name); | |
8799 | if (filter->plist[FILTER_OUT].name) | |
8800 | json_object_string_add(json_addr, | |
8801 | "outgoingUpdatePrefixFilterList", | |
8802 | filter->plist[FILTER_OUT].name); | |
8803 | ||
8804 | /* distribute-list */ | |
8805 | if (filter->dlist[FILTER_IN].name) | |
8806 | json_object_string_add( | |
8807 | json_addr, "incomingUpdateNetworkFilterList", | |
8808 | filter->dlist[FILTER_IN].name); | |
8809 | if (filter->dlist[FILTER_OUT].name) | |
8810 | json_object_string_add( | |
8811 | json_addr, "outgoingUpdateNetworkFilterList", | |
8812 | filter->dlist[FILTER_OUT].name); | |
8813 | ||
8814 | /* filter-list. */ | |
8815 | if (filter->aslist[FILTER_IN].name) | |
8816 | json_object_string_add(json_addr, | |
8817 | "incomingUpdateAsPathFilterList", | |
8818 | filter->aslist[FILTER_IN].name); | |
8819 | if (filter->aslist[FILTER_OUT].name) | |
8820 | json_object_string_add(json_addr, | |
8821 | "outgoingUpdateAsPathFilterList", | |
8822 | filter->aslist[FILTER_OUT].name); | |
8823 | ||
8824 | /* route-map. */ | |
8825 | if (filter->map[RMAP_IN].name) | |
8826 | json_object_string_add( | |
8827 | json_addr, "routeMapForIncomingAdvertisements", | |
8828 | filter->map[RMAP_IN].name); | |
8829 | if (filter->map[RMAP_OUT].name) | |
8830 | json_object_string_add( | |
8831 | json_addr, "routeMapForOutgoingAdvertisements", | |
8832 | filter->map[RMAP_OUT].name); | |
8833 | ||
8834 | /* unsuppress-map */ | |
8835 | if (filter->usmap.name) | |
8836 | json_object_string_add(json_addr, | |
8837 | "selectiveUnsuppressRouteMap", | |
8838 | filter->usmap.name); | |
8839 | ||
8840 | /* Receive prefix count */ | |
8841 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
8842 | p->pcount[afi][safi]); | |
50e05855 AD |
8843 | if (paf && PAF_SUBGRP(paf)) |
8844 | json_object_int_add(json_addr, "sentPrefixCounter", | |
8845 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 8846 | |
8847 | /* Maximum prefix */ | |
8848 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
8849 | json_object_int_add(json_addr, "prefixAllowedMax", | |
8850 | p->pmax[afi][safi]); | |
8851 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8852 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
8853 | json_object_boolean_true_add( | |
8854 | json_addr, "prefixAllowedMaxWarning"); | |
8855 | json_object_int_add(json_addr, | |
8856 | "prefixAllowedWarningThresh", | |
8857 | p->pmax_threshold[afi][safi]); | |
8858 | if (p->pmax_restart[afi][safi]) | |
8859 | json_object_int_add( | |
8860 | json_addr, | |
8861 | "prefixAllowedRestartIntervalMsecs", | |
8862 | p->pmax_restart[afi][safi] * 60000); | |
8863 | } | |
8864 | json_object_object_add(json_neigh, afi_safi_print(afi, safi), | |
8865 | json_addr); | |
8866 | ||
8867 | } else { | |
8868 | filter = &p->filter[afi][safi]; | |
8869 | ||
8870 | vty_out(vty, " For address family: %s\n", | |
8871 | afi_safi_print(afi, safi)); | |
8872 | ||
8873 | if (peer_group_active(p)) | |
8874 | vty_out(vty, " %s peer-group member\n", | |
8875 | p->group->name); | |
8876 | ||
8877 | paf = peer_af_find(p, afi, safi); | |
8878 | if (paf && PAF_SUBGRP(paf)) { | |
996c9314 LB |
8879 | vty_out(vty, " Update group %" PRIu64 |
8880 | ", subgroup %" PRIu64 "\n", | |
d62a17ae | 8881 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
8882 | vty_out(vty, " Packet Queue length %d\n", | |
8883 | bpacket_queue_virtual_length(paf)); | |
8884 | } else { | |
8885 | vty_out(vty, " Not part of any update group\n"); | |
8886 | } | |
8887 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8888 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8889 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8890 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8891 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8892 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8893 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8894 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8895 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
8896 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8897 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
8898 | vty_out(vty, " AF-dependant capabilities:\n"); | |
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_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_RCV)) { | |
8907 | vty_out(vty, | |
8908 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
8909 | ORF_TYPE_PREFIX); | |
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_RCV, | |
8914 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
8915 | } | |
8916 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8917 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8918 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8919 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8920 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8921 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8922 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
8923 | vty_out(vty, | |
8924 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
8925 | ORF_TYPE_PREFIX_OLD); | |
8926 | bgp_show_peer_afi_orf_cap( | |
8927 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
8928 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8929 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
8930 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
8931 | } | |
8932 | ||
8933 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
8934 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
8935 | NULL, afi, orf_pfx_name, use_json); | |
8936 | ||
8937 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8938 | PEER_STATUS_ORF_PREFIX_SEND) | |
8939 | || orf_pfx_count) { | |
8940 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
8941 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8942 | PEER_STATUS_ORF_PREFIX_SEND)) | |
8943 | vty_out(vty, " sent;"); | |
8944 | if (orf_pfx_count) | |
8945 | vty_out(vty, " received (%d entries)", | |
8946 | orf_pfx_count); | |
8947 | vty_out(vty, "\n"); | |
8948 | } | |
8949 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8950 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
8951 | vty_out(vty, | |
8952 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
8953 | ||
8954 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8955 | PEER_FLAG_REFLECTOR_CLIENT)) | |
8956 | vty_out(vty, " Route-Reflector Client\n"); | |
8957 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8958 | PEER_FLAG_RSERVER_CLIENT)) | |
8959 | vty_out(vty, " Route-Server Client\n"); | |
8960 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
8961 | vty_out(vty, | |
8962 | " Inbound soft reconfiguration allowed\n"); | |
8963 | ||
8964 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8965 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
8966 | vty_out(vty, | |
8967 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
8968 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8969 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
8970 | vty_out(vty, | |
8971 | " Private AS numbers replaced in updates to this neighbor\n"); | |
8972 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8973 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
8974 | vty_out(vty, | |
8975 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
8976 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8977 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
8978 | vty_out(vty, | |
8979 | " Private AS numbers removed in updates to this neighbor\n"); | |
8980 | ||
dcc68b5e MS |
8981 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
8982 | vty_out(vty, " %s\n", | |
8983 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
8984 | ->human_description); | |
d62a17ae | 8985 | |
8986 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
8987 | vty_out(vty, | |
8988 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
8989 | ||
8990 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
8991 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8992 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
8993 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
8994 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8995 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
8996 | vty_out(vty, | |
8997 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
8998 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8999 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
9000 | vty_out(vty, | |
9001 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
9002 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
9003 | vty_out(vty, | |
9004 | " MED is propagated unchanged to this neighbor\n"); | |
9005 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
9006 | || CHECK_FLAG(p->af_flags[afi][safi], | |
9007 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
9008 | || CHECK_FLAG(p->af_flags[afi][safi], | |
9009 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
9010 | vty_out(vty, | |
9011 | " Community attribute sent to this neighbor"); | |
9012 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9013 | PEER_FLAG_SEND_COMMUNITY) | |
9014 | && CHECK_FLAG(p->af_flags[afi][safi], | |
9015 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
9016 | && CHECK_FLAG(p->af_flags[afi][safi], | |
9017 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
9018 | vty_out(vty, "(all)\n"); | |
9019 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9020 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
9021 | vty_out(vty, "(large)\n"); | |
9022 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9023 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
9024 | vty_out(vty, "(extended)\n"); | |
9025 | else | |
9026 | vty_out(vty, "(standard)\n"); | |
9027 | } | |
9028 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9029 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
9030 | vty_out(vty, " Default information originate,"); | |
9031 | ||
9032 | if (p->default_rmap[afi][safi].name) | |
9033 | vty_out(vty, " default route-map %s%s,", | |
9034 | p->default_rmap[afi][safi].map ? "*" | |
9035 | : "", | |
9036 | p->default_rmap[afi][safi].name); | |
9037 | if (paf && PAF_SUBGRP(paf) | |
9038 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
9039 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
9040 | vty_out(vty, " default sent\n"); | |
9041 | else | |
9042 | vty_out(vty, " default not sent\n"); | |
9043 | } | |
9044 | ||
dff8f48d MK |
9045 | /* advertise-vni-all */ |
9046 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 9047 | if (is_evpn_enabled()) |
dff8f48d MK |
9048 | vty_out(vty, " advertise-all-vni\n"); |
9049 | } | |
9050 | ||
d62a17ae | 9051 | if (filter->plist[FILTER_IN].name |
9052 | || filter->dlist[FILTER_IN].name | |
9053 | || filter->aslist[FILTER_IN].name | |
9054 | || filter->map[RMAP_IN].name) | |
9055 | vty_out(vty, " Inbound path policy configured\n"); | |
9056 | if (filter->plist[FILTER_OUT].name | |
9057 | || filter->dlist[FILTER_OUT].name | |
9058 | || filter->aslist[FILTER_OUT].name | |
9059 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
9060 | vty_out(vty, " Outbound path policy configured\n"); | |
9061 | ||
9062 | /* prefix-list */ | |
9063 | if (filter->plist[FILTER_IN].name) | |
9064 | vty_out(vty, | |
9065 | " Incoming update prefix filter list is %s%s\n", | |
9066 | filter->plist[FILTER_IN].plist ? "*" : "", | |
9067 | filter->plist[FILTER_IN].name); | |
9068 | if (filter->plist[FILTER_OUT].name) | |
9069 | vty_out(vty, | |
9070 | " Outgoing update prefix filter list is %s%s\n", | |
9071 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
9072 | filter->plist[FILTER_OUT].name); | |
9073 | ||
9074 | /* distribute-list */ | |
9075 | if (filter->dlist[FILTER_IN].name) | |
9076 | vty_out(vty, | |
9077 | " Incoming update network filter list is %s%s\n", | |
9078 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
9079 | filter->dlist[FILTER_IN].name); | |
9080 | if (filter->dlist[FILTER_OUT].name) | |
9081 | vty_out(vty, | |
9082 | " Outgoing update network filter list is %s%s\n", | |
9083 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
9084 | filter->dlist[FILTER_OUT].name); | |
9085 | ||
9086 | /* filter-list. */ | |
9087 | if (filter->aslist[FILTER_IN].name) | |
9088 | vty_out(vty, | |
9089 | " Incoming update AS path filter list is %s%s\n", | |
9090 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
9091 | filter->aslist[FILTER_IN].name); | |
9092 | if (filter->aslist[FILTER_OUT].name) | |
9093 | vty_out(vty, | |
9094 | " Outgoing update AS path filter list is %s%s\n", | |
9095 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
9096 | filter->aslist[FILTER_OUT].name); | |
9097 | ||
9098 | /* route-map. */ | |
9099 | if (filter->map[RMAP_IN].name) | |
9100 | vty_out(vty, | |
9101 | " Route map for incoming advertisements is %s%s\n", | |
9102 | filter->map[RMAP_IN].map ? "*" : "", | |
9103 | filter->map[RMAP_IN].name); | |
9104 | if (filter->map[RMAP_OUT].name) | |
9105 | vty_out(vty, | |
9106 | " Route map for outgoing advertisements is %s%s\n", | |
9107 | filter->map[RMAP_OUT].map ? "*" : "", | |
9108 | filter->map[RMAP_OUT].name); | |
9109 | ||
9110 | /* unsuppress-map */ | |
9111 | if (filter->usmap.name) | |
9112 | vty_out(vty, | |
9113 | " Route map for selective unsuppress is %s%s\n", | |
9114 | filter->usmap.map ? "*" : "", | |
9115 | filter->usmap.name); | |
9116 | ||
9117 | /* Receive prefix count */ | |
9118 | vty_out(vty, " %ld accepted prefixes\n", p->pcount[afi][safi]); | |
9119 | ||
9120 | /* Maximum prefix */ | |
9121 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
9122 | vty_out(vty, " Maximum prefixes allowed %ld%s\n", | |
9123 | p->pmax[afi][safi], | |
9124 | CHECK_FLAG(p->af_flags[afi][safi], | |
9125 | PEER_FLAG_MAX_PREFIX_WARNING) | |
9126 | ? " (warning-only)" | |
9127 | : ""); | |
9128 | vty_out(vty, " Threshold for warning message %d%%", | |
9129 | p->pmax_threshold[afi][safi]); | |
9130 | if (p->pmax_restart[afi][safi]) | |
9131 | vty_out(vty, ", restart interval %d min", | |
9132 | p->pmax_restart[afi][safi]); | |
9133 | vty_out(vty, "\n"); | |
9134 | } | |
9135 | ||
9136 | vty_out(vty, "\n"); | |
9137 | } | |
9138 | } | |
9139 | ||
9f049418 | 9140 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 9141 | json_object *json) |
718e3744 | 9142 | { |
d62a17ae | 9143 | struct bgp *bgp; |
9144 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
9145 | char timebuf[BGP_UPTIME_LEN]; | |
9146 | char dn_flag[2]; | |
9147 | const char *subcode_str; | |
9148 | const char *code_str; | |
9149 | afi_t afi; | |
9150 | safi_t safi; | |
d7c0a89a QY |
9151 | uint16_t i; |
9152 | uint8_t *msg; | |
d62a17ae | 9153 | json_object *json_neigh = NULL; |
9154 | time_t epoch_tbuf; | |
718e3744 | 9155 | |
d62a17ae | 9156 | bgp = p->bgp; |
9157 | ||
9158 | if (use_json) | |
9159 | json_neigh = json_object_new_object(); | |
9160 | ||
9161 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
9162 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
9163 | dn_flag[0] = '*'; | |
9164 | ||
9165 | if (!use_json) { | |
9166 | if (p->conf_if) /* Configured interface name. */ | |
9167 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
9168 | BGP_PEER_SU_UNSPEC(p) | |
9169 | ? "None" | |
9170 | : sockunion2str(&p->su, buf, | |
9171 | SU_ADDRSTRLEN)); | |
9172 | else /* Configured IP address. */ | |
9173 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
9174 | p->host); | |
9175 | } | |
9176 | ||
9177 | if (use_json) { | |
9178 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
9179 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
9180 | "none"); | |
9181 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
9182 | json_object_string_add( | |
9183 | json_neigh, "bgpNeighborAddr", | |
9184 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
9185 | ||
9186 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
9187 | ||
9188 | if (p->change_local_as) | |
9189 | json_object_int_add(json_neigh, "localAs", | |
9190 | p->change_local_as); | |
9191 | else | |
9192 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
9193 | ||
9194 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
9195 | json_object_boolean_true_add(json_neigh, | |
9196 | "localAsNoPrepend"); | |
9197 | ||
9198 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
9199 | json_object_boolean_true_add(json_neigh, | |
9200 | "localAsReplaceAs"); | |
9201 | } else { | |
9202 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
9203 | || (p->as_type == AS_INTERNAL)) | |
9204 | vty_out(vty, "remote AS %u, ", p->as); | |
9205 | else | |
9206 | vty_out(vty, "remote AS Unspecified, "); | |
9207 | vty_out(vty, "local AS %u%s%s, ", | |
9208 | p->change_local_as ? p->change_local_as : p->local_as, | |
9209 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
9210 | ? " no-prepend" | |
9211 | : "", | |
9212 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
9213 | ? " replace-as" | |
9214 | : ""); | |
9215 | } | |
9216 | /* peer type internal, external, confed-internal or confed-external */ | |
9217 | if (p->as == p->local_as) { | |
9218 | if (use_json) { | |
9219 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9220 | json_object_boolean_true_add( | |
9221 | json_neigh, "nbrConfedInternalLink"); | |
9222 | else | |
9223 | json_object_boolean_true_add(json_neigh, | |
9224 | "nbrInternalLink"); | |
9225 | } else { | |
9226 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9227 | vty_out(vty, "confed-internal link\n"); | |
9228 | else | |
9229 | vty_out(vty, "internal link\n"); | |
9230 | } | |
9231 | } else { | |
9232 | if (use_json) { | |
9233 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9234 | json_object_boolean_true_add( | |
9235 | json_neigh, "nbrConfedExternalLink"); | |
9236 | else | |
9237 | json_object_boolean_true_add(json_neigh, | |
9238 | "nbrExternalLink"); | |
9239 | } else { | |
9240 | if (bgp_confederation_peers_check(bgp, p->as)) | |
9241 | vty_out(vty, "confed-external link\n"); | |
9242 | else | |
9243 | vty_out(vty, "external link\n"); | |
9244 | } | |
9245 | } | |
9246 | ||
9247 | /* Description. */ | |
9248 | if (p->desc) { | |
9249 | if (use_json) | |
9250 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
9251 | else | |
9252 | vty_out(vty, " Description: %s\n", p->desc); | |
9253 | } | |
9254 | ||
9255 | if (p->hostname) { | |
9256 | if (use_json) { | |
9257 | if (p->hostname) | |
9258 | json_object_string_add(json_neigh, "hostname", | |
9259 | p->hostname); | |
9260 | ||
9261 | if (p->domainname) | |
9262 | json_object_string_add(json_neigh, "domainname", | |
9263 | p->domainname); | |
9264 | } else { | |
9265 | if (p->domainname && (p->domainname[0] != '\0')) | |
9266 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
9267 | p->domainname); | |
9268 | else | |
9269 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
9270 | } | |
9271 | } | |
9272 | ||
9273 | /* Peer-group */ | |
9274 | if (p->group) { | |
9275 | if (use_json) { | |
9276 | json_object_string_add(json_neigh, "peerGroup", | |
9277 | p->group->name); | |
9278 | ||
9279 | if (dn_flag[0]) { | |
9280 | struct prefix prefix, *range = NULL; | |
9281 | ||
9282 | sockunion2hostprefix(&(p->su), &prefix); | |
9283 | range = peer_group_lookup_dynamic_neighbor_range( | |
9284 | p->group, &prefix); | |
9285 | ||
9286 | if (range) { | |
9287 | prefix2str(range, buf1, sizeof(buf1)); | |
9288 | json_object_string_add( | |
9289 | json_neigh, | |
9290 | "peerSubnetRangeGroup", buf1); | |
9291 | } | |
9292 | } | |
9293 | } else { | |
9294 | vty_out(vty, | |
9295 | " Member of peer-group %s for session parameters\n", | |
9296 | p->group->name); | |
9297 | ||
9298 | if (dn_flag[0]) { | |
9299 | struct prefix prefix, *range = NULL; | |
9300 | ||
9301 | sockunion2hostprefix(&(p->su), &prefix); | |
9302 | range = peer_group_lookup_dynamic_neighbor_range( | |
9303 | p->group, &prefix); | |
9304 | ||
9305 | if (range) { | |
9306 | prefix2str(range, buf1, sizeof(buf1)); | |
9307 | vty_out(vty, | |
9308 | " Belongs to the subnet range group: %s\n", | |
9309 | buf1); | |
9310 | } | |
9311 | } | |
9312 | } | |
9313 | } | |
9314 | ||
9315 | if (use_json) { | |
9316 | /* Administrative shutdown. */ | |
9317 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
9318 | json_object_boolean_true_add(json_neigh, | |
9319 | "adminShutDown"); | |
9320 | ||
9321 | /* BGP Version. */ | |
9322 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
9323 | json_object_string_add( | |
9324 | json_neigh, "remoteRouterId", | |
9325 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
d0086e8e AD |
9326 | json_object_string_add( |
9327 | json_neigh, "localRouterId", | |
9328 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
9329 | sizeof(buf1))); | |
d62a17ae | 9330 | |
9331 | /* Confederation */ | |
9332 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
9333 | && bgp_confederation_peers_check(bgp, p->as)) | |
9334 | json_object_boolean_true_add(json_neigh, | |
9335 | "nbrCommonAdmin"); | |
9336 | ||
9337 | /* Status. */ | |
9338 | json_object_string_add( | |
9339 | json_neigh, "bgpState", | |
9340 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
9341 | ||
9342 | if (p->status == Established) { | |
9343 | time_t uptime; | |
d62a17ae | 9344 | |
9345 | uptime = bgp_clock(); | |
9346 | uptime -= p->uptime; | |
d62a17ae | 9347 | epoch_tbuf = time(NULL) - uptime; |
9348 | ||
bee57a7a | 9349 | #if CONFDATE > 20200101 |
a4d82a8a PZ |
9350 | CPP_NOTICE( |
9351 | "bgpTimerUp should be deprecated and can be removed now"); | |
d3c7efed DS |
9352 | #endif |
9353 | /* | |
9354 | * bgpTimerUp was miliseconds that was accurate | |
9355 | * up to 1 day, then the value returned | |
9356 | * became garbage. So in order to provide | |
9357 | * some level of backwards compatability, | |
9358 | * we still provde the data, but now | |
9359 | * we are returning the correct value | |
9360 | * and also adding a new bgpTimerUpMsec | |
9361 | * which will allow us to deprecate | |
9362 | * this eventually | |
9363 | */ | |
d62a17ae | 9364 | json_object_int_add(json_neigh, "bgpTimerUp", |
e0330274 | 9365 | uptime * 1000); |
d3c7efed DS |
9366 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
9367 | uptime * 1000); | |
d62a17ae | 9368 | json_object_string_add(json_neigh, "bgpTimerUpString", |
9369 | peer_uptime(p->uptime, timebuf, | |
9370 | BGP_UPTIME_LEN, 0, | |
9371 | NULL)); | |
9372 | json_object_int_add(json_neigh, | |
9373 | "bgpTimerUpEstablishedEpoch", | |
9374 | epoch_tbuf); | |
9375 | } | |
9376 | ||
9377 | else if (p->status == Active) { | |
9378 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
9379 | json_object_string_add(json_neigh, "bgpStateIs", | |
9380 | "passive"); | |
9381 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
9382 | json_object_string_add(json_neigh, "bgpStateIs", | |
9383 | "passiveNSF"); | |
9384 | } | |
9385 | ||
9386 | /* read timer */ | |
9387 | time_t uptime; | |
9388 | struct tm *tm; | |
9389 | ||
9390 | uptime = bgp_clock(); | |
9391 | uptime -= p->readtime; | |
9392 | tm = gmtime(&uptime); | |
9393 | json_object_int_add(json_neigh, "bgpTimerLastRead", | |
9394 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9395 | + (tm->tm_hour * 3600000)); | |
9396 | ||
9397 | uptime = bgp_clock(); | |
9398 | uptime -= p->last_write; | |
9399 | tm = gmtime(&uptime); | |
9400 | json_object_int_add(json_neigh, "bgpTimerLastWrite", | |
9401 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9402 | + (tm->tm_hour * 3600000)); | |
9403 | ||
9404 | uptime = bgp_clock(); | |
9405 | uptime -= p->update_time; | |
9406 | tm = gmtime(&uptime); | |
9407 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", | |
9408 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9409 | + (tm->tm_hour * 3600000)); | |
9410 | ||
9411 | /* Configured timer values. */ | |
9412 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
9413 | p->v_holdtime * 1000); | |
9414 | json_object_int_add(json_neigh, | |
9415 | "bgpTimerKeepAliveIntervalMsecs", | |
9416 | p->v_keepalive * 1000); | |
b90a8e13 | 9417 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 9418 | json_object_int_add(json_neigh, |
9419 | "bgpTimerConfiguredHoldTimeMsecs", | |
9420 | p->holdtime * 1000); | |
9421 | json_object_int_add( | |
9422 | json_neigh, | |
9423 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
9424 | p->keepalive * 1000); | |
d25e4efc | 9425 | } else if ((bgp->default_holdtime != BGP_DEFAULT_HOLDTIME) |
a4d82a8a PZ |
9426 | || (bgp->default_keepalive |
9427 | != BGP_DEFAULT_KEEPALIVE)) { | |
d25e4efc DS |
9428 | json_object_int_add(json_neigh, |
9429 | "bgpTimerConfiguredHoldTimeMsecs", | |
9430 | bgp->default_holdtime); | |
9431 | json_object_int_add( | |
9432 | json_neigh, | |
9433 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
9434 | bgp->default_keepalive); | |
d62a17ae | 9435 | } |
9436 | } else { | |
9437 | /* Administrative shutdown. */ | |
9438 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
9439 | vty_out(vty, " Administratively shut down\n"); | |
9440 | ||
9441 | /* BGP Version. */ | |
9442 | vty_out(vty, " BGP version 4"); | |
0e38aeb4 | 9443 | vty_out(vty, ", remote router ID %s", |
d62a17ae | 9444 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
0e38aeb4 AD |
9445 | vty_out(vty, ", local router ID %s\n", |
9446 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
9447 | sizeof(buf1))); | |
d62a17ae | 9448 | |
9449 | /* Confederation */ | |
9450 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
9451 | && bgp_confederation_peers_check(bgp, p->as)) | |
9452 | vty_out(vty, | |
9453 | " Neighbor under common administration\n"); | |
9454 | ||
9455 | /* Status. */ | |
9456 | vty_out(vty, " BGP state = %s", | |
9457 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
9458 | ||
9459 | if (p->status == Established) | |
9460 | vty_out(vty, ", up for %8s", | |
9461 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
9462 | 0, NULL)); | |
9463 | ||
9464 | else if (p->status == Active) { | |
9465 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
9466 | vty_out(vty, " (passive)"); | |
9467 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
9468 | vty_out(vty, " (NSF passive)"); | |
9469 | } | |
9470 | vty_out(vty, "\n"); | |
9471 | ||
9472 | /* read timer */ | |
9473 | vty_out(vty, " Last read %s", | |
9474 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
9475 | NULL)); | |
9476 | vty_out(vty, ", Last write %s\n", | |
9477 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
9478 | NULL)); | |
9479 | ||
9480 | /* Configured timer values. */ | |
9481 | vty_out(vty, | |
9482 | " Hold time is %d, keepalive interval is %d seconds\n", | |
9483 | p->v_holdtime, p->v_keepalive); | |
b90a8e13 | 9484 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 9485 | vty_out(vty, " Configured hold time is %d", |
9486 | p->holdtime); | |
9487 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
9488 | p->keepalive); | |
d25e4efc | 9489 | } else if ((bgp->default_holdtime != BGP_DEFAULT_HOLDTIME) |
a4d82a8a PZ |
9490 | || (bgp->default_keepalive |
9491 | != BGP_DEFAULT_KEEPALIVE)) { | |
d25e4efc DS |
9492 | vty_out(vty, " Configured hold time is %d", |
9493 | bgp->default_holdtime); | |
9494 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
9495 | bgp->default_keepalive); | |
d62a17ae | 9496 | } |
9497 | } | |
9498 | /* Capability. */ | |
9499 | if (p->status == Established) { | |
9500 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] | |
9501 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
9502 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
9503 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
9504 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
9505 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
9506 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
9507 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
9508 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
9509 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
9510 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
9511 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
7c40bf39 | 9512 | || p->afc_adv[AFI_IP6][SAFI_FLOWSPEC] |
9513 | || p->afc_recv[AFI_IP6][SAFI_FLOWSPEC] | |
d62a17ae | 9514 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
9515 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
7c40bf39 | 9516 | || p->afc_adv[AFI_IP][SAFI_FLOWSPEC] |
9517 | || p->afc_recv[AFI_IP][SAFI_FLOWSPEC] | |
d62a17ae | 9518 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
9519 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
9520 | if (use_json) { | |
9521 | json_object *json_cap = NULL; | |
9522 | ||
9523 | json_cap = json_object_new_object(); | |
9524 | ||
9525 | /* AS4 */ | |
9526 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
9527 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
9528 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
9529 | && CHECK_FLAG(p->cap, | |
9530 | PEER_CAP_AS4_RCV)) | |
9531 | json_object_string_add( | |
9532 | json_cap, "4byteAs", | |
9533 | "advertisedAndReceived"); | |
9534 | else if (CHECK_FLAG(p->cap, | |
9535 | PEER_CAP_AS4_ADV)) | |
9536 | json_object_string_add( | |
9537 | json_cap, "4byteAs", | |
9538 | "advertised"); | |
9539 | else if (CHECK_FLAG(p->cap, | |
9540 | PEER_CAP_AS4_RCV)) | |
9541 | json_object_string_add( | |
9542 | json_cap, "4byteAs", | |
9543 | "received"); | |
9544 | } | |
9545 | ||
9546 | /* AddPath */ | |
9547 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
9548 | || CHECK_FLAG(p->cap, | |
9549 | PEER_CAP_ADDPATH_ADV)) { | |
9550 | json_object *json_add = NULL; | |
9551 | const char *print_store; | |
9552 | ||
9553 | json_add = json_object_new_object(); | |
9554 | ||
05c7a1cc QY |
9555 | FOREACH_AFI_SAFI (afi, safi) { |
9556 | json_object *json_sub = NULL; | |
9557 | json_sub = | |
9558 | json_object_new_object(); | |
9559 | print_store = afi_safi_print( | |
9560 | afi, safi); | |
d62a17ae | 9561 | |
05c7a1cc QY |
9562 | if (CHECK_FLAG( |
9563 | p->af_cap[afi] | |
9564 | [safi], | |
9565 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9566 | || CHECK_FLAG( | |
9567 | p->af_cap[afi] | |
9568 | [safi], | |
9569 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 9570 | if (CHECK_FLAG( |
9571 | p->af_cap | |
9572 | [afi] | |
9573 | [safi], | |
9574 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 9575 | && CHECK_FLAG( |
d62a17ae | 9576 | p->af_cap |
9577 | [afi] | |
9578 | [safi], | |
05c7a1cc QY |
9579 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
9580 | json_object_boolean_true_add( | |
9581 | json_sub, | |
9582 | "txAdvertisedAndReceived"); | |
9583 | else if ( | |
9584 | CHECK_FLAG( | |
9585 | p->af_cap | |
9586 | [afi] | |
9587 | [safi], | |
9588 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
9589 | json_object_boolean_true_add( | |
9590 | json_sub, | |
9591 | "txAdvertised"); | |
9592 | else if ( | |
9593 | CHECK_FLAG( | |
9594 | p->af_cap | |
9595 | [afi] | |
9596 | [safi], | |
9597 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
9598 | json_object_boolean_true_add( | |
9599 | json_sub, | |
9600 | "txReceived"); | |
9601 | } | |
d62a17ae | 9602 | |
05c7a1cc QY |
9603 | if (CHECK_FLAG( |
9604 | p->af_cap[afi] | |
9605 | [safi], | |
9606 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9607 | || CHECK_FLAG( | |
9608 | p->af_cap[afi] | |
9609 | [safi], | |
9610 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 9611 | if (CHECK_FLAG( |
9612 | p->af_cap | |
9613 | [afi] | |
9614 | [safi], | |
9615 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 9616 | && CHECK_FLAG( |
d62a17ae | 9617 | p->af_cap |
9618 | [afi] | |
9619 | [safi], | |
9620 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
9621 | json_object_boolean_true_add( |
9622 | json_sub, | |
9623 | "rxAdvertisedAndReceived"); | |
9624 | else if ( | |
9625 | CHECK_FLAG( | |
9626 | p->af_cap | |
9627 | [afi] | |
9628 | [safi], | |
9629 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
9630 | json_object_boolean_true_add( | |
9631 | json_sub, | |
9632 | "rxAdvertised"); | |
9633 | else if ( | |
9634 | CHECK_FLAG( | |
9635 | p->af_cap | |
9636 | [afi] | |
9637 | [safi], | |
9638 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
9639 | json_object_boolean_true_add( | |
9640 | json_sub, | |
9641 | "rxReceived"); | |
d62a17ae | 9642 | } |
9643 | ||
05c7a1cc QY |
9644 | if (CHECK_FLAG( |
9645 | p->af_cap[afi] | |
9646 | [safi], | |
9647 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9648 | || CHECK_FLAG( | |
9649 | p->af_cap[afi] | |
9650 | [safi], | |
9651 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
9652 | || CHECK_FLAG( | |
9653 | p->af_cap[afi] | |
9654 | [safi], | |
9655 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9656 | || CHECK_FLAG( | |
9657 | p->af_cap[afi] | |
9658 | [safi], | |
9659 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
9660 | json_object_object_add( | |
9661 | json_add, | |
9662 | print_store, | |
9663 | json_sub); | |
9664 | else | |
9665 | json_object_free( | |
9666 | json_sub); | |
9667 | } | |
9668 | ||
d62a17ae | 9669 | json_object_object_add( |
9670 | json_cap, "addPath", json_add); | |
9671 | } | |
9672 | ||
9673 | /* Dynamic */ | |
9674 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
9675 | || CHECK_FLAG(p->cap, | |
9676 | PEER_CAP_DYNAMIC_ADV)) { | |
9677 | if (CHECK_FLAG(p->cap, | |
9678 | PEER_CAP_DYNAMIC_ADV) | |
9679 | && CHECK_FLAG(p->cap, | |
9680 | PEER_CAP_DYNAMIC_RCV)) | |
9681 | json_object_string_add( | |
9682 | json_cap, "dynamic", | |
9683 | "advertisedAndReceived"); | |
9684 | else if (CHECK_FLAG( | |
9685 | p->cap, | |
9686 | PEER_CAP_DYNAMIC_ADV)) | |
9687 | json_object_string_add( | |
9688 | json_cap, "dynamic", | |
9689 | "advertised"); | |
9690 | else if (CHECK_FLAG( | |
9691 | p->cap, | |
9692 | PEER_CAP_DYNAMIC_RCV)) | |
9693 | json_object_string_add( | |
9694 | json_cap, "dynamic", | |
9695 | "received"); | |
9696 | } | |
9697 | ||
9698 | /* Extended nexthop */ | |
9699 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
9700 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
9701 | json_object *json_nxt = NULL; | |
9702 | const char *print_store; | |
9703 | ||
9704 | ||
9705 | if (CHECK_FLAG(p->cap, | |
9706 | PEER_CAP_ENHE_ADV) | |
9707 | && CHECK_FLAG(p->cap, | |
9708 | PEER_CAP_ENHE_RCV)) | |
9709 | json_object_string_add( | |
9710 | json_cap, | |
9711 | "extendedNexthop", | |
9712 | "advertisedAndReceived"); | |
9713 | else if (CHECK_FLAG(p->cap, | |
9714 | PEER_CAP_ENHE_ADV)) | |
9715 | json_object_string_add( | |
9716 | json_cap, | |
9717 | "extendedNexthop", | |
9718 | "advertised"); | |
9719 | else if (CHECK_FLAG(p->cap, | |
9720 | PEER_CAP_ENHE_RCV)) | |
9721 | json_object_string_add( | |
9722 | json_cap, | |
9723 | "extendedNexthop", | |
9724 | "received"); | |
9725 | ||
9726 | if (CHECK_FLAG(p->cap, | |
9727 | PEER_CAP_ENHE_RCV)) { | |
9728 | json_nxt = | |
9729 | json_object_new_object(); | |
9730 | ||
9731 | for (safi = SAFI_UNICAST; | |
9732 | safi < SAFI_MAX; safi++) { | |
9733 | if (CHECK_FLAG( | |
9734 | p->af_cap | |
9735 | [AFI_IP] | |
9736 | [safi], | |
9737 | PEER_CAP_ENHE_AF_RCV)) { | |
9738 | print_store = afi_safi_print( | |
9739 | AFI_IP, | |
9740 | safi); | |
9741 | json_object_string_add( | |
9742 | json_nxt, | |
9743 | print_store, | |
54f29523 | 9744 | "recieved"); /* misspelled for compatibility */ |
d62a17ae | 9745 | } |
9746 | } | |
9747 | json_object_object_add( | |
9748 | json_cap, | |
9749 | "extendedNexthopFamililesByPeer", | |
9750 | json_nxt); | |
9751 | } | |
9752 | } | |
9753 | ||
9754 | /* Route Refresh */ | |
9755 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
9756 | || CHECK_FLAG(p->cap, | |
9757 | PEER_CAP_REFRESH_NEW_RCV) | |
9758 | || CHECK_FLAG(p->cap, | |
9759 | PEER_CAP_REFRESH_OLD_RCV)) { | |
9760 | if (CHECK_FLAG(p->cap, | |
9761 | PEER_CAP_REFRESH_ADV) | |
9762 | && (CHECK_FLAG( | |
9763 | p->cap, | |
9764 | PEER_CAP_REFRESH_NEW_RCV) | |
9765 | || CHECK_FLAG( | |
9766 | p->cap, | |
9767 | PEER_CAP_REFRESH_OLD_RCV))) { | |
9768 | if (CHECK_FLAG( | |
9769 | p->cap, | |
9770 | PEER_CAP_REFRESH_OLD_RCV) | |
9771 | && CHECK_FLAG( | |
9772 | p->cap, | |
9773 | PEER_CAP_REFRESH_NEW_RCV)) | |
9774 | json_object_string_add( | |
9775 | json_cap, | |
9776 | "routeRefresh", | |
9777 | "advertisedAndReceivedOldNew"); | |
9778 | else { | |
9779 | if (CHECK_FLAG( | |
9780 | p->cap, | |
9781 | PEER_CAP_REFRESH_OLD_RCV)) | |
9782 | json_object_string_add( | |
9783 | json_cap, | |
9784 | "routeRefresh", | |
9785 | "advertisedAndReceivedOld"); | |
9786 | else | |
9787 | json_object_string_add( | |
9788 | json_cap, | |
9789 | "routeRefresh", | |
9790 | "advertisedAndReceivedNew"); | |
9791 | } | |
9792 | } else if ( | |
9793 | CHECK_FLAG( | |
9794 | p->cap, | |
9795 | PEER_CAP_REFRESH_ADV)) | |
9796 | json_object_string_add( | |
9797 | json_cap, | |
9798 | "routeRefresh", | |
9799 | "advertised"); | |
9800 | else if ( | |
9801 | CHECK_FLAG( | |
9802 | p->cap, | |
9803 | PEER_CAP_REFRESH_NEW_RCV) | |
9804 | || CHECK_FLAG( | |
9805 | p->cap, | |
9806 | PEER_CAP_REFRESH_OLD_RCV)) | |
9807 | json_object_string_add( | |
9808 | json_cap, | |
9809 | "routeRefresh", | |
9810 | "received"); | |
9811 | } | |
9812 | ||
9813 | /* Multiprotocol Extensions */ | |
9814 | json_object *json_multi = NULL; | |
9815 | json_multi = json_object_new_object(); | |
9816 | ||
05c7a1cc QY |
9817 | FOREACH_AFI_SAFI (afi, safi) { |
9818 | if (p->afc_adv[afi][safi] | |
9819 | || p->afc_recv[afi][safi]) { | |
9820 | json_object *json_exten = NULL; | |
9821 | json_exten = | |
9822 | json_object_new_object(); | |
9823 | ||
d62a17ae | 9824 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
9825 | && p->afc_recv[afi][safi]) |
9826 | json_object_boolean_true_add( | |
9827 | json_exten, | |
9828 | "advertisedAndReceived"); | |
9829 | else if (p->afc_adv[afi][safi]) | |
9830 | json_object_boolean_true_add( | |
9831 | json_exten, | |
9832 | "advertised"); | |
9833 | else if (p->afc_recv[afi][safi]) | |
9834 | json_object_boolean_true_add( | |
9835 | json_exten, | |
9836 | "received"); | |
d62a17ae | 9837 | |
05c7a1cc QY |
9838 | json_object_object_add( |
9839 | json_multi, | |
9840 | afi_safi_print(afi, | |
9841 | safi), | |
9842 | json_exten); | |
d62a17ae | 9843 | } |
9844 | } | |
9845 | json_object_object_add( | |
9846 | json_cap, "multiprotocolExtensions", | |
9847 | json_multi); | |
9848 | ||
d77114b7 | 9849 | /* Hostname capabilities */ |
60466a63 | 9850 | json_object *json_hname = NULL; |
d77114b7 MK |
9851 | |
9852 | json_hname = json_object_new_object(); | |
9853 | ||
9854 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
9855 | json_object_string_add( | |
60466a63 QY |
9856 | json_hname, "advHostName", |
9857 | bgp->peer_self->hostname | |
9858 | ? bgp->peer_self | |
9859 | ->hostname | |
d77114b7 MK |
9860 | : "n/a"); |
9861 | json_object_string_add( | |
60466a63 QY |
9862 | json_hname, "advDomainName", |
9863 | bgp->peer_self->domainname | |
9864 | ? bgp->peer_self | |
9865 | ->domainname | |
d77114b7 MK |
9866 | : "n/a"); |
9867 | } | |
9868 | ||
9869 | ||
9870 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
9871 | json_object_string_add( | |
60466a63 QY |
9872 | json_hname, "rcvHostName", |
9873 | p->hostname ? p->hostname | |
9874 | : "n/a"); | |
d77114b7 | 9875 | json_object_string_add( |
60466a63 QY |
9876 | json_hname, "rcvDomainName", |
9877 | p->domainname ? p->domainname | |
9878 | : "n/a"); | |
d77114b7 MK |
9879 | } |
9880 | ||
60466a63 | 9881 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
9882 | json_hname); |
9883 | ||
d62a17ae | 9884 | /* Gracefull Restart */ |
9885 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
9886 | || CHECK_FLAG(p->cap, | |
9887 | PEER_CAP_RESTART_ADV)) { | |
9888 | if (CHECK_FLAG(p->cap, | |
9889 | PEER_CAP_RESTART_ADV) | |
9890 | && CHECK_FLAG(p->cap, | |
9891 | PEER_CAP_RESTART_RCV)) | |
9892 | json_object_string_add( | |
9893 | json_cap, | |
9894 | "gracefulRestart", | |
9895 | "advertisedAndReceived"); | |
9896 | else if (CHECK_FLAG( | |
9897 | p->cap, | |
9898 | PEER_CAP_RESTART_ADV)) | |
9899 | json_object_string_add( | |
9900 | json_cap, | |
9901 | "gracefulRestartCapability", | |
9902 | "advertised"); | |
9903 | else if (CHECK_FLAG( | |
9904 | p->cap, | |
9905 | PEER_CAP_RESTART_RCV)) | |
9906 | json_object_string_add( | |
9907 | json_cap, | |
9908 | "gracefulRestartCapability", | |
9909 | "received"); | |
9910 | ||
9911 | if (CHECK_FLAG(p->cap, | |
9912 | PEER_CAP_RESTART_RCV)) { | |
9913 | int restart_af_count = 0; | |
9914 | json_object *json_restart = | |
9915 | NULL; | |
9916 | json_restart = | |
9917 | json_object_new_object(); | |
9918 | ||
9919 | json_object_int_add( | |
9920 | json_cap, | |
9921 | "gracefulRestartRemoteTimerMsecs", | |
9922 | p->v_gr_restart * 1000); | |
9923 | ||
05c7a1cc QY |
9924 | FOREACH_AFI_SAFI (afi, safi) { |
9925 | if (CHECK_FLAG( | |
9926 | p->af_cap | |
9927 | [afi] | |
9928 | [safi], | |
9929 | PEER_CAP_RESTART_AF_RCV)) { | |
9930 | json_object * | |
9931 | json_sub = | |
9932 | NULL; | |
9933 | json_sub = | |
9934 | json_object_new_object(); | |
9935 | ||
d62a17ae | 9936 | if (CHECK_FLAG( |
9937 | p->af_cap | |
9938 | [afi] | |
9939 | [safi], | |
05c7a1cc QY |
9940 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
9941 | json_object_boolean_true_add( | |
9942 | json_sub, | |
9943 | "preserved"); | |
9944 | restart_af_count++; | |
9945 | json_object_object_add( | |
9946 | json_restart, | |
9947 | afi_safi_print( | |
9948 | afi, | |
9949 | safi), | |
9950 | json_sub); | |
d62a17ae | 9951 | } |
9952 | } | |
9953 | if (!restart_af_count) { | |
9954 | json_object_string_add( | |
9955 | json_cap, | |
9956 | "addressFamiliesByPeer", | |
9957 | "none"); | |
9958 | json_object_free( | |
9959 | json_restart); | |
9960 | } else | |
9961 | json_object_object_add( | |
9962 | json_cap, | |
9963 | "addressFamiliesByPeer", | |
9964 | json_restart); | |
9965 | } | |
9966 | } | |
9967 | json_object_object_add(json_neigh, | |
9968 | "neighborCapabilities", | |
9969 | json_cap); | |
9970 | } else { | |
9971 | vty_out(vty, " Neighbor capabilities:\n"); | |
9972 | ||
9973 | /* AS4 */ | |
9974 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
9975 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
9976 | vty_out(vty, " 4 Byte AS:"); | |
9977 | if (CHECK_FLAG(p->cap, | |
9978 | PEER_CAP_AS4_ADV)) | |
9979 | vty_out(vty, " advertised"); | |
9980 | if (CHECK_FLAG(p->cap, | |
9981 | PEER_CAP_AS4_RCV)) | |
9982 | vty_out(vty, " %sreceived", | |
9983 | CHECK_FLAG( | |
9984 | p->cap, | |
9985 | PEER_CAP_AS4_ADV) | |
9986 | ? "and " | |
9987 | : ""); | |
9988 | vty_out(vty, "\n"); | |
9989 | } | |
9990 | ||
9991 | /* AddPath */ | |
9992 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
9993 | || CHECK_FLAG(p->cap, | |
9994 | PEER_CAP_ADDPATH_ADV)) { | |
9995 | vty_out(vty, " AddPath:\n"); | |
9996 | ||
05c7a1cc QY |
9997 | FOREACH_AFI_SAFI (afi, safi) { |
9998 | if (CHECK_FLAG( | |
9999 | p->af_cap[afi] | |
10000 | [safi], | |
10001 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
10002 | || CHECK_FLAG( | |
10003 | p->af_cap[afi] | |
10004 | [safi], | |
10005 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
10006 | vty_out(vty, | |
10007 | " %s: TX ", | |
10008 | afi_safi_print( | |
10009 | afi, | |
10010 | safi)); | |
10011 | ||
d62a17ae | 10012 | if (CHECK_FLAG( |
10013 | p->af_cap | |
10014 | [afi] | |
10015 | [safi], | |
05c7a1cc | 10016 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 10017 | vty_out(vty, |
05c7a1cc | 10018 | "advertised %s", |
d62a17ae | 10019 | afi_safi_print( |
10020 | afi, | |
10021 | safi)); | |
10022 | ||
05c7a1cc QY |
10023 | if (CHECK_FLAG( |
10024 | p->af_cap | |
10025 | [afi] | |
10026 | [safi], | |
10027 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
10028 | vty_out(vty, | |
10029 | "%sreceived", | |
10030 | CHECK_FLAG( | |
10031 | p->af_cap | |
10032 | [afi] | |
10033 | [safi], | |
10034 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
10035 | ? " and " | |
10036 | : ""); | |
d62a17ae | 10037 | |
05c7a1cc QY |
10038 | vty_out(vty, "\n"); |
10039 | } | |
d62a17ae | 10040 | |
05c7a1cc QY |
10041 | if (CHECK_FLAG( |
10042 | p->af_cap[afi] | |
10043 | [safi], | |
10044 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
10045 | || CHECK_FLAG( | |
10046 | p->af_cap[afi] | |
10047 | [safi], | |
10048 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
10049 | vty_out(vty, | |
10050 | " %s: RX ", | |
10051 | afi_safi_print( | |
10052 | afi, | |
10053 | safi)); | |
d62a17ae | 10054 | |
10055 | if (CHECK_FLAG( | |
10056 | p->af_cap | |
10057 | [afi] | |
10058 | [safi], | |
05c7a1cc | 10059 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 10060 | vty_out(vty, |
05c7a1cc | 10061 | "advertised %s", |
d62a17ae | 10062 | afi_safi_print( |
10063 | afi, | |
10064 | safi)); | |
10065 | ||
05c7a1cc QY |
10066 | if (CHECK_FLAG( |
10067 | p->af_cap | |
10068 | [afi] | |
10069 | [safi], | |
10070 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 10071 | vty_out(vty, |
05c7a1cc QY |
10072 | "%sreceived", |
10073 | CHECK_FLAG( | |
10074 | p->af_cap | |
10075 | [afi] | |
10076 | [safi], | |
10077 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
10078 | ? " and " | |
10079 | : ""); | |
10080 | ||
10081 | vty_out(vty, "\n"); | |
d62a17ae | 10082 | } |
05c7a1cc | 10083 | } |
d62a17ae | 10084 | } |
10085 | ||
10086 | /* Dynamic */ | |
10087 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
10088 | || CHECK_FLAG(p->cap, | |
10089 | PEER_CAP_DYNAMIC_ADV)) { | |
10090 | vty_out(vty, " Dynamic:"); | |
10091 | if (CHECK_FLAG(p->cap, | |
10092 | PEER_CAP_DYNAMIC_ADV)) | |
10093 | vty_out(vty, " advertised"); | |
10094 | if (CHECK_FLAG(p->cap, | |
10095 | PEER_CAP_DYNAMIC_RCV)) | |
10096 | vty_out(vty, " %sreceived", | |
10097 | CHECK_FLAG( | |
10098 | p->cap, | |
10099 | PEER_CAP_DYNAMIC_ADV) | |
10100 | ? "and " | |
10101 | : ""); | |
10102 | vty_out(vty, "\n"); | |
10103 | } | |
10104 | ||
10105 | /* Extended nexthop */ | |
10106 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
10107 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
10108 | vty_out(vty, " Extended nexthop:"); | |
10109 | if (CHECK_FLAG(p->cap, | |
10110 | PEER_CAP_ENHE_ADV)) | |
10111 | vty_out(vty, " advertised"); | |
10112 | if (CHECK_FLAG(p->cap, | |
10113 | PEER_CAP_ENHE_RCV)) | |
10114 | vty_out(vty, " %sreceived", | |
10115 | CHECK_FLAG( | |
10116 | p->cap, | |
10117 | PEER_CAP_ENHE_ADV) | |
10118 | ? "and " | |
10119 | : ""); | |
10120 | vty_out(vty, "\n"); | |
10121 | ||
10122 | if (CHECK_FLAG(p->cap, | |
10123 | PEER_CAP_ENHE_RCV)) { | |
10124 | vty_out(vty, | |
10125 | " Address families by peer:\n "); | |
10126 | for (safi = SAFI_UNICAST; | |
10127 | safi < SAFI_MAX; safi++) | |
10128 | if (CHECK_FLAG( | |
10129 | p->af_cap | |
10130 | [AFI_IP] | |
10131 | [safi], | |
10132 | PEER_CAP_ENHE_AF_RCV)) | |
10133 | vty_out(vty, | |
10134 | " %s\n", | |
10135 | afi_safi_print( | |
10136 | AFI_IP, | |
10137 | safi)); | |
10138 | } | |
10139 | } | |
10140 | ||
10141 | /* Route Refresh */ | |
10142 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
10143 | || CHECK_FLAG(p->cap, | |
10144 | PEER_CAP_REFRESH_NEW_RCV) | |
10145 | || CHECK_FLAG(p->cap, | |
10146 | PEER_CAP_REFRESH_OLD_RCV)) { | |
10147 | vty_out(vty, " Route refresh:"); | |
10148 | if (CHECK_FLAG(p->cap, | |
10149 | PEER_CAP_REFRESH_ADV)) | |
10150 | vty_out(vty, " advertised"); | |
10151 | if (CHECK_FLAG(p->cap, | |
10152 | PEER_CAP_REFRESH_NEW_RCV) | |
10153 | || CHECK_FLAG( | |
10154 | p->cap, | |
10155 | PEER_CAP_REFRESH_OLD_RCV)) | |
10156 | vty_out(vty, " %sreceived(%s)", | |
10157 | CHECK_FLAG( | |
10158 | p->cap, | |
10159 | PEER_CAP_REFRESH_ADV) | |
10160 | ? "and " | |
10161 | : "", | |
10162 | (CHECK_FLAG( | |
10163 | p->cap, | |
10164 | PEER_CAP_REFRESH_OLD_RCV) | |
10165 | && CHECK_FLAG( | |
10166 | p->cap, | |
10167 | PEER_CAP_REFRESH_NEW_RCV)) | |
10168 | ? "old & new" | |
10169 | : CHECK_FLAG( | |
10170 | p->cap, | |
10171 | PEER_CAP_REFRESH_OLD_RCV) | |
10172 | ? "old" | |
10173 | : "new"); | |
10174 | ||
10175 | vty_out(vty, "\n"); | |
10176 | } | |
10177 | ||
10178 | /* Multiprotocol Extensions */ | |
05c7a1cc QY |
10179 | FOREACH_AFI_SAFI (afi, safi) |
10180 | if (p->afc_adv[afi][safi] | |
10181 | || p->afc_recv[afi][safi]) { | |
10182 | vty_out(vty, | |
10183 | " Address Family %s:", | |
10184 | afi_safi_print(afi, | |
10185 | safi)); | |
10186 | if (p->afc_adv[afi][safi]) | |
d62a17ae | 10187 | vty_out(vty, |
05c7a1cc QY |
10188 | " advertised"); |
10189 | if (p->afc_recv[afi][safi]) | |
10190 | vty_out(vty, | |
10191 | " %sreceived", | |
10192 | p->afc_adv[afi] | |
10193 | [safi] | |
10194 | ? "and " | |
10195 | : ""); | |
10196 | vty_out(vty, "\n"); | |
10197 | } | |
d62a17ae | 10198 | |
10199 | /* Hostname capability */ | |
60466a63 | 10200 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
10201 | |
10202 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
10203 | vty_out(vty, |
10204 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
10205 | bgp->peer_self->hostname |
10206 | ? bgp->peer_self | |
10207 | ->hostname | |
d77114b7 | 10208 | : "n/a", |
60466a63 QY |
10209 | bgp->peer_self->domainname |
10210 | ? bgp->peer_self | |
10211 | ->domainname | |
d77114b7 MK |
10212 | : "n/a"); |
10213 | } else { | |
10214 | vty_out(vty, " not advertised"); | |
d62a17ae | 10215 | } |
10216 | ||
d77114b7 | 10217 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
10218 | vty_out(vty, |
10219 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
10220 | p->hostname ? p->hostname |
10221 | : "n/a", | |
10222 | p->domainname ? p->domainname | |
10223 | : "n/a"); | |
d77114b7 MK |
10224 | } else { |
10225 | vty_out(vty, " not received"); | |
10226 | } | |
10227 | ||
10228 | vty_out(vty, "\n"); | |
10229 | ||
d62a17ae | 10230 | /* Gracefull Restart */ |
10231 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
10232 | || CHECK_FLAG(p->cap, | |
10233 | PEER_CAP_RESTART_ADV)) { | |
10234 | vty_out(vty, | |
10235 | " Graceful Restart Capabilty:"); | |
10236 | if (CHECK_FLAG(p->cap, | |
10237 | PEER_CAP_RESTART_ADV)) | |
10238 | vty_out(vty, " advertised"); | |
10239 | if (CHECK_FLAG(p->cap, | |
10240 | PEER_CAP_RESTART_RCV)) | |
10241 | vty_out(vty, " %sreceived", | |
10242 | CHECK_FLAG( | |
10243 | p->cap, | |
10244 | PEER_CAP_RESTART_ADV) | |
10245 | ? "and " | |
10246 | : ""); | |
10247 | vty_out(vty, "\n"); | |
10248 | ||
10249 | if (CHECK_FLAG(p->cap, | |
10250 | PEER_CAP_RESTART_RCV)) { | |
10251 | int restart_af_count = 0; | |
10252 | ||
10253 | vty_out(vty, | |
10254 | " Remote Restart timer is %d seconds\n", | |
10255 | p->v_gr_restart); | |
10256 | vty_out(vty, | |
10257 | " Address families by peer:\n "); | |
10258 | ||
05c7a1cc QY |
10259 | FOREACH_AFI_SAFI (afi, safi) |
10260 | if (CHECK_FLAG( | |
10261 | p->af_cap | |
10262 | [afi] | |
10263 | [safi], | |
10264 | PEER_CAP_RESTART_AF_RCV)) { | |
10265 | vty_out(vty, | |
10266 | "%s%s(%s)", | |
10267 | restart_af_count | |
10268 | ? ", " | |
10269 | : "", | |
10270 | afi_safi_print( | |
10271 | afi, | |
10272 | safi), | |
10273 | CHECK_FLAG( | |
10274 | p->af_cap | |
10275 | [afi] | |
10276 | [safi], | |
10277 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
10278 | ? "preserved" | |
10279 | : "not preserved"); | |
10280 | restart_af_count++; | |
10281 | } | |
d62a17ae | 10282 | if (!restart_af_count) |
10283 | vty_out(vty, "none"); | |
10284 | vty_out(vty, "\n"); | |
10285 | } | |
10286 | } | |
10287 | } | |
10288 | } | |
10289 | } | |
10290 | ||
10291 | /* graceful restart information */ | |
10292 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) || p->t_gr_restart | |
10293 | || p->t_gr_stale) { | |
10294 | json_object *json_grace = NULL; | |
10295 | json_object *json_grace_send = NULL; | |
10296 | json_object *json_grace_recv = NULL; | |
10297 | int eor_send_af_count = 0; | |
10298 | int eor_receive_af_count = 0; | |
10299 | ||
10300 | if (use_json) { | |
10301 | json_grace = json_object_new_object(); | |
10302 | json_grace_send = json_object_new_object(); | |
10303 | json_grace_recv = json_object_new_object(); | |
10304 | ||
10305 | if (p->status == Established) { | |
05c7a1cc QY |
10306 | FOREACH_AFI_SAFI (afi, safi) { |
10307 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10308 | PEER_STATUS_EOR_SEND)) { | |
10309 | json_object_boolean_true_add( | |
10310 | json_grace_send, | |
10311 | afi_safi_print(afi, | |
10312 | safi)); | |
10313 | eor_send_af_count++; | |
d62a17ae | 10314 | } |
10315 | } | |
05c7a1cc QY |
10316 | FOREACH_AFI_SAFI (afi, safi) { |
10317 | if (CHECK_FLAG( | |
10318 | p->af_sflags[afi][safi], | |
10319 | PEER_STATUS_EOR_RECEIVED)) { | |
10320 | json_object_boolean_true_add( | |
10321 | json_grace_recv, | |
10322 | afi_safi_print(afi, | |
10323 | safi)); | |
10324 | eor_receive_af_count++; | |
d62a17ae | 10325 | } |
10326 | } | |
10327 | } | |
10328 | ||
10329 | json_object_object_add(json_grace, "endOfRibSend", | |
10330 | json_grace_send); | |
10331 | json_object_object_add(json_grace, "endOfRibRecv", | |
10332 | json_grace_recv); | |
10333 | ||
10334 | if (p->t_gr_restart) | |
10335 | json_object_int_add(json_grace, | |
10336 | "gracefulRestartTimerMsecs", | |
10337 | thread_timer_remain_second( | |
10338 | p->t_gr_restart) | |
10339 | * 1000); | |
10340 | ||
10341 | if (p->t_gr_stale) | |
10342 | json_object_int_add( | |
10343 | json_grace, | |
10344 | "gracefulStalepathTimerMsecs", | |
10345 | thread_timer_remain_second( | |
10346 | p->t_gr_stale) | |
10347 | * 1000); | |
10348 | ||
10349 | json_object_object_add( | |
10350 | json_neigh, "gracefulRestartInfo", json_grace); | |
10351 | } else { | |
0437e105 | 10352 | vty_out(vty, " Graceful restart information:\n"); |
d62a17ae | 10353 | if (p->status == Established) { |
10354 | vty_out(vty, " End-of-RIB send: "); | |
05c7a1cc QY |
10355 | FOREACH_AFI_SAFI (afi, safi) { |
10356 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10357 | PEER_STATUS_EOR_SEND)) { | |
10358 | vty_out(vty, "%s%s", | |
10359 | eor_send_af_count ? ", " | |
10360 | : "", | |
10361 | afi_safi_print(afi, | |
10362 | safi)); | |
10363 | eor_send_af_count++; | |
d62a17ae | 10364 | } |
10365 | } | |
10366 | vty_out(vty, "\n"); | |
10367 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
10368 | FOREACH_AFI_SAFI (afi, safi) { |
10369 | if (CHECK_FLAG( | |
10370 | p->af_sflags[afi][safi], | |
10371 | PEER_STATUS_EOR_RECEIVED)) { | |
10372 | vty_out(vty, "%s%s", | |
10373 | eor_receive_af_count | |
10374 | ? ", " | |
10375 | : "", | |
10376 | afi_safi_print(afi, | |
10377 | safi)); | |
10378 | eor_receive_af_count++; | |
d62a17ae | 10379 | } |
10380 | } | |
10381 | vty_out(vty, "\n"); | |
10382 | } | |
10383 | ||
10384 | if (p->t_gr_restart) | |
10385 | vty_out(vty, | |
10386 | " The remaining time of restart timer is %ld\n", | |
10387 | thread_timer_remain_second( | |
10388 | p->t_gr_restart)); | |
10389 | ||
10390 | if (p->t_gr_stale) | |
10391 | vty_out(vty, | |
10392 | " The remaining time of stalepath timer is %ld\n", | |
10393 | thread_timer_remain_second( | |
10394 | p->t_gr_stale)); | |
10395 | } | |
10396 | } | |
10397 | if (use_json) { | |
10398 | json_object *json_stat = NULL; | |
10399 | json_stat = json_object_new_object(); | |
10400 | /* Packet counts. */ | |
10401 | json_object_int_add(json_stat, "depthInq", 0); | |
10402 | json_object_int_add(json_stat, "depthOutq", | |
10403 | (unsigned long)p->obuf->count); | |
0112e9e0 QY |
10404 | json_object_int_add(json_stat, "opensSent", |
10405 | atomic_load_explicit(&p->open_out, | |
10406 | memory_order_relaxed)); | |
10407 | json_object_int_add(json_stat, "opensRecv", | |
10408 | atomic_load_explicit(&p->open_in, | |
10409 | memory_order_relaxed)); | |
d62a17ae | 10410 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
10411 | atomic_load_explicit(&p->notify_out, |
10412 | memory_order_relaxed)); | |
d62a17ae | 10413 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
10414 | atomic_load_explicit(&p->notify_in, |
10415 | memory_order_relaxed)); | |
10416 | json_object_int_add(json_stat, "updatesSent", | |
10417 | atomic_load_explicit(&p->update_out, | |
10418 | memory_order_relaxed)); | |
10419 | json_object_int_add(json_stat, "updatesRecv", | |
10420 | atomic_load_explicit(&p->update_in, | |
10421 | memory_order_relaxed)); | |
d62a17ae | 10422 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
10423 | atomic_load_explicit(&p->keepalive_out, |
10424 | memory_order_relaxed)); | |
d62a17ae | 10425 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
10426 | atomic_load_explicit(&p->keepalive_in, |
10427 | memory_order_relaxed)); | |
d62a17ae | 10428 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
10429 | atomic_load_explicit(&p->refresh_out, |
10430 | memory_order_relaxed)); | |
d62a17ae | 10431 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
10432 | atomic_load_explicit(&p->refresh_in, |
10433 | memory_order_relaxed)); | |
d62a17ae | 10434 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
10435 | atomic_load_explicit(&p->dynamic_cap_out, |
10436 | memory_order_relaxed)); | |
d62a17ae | 10437 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
10438 | atomic_load_explicit(&p->dynamic_cap_in, |
10439 | memory_order_relaxed)); | |
10440 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
10441 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 10442 | json_object_object_add(json_neigh, "messageStats", json_stat); |
10443 | } else { | |
10444 | /* Packet counts. */ | |
10445 | vty_out(vty, " Message statistics:\n"); | |
10446 | vty_out(vty, " Inq depth is 0\n"); | |
10447 | vty_out(vty, " Outq depth is %lu\n", | |
10448 | (unsigned long)p->obuf->count); | |
10449 | vty_out(vty, " Sent Rcvd\n"); | |
0112e9e0 QY |
10450 | vty_out(vty, " Opens: %10d %10d\n", |
10451 | atomic_load_explicit(&p->open_out, | |
10452 | memory_order_relaxed), | |
10453 | atomic_load_explicit(&p->open_in, | |
10454 | memory_order_relaxed)); | |
10455 | vty_out(vty, " Notifications: %10d %10d\n", | |
10456 | atomic_load_explicit(&p->notify_out, | |
10457 | memory_order_relaxed), | |
10458 | atomic_load_explicit(&p->notify_in, | |
10459 | memory_order_relaxed)); | |
10460 | vty_out(vty, " Updates: %10d %10d\n", | |
10461 | atomic_load_explicit(&p->update_out, | |
10462 | memory_order_relaxed), | |
10463 | atomic_load_explicit(&p->update_in, | |
10464 | memory_order_relaxed)); | |
10465 | vty_out(vty, " Keepalives: %10d %10d\n", | |
10466 | atomic_load_explicit(&p->keepalive_out, | |
10467 | memory_order_relaxed), | |
10468 | atomic_load_explicit(&p->keepalive_in, | |
10469 | memory_order_relaxed)); | |
10470 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
10471 | atomic_load_explicit(&p->refresh_out, | |
10472 | memory_order_relaxed), | |
10473 | atomic_load_explicit(&p->refresh_in, | |
10474 | memory_order_relaxed)); | |
d62a17ae | 10475 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
10476 | atomic_load_explicit(&p->dynamic_cap_out, |
10477 | memory_order_relaxed), | |
10478 | atomic_load_explicit(&p->dynamic_cap_in, | |
10479 | memory_order_relaxed)); | |
10480 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
10481 | PEER_TOTAL_RX(p)); | |
d62a17ae | 10482 | } |
10483 | ||
10484 | if (use_json) { | |
10485 | /* advertisement-interval */ | |
10486 | json_object_int_add(json_neigh, | |
10487 | "minBtwnAdvertisementRunsTimerMsecs", | |
10488 | p->v_routeadv * 1000); | |
10489 | ||
10490 | /* Update-source. */ | |
10491 | if (p->update_if || p->update_source) { | |
10492 | if (p->update_if) | |
10493 | json_object_string_add(json_neigh, | |
10494 | "updateSource", | |
10495 | p->update_if); | |
10496 | else if (p->update_source) | |
10497 | json_object_string_add( | |
10498 | json_neigh, "updateSource", | |
10499 | sockunion2str(p->update_source, buf1, | |
10500 | SU_ADDRSTRLEN)); | |
10501 | } | |
10502 | } else { | |
10503 | /* advertisement-interval */ | |
10504 | vty_out(vty, | |
10505 | " Minimum time between advertisement runs is %d seconds\n", | |
10506 | p->v_routeadv); | |
10507 | ||
10508 | /* Update-source. */ | |
10509 | if (p->update_if || p->update_source) { | |
10510 | vty_out(vty, " Update source is "); | |
10511 | if (p->update_if) | |
10512 | vty_out(vty, "%s", p->update_if); | |
10513 | else if (p->update_source) | |
10514 | vty_out(vty, "%s", | |
10515 | sockunion2str(p->update_source, buf1, | |
10516 | SU_ADDRSTRLEN)); | |
10517 | vty_out(vty, "\n"); | |
10518 | } | |
10519 | ||
10520 | vty_out(vty, "\n"); | |
10521 | } | |
10522 | ||
10523 | /* Address Family Information */ | |
10524 | json_object *json_hold = NULL; | |
10525 | ||
10526 | if (use_json) | |
10527 | json_hold = json_object_new_object(); | |
10528 | ||
05c7a1cc QY |
10529 | FOREACH_AFI_SAFI (afi, safi) |
10530 | if (p->afc[afi][safi]) | |
10531 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
10532 | json_hold); | |
d62a17ae | 10533 | |
10534 | if (use_json) { | |
10535 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
10536 | json_hold); | |
10537 | json_object_int_add(json_neigh, "connectionsEstablished", | |
10538 | p->established); | |
10539 | json_object_int_add(json_neigh, "connectionsDropped", | |
10540 | p->dropped); | |
10541 | } else | |
10542 | vty_out(vty, " Connections established %d; dropped %d\n", | |
10543 | p->established, p->dropped); | |
10544 | ||
10545 | if (!p->last_reset) { | |
10546 | if (use_json) | |
10547 | json_object_string_add(json_neigh, "lastReset", | |
10548 | "never"); | |
10549 | else | |
10550 | vty_out(vty, " Last reset never\n"); | |
10551 | } else { | |
10552 | if (use_json) { | |
10553 | time_t uptime; | |
10554 | struct tm *tm; | |
10555 | ||
10556 | uptime = bgp_clock(); | |
10557 | uptime -= p->resettime; | |
10558 | tm = gmtime(&uptime); | |
10559 | json_object_int_add(json_neigh, "lastResetTimerMsecs", | |
10560 | (tm->tm_sec * 1000) | |
10561 | + (tm->tm_min * 60000) | |
10562 | + (tm->tm_hour * 3600000)); | |
10563 | json_object_string_add( | |
10564 | json_neigh, "lastResetDueTo", | |
10565 | peer_down_str[(int)p->last_reset]); | |
10566 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND | |
10567 | || p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10568 | char errorcodesubcode_hexstr[5]; | |
10569 | char errorcodesubcode_str[256]; | |
10570 | ||
10571 | code_str = bgp_notify_code_str(p->notify.code); | |
10572 | subcode_str = bgp_notify_subcode_str( | |
10573 | p->notify.code, p->notify.subcode); | |
10574 | ||
10575 | sprintf(errorcodesubcode_hexstr, "%02X%02X", | |
10576 | p->notify.code, p->notify.subcode); | |
10577 | json_object_string_add(json_neigh, | |
10578 | "lastErrorCodeSubcode", | |
10579 | errorcodesubcode_hexstr); | |
10580 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
10581 | code_str, subcode_str); | |
10582 | json_object_string_add(json_neigh, | |
10583 | "lastNotificationReason", | |
10584 | errorcodesubcode_str); | |
10585 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
10586 | && p->notify.code == BGP_NOTIFY_CEASE | |
10587 | && (p->notify.subcode | |
10588 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
10589 | || p->notify.subcode | |
10590 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
10591 | && p->notify.length) { | |
10592 | char msgbuf[1024]; | |
10593 | const char *msg_str; | |
10594 | ||
10595 | msg_str = bgp_notify_admin_message( | |
10596 | msgbuf, sizeof(msgbuf), | |
d7c0a89a | 10597 | (uint8_t *)p->notify.data, |
d62a17ae | 10598 | p->notify.length); |
10599 | if (msg_str) | |
10600 | json_object_string_add( | |
10601 | json_neigh, | |
10602 | "lastShutdownDescription", | |
10603 | msg_str); | |
10604 | } | |
10605 | } | |
10606 | } else { | |
10607 | vty_out(vty, " Last reset %s, ", | |
10608 | peer_uptime(p->resettime, timebuf, | |
10609 | BGP_UPTIME_LEN, 0, NULL)); | |
10610 | ||
10611 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND | |
10612 | || p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10613 | code_str = bgp_notify_code_str(p->notify.code); | |
10614 | subcode_str = bgp_notify_subcode_str( | |
10615 | p->notify.code, p->notify.subcode); | |
10616 | vty_out(vty, "due to NOTIFICATION %s (%s%s)\n", | |
10617 | p->last_reset == PEER_DOWN_NOTIFY_SEND | |
10618 | ? "sent" | |
10619 | : "received", | |
10620 | code_str, subcode_str); | |
10621 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
10622 | && p->notify.code == BGP_NOTIFY_CEASE | |
10623 | && (p->notify.subcode | |
10624 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
10625 | || p->notify.subcode | |
10626 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
10627 | && p->notify.length) { | |
10628 | char msgbuf[1024]; | |
10629 | const char *msg_str; | |
10630 | ||
10631 | msg_str = bgp_notify_admin_message( | |
10632 | msgbuf, sizeof(msgbuf), | |
d7c0a89a | 10633 | (uint8_t *)p->notify.data, |
d62a17ae | 10634 | p->notify.length); |
10635 | if (msg_str) | |
10636 | vty_out(vty, | |
10637 | " Message: \"%s\"\n", | |
10638 | msg_str); | |
10639 | } | |
10640 | } else { | |
10641 | vty_out(vty, "due to %s\n", | |
10642 | peer_down_str[(int)p->last_reset]); | |
10643 | } | |
10644 | ||
10645 | if (p->last_reset_cause_size) { | |
10646 | msg = p->last_reset_cause; | |
10647 | vty_out(vty, | |
10648 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
10649 | for (i = 1; i <= p->last_reset_cause_size; | |
10650 | i++) { | |
10651 | vty_out(vty, "%02X", *msg++); | |
10652 | ||
10653 | if (i != p->last_reset_cause_size) { | |
10654 | if (i % 16 == 0) { | |
10655 | vty_out(vty, "\n "); | |
10656 | } else if (i % 4 == 0) { | |
10657 | vty_out(vty, " "); | |
10658 | } | |
10659 | } | |
10660 | } | |
10661 | vty_out(vty, "\n"); | |
10662 | } | |
10663 | } | |
10664 | } | |
10665 | ||
10666 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
10667 | if (use_json) | |
10668 | json_object_boolean_true_add(json_neigh, | |
10669 | "prefixesConfigExceedMax"); | |
10670 | else | |
10671 | vty_out(vty, | |
10672 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
10673 | ||
10674 | if (p->t_pmax_restart) { | |
10675 | if (use_json) { | |
10676 | json_object_boolean_true_add( | |
10677 | json_neigh, "reducePrefixNumFrom"); | |
10678 | json_object_int_add(json_neigh, | |
10679 | "restartInTimerMsec", | |
10680 | thread_timer_remain_second( | |
10681 | p->t_pmax_restart) | |
10682 | * 1000); | |
10683 | } else | |
10684 | vty_out(vty, | |
10685 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
10686 | p->host, thread_timer_remain_second( |
10687 | p->t_pmax_restart)); | |
d62a17ae | 10688 | } else { |
10689 | if (use_json) | |
10690 | json_object_boolean_true_add( | |
10691 | json_neigh, | |
10692 | "reducePrefixNumAndClearIpBgp"); | |
10693 | else | |
10694 | vty_out(vty, | |
10695 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
10696 | p->host); | |
10697 | } | |
10698 | } | |
10699 | ||
10700 | /* EBGP Multihop and GTSM */ | |
10701 | if (p->sort != BGP_PEER_IBGP) { | |
10702 | if (use_json) { | |
10703 | if (p->gtsm_hops > 0) | |
10704 | json_object_int_add(json_neigh, | |
10705 | "externalBgpNbrMaxHopsAway", | |
10706 | p->gtsm_hops); | |
10707 | else if (p->ttl > 1) | |
10708 | json_object_int_add(json_neigh, | |
10709 | "externalBgpNbrMaxHopsAway", | |
10710 | p->ttl); | |
10711 | } else { | |
10712 | if (p->gtsm_hops > 0) | |
10713 | vty_out(vty, | |
10714 | " External BGP neighbor may be up to %d hops away.\n", | |
10715 | p->gtsm_hops); | |
10716 | else if (p->ttl > 1) | |
10717 | vty_out(vty, | |
10718 | " External BGP neighbor may be up to %d hops away.\n", | |
10719 | p->ttl); | |
10720 | } | |
10721 | } else { | |
10722 | if (p->gtsm_hops > 0) { | |
10723 | if (use_json) | |
10724 | json_object_int_add(json_neigh, | |
10725 | "internalBgpNbrMaxHopsAway", | |
10726 | p->gtsm_hops); | |
10727 | else | |
10728 | vty_out(vty, | |
10729 | " Internal BGP neighbor may be up to %d hops away.\n", | |
10730 | p->gtsm_hops); | |
10731 | } | |
10732 | } | |
10733 | ||
10734 | /* Local address. */ | |
10735 | if (p->su_local) { | |
10736 | if (use_json) { | |
10737 | json_object_string_add(json_neigh, "hostLocal", | |
10738 | sockunion2str(p->su_local, buf1, | |
10739 | SU_ADDRSTRLEN)); | |
10740 | json_object_int_add(json_neigh, "portLocal", | |
10741 | ntohs(p->su_local->sin.sin_port)); | |
10742 | } else | |
10743 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
10744 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
10745 | ntohs(p->su_local->sin.sin_port)); | |
10746 | } | |
10747 | ||
10748 | /* Remote address. */ | |
10749 | if (p->su_remote) { | |
10750 | if (use_json) { | |
10751 | json_object_string_add(json_neigh, "hostForeign", | |
10752 | sockunion2str(p->su_remote, buf1, | |
10753 | SU_ADDRSTRLEN)); | |
10754 | json_object_int_add(json_neigh, "portForeign", | |
10755 | ntohs(p->su_remote->sin.sin_port)); | |
10756 | } else | |
10757 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
10758 | sockunion2str(p->su_remote, buf1, | |
10759 | SU_ADDRSTRLEN), | |
10760 | ntohs(p->su_remote->sin.sin_port)); | |
10761 | } | |
10762 | ||
10763 | /* Nexthop display. */ | |
10764 | if (p->su_local) { | |
10765 | if (use_json) { | |
10766 | json_object_string_add(json_neigh, "nexthop", | |
10767 | inet_ntop(AF_INET, | |
10768 | &p->nexthop.v4, buf1, | |
10769 | sizeof(buf1))); | |
10770 | json_object_string_add(json_neigh, "nexthopGlobal", | |
10771 | inet_ntop(AF_INET6, | |
10772 | &p->nexthop.v6_global, | |
10773 | buf1, sizeof(buf1))); | |
10774 | json_object_string_add(json_neigh, "nexthopLocal", | |
10775 | inet_ntop(AF_INET6, | |
10776 | &p->nexthop.v6_local, | |
10777 | buf1, sizeof(buf1))); | |
10778 | if (p->shared_network) | |
10779 | json_object_string_add(json_neigh, | |
10780 | "bgpConnection", | |
10781 | "sharedNetwork"); | |
10782 | else | |
10783 | json_object_string_add(json_neigh, | |
10784 | "bgpConnection", | |
10785 | "nonSharedNetwork"); | |
10786 | } else { | |
10787 | vty_out(vty, "Nexthop: %s\n", | |
10788 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
10789 | sizeof(buf1))); | |
10790 | vty_out(vty, "Nexthop global: %s\n", | |
10791 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
10792 | sizeof(buf1))); | |
10793 | vty_out(vty, "Nexthop local: %s\n", | |
10794 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
10795 | sizeof(buf1))); | |
10796 | vty_out(vty, "BGP connection: %s\n", | |
10797 | p->shared_network ? "shared network" | |
10798 | : "non shared network"); | |
10799 | } | |
10800 | } | |
10801 | ||
10802 | /* Timer information. */ | |
10803 | if (use_json) { | |
10804 | json_object_int_add(json_neigh, "connectRetryTimer", | |
10805 | p->v_connect); | |
10806 | if (p->status == Established && p->rtt) | |
10807 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
10808 | p->rtt); | |
10809 | if (p->t_start) | |
10810 | json_object_int_add( | |
10811 | json_neigh, "nextStartTimerDueInMsecs", | |
10812 | thread_timer_remain_second(p->t_start) * 1000); | |
10813 | if (p->t_connect) | |
10814 | json_object_int_add( | |
10815 | json_neigh, "nextConnectTimerDueInMsecs", | |
10816 | thread_timer_remain_second(p->t_connect) | |
10817 | * 1000); | |
10818 | if (p->t_routeadv) { | |
10819 | json_object_int_add(json_neigh, "mraiInterval", | |
10820 | p->v_routeadv); | |
10821 | json_object_int_add( | |
10822 | json_neigh, "mraiTimerExpireInMsecs", | |
10823 | thread_timer_remain_second(p->t_routeadv) | |
10824 | * 1000); | |
10825 | } | |
10826 | if (p->password) | |
10827 | json_object_int_add(json_neigh, "authenticationEnabled", | |
10828 | 1); | |
10829 | ||
10830 | if (p->t_read) | |
10831 | json_object_string_add(json_neigh, "readThread", "on"); | |
10832 | else | |
10833 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
10834 | |
10835 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 10836 | json_object_string_add(json_neigh, "writeThread", "on"); |
10837 | else | |
10838 | json_object_string_add(json_neigh, "writeThread", | |
10839 | "off"); | |
10840 | } else { | |
10841 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
10842 | p->v_connect); | |
10843 | if (p->status == Established && p->rtt) | |
10844 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
10845 | p->rtt); | |
10846 | if (p->t_start) | |
10847 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
10848 | thread_timer_remain_second(p->t_start)); | |
10849 | if (p->t_connect) | |
10850 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
10851 | thread_timer_remain_second(p->t_connect)); | |
10852 | if (p->t_routeadv) | |
10853 | vty_out(vty, | |
10854 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
10855 | p->v_routeadv, | |
10856 | thread_timer_remain_second(p->t_routeadv)); | |
10857 | if (p->password) | |
10858 | vty_out(vty, "Peer Authentication Enabled\n"); | |
10859 | ||
10860 | vty_out(vty, "Read thread: %s Write thread: %s\n", | |
49507a6f QY |
10861 | p->t_read ? "on" : "off", |
10862 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
10863 | ? "on" | |
10864 | : "off"); | |
d62a17ae | 10865 | } |
10866 | ||
10867 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
10868 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
10869 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
10870 | ||
10871 | if (!use_json) | |
10872 | vty_out(vty, "\n"); | |
10873 | ||
10874 | /* BFD information. */ | |
10875 | bgp_bfd_show_info(vty, p, use_json, json_neigh); | |
10876 | ||
10877 | if (use_json) { | |
10878 | if (p->conf_if) /* Configured interface name. */ | |
10879 | json_object_object_add(json, p->conf_if, json_neigh); | |
10880 | else /* Configured IP address. */ | |
10881 | json_object_object_add(json, p->host, json_neigh); | |
10882 | } | |
10883 | } | |
10884 | ||
10885 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, | |
10886 | enum show_type type, union sockunion *su, | |
9f049418 | 10887 | const char *conf_if, bool use_json, |
d62a17ae | 10888 | json_object *json) |
10889 | { | |
10890 | struct listnode *node, *nnode; | |
10891 | struct peer *peer; | |
10892 | int find = 0; | |
9f049418 | 10893 | bool nbr_output = false; |
d62a17ae | 10894 | |
10895 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
10896 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
10897 | continue; | |
10898 | ||
10899 | switch (type) { | |
10900 | case show_all: | |
10901 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 10902 | nbr_output = true; |
d62a17ae | 10903 | break; |
10904 | case show_peer: | |
10905 | if (conf_if) { | |
10906 | if ((peer->conf_if | |
10907 | && !strcmp(peer->conf_if, conf_if)) | |
10908 | || (peer->hostname | |
10909 | && !strcmp(peer->hostname, conf_if))) { | |
10910 | find = 1; | |
10911 | bgp_show_peer(vty, peer, use_json, | |
10912 | json); | |
10913 | } | |
10914 | } else { | |
10915 | if (sockunion_same(&peer->su, su)) { | |
10916 | find = 1; | |
10917 | bgp_show_peer(vty, peer, use_json, | |
10918 | json); | |
10919 | } | |
10920 | } | |
10921 | break; | |
10922 | } | |
10923 | } | |
10924 | ||
10925 | if (type == show_peer && !find) { | |
10926 | if (use_json) | |
10927 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
10928 | else | |
88b7d255 | 10929 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 10930 | } |
10931 | ||
9f049418 | 10932 | if (type != show_peer && !nbr_output && !use_json) |
94d4c685 | 10933 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 10934 | |
d62a17ae | 10935 | if (use_json) { |
996c9314 LB |
10936 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
10937 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 10938 | } else { |
10939 | vty_out(vty, "\n"); | |
10940 | } | |
10941 | ||
10942 | return CMD_SUCCESS; | |
10943 | } | |
10944 | ||
10945 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, | |
71aedaa3 DS |
10946 | enum show_type type, |
10947 | const char *ip_str, | |
9f049418 | 10948 | bool use_json) |
d62a17ae | 10949 | { |
0291c246 MK |
10950 | struct listnode *node, *nnode; |
10951 | struct bgp *bgp; | |
71aedaa3 | 10952 | union sockunion su; |
0291c246 | 10953 | json_object *json = NULL; |
71aedaa3 | 10954 | int ret, is_first = 1; |
9f049418 | 10955 | bool nbr_output = false; |
d62a17ae | 10956 | |
10957 | if (use_json) | |
10958 | vty_out(vty, "{\n"); | |
10959 | ||
10960 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 10961 | nbr_output = true; |
d62a17ae | 10962 | if (use_json) { |
10963 | if (!(json = json_object_new_object())) { | |
af4c2728 | 10964 | flog_err( |
e50f7cfd | 10965 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 10966 | "Unable to allocate memory for JSON object"); |
10967 | vty_out(vty, | |
10968 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
10969 | return; | |
10970 | } | |
10971 | ||
10972 | json_object_int_add(json, "vrfId", | |
10973 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
10974 | ? -1 |
10975 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 10976 | json_object_string_add( |
10977 | json, "vrfName", | |
10978 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 10979 | ? VRF_DEFAULT_NAME |
d62a17ae | 10980 | : bgp->name); |
10981 | ||
10982 | if (!is_first) | |
10983 | vty_out(vty, ",\n"); | |
10984 | else | |
10985 | is_first = 0; | |
10986 | ||
10987 | vty_out(vty, "\"%s\":", | |
10988 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 10989 | ? VRF_DEFAULT_NAME |
d62a17ae | 10990 | : bgp->name); |
10991 | } else { | |
10992 | vty_out(vty, "\nInstance %s:\n", | |
10993 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 10994 | ? VRF_DEFAULT_NAME |
d62a17ae | 10995 | : bgp->name); |
10996 | } | |
71aedaa3 DS |
10997 | |
10998 | if (type == show_peer) { | |
10999 | ret = str2sockunion(ip_str, &su); | |
11000 | if (ret < 0) | |
11001 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
11002 | use_json, json); | |
11003 | else | |
11004 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
11005 | use_json, json); | |
11006 | } else { | |
11007 | bgp_show_neighbor(vty, bgp, show_all, NULL, NULL, | |
11008 | use_json, json); | |
11009 | } | |
d62a17ae | 11010 | } |
11011 | ||
01cbfd04 | 11012 | if (use_json) { |
d62a17ae | 11013 | vty_out(vty, "}\n"); |
01cbfd04 QY |
11014 | json_object_free(json); |
11015 | } | |
9f049418 DS |
11016 | else if (!nbr_output) |
11017 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 11018 | } |
11019 | ||
11020 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
11021 | enum show_type type, const char *ip_str, | |
9f049418 | 11022 | bool use_json) |
d62a17ae | 11023 | { |
11024 | int ret; | |
11025 | struct bgp *bgp; | |
11026 | union sockunion su; | |
11027 | json_object *json = NULL; | |
11028 | ||
11029 | if (name) { | |
11030 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
11031 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
11032 | use_json); | |
d62a17ae | 11033 | return CMD_SUCCESS; |
11034 | } else { | |
11035 | bgp = bgp_lookup_by_name(name); | |
11036 | if (!bgp) { | |
11037 | if (use_json) { | |
11038 | json = json_object_new_object(); | |
d62a17ae | 11039 | vty_out(vty, "%s\n", |
11040 | json_object_to_json_string_ext( | |
11041 | json, | |
11042 | JSON_C_TO_STRING_PRETTY)); | |
11043 | json_object_free(json); | |
11044 | } else | |
11045 | vty_out(vty, | |
9f049418 | 11046 | "%% BGP instance not found\n"); |
d62a17ae | 11047 | |
11048 | return CMD_WARNING; | |
11049 | } | |
11050 | } | |
11051 | } else { | |
11052 | bgp = bgp_get_default(); | |
11053 | } | |
11054 | ||
11055 | if (bgp) { | |
11056 | json = json_object_new_object(); | |
11057 | if (ip_str) { | |
11058 | ret = str2sockunion(ip_str, &su); | |
11059 | if (ret < 0) | |
11060 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
11061 | use_json, json); | |
11062 | else | |
11063 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
11064 | use_json, json); | |
11065 | } else { | |
11066 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
11067 | json); | |
11068 | } | |
11069 | json_object_free(json); | |
ca61fd25 DS |
11070 | } else { |
11071 | if (use_json) | |
11072 | vty_out(vty, "{}\n"); | |
11073 | else | |
11074 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 11075 | } |
11076 | ||
11077 | return CMD_SUCCESS; | |
4fb25c53 DW |
11078 | } |
11079 | ||
716b2d8a | 11080 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 11081 | DEFUN (show_ip_bgp_neighbors, |
11082 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 11083 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 11084 | SHOW_STR |
11085 | IP_STR | |
11086 | BGP_STR | |
f2a8972b | 11087 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
11088 | "Address Family\n" |
11089 | "Address Family\n" | |
718e3744 | 11090 | "Detailed information on TCP and BGP neighbor connections\n" |
11091 | "Neighbor to display information about\n" | |
a80beece | 11092 | "Neighbor to display information about\n" |
91d37724 | 11093 | "Neighbor on BGP configured interface\n" |
9973d184 | 11094 | JSON_STR) |
718e3744 | 11095 | { |
d62a17ae | 11096 | char *vrf = NULL; |
11097 | char *sh_arg = NULL; | |
11098 | enum show_type sh_type; | |
718e3744 | 11099 | |
9f049418 | 11100 | bool uj = use_json(argc, argv); |
718e3744 | 11101 | |
d62a17ae | 11102 | int idx = 0; |
718e3744 | 11103 | |
9a8bdf1c PG |
11104 | /* [<vrf> VIEWVRFNAME] */ |
11105 | if (argv_find(argv, argc, "vrf", &idx)) { | |
11106 | vrf = argv[idx + 1]->arg; | |
11107 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11108 | vrf = NULL; | |
11109 | } else if (argv_find(argv, argc, "view", &idx)) | |
11110 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 11111 | vrf = argv[idx + 1]->arg; |
718e3744 | 11112 | |
d62a17ae | 11113 | idx++; |
11114 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
11115 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
11116 | || argv_find(argv, argc, "WORD", &idx)) { | |
11117 | sh_type = show_peer; | |
11118 | sh_arg = argv[idx]->arg; | |
11119 | } else | |
11120 | sh_type = show_all; | |
856ca177 | 11121 | |
d62a17ae | 11122 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 11123 | } |
11124 | ||
716b2d8a | 11125 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 11126 | paths' and `show ip mbgp paths'. Those functions results are the |
11127 | same.*/ | |
f412b39a | 11128 | DEFUN (show_ip_bgp_paths, |
718e3744 | 11129 | show_ip_bgp_paths_cmd, |
46f296b4 | 11130 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 11131 | SHOW_STR |
11132 | IP_STR | |
11133 | BGP_STR | |
46f296b4 | 11134 | BGP_SAFI_HELP_STR |
718e3744 | 11135 | "Path information\n") |
11136 | { | |
d62a17ae | 11137 | vty_out(vty, "Address Refcnt Path\n"); |
11138 | aspath_print_all_vty(vty); | |
11139 | return CMD_SUCCESS; | |
718e3744 | 11140 | } |
11141 | ||
718e3744 | 11142 | #include "hash.h" |
11143 | ||
d62a17ae | 11144 | static void community_show_all_iterator(struct hash_backet *backet, |
11145 | struct vty *vty) | |
718e3744 | 11146 | { |
d62a17ae | 11147 | struct community *com; |
718e3744 | 11148 | |
d62a17ae | 11149 | com = (struct community *)backet->data; |
3f65c5b1 | 11150 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 11151 | community_str(com, false)); |
718e3744 | 11152 | } |
11153 | ||
11154 | /* Show BGP's community internal data. */ | |
f412b39a | 11155 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 11156 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 11157 | "show [ip] bgp community-info", |
718e3744 | 11158 | SHOW_STR |
11159 | IP_STR | |
11160 | BGP_STR | |
11161 | "List all bgp community information\n") | |
11162 | { | |
d62a17ae | 11163 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 11164 | |
d62a17ae | 11165 | hash_iterate(community_hash(), |
11166 | (void (*)(struct hash_backet *, | |
11167 | void *))community_show_all_iterator, | |
11168 | vty); | |
718e3744 | 11169 | |
d62a17ae | 11170 | return CMD_SUCCESS; |
718e3744 | 11171 | } |
11172 | ||
d62a17ae | 11173 | static void lcommunity_show_all_iterator(struct hash_backet *backet, |
11174 | struct vty *vty) | |
57d187bc | 11175 | { |
d62a17ae | 11176 | struct lcommunity *lcom; |
57d187bc | 11177 | |
d62a17ae | 11178 | lcom = (struct lcommunity *)backet->data; |
3f65c5b1 | 11179 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
8d9b8ed9 | 11180 | lcommunity_str(lcom, false)); |
57d187bc JS |
11181 | } |
11182 | ||
11183 | /* Show BGP's community internal data. */ | |
11184 | DEFUN (show_ip_bgp_lcommunity_info, | |
11185 | show_ip_bgp_lcommunity_info_cmd, | |
11186 | "show ip bgp large-community-info", | |
11187 | SHOW_STR | |
11188 | IP_STR | |
11189 | BGP_STR | |
11190 | "List all bgp large-community information\n") | |
11191 | { | |
d62a17ae | 11192 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 11193 | |
d62a17ae | 11194 | hash_iterate(lcommunity_hash(), |
11195 | (void (*)(struct hash_backet *, | |
11196 | void *))lcommunity_show_all_iterator, | |
11197 | vty); | |
57d187bc | 11198 | |
d62a17ae | 11199 | return CMD_SUCCESS; |
57d187bc JS |
11200 | } |
11201 | ||
11202 | ||
f412b39a | 11203 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 11204 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 11205 | "show [ip] bgp attribute-info", |
718e3744 | 11206 | SHOW_STR |
11207 | IP_STR | |
11208 | BGP_STR | |
11209 | "List all bgp attribute information\n") | |
11210 | { | |
d62a17ae | 11211 | attr_show_all(vty); |
11212 | return CMD_SUCCESS; | |
718e3744 | 11213 | } |
6b0655a2 | 11214 | |
9f049418 DS |
11215 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, afi_t afi, |
11216 | safi_t safi, bool use_json) | |
53089bec | 11217 | { |
11218 | struct bgp *bgp; | |
11219 | struct listnode *node; | |
11220 | char *vname; | |
11221 | char buf1[INET6_ADDRSTRLEN]; | |
11222 | char *ecom_str; | |
11223 | vpn_policy_direction_t dir; | |
11224 | ||
b46dfd20 DS |
11225 | if (use_json) { |
11226 | json_object *json = NULL; | |
11227 | json_object *json_import_vrfs = NULL; | |
11228 | json_object *json_export_vrfs = NULL; | |
11229 | ||
11230 | json = json_object_new_object(); | |
b46dfd20 | 11231 | |
b46dfd20 DS |
11232 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
11233 | ||
53089bec | 11234 | if (!bgp) { |
b46dfd20 DS |
11235 | vty_out(vty, "%s\n", |
11236 | json_object_to_json_string_ext( | |
11237 | json, | |
11238 | JSON_C_TO_STRING_PRETTY)); | |
11239 | json_object_free(json); | |
11240 | ||
53089bec | 11241 | return CMD_WARNING; |
11242 | } | |
b46dfd20 | 11243 | |
94d4c685 DS |
11244 | /* Provide context for the block */ |
11245 | json_object_string_add(json, "vrf", name ? name : "default"); | |
11246 | json_object_string_add(json, "afiSafi", | |
11247 | afi_safi_print(afi, safi)); | |
11248 | ||
b46dfd20 DS |
11249 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
11250 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
11251 | json_object_string_add(json, "importFromVrfs", "none"); | |
11252 | json_object_string_add(json, "importRts", "none"); | |
11253 | } else { | |
6ce24e52 DS |
11254 | json_import_vrfs = json_object_new_array(); |
11255 | ||
b46dfd20 DS |
11256 | for (ALL_LIST_ELEMENTS_RO( |
11257 | bgp->vpn_policy[afi].import_vrf, | |
11258 | node, vname)) | |
11259 | json_object_array_add(json_import_vrfs, | |
11260 | json_object_new_string(vname)); | |
11261 | ||
11262 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
11263 | ecom_str = ecommunity_ecom2str( | |
11264 | bgp->vpn_policy[afi].rtlist[dir], | |
11265 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
11266 | json_object_object_add(json, "importFromVrfs", | |
11267 | json_import_vrfs); | |
11268 | json_object_string_add(json, "importRts", ecom_str); | |
11269 | ||
11270 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
11271 | } | |
11272 | ||
11273 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
11274 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
11275 | json_object_string_add(json, "exportToVrfs", "none"); | |
11276 | json_object_string_add(json, "routeDistinguisher", | |
11277 | "none"); | |
11278 | json_object_string_add(json, "exportRts", "none"); | |
11279 | } else { | |
6ce24e52 DS |
11280 | json_export_vrfs = json_object_new_array(); |
11281 | ||
b46dfd20 DS |
11282 | for (ALL_LIST_ELEMENTS_RO( |
11283 | bgp->vpn_policy[afi].export_vrf, | |
11284 | node, vname)) | |
11285 | json_object_array_add(json_export_vrfs, | |
11286 | json_object_new_string(vname)); | |
11287 | json_object_object_add(json, "exportToVrfs", | |
11288 | json_export_vrfs); | |
11289 | json_object_string_add(json, "routeDistinguisher", | |
11290 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
11291 | buf1, RD_ADDRSTRLEN)); | |
11292 | ||
11293 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
11294 | ecom_str = ecommunity_ecom2str( | |
11295 | bgp->vpn_policy[afi].rtlist[dir], | |
11296 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
11297 | json_object_string_add(json, "exportRts", ecom_str); | |
11298 | ||
11299 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
11300 | } | |
11301 | ||
11302 | vty_out(vty, "%s\n", | |
11303 | json_object_to_json_string_ext(json, | |
11304 | JSON_C_TO_STRING_PRETTY)); | |
11305 | json_object_free(json); | |
11306 | ||
53089bec | 11307 | } else { |
b46dfd20 DS |
11308 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
11309 | ||
53089bec | 11310 | if (!bgp) { |
b46dfd20 | 11311 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 11312 | return CMD_WARNING; |
11313 | } | |
53089bec | 11314 | |
b46dfd20 DS |
11315 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
11316 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
11317 | vty_out(vty, | |
11318 | "This VRF is not importing %s routes from any other VRF\n", | |
11319 | afi_safi_print(afi, safi)); | |
11320 | else { | |
11321 | vty_out(vty, | |
11322 | "This VRF is importing %s routes from the following VRFs:\n", | |
11323 | afi_safi_print(afi, safi)); | |
11324 | ||
11325 | for (ALL_LIST_ELEMENTS_RO( | |
11326 | bgp->vpn_policy[afi].import_vrf, | |
11327 | node, vname)) | |
11328 | vty_out(vty, " %s\n", vname); | |
11329 | ||
11330 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
11331 | ecom_str = ecommunity_ecom2str( | |
11332 | bgp->vpn_policy[afi].rtlist[dir], | |
11333 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
11334 | vty_out(vty, "Import RT(s): %s\n", ecom_str); | |
11335 | ||
11336 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
53089bec | 11337 | } |
53089bec | 11338 | |
b46dfd20 DS |
11339 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
11340 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
11341 | vty_out(vty, | |
11342 | "This VRF is not exporting %s routes to any other VRF\n", | |
53089bec | 11343 | afi_safi_print(afi, safi)); |
b46dfd20 DS |
11344 | else { |
11345 | vty_out(vty, | |
04c9077f | 11346 | "This VRF is exporting %s routes to the following VRFs:\n", |
53089bec | 11347 | afi_safi_print(afi, safi)); |
b46dfd20 DS |
11348 | |
11349 | for (ALL_LIST_ELEMENTS_RO( | |
11350 | bgp->vpn_policy[afi].export_vrf, | |
11351 | node, vname)) | |
11352 | vty_out(vty, " %s\n", vname); | |
11353 | ||
11354 | vty_out(vty, "RD: %s\n", | |
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 | vty_out(vty, "Export RT: %s\n", ecom_str); | |
04c9077f | 11363 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
53089bec | 11364 | } |
53089bec | 11365 | } |
11366 | ||
11367 | return CMD_SUCCESS; | |
11368 | } | |
11369 | ||
11370 | /* "show [ip] bgp route-leak" command. */ | |
11371 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
11372 | show_ip_bgp_route_leak_cmd, |
11373 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
11374 | SHOW_STR |
11375 | IP_STR | |
11376 | BGP_STR | |
11377 | BGP_INSTANCE_HELP_STR | |
11378 | BGP_AFI_HELP_STR | |
11379 | BGP_SAFI_HELP_STR | |
11380 | "Route leaking information\n" | |
11381 | JSON_STR) | |
53089bec | 11382 | { |
11383 | char *vrf = NULL; | |
11384 | afi_t afi = AFI_MAX; | |
11385 | safi_t safi = SAFI_MAX; | |
11386 | ||
9f049418 | 11387 | bool uj = use_json(argc, argv); |
53089bec | 11388 | int idx = 0; |
11389 | ||
11390 | /* show [ip] bgp */ | |
11391 | if (argv_find(argv, argc, "ip", &idx)) { | |
11392 | afi = AFI_IP; | |
11393 | safi = SAFI_UNICAST; | |
11394 | } | |
11395 | /* [vrf VIEWVRFNAME] */ | |
11396 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
11397 | vty_out(vty, |
11398 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 11399 | return CMD_WARNING; |
11400 | } | |
11401 | ||
9a8bdf1c PG |
11402 | if (argv_find(argv, argc, "vrf", &idx)) { |
11403 | vrf = argv[idx + 1]->arg; | |
11404 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11405 | vrf = NULL; | |
11406 | } | |
53089bec | 11407 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
11408 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11409 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11410 | } | |
11411 | ||
11412 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
11413 | vty_out(vty, |
11414 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 11415 | return CMD_WARNING; |
11416 | } | |
11417 | ||
b46dfd20 | 11418 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj); |
53089bec | 11419 | } |
11420 | ||
d62a17ae | 11421 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
11422 | safi_t safi) | |
f186de26 | 11423 | { |
d62a17ae | 11424 | struct listnode *node, *nnode; |
11425 | struct bgp *bgp; | |
f186de26 | 11426 | |
d62a17ae | 11427 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
11428 | vty_out(vty, "\nInstance %s:\n", | |
11429 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11430 | ? VRF_DEFAULT_NAME |
d62a17ae | 11431 | : bgp->name); |
11432 | update_group_show(bgp, afi, safi, vty, 0); | |
11433 | } | |
f186de26 | 11434 | } |
11435 | ||
d62a17ae | 11436 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
11437 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 11438 | { |
d62a17ae | 11439 | struct bgp *bgp; |
4fb25c53 | 11440 | |
d62a17ae | 11441 | if (name) { |
11442 | if (strmatch(name, "all")) { | |
11443 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
11444 | return CMD_SUCCESS; | |
11445 | } else { | |
11446 | bgp = bgp_lookup_by_name(name); | |
11447 | } | |
11448 | } else { | |
11449 | bgp = bgp_get_default(); | |
11450 | } | |
4fb25c53 | 11451 | |
d62a17ae | 11452 | if (bgp) |
11453 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
11454 | return CMD_SUCCESS; | |
4fb25c53 DW |
11455 | } |
11456 | ||
8fe8a7f6 DS |
11457 | DEFUN (show_ip_bgp_updgrps, |
11458 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 11459 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 11460 | SHOW_STR |
11461 | IP_STR | |
11462 | BGP_STR | |
11463 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 11464 | BGP_AFI_HELP_STR |
9bedbb1e | 11465 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
11466 | "Detailed info about dynamic update groups\n" |
11467 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 11468 | { |
d62a17ae | 11469 | char *vrf = NULL; |
11470 | afi_t afi = AFI_IP6; | |
11471 | safi_t safi = SAFI_UNICAST; | |
11472 | uint64_t subgrp_id = 0; | |
11473 | ||
11474 | int idx = 0; | |
11475 | ||
11476 | /* show [ip] bgp */ | |
11477 | if (argv_find(argv, argc, "ip", &idx)) | |
11478 | afi = AFI_IP; | |
9a8bdf1c PG |
11479 | /* [<vrf> VIEWVRFNAME] */ |
11480 | if (argv_find(argv, argc, "vrf", &idx)) { | |
11481 | vrf = argv[idx + 1]->arg; | |
11482 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11483 | vrf = NULL; | |
11484 | } else if (argv_find(argv, argc, "view", &idx)) | |
11485 | /* [<view> VIEWVRFNAME] */ | |
11486 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 11487 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
11488 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11489 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11490 | } | |
5bf15956 | 11491 | |
d62a17ae | 11492 | /* get subgroup id, if provided */ |
11493 | idx = argc - 1; | |
11494 | if (argv[idx]->type == VARIABLE_TKN) | |
11495 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 11496 | |
d62a17ae | 11497 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
11498 | } |
11499 | ||
f186de26 | 11500 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
11501 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 11502 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 11503 | SHOW_STR |
716b2d8a | 11504 | IP_STR |
f186de26 | 11505 | BGP_STR |
11506 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 11507 | "Detailed info about dynamic update groups\n") |
f186de26 | 11508 | { |
d62a17ae | 11509 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
11510 | return CMD_SUCCESS; | |
f186de26 | 11511 | } |
11512 | ||
43d3f4fc DS |
11513 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
11514 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
11515 | "show [ip] bgp l2vpn evpn update-groups", | |
11516 | SHOW_STR | |
11517 | IP_STR | |
11518 | BGP_STR | |
11519 | "l2vpn address family\n" | |
11520 | "evpn sub-address family\n" | |
11521 | "Detailed info about dynamic update groups\n") | |
11522 | { | |
11523 | char *vrf = NULL; | |
11524 | uint64_t subgrp_id = 0; | |
11525 | ||
11526 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id); | |
11527 | return CMD_SUCCESS; | |
11528 | } | |
11529 | ||
5bf15956 DW |
11530 | DEFUN (show_bgp_updgrps_stats, |
11531 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 11532 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 11533 | SHOW_STR |
716b2d8a | 11534 | IP_STR |
3f9c7369 | 11535 | BGP_STR |
0c7b1b01 | 11536 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
11537 | "Statistics\n") |
11538 | { | |
d62a17ae | 11539 | struct bgp *bgp; |
3f9c7369 | 11540 | |
d62a17ae | 11541 | bgp = bgp_get_default(); |
11542 | if (bgp) | |
11543 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 11544 | |
d62a17ae | 11545 | return CMD_SUCCESS; |
3f9c7369 DS |
11546 | } |
11547 | ||
8386ac43 | 11548 | DEFUN (show_bgp_instance_updgrps_stats, |
11549 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 11550 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 11551 | SHOW_STR |
716b2d8a | 11552 | IP_STR |
8386ac43 | 11553 | BGP_STR |
11554 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 11555 | "Detailed info about dynamic update groups\n" |
8386ac43 | 11556 | "Statistics\n") |
11557 | { | |
d62a17ae | 11558 | int idx_word = 3; |
11559 | struct bgp *bgp; | |
8386ac43 | 11560 | |
d62a17ae | 11561 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
11562 | if (bgp) | |
11563 | update_group_show_stats(bgp, vty); | |
8386ac43 | 11564 | |
d62a17ae | 11565 | return CMD_SUCCESS; |
8386ac43 | 11566 | } |
11567 | ||
d62a17ae | 11568 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
11569 | afi_t afi, safi_t safi, | |
11570 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 11571 | { |
d62a17ae | 11572 | struct bgp *bgp; |
8386ac43 | 11573 | |
d62a17ae | 11574 | if (name) |
11575 | bgp = bgp_lookup_by_name(name); | |
11576 | else | |
11577 | bgp = bgp_get_default(); | |
8386ac43 | 11578 | |
d62a17ae | 11579 | if (bgp) { |
11580 | if (!strcmp(what, "advertise-queue")) | |
11581 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
11582 | subgrp_id); | |
11583 | else if (!strcmp(what, "advertised-routes")) | |
11584 | update_group_show_advertised(bgp, afi, safi, vty, | |
11585 | subgrp_id); | |
11586 | else if (!strcmp(what, "packet-queue")) | |
11587 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
11588 | subgrp_id); | |
11589 | } | |
3f9c7369 DS |
11590 | } |
11591 | ||
dc64bdec QY |
11592 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
11593 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
11594 | "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", | |
11595 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
11596 | BGP_SAFI_HELP_STR | |
11597 | "Detailed info about dynamic update groups\n" | |
11598 | "Specific subgroup to display info for\n" | |
11599 | "Advertisement queue\n" | |
11600 | "Announced routes\n" | |
11601 | "Packet queue\n") | |
3f9c7369 | 11602 | { |
dc64bdec QY |
11603 | uint64_t subgrp_id = 0; |
11604 | afi_t afiz; | |
11605 | safi_t safiz; | |
11606 | if (sgid) | |
11607 | subgrp_id = strtoull(sgid, NULL, 10); | |
11608 | ||
11609 | if (!ip && !afi) | |
11610 | afiz = AFI_IP6; | |
11611 | if (!ip && afi) | |
11612 | afiz = bgp_vty_afi_from_str(afi); | |
11613 | if (ip && !afi) | |
11614 | afiz = AFI_IP; | |
11615 | if (ip && afi) { | |
11616 | afiz = bgp_vty_afi_from_str(afi); | |
11617 | if (afiz != AFI_IP) | |
11618 | vty_out(vty, | |
11619 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
11620 | return CMD_WARNING; | |
11621 | } | |
d62a17ae | 11622 | |
dc64bdec | 11623 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 11624 | |
dc64bdec | 11625 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 11626 | return CMD_SUCCESS; |
11627 | } | |
11628 | ||
d62a17ae | 11629 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group) |
11630 | { | |
11631 | struct listnode *node, *nnode; | |
11632 | struct prefix *range; | |
11633 | struct peer *conf; | |
11634 | struct peer *peer; | |
11635 | char buf[PREFIX2STR_BUFFER]; | |
11636 | afi_t afi; | |
11637 | safi_t safi; | |
11638 | const char *peer_status; | |
11639 | const char *af_str; | |
11640 | int lr_count; | |
11641 | int dynamic; | |
11642 | int af_cfgd; | |
11643 | ||
11644 | conf = group->conf; | |
11645 | ||
11646 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
11647 | vty_out(vty, "\nBGP peer-group %s, remote AS %d\n", group->name, | |
11648 | conf->as); | |
11649 | } else if (conf->as_type == AS_INTERNAL) { | |
11650 | vty_out(vty, "\nBGP peer-group %s, remote AS %d\n", group->name, | |
11651 | group->bgp->as); | |
11652 | } else { | |
11653 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
11654 | } | |
f14e6fdb | 11655 | |
d62a17ae | 11656 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
11657 | vty_out(vty, " Peer-group type is internal\n"); | |
11658 | else | |
11659 | vty_out(vty, " Peer-group type is external\n"); | |
11660 | ||
11661 | /* Display AFs configured. */ | |
11662 | vty_out(vty, " Configured address-families:"); | |
05c7a1cc QY |
11663 | FOREACH_AFI_SAFI (afi, safi) { |
11664 | if (conf->afc[afi][safi]) { | |
11665 | af_cfgd = 1; | |
11666 | vty_out(vty, " %s;", afi_safi_print(afi, safi)); | |
d62a17ae | 11667 | } |
05c7a1cc | 11668 | } |
d62a17ae | 11669 | if (!af_cfgd) |
11670 | vty_out(vty, " none\n"); | |
11671 | else | |
11672 | vty_out(vty, "\n"); | |
11673 | ||
11674 | /* Display listen ranges (for dynamic neighbors), if any */ | |
11675 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
11676 | if (afi == AFI_IP) | |
11677 | af_str = "IPv4"; | |
11678 | else if (afi == AFI_IP6) | |
11679 | af_str = "IPv6"; | |
11680 | else | |
11681 | af_str = "???"; | |
11682 | lr_count = listcount(group->listen_range[afi]); | |
11683 | if (lr_count) { | |
11684 | vty_out(vty, " %d %s listen range(s)\n", lr_count, | |
11685 | af_str); | |
11686 | ||
11687 | ||
11688 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
11689 | nnode, range)) { | |
11690 | prefix2str(range, buf, sizeof(buf)); | |
11691 | vty_out(vty, " %s\n", buf); | |
11692 | } | |
11693 | } | |
11694 | } | |
f14e6fdb | 11695 | |
d62a17ae | 11696 | /* Display group members and their status */ |
11697 | if (listcount(group->peer)) { | |
11698 | vty_out(vty, " Peer-group members:\n"); | |
11699 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
11700 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
11701 | peer_status = "Idle (Admin)"; | |
11702 | else if (CHECK_FLAG(peer->sflags, | |
11703 | PEER_STATUS_PREFIX_OVERFLOW)) | |
11704 | peer_status = "Idle (PfxCt)"; | |
11705 | else | |
11706 | peer_status = lookup_msg(bgp_status_msg, | |
11707 | peer->status, NULL); | |
11708 | ||
11709 | dynamic = peer_dynamic_neighbor(peer); | |
11710 | vty_out(vty, " %s %s %s \n", peer->host, | |
11711 | dynamic ? "(dynamic)" : "", peer_status); | |
11712 | } | |
11713 | } | |
f14e6fdb | 11714 | |
d62a17ae | 11715 | return CMD_SUCCESS; |
11716 | } | |
11717 | ||
ff9959b0 QY |
11718 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
11719 | const char *group_name) | |
d62a17ae | 11720 | { |
ff9959b0 | 11721 | struct bgp *bgp; |
d62a17ae | 11722 | struct listnode *node, *nnode; |
11723 | struct peer_group *group; | |
ff9959b0 QY |
11724 | bool found = false; |
11725 | ||
11726 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
11727 | ||
11728 | if (!bgp) { | |
9f049418 | 11729 | vty_out(vty, "%% BGP instance not found\n"); |
ff9959b0 QY |
11730 | return CMD_WARNING; |
11731 | } | |
d62a17ae | 11732 | |
11733 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
11734 | if (group_name) { |
11735 | if (strmatch(group->name, group_name)) { | |
d62a17ae | 11736 | bgp_show_one_peer_group(vty, group); |
ff9959b0 QY |
11737 | found = true; |
11738 | break; | |
d62a17ae | 11739 | } |
ff9959b0 QY |
11740 | } else { |
11741 | bgp_show_one_peer_group(vty, group); | |
d62a17ae | 11742 | } |
f14e6fdb | 11743 | } |
f14e6fdb | 11744 | |
ff9959b0 | 11745 | if (group_name && !found) |
d62a17ae | 11746 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 11747 | |
d62a17ae | 11748 | return CMD_SUCCESS; |
f14e6fdb DS |
11749 | } |
11750 | ||
f14e6fdb DS |
11751 | DEFUN (show_ip_bgp_peer_groups, |
11752 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 11753 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
11754 | SHOW_STR |
11755 | IP_STR | |
11756 | BGP_STR | |
8386ac43 | 11757 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
11758 | "Detailed information on BGP peer groups\n" |
11759 | "Peer group name\n") | |
f14e6fdb | 11760 | { |
d62a17ae | 11761 | char *vrf, *pg; |
d62a17ae | 11762 | int idx = 0; |
f14e6fdb | 11763 | |
a4d82a8a PZ |
11764 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
11765 | : NULL; | |
d62a17ae | 11766 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 11767 | |
ff9959b0 | 11768 | return bgp_show_peer_group_vty(vty, vrf, pg); |
f14e6fdb | 11769 | } |
3f9c7369 | 11770 | |
d6e3c605 | 11771 | |
718e3744 | 11772 | /* Redistribute VTY commands. */ |
11773 | ||
718e3744 | 11774 | DEFUN (bgp_redistribute_ipv4, |
11775 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 11776 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 11777 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11778 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 11779 | { |
d62a17ae | 11780 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11781 | int idx_protocol = 1; | |
11782 | int type; | |
718e3744 | 11783 | |
d62a17ae | 11784 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
11785 | if (type < 0) { | |
11786 | vty_out(vty, "%% Invalid route type\n"); | |
11787 | return CMD_WARNING_CONFIG_FAILED; | |
11788 | } | |
7f323236 | 11789 | |
d62a17ae | 11790 | bgp_redist_add(bgp, AFI_IP, type, 0); |
e923dd62 | 11791 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, false); |
718e3744 | 11792 | } |
11793 | ||
d62a17ae | 11794 | ALIAS_HIDDEN( |
11795 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
11796 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
11797 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 11798 | |
718e3744 | 11799 | DEFUN (bgp_redistribute_ipv4_rmap, |
11800 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 11801 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 11802 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11803 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 11804 | "Route map reference\n" |
11805 | "Pointer to route-map entries\n") | |
11806 | { | |
d62a17ae | 11807 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11808 | int idx_protocol = 1; | |
11809 | int idx_word = 3; | |
11810 | int type; | |
11811 | struct bgp_redist *red; | |
e923dd62 | 11812 | bool changed; |
1de27621 DA |
11813 | struct route_map *route_map = route_map_lookup_warn_noexist( |
11814 | vty, argv[idx_word]->arg); | |
718e3744 | 11815 | |
d62a17ae | 11816 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
11817 | if (type < 0) { | |
11818 | vty_out(vty, "%% Invalid route type\n"); | |
11819 | return CMD_WARNING_CONFIG_FAILED; | |
11820 | } | |
718e3744 | 11821 | |
d62a17ae | 11822 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
1de27621 DA |
11823 | changed = |
11824 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 11825 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
718e3744 | 11826 | } |
11827 | ||
d62a17ae | 11828 | ALIAS_HIDDEN( |
11829 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
11830 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
11831 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
11832 | "Route map reference\n" | |
11833 | "Pointer to route-map entries\n") | |
596c17ba | 11834 | |
718e3744 | 11835 | DEFUN (bgp_redistribute_ipv4_metric, |
11836 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 11837 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 11838 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11839 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 11840 | "Metric for redistributed routes\n" |
11841 | "Default metric\n") | |
11842 | { | |
d62a17ae | 11843 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11844 | int idx_protocol = 1; | |
11845 | int idx_number = 3; | |
11846 | int type; | |
d7c0a89a | 11847 | uint32_t metric; |
d62a17ae | 11848 | struct bgp_redist *red; |
e923dd62 | 11849 | bool changed; |
d62a17ae | 11850 | |
11851 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
11852 | if (type < 0) { | |
11853 | vty_out(vty, "%% Invalid route type\n"); | |
11854 | return CMD_WARNING_CONFIG_FAILED; | |
11855 | } | |
11856 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
11857 | ||
11858 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 11859 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
11860 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 11861 | } |
11862 | ||
11863 | ALIAS_HIDDEN( | |
11864 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
11865 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
11866 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
11867 | "Metric for redistributed routes\n" | |
11868 | "Default metric\n") | |
596c17ba | 11869 | |
718e3744 | 11870 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
11871 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 11872 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 11873 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11874 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 11875 | "Route map reference\n" |
11876 | "Pointer to route-map entries\n" | |
11877 | "Metric for redistributed routes\n" | |
11878 | "Default metric\n") | |
11879 | { | |
d62a17ae | 11880 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11881 | int idx_protocol = 1; | |
11882 | int idx_word = 3; | |
11883 | int idx_number = 5; | |
11884 | int type; | |
d7c0a89a | 11885 | uint32_t metric; |
d62a17ae | 11886 | struct bgp_redist *red; |
e923dd62 | 11887 | bool changed; |
1de27621 DA |
11888 | struct route_map *route_map = |
11889 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 11890 | |
11891 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
11892 | if (type < 0) { | |
11893 | vty_out(vty, "%% Invalid route type\n"); | |
11894 | return CMD_WARNING_CONFIG_FAILED; | |
11895 | } | |
11896 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
11897 | ||
11898 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
1de27621 DA |
11899 | changed = |
11900 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 11901 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
11902 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 11903 | } |
11904 | ||
11905 | ALIAS_HIDDEN( | |
11906 | bgp_redistribute_ipv4_rmap_metric, | |
11907 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
11908 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
11909 | " route-map WORD metric (0-4294967295)", | |
11910 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
11911 | "Route map reference\n" | |
11912 | "Pointer to route-map entries\n" | |
11913 | "Metric for redistributed routes\n" | |
11914 | "Default metric\n") | |
596c17ba | 11915 | |
718e3744 | 11916 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
11917 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 11918 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 11919 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11920 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 11921 | "Metric for redistributed routes\n" |
11922 | "Default metric\n" | |
11923 | "Route map reference\n" | |
11924 | "Pointer to route-map entries\n") | |
11925 | { | |
d62a17ae | 11926 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11927 | int idx_protocol = 1; | |
11928 | int idx_number = 3; | |
11929 | int idx_word = 5; | |
11930 | int type; | |
d7c0a89a | 11931 | uint32_t metric; |
d62a17ae | 11932 | struct bgp_redist *red; |
e923dd62 | 11933 | bool changed; |
1de27621 DA |
11934 | struct route_map *route_map = |
11935 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 11936 | |
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 | } | |
11942 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
11943 | ||
11944 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 11945 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
1de27621 DA |
11946 | changed |= |
11947 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 11948 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
d62a17ae | 11949 | } |
11950 | ||
11951 | ALIAS_HIDDEN( | |
11952 | bgp_redistribute_ipv4_metric_rmap, | |
11953 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
11954 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
11955 | " metric (0-4294967295) route-map WORD", | |
11956 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
11957 | "Metric for redistributed routes\n" | |
11958 | "Default metric\n" | |
11959 | "Route map reference\n" | |
11960 | "Pointer to route-map entries\n") | |
596c17ba | 11961 | |
7c8ff89e DS |
11962 | DEFUN (bgp_redistribute_ipv4_ospf, |
11963 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 11964 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
11965 | "Redistribute information from another routing protocol\n" |
11966 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
11967 | "Non-main Kernel Routing Table\n" |
11968 | "Instance ID/Table ID\n") | |
7c8ff89e | 11969 | { |
d62a17ae | 11970 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11971 | int idx_ospf_table = 1; | |
11972 | int idx_number = 2; | |
d7c0a89a QY |
11973 | unsigned short instance; |
11974 | unsigned short protocol; | |
7c8ff89e | 11975 | |
d62a17ae | 11976 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 11977 | |
d62a17ae | 11978 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
11979 | protocol = ZEBRA_ROUTE_OSPF; | |
11980 | else | |
11981 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 11982 | |
d62a17ae | 11983 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
e923dd62 | 11984 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, false); |
7c8ff89e DS |
11985 | } |
11986 | ||
d62a17ae | 11987 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
11988 | "redistribute <ospf|table> (1-65535)", | |
11989 | "Redistribute information from another routing protocol\n" | |
11990 | "Open Shortest Path First (OSPFv2)\n" | |
11991 | "Non-main Kernel Routing Table\n" | |
11992 | "Instance ID/Table ID\n") | |
596c17ba | 11993 | |
7c8ff89e DS |
11994 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
11995 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 11996 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
11997 | "Redistribute information from another routing protocol\n" |
11998 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
11999 | "Non-main Kernel Routing Table\n" |
12000 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12001 | "Route map reference\n" |
12002 | "Pointer to route-map entries\n") | |
12003 | { | |
d62a17ae | 12004 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12005 | int idx_ospf_table = 1; | |
12006 | int idx_number = 2; | |
12007 | int idx_word = 4; | |
12008 | struct bgp_redist *red; | |
d7c0a89a | 12009 | unsigned short instance; |
d62a17ae | 12010 | int protocol; |
e923dd62 | 12011 | bool changed; |
1de27621 DA |
12012 | struct route_map *route_map = |
12013 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12014 | |
12015 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12016 | protocol = ZEBRA_ROUTE_OSPF; | |
12017 | else | |
12018 | protocol = ZEBRA_ROUTE_TABLE; | |
12019 | ||
12020 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12021 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
12022 | changed = |
12023 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12024 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 12025 | } |
12026 | ||
12027 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
12028 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
12029 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
12030 | "Redistribute information from another routing protocol\n" | |
12031 | "Open Shortest Path First (OSPFv2)\n" | |
12032 | "Non-main Kernel Routing Table\n" | |
12033 | "Instance ID/Table ID\n" | |
12034 | "Route map reference\n" | |
12035 | "Pointer to route-map entries\n") | |
596c17ba | 12036 | |
7c8ff89e DS |
12037 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
12038 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 12039 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
12040 | "Redistribute information from another routing protocol\n" |
12041 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12042 | "Non-main Kernel Routing Table\n" |
12043 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12044 | "Metric for redistributed routes\n" |
12045 | "Default metric\n") | |
12046 | { | |
d62a17ae | 12047 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12048 | int idx_ospf_table = 1; | |
12049 | int idx_number = 2; | |
12050 | int idx_number_2 = 4; | |
d7c0a89a | 12051 | uint32_t metric; |
d62a17ae | 12052 | struct bgp_redist *red; |
d7c0a89a | 12053 | unsigned short instance; |
d62a17ae | 12054 | int protocol; |
e923dd62 | 12055 | bool changed; |
d62a17ae | 12056 | |
12057 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12058 | protocol = ZEBRA_ROUTE_OSPF; | |
12059 | else | |
12060 | protocol = ZEBRA_ROUTE_TABLE; | |
12061 | ||
12062 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12063 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
12064 | ||
12065 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 12066 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
12067 | metric); | |
12068 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 12069 | } |
12070 | ||
12071 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
12072 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
12073 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
12074 | "Redistribute information from another routing protocol\n" | |
12075 | "Open Shortest Path First (OSPFv2)\n" | |
12076 | "Non-main Kernel Routing Table\n" | |
12077 | "Instance ID/Table ID\n" | |
12078 | "Metric for redistributed routes\n" | |
12079 | "Default metric\n") | |
596c17ba | 12080 | |
7c8ff89e DS |
12081 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
12082 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 12083 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
12084 | "Redistribute information from another routing protocol\n" |
12085 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12086 | "Non-main Kernel Routing Table\n" |
12087 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12088 | "Route map reference\n" |
12089 | "Pointer to route-map entries\n" | |
12090 | "Metric for redistributed routes\n" | |
12091 | "Default metric\n") | |
12092 | { | |
d62a17ae | 12093 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12094 | int idx_ospf_table = 1; | |
12095 | int idx_number = 2; | |
12096 | int idx_word = 4; | |
12097 | int idx_number_2 = 6; | |
d7c0a89a | 12098 | uint32_t metric; |
d62a17ae | 12099 | struct bgp_redist *red; |
d7c0a89a | 12100 | unsigned short instance; |
d62a17ae | 12101 | int protocol; |
e923dd62 | 12102 | bool changed; |
1de27621 DA |
12103 | struct route_map *route_map = |
12104 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12105 | |
12106 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12107 | protocol = ZEBRA_ROUTE_OSPF; | |
12108 | else | |
12109 | protocol = ZEBRA_ROUTE_TABLE; | |
12110 | ||
12111 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12112 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
12113 | ||
12114 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
12115 | changed = |
12116 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12117 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
12118 | metric); | |
12119 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 12120 | } |
12121 | ||
12122 | ALIAS_HIDDEN( | |
12123 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
12124 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
12125 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
12126 | "Redistribute information from another routing protocol\n" | |
12127 | "Open Shortest Path First (OSPFv2)\n" | |
12128 | "Non-main Kernel Routing Table\n" | |
12129 | "Instance ID/Table ID\n" | |
12130 | "Route map reference\n" | |
12131 | "Pointer to route-map entries\n" | |
12132 | "Metric for redistributed routes\n" | |
12133 | "Default metric\n") | |
596c17ba | 12134 | |
7c8ff89e DS |
12135 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
12136 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 12137 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
12138 | "Redistribute information from another routing protocol\n" |
12139 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12140 | "Non-main Kernel Routing Table\n" |
12141 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12142 | "Metric for redistributed routes\n" |
12143 | "Default metric\n" | |
12144 | "Route map reference\n" | |
12145 | "Pointer to route-map entries\n") | |
12146 | { | |
d62a17ae | 12147 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12148 | int idx_ospf_table = 1; | |
12149 | int idx_number = 2; | |
12150 | int idx_number_2 = 4; | |
12151 | int idx_word = 6; | |
d7c0a89a | 12152 | uint32_t metric; |
d62a17ae | 12153 | struct bgp_redist *red; |
d7c0a89a | 12154 | unsigned short instance; |
d62a17ae | 12155 | int protocol; |
e923dd62 | 12156 | bool changed; |
1de27621 DA |
12157 | struct route_map *route_map = |
12158 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12159 | |
12160 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12161 | protocol = ZEBRA_ROUTE_OSPF; | |
12162 | else | |
12163 | protocol = ZEBRA_ROUTE_TABLE; | |
12164 | ||
12165 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12166 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
12167 | ||
12168 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 12169 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
12170 | metric); | |
1de27621 DA |
12171 | changed |= |
12172 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12173 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 12174 | } |
12175 | ||
12176 | ALIAS_HIDDEN( | |
12177 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
12178 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
12179 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
12180 | "Redistribute information from another routing protocol\n" | |
12181 | "Open Shortest Path First (OSPFv2)\n" | |
12182 | "Non-main Kernel Routing Table\n" | |
12183 | "Instance ID/Table ID\n" | |
12184 | "Metric for redistributed routes\n" | |
12185 | "Default metric\n" | |
12186 | "Route map reference\n" | |
12187 | "Pointer to route-map entries\n") | |
596c17ba | 12188 | |
7c8ff89e DS |
12189 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
12190 | no_bgp_redistribute_ipv4_ospf_cmd, | |
d04c479d | 12191 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", |
7c8ff89e DS |
12192 | NO_STR |
12193 | "Redistribute information from another routing protocol\n" | |
12194 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 12195 | "Non-main Kernel Routing Table\n" |
31500417 DW |
12196 | "Instance ID/Table ID\n" |
12197 | "Metric for redistributed routes\n" | |
12198 | "Default metric\n" | |
12199 | "Route map reference\n" | |
12200 | "Pointer to route-map entries\n") | |
7c8ff89e | 12201 | { |
d62a17ae | 12202 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12203 | int idx_ospf_table = 2; | |
12204 | int idx_number = 3; | |
d7c0a89a | 12205 | unsigned short instance; |
d62a17ae | 12206 | int protocol; |
12207 | ||
12208 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12209 | protocol = ZEBRA_ROUTE_OSPF; | |
12210 | else | |
12211 | protocol = ZEBRA_ROUTE_TABLE; | |
12212 | ||
12213 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12214 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
12215 | } | |
12216 | ||
12217 | ALIAS_HIDDEN( | |
12218 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
12219 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", | |
12220 | NO_STR | |
12221 | "Redistribute information from another routing protocol\n" | |
12222 | "Open Shortest Path First (OSPFv2)\n" | |
12223 | "Non-main Kernel Routing Table\n" | |
12224 | "Instance ID/Table ID\n" | |
12225 | "Metric for redistributed routes\n" | |
12226 | "Default metric\n" | |
12227 | "Route map reference\n" | |
12228 | "Pointer to route-map entries\n") | |
596c17ba | 12229 | |
718e3744 | 12230 | DEFUN (no_bgp_redistribute_ipv4, |
12231 | no_bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 12232 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 12233 | NO_STR |
12234 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 12235 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
12236 | "Metric for redistributed routes\n" |
12237 | "Default metric\n" | |
12238 | "Route map reference\n" | |
12239 | "Pointer to route-map entries\n") | |
718e3744 | 12240 | { |
d62a17ae | 12241 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12242 | int idx_protocol = 2; | |
12243 | int type; | |
12244 | ||
12245 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
12246 | if (type < 0) { | |
12247 | vty_out(vty, "%% Invalid route type\n"); | |
12248 | return CMD_WARNING_CONFIG_FAILED; | |
12249 | } | |
12250 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
12251 | } | |
12252 | ||
12253 | ALIAS_HIDDEN( | |
12254 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
12255 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
12256 | " [metric (0-4294967295)] [route-map WORD]", | |
12257 | NO_STR | |
12258 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
12259 | "Metric for redistributed routes\n" | |
12260 | "Default metric\n" | |
12261 | "Route map reference\n" | |
12262 | "Pointer to route-map entries\n") | |
596c17ba | 12263 | |
718e3744 | 12264 | DEFUN (bgp_redistribute_ipv6, |
12265 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 12266 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 12267 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12268 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 12269 | { |
d62a17ae | 12270 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12271 | int idx_protocol = 1; | |
12272 | int type; | |
718e3744 | 12273 | |
d62a17ae | 12274 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
12275 | if (type < 0) { | |
12276 | vty_out(vty, "%% Invalid route type\n"); | |
12277 | return CMD_WARNING_CONFIG_FAILED; | |
12278 | } | |
718e3744 | 12279 | |
d62a17ae | 12280 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 12281 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, false); |
718e3744 | 12282 | } |
12283 | ||
12284 | DEFUN (bgp_redistribute_ipv6_rmap, | |
12285 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 12286 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 12287 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12288 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12289 | "Route map reference\n" |
12290 | "Pointer to route-map entries\n") | |
12291 | { | |
d62a17ae | 12292 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12293 | int idx_protocol = 1; | |
12294 | int idx_word = 3; | |
12295 | int type; | |
12296 | struct bgp_redist *red; | |
e923dd62 | 12297 | bool changed; |
1de27621 DA |
12298 | struct route_map *route_map = |
12299 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
718e3744 | 12300 | |
d62a17ae | 12301 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
12302 | if (type < 0) { | |
12303 | vty_out(vty, "%% Invalid route type\n"); | |
12304 | return CMD_WARNING_CONFIG_FAILED; | |
12305 | } | |
718e3744 | 12306 | |
d62a17ae | 12307 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
12308 | changed = |
12309 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12310 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 12311 | } |
12312 | ||
12313 | DEFUN (bgp_redistribute_ipv6_metric, | |
12314 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 12315 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 12316 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12317 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12318 | "Metric for redistributed routes\n" |
12319 | "Default metric\n") | |
12320 | { | |
d62a17ae | 12321 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12322 | int idx_protocol = 1; | |
12323 | int idx_number = 3; | |
12324 | int type; | |
d7c0a89a | 12325 | uint32_t metric; |
d62a17ae | 12326 | struct bgp_redist *red; |
e923dd62 | 12327 | bool changed; |
d62a17ae | 12328 | |
12329 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
12330 | if (type < 0) { | |
12331 | vty_out(vty, "%% Invalid route type\n"); | |
12332 | return CMD_WARNING_CONFIG_FAILED; | |
12333 | } | |
12334 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 12335 | |
d62a17ae | 12336 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 12337 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); |
12338 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 12339 | } |
12340 | ||
12341 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
12342 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 12343 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 12344 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12345 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12346 | "Route map reference\n" |
12347 | "Pointer to route-map entries\n" | |
12348 | "Metric for redistributed routes\n" | |
12349 | "Default metric\n") | |
12350 | { | |
d62a17ae | 12351 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12352 | int idx_protocol = 1; | |
12353 | int idx_word = 3; | |
12354 | int idx_number = 5; | |
12355 | int type; | |
d7c0a89a | 12356 | uint32_t metric; |
d62a17ae | 12357 | struct bgp_redist *red; |
e923dd62 | 12358 | bool changed; |
1de27621 DA |
12359 | struct route_map *route_map = |
12360 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12361 | |
12362 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
12363 | if (type < 0) { | |
12364 | vty_out(vty, "%% Invalid route type\n"); | |
12365 | return CMD_WARNING_CONFIG_FAILED; | |
12366 | } | |
12367 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 12368 | |
d62a17ae | 12369 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
12370 | changed = |
12371 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12372 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, |
12373 | metric); | |
12374 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 12375 | } |
12376 | ||
12377 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
12378 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 12379 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 12380 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12381 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12382 | "Metric for redistributed routes\n" |
12383 | "Default metric\n" | |
12384 | "Route map reference\n" | |
12385 | "Pointer to route-map entries\n") | |
12386 | { | |
d62a17ae | 12387 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12388 | int idx_protocol = 1; | |
12389 | int idx_number = 3; | |
12390 | int idx_word = 5; | |
12391 | int type; | |
d7c0a89a | 12392 | uint32_t metric; |
d62a17ae | 12393 | struct bgp_redist *red; |
e923dd62 | 12394 | bool changed; |
1de27621 DA |
12395 | struct route_map *route_map = |
12396 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12397 | |
12398 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
12399 | if (type < 0) { | |
12400 | vty_out(vty, "%% Invalid route type\n"); | |
12401 | return CMD_WARNING_CONFIG_FAILED; | |
12402 | } | |
12403 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 12404 | |
d62a17ae | 12405 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 12406 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, |
12407 | metric); | |
1de27621 DA |
12408 | changed |= |
12409 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12410 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 12411 | } |
12412 | ||
12413 | DEFUN (no_bgp_redistribute_ipv6, | |
12414 | no_bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 12415 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 12416 | NO_STR |
12417 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 12418 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
12419 | "Metric for redistributed routes\n" |
12420 | "Default metric\n" | |
12421 | "Route map reference\n" | |
12422 | "Pointer to route-map entries\n") | |
718e3744 | 12423 | { |
d62a17ae | 12424 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12425 | int idx_protocol = 2; | |
12426 | int type; | |
718e3744 | 12427 | |
d62a17ae | 12428 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
12429 | if (type < 0) { | |
12430 | vty_out(vty, "%% Invalid route type\n"); | |
12431 | return CMD_WARNING_CONFIG_FAILED; | |
12432 | } | |
718e3744 | 12433 | |
d62a17ae | 12434 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
12435 | } | |
12436 | ||
2b791107 | 12437 | void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, afi_t afi, |
60466a63 | 12438 | safi_t safi) |
d62a17ae | 12439 | { |
12440 | int i; | |
12441 | ||
12442 | /* Unicast redistribution only. */ | |
12443 | if (safi != SAFI_UNICAST) | |
2b791107 | 12444 | return; |
d62a17ae | 12445 | |
12446 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
12447 | /* Redistribute BGP does not make sense. */ | |
12448 | if (i != ZEBRA_ROUTE_BGP) { | |
12449 | struct list *red_list; | |
12450 | struct listnode *node; | |
12451 | struct bgp_redist *red; | |
12452 | ||
12453 | red_list = bgp->redist[afi][i]; | |
12454 | if (!red_list) | |
12455 | continue; | |
12456 | ||
12457 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 12458 | /* "redistribute" configuration. */ |
12459 | vty_out(vty, " redistribute %s", | |
12460 | zebra_route_string(i)); | |
12461 | if (red->instance) | |
12462 | vty_out(vty, " %d", red->instance); | |
12463 | if (red->redist_metric_flag) | |
12464 | vty_out(vty, " metric %u", | |
12465 | red->redist_metric); | |
12466 | if (red->rmap.name) | |
12467 | vty_out(vty, " route-map %s", | |
12468 | red->rmap.name); | |
12469 | vty_out(vty, "\n"); | |
12470 | } | |
12471 | } | |
12472 | } | |
718e3744 | 12473 | } |
6b0655a2 | 12474 | |
b9c7bc5a PZ |
12475 | /* This is part of the address-family block (unicast only) */ |
12476 | void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, | |
ddb5b488 PZ |
12477 | afi_t afi) |
12478 | { | |
b9c7bc5a | 12479 | int indent = 2; |
ddb5b488 | 12480 | |
8a066a70 PG |
12481 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
12482 | if (listcount(bgp->vpn_policy[afi].import_vrf)) | |
12483 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", | |
12484 | bgp->vpn_policy[afi] | |
bb4f6190 | 12485 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
12486 | else |
12487 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
12488 | bgp->vpn_policy[afi] | |
12489 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
12490 | } | |
12a844a5 DS |
12491 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
12492 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
12493 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
12494 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
12495 | return; | |
12496 | ||
e70e9f8e PZ |
12497 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
12498 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
12499 | ||
12500 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
12501 | ||
12502 | } else { | |
12503 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
12504 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
12505 | bgp->vpn_policy[afi].tovpn_label); | |
12506 | } | |
ddb5b488 PZ |
12507 | } |
12508 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
12509 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
12510 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 12511 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
12512 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
12513 | sizeof(buf))); | |
12514 | } | |
12515 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
12516 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
12517 | ||
12518 | char buf[PREFIX_STRLEN]; | |
12519 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
12520 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
12521 | sizeof(buf))) { | |
12522 | ||
b9c7bc5a PZ |
12523 | vty_out(vty, "%*snexthop vpn export %s\n", |
12524 | indent, "", buf); | |
ddb5b488 PZ |
12525 | } |
12526 | } | |
12527 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
12528 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
12529 | && ecommunity_cmp( | |
12530 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
12531 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
12532 | ||
12533 | char *b = ecommunity_ecom2str( | |
12534 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
12535 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12536 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
12537 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12538 | } else { | |
12539 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
12540 | char *b = ecommunity_ecom2str( | |
12541 | bgp->vpn_policy[afi] | |
12542 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
12543 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12544 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12545 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
12546 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12547 | } | |
12548 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
12549 | char *b = ecommunity_ecom2str( | |
12550 | bgp->vpn_policy[afi] | |
12551 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
12552 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12553 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12554 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
12555 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12556 | } | |
12557 | } | |
bb4f6190 DS |
12558 | |
12559 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 12560 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
12561 | bgp->vpn_policy[afi] |
12562 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 12563 | |
301ad80a PG |
12564 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
12565 | char *b = ecommunity_ecom2str( | |
12566 | bgp->vpn_policy[afi] | |
12567 | .import_redirect_rtlist, | |
12568 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12569 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 12570 | |
301ad80a PG |
12571 | vty_out(vty, "%*srt redirect import %s\n", indent, "", b); |
12572 | XFREE(MTYPE_ECOMMUNITY_STR, b); | |
12573 | } | |
ddb5b488 PZ |
12574 | } |
12575 | ||
12576 | ||
718e3744 | 12577 | /* BGP node structure. */ |
d62a17ae | 12578 | static struct cmd_node bgp_node = { |
9d303b37 | 12579 | BGP_NODE, "%s(config-router)# ", 1, |
718e3744 | 12580 | }; |
12581 | ||
d62a17ae | 12582 | static struct cmd_node bgp_ipv4_unicast_node = { |
9d303b37 | 12583 | BGP_IPV4_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12584 | }; |
12585 | ||
d62a17ae | 12586 | static struct cmd_node bgp_ipv4_multicast_node = { |
9d303b37 | 12587 | BGP_IPV4M_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12588 | }; |
12589 | ||
d62a17ae | 12590 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
9d303b37 | 12591 | BGP_IPV4L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
12592 | }; |
12593 | ||
d62a17ae | 12594 | static struct cmd_node bgp_ipv6_unicast_node = { |
9d303b37 | 12595 | BGP_IPV6_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12596 | }; |
12597 | ||
d62a17ae | 12598 | static struct cmd_node bgp_ipv6_multicast_node = { |
9d303b37 | 12599 | BGP_IPV6M_NODE, "%s(config-router-af)# ", 1, |
25ffbdc1 | 12600 | }; |
12601 | ||
d62a17ae | 12602 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
9d303b37 | 12603 | BGP_IPV6L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
12604 | }; |
12605 | ||
d62a17ae | 12606 | static struct cmd_node bgp_vpnv4_node = {BGP_VPNV4_NODE, |
12607 | "%s(config-router-af)# ", 1}; | |
6b0655a2 | 12608 | |
d62a17ae | 12609 | static struct cmd_node bgp_vpnv6_node = {BGP_VPNV6_NODE, |
12610 | "%s(config-router-af-vpnv6)# ", 1}; | |
8ecd3266 | 12611 | |
d62a17ae | 12612 | static struct cmd_node bgp_evpn_node = {BGP_EVPN_NODE, |
12613 | "%s(config-router-evpn)# ", 1}; | |
4e0b7b6d | 12614 | |
d62a17ae | 12615 | static struct cmd_node bgp_evpn_vni_node = {BGP_EVPN_VNI_NODE, |
12616 | "%s(config-router-af-vni)# ", 1}; | |
90e60aa7 | 12617 | |
7c40bf39 | 12618 | static struct cmd_node bgp_flowspecv4_node = {BGP_FLOWSPECV4_NODE, |
12619 | "%s(config-router-af)# ", 1}; | |
12620 | ||
12621 | static struct cmd_node bgp_flowspecv6_node = {BGP_FLOWSPECV6_NODE, | |
12622 | "%s(config-router-af-vpnv6)# ", 1}; | |
12623 | ||
d62a17ae | 12624 | static void community_list_vty(void); |
1f8ae70b | 12625 | |
d62a17ae | 12626 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 12627 | { |
d62a17ae | 12628 | struct bgp *bgp; |
12629 | struct peer *peer; | |
d62a17ae | 12630 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 12631 | |
d62a17ae | 12632 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
12633 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
12634 | /* only provide suggestions on the appropriate input | |
12635 | * token type, | |
12636 | * they'll otherwise show up multiple times */ | |
12637 | enum cmd_token_type match_type; | |
12638 | char *name = peer->host; | |
d48ed3e0 | 12639 | |
d62a17ae | 12640 | if (peer->conf_if) { |
12641 | match_type = VARIABLE_TKN; | |
12642 | name = peer->conf_if; | |
12643 | } else if (strchr(peer->host, ':')) | |
12644 | match_type = IPV6_TKN; | |
12645 | else | |
12646 | match_type = IPV4_TKN; | |
d48ed3e0 | 12647 | |
d62a17ae | 12648 | if (token->type != match_type) |
12649 | continue; | |
d48ed3e0 | 12650 | |
d62a17ae | 12651 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
12652 | } | |
d62a17ae | 12653 | } |
b8a815e5 DL |
12654 | } |
12655 | ||
12656 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 12657 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
12658 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 12659 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 12660 | {.completions = NULL}}; |
12661 | ||
47a306a0 DS |
12662 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
12663 | { | |
12664 | struct bgp *bgp; | |
12665 | struct peer_group *group; | |
12666 | struct listnode *lnbgp, *lnpeer; | |
12667 | ||
12668 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
12669 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
12670 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
12671 | group->name)); | |
12672 | } | |
12673 | } | |
12674 | ||
12675 | static const struct cmd_variable_handler bgp_var_peergroup[] = { | |
12676 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
12677 | {.completions = NULL} }; | |
12678 | ||
d62a17ae | 12679 | void bgp_vty_init(void) |
12680 | { | |
12681 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 12682 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 12683 | |
12684 | /* Install bgp top node. */ | |
12685 | install_node(&bgp_node, bgp_config_write); | |
12686 | install_node(&bgp_ipv4_unicast_node, NULL); | |
12687 | install_node(&bgp_ipv4_multicast_node, NULL); | |
12688 | install_node(&bgp_ipv4_labeled_unicast_node, NULL); | |
12689 | install_node(&bgp_ipv6_unicast_node, NULL); | |
12690 | install_node(&bgp_ipv6_multicast_node, NULL); | |
12691 | install_node(&bgp_ipv6_labeled_unicast_node, NULL); | |
12692 | install_node(&bgp_vpnv4_node, NULL); | |
12693 | install_node(&bgp_vpnv6_node, NULL); | |
12694 | install_node(&bgp_evpn_node, NULL); | |
12695 | install_node(&bgp_evpn_vni_node, NULL); | |
7c40bf39 | 12696 | install_node(&bgp_flowspecv4_node, NULL); |
12697 | install_node(&bgp_flowspecv6_node, NULL); | |
d62a17ae | 12698 | |
12699 | /* Install default VTY commands to new nodes. */ | |
12700 | install_default(BGP_NODE); | |
12701 | install_default(BGP_IPV4_NODE); | |
12702 | install_default(BGP_IPV4M_NODE); | |
12703 | install_default(BGP_IPV4L_NODE); | |
12704 | install_default(BGP_IPV6_NODE); | |
12705 | install_default(BGP_IPV6M_NODE); | |
12706 | install_default(BGP_IPV6L_NODE); | |
12707 | install_default(BGP_VPNV4_NODE); | |
12708 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 12709 | install_default(BGP_FLOWSPECV4_NODE); |
12710 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 12711 | install_default(BGP_EVPN_NODE); |
12712 | install_default(BGP_EVPN_VNI_NODE); | |
12713 | ||
12714 | /* "bgp multiple-instance" commands. */ | |
12715 | install_element(CONFIG_NODE, &bgp_multiple_instance_cmd); | |
12716 | install_element(CONFIG_NODE, &no_bgp_multiple_instance_cmd); | |
12717 | ||
12718 | /* "bgp config-type" commands. */ | |
12719 | install_element(CONFIG_NODE, &bgp_config_type_cmd); | |
12720 | install_element(CONFIG_NODE, &no_bgp_config_type_cmd); | |
12721 | ||
8029b216 AK |
12722 | /* "bgp local-mac" hidden commands. */ |
12723 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
12724 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
12725 | ||
d62a17ae | 12726 | /* bgp route-map delay-timer commands. */ |
12727 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
12728 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
12729 | ||
12730 | /* Dummy commands (Currently not supported) */ | |
12731 | install_element(BGP_NODE, &no_synchronization_cmd); | |
12732 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
12733 | ||
12734 | /* "router bgp" commands. */ | |
12735 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
12736 | ||
12737 | /* "no router bgp" commands. */ | |
12738 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
12739 | ||
12740 | /* "bgp router-id" commands. */ | |
12741 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
12742 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
12743 | ||
12744 | /* "bgp cluster-id" commands. */ | |
12745 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
12746 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
12747 | ||
12748 | /* "bgp confederation" commands. */ | |
12749 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
12750 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
12751 | ||
12752 | /* "bgp confederation peers" commands. */ | |
12753 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
12754 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
12755 | ||
12756 | /* bgp max-med command */ | |
12757 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
12758 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
12759 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
12760 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
12761 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
12762 | ||
12763 | /* bgp disable-ebgp-connected-nh-check */ | |
12764 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
12765 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
12766 | ||
12767 | /* bgp update-delay command */ | |
12768 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
12769 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
12770 | install_element(BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
12771 | ||
12772 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
12773 | install_element(BGP_NODE, &no_bgp_wpkt_quanta_cmd); | |
555e09d4 QY |
12774 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
12775 | install_element(BGP_NODE, &no_bgp_rpkt_quanta_cmd); | |
d62a17ae | 12776 | |
12777 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
12778 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
12779 | ||
12780 | /* "maximum-paths" commands. */ | |
12781 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
12782 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
12783 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
12784 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
12785 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
12786 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
12787 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
12788 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
12789 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
12790 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
12791 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
12792 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
12793 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
12794 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
12795 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
12796 | ||
12797 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); | |
12798 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
12799 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
12800 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
12801 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
12802 | ||
12803 | /* "timers bgp" commands. */ | |
12804 | install_element(BGP_NODE, &bgp_timers_cmd); | |
12805 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
12806 | ||
12807 | /* route-map delay-timer commands - per instance for backwards compat. | |
12808 | */ | |
12809 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
12810 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
12811 | ||
12812 | /* "bgp client-to-client reflection" commands */ | |
12813 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
12814 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
12815 | ||
12816 | /* "bgp always-compare-med" commands */ | |
12817 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
12818 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
12819 | ||
12820 | /* "bgp deterministic-med" commands */ | |
12821 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
12822 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
12823 | ||
12824 | /* "bgp graceful-restart" commands */ | |
12825 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); | |
12826 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
12827 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); | |
12828 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
12829 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
12830 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
12831 | ||
12832 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); | |
12833 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
12834 | ||
7f323236 DW |
12835 | /* "bgp graceful-shutdown" commands */ |
12836 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
12837 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
12838 | ||
d62a17ae | 12839 | /* "bgp fast-external-failover" commands */ |
12840 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
12841 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
12842 | ||
12843 | /* "bgp enforce-first-as" commands */ | |
12844 | install_element(BGP_NODE, &bgp_enforce_first_as_cmd); | |
d62a17ae | 12845 | |
12846 | /* "bgp bestpath compare-routerid" commands */ | |
12847 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
12848 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
12849 | ||
12850 | /* "bgp bestpath as-path ignore" commands */ | |
12851 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
12852 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
12853 | ||
12854 | /* "bgp bestpath as-path confed" commands */ | |
12855 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
12856 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
12857 | ||
12858 | /* "bgp bestpath as-path multipath-relax" commands */ | |
12859 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
12860 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
12861 | ||
12862 | /* "bgp log-neighbor-changes" commands */ | |
12863 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
12864 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
12865 | ||
12866 | /* "bgp bestpath med" commands */ | |
12867 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
12868 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
12869 | ||
12870 | /* "no bgp default ipv4-unicast" commands. */ | |
12871 | install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
12872 | install_element(BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
12873 | ||
12874 | /* "bgp network import-check" commands. */ | |
12875 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
12876 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
12877 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
12878 | ||
12879 | /* "bgp default local-preference" commands. */ | |
12880 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
12881 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
12882 | ||
12883 | /* bgp default show-hostname */ | |
12884 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
12885 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
12886 | ||
12887 | /* "bgp default subgroup-pkt-queue-max" commands. */ | |
12888 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
12889 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
12890 | ||
12891 | /* bgp ibgp-allow-policy-mods command */ | |
12892 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
12893 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
12894 | ||
12895 | /* "bgp listen limit" commands. */ | |
12896 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
12897 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
12898 | ||
12899 | /* "bgp listen range" commands. */ | |
12900 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
12901 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
12902 | ||
8175f54a | 12903 | /* "bgp default shutdown" command */ |
f26845f9 QY |
12904 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
12905 | ||
d62a17ae | 12906 | /* "neighbor remote-as" commands. */ |
12907 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
12908 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
12909 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
12910 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
12911 | install_element(BGP_NODE, | |
12912 | &neighbor_interface_v6only_config_remote_as_cmd); | |
12913 | install_element(BGP_NODE, &no_neighbor_cmd); | |
12914 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
12915 | ||
12916 | /* "neighbor peer-group" commands. */ | |
12917 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
12918 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
12919 | install_element(BGP_NODE, | |
12920 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
12921 | ||
12922 | /* "neighbor local-as" commands. */ | |
12923 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
12924 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
12925 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
12926 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
12927 | ||
12928 | /* "neighbor solo" commands. */ | |
12929 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
12930 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
12931 | ||
12932 | /* "neighbor password" commands. */ | |
12933 | install_element(BGP_NODE, &neighbor_password_cmd); | |
12934 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
12935 | ||
12936 | /* "neighbor activate" commands. */ | |
12937 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
12938 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
12939 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
12940 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
12941 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
12942 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
12943 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
12944 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
12945 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 12946 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
12947 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 12948 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
12949 | ||
12950 | /* "no neighbor activate" commands. */ | |
12951 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
12952 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
12953 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
12954 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
12955 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
12956 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
12957 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
12958 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
12959 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 12960 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
12961 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 12962 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
12963 | ||
12964 | /* "neighbor peer-group" set commands. */ | |
12965 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
12966 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12967 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12968 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12969 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12970 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12971 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12972 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 12973 | install_element(BGP_FLOWSPECV4_NODE, |
12974 | &neighbor_set_peer_group_hidden_cmd); | |
12975 | install_element(BGP_FLOWSPECV6_NODE, | |
12976 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 12977 | |
12978 | /* "no neighbor peer-group unset" commands. */ | |
12979 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
12980 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12981 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12982 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12983 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12984 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12985 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12986 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 12987 | install_element(BGP_FLOWSPECV4_NODE, |
12988 | &no_neighbor_set_peer_group_hidden_cmd); | |
12989 | install_element(BGP_FLOWSPECV6_NODE, | |
12990 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 12991 | |
12992 | /* "neighbor softreconfiguration inbound" commands.*/ | |
12993 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
12994 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
12995 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
12996 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12997 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
12998 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12999 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
13000 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13001 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
13002 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13003 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
13004 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13005 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
13006 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13007 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
13008 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13009 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
13010 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 13011 | install_element(BGP_FLOWSPECV4_NODE, |
13012 | &neighbor_soft_reconfiguration_cmd); | |
13013 | install_element(BGP_FLOWSPECV4_NODE, | |
13014 | &no_neighbor_soft_reconfiguration_cmd); | |
13015 | install_element(BGP_FLOWSPECV6_NODE, | |
13016 | &neighbor_soft_reconfiguration_cmd); | |
13017 | install_element(BGP_FLOWSPECV6_NODE, | |
13018 | &no_neighbor_soft_reconfiguration_cmd); | |
616c6ee8 PG |
13019 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); |
13020 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 13021 | |
13022 | /* "neighbor attribute-unchanged" commands. */ | |
13023 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
13024 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
13025 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
13026 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
13027 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
13028 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
13029 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
13030 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
13031 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
13032 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
13033 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
13034 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
13035 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
13036 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
13037 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
13038 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
13039 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
13040 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
13041 | ||
13042 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
13043 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
13044 | ||
13045 | /* "nexthop-local unchanged" commands */ | |
13046 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
13047 | install_element(BGP_IPV6_NODE, | |
13048 | &no_neighbor_nexthop_local_unchanged_cmd); | |
13049 | ||
13050 | /* "neighbor next-hop-self" commands. */ | |
13051 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
13052 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
13053 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
13054 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
13055 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
13056 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
13057 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
13058 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
13059 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
13060 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
13061 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
13062 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
13063 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
13064 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
13065 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
13066 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
13067 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
13068 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
13069 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
13070 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 13071 | |
13072 | /* "neighbor next-hop-self force" commands. */ | |
13073 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
13074 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
13075 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); | |
13076 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13077 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); | |
13078 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13079 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); | |
13080 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13081 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); | |
13082 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13083 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); | |
13084 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13085 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); | |
13086 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13087 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); | |
13088 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13089 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); | |
13090 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13091 | ||
13092 | /* "neighbor as-override" commands. */ | |
13093 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
13094 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
13095 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
13096 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
13097 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
13098 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
13099 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
13100 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
13101 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
13102 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
13103 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
13104 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
13105 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
13106 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
13107 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
13108 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
13109 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
13110 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
13111 | ||
13112 | /* "neighbor remove-private-AS" commands. */ | |
13113 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
13114 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
13115 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
13116 | install_element(BGP_NODE, | |
13117 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
13118 | install_element(BGP_NODE, | |
13119 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
13120 | install_element(BGP_NODE, | |
13121 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
13122 | install_element(BGP_NODE, | |
13123 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
13124 | install_element( | |
13125 | BGP_NODE, | |
13126 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
13127 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
13128 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
13129 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
13130 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13131 | install_element(BGP_IPV4_NODE, | |
13132 | &neighbor_remove_private_as_replace_as_cmd); | |
13133 | install_element(BGP_IPV4_NODE, | |
13134 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13135 | install_element(BGP_IPV4_NODE, | |
13136 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13137 | install_element(BGP_IPV4_NODE, | |
13138 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13139 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
13140 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
13141 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
13142 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13143 | install_element(BGP_IPV4M_NODE, | |
13144 | &neighbor_remove_private_as_replace_as_cmd); | |
13145 | install_element(BGP_IPV4M_NODE, | |
13146 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13147 | install_element(BGP_IPV4M_NODE, | |
13148 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13149 | install_element(BGP_IPV4M_NODE, | |
13150 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13151 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
13152 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
13153 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
13154 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13155 | install_element(BGP_IPV4L_NODE, | |
13156 | &neighbor_remove_private_as_replace_as_cmd); | |
13157 | install_element(BGP_IPV4L_NODE, | |
13158 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13159 | install_element(BGP_IPV4L_NODE, | |
13160 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13161 | install_element(BGP_IPV4L_NODE, | |
13162 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13163 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
13164 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
13165 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
13166 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13167 | install_element(BGP_IPV6_NODE, | |
13168 | &neighbor_remove_private_as_replace_as_cmd); | |
13169 | install_element(BGP_IPV6_NODE, | |
13170 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13171 | install_element(BGP_IPV6_NODE, | |
13172 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13173 | install_element(BGP_IPV6_NODE, | |
13174 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13175 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
13176 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
13177 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
13178 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13179 | install_element(BGP_IPV6M_NODE, | |
13180 | &neighbor_remove_private_as_replace_as_cmd); | |
13181 | install_element(BGP_IPV6M_NODE, | |
13182 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13183 | install_element(BGP_IPV6M_NODE, | |
13184 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13185 | install_element(BGP_IPV6M_NODE, | |
13186 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13187 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
13188 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
13189 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
13190 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13191 | install_element(BGP_IPV6L_NODE, | |
13192 | &neighbor_remove_private_as_replace_as_cmd); | |
13193 | install_element(BGP_IPV6L_NODE, | |
13194 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13195 | install_element(BGP_IPV6L_NODE, | |
13196 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13197 | install_element(BGP_IPV6L_NODE, | |
13198 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13199 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
13200 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
13201 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
13202 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13203 | install_element(BGP_VPNV4_NODE, | |
13204 | &neighbor_remove_private_as_replace_as_cmd); | |
13205 | install_element(BGP_VPNV4_NODE, | |
13206 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13207 | install_element(BGP_VPNV4_NODE, | |
13208 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13209 | install_element(BGP_VPNV4_NODE, | |
13210 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13211 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
13212 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
13213 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
13214 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13215 | install_element(BGP_VPNV6_NODE, | |
13216 | &neighbor_remove_private_as_replace_as_cmd); | |
13217 | install_element(BGP_VPNV6_NODE, | |
13218 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13219 | install_element(BGP_VPNV6_NODE, | |
13220 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13221 | install_element(BGP_VPNV6_NODE, | |
13222 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13223 | ||
13224 | /* "neighbor send-community" commands.*/ | |
13225 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
13226 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
13227 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
13228 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
13229 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
13230 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
13231 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
13232 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
13233 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
13234 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
13235 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
13236 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
13237 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
13238 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
13239 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
13240 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
13241 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
13242 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
13243 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
13244 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
13245 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
13246 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
13247 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
13248 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
13249 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
13250 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
13251 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
13252 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
13253 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
13254 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
13255 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
13256 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
13257 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
13258 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
13259 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
13260 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
13261 | ||
13262 | /* "neighbor route-reflector" commands.*/ | |
13263 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
13264 | install_element(BGP_NODE, | |
13265 | &no_neighbor_route_reflector_client_hidden_cmd); | |
13266 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
13267 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
13268 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
13269 | install_element(BGP_IPV4M_NODE, | |
13270 | &no_neighbor_route_reflector_client_cmd); | |
13271 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
13272 | install_element(BGP_IPV4L_NODE, | |
13273 | &no_neighbor_route_reflector_client_cmd); | |
13274 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
13275 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
13276 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
13277 | install_element(BGP_IPV6M_NODE, | |
13278 | &no_neighbor_route_reflector_client_cmd); | |
13279 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
13280 | install_element(BGP_IPV6L_NODE, | |
13281 | &no_neighbor_route_reflector_client_cmd); | |
13282 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
13283 | install_element(BGP_VPNV4_NODE, | |
13284 | &no_neighbor_route_reflector_client_cmd); | |
13285 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
13286 | install_element(BGP_VPNV6_NODE, | |
13287 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 13288 | install_element(BGP_FLOWSPECV4_NODE, |
13289 | &neighbor_route_reflector_client_cmd); | |
13290 | install_element(BGP_FLOWSPECV4_NODE, | |
13291 | &no_neighbor_route_reflector_client_cmd); | |
13292 | install_element(BGP_FLOWSPECV6_NODE, | |
13293 | &neighbor_route_reflector_client_cmd); | |
13294 | install_element(BGP_FLOWSPECV6_NODE, | |
13295 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 13296 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
13297 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
13298 | ||
13299 | /* "neighbor route-server" commands.*/ | |
13300 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
13301 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
13302 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
13303 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
13304 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
13305 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
13306 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
13307 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
13308 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
13309 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
13310 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
13311 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
13312 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
13313 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
13314 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
13315 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
13316 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
13317 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
13318 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
13319 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 13320 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
13321 | install_element(BGP_FLOWSPECV4_NODE, | |
13322 | &no_neighbor_route_server_client_cmd); | |
13323 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
13324 | install_element(BGP_FLOWSPECV6_NODE, | |
13325 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 13326 | |
13327 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
13328 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
13329 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
13330 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13331 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13332 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13333 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13334 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13335 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13336 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13337 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13338 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13339 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13340 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13341 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13342 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13343 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13344 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13345 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13346 | ||
13347 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
13348 | install_element(BGP_NODE, | |
13349 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
13350 | install_element(BGP_NODE, | |
13351 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
13352 | install_element(BGP_IPV4_NODE, | |
13353 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13354 | install_element(BGP_IPV4_NODE, | |
13355 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13356 | install_element(BGP_IPV4M_NODE, | |
13357 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13358 | install_element(BGP_IPV4M_NODE, | |
13359 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13360 | install_element(BGP_IPV4L_NODE, | |
13361 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13362 | install_element(BGP_IPV4L_NODE, | |
13363 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13364 | install_element(BGP_IPV6_NODE, | |
13365 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13366 | install_element(BGP_IPV6_NODE, | |
13367 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13368 | install_element(BGP_IPV6M_NODE, | |
13369 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13370 | install_element(BGP_IPV6M_NODE, | |
13371 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13372 | install_element(BGP_IPV6L_NODE, | |
13373 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13374 | install_element(BGP_IPV6L_NODE, | |
13375 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13376 | install_element(BGP_VPNV4_NODE, | |
13377 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13378 | install_element(BGP_VPNV4_NODE, | |
13379 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13380 | install_element(BGP_VPNV6_NODE, | |
13381 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13382 | install_element(BGP_VPNV6_NODE, | |
13383 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13384 | ||
13385 | /* "neighbor passive" commands. */ | |
13386 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
13387 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
13388 | ||
13389 | ||
13390 | /* "neighbor shutdown" commands. */ | |
13391 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
13392 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
13393 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
13394 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
13395 | ||
13396 | /* "neighbor capability extended-nexthop" commands.*/ | |
13397 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
13398 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
13399 | ||
13400 | /* "neighbor capability orf prefix-list" commands.*/ | |
13401 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
13402 | install_element(BGP_NODE, | |
13403 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
13404 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
13405 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13406 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
13407 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13408 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
13409 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13410 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
13411 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13412 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
13413 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13414 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
13415 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13416 | ||
13417 | /* "neighbor capability dynamic" commands.*/ | |
13418 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
13419 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
13420 | ||
13421 | /* "neighbor dont-capability-negotiate" commands. */ | |
13422 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
13423 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
13424 | ||
13425 | /* "neighbor ebgp-multihop" commands. */ | |
13426 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
13427 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
13428 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
13429 | ||
13430 | /* "neighbor disable-connected-check" commands. */ | |
13431 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
13432 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
13433 | ||
47cbc09b PM |
13434 | /* "neighbor enforce-first-as" commands. */ |
13435 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
13436 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
13437 | ||
d62a17ae | 13438 | /* "neighbor description" commands. */ |
13439 | install_element(BGP_NODE, &neighbor_description_cmd); | |
13440 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 13441 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 13442 | |
13443 | /* "neighbor update-source" commands. "*/ | |
13444 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
13445 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
13446 | ||
13447 | /* "neighbor default-originate" commands. */ | |
13448 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
13449 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
13450 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
13451 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
13452 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
13453 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
13454 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
13455 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
13456 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
13457 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
13458 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
13459 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
13460 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
13461 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
13462 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
13463 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
13464 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
13465 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
13466 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
13467 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
13468 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
13469 | ||
13470 | /* "neighbor port" commands. */ | |
13471 | install_element(BGP_NODE, &neighbor_port_cmd); | |
13472 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
13473 | ||
13474 | /* "neighbor weight" commands. */ | |
13475 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
13476 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
13477 | ||
13478 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
13479 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
13480 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
13481 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
13482 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
13483 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
13484 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
13485 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
13486 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
13487 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
13488 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
13489 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
13490 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
13491 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
13492 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
13493 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
13494 | ||
13495 | /* "neighbor override-capability" commands. */ | |
13496 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
13497 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
13498 | ||
13499 | /* "neighbor strict-capability-match" commands. */ | |
13500 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
13501 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
13502 | ||
13503 | /* "neighbor timers" commands. */ | |
13504 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
13505 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
13506 | ||
13507 | /* "neighbor timers connect" commands. */ | |
13508 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
13509 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
13510 | ||
13511 | /* "neighbor advertisement-interval" commands. */ | |
13512 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
13513 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
13514 | ||
13515 | /* "neighbor interface" commands. */ | |
13516 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
13517 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
13518 | ||
13519 | /* "neighbor distribute" commands. */ | |
13520 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
13521 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
13522 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
13523 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
13524 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
13525 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
13526 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
13527 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
13528 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
13529 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
13530 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
13531 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
13532 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
13533 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
13534 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
13535 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
13536 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
13537 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
13538 | ||
13539 | /* "neighbor prefix-list" commands. */ | |
13540 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
13541 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
13542 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
13543 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
13544 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
13545 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
13546 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); | |
13547 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
13548 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
13549 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
13550 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); | |
13551 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
13552 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); | |
13553 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
13554 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); | |
13555 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
13556 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); | |
13557 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
7c40bf39 | 13558 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
13559 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); | |
13560 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); | |
13561 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); | |
d62a17ae | 13562 | |
13563 | /* "neighbor filter-list" commands. */ | |
13564 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
13565 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
13566 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
13567 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
13568 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
13569 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
13570 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
13571 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
13572 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
13573 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
13574 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
13575 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
13576 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
13577 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
13578 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
13579 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
13580 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
13581 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 13582 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
13583 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
13584 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
13585 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 13586 | |
13587 | /* "neighbor route-map" commands. */ | |
13588 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); | |
13589 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
13590 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
13591 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
13592 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
13593 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
13594 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); | |
13595 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
13596 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
13597 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
13598 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); | |
13599 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
13600 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); | |
13601 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
13602 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); | |
13603 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
13604 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); | |
13605 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
7c40bf39 | 13606 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
13607 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); | |
13608 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); | |
13609 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); | |
d37ba549 MK |
13610 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
13611 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); | |
d62a17ae | 13612 | |
13613 | /* "neighbor unsuppress-map" commands. */ | |
13614 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
13615 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
13616 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
13617 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
13618 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
13619 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
13620 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
13621 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
13622 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
13623 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
13624 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
13625 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
13626 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
13627 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
13628 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
13629 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
13630 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
13631 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
13632 | ||
13633 | /* "neighbor maximum-prefix" commands. */ | |
13634 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
13635 | install_element(BGP_NODE, | |
13636 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
13637 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
13638 | install_element(BGP_NODE, | |
13639 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
13640 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
13641 | install_element(BGP_NODE, | |
13642 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
13643 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
13644 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
13645 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13646 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13647 | install_element(BGP_IPV4_NODE, | |
13648 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13649 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13650 | install_element(BGP_IPV4_NODE, | |
13651 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13652 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
13653 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
13654 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13655 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13656 | install_element(BGP_IPV4M_NODE, | |
13657 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13658 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13659 | install_element(BGP_IPV4M_NODE, | |
13660 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13661 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
13662 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
13663 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13664 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13665 | install_element(BGP_IPV4L_NODE, | |
13666 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13667 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13668 | install_element(BGP_IPV4L_NODE, | |
13669 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13670 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
13671 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
13672 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13673 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13674 | install_element(BGP_IPV6_NODE, | |
13675 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13676 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13677 | install_element(BGP_IPV6_NODE, | |
13678 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13679 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
13680 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
13681 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13682 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13683 | install_element(BGP_IPV6M_NODE, | |
13684 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13685 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13686 | install_element(BGP_IPV6M_NODE, | |
13687 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13688 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
13689 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
13690 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13691 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13692 | install_element(BGP_IPV6L_NODE, | |
13693 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13694 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13695 | install_element(BGP_IPV6L_NODE, | |
13696 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13697 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
13698 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
13699 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13700 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13701 | install_element(BGP_VPNV4_NODE, | |
13702 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13703 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13704 | install_element(BGP_VPNV4_NODE, | |
13705 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13706 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
13707 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
13708 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13709 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13710 | install_element(BGP_VPNV6_NODE, | |
13711 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13712 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13713 | install_element(BGP_VPNV6_NODE, | |
13714 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13715 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
13716 | ||
13717 | /* "neighbor allowas-in" */ | |
13718 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
13719 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
13720 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
13721 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
13722 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
13723 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
13724 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
13725 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
13726 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
13727 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
13728 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
13729 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
13730 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
13731 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
13732 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
13733 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
13734 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
13735 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
13736 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
13737 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
13738 | ||
13739 | /* address-family commands. */ | |
13740 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
13741 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 13742 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 13743 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
13744 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 13745 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 13746 | |
d62a17ae | 13747 | install_element(BGP_NODE, &address_family_evpn_cmd); |
13748 | ||
13749 | /* "exit-address-family" command. */ | |
13750 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
13751 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
13752 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
13753 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
13754 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
13755 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
13756 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
13757 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 13758 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
13759 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 13760 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
13761 | ||
13762 | /* "clear ip bgp commands" */ | |
13763 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
13764 | ||
13765 | /* clear ip bgp prefix */ | |
13766 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
13767 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
13768 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
13769 | ||
13770 | /* "show [ip] bgp summary" commands. */ | |
13771 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 13772 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 13773 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 13774 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 13775 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
13776 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 13777 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
13778 | ||
13779 | /* "show [ip] bgp neighbors" commands. */ | |
13780 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
13781 | ||
13782 | /* "show [ip] bgp peer-group" commands. */ | |
13783 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
13784 | ||
13785 | /* "show [ip] bgp paths" commands. */ | |
13786 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
13787 | ||
13788 | /* "show [ip] bgp community" commands. */ | |
13789 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
13790 | ||
13791 | /* "show ip bgp large-community" commands. */ | |
13792 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
13793 | /* "show [ip] bgp attribute-info" commands. */ | |
13794 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 13795 | /* "show [ip] bgp route-leak" command */ |
13796 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 13797 | |
13798 | /* "redistribute" commands. */ | |
13799 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
13800 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
13801 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
13802 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
13803 | install_element(BGP_NODE, | |
13804 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
13805 | install_element(BGP_NODE, | |
13806 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
13807 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
13808 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
13809 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
13810 | install_element(BGP_NODE, | |
13811 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
13812 | install_element(BGP_NODE, | |
13813 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
13814 | install_element(BGP_NODE, | |
13815 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
13816 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
13817 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
13818 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
13819 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
13820 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
13821 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
13822 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
13823 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
13824 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
13825 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
13826 | install_element(BGP_IPV4_NODE, | |
13827 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
13828 | install_element(BGP_IPV4_NODE, | |
13829 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
13830 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
13831 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
13832 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
13833 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
13834 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
13835 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
13836 | ||
b9c7bc5a PZ |
13837 | /* import|export vpn [route-map WORD] */ |
13838 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
13839 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 13840 | |
12a844a5 DS |
13841 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
13842 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
13843 | ||
d62a17ae | 13844 | /* ttl_security commands */ |
13845 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
13846 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
13847 | ||
13848 | /* "show [ip] bgp memory" commands. */ | |
13849 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
13850 | ||
acf71666 MK |
13851 | /* "show bgp martian next-hop" */ |
13852 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
13853 | ||
48ecf8f5 DS |
13854 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); |
13855 | ||
d62a17ae | 13856 | /* "show [ip] bgp views" commands. */ |
13857 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
13858 | ||
13859 | /* "show [ip] bgp vrfs" commands. */ | |
13860 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
13861 | ||
13862 | /* Community-list. */ | |
13863 | community_list_vty(); | |
ddb5b488 PZ |
13864 | |
13865 | /* vpn-policy commands */ | |
b9c7bc5a PZ |
13866 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
13867 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
13868 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
13869 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
13870 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
13871 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
13872 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
13873 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
13874 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
13875 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
13876 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
13877 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 13878 | |
301ad80a PG |
13879 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
13880 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
13881 | ||
b9c7bc5a PZ |
13882 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
13883 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
13884 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
13885 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
13886 | install_element(BGP_IPV4_NODE, &af_no_nexthop_vpn_export_cmd); | |
13887 | install_element(BGP_IPV6_NODE, &af_no_nexthop_vpn_export_cmd); | |
13888 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); | |
13889 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
13890 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
13891 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
13892 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
13893 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
718e3744 | 13894 | } |
6b0655a2 | 13895 | |
718e3744 | 13896 | #include "memory.h" |
13897 | #include "bgp_regex.h" | |
13898 | #include "bgp_clist.h" | |
13899 | #include "bgp_ecommunity.h" | |
13900 | ||
13901 | /* VTY functions. */ | |
13902 | ||
13903 | /* Direction value to string conversion. */ | |
d62a17ae | 13904 | static const char *community_direct_str(int direct) |
13905 | { | |
13906 | switch (direct) { | |
13907 | case COMMUNITY_DENY: | |
13908 | return "deny"; | |
13909 | case COMMUNITY_PERMIT: | |
13910 | return "permit"; | |
13911 | default: | |
13912 | return "unknown"; | |
13913 | } | |
718e3744 | 13914 | } |
13915 | ||
13916 | /* Display error string. */ | |
d62a17ae | 13917 | static void community_list_perror(struct vty *vty, int ret) |
13918 | { | |
13919 | switch (ret) { | |
13920 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
13921 | vty_out(vty, "%% Can't find community-list\n"); | |
13922 | break; | |
13923 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
13924 | vty_out(vty, "%% Malformed community-list value\n"); | |
13925 | break; | |
13926 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
13927 | vty_out(vty, | |
13928 | "%% Community name conflict, previously defined as standard community\n"); | |
13929 | break; | |
13930 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
13931 | vty_out(vty, | |
13932 | "%% Community name conflict, previously defined as expanded community\n"); | |
13933 | break; | |
13934 | } | |
718e3744 | 13935 | } |
13936 | ||
5bf15956 DW |
13937 | /* "community-list" keyword help string. */ |
13938 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
13939 | ||
7336e101 SP |
13940 | /*community-list standard */ |
13941 | DEFUN (community_list_standard, | |
13942 | bgp_community_list_standard_cmd, | |
13943 | "bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
13944 | BGP_STR | |
718e3744 | 13945 | COMMUNITY_LIST_STR |
13946 | "Community list number (standard)\n" | |
5bf15956 | 13947 | "Add an standard community-list entry\n" |
718e3744 | 13948 | "Community list name\n" |
13949 | "Specify community to reject\n" | |
13950 | "Specify community to accept\n" | |
13951 | COMMUNITY_VAL_STR) | |
13952 | { | |
d62a17ae | 13953 | char *cl_name_or_number = NULL; |
13954 | int direct = 0; | |
13955 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 13956 | |
d62a17ae | 13957 | int idx = 0; |
7336e101 SP |
13958 | |
13959 | if (argv_find(argv, argc, "ip", &idx)) { | |
13960 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
13961 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
13962 | vty_out(vty, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n"); | |
13963 | zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used"); | |
13964 | } | |
13965 | ||
d62a17ae | 13966 | argv_find(argv, argc, "(1-99)", &idx); |
13967 | argv_find(argv, argc, "WORD", &idx); | |
13968 | cl_name_or_number = argv[idx]->arg; | |
13969 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13970 | : COMMUNITY_DENY; | |
13971 | argv_find(argv, argc, "AA:NN", &idx); | |
13972 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 13973 | |
d62a17ae | 13974 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
13975 | style); | |
42f914d4 | 13976 | |
d62a17ae | 13977 | XFREE(MTYPE_TMP, str); |
42f914d4 | 13978 | |
d62a17ae | 13979 | if (ret < 0) { |
13980 | /* Display error string. */ | |
13981 | community_list_perror(vty, ret); | |
13982 | return CMD_WARNING_CONFIG_FAILED; | |
13983 | } | |
42f914d4 | 13984 | |
d62a17ae | 13985 | return CMD_SUCCESS; |
718e3744 | 13986 | } |
13987 | ||
7336e101 SP |
13988 | #if CONFDATE > 20191005 |
13989 | CPP_NOTICE("bgpd: remove deprecated 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' command") | |
13990 | #endif | |
13991 | ALIAS (community_list_standard, | |
13992 | ip_community_list_standard_cmd, | |
13993 | "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
718e3744 | 13994 | IP_STR |
13995 | COMMUNITY_LIST_STR | |
13996 | "Community list number (standard)\n" | |
5bf15956 DW |
13997 | "Add an standard community-list entry\n" |
13998 | "Community list name\n" | |
718e3744 | 13999 | "Specify community to reject\n" |
14000 | "Specify community to accept\n" | |
14001 | COMMUNITY_VAL_STR) | |
7336e101 SP |
14002 | |
14003 | DEFUN (no_community_list_standard_all, | |
14004 | no_bgp_community_list_standard_all_cmd, | |
14005 | "no bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
14006 | NO_STR | |
14007 | BGP_STR | |
14008 | COMMUNITY_LIST_STR | |
14009 | "Community list number (standard)\n" | |
14010 | "Add an standard community-list entry\n" | |
14011 | "Community list name\n" | |
14012 | "Specify community to reject\n" | |
14013 | "Specify community to accept\n" | |
14014 | COMMUNITY_VAL_STR) | |
718e3744 | 14015 | { |
d62a17ae | 14016 | char *cl_name_or_number = NULL; |
174b5cb9 | 14017 | char *str = NULL; |
d62a17ae | 14018 | int direct = 0; |
14019 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 14020 | |
d62a17ae | 14021 | int idx = 0; |
7336e101 SP |
14022 | |
14023 | if (argv_find(argv, argc, "ip", &idx)) { | |
14024 | vty_out(vty, "This config option is deprecated, and is scheduled for removal\n"); | |
14025 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14026 | vty_out(vty, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n"); | |
14027 | zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> |AA:NN' being used"); | |
14028 | } | |
14029 | ||
174b5cb9 DA |
14030 | argv_find(argv, argc, "permit", &idx); |
14031 | argv_find(argv, argc, "deny", &idx); | |
14032 | ||
14033 | if (idx) { | |
14034 | direct = argv_find(argv, argc, "permit", &idx) | |
14035 | ? COMMUNITY_PERMIT | |
14036 | : COMMUNITY_DENY; | |
14037 | ||
14038 | idx = 0; | |
14039 | argv_find(argv, argc, "AA:NN", &idx); | |
14040 | str = argv_concat(argv, argc, idx); | |
14041 | } | |
14042 | ||
14043 | idx = 0; | |
d62a17ae | 14044 | argv_find(argv, argc, "(1-99)", &idx); |
14045 | argv_find(argv, argc, "WORD", &idx); | |
14046 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 14047 | |
d62a17ae | 14048 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
7298a8e1 | 14049 | direct, style); |
42f914d4 | 14050 | |
d62a17ae | 14051 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 14052 | |
d62a17ae | 14053 | if (ret < 0) { |
14054 | community_list_perror(vty, ret); | |
14055 | return CMD_WARNING_CONFIG_FAILED; | |
14056 | } | |
42f914d4 | 14057 | |
d62a17ae | 14058 | return CMD_SUCCESS; |
718e3744 | 14059 | } |
7336e101 SP |
14060 | ALIAS (no_community_list_standard_all, |
14061 | no_ip_community_list_standard_all_cmd, | |
14062 | "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
14063 | NO_STR | |
718e3744 | 14064 | IP_STR |
14065 | COMMUNITY_LIST_STR | |
7336e101 SP |
14066 | "Community list number (standard)\n" |
14067 | "Add an standard community-list entry\n" | |
14068 | "Community list name\n" | |
14069 | "Specify community to reject\n" | |
14070 | "Specify community to accept\n" | |
14071 | COMMUNITY_VAL_STR) | |
14072 | ||
174b5cb9 DA |
14073 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
14074 | "no bgp community-list <(1-99)|standard WORD>", | |
14075 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
14076 | "Community list number (standard)\n" | |
14077 | "Add an standard community-list entry\n" | |
14078 | "Community list name\n") | |
14079 | ||
14080 | ALIAS(no_community_list_standard_all, no_ip_community_list_standard_all_list_cmd, | |
14081 | "no ip community-list <(1-99)|standard WORD>", | |
14082 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
14083 | "Community list number (standard)\n" | |
14084 | "Add an standard community-list entry\n" | |
14085 | "Community list name\n") | |
14086 | ||
7336e101 SP |
14087 | /*community-list expanded */ |
14088 | DEFUN (community_list_expanded_all, | |
14089 | bgp_community_list_expanded_all_cmd, | |
14090 | "bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
14091 | BGP_STR | |
14092 | COMMUNITY_LIST_STR | |
718e3744 | 14093 | "Community list number (expanded)\n" |
5bf15956 | 14094 | "Add an expanded community-list entry\n" |
718e3744 | 14095 | "Community list name\n" |
14096 | "Specify community to reject\n" | |
14097 | "Specify community to accept\n" | |
14098 | COMMUNITY_VAL_STR) | |
14099 | { | |
d62a17ae | 14100 | char *cl_name_or_number = NULL; |
14101 | int direct = 0; | |
14102 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 14103 | |
d62a17ae | 14104 | int idx = 0; |
7336e101 SP |
14105 | if (argv_find(argv, argc, "ip", &idx)) { |
14106 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14107 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14108 | vty_out(vty, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n"); | |
14109 | zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used"); | |
14110 | } | |
d62a17ae | 14111 | argv_find(argv, argc, "(100-500)", &idx); |
14112 | argv_find(argv, argc, "WORD", &idx); | |
14113 | cl_name_or_number = argv[idx]->arg; | |
14114 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14115 | : COMMUNITY_DENY; | |
14116 | argv_find(argv, argc, "AA:NN", &idx); | |
14117 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14118 | |
d62a17ae | 14119 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
14120 | style); | |
42f914d4 | 14121 | |
d62a17ae | 14122 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14123 | |
d62a17ae | 14124 | if (ret < 0) { |
14125 | /* Display error string. */ | |
14126 | community_list_perror(vty, ret); | |
14127 | return CMD_WARNING_CONFIG_FAILED; | |
14128 | } | |
42f914d4 | 14129 | |
d62a17ae | 14130 | return CMD_SUCCESS; |
718e3744 | 14131 | } |
14132 | ||
7336e101 SP |
14133 | ALIAS (community_list_expanded_all, |
14134 | ip_community_list_expanded_all_cmd, | |
14135 | "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
718e3744 | 14136 | IP_STR |
14137 | COMMUNITY_LIST_STR | |
5bf15956 DW |
14138 | "Community list number (expanded)\n" |
14139 | "Add an expanded community-list entry\n" | |
718e3744 | 14140 | "Community list name\n" |
14141 | "Specify community to reject\n" | |
14142 | "Specify community to accept\n" | |
5bf15956 | 14143 | COMMUNITY_VAL_STR) |
7336e101 SP |
14144 | |
14145 | DEFUN (no_community_list_expanded_all, | |
14146 | no_bgp_community_list_expanded_all_cmd, | |
14147 | "no bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
14148 | NO_STR | |
14149 | BGP_STR | |
14150 | COMMUNITY_LIST_STR | |
14151 | "Community list number (expanded)\n" | |
14152 | "Add an expanded community-list entry\n" | |
14153 | "Community list name\n" | |
14154 | "Specify community to reject\n" | |
14155 | "Specify community to accept\n" | |
14156 | COMMUNITY_VAL_STR) | |
718e3744 | 14157 | { |
d62a17ae | 14158 | char *cl_name_or_number = NULL; |
174b5cb9 | 14159 | char *str = NULL; |
d62a17ae | 14160 | int direct = 0; |
14161 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 14162 | |
d62a17ae | 14163 | int idx = 0; |
7336e101 SP |
14164 | if (argv_find(argv, argc, "ip", &idx)) { |
14165 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14166 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
174b5cb9 DA |
14167 | vty_out(vty, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n"); |
14168 | zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used"); | |
14169 | } | |
14170 | ||
3c4b8fe2 | 14171 | idx = 0; |
174b5cb9 DA |
14172 | argv_find(argv, argc, "permit", &idx); |
14173 | argv_find(argv, argc, "deny", &idx); | |
14174 | ||
14175 | if (idx) { | |
14176 | direct = argv_find(argv, argc, "permit", &idx) | |
14177 | ? COMMUNITY_PERMIT | |
14178 | : COMMUNITY_DENY; | |
14179 | ||
14180 | idx = 0; | |
14181 | argv_find(argv, argc, "AA:NN", &idx); | |
14182 | str = argv_concat(argv, argc, idx); | |
7336e101 | 14183 | } |
174b5cb9 DA |
14184 | |
14185 | idx = 0; | |
d62a17ae | 14186 | argv_find(argv, argc, "(100-500)", &idx); |
14187 | argv_find(argv, argc, "WORD", &idx); | |
14188 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 14189 | |
d62a17ae | 14190 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
7298a8e1 | 14191 | direct, style); |
42f914d4 | 14192 | |
d62a17ae | 14193 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 14194 | |
d62a17ae | 14195 | if (ret < 0) { |
14196 | community_list_perror(vty, ret); | |
14197 | return CMD_WARNING_CONFIG_FAILED; | |
14198 | } | |
42f914d4 | 14199 | |
d62a17ae | 14200 | return CMD_SUCCESS; |
718e3744 | 14201 | } |
14202 | ||
7336e101 SP |
14203 | ALIAS (no_community_list_expanded_all, |
14204 | no_ip_community_list_expanded_all_cmd, | |
14205 | "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
14206 | NO_STR | |
14207 | IP_STR | |
14208 | COMMUNITY_LIST_STR | |
14209 | "Community list number (expanded)\n" | |
14210 | "Add an expanded community-list entry\n" | |
14211 | "Community list name\n" | |
14212 | "Specify community to reject\n" | |
14213 | "Specify community to accept\n" | |
14214 | COMMUNITY_VAL_STR) | |
14215 | ||
174b5cb9 DA |
14216 | ALIAS(no_community_list_expanded_all, no_bgp_community_list_expanded_all_list_cmd, |
14217 | "no bgp community-list <(100-500)|expanded WORD>", | |
14218 | NO_STR IP_STR COMMUNITY_LIST_STR | |
14219 | "Community list number (expanded)\n" | |
14220 | "Add an expanded community-list entry\n" | |
14221 | "Community list name\n") | |
14222 | ||
14223 | ALIAS(no_community_list_expanded_all, no_ip_community_list_expanded_all_list_cmd, | |
14224 | "no ip community-list <(100-500)|expanded WORD>", | |
14225 | NO_STR IP_STR COMMUNITY_LIST_STR | |
14226 | "Community list number (expanded)\n" | |
14227 | "Add an expanded community-list entry\n" | |
14228 | "Community list name\n") | |
14229 | ||
8d9b8ed9 PM |
14230 | /* Return configuration string of community-list entry. */ |
14231 | static const char *community_list_config_str(struct community_entry *entry) | |
14232 | { | |
14233 | const char *str; | |
14234 | ||
14235 | if (entry->any) | |
14236 | str = ""; | |
14237 | else { | |
14238 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
14239 | str = community_str(entry->u.com, false); | |
14240 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
14241 | str = lcommunity_str(entry->u.lcom, false); | |
14242 | else | |
14243 | str = entry->config; | |
14244 | } | |
14245 | return str; | |
14246 | } | |
14247 | ||
d62a17ae | 14248 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 14249 | { |
d62a17ae | 14250 | struct community_entry *entry; |
718e3744 | 14251 | |
d62a17ae | 14252 | for (entry = list->head; entry; entry = entry->next) { |
14253 | if (entry == list->head) { | |
14254 | if (all_digit(list->name)) | |
14255 | vty_out(vty, "Community %s list %s\n", | |
14256 | entry->style == COMMUNITY_LIST_STANDARD | |
14257 | ? "standard" | |
14258 | : "(expanded) access", | |
14259 | list->name); | |
14260 | else | |
14261 | vty_out(vty, "Named Community %s list %s\n", | |
14262 | entry->style == COMMUNITY_LIST_STANDARD | |
14263 | ? "standard" | |
14264 | : "expanded", | |
14265 | list->name); | |
14266 | } | |
14267 | if (entry->any) | |
14268 | vty_out(vty, " %s\n", | |
14269 | community_direct_str(entry->direct)); | |
14270 | else | |
14271 | vty_out(vty, " %s %s\n", | |
14272 | community_direct_str(entry->direct), | |
8d9b8ed9 | 14273 | community_list_config_str(entry)); |
d62a17ae | 14274 | } |
718e3744 | 14275 | } |
14276 | ||
7336e101 SP |
14277 | DEFUN (show_community_list, |
14278 | show_bgp_community_list_cmd, | |
14279 | "show bgp community-list", | |
718e3744 | 14280 | SHOW_STR |
7336e101 | 14281 | BGP_STR |
718e3744 | 14282 | "List community-list\n") |
14283 | { | |
d62a17ae | 14284 | struct community_list *list; |
14285 | struct community_list_master *cm; | |
718e3744 | 14286 | |
7336e101 SP |
14287 | int idx = 0; |
14288 | if (argv_find(argv, argc, "ip", &idx)) { | |
14289 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14290 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14291 | vty_out(vty, "'show bgp community-list <(1-500)|WORD>'\n"); | |
14292 | zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used"); | |
14293 | } | |
d62a17ae | 14294 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
14295 | if (!cm) | |
14296 | return CMD_SUCCESS; | |
718e3744 | 14297 | |
d62a17ae | 14298 | for (list = cm->num.head; list; list = list->next) |
14299 | community_list_show(vty, list); | |
718e3744 | 14300 | |
d62a17ae | 14301 | for (list = cm->str.head; list; list = list->next) |
14302 | community_list_show(vty, list); | |
718e3744 | 14303 | |
d62a17ae | 14304 | return CMD_SUCCESS; |
718e3744 | 14305 | } |
14306 | ||
7336e101 SP |
14307 | ALIAS (show_community_list, |
14308 | show_ip_community_list_cmd, | |
14309 | "show ip community-list", | |
718e3744 | 14310 | SHOW_STR |
14311 | IP_STR | |
7336e101 SP |
14312 | "List community-list\n") |
14313 | ||
14314 | DEFUN (show_community_list_arg, | |
14315 | show_bgp_community_list_arg_cmd, | |
14316 | "show bgp community-list <(1-500)|WORD>", | |
14317 | SHOW_STR | |
14318 | BGP_STR | |
718e3744 | 14319 | "List community-list\n" |
14320 | "Community-list number\n" | |
14321 | "Community-list name\n") | |
14322 | { | |
d62a17ae | 14323 | int idx_comm_list = 3; |
14324 | struct community_list *list; | |
718e3744 | 14325 | |
7336e101 SP |
14326 | int idx = 0; |
14327 | if (argv_find(argv, argc, "ip", &idx)) { | |
14328 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14329 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14330 | vty_out(vty, "'show bgp community-list <(1-500)|WORD>'\n"); | |
14331 | zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used"); | |
14332 | } | |
e237b0d2 | 14333 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 14334 | COMMUNITY_LIST_MASTER); |
14335 | if (!list) { | |
14336 | vty_out(vty, "%% Can't find community-list\n"); | |
14337 | return CMD_WARNING; | |
14338 | } | |
718e3744 | 14339 | |
d62a17ae | 14340 | community_list_show(vty, list); |
718e3744 | 14341 | |
d62a17ae | 14342 | return CMD_SUCCESS; |
718e3744 | 14343 | } |
6b0655a2 | 14344 | |
7336e101 SP |
14345 | ALIAS (show_community_list_arg, |
14346 | show_ip_community_list_arg_cmd, | |
14347 | "show ip community-list <(1-500)|WORD>", | |
14348 | SHOW_STR | |
14349 | IP_STR | |
14350 | "List community-list\n" | |
14351 | "Community-list number\n" | |
14352 | "Community-list name\n") | |
14353 | ||
57d187bc JS |
14354 | /* |
14355 | * Large Community code. | |
14356 | */ | |
d62a17ae | 14357 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
14358 | struct cmd_token **argv, int style, | |
14359 | int reject_all_digit_name) | |
14360 | { | |
14361 | int ret; | |
14362 | int direct; | |
14363 | char *str; | |
14364 | int idx = 0; | |
14365 | char *cl_name; | |
14366 | ||
7336e101 SP |
14367 | if (argv_find(argv, argc, "ip", &idx)) { |
14368 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14369 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14370 | vty_out(vty, "'bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n"); | |
14371 | zlog_warn("Deprecated option: 'large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used"); | |
14372 | } | |
d62a17ae | 14373 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
14374 | : COMMUNITY_DENY; | |
14375 | ||
14376 | /* All digit name check. */ | |
14377 | idx = 0; | |
14378 | argv_find(argv, argc, "WORD", &idx); | |
14379 | argv_find(argv, argc, "(1-99)", &idx); | |
14380 | argv_find(argv, argc, "(100-500)", &idx); | |
14381 | cl_name = argv[idx]->arg; | |
14382 | if (reject_all_digit_name && all_digit(cl_name)) { | |
14383 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
14384 | return CMD_WARNING_CONFIG_FAILED; | |
14385 | } | |
14386 | ||
14387 | idx = 0; | |
14388 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
14389 | argv_find(argv, argc, "LINE", &idx); | |
14390 | /* Concat community string argument. */ | |
14391 | if (idx) | |
14392 | str = argv_concat(argv, argc, idx); | |
14393 | else | |
14394 | str = NULL; | |
14395 | ||
14396 | ret = lcommunity_list_set(bgp_clist, cl_name, str, direct, style); | |
14397 | ||
14398 | /* Free temporary community list string allocated by | |
14399 | argv_concat(). */ | |
14400 | if (str) | |
14401 | XFREE(MTYPE_TMP, str); | |
14402 | ||
14403 | if (ret < 0) { | |
14404 | community_list_perror(vty, ret); | |
14405 | return CMD_WARNING_CONFIG_FAILED; | |
14406 | } | |
14407 | return CMD_SUCCESS; | |
14408 | } | |
14409 | ||
14410 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
14411 | struct cmd_token **argv, int style) | |
14412 | { | |
14413 | int ret; | |
14414 | int direct = 0; | |
14415 | char *str = NULL; | |
14416 | int idx = 0; | |
14417 | ||
7336e101 SP |
14418 | if (argv_find(argv, argc, "ip", &idx)) { |
14419 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14420 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14421 | vty_out(vty, "'no bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n"); | |
14422 | zlog_warn("Deprecated option: 'no ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used"); | |
14423 | } | |
d62a17ae | 14424 | argv_find(argv, argc, "permit", &idx); |
14425 | argv_find(argv, argc, "deny", &idx); | |
14426 | ||
14427 | if (idx) { | |
14428 | /* Check the list direct. */ | |
14429 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
14430 | direct = COMMUNITY_PERMIT; | |
14431 | else | |
14432 | direct = COMMUNITY_DENY; | |
14433 | ||
14434 | idx = 0; | |
14435 | argv_find(argv, argc, "LINE", &idx); | |
14436 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
14437 | /* Concat community string argument. */ | |
14438 | str = argv_concat(argv, argc, idx); | |
14439 | } | |
14440 | ||
14441 | idx = 0; | |
14442 | argv_find(argv, argc, "(1-99)", &idx); | |
14443 | argv_find(argv, argc, "(100-500)", &idx); | |
14444 | argv_find(argv, argc, "WORD", &idx); | |
14445 | ||
14446 | /* Unset community list. */ | |
14447 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, direct, | |
14448 | style); | |
14449 | ||
14450 | /* Free temporary community list string allocated by | |
14451 | argv_concat(). */ | |
14452 | if (str) | |
14453 | XFREE(MTYPE_TMP, str); | |
14454 | ||
14455 | if (ret < 0) { | |
14456 | community_list_perror(vty, ret); | |
14457 | return CMD_WARNING_CONFIG_FAILED; | |
14458 | } | |
14459 | ||
14460 | return CMD_SUCCESS; | |
57d187bc JS |
14461 | } |
14462 | ||
14463 | /* "large-community-list" keyword help string. */ | |
14464 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
14465 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
14466 | ||
7336e101 SP |
14467 | #if CONFDATE > 20191005 |
14468 | CPP_NOTICE("bgpd: remove deprecated 'ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' command") | |
14469 | #endif | |
14470 | DEFUN (lcommunity_list_standard, | |
14471 | bgp_lcommunity_list_standard_cmd, | |
14472 | "bgp large-community-list (1-99) <deny|permit>", | |
14473 | BGP_STR | |
14474 | LCOMMUNITY_LIST_STR | |
14475 | "Large Community list number (standard)\n" | |
14476 | "Specify large community to reject\n" | |
14477 | "Specify large community to accept\n") | |
14478 | { | |
14479 | return lcommunity_list_set_vty(vty, argc, argv, | |
14480 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
14481 | } | |
14482 | ||
14483 | ALIAS (lcommunity_list_standard, | |
57d187bc | 14484 | ip_lcommunity_list_standard_cmd, |
52951b63 DS |
14485 | "ip large-community-list (1-99) <deny|permit>", |
14486 | IP_STR | |
14487 | LCOMMUNITY_LIST_STR | |
14488 | "Large Community list number (standard)\n" | |
14489 | "Specify large community to reject\n" | |
7111c1a0 | 14490 | "Specify large community to accept\n") |
7336e101 SP |
14491 | |
14492 | DEFUN (lcommunity_list_standard1, | |
14493 | bgp_lcommunity_list_standard1_cmd, | |
14494 | "bgp large-community-list (1-99) <deny|permit> AA:BB:CC...", | |
14495 | BGP_STR | |
14496 | LCOMMUNITY_LIST_STR | |
14497 | "Large Community list number (standard)\n" | |
14498 | "Specify large community to reject\n" | |
14499 | "Specify large community to accept\n" | |
14500 | LCOMMUNITY_VAL_STR) | |
52951b63 | 14501 | { |
d62a17ae | 14502 | return lcommunity_list_set_vty(vty, argc, argv, |
14503 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
14504 | } |
14505 | ||
7336e101 | 14506 | ALIAS (lcommunity_list_standard1, |
52951b63 DS |
14507 | ip_lcommunity_list_standard1_cmd, |
14508 | "ip large-community-list (1-99) <deny|permit> AA:BB:CC...", | |
57d187bc JS |
14509 | IP_STR |
14510 | LCOMMUNITY_LIST_STR | |
14511 | "Large Community list number (standard)\n" | |
14512 | "Specify large community to reject\n" | |
14513 | "Specify large community to accept\n" | |
14514 | LCOMMUNITY_VAL_STR) | |
7336e101 SP |
14515 | |
14516 | DEFUN (lcommunity_list_expanded, | |
14517 | bgp_lcommunity_list_expanded_cmd, | |
14518 | "bgp large-community-list (100-500) <deny|permit> LINE...", | |
14519 | BGP_STR | |
14520 | LCOMMUNITY_LIST_STR | |
14521 | "Large Community list number (expanded)\n" | |
14522 | "Specify large community to reject\n" | |
14523 | "Specify large community to accept\n" | |
14524 | "An ordered list as a regular-expression\n") | |
57d187bc | 14525 | { |
d62a17ae | 14526 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 14527 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
14528 | } |
14529 | ||
7336e101 | 14530 | ALIAS (lcommunity_list_expanded, |
57d187bc JS |
14531 | ip_lcommunity_list_expanded_cmd, |
14532 | "ip large-community-list (100-500) <deny|permit> LINE...", | |
14533 | IP_STR | |
14534 | LCOMMUNITY_LIST_STR | |
14535 | "Large Community list number (expanded)\n" | |
14536 | "Specify large community to reject\n" | |
14537 | "Specify large community to accept\n" | |
14538 | "An ordered list as a regular-expression\n") | |
7336e101 SP |
14539 | |
14540 | DEFUN (lcommunity_list_name_standard, | |
14541 | bgp_lcommunity_list_name_standard_cmd, | |
14542 | "bgp large-community-list standard WORD <deny|permit>", | |
14543 | BGP_STR | |
14544 | LCOMMUNITY_LIST_STR | |
14545 | "Specify standard large-community-list\n" | |
14546 | "Large Community list name\n" | |
14547 | "Specify large community to reject\n" | |
14548 | "Specify large community to accept\n") | |
57d187bc | 14549 | { |
d62a17ae | 14550 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 14551 | LARGE_COMMUNITY_LIST_STANDARD, 1); |
57d187bc JS |
14552 | } |
14553 | ||
7336e101 | 14554 | ALIAS (lcommunity_list_name_standard, |
57d187bc | 14555 | ip_lcommunity_list_name_standard_cmd, |
52951b63 DS |
14556 | "ip large-community-list standard WORD <deny|permit>", |
14557 | IP_STR | |
14558 | LCOMMUNITY_LIST_STR | |
14559 | "Specify standard large-community-list\n" | |
14560 | "Large Community list name\n" | |
14561 | "Specify large community to reject\n" | |
14562 | "Specify large community to accept\n") | |
7336e101 SP |
14563 | |
14564 | DEFUN (lcommunity_list_name_standard1, | |
14565 | bgp_lcommunity_list_name_standard1_cmd, | |
14566 | "bgp large-community-list standard WORD <deny|permit> AA:BB:CC...", | |
14567 | BGP_STR | |
14568 | LCOMMUNITY_LIST_STR | |
14569 | "Specify standard large-community-list\n" | |
14570 | "Large Community list name\n" | |
14571 | "Specify large community to reject\n" | |
14572 | "Specify large community to accept\n" | |
14573 | LCOMMUNITY_VAL_STR) | |
52951b63 | 14574 | { |
d62a17ae | 14575 | return lcommunity_list_set_vty(vty, argc, argv, |
14576 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
14577 | } |
14578 | ||
7336e101 | 14579 | ALIAS (lcommunity_list_name_standard1, |
52951b63 DS |
14580 | ip_lcommunity_list_name_standard1_cmd, |
14581 | "ip large-community-list standard WORD <deny|permit> AA:BB:CC...", | |
57d187bc JS |
14582 | IP_STR |
14583 | LCOMMUNITY_LIST_STR | |
14584 | "Specify standard large-community-list\n" | |
14585 | "Large Community list name\n" | |
14586 | "Specify large community to reject\n" | |
14587 | "Specify large community to accept\n" | |
14588 | LCOMMUNITY_VAL_STR) | |
7336e101 SP |
14589 | |
14590 | DEFUN (lcommunity_list_name_expanded, | |
14591 | bgp_lcommunity_list_name_expanded_cmd, | |
14592 | "bgp large-community-list expanded WORD <deny|permit> LINE...", | |
14593 | BGP_STR | |
14594 | LCOMMUNITY_LIST_STR | |
14595 | "Specify expanded large-community-list\n" | |
14596 | "Large Community list name\n" | |
14597 | "Specify large community to reject\n" | |
14598 | "Specify large community to accept\n" | |
14599 | "An ordered list as a regular-expression\n") | |
57d187bc | 14600 | { |
d62a17ae | 14601 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 14602 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
14603 | } |
14604 | ||
7336e101 | 14605 | ALIAS (lcommunity_list_name_expanded, |
57d187bc JS |
14606 | ip_lcommunity_list_name_expanded_cmd, |
14607 | "ip large-community-list expanded WORD <deny|permit> LINE...", | |
14608 | IP_STR | |
14609 | LCOMMUNITY_LIST_STR | |
14610 | "Specify expanded large-community-list\n" | |
14611 | "Large Community list name\n" | |
14612 | "Specify large community to reject\n" | |
14613 | "Specify large community to accept\n" | |
14614 | "An ordered list as a regular-expression\n") | |
7336e101 SP |
14615 | |
14616 | DEFUN (no_lcommunity_list_standard_all, | |
14617 | no_bgp_lcommunity_list_standard_all_cmd, | |
14618 | "no bgp large-community-list <(1-99)|(100-500)|WORD>", | |
14619 | NO_STR | |
14620 | BGP_STR | |
14621 | LCOMMUNITY_LIST_STR | |
14622 | "Large Community list number (standard)\n" | |
14623 | "Large Community list number (expanded)\n" | |
14624 | "Large Community list name\n") | |
57d187bc | 14625 | { |
7336e101 SP |
14626 | return lcommunity_list_unset_vty(vty, argc, argv, |
14627 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
14628 | } |
14629 | ||
7336e101 | 14630 | ALIAS (no_lcommunity_list_standard_all, |
57d187bc JS |
14631 | no_ip_lcommunity_list_standard_all_cmd, |
14632 | "no ip large-community-list <(1-99)|(100-500)|WORD>", | |
14633 | NO_STR | |
14634 | IP_STR | |
14635 | LCOMMUNITY_LIST_STR | |
14636 | "Large Community list number (standard)\n" | |
14637 | "Large Community list number (expanded)\n" | |
14638 | "Large Community list name\n") | |
7336e101 SP |
14639 | |
14640 | DEFUN (no_lcommunity_list_name_expanded_all, | |
14641 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
14642 | "no bgp large-community-list expanded WORD", | |
14643 | NO_STR | |
14644 | BGP_STR | |
14645 | LCOMMUNITY_LIST_STR | |
14646 | "Specify expanded large-community-list\n" | |
14647 | "Large Community list name\n") | |
57d187bc | 14648 | { |
d62a17ae | 14649 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14650 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
14651 | } |
14652 | ||
7336e101 | 14653 | ALIAS (no_lcommunity_list_name_expanded_all, |
57d187bc JS |
14654 | no_ip_lcommunity_list_name_expanded_all_cmd, |
14655 | "no ip large-community-list expanded WORD", | |
14656 | NO_STR | |
14657 | IP_STR | |
14658 | LCOMMUNITY_LIST_STR | |
14659 | "Specify expanded large-community-list\n" | |
14660 | "Large Community list name\n") | |
7336e101 SP |
14661 | |
14662 | DEFUN (no_lcommunity_list_standard, | |
14663 | no_bgp_lcommunity_list_standard_cmd, | |
14664 | "no bgp large-community-list (1-99) <deny|permit> AA:AA:NN...", | |
14665 | NO_STR | |
14666 | BGP_STR | |
14667 | LCOMMUNITY_LIST_STR | |
14668 | "Large Community list number (standard)\n" | |
14669 | "Specify large community to reject\n" | |
14670 | "Specify large community to accept\n" | |
14671 | LCOMMUNITY_VAL_STR) | |
57d187bc | 14672 | { |
d62a17ae | 14673 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14674 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
14675 | } |
14676 | ||
7336e101 | 14677 | ALIAS (no_lcommunity_list_standard, |
57d187bc JS |
14678 | no_ip_lcommunity_list_standard_cmd, |
14679 | "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...", | |
14680 | NO_STR | |
14681 | IP_STR | |
14682 | LCOMMUNITY_LIST_STR | |
14683 | "Large Community list number (standard)\n" | |
14684 | "Specify large community to reject\n" | |
14685 | "Specify large community to accept\n" | |
14686 | LCOMMUNITY_VAL_STR) | |
7336e101 SP |
14687 | |
14688 | DEFUN (no_lcommunity_list_expanded, | |
14689 | no_bgp_lcommunity_list_expanded_cmd, | |
14690 | "no bgp large-community-list (100-500) <deny|permit> LINE...", | |
14691 | NO_STR | |
14692 | BGP_STR | |
14693 | LCOMMUNITY_LIST_STR | |
14694 | "Large Community list number (expanded)\n" | |
14695 | "Specify large community to reject\n" | |
14696 | "Specify large community to accept\n" | |
14697 | "An ordered list as a regular-expression\n") | |
57d187bc | 14698 | { |
d62a17ae | 14699 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14700 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
14701 | } |
14702 | ||
7336e101 | 14703 | ALIAS (no_lcommunity_list_expanded, |
57d187bc JS |
14704 | no_ip_lcommunity_list_expanded_cmd, |
14705 | "no ip large-community-list (100-500) <deny|permit> LINE...", | |
14706 | NO_STR | |
14707 | IP_STR | |
14708 | LCOMMUNITY_LIST_STR | |
14709 | "Large Community list number (expanded)\n" | |
14710 | "Specify large community to reject\n" | |
14711 | "Specify large community to accept\n" | |
14712 | "An ordered list as a regular-expression\n") | |
7336e101 SP |
14713 | |
14714 | DEFUN (no_lcommunity_list_name_standard, | |
14715 | no_bgp_lcommunity_list_name_standard_cmd, | |
14716 | "no bgp large-community-list standard WORD <deny|permit> AA:AA:NN...", | |
14717 | NO_STR | |
14718 | BGP_STR | |
14719 | LCOMMUNITY_LIST_STR | |
14720 | "Specify standard large-community-list\n" | |
14721 | "Large Community list name\n" | |
14722 | "Specify large community to reject\n" | |
14723 | "Specify large community to accept\n" | |
14724 | LCOMMUNITY_VAL_STR) | |
57d187bc | 14725 | { |
d62a17ae | 14726 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14727 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
14728 | } |
14729 | ||
7336e101 | 14730 | ALIAS (no_lcommunity_list_name_standard, |
57d187bc JS |
14731 | no_ip_lcommunity_list_name_standard_cmd, |
14732 | "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...", | |
14733 | NO_STR | |
14734 | IP_STR | |
14735 | LCOMMUNITY_LIST_STR | |
14736 | "Specify standard large-community-list\n" | |
14737 | "Large Community list name\n" | |
14738 | "Specify large community to reject\n" | |
14739 | "Specify large community to accept\n" | |
14740 | LCOMMUNITY_VAL_STR) | |
7336e101 SP |
14741 | |
14742 | DEFUN (no_lcommunity_list_name_expanded, | |
14743 | no_bgp_lcommunity_list_name_expanded_cmd, | |
14744 | "no bgp large-community-list expanded WORD <deny|permit> LINE...", | |
14745 | NO_STR | |
14746 | BGP_STR | |
14747 | LCOMMUNITY_LIST_STR | |
14748 | "Specify expanded large-community-list\n" | |
14749 | "Large community list name\n" | |
14750 | "Specify large community to reject\n" | |
14751 | "Specify large community to accept\n" | |
14752 | "An ordered list as a regular-expression\n") | |
57d187bc | 14753 | { |
d62a17ae | 14754 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14755 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
14756 | } |
14757 | ||
7336e101 | 14758 | ALIAS (no_lcommunity_list_name_expanded, |
57d187bc JS |
14759 | no_ip_lcommunity_list_name_expanded_cmd, |
14760 | "no ip large-community-list expanded WORD <deny|permit> LINE...", | |
14761 | NO_STR | |
14762 | IP_STR | |
14763 | LCOMMUNITY_LIST_STR | |
14764 | "Specify expanded large-community-list\n" | |
14765 | "Large community list name\n" | |
14766 | "Specify large community to reject\n" | |
14767 | "Specify large community to accept\n" | |
14768 | "An ordered list as a regular-expression\n") | |
d62a17ae | 14769 | |
14770 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) | |
14771 | { | |
14772 | struct community_entry *entry; | |
14773 | ||
14774 | for (entry = list->head; entry; entry = entry->next) { | |
14775 | if (entry == list->head) { | |
14776 | if (all_digit(list->name)) | |
14777 | vty_out(vty, "Large community %s list %s\n", | |
14778 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
14779 | ? "standard" | |
14780 | : "(expanded) access", | |
14781 | list->name); | |
14782 | else | |
14783 | vty_out(vty, | |
14784 | "Named large community %s list %s\n", | |
14785 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
14786 | ? "standard" | |
14787 | : "expanded", | |
14788 | list->name); | |
14789 | } | |
14790 | if (entry->any) | |
14791 | vty_out(vty, " %s\n", | |
14792 | community_direct_str(entry->direct)); | |
14793 | else | |
14794 | vty_out(vty, " %s %s\n", | |
14795 | community_direct_str(entry->direct), | |
8d9b8ed9 | 14796 | community_list_config_str(entry)); |
d62a17ae | 14797 | } |
57d187bc JS |
14798 | } |
14799 | ||
7336e101 SP |
14800 | DEFUN (show_lcommunity_list, |
14801 | show_bgp_lcommunity_list_cmd, | |
14802 | "show bgp large-community-list", | |
57d187bc | 14803 | SHOW_STR |
7336e101 | 14804 | BGP_STR |
57d187bc JS |
14805 | "List large-community list\n") |
14806 | { | |
d62a17ae | 14807 | struct community_list *list; |
14808 | struct community_list_master *cm; | |
7336e101 SP |
14809 | int idx = 0; |
14810 | ||
14811 | if (argv_find(argv, argc, "ip", &idx)) { | |
14812 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14813 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14814 | vty_out(vty, "'show bgp large-community-list <(1-500)|WORD>'\n"); | |
14815 | zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used"); | |
14816 | } | |
57d187bc | 14817 | |
d62a17ae | 14818 | cm = community_list_master_lookup(bgp_clist, |
14819 | LARGE_COMMUNITY_LIST_MASTER); | |
14820 | if (!cm) | |
14821 | return CMD_SUCCESS; | |
57d187bc | 14822 | |
d62a17ae | 14823 | for (list = cm->num.head; list; list = list->next) |
14824 | lcommunity_list_show(vty, list); | |
57d187bc | 14825 | |
d62a17ae | 14826 | for (list = cm->str.head; list; list = list->next) |
14827 | lcommunity_list_show(vty, list); | |
57d187bc | 14828 | |
d62a17ae | 14829 | return CMD_SUCCESS; |
57d187bc JS |
14830 | } |
14831 | ||
7336e101 SP |
14832 | ALIAS (show_lcommunity_list, |
14833 | show_ip_lcommunity_list_cmd, | |
14834 | "show ip large-community-list", | |
57d187bc JS |
14835 | SHOW_STR |
14836 | IP_STR | |
7336e101 SP |
14837 | "List large-community list\n") |
14838 | ||
14839 | DEFUN (show_lcommunity_list_arg, | |
14840 | show_bgp_lcommunity_list_arg_cmd, | |
14841 | "show bgp large-community-list <(1-500)|WORD>", | |
14842 | SHOW_STR | |
14843 | BGP_STR | |
57d187bc JS |
14844 | "List large-community list\n" |
14845 | "large-community-list number\n" | |
14846 | "large-community-list name\n") | |
14847 | { | |
d62a17ae | 14848 | struct community_list *list; |
7336e101 SP |
14849 | int idx = 0; |
14850 | ||
14851 | if (argv_find(argv, argc, "ip", &idx)) { | |
14852 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14853 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14854 | vty_out(vty, "'show bgp large-community-list <(1-500)|WORD>'\n"); | |
14855 | zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used"); | |
14856 | } | |
57d187bc | 14857 | |
e237b0d2 | 14858 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, |
d62a17ae | 14859 | LARGE_COMMUNITY_LIST_MASTER); |
14860 | if (!list) { | |
14861 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
14862 | return CMD_WARNING; | |
14863 | } | |
57d187bc | 14864 | |
d62a17ae | 14865 | lcommunity_list_show(vty, list); |
57d187bc | 14866 | |
d62a17ae | 14867 | return CMD_SUCCESS; |
57d187bc JS |
14868 | } |
14869 | ||
7336e101 SP |
14870 | ALIAS (show_lcommunity_list_arg, |
14871 | show_ip_lcommunity_list_arg_cmd, | |
14872 | "show ip large-community-list <(1-500)|WORD>", | |
14873 | SHOW_STR | |
14874 | IP_STR | |
14875 | "List large-community list\n" | |
14876 | "large-community-list number\n" | |
14877 | "large-community-list name\n") | |
14878 | ||
718e3744 | 14879 | /* "extcommunity-list" keyword help string. */ |
14880 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
14881 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
14882 | ||
7336e101 SP |
14883 | DEFUN (extcommunity_list_standard, |
14884 | bgp_extcommunity_list_standard_cmd, | |
14885 | "bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
14886 | BGP_STR | |
718e3744 | 14887 | EXTCOMMUNITY_LIST_STR |
14888 | "Extended Community list number (standard)\n" | |
718e3744 | 14889 | "Specify standard extcommunity-list\n" |
5bf15956 | 14890 | "Community list name\n" |
718e3744 | 14891 | "Specify community to reject\n" |
14892 | "Specify community to accept\n" | |
14893 | EXTCOMMUNITY_VAL_STR) | |
14894 | { | |
d62a17ae | 14895 | int style = EXTCOMMUNITY_LIST_STANDARD; |
14896 | int direct = 0; | |
14897 | char *cl_number_or_name = NULL; | |
42f914d4 | 14898 | |
d62a17ae | 14899 | int idx = 0; |
7336e101 SP |
14900 | if (argv_find(argv, argc, "ip", &idx)) { |
14901 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14902 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14903 | vty_out(vty, "'bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n"); | |
14904 | zlog_warn("Deprecated option: 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used"); | |
14905 | } | |
d62a17ae | 14906 | argv_find(argv, argc, "(1-99)", &idx); |
14907 | argv_find(argv, argc, "WORD", &idx); | |
14908 | cl_number_or_name = argv[idx]->arg; | |
14909 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14910 | : COMMUNITY_DENY; | |
14911 | argv_find(argv, argc, "AA:NN", &idx); | |
14912 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14913 | |
d62a17ae | 14914 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
14915 | direct, style); | |
42f914d4 | 14916 | |
d62a17ae | 14917 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14918 | |
d62a17ae | 14919 | if (ret < 0) { |
14920 | community_list_perror(vty, ret); | |
14921 | return CMD_WARNING_CONFIG_FAILED; | |
14922 | } | |
42f914d4 | 14923 | |
d62a17ae | 14924 | return CMD_SUCCESS; |
718e3744 | 14925 | } |
14926 | ||
7336e101 SP |
14927 | #if CONFDATE > 20191005 |
14928 | CPP_NOTICE("bgpd: remove deprecated 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' command") | |
14929 | #endif | |
14930 | ALIAS (extcommunity_list_standard, | |
14931 | ip_extcommunity_list_standard_cmd, | |
14932 | "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
718e3744 | 14933 | IP_STR |
14934 | EXTCOMMUNITY_LIST_STR | |
7336e101 SP |
14935 | "Extended Community list number (standard)\n" |
14936 | "Specify standard extcommunity-list\n" | |
14937 | "Community list name\n" | |
14938 | "Specify community to reject\n" | |
14939 | "Specify community to accept\n" | |
14940 | EXTCOMMUNITY_VAL_STR) | |
14941 | ||
14942 | DEFUN (extcommunity_list_name_expanded, | |
14943 | bgp_extcommunity_list_name_expanded_cmd, | |
14944 | "bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
14945 | BGP_STR | |
14946 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 14947 | "Extended Community list number (expanded)\n" |
718e3744 | 14948 | "Specify expanded extcommunity-list\n" |
14949 | "Extended Community list name\n" | |
14950 | "Specify community to reject\n" | |
14951 | "Specify community to accept\n" | |
14952 | "An ordered list as a regular-expression\n") | |
14953 | { | |
d62a17ae | 14954 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
14955 | int direct = 0; | |
14956 | char *cl_number_or_name = NULL; | |
42f914d4 | 14957 | |
d62a17ae | 14958 | int idx = 0; |
7336e101 SP |
14959 | if (argv_find(argv, argc, "ip", &idx)) { |
14960 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14961 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14962 | vty_out(vty, "'extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n"); | |
14963 | zlog_warn("Deprecated option: ‘ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used"); | |
14964 | } | |
14965 | ||
d62a17ae | 14966 | argv_find(argv, argc, "(100-500)", &idx); |
14967 | argv_find(argv, argc, "WORD", &idx); | |
14968 | cl_number_or_name = argv[idx]->arg; | |
14969 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14970 | : COMMUNITY_DENY; | |
14971 | argv_find(argv, argc, "LINE", &idx); | |
14972 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14973 | |
d62a17ae | 14974 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
14975 | direct, style); | |
42f914d4 | 14976 | |
d62a17ae | 14977 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14978 | |
d62a17ae | 14979 | if (ret < 0) { |
14980 | community_list_perror(vty, ret); | |
14981 | return CMD_WARNING_CONFIG_FAILED; | |
14982 | } | |
42f914d4 | 14983 | |
d62a17ae | 14984 | return CMD_SUCCESS; |
718e3744 | 14985 | } |
14986 | ||
7336e101 SP |
14987 | ALIAS (extcommunity_list_name_expanded, |
14988 | ip_extcommunity_list_name_expanded_cmd, | |
14989 | "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
813d4307 DW |
14990 | IP_STR |
14991 | EXTCOMMUNITY_LIST_STR | |
7336e101 SP |
14992 | "Extended Community list number (expanded)\n" |
14993 | "Specify expanded extcommunity-list\n" | |
14994 | "Extended Community list name\n" | |
14995 | "Specify community to reject\n" | |
14996 | "Specify community to accept\n" | |
14997 | "An ordered list as a regular-expression\n") | |
14998 | ||
14999 | DEFUN (no_extcommunity_list_standard_all, | |
15000 | no_bgp_extcommunity_list_standard_all_cmd, | |
15001 | "no bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
15002 | NO_STR | |
15003 | BGP_STR | |
15004 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 15005 | "Extended Community list number (standard)\n" |
718e3744 | 15006 | "Specify standard extcommunity-list\n" |
5bf15956 | 15007 | "Community list name\n" |
718e3744 | 15008 | "Specify community to reject\n" |
15009 | "Specify community to accept\n" | |
15010 | EXTCOMMUNITY_VAL_STR) | |
15011 | { | |
d62a17ae | 15012 | int style = EXTCOMMUNITY_LIST_STANDARD; |
15013 | int direct = 0; | |
15014 | char *cl_number_or_name = NULL; | |
d4455c89 | 15015 | char *str = NULL; |
42f914d4 | 15016 | |
d62a17ae | 15017 | int idx = 0; |
7336e101 SP |
15018 | if (argv_find(argv, argc, "ip", &idx)) { |
15019 | vty_out(vty, "This config option is deprecated, and is scheduled for removal\n"); | |
15020 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15021 | vty_out(vty, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n"); | |
15022 | zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used"); | |
15023 | } | |
d4455c89 DA |
15024 | |
15025 | idx = 0; | |
15026 | argv_find(argv, argc, "permit", &idx); | |
15027 | argv_find(argv, argc, "deny", &idx); | |
15028 | ||
15029 | if (idx) { | |
15030 | direct = argv_find(argv, argc, "permit", &idx) | |
15031 | ? COMMUNITY_PERMIT | |
15032 | : COMMUNITY_DENY; | |
15033 | ||
15034 | idx = 0; | |
15035 | argv_find(argv, argc, "AA:NN", &idx); | |
15036 | str = argv_concat(argv, argc, idx); | |
15037 | } | |
15038 | ||
15039 | idx = 0; | |
d62a17ae | 15040 | argv_find(argv, argc, "(1-99)", &idx); |
15041 | argv_find(argv, argc, "WORD", &idx); | |
15042 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 15043 | |
d62a17ae | 15044 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
7298a8e1 | 15045 | direct, style); |
42f914d4 | 15046 | |
d62a17ae | 15047 | XFREE(MTYPE_TMP, str); |
42f914d4 | 15048 | |
d62a17ae | 15049 | if (ret < 0) { |
15050 | community_list_perror(vty, ret); | |
15051 | return CMD_WARNING_CONFIG_FAILED; | |
15052 | } | |
42f914d4 | 15053 | |
d62a17ae | 15054 | return CMD_SUCCESS; |
718e3744 | 15055 | } |
15056 | ||
7336e101 SP |
15057 | ALIAS (no_extcommunity_list_standard_all, |
15058 | no_ip_extcommunity_list_standard_all_cmd, | |
15059 | "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
718e3744 | 15060 | NO_STR |
15061 | IP_STR | |
15062 | EXTCOMMUNITY_LIST_STR | |
7336e101 SP |
15063 | "Extended Community list number (standard)\n" |
15064 | "Specify standard extcommunity-list\n" | |
15065 | "Community list name\n" | |
15066 | "Specify community to reject\n" | |
15067 | "Specify community to accept\n" | |
15068 | EXTCOMMUNITY_VAL_STR) | |
15069 | ||
d4455c89 DA |
15070 | ALIAS(no_extcommunity_list_standard_all, |
15071 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
15072 | "no bgp extcommunity-list <(1-99)|standard WORD>", | |
15073 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
15074 | "Extended Community list number (standard)\n" | |
15075 | "Specify standard extcommunity-list\n" | |
15076 | "Community list name\n") | |
15077 | ||
15078 | ALIAS(no_extcommunity_list_standard_all, | |
15079 | no_ip_extcommunity_list_standard_all_list_cmd, | |
15080 | "no ip extcommunity-list <(1-99)|standard WORD>", | |
15081 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
15082 | "Extended Community list number (standard)\n" | |
15083 | "Specify standard extcommunity-list\n" | |
15084 | "Community list name\n") | |
15085 | ||
7336e101 SP |
15086 | DEFUN (no_extcommunity_list_expanded_all, |
15087 | no_bgp_extcommunity_list_expanded_all_cmd, | |
15088 | "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
15089 | NO_STR | |
15090 | BGP_STR | |
15091 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 15092 | "Extended Community list number (expanded)\n" |
718e3744 | 15093 | "Specify expanded extcommunity-list\n" |
5bf15956 | 15094 | "Extended Community list name\n" |
718e3744 | 15095 | "Specify community to reject\n" |
15096 | "Specify community to accept\n" | |
15097 | "An ordered list as a regular-expression\n") | |
15098 | { | |
d62a17ae | 15099 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
15100 | int direct = 0; | |
15101 | char *cl_number_or_name = NULL; | |
d4455c89 | 15102 | char *str = NULL; |
42f914d4 | 15103 | |
d62a17ae | 15104 | int idx = 0; |
7336e101 SP |
15105 | if (argv_find(argv, argc, "ip", &idx)) { |
15106 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
15107 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15108 | vty_out(vty, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n"); | |
15109 | zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used"); | |
15110 | } | |
d4455c89 DA |
15111 | |
15112 | idx = 0; | |
15113 | argv_find(argv, argc, "permit", &idx); | |
15114 | argv_find(argv, argc, "deny", &idx); | |
15115 | ||
15116 | if (idx) { | |
15117 | direct = argv_find(argv, argc, "permit", &idx) | |
15118 | ? COMMUNITY_PERMIT | |
15119 | : COMMUNITY_DENY; | |
15120 | ||
15121 | idx = 0; | |
15122 | argv_find(argv, argc, "LINE", &idx); | |
15123 | str = argv_concat(argv, argc, idx); | |
15124 | } | |
15125 | ||
15126 | idx = 0; | |
d62a17ae | 15127 | argv_find(argv, argc, "(100-500)", &idx); |
15128 | argv_find(argv, argc, "WORD", &idx); | |
15129 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 15130 | |
d62a17ae | 15131 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
7298a8e1 | 15132 | direct, style); |
42f914d4 | 15133 | |
d62a17ae | 15134 | XFREE(MTYPE_TMP, str); |
42f914d4 | 15135 | |
d62a17ae | 15136 | if (ret < 0) { |
15137 | community_list_perror(vty, ret); | |
15138 | return CMD_WARNING_CONFIG_FAILED; | |
15139 | } | |
42f914d4 | 15140 | |
d62a17ae | 15141 | return CMD_SUCCESS; |
718e3744 | 15142 | } |
15143 | ||
7336e101 SP |
15144 | ALIAS (no_extcommunity_list_expanded_all, |
15145 | no_ip_extcommunity_list_expanded_all_cmd, | |
15146 | "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
15147 | NO_STR | |
15148 | IP_STR | |
15149 | EXTCOMMUNITY_LIST_STR | |
15150 | "Extended Community list number (expanded)\n" | |
15151 | "Specify expanded extcommunity-list\n" | |
15152 | "Extended Community list name\n" | |
15153 | "Specify community to reject\n" | |
15154 | "Specify community to accept\n" | |
15155 | "An ordered list as a regular-expression\n") | |
15156 | ||
d4455c89 DA |
15157 | ALIAS(no_extcommunity_list_expanded_all, |
15158 | no_ip_extcommunity_list_expanded_all_list_cmd, | |
15159 | "no ip extcommunity-list <(100-500)|expanded WORD>", | |
15160 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
15161 | "Extended Community list number (expanded)\n" | |
15162 | "Specify expanded extcommunity-list\n" | |
15163 | "Extended Community list name\n") | |
15164 | ||
15165 | ALIAS(no_extcommunity_list_expanded_all, | |
15166 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
15167 | "no bgp extcommunity-list <(100-500)|expanded WORD>", | |
15168 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
15169 | "Extended Community list number (expanded)\n" | |
15170 | "Specify expanded extcommunity-list\n" | |
15171 | "Extended Community list name\n") | |
15172 | ||
d62a17ae | 15173 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 15174 | { |
d62a17ae | 15175 | struct community_entry *entry; |
718e3744 | 15176 | |
d62a17ae | 15177 | for (entry = list->head; entry; entry = entry->next) { |
15178 | if (entry == list->head) { | |
15179 | if (all_digit(list->name)) | |
15180 | vty_out(vty, "Extended community %s list %s\n", | |
15181 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
15182 | ? "standard" | |
15183 | : "(expanded) access", | |
15184 | list->name); | |
15185 | else | |
15186 | vty_out(vty, | |
15187 | "Named extended community %s list %s\n", | |
15188 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
15189 | ? "standard" | |
15190 | : "expanded", | |
15191 | list->name); | |
15192 | } | |
15193 | if (entry->any) | |
15194 | vty_out(vty, " %s\n", | |
15195 | community_direct_str(entry->direct)); | |
15196 | else | |
15197 | vty_out(vty, " %s %s\n", | |
15198 | community_direct_str(entry->direct), | |
8d9b8ed9 | 15199 | community_list_config_str(entry)); |
d62a17ae | 15200 | } |
718e3744 | 15201 | } |
15202 | ||
7336e101 SP |
15203 | DEFUN (show_extcommunity_list, |
15204 | show_bgp_extcommunity_list_cmd, | |
15205 | "show bgp extcommunity-list", | |
718e3744 | 15206 | SHOW_STR |
7336e101 | 15207 | BGP_STR |
718e3744 | 15208 | "List extended-community list\n") |
15209 | { | |
d62a17ae | 15210 | struct community_list *list; |
15211 | struct community_list_master *cm; | |
7336e101 | 15212 | int idx = 0; |
718e3744 | 15213 | |
7336e101 SP |
15214 | if (argv_find(argv, argc, "ip", &idx)) { |
15215 | vty_out(vty, "This config option is deprecated, and is scheduled for removal\n"); | |
15216 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15217 | vty_out(vty, "'show bgp extcommunity-list <(1-500)|WORD>'\n"); | |
15218 | zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used"); | |
15219 | } | |
d62a17ae | 15220 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
15221 | if (!cm) | |
15222 | return CMD_SUCCESS; | |
718e3744 | 15223 | |
d62a17ae | 15224 | for (list = cm->num.head; list; list = list->next) |
15225 | extcommunity_list_show(vty, list); | |
718e3744 | 15226 | |
d62a17ae | 15227 | for (list = cm->str.head; list; list = list->next) |
15228 | extcommunity_list_show(vty, list); | |
718e3744 | 15229 | |
d62a17ae | 15230 | return CMD_SUCCESS; |
718e3744 | 15231 | } |
15232 | ||
7336e101 SP |
15233 | ALIAS (show_extcommunity_list, |
15234 | show_ip_extcommunity_list_cmd, | |
15235 | "show ip extcommunity-list", | |
718e3744 | 15236 | SHOW_STR |
15237 | IP_STR | |
7336e101 SP |
15238 | "List extended-community list\n") |
15239 | ||
15240 | DEFUN (show_extcommunity_list_arg, | |
15241 | show_bgp_extcommunity_list_arg_cmd, | |
15242 | "show bgp extcommunity-list <(1-500)|WORD>", | |
15243 | SHOW_STR | |
15244 | BGP_STR | |
718e3744 | 15245 | "List extended-community list\n" |
15246 | "Extcommunity-list number\n" | |
15247 | "Extcommunity-list name\n") | |
15248 | { | |
d62a17ae | 15249 | int idx_comm_list = 3; |
15250 | struct community_list *list; | |
7336e101 | 15251 | int idx = 0; |
718e3744 | 15252 | |
7336e101 SP |
15253 | if (argv_find(argv, argc, "ip", &idx)) { |
15254 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
15255 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15256 | vty_out(vty, "'show bgp extcommunity-list <(1-500)|WORD>'\n"); | |
15257 | zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used"); | |
15258 | } | |
e237b0d2 | 15259 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 15260 | EXTCOMMUNITY_LIST_MASTER); |
15261 | if (!list) { | |
15262 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
15263 | return CMD_WARNING; | |
15264 | } | |
718e3744 | 15265 | |
d62a17ae | 15266 | extcommunity_list_show(vty, list); |
718e3744 | 15267 | |
d62a17ae | 15268 | return CMD_SUCCESS; |
718e3744 | 15269 | } |
6b0655a2 | 15270 | |
7336e101 SP |
15271 | ALIAS (show_extcommunity_list_arg, |
15272 | show_ip_extcommunity_list_arg_cmd, | |
15273 | "show ip extcommunity-list <(1-500)|WORD>", | |
15274 | SHOW_STR | |
15275 | IP_STR | |
15276 | "List extended-community list\n" | |
15277 | "Extcommunity-list number\n" | |
15278 | "Extcommunity-list name\n") | |
15279 | ||
718e3744 | 15280 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 15281 | static int community_list_config_write(struct vty *vty) |
15282 | { | |
15283 | struct community_list *list; | |
15284 | struct community_entry *entry; | |
15285 | struct community_list_master *cm; | |
15286 | int write = 0; | |
15287 | ||
15288 | /* Community-list. */ | |
15289 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
15290 | ||
15291 | for (list = cm->num.head; list; list = list->next) | |
15292 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15293 | vty_out(vty, "bgp community-list %s %s %s\n", list->name, |
d62a17ae | 15294 | community_direct_str(entry->direct), |
15295 | community_list_config_str(entry)); | |
15296 | write++; | |
15297 | } | |
15298 | for (list = cm->str.head; list; list = list->next) | |
15299 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15300 | vty_out(vty, "bgp community-list %s %s %s %s\n", |
d62a17ae | 15301 | entry->style == COMMUNITY_LIST_STANDARD |
15302 | ? "standard" | |
15303 | : "expanded", | |
15304 | list->name, community_direct_str(entry->direct), | |
15305 | community_list_config_str(entry)); | |
15306 | write++; | |
15307 | } | |
15308 | ||
15309 | /* Extcommunity-list. */ | |
15310 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
15311 | ||
15312 | for (list = cm->num.head; list; list = list->next) | |
15313 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15314 | vty_out(vty, "bgp extcommunity-list %s %s %s\n", |
d62a17ae | 15315 | list->name, community_direct_str(entry->direct), |
15316 | community_list_config_str(entry)); | |
15317 | write++; | |
15318 | } | |
15319 | for (list = cm->str.head; list; list = list->next) | |
15320 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15321 | vty_out(vty, "bgp extcommunity-list %s %s %s %s\n", |
d62a17ae | 15322 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
15323 | ? "standard" | |
15324 | : "expanded", | |
15325 | list->name, community_direct_str(entry->direct), | |
15326 | community_list_config_str(entry)); | |
15327 | write++; | |
15328 | } | |
15329 | ||
15330 | ||
15331 | /* lcommunity-list. */ | |
15332 | cm = community_list_master_lookup(bgp_clist, | |
15333 | LARGE_COMMUNITY_LIST_MASTER); | |
15334 | ||
15335 | for (list = cm->num.head; list; list = list->next) | |
15336 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15337 | vty_out(vty, "bgp large-community-list %s %s %s\n", |
d62a17ae | 15338 | list->name, community_direct_str(entry->direct), |
15339 | community_list_config_str(entry)); | |
15340 | write++; | |
15341 | } | |
15342 | for (list = cm->str.head; list; list = list->next) | |
15343 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15344 | vty_out(vty, "bgp large-community-list %s %s %s %s\n", |
d62a17ae | 15345 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
15346 | ? "standard" | |
15347 | : "expanded", | |
15348 | list->name, community_direct_str(entry->direct), | |
15349 | community_list_config_str(entry)); | |
15350 | write++; | |
15351 | } | |
15352 | ||
15353 | return write; | |
15354 | } | |
15355 | ||
15356 | static struct cmd_node community_list_node = { | |
15357 | COMMUNITY_LIST_NODE, "", 1 /* Export to vtysh. */ | |
718e3744 | 15358 | }; |
15359 | ||
d62a17ae | 15360 | static void community_list_vty(void) |
15361 | { | |
15362 | install_node(&community_list_node, community_list_config_write); | |
15363 | ||
15364 | /* Community-list. */ | |
7336e101 SP |
15365 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
15366 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
15367 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 15368 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 15369 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 15370 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
15371 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
15372 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 15373 | install_element(CONFIG_NODE, &ip_community_list_standard_cmd); |
15374 | install_element(CONFIG_NODE, &ip_community_list_expanded_all_cmd); | |
15375 | install_element(CONFIG_NODE, &no_ip_community_list_standard_all_cmd); | |
174b5cb9 | 15376 | install_element(CONFIG_NODE, &no_ip_community_list_standard_all_list_cmd); |
d62a17ae | 15377 | install_element(CONFIG_NODE, &no_ip_community_list_expanded_all_cmd); |
174b5cb9 | 15378 | install_element(CONFIG_NODE, &no_ip_community_list_expanded_all_list_cmd); |
d62a17ae | 15379 | install_element(VIEW_NODE, &show_ip_community_list_cmd); |
15380 | install_element(VIEW_NODE, &show_ip_community_list_arg_cmd); | |
15381 | ||
15382 | /* Extcommunity-list. */ | |
7336e101 SP |
15383 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
15384 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
15385 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
d4455c89 DA |
15386 | install_element(CONFIG_NODE, |
15387 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
7336e101 | 15388 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); |
d4455c89 DA |
15389 | install_element(CONFIG_NODE, |
15390 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
7336e101 SP |
15391 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); |
15392 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 15393 | install_element(CONFIG_NODE, &ip_extcommunity_list_standard_cmd); |
15394 | install_element(CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd); | |
15395 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd); | |
d4455c89 | 15396 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_standard_all_list_cmd); |
d62a17ae | 15397 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd); |
d4455c89 | 15398 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_list_cmd); |
d62a17ae | 15399 | install_element(VIEW_NODE, &show_ip_extcommunity_list_cmd); |
15400 | install_element(VIEW_NODE, &show_ip_extcommunity_list_arg_cmd); | |
15401 | ||
15402 | /* Large Community List */ | |
7336e101 SP |
15403 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
15404 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard1_cmd); | |
15405 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); | |
15406 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
15407 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard1_cmd); | |
15408 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); | |
15409 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_all_cmd); | |
15410 | install_element(CONFIG_NODE, | |
15411 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
15412 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
15413 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
15414 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
15415 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
15416 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
15417 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
d62a17ae | 15418 | install_element(CONFIG_NODE, &ip_lcommunity_list_standard_cmd); |
15419 | install_element(CONFIG_NODE, &ip_lcommunity_list_standard1_cmd); | |
15420 | install_element(CONFIG_NODE, &ip_lcommunity_list_expanded_cmd); | |
15421 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_standard_cmd); | |
15422 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_standard1_cmd); | |
15423 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_expanded_cmd); | |
15424 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_standard_all_cmd); | |
15425 | install_element(CONFIG_NODE, | |
15426 | &no_ip_lcommunity_list_name_expanded_all_cmd); | |
15427 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_standard_cmd); | |
15428 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_expanded_cmd); | |
15429 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_name_standard_cmd); | |
15430 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_cmd); | |
15431 | install_element(VIEW_NODE, &show_ip_lcommunity_list_cmd); | |
15432 | install_element(VIEW_NODE, &show_ip_lcommunity_list_arg_cmd); | |
5bf15956 | 15433 | } |