]>
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 | { |
99b3ebd3 NS |
774 | afi_t afi; |
775 | safi_t safi; | |
776 | ||
777 | FOREACH_AFI_SAFI (afi, safi) | |
778 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
779 | BGP_CLEAR_SOFT_IN, NULL); | |
7aafcaca DS |
780 | } |
781 | ||
782 | /* clear soft outbound */ | |
d62a17ae | 783 | static void bgp_clear_star_soft_out(struct vty *vty, const char *name) |
7aafcaca | 784 | { |
99b3ebd3 NS |
785 | afi_t afi; |
786 | safi_t safi; | |
787 | ||
788 | FOREACH_AFI_SAFI (afi, safi) | |
789 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
790 | BGP_CLEAR_SOFT_OUT, NULL); | |
7aafcaca DS |
791 | } |
792 | ||
793 | ||
f787d7a0 | 794 | #ifndef VTYSH_EXTRACT_PL |
2e4c2296 | 795 | #include "bgpd/bgp_vty_clippy.c" |
f787d7a0 DL |
796 | #endif |
797 | ||
718e3744 | 798 | /* BGP global configuration. */ |
bee57a7a | 799 | #if (CONFDATE > 20190601) |
1cc40660 DS |
800 | CPP_NOTICE("bgpd: time to remove deprecated bgp multiple-instance") |
801 | CPP_NOTICE("This includes BGP_OPT_MULTIPLE_INSTANCE") | |
802 | #endif | |
803 | DEFUN_HIDDEN (bgp_multiple_instance_func, | |
804 | bgp_multiple_instance_cmd, | |
805 | "bgp multiple-instance", | |
806 | BGP_STR | |
807 | "Enable bgp multiple instance\n") | |
718e3744 | 808 | { |
d62a17ae | 809 | bgp_option_set(BGP_OPT_MULTIPLE_INSTANCE); |
810 | return CMD_SUCCESS; | |
718e3744 | 811 | } |
812 | ||
1cc40660 | 813 | DEFUN_HIDDEN (no_bgp_multiple_instance, |
718e3744 | 814 | no_bgp_multiple_instance_cmd, |
815 | "no bgp multiple-instance", | |
816 | NO_STR | |
817 | BGP_STR | |
818 | "BGP multiple instance\n") | |
819 | { | |
d62a17ae | 820 | int ret; |
718e3744 | 821 | |
1cc40660 DS |
822 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); |
823 | vty_out(vty, "if you are using this please let the developers know\n"); | |
b7cd3069 | 824 | zlog_info("Deprecated option: `bgp multiple-instance` being used"); |
d62a17ae | 825 | ret = bgp_option_unset(BGP_OPT_MULTIPLE_INSTANCE); |
826 | if (ret < 0) { | |
827 | vty_out(vty, "%% There are more than two BGP instances\n"); | |
828 | return CMD_WARNING_CONFIG_FAILED; | |
829 | } | |
830 | return CMD_SUCCESS; | |
718e3744 | 831 | } |
832 | ||
8029b216 AK |
833 | DEFUN_HIDDEN (bgp_local_mac, |
834 | bgp_local_mac_cmd, | |
093e3f23 | 835 | "bgp local-mac vni " CMD_VNI_RANGE " mac WORD seq (0-4294967295)", |
8029b216 AK |
836 | BGP_STR |
837 | "Local MAC config\n" | |
838 | "VxLAN Network Identifier\n" | |
839 | "VNI number\n" | |
840 | "local mac\n" | |
841 | "mac address\n" | |
842 | "mac-mobility sequence\n" | |
843 | "seq number\n") | |
844 | { | |
845 | int rv; | |
846 | vni_t vni; | |
847 | struct ethaddr mac; | |
848 | struct ipaddr ip; | |
849 | uint32_t seq; | |
850 | struct bgp *bgp; | |
851 | ||
852 | vni = strtoul(argv[3]->arg, NULL, 10); | |
853 | if (!prefix_str2mac(argv[5]->arg, &mac)) { | |
854 | vty_out(vty, "%% Malformed MAC address\n"); | |
855 | return CMD_WARNING; | |
856 | } | |
857 | memset(&ip, 0, sizeof(ip)); | |
858 | seq = strtoul(argv[7]->arg, NULL, 10); | |
859 | ||
860 | bgp = bgp_get_default(); | |
861 | if (!bgp) { | |
862 | vty_out(vty, "Default BGP instance is not there\n"); | |
863 | return CMD_WARNING; | |
864 | } | |
865 | ||
866 | rv = bgp_evpn_local_macip_add(bgp, vni, &mac, &ip, 0 /* flags */, seq); | |
867 | if (rv < 0) { | |
868 | vty_out(vty, "Internal error\n"); | |
869 | return CMD_WARNING; | |
870 | } | |
871 | ||
872 | return CMD_SUCCESS; | |
873 | } | |
874 | ||
875 | DEFUN_HIDDEN (no_bgp_local_mac, | |
876 | no_bgp_local_mac_cmd, | |
093e3f23 | 877 | "no bgp local-mac vni " CMD_VNI_RANGE " mac WORD", |
8029b216 AK |
878 | NO_STR |
879 | BGP_STR | |
880 | "Local MAC config\n" | |
881 | "VxLAN Network Identifier\n" | |
882 | "VNI number\n" | |
883 | "local mac\n" | |
884 | "mac address\n") | |
885 | { | |
886 | int rv; | |
887 | vni_t vni; | |
888 | struct ethaddr mac; | |
889 | struct ipaddr ip; | |
890 | struct bgp *bgp; | |
891 | ||
892 | vni = strtoul(argv[4]->arg, NULL, 10); | |
893 | if (!prefix_str2mac(argv[6]->arg, &mac)) { | |
894 | vty_out(vty, "%% Malformed MAC address\n"); | |
895 | return CMD_WARNING; | |
896 | } | |
897 | memset(&ip, 0, sizeof(ip)); | |
898 | ||
899 | bgp = bgp_get_default(); | |
900 | if (!bgp) { | |
901 | vty_out(vty, "Default BGP instance is not there\n"); | |
902 | return CMD_WARNING; | |
903 | } | |
904 | ||
ec0ab544 | 905 | rv = bgp_evpn_local_macip_del(bgp, vni, &mac, &ip, ZEBRA_NEIGH_ACTIVE); |
8029b216 AK |
906 | if (rv < 0) { |
907 | vty_out(vty, "Internal error\n"); | |
908 | return CMD_WARNING; | |
909 | } | |
910 | ||
911 | return CMD_SUCCESS; | |
912 | } | |
913 | ||
bee57a7a | 914 | #if (CONFDATE > 20190601) |
798467a2 DS |
915 | CPP_NOTICE("bgpd: time to remove deprecated cli bgp config-type cisco") |
916 | CPP_NOTICE("This includes BGP_OPT_CISCO_CONFIG") | |
917 | #endif | |
918 | DEFUN_HIDDEN (bgp_config_type, | |
919 | bgp_config_type_cmd, | |
920 | "bgp config-type <cisco|zebra>", | |
921 | BGP_STR | |
922 | "Configuration type\n" | |
923 | "cisco\n" | |
924 | "zebra\n") | |
718e3744 | 925 | { |
d62a17ae | 926 | int idx = 0; |
798467a2 DS |
927 | if (argv_find(argv, argc, "cisco", &idx)) { |
928 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
929 | vty_out(vty, "if you are using this please let the developers know!\n"); | |
b7cd3069 | 930 | zlog_info("Deprecated option: `bgp config-type cisco` being used"); |
d62a17ae | 931 | bgp_option_set(BGP_OPT_CONFIG_CISCO); |
798467a2 | 932 | } else |
d62a17ae | 933 | bgp_option_unset(BGP_OPT_CONFIG_CISCO); |
718e3744 | 934 | |
d62a17ae | 935 | return CMD_SUCCESS; |
718e3744 | 936 | } |
937 | ||
798467a2 DS |
938 | DEFUN_HIDDEN (no_bgp_config_type, |
939 | no_bgp_config_type_cmd, | |
940 | "no bgp config-type [<cisco|zebra>]", | |
941 | NO_STR | |
942 | BGP_STR | |
943 | "Display configuration type\n" | |
944 | "cisco\n" | |
945 | "zebra\n") | |
718e3744 | 946 | { |
d62a17ae | 947 | bgp_option_unset(BGP_OPT_CONFIG_CISCO); |
948 | return CMD_SUCCESS; | |
718e3744 | 949 | } |
950 | ||
813d4307 | 951 | |
718e3744 | 952 | DEFUN (no_synchronization, |
953 | no_synchronization_cmd, | |
954 | "no synchronization", | |
955 | NO_STR | |
956 | "Perform IGP synchronization\n") | |
957 | { | |
d62a17ae | 958 | return CMD_SUCCESS; |
718e3744 | 959 | } |
960 | ||
961 | DEFUN (no_auto_summary, | |
962 | no_auto_summary_cmd, | |
963 | "no auto-summary", | |
964 | NO_STR | |
965 | "Enable automatic network number summarization\n") | |
966 | { | |
d62a17ae | 967 | return CMD_SUCCESS; |
718e3744 | 968 | } |
3d515fd9 | 969 | |
718e3744 | 970 | /* "router bgp" commands. */ |
505e5056 | 971 | DEFUN_NOSH (router_bgp, |
f412b39a | 972 | router_bgp_cmd, |
18c57037 | 973 | "router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 974 | ROUTER_STR |
975 | BGP_STR | |
31500417 DW |
976 | AS_STR |
977 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 978 | { |
d62a17ae | 979 | int idx_asn = 2; |
980 | int idx_view_vrf = 3; | |
981 | int idx_vrf = 4; | |
ecec9495 | 982 | int is_new_bgp = 0; |
d62a17ae | 983 | int ret; |
984 | as_t as; | |
985 | struct bgp *bgp; | |
986 | const char *name = NULL; | |
987 | enum bgp_instance_type inst_type; | |
988 | ||
989 | // "router bgp" without an ASN | |
990 | if (argc == 2) { | |
991 | // Pending: Make VRF option available for ASN less config | |
992 | bgp = bgp_get_default(); | |
993 | ||
994 | if (bgp == NULL) { | |
995 | vty_out(vty, "%% No BGP process is configured\n"); | |
996 | return CMD_WARNING_CONFIG_FAILED; | |
997 | } | |
998 | ||
999 | if (listcount(bm->bgp) > 1) { | |
996c9314 | 1000 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1001 | return CMD_WARNING_CONFIG_FAILED; |
1002 | } | |
1003 | } | |
1004 | ||
1005 | // "router bgp X" | |
1006 | else { | |
1007 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
1008 | ||
1009 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; | |
1010 | if (argc > 3) { | |
1011 | name = argv[idx_vrf]->arg; | |
1012 | ||
9a8bdf1c PG |
1013 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) { |
1014 | if (strmatch(name, VRF_DEFAULT_NAME)) | |
1015 | name = NULL; | |
1016 | else | |
1017 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
1018 | } else if (!strcmp(argv[idx_view_vrf]->text, "view")) | |
d62a17ae | 1019 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
1020 | } | |
1021 | ||
ecec9495 AD |
1022 | if (inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
1023 | is_new_bgp = (bgp_lookup(as, name) == NULL); | |
1024 | ||
d62a17ae | 1025 | ret = bgp_get(&bgp, &as, name, inst_type); |
1026 | switch (ret) { | |
1027 | case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET: | |
1028 | vty_out(vty, | |
1029 | "Please specify 'bgp multiple-instance' first\n"); | |
1030 | return CMD_WARNING_CONFIG_FAILED; | |
1031 | case BGP_ERR_AS_MISMATCH: | |
1032 | vty_out(vty, "BGP is already running; AS is %u\n", as); | |
1033 | return CMD_WARNING_CONFIG_FAILED; | |
1034 | case BGP_ERR_INSTANCE_MISMATCH: | |
1035 | vty_out(vty, | |
1036 | "BGP instance name and AS number mismatch\n"); | |
1037 | vty_out(vty, | |
1038 | "BGP instance is already running; AS is %u\n", | |
1039 | as); | |
1040 | return CMD_WARNING_CONFIG_FAILED; | |
1041 | } | |
1042 | ||
3bd70bf8 PZ |
1043 | /* |
1044 | * If we just instantiated the default instance, complete | |
1045 | * any pending VRF-VPN leaking that was configured via | |
1046 | * earlier "router bgp X vrf FOO" blocks. | |
1047 | */ | |
ecec9495 | 1048 | if (is_new_bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
3bd70bf8 PZ |
1049 | vpn_leak_postchange_all(); |
1050 | ||
d62a17ae | 1051 | /* Pending: handle when user tries to change a view to vrf n vv. |
1052 | */ | |
1053 | } | |
1054 | ||
0b5131c9 MK |
1055 | /* unset the auto created flag as the user config is now present */ |
1056 | UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO); | |
d62a17ae | 1057 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); |
1058 | ||
1059 | return CMD_SUCCESS; | |
718e3744 | 1060 | } |
1061 | ||
718e3744 | 1062 | /* "no router bgp" commands. */ |
1063 | DEFUN (no_router_bgp, | |
1064 | no_router_bgp_cmd, | |
18c57037 | 1065 | "no router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 1066 | NO_STR |
1067 | ROUTER_STR | |
1068 | BGP_STR | |
31500417 DW |
1069 | AS_STR |
1070 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1071 | { |
d62a17ae | 1072 | int idx_asn = 3; |
1073 | int idx_vrf = 5; | |
1074 | as_t as; | |
1075 | struct bgp *bgp; | |
1076 | const char *name = NULL; | |
718e3744 | 1077 | |
d62a17ae | 1078 | // "no router bgp" without an ASN |
1079 | if (argc == 3) { | |
1080 | // Pending: Make VRF option available for ASN less config | |
1081 | bgp = bgp_get_default(); | |
718e3744 | 1082 | |
d62a17ae | 1083 | if (bgp == NULL) { |
1084 | vty_out(vty, "%% No BGP process is configured\n"); | |
1085 | return CMD_WARNING_CONFIG_FAILED; | |
1086 | } | |
7fb21a9f | 1087 | |
d62a17ae | 1088 | if (listcount(bm->bgp) > 1) { |
996c9314 | 1089 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1090 | return CMD_WARNING_CONFIG_FAILED; |
1091 | } | |
0b5131c9 MK |
1092 | |
1093 | if (bgp->l3vni) { | |
1094 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
1095 | bgp->l3vni); | |
1096 | return CMD_WARNING_CONFIG_FAILED; | |
1097 | } | |
d62a17ae | 1098 | } else { |
1099 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
7fb21a9f | 1100 | |
d62a17ae | 1101 | if (argc > 4) |
1102 | name = argv[idx_vrf]->arg; | |
7fb21a9f | 1103 | |
d62a17ae | 1104 | /* Lookup bgp structure. */ |
1105 | bgp = bgp_lookup(as, name); | |
1106 | if (!bgp) { | |
1107 | vty_out(vty, "%% Can't find BGP instance\n"); | |
1108 | return CMD_WARNING_CONFIG_FAILED; | |
1109 | } | |
0b5131c9 MK |
1110 | |
1111 | if (bgp->l3vni) { | |
1112 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
1113 | bgp->l3vni); | |
1114 | return CMD_WARNING_CONFIG_FAILED; | |
1115 | } | |
d62a17ae | 1116 | } |
718e3744 | 1117 | |
d62a17ae | 1118 | bgp_delete(bgp); |
718e3744 | 1119 | |
d62a17ae | 1120 | return CMD_SUCCESS; |
718e3744 | 1121 | } |
1122 | ||
6b0655a2 | 1123 | |
718e3744 | 1124 | /* BGP router-id. */ |
1125 | ||
f787d7a0 | 1126 | DEFPY (bgp_router_id, |
718e3744 | 1127 | bgp_router_id_cmd, |
1128 | "bgp router-id A.B.C.D", | |
1129 | BGP_STR | |
1130 | "Override configured router identifier\n" | |
1131 | "Manually configured router identifier\n") | |
1132 | { | |
d62a17ae | 1133 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1134 | bgp_router_id_static_set(bgp, router_id); | |
1135 | return CMD_SUCCESS; | |
718e3744 | 1136 | } |
1137 | ||
f787d7a0 | 1138 | DEFPY (no_bgp_router_id, |
718e3744 | 1139 | no_bgp_router_id_cmd, |
31500417 | 1140 | "no bgp router-id [A.B.C.D]", |
718e3744 | 1141 | NO_STR |
1142 | BGP_STR | |
31500417 DW |
1143 | "Override configured router identifier\n" |
1144 | "Manually configured router identifier\n") | |
718e3744 | 1145 | { |
d62a17ae | 1146 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1147 | |
d62a17ae | 1148 | if (router_id_str) { |
1149 | if (!IPV4_ADDR_SAME(&bgp->router_id_static, &router_id)) { | |
1150 | vty_out(vty, "%% BGP router-id doesn't match\n"); | |
1151 | return CMD_WARNING_CONFIG_FAILED; | |
1152 | } | |
e018c7cc | 1153 | } |
718e3744 | 1154 | |
d62a17ae | 1155 | router_id.s_addr = 0; |
1156 | bgp_router_id_static_set(bgp, router_id); | |
718e3744 | 1157 | |
d62a17ae | 1158 | return CMD_SUCCESS; |
718e3744 | 1159 | } |
1160 | ||
6b0655a2 | 1161 | |
718e3744 | 1162 | /* BGP Cluster ID. */ |
718e3744 | 1163 | DEFUN (bgp_cluster_id, |
1164 | bgp_cluster_id_cmd, | |
838758ac | 1165 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", |
718e3744 | 1166 | BGP_STR |
1167 | "Configure Route-Reflector Cluster-id\n" | |
838758ac DW |
1168 | "Route-Reflector Cluster-id in IP address format\n" |
1169 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1170 | { |
d62a17ae | 1171 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1172 | int idx_ipv4 = 2; | |
1173 | int ret; | |
1174 | struct in_addr cluster; | |
718e3744 | 1175 | |
d62a17ae | 1176 | ret = inet_aton(argv[idx_ipv4]->arg, &cluster); |
1177 | if (!ret) { | |
1178 | vty_out(vty, "%% Malformed bgp cluster identifier\n"); | |
1179 | return CMD_WARNING_CONFIG_FAILED; | |
1180 | } | |
718e3744 | 1181 | |
d62a17ae | 1182 | bgp_cluster_id_set(bgp, &cluster); |
1183 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1184 | |
d62a17ae | 1185 | return CMD_SUCCESS; |
718e3744 | 1186 | } |
1187 | ||
718e3744 | 1188 | DEFUN (no_bgp_cluster_id, |
1189 | no_bgp_cluster_id_cmd, | |
c7178fe7 | 1190 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", |
718e3744 | 1191 | NO_STR |
1192 | BGP_STR | |
838758ac DW |
1193 | "Configure Route-Reflector Cluster-id\n" |
1194 | "Route-Reflector Cluster-id in IP address format\n" | |
1195 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1196 | { |
d62a17ae | 1197 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1198 | bgp_cluster_id_unset(bgp); | |
1199 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1200 | |
d62a17ae | 1201 | return CMD_SUCCESS; |
718e3744 | 1202 | } |
1203 | ||
718e3744 | 1204 | DEFUN (bgp_confederation_identifier, |
1205 | bgp_confederation_identifier_cmd, | |
9ccf14f7 | 1206 | "bgp confederation identifier (1-4294967295)", |
718e3744 | 1207 | "BGP specific commands\n" |
1208 | "AS confederation parameters\n" | |
1209 | "AS number\n" | |
1210 | "Set routing domain confederation AS\n") | |
1211 | { | |
d62a17ae | 1212 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1213 | int idx_number = 3; | |
1214 | as_t as; | |
718e3744 | 1215 | |
d62a17ae | 1216 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 1217 | |
d62a17ae | 1218 | bgp_confederation_id_set(bgp, as); |
718e3744 | 1219 | |
d62a17ae | 1220 | return CMD_SUCCESS; |
718e3744 | 1221 | } |
1222 | ||
1223 | DEFUN (no_bgp_confederation_identifier, | |
1224 | no_bgp_confederation_identifier_cmd, | |
838758ac | 1225 | "no bgp confederation identifier [(1-4294967295)]", |
718e3744 | 1226 | NO_STR |
1227 | "BGP specific commands\n" | |
1228 | "AS confederation parameters\n" | |
3a2d747c QY |
1229 | "AS number\n" |
1230 | "Set routing domain confederation AS\n") | |
718e3744 | 1231 | { |
d62a17ae | 1232 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1233 | bgp_confederation_id_unset(bgp); | |
718e3744 | 1234 | |
d62a17ae | 1235 | return CMD_SUCCESS; |
718e3744 | 1236 | } |
1237 | ||
718e3744 | 1238 | DEFUN (bgp_confederation_peers, |
1239 | bgp_confederation_peers_cmd, | |
12dcf78e | 1240 | "bgp confederation peers (1-4294967295)...", |
718e3744 | 1241 | "BGP specific commands\n" |
1242 | "AS confederation parameters\n" | |
1243 | "Peer ASs in BGP confederation\n" | |
1244 | AS_STR) | |
1245 | { | |
d62a17ae | 1246 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1247 | int idx_asn = 3; | |
1248 | as_t as; | |
1249 | int i; | |
718e3744 | 1250 | |
d62a17ae | 1251 | for (i = idx_asn; i < argc; i++) { |
1252 | as = strtoul(argv[i]->arg, NULL, 10); | |
718e3744 | 1253 | |
d62a17ae | 1254 | if (bgp->as == as) { |
1255 | vty_out(vty, | |
1256 | "%% Local member-AS not allowed in confed peer list\n"); | |
1257 | continue; | |
1258 | } | |
718e3744 | 1259 | |
d62a17ae | 1260 | bgp_confederation_peers_add(bgp, as); |
1261 | } | |
1262 | return CMD_SUCCESS; | |
718e3744 | 1263 | } |
1264 | ||
1265 | DEFUN (no_bgp_confederation_peers, | |
1266 | no_bgp_confederation_peers_cmd, | |
e83a9414 | 1267 | "no bgp confederation peers (1-4294967295)...", |
718e3744 | 1268 | NO_STR |
1269 | "BGP specific commands\n" | |
1270 | "AS confederation parameters\n" | |
1271 | "Peer ASs in BGP confederation\n" | |
1272 | AS_STR) | |
1273 | { | |
d62a17ae | 1274 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1275 | int idx_asn = 4; | |
1276 | as_t as; | |
1277 | int i; | |
718e3744 | 1278 | |
d62a17ae | 1279 | for (i = idx_asn; i < argc; i++) { |
1280 | as = strtoul(argv[i]->arg, NULL, 10); | |
0b2aa3a0 | 1281 | |
d62a17ae | 1282 | bgp_confederation_peers_remove(bgp, as); |
1283 | } | |
1284 | return CMD_SUCCESS; | |
718e3744 | 1285 | } |
6b0655a2 | 1286 | |
5e242b0d DS |
1287 | /** |
1288 | * Central routine for maximum-paths configuration. | |
1289 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1290 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1291 | */ | |
d62a17ae | 1292 | static int bgp_maxpaths_config_vty(struct vty *vty, int peer_type, |
d7c0a89a | 1293 | const char *mpaths, uint16_t options, |
d62a17ae | 1294 | int set) |
1295 | { | |
1296 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
d7c0a89a | 1297 | uint16_t maxpaths = 0; |
d62a17ae | 1298 | int ret; |
1299 | afi_t afi; | |
1300 | safi_t safi; | |
1301 | ||
1302 | afi = bgp_node_afi(vty); | |
1303 | safi = bgp_node_safi(vty); | |
1304 | ||
1305 | if (set) { | |
1306 | maxpaths = strtol(mpaths, NULL, 10); | |
1307 | if (maxpaths > multipath_num) { | |
1308 | vty_out(vty, | |
1309 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", | |
1310 | maxpaths, multipath_num); | |
1311 | return CMD_WARNING_CONFIG_FAILED; | |
1312 | } | |
1313 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1314 | options); | |
1315 | } else | |
1316 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1317 | ||
1318 | if (ret < 0) { | |
1319 | vty_out(vty, | |
1320 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", | |
1321 | (set == 1) ? "" : "un", | |
1322 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1323 | maxpaths, afi, safi); | |
1324 | return CMD_WARNING_CONFIG_FAILED; | |
1325 | } | |
1326 | ||
1327 | bgp_recalculate_all_bestpaths(bgp); | |
1328 | ||
1329 | return CMD_SUCCESS; | |
165b5fff JB |
1330 | } |
1331 | ||
abc920f8 DS |
1332 | DEFUN (bgp_maxmed_admin, |
1333 | bgp_maxmed_admin_cmd, | |
1334 | "bgp max-med administrative ", | |
1335 | BGP_STR | |
1336 | "Advertise routes with max-med\n" | |
1337 | "Administratively applied, for an indefinite period\n") | |
1338 | { | |
d62a17ae | 1339 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1340 | |
d62a17ae | 1341 | bgp->v_maxmed_admin = 1; |
1342 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1343 | |
d62a17ae | 1344 | bgp_maxmed_update(bgp); |
abc920f8 | 1345 | |
d62a17ae | 1346 | return CMD_SUCCESS; |
abc920f8 DS |
1347 | } |
1348 | ||
1349 | DEFUN (bgp_maxmed_admin_medv, | |
1350 | bgp_maxmed_admin_medv_cmd, | |
4668a151 | 1351 | "bgp max-med administrative (0-4294967295)", |
abc920f8 DS |
1352 | BGP_STR |
1353 | "Advertise routes with max-med\n" | |
1354 | "Administratively applied, for an indefinite period\n" | |
1355 | "Max MED value to be used\n") | |
1356 | { | |
d62a17ae | 1357 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1358 | int idx_number = 3; | |
abc920f8 | 1359 | |
d62a17ae | 1360 | bgp->v_maxmed_admin = 1; |
1361 | bgp->maxmed_admin_value = strtoul(argv[idx_number]->arg, NULL, 10); | |
abc920f8 | 1362 | |
d62a17ae | 1363 | bgp_maxmed_update(bgp); |
abc920f8 | 1364 | |
d62a17ae | 1365 | return CMD_SUCCESS; |
abc920f8 DS |
1366 | } |
1367 | ||
1368 | DEFUN (no_bgp_maxmed_admin, | |
1369 | no_bgp_maxmed_admin_cmd, | |
4668a151 | 1370 | "no bgp max-med administrative [(0-4294967295)]", |
abc920f8 DS |
1371 | NO_STR |
1372 | BGP_STR | |
1373 | "Advertise routes with max-med\n" | |
838758ac DW |
1374 | "Administratively applied, for an indefinite period\n" |
1375 | "Max MED value to be used\n") | |
abc920f8 | 1376 | { |
d62a17ae | 1377 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1378 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; | |
1379 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1380 | bgp_maxmed_update(bgp); | |
abc920f8 | 1381 | |
d62a17ae | 1382 | return CMD_SUCCESS; |
abc920f8 DS |
1383 | } |
1384 | ||
abc920f8 DS |
1385 | DEFUN (bgp_maxmed_onstartup, |
1386 | bgp_maxmed_onstartup_cmd, | |
4668a151 | 1387 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", |
abc920f8 DS |
1388 | BGP_STR |
1389 | "Advertise routes with max-med\n" | |
1390 | "Effective on a startup\n" | |
1391 | "Time (seconds) period for max-med\n" | |
1392 | "Max MED value to be used\n") | |
1393 | { | |
d62a17ae | 1394 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1395 | int idx = 0; | |
4668a151 | 1396 | |
d62a17ae | 1397 | argv_find(argv, argc, "(5-86400)", &idx); |
1398 | bgp->v_maxmed_onstartup = strtoul(argv[idx]->arg, NULL, 10); | |
1399 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
1400 | bgp->maxmed_onstartup_value = strtoul(argv[idx]->arg, NULL, 10); | |
1401 | else | |
1402 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
4668a151 | 1403 | |
d62a17ae | 1404 | bgp_maxmed_update(bgp); |
abc920f8 | 1405 | |
d62a17ae | 1406 | return CMD_SUCCESS; |
abc920f8 DS |
1407 | } |
1408 | ||
1409 | DEFUN (no_bgp_maxmed_onstartup, | |
1410 | no_bgp_maxmed_onstartup_cmd, | |
4668a151 | 1411 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", |
abc920f8 DS |
1412 | NO_STR |
1413 | BGP_STR | |
1414 | "Advertise routes with max-med\n" | |
838758ac DW |
1415 | "Effective on a startup\n" |
1416 | "Time (seconds) period for max-med\n" | |
1417 | "Max MED value to be used\n") | |
abc920f8 | 1418 | { |
d62a17ae | 1419 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1420 | |
d62a17ae | 1421 | /* Cancel max-med onstartup if its on */ |
1422 | if (bgp->t_maxmed_onstartup) { | |
1423 | THREAD_TIMER_OFF(bgp->t_maxmed_onstartup); | |
1424 | bgp->maxmed_onstartup_over = 1; | |
1425 | } | |
abc920f8 | 1426 | |
d62a17ae | 1427 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; |
1428 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1429 | |
d62a17ae | 1430 | bgp_maxmed_update(bgp); |
abc920f8 | 1431 | |
d62a17ae | 1432 | return CMD_SUCCESS; |
abc920f8 DS |
1433 | } |
1434 | ||
d62a17ae | 1435 | static int bgp_update_delay_config_vty(struct vty *vty, const char *delay, |
1436 | const char *wait) | |
f188f2c4 | 1437 | { |
d62a17ae | 1438 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d7c0a89a QY |
1439 | uint16_t update_delay; |
1440 | uint16_t establish_wait; | |
f188f2c4 | 1441 | |
d62a17ae | 1442 | update_delay = strtoul(delay, NULL, 10); |
f188f2c4 | 1443 | |
d62a17ae | 1444 | if (!wait) /* update-delay <delay> */ |
1445 | { | |
1446 | bgp->v_update_delay = update_delay; | |
1447 | bgp->v_establish_wait = bgp->v_update_delay; | |
1448 | return CMD_SUCCESS; | |
1449 | } | |
f188f2c4 | 1450 | |
d62a17ae | 1451 | /* update-delay <delay> <establish-wait> */ |
1452 | establish_wait = atoi(wait); | |
1453 | if (update_delay < establish_wait) { | |
1454 | vty_out(vty, | |
1455 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1456 | return CMD_WARNING_CONFIG_FAILED; | |
1457 | } | |
f188f2c4 | 1458 | |
d62a17ae | 1459 | bgp->v_update_delay = update_delay; |
1460 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 1461 | |
d62a17ae | 1462 | return CMD_SUCCESS; |
f188f2c4 DS |
1463 | } |
1464 | ||
d62a17ae | 1465 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 1466 | { |
d62a17ae | 1467 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 1468 | |
d62a17ae | 1469 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
1470 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 1471 | |
d62a17ae | 1472 | return CMD_SUCCESS; |
f188f2c4 DS |
1473 | } |
1474 | ||
2b791107 | 1475 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 1476 | { |
d62a17ae | 1477 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
1478 | vty_out(vty, " update-delay %d", bgp->v_update_delay); | |
1479 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1480 | vty_out(vty, " %d", bgp->v_establish_wait); | |
1481 | vty_out(vty, "\n"); | |
1482 | } | |
f188f2c4 DS |
1483 | } |
1484 | ||
1485 | ||
1486 | /* Update-delay configuration */ | |
1487 | DEFUN (bgp_update_delay, | |
1488 | bgp_update_delay_cmd, | |
6147e2c6 | 1489 | "update-delay (0-3600)", |
f188f2c4 DS |
1490 | "Force initial delay for best-path and updates\n" |
1491 | "Seconds\n") | |
1492 | { | |
d62a17ae | 1493 | int idx_number = 1; |
1494 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); | |
f188f2c4 DS |
1495 | } |
1496 | ||
1497 | DEFUN (bgp_update_delay_establish_wait, | |
1498 | bgp_update_delay_establish_wait_cmd, | |
6147e2c6 | 1499 | "update-delay (0-3600) (1-3600)", |
f188f2c4 DS |
1500 | "Force initial delay for best-path and updates\n" |
1501 | "Seconds\n" | |
f188f2c4 DS |
1502 | "Seconds\n") |
1503 | { | |
d62a17ae | 1504 | int idx_number = 1; |
1505 | int idx_number_2 = 2; | |
1506 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, | |
1507 | argv[idx_number_2]->arg); | |
f188f2c4 DS |
1508 | } |
1509 | ||
1510 | /* Update-delay deconfiguration */ | |
1511 | DEFUN (no_bgp_update_delay, | |
1512 | no_bgp_update_delay_cmd, | |
838758ac DW |
1513 | "no update-delay [(0-3600) [(1-3600)]]", |
1514 | NO_STR | |
f188f2c4 | 1515 | "Force initial delay for best-path and updates\n" |
838758ac | 1516 | "Seconds\n" |
7111c1a0 | 1517 | "Seconds\n") |
f188f2c4 | 1518 | { |
d62a17ae | 1519 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
1520 | } |
1521 | ||
5e242b0d | 1522 | |
d62a17ae | 1523 | static int bgp_wpkt_quanta_config_vty(struct vty *vty, const char *num, |
1524 | char set) | |
cb1faec9 | 1525 | { |
d62a17ae | 1526 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
cb1faec9 | 1527 | |
555e09d4 QY |
1528 | if (set) { |
1529 | uint32_t quanta = strtoul(num, NULL, 10); | |
1530 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, | |
1531 | memory_order_relaxed); | |
1532 | } else { | |
1533 | atomic_store_explicit(&bgp->wpkt_quanta, BGP_WRITE_PACKET_MAX, | |
1534 | memory_order_relaxed); | |
1535 | } | |
1536 | ||
1537 | return CMD_SUCCESS; | |
1538 | } | |
1539 | ||
1540 | static int bgp_rpkt_quanta_config_vty(struct vty *vty, const char *num, | |
1541 | char set) | |
1542 | { | |
1543 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1544 | ||
1545 | if (set) { | |
1546 | uint32_t quanta = strtoul(num, NULL, 10); | |
1547 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, | |
1548 | memory_order_relaxed); | |
1549 | } else { | |
1550 | atomic_store_explicit(&bgp->rpkt_quanta, BGP_READ_PACKET_MAX, | |
1551 | memory_order_relaxed); | |
1552 | } | |
cb1faec9 | 1553 | |
d62a17ae | 1554 | return CMD_SUCCESS; |
cb1faec9 DS |
1555 | } |
1556 | ||
2b791107 | 1557 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 1558 | { |
555e09d4 QY |
1559 | uint32_t quanta = |
1560 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
1561 | if (quanta != BGP_WRITE_PACKET_MAX) | |
152456fe | 1562 | vty_out(vty, " write-quanta %d\n", quanta); |
cb1faec9 DS |
1563 | } |
1564 | ||
555e09d4 QY |
1565 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) |
1566 | { | |
1567 | uint32_t quanta = | |
1568 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
1569 | if (quanta != BGP_READ_PACKET_MAX) | |
152456fe | 1570 | vty_out(vty, " read-quanta %d\n", quanta); |
555e09d4 | 1571 | } |
cb1faec9 | 1572 | |
555e09d4 | 1573 | /* Packet quanta configuration */ |
cb1faec9 DS |
1574 | DEFUN (bgp_wpkt_quanta, |
1575 | bgp_wpkt_quanta_cmd, | |
555e09d4 | 1576 | "write-quanta (1-10)", |
cb1faec9 DS |
1577 | "How many packets to write to peer socket per run\n" |
1578 | "Number of packets\n") | |
1579 | { | |
d62a17ae | 1580 | int idx_number = 1; |
1581 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
cb1faec9 DS |
1582 | } |
1583 | ||
cb1faec9 DS |
1584 | DEFUN (no_bgp_wpkt_quanta, |
1585 | no_bgp_wpkt_quanta_cmd, | |
555e09d4 | 1586 | "no write-quanta (1-10)", |
d7fa34c1 | 1587 | NO_STR |
555e09d4 | 1588 | "How many packets to write to peer socket per I/O cycle\n" |
cb1faec9 DS |
1589 | "Number of packets\n") |
1590 | { | |
d62a17ae | 1591 | int idx_number = 2; |
1592 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
cb1faec9 DS |
1593 | } |
1594 | ||
555e09d4 QY |
1595 | DEFUN (bgp_rpkt_quanta, |
1596 | bgp_rpkt_quanta_cmd, | |
1597 | "read-quanta (1-10)", | |
1598 | "How many packets to read from peer socket per I/O cycle\n" | |
1599 | "Number of packets\n") | |
1600 | { | |
1601 | int idx_number = 1; | |
1602 | return bgp_rpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
1603 | } | |
1604 | ||
1605 | DEFUN (no_bgp_rpkt_quanta, | |
1606 | no_bgp_rpkt_quanta_cmd, | |
1607 | "no read-quanta (1-10)", | |
1608 | NO_STR | |
1609 | "How many packets to read from peer socket per I/O cycle\n" | |
1610 | "Number of packets\n") | |
1611 | { | |
1612 | int idx_number = 2; | |
1613 | return bgp_rpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
1614 | } | |
1615 | ||
2b791107 | 1616 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 1617 | { |
37a333fe | 1618 | if (!bgp->heuristic_coalesce) |
d62a17ae | 1619 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); |
3f9c7369 DS |
1620 | } |
1621 | ||
1622 | ||
1623 | DEFUN (bgp_coalesce_time, | |
1624 | bgp_coalesce_time_cmd, | |
6147e2c6 | 1625 | "coalesce-time (0-4294967295)", |
3f9c7369 DS |
1626 | "Subgroup coalesce timer\n" |
1627 | "Subgroup coalesce timer value (in ms)\n") | |
1628 | { | |
d62a17ae | 1629 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1630 | |
d62a17ae | 1631 | int idx = 0; |
1632 | argv_find(argv, argc, "(0-4294967295)", &idx); | |
37a333fe | 1633 | bgp->heuristic_coalesce = false; |
d62a17ae | 1634 | bgp->coalesce_time = strtoul(argv[idx]->arg, NULL, 10); |
1635 | return CMD_SUCCESS; | |
3f9c7369 DS |
1636 | } |
1637 | ||
1638 | DEFUN (no_bgp_coalesce_time, | |
1639 | no_bgp_coalesce_time_cmd, | |
6147e2c6 | 1640 | "no coalesce-time (0-4294967295)", |
3a2d747c | 1641 | NO_STR |
3f9c7369 DS |
1642 | "Subgroup coalesce timer\n" |
1643 | "Subgroup coalesce timer value (in ms)\n") | |
1644 | { | |
d62a17ae | 1645 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1646 | |
37a333fe | 1647 | bgp->heuristic_coalesce = true; |
d62a17ae | 1648 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; |
1649 | return CMD_SUCCESS; | |
3f9c7369 DS |
1650 | } |
1651 | ||
5e242b0d DS |
1652 | /* Maximum-paths configuration */ |
1653 | DEFUN (bgp_maxpaths, | |
1654 | bgp_maxpaths_cmd, | |
6319fd63 | 1655 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), |
5e242b0d DS |
1656 | "Forward packets over multiple paths\n" |
1657 | "Number of paths\n") | |
1658 | { | |
d62a17ae | 1659 | int idx_number = 1; |
1660 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, | |
1661 | argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
1662 | } |
1663 | ||
d62a17ae | 1664 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
1665 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1666 | "Forward packets over multiple paths\n" | |
1667 | "Number of paths\n") | |
596c17ba | 1668 | |
165b5fff JB |
1669 | DEFUN (bgp_maxpaths_ibgp, |
1670 | bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1671 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), |
165b5fff JB |
1672 | "Forward packets over multiple paths\n" |
1673 | "iBGP-multipath\n" | |
1674 | "Number of paths\n") | |
1675 | { | |
d62a17ae | 1676 | int idx_number = 2; |
1677 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, | |
1678 | argv[idx_number]->arg, 0, 1); | |
5e242b0d | 1679 | } |
165b5fff | 1680 | |
d62a17ae | 1681 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
1682 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1683 | "Forward packets over multiple paths\n" | |
1684 | "iBGP-multipath\n" | |
1685 | "Number of paths\n") | |
596c17ba | 1686 | |
5e242b0d DS |
1687 | DEFUN (bgp_maxpaths_ibgp_cluster, |
1688 | bgp_maxpaths_ibgp_cluster_cmd, | |
6319fd63 | 1689 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", |
5e242b0d DS |
1690 | "Forward packets over multiple paths\n" |
1691 | "iBGP-multipath\n" | |
1692 | "Number of paths\n" | |
1693 | "Match the cluster length\n") | |
1694 | { | |
d62a17ae | 1695 | int idx_number = 2; |
1696 | return bgp_maxpaths_config_vty( | |
1697 | vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
1698 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); | |
165b5fff JB |
1699 | } |
1700 | ||
d62a17ae | 1701 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
1702 | "maximum-paths ibgp " CMD_RANGE_STR( | |
1703 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
1704 | "Forward packets over multiple paths\n" | |
1705 | "iBGP-multipath\n" | |
1706 | "Number of paths\n" | |
1707 | "Match the cluster length\n") | |
596c17ba | 1708 | |
165b5fff JB |
1709 | DEFUN (no_bgp_maxpaths, |
1710 | no_bgp_maxpaths_cmd, | |
6319fd63 | 1711 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", |
165b5fff JB |
1712 | NO_STR |
1713 | "Forward packets over multiple paths\n" | |
1714 | "Number of paths\n") | |
1715 | { | |
d62a17ae | 1716 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
1717 | } |
1718 | ||
d62a17ae | 1719 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
996c9314 | 1720 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 1721 | "Forward packets over multiple paths\n" |
1722 | "Number of paths\n") | |
596c17ba | 1723 | |
165b5fff JB |
1724 | DEFUN (no_bgp_maxpaths_ibgp, |
1725 | no_bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1726 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", |
165b5fff JB |
1727 | NO_STR |
1728 | "Forward packets over multiple paths\n" | |
1729 | "iBGP-multipath\n" | |
838758ac DW |
1730 | "Number of paths\n" |
1731 | "Match the cluster length\n") | |
165b5fff | 1732 | { |
d62a17ae | 1733 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1734 | } |
1735 | ||
d62a17ae | 1736 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
1737 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
1738 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
1739 | NO_STR | |
1740 | "Forward packets over multiple paths\n" | |
1741 | "iBGP-multipath\n" | |
1742 | "Number of paths\n" | |
1743 | "Match the cluster length\n") | |
596c17ba | 1744 | |
2b791107 | 1745 | void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, afi_t afi, |
60466a63 | 1746 | safi_t safi) |
165b5fff | 1747 | { |
d62a17ae | 1748 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) { |
d62a17ae | 1749 | vty_out(vty, " maximum-paths %d\n", |
1750 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
1751 | } | |
165b5fff | 1752 | |
d62a17ae | 1753 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) { |
d62a17ae | 1754 | vty_out(vty, " maximum-paths ibgp %d", |
1755 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
1756 | if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, | |
1757 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1758 | vty_out(vty, " equal-cluster-length"); | |
1759 | vty_out(vty, "\n"); | |
1760 | } | |
165b5fff | 1761 | } |
6b0655a2 | 1762 | |
718e3744 | 1763 | /* BGP timers. */ |
1764 | ||
1765 | DEFUN (bgp_timers, | |
1766 | bgp_timers_cmd, | |
6147e2c6 | 1767 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1768 | "Adjust routing timers\n" |
1769 | "BGP timers\n" | |
1770 | "Keepalive interval\n" | |
1771 | "Holdtime\n") | |
1772 | { | |
d62a17ae | 1773 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1774 | int idx_number = 2; | |
1775 | int idx_number_2 = 3; | |
1776 | unsigned long keepalive = 0; | |
1777 | unsigned long holdtime = 0; | |
718e3744 | 1778 | |
d62a17ae | 1779 | keepalive = strtoul(argv[idx_number]->arg, NULL, 10); |
1780 | holdtime = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
718e3744 | 1781 | |
d62a17ae | 1782 | /* Holdtime value check. */ |
1783 | if (holdtime < 3 && holdtime != 0) { | |
1784 | vty_out(vty, | |
1785 | "%% hold time value must be either 0 or greater than 3\n"); | |
1786 | return CMD_WARNING_CONFIG_FAILED; | |
1787 | } | |
718e3744 | 1788 | |
d62a17ae | 1789 | bgp_timers_set(bgp, keepalive, holdtime); |
718e3744 | 1790 | |
d62a17ae | 1791 | return CMD_SUCCESS; |
718e3744 | 1792 | } |
1793 | ||
1794 | DEFUN (no_bgp_timers, | |
1795 | no_bgp_timers_cmd, | |
838758ac | 1796 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1797 | NO_STR |
1798 | "Adjust routing timers\n" | |
838758ac DW |
1799 | "BGP timers\n" |
1800 | "Keepalive interval\n" | |
1801 | "Holdtime\n") | |
718e3744 | 1802 | { |
d62a17ae | 1803 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1804 | bgp_timers_unset(bgp); | |
718e3744 | 1805 | |
d62a17ae | 1806 | return CMD_SUCCESS; |
718e3744 | 1807 | } |
1808 | ||
6b0655a2 | 1809 | |
718e3744 | 1810 | DEFUN (bgp_client_to_client_reflection, |
1811 | bgp_client_to_client_reflection_cmd, | |
1812 | "bgp client-to-client reflection", | |
1813 | "BGP specific commands\n" | |
1814 | "Configure client to client route reflection\n" | |
1815 | "reflection of routes allowed\n") | |
1816 | { | |
d62a17ae | 1817 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1818 | bgp_flag_unset(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1819 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1820 | |
d62a17ae | 1821 | return CMD_SUCCESS; |
718e3744 | 1822 | } |
1823 | ||
1824 | DEFUN (no_bgp_client_to_client_reflection, | |
1825 | no_bgp_client_to_client_reflection_cmd, | |
1826 | "no bgp client-to-client reflection", | |
1827 | NO_STR | |
1828 | "BGP specific commands\n" | |
1829 | "Configure client to client route reflection\n" | |
1830 | "reflection of routes allowed\n") | |
1831 | { | |
d62a17ae | 1832 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1833 | bgp_flag_set(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1834 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1835 | |
d62a17ae | 1836 | return CMD_SUCCESS; |
718e3744 | 1837 | } |
1838 | ||
1839 | /* "bgp always-compare-med" configuration. */ | |
1840 | DEFUN (bgp_always_compare_med, | |
1841 | bgp_always_compare_med_cmd, | |
1842 | "bgp always-compare-med", | |
1843 | "BGP specific commands\n" | |
1844 | "Allow comparing MED from different neighbors\n") | |
1845 | { | |
d62a17ae | 1846 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1847 | bgp_flag_set(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1848 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1849 | |
d62a17ae | 1850 | return CMD_SUCCESS; |
718e3744 | 1851 | } |
1852 | ||
1853 | DEFUN (no_bgp_always_compare_med, | |
1854 | no_bgp_always_compare_med_cmd, | |
1855 | "no bgp always-compare-med", | |
1856 | NO_STR | |
1857 | "BGP specific commands\n" | |
1858 | "Allow comparing MED from different neighbors\n") | |
1859 | { | |
d62a17ae | 1860 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1861 | bgp_flag_unset(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1862 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1863 | |
d62a17ae | 1864 | return CMD_SUCCESS; |
718e3744 | 1865 | } |
6b0655a2 | 1866 | |
9dac9fc8 DA |
1867 | |
1868 | DEFUN(bgp_ebgp_requires_policy, bgp_ebgp_requires_policy_cmd, | |
1869 | "bgp ebgp-requires-policy", | |
1870 | "BGP specific commands\n" | |
1871 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
1872 | { | |
1873 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1874 | bgp->ebgp_requires_policy = DEFAULT_EBGP_POLICY_ENABLED; | |
1875 | return CMD_SUCCESS; | |
1876 | } | |
1877 | ||
1878 | DEFUN(no_bgp_ebgp_requires_policy, no_bgp_ebgp_requires_policy_cmd, | |
1879 | "no bgp ebgp-requires-policy", | |
1880 | NO_STR | |
1881 | "BGP specific commands\n" | |
1882 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
1883 | { | |
1884 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1885 | bgp->ebgp_requires_policy = DEFAULT_EBGP_POLICY_DISABLED; | |
1886 | return CMD_SUCCESS; | |
1887 | } | |
1888 | ||
1889 | ||
718e3744 | 1890 | /* "bgp deterministic-med" configuration. */ |
1891 | DEFUN (bgp_deterministic_med, | |
1892 | bgp_deterministic_med_cmd, | |
1893 | "bgp deterministic-med", | |
1894 | "BGP specific commands\n" | |
1895 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1896 | { | |
d62a17ae | 1897 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1475ac87 | 1898 | |
d62a17ae | 1899 | if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { |
1900 | bgp_flag_set(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1901 | bgp_recalculate_all_bestpaths(bgp); | |
1902 | } | |
7aafcaca | 1903 | |
d62a17ae | 1904 | return CMD_SUCCESS; |
718e3744 | 1905 | } |
1906 | ||
1907 | DEFUN (no_bgp_deterministic_med, | |
1908 | no_bgp_deterministic_med_cmd, | |
1909 | "no bgp deterministic-med", | |
1910 | NO_STR | |
1911 | "BGP specific commands\n" | |
1912 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1913 | { | |
d62a17ae | 1914 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1915 | int bestpath_per_as_used; | |
1916 | afi_t afi; | |
1917 | safi_t safi; | |
1918 | struct peer *peer; | |
1919 | struct listnode *node, *nnode; | |
1920 | ||
1921 | if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { | |
1922 | bestpath_per_as_used = 0; | |
1923 | ||
1924 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
05c7a1cc | 1925 | FOREACH_AFI_SAFI (afi, safi) |
dcc68b5e MS |
1926 | if (bgp_addpath_dmed_required( |
1927 | peer->addpath_type[afi][safi])) { | |
05c7a1cc QY |
1928 | bestpath_per_as_used = 1; |
1929 | break; | |
1930 | } | |
d62a17ae | 1931 | |
1932 | if (bestpath_per_as_used) | |
1933 | break; | |
1934 | } | |
1935 | ||
1936 | if (bestpath_per_as_used) { | |
1937 | vty_out(vty, | |
1938 | "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n"); | |
1939 | return CMD_WARNING_CONFIG_FAILED; | |
1940 | } else { | |
1941 | bgp_flag_unset(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1942 | bgp_recalculate_all_bestpaths(bgp); | |
1943 | } | |
1944 | } | |
1945 | ||
1946 | return CMD_SUCCESS; | |
718e3744 | 1947 | } |
538621f2 | 1948 | |
1949 | /* "bgp graceful-restart" configuration. */ | |
1950 | DEFUN (bgp_graceful_restart, | |
1951 | bgp_graceful_restart_cmd, | |
1952 | "bgp graceful-restart", | |
1953 | "BGP specific commands\n" | |
1954 | "Graceful restart capability parameters\n") | |
1955 | { | |
d62a17ae | 1956 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1957 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
1958 | return CMD_SUCCESS; | |
538621f2 | 1959 | } |
1960 | ||
1961 | DEFUN (no_bgp_graceful_restart, | |
1962 | no_bgp_graceful_restart_cmd, | |
1963 | "no bgp graceful-restart", | |
1964 | NO_STR | |
1965 | "BGP specific commands\n" | |
1966 | "Graceful restart capability parameters\n") | |
1967 | { | |
d62a17ae | 1968 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1969 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
1970 | return CMD_SUCCESS; | |
538621f2 | 1971 | } |
1972 | ||
93406d87 | 1973 | DEFUN (bgp_graceful_restart_stalepath_time, |
1974 | bgp_graceful_restart_stalepath_time_cmd, | |
c1779b7d | 1975 | "bgp graceful-restart stalepath-time (1-4095)", |
93406d87 | 1976 | "BGP specific commands\n" |
1977 | "Graceful restart capability parameters\n" | |
1978 | "Set the max time to hold onto restarting peer's stale paths\n" | |
1979 | "Delay value (seconds)\n") | |
1980 | { | |
d62a17ae | 1981 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1982 | int idx_number = 3; | |
d7c0a89a | 1983 | uint32_t stalepath; |
93406d87 | 1984 | |
d62a17ae | 1985 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
1986 | bgp->stalepath_time = stalepath; | |
1987 | return CMD_SUCCESS; | |
93406d87 | 1988 | } |
1989 | ||
eb6f1b41 PG |
1990 | DEFUN (bgp_graceful_restart_restart_time, |
1991 | bgp_graceful_restart_restart_time_cmd, | |
c72d0314 | 1992 | "bgp graceful-restart restart-time (1-4095)", |
eb6f1b41 PG |
1993 | "BGP specific commands\n" |
1994 | "Graceful restart capability parameters\n" | |
1995 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
1996 | "Delay value (seconds)\n") | |
1997 | { | |
d62a17ae | 1998 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1999 | int idx_number = 3; | |
d7c0a89a | 2000 | uint32_t restart; |
eb6f1b41 | 2001 | |
d62a17ae | 2002 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
2003 | bgp->restart_time = restart; | |
2004 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2005 | } |
2006 | ||
93406d87 | 2007 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
2008 | no_bgp_graceful_restart_stalepath_time_cmd, | |
c1779b7d | 2009 | "no bgp graceful-restart stalepath-time [(1-4095)]", |
93406d87 | 2010 | NO_STR |
2011 | "BGP specific commands\n" | |
2012 | "Graceful restart capability parameters\n" | |
838758ac DW |
2013 | "Set the max time to hold onto restarting peer's stale paths\n" |
2014 | "Delay value (seconds)\n") | |
93406d87 | 2015 | { |
d62a17ae | 2016 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 2017 | |
d62a17ae | 2018 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
2019 | return CMD_SUCCESS; | |
93406d87 | 2020 | } |
2021 | ||
eb6f1b41 PG |
2022 | DEFUN (no_bgp_graceful_restart_restart_time, |
2023 | no_bgp_graceful_restart_restart_time_cmd, | |
c72d0314 | 2024 | "no bgp graceful-restart restart-time [(1-4095)]", |
eb6f1b41 PG |
2025 | NO_STR |
2026 | "BGP specific commands\n" | |
2027 | "Graceful restart capability parameters\n" | |
838758ac DW |
2028 | "Set the time to wait to delete stale routes before a BGP open message is received\n" |
2029 | "Delay value (seconds)\n") | |
eb6f1b41 | 2030 | { |
d62a17ae | 2031 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 2032 | |
d62a17ae | 2033 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
2034 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2035 | } |
2036 | ||
43fc21b3 JC |
2037 | DEFUN (bgp_graceful_restart_preserve_fw, |
2038 | bgp_graceful_restart_preserve_fw_cmd, | |
2039 | "bgp graceful-restart preserve-fw-state", | |
2040 | "BGP specific commands\n" | |
2041 | "Graceful restart capability parameters\n" | |
2042 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
2043 | { | |
d62a17ae | 2044 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2045 | bgp_flag_set(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
2046 | return CMD_SUCCESS; | |
43fc21b3 JC |
2047 | } |
2048 | ||
2049 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
2050 | no_bgp_graceful_restart_preserve_fw_cmd, | |
2051 | "no bgp graceful-restart preserve-fw-state", | |
2052 | NO_STR | |
2053 | "BGP specific commands\n" | |
2054 | "Graceful restart capability parameters\n" | |
2055 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
2056 | { | |
d62a17ae | 2057 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2058 | bgp_flag_unset(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
2059 | return CMD_SUCCESS; | |
43fc21b3 JC |
2060 | } |
2061 | ||
7f323236 DW |
2062 | /* "bgp graceful-shutdown" configuration */ |
2063 | DEFUN (bgp_graceful_shutdown, | |
2064 | bgp_graceful_shutdown_cmd, | |
2065 | "bgp graceful-shutdown", | |
2066 | BGP_STR | |
2067 | "Graceful shutdown parameters\n") | |
2068 | { | |
2069 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2070 | ||
2071 | if (!bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
2072 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
2073 | bgp_static_redo_import_check(bgp); | |
2074 | bgp_redistribute_redo(bgp); | |
2075 | bgp_clear_star_soft_out(vty, bgp->name); | |
2076 | bgp_clear_star_soft_in(vty, bgp->name); | |
2077 | } | |
2078 | ||
2079 | return CMD_SUCCESS; | |
2080 | } | |
2081 | ||
2082 | DEFUN (no_bgp_graceful_shutdown, | |
2083 | no_bgp_graceful_shutdown_cmd, | |
2084 | "no bgp graceful-shutdown", | |
2085 | NO_STR | |
2086 | BGP_STR | |
2087 | "Graceful shutdown parameters\n") | |
2088 | { | |
2089 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2090 | ||
2091 | if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
2092 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
2093 | bgp_static_redo_import_check(bgp); | |
2094 | bgp_redistribute_redo(bgp); | |
2095 | bgp_clear_star_soft_out(vty, bgp->name); | |
2096 | bgp_clear_star_soft_in(vty, bgp->name); | |
2097 | } | |
2098 | ||
2099 | return CMD_SUCCESS; | |
2100 | } | |
2101 | ||
718e3744 | 2102 | /* "bgp fast-external-failover" configuration. */ |
2103 | DEFUN (bgp_fast_external_failover, | |
2104 | bgp_fast_external_failover_cmd, | |
2105 | "bgp fast-external-failover", | |
2106 | BGP_STR | |
2107 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2108 | { | |
d62a17ae | 2109 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2110 | bgp_flag_unset(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
2111 | return CMD_SUCCESS; | |
718e3744 | 2112 | } |
2113 | ||
2114 | DEFUN (no_bgp_fast_external_failover, | |
2115 | no_bgp_fast_external_failover_cmd, | |
2116 | "no bgp fast-external-failover", | |
2117 | NO_STR | |
2118 | BGP_STR | |
2119 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2120 | { | |
d62a17ae | 2121 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2122 | bgp_flag_set(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
2123 | return CMD_SUCCESS; | |
718e3744 | 2124 | } |
6b0655a2 | 2125 | |
718e3744 | 2126 | /* "bgp enforce-first-as" configuration. */ |
ec4f0750 | 2127 | #if CONFDATE > 20190517 |
47cbc09b PM |
2128 | CPP_NOTICE("bgpd: remove deprecated '[no] bgp enforce-first-as' commands") |
2129 | #endif | |
2130 | ||
f07e1c4f QY |
2131 | DEFUN_HIDDEN (bgp_enforce_first_as, |
2132 | bgp_enforce_first_as_cmd, | |
2133 | "[no] bgp enforce-first-as", | |
2134 | NO_STR | |
2135 | BGP_STR | |
2136 | "Enforce the first AS for EBGP routes\n") | |
718e3744 | 2137 | { |
d62a17ae | 2138 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2139 | |
f07e1c4f QY |
2140 | if (strmatch(argv[0]->text, "no")) |
2141 | bgp_flag_unset(bgp, BGP_FLAG_ENFORCE_FIRST_AS); | |
2142 | else | |
2143 | bgp_flag_set(bgp, BGP_FLAG_ENFORCE_FIRST_AS); | |
7aafcaca | 2144 | |
d62a17ae | 2145 | return CMD_SUCCESS; |
718e3744 | 2146 | } |
6b0655a2 | 2147 | |
718e3744 | 2148 | /* "bgp bestpath compare-routerid" configuration. */ |
2149 | DEFUN (bgp_bestpath_compare_router_id, | |
2150 | bgp_bestpath_compare_router_id_cmd, | |
2151 | "bgp bestpath compare-routerid", | |
2152 | "BGP specific commands\n" | |
2153 | "Change the default bestpath selection\n" | |
2154 | "Compare router-id for identical EBGP paths\n") | |
2155 | { | |
d62a17ae | 2156 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2157 | bgp_flag_set(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
2158 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2159 | |
d62a17ae | 2160 | return CMD_SUCCESS; |
718e3744 | 2161 | } |
2162 | ||
2163 | DEFUN (no_bgp_bestpath_compare_router_id, | |
2164 | no_bgp_bestpath_compare_router_id_cmd, | |
2165 | "no bgp bestpath compare-routerid", | |
2166 | NO_STR | |
2167 | "BGP specific commands\n" | |
2168 | "Change the default bestpath selection\n" | |
2169 | "Compare router-id for identical EBGP paths\n") | |
2170 | { | |
d62a17ae | 2171 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2172 | bgp_flag_unset(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
2173 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2174 | |
d62a17ae | 2175 | return CMD_SUCCESS; |
718e3744 | 2176 | } |
6b0655a2 | 2177 | |
718e3744 | 2178 | /* "bgp bestpath as-path ignore" configuration. */ |
2179 | DEFUN (bgp_bestpath_aspath_ignore, | |
2180 | bgp_bestpath_aspath_ignore_cmd, | |
2181 | "bgp bestpath as-path ignore", | |
2182 | "BGP specific commands\n" | |
2183 | "Change the default bestpath selection\n" | |
2184 | "AS-path attribute\n" | |
2185 | "Ignore as-path length in selecting a route\n") | |
2186 | { | |
d62a17ae | 2187 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2188 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2189 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2190 | |
d62a17ae | 2191 | return CMD_SUCCESS; |
718e3744 | 2192 | } |
2193 | ||
2194 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
2195 | no_bgp_bestpath_aspath_ignore_cmd, | |
2196 | "no bgp bestpath as-path ignore", | |
2197 | NO_STR | |
2198 | "BGP specific commands\n" | |
2199 | "Change the default bestpath selection\n" | |
2200 | "AS-path attribute\n" | |
2201 | "Ignore as-path length in selecting a route\n") | |
2202 | { | |
d62a17ae | 2203 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2204 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2205 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2206 | |
d62a17ae | 2207 | return CMD_SUCCESS; |
718e3744 | 2208 | } |
6b0655a2 | 2209 | |
6811845b | 2210 | /* "bgp bestpath as-path confed" configuration. */ |
2211 | DEFUN (bgp_bestpath_aspath_confed, | |
2212 | bgp_bestpath_aspath_confed_cmd, | |
2213 | "bgp bestpath as-path confed", | |
2214 | "BGP specific commands\n" | |
2215 | "Change the default bestpath selection\n" | |
2216 | "AS-path attribute\n" | |
2217 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2218 | { | |
d62a17ae | 2219 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2220 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_CONFED); | |
2221 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2222 | |
d62a17ae | 2223 | return CMD_SUCCESS; |
6811845b | 2224 | } |
2225 | ||
2226 | DEFUN (no_bgp_bestpath_aspath_confed, | |
2227 | no_bgp_bestpath_aspath_confed_cmd, | |
2228 | "no bgp bestpath as-path confed", | |
2229 | NO_STR | |
2230 | "BGP specific commands\n" | |
2231 | "Change the default bestpath selection\n" | |
2232 | "AS-path attribute\n" | |
2233 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2234 | { | |
d62a17ae | 2235 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2236 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_CONFED); | |
2237 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2238 | |
d62a17ae | 2239 | return CMD_SUCCESS; |
6811845b | 2240 | } |
6b0655a2 | 2241 | |
2fdd455c PM |
2242 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
2243 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
2244 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2245 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2246 | "BGP specific commands\n" |
2247 | "Change the default bestpath selection\n" | |
2248 | "AS-path attribute\n" | |
2249 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2250 | "Generate an AS_SET\n" |
16fc1eec DS |
2251 | "Do not generate an AS_SET\n") |
2252 | { | |
d62a17ae | 2253 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2254 | int idx = 0; | |
2255 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
219178b6 | 2256 | |
d62a17ae | 2257 | /* no-as-set is now the default behavior so we can silently |
2258 | * ignore it */ | |
2259 | if (argv_find(argv, argc, "as-set", &idx)) | |
2260 | bgp_flag_set(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2261 | else | |
2262 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
219178b6 | 2263 | |
d62a17ae | 2264 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2265 | |
d62a17ae | 2266 | return CMD_SUCCESS; |
16fc1eec DS |
2267 | } |
2268 | ||
219178b6 DW |
2269 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
2270 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2271 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2272 | NO_STR |
2273 | "BGP specific commands\n" | |
2274 | "Change the default bestpath selection\n" | |
2275 | "AS-path attribute\n" | |
2276 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2277 | "Generate an AS_SET\n" |
16fc1eec DS |
2278 | "Do not generate an AS_SET\n") |
2279 | { | |
d62a17ae | 2280 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2281 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
2282 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2283 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2284 | |
d62a17ae | 2285 | return CMD_SUCCESS; |
2fdd455c | 2286 | } |
6b0655a2 | 2287 | |
848973c7 | 2288 | /* "bgp log-neighbor-changes" configuration. */ |
2289 | DEFUN (bgp_log_neighbor_changes, | |
2290 | bgp_log_neighbor_changes_cmd, | |
2291 | "bgp log-neighbor-changes", | |
2292 | "BGP specific commands\n" | |
2293 | "Log neighbor up/down and reset reason\n") | |
2294 | { | |
d62a17ae | 2295 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2296 | bgp_flag_set(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2297 | return CMD_SUCCESS; | |
848973c7 | 2298 | } |
2299 | ||
2300 | DEFUN (no_bgp_log_neighbor_changes, | |
2301 | no_bgp_log_neighbor_changes_cmd, | |
2302 | "no bgp log-neighbor-changes", | |
2303 | NO_STR | |
2304 | "BGP specific commands\n" | |
2305 | "Log neighbor up/down and reset reason\n") | |
2306 | { | |
d62a17ae | 2307 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2308 | bgp_flag_unset(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2309 | return CMD_SUCCESS; | |
848973c7 | 2310 | } |
6b0655a2 | 2311 | |
718e3744 | 2312 | /* "bgp bestpath med" configuration. */ |
2313 | DEFUN (bgp_bestpath_med, | |
2314 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 2315 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2316 | "BGP specific commands\n" |
2317 | "Change the default bestpath selection\n" | |
2318 | "MED attribute\n" | |
2319 | "Compare MED among confederation paths\n" | |
838758ac DW |
2320 | "Treat missing MED as the least preferred one\n" |
2321 | "Treat missing MED as the least preferred one\n" | |
2322 | "Compare MED among confederation paths\n") | |
718e3744 | 2323 | { |
d62a17ae | 2324 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6cbd1915 | 2325 | |
d62a17ae | 2326 | int idx = 0; |
2327 | if (argv_find(argv, argc, "confed", &idx)) | |
2328 | bgp_flag_set(bgp, BGP_FLAG_MED_CONFED); | |
2329 | idx = 0; | |
2330 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2331 | bgp_flag_set(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
e52702f2 | 2332 | |
d62a17ae | 2333 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2334 | |
d62a17ae | 2335 | return CMD_SUCCESS; |
718e3744 | 2336 | } |
2337 | ||
718e3744 | 2338 | DEFUN (no_bgp_bestpath_med, |
2339 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2340 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2341 | NO_STR |
2342 | "BGP specific commands\n" | |
2343 | "Change the default bestpath selection\n" | |
2344 | "MED attribute\n" | |
2345 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2346 | "Treat missing MED as the least preferred one\n" |
2347 | "Treat missing MED as the least preferred one\n" | |
2348 | "Compare MED among confederation paths\n") | |
718e3744 | 2349 | { |
d62a17ae | 2350 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
e52702f2 | 2351 | |
d62a17ae | 2352 | int idx = 0; |
2353 | if (argv_find(argv, argc, "confed", &idx)) | |
2354 | bgp_flag_unset(bgp, BGP_FLAG_MED_CONFED); | |
2355 | idx = 0; | |
2356 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2357 | bgp_flag_unset(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
718e3744 | 2358 | |
d62a17ae | 2359 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2360 | |
d62a17ae | 2361 | return CMD_SUCCESS; |
718e3744 | 2362 | } |
2363 | ||
718e3744 | 2364 | /* "no bgp default ipv4-unicast". */ |
2365 | DEFUN (no_bgp_default_ipv4_unicast, | |
2366 | no_bgp_default_ipv4_unicast_cmd, | |
2367 | "no bgp default ipv4-unicast", | |
2368 | NO_STR | |
2369 | "BGP specific commands\n" | |
2370 | "Configure BGP defaults\n" | |
2371 | "Activate ipv4-unicast for a peer by default\n") | |
2372 | { | |
d62a17ae | 2373 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2374 | bgp_flag_set(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2375 | return CMD_SUCCESS; | |
718e3744 | 2376 | } |
2377 | ||
2378 | DEFUN (bgp_default_ipv4_unicast, | |
2379 | bgp_default_ipv4_unicast_cmd, | |
2380 | "bgp default ipv4-unicast", | |
2381 | "BGP specific commands\n" | |
2382 | "Configure BGP defaults\n" | |
2383 | "Activate ipv4-unicast for a peer by default\n") | |
2384 | { | |
d62a17ae | 2385 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2386 | bgp_flag_unset(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2387 | return CMD_SUCCESS; | |
718e3744 | 2388 | } |
6b0655a2 | 2389 | |
04b6bdc0 DW |
2390 | /* Display hostname in certain command outputs */ |
2391 | DEFUN (bgp_default_show_hostname, | |
2392 | bgp_default_show_hostname_cmd, | |
2393 | "bgp default show-hostname", | |
2394 | "BGP specific commands\n" | |
2395 | "Configure BGP defaults\n" | |
0437e105 | 2396 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 2397 | { |
d62a17ae | 2398 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2399 | bgp_flag_set(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2400 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2401 | } |
2402 | ||
2403 | DEFUN (no_bgp_default_show_hostname, | |
2404 | no_bgp_default_show_hostname_cmd, | |
2405 | "no bgp default show-hostname", | |
2406 | NO_STR | |
2407 | "BGP specific commands\n" | |
2408 | "Configure BGP defaults\n" | |
0437e105 | 2409 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 2410 | { |
d62a17ae | 2411 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2412 | bgp_flag_unset(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2413 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2414 | } |
2415 | ||
8233ef81 | 2416 | /* "bgp network import-check" configuration. */ |
718e3744 | 2417 | DEFUN (bgp_network_import_check, |
2418 | bgp_network_import_check_cmd, | |
5623e905 | 2419 | "bgp network import-check", |
718e3744 | 2420 | "BGP specific commands\n" |
2421 | "BGP network command\n" | |
5623e905 | 2422 | "Check BGP network route exists in IGP\n") |
718e3744 | 2423 | { |
d62a17ae | 2424 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2425 | if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2426 | bgp_flag_set(bgp, BGP_FLAG_IMPORT_CHECK); | |
2427 | bgp_static_redo_import_check(bgp); | |
2428 | } | |
078430f6 | 2429 | |
d62a17ae | 2430 | return CMD_SUCCESS; |
718e3744 | 2431 | } |
2432 | ||
d62a17ae | 2433 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
2434 | "bgp network import-check exact", | |
2435 | "BGP specific commands\n" | |
2436 | "BGP network command\n" | |
2437 | "Check BGP network route exists in IGP\n" | |
2438 | "Match route precisely\n") | |
8233ef81 | 2439 | |
718e3744 | 2440 | DEFUN (no_bgp_network_import_check, |
2441 | no_bgp_network_import_check_cmd, | |
5623e905 | 2442 | "no bgp network import-check", |
718e3744 | 2443 | NO_STR |
2444 | "BGP specific commands\n" | |
2445 | "BGP network command\n" | |
2446 | "Check BGP network route exists in IGP\n") | |
2447 | { | |
d62a17ae | 2448 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2449 | if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2450 | bgp_flag_unset(bgp, BGP_FLAG_IMPORT_CHECK); | |
2451 | bgp_static_redo_import_check(bgp); | |
2452 | } | |
5623e905 | 2453 | |
d62a17ae | 2454 | return CMD_SUCCESS; |
718e3744 | 2455 | } |
6b0655a2 | 2456 | |
718e3744 | 2457 | DEFUN (bgp_default_local_preference, |
2458 | bgp_default_local_preference_cmd, | |
6147e2c6 | 2459 | "bgp default local-preference (0-4294967295)", |
718e3744 | 2460 | "BGP specific commands\n" |
2461 | "Configure BGP defaults\n" | |
2462 | "local preference (higher=more preferred)\n" | |
2463 | "Configure default local preference value\n") | |
2464 | { | |
d62a17ae | 2465 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2466 | int idx_number = 3; | |
d7c0a89a | 2467 | uint32_t local_pref; |
718e3744 | 2468 | |
d62a17ae | 2469 | local_pref = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 2470 | |
d62a17ae | 2471 | bgp_default_local_preference_set(bgp, local_pref); |
2472 | bgp_clear_star_soft_in(vty, bgp->name); | |
718e3744 | 2473 | |
d62a17ae | 2474 | return CMD_SUCCESS; |
718e3744 | 2475 | } |
2476 | ||
2477 | DEFUN (no_bgp_default_local_preference, | |
2478 | no_bgp_default_local_preference_cmd, | |
838758ac | 2479 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 2480 | NO_STR |
2481 | "BGP specific commands\n" | |
2482 | "Configure BGP defaults\n" | |
838758ac DW |
2483 | "local preference (higher=more preferred)\n" |
2484 | "Configure default local preference value\n") | |
718e3744 | 2485 | { |
d62a17ae | 2486 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2487 | bgp_default_local_preference_unset(bgp); | |
2488 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2489 | |
d62a17ae | 2490 | return CMD_SUCCESS; |
718e3744 | 2491 | } |
2492 | ||
6b0655a2 | 2493 | |
3f9c7369 DS |
2494 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
2495 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 2496 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
2497 | "BGP specific commands\n" |
2498 | "Configure BGP defaults\n" | |
2499 | "subgroup-pkt-queue-max\n" | |
2500 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 2501 | { |
d62a17ae | 2502 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2503 | int idx_number = 3; | |
d7c0a89a | 2504 | uint32_t max_size; |
8bd9d948 | 2505 | |
d62a17ae | 2506 | max_size = strtoul(argv[idx_number]->arg, NULL, 10); |
3f9c7369 | 2507 | |
d62a17ae | 2508 | bgp_default_subgroup_pkt_queue_max_set(bgp, max_size); |
3f9c7369 | 2509 | |
d62a17ae | 2510 | return CMD_SUCCESS; |
3f9c7369 DS |
2511 | } |
2512 | ||
2513 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
2514 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 2515 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
2516 | NO_STR |
2517 | "BGP specific commands\n" | |
2518 | "Configure BGP defaults\n" | |
838758ac DW |
2519 | "subgroup-pkt-queue-max\n" |
2520 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 2521 | { |
d62a17ae | 2522 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2523 | bgp_default_subgroup_pkt_queue_max_unset(bgp); | |
2524 | return CMD_SUCCESS; | |
8bd9d948 DS |
2525 | } |
2526 | ||
813d4307 | 2527 | |
8bd9d948 DS |
2528 | DEFUN (bgp_rr_allow_outbound_policy, |
2529 | bgp_rr_allow_outbound_policy_cmd, | |
2530 | "bgp route-reflector allow-outbound-policy", | |
2531 | "BGP specific commands\n" | |
2532 | "Allow modifications made by out route-map\n" | |
2533 | "on ibgp neighbors\n") | |
2534 | { | |
d62a17ae | 2535 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2536 | |
d62a17ae | 2537 | if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2538 | bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2539 | update_group_announce_rrclients(bgp); | |
2540 | bgp_clear_star_soft_out(vty, bgp->name); | |
2541 | } | |
8bd9d948 | 2542 | |
d62a17ae | 2543 | return CMD_SUCCESS; |
8bd9d948 DS |
2544 | } |
2545 | ||
2546 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
2547 | no_bgp_rr_allow_outbound_policy_cmd, | |
2548 | "no bgp route-reflector allow-outbound-policy", | |
2549 | NO_STR | |
2550 | "BGP specific commands\n" | |
2551 | "Allow modifications made by out route-map\n" | |
2552 | "on ibgp neighbors\n") | |
2553 | { | |
d62a17ae | 2554 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2555 | |
d62a17ae | 2556 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2557 | bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2558 | update_group_announce_rrclients(bgp); | |
2559 | bgp_clear_star_soft_out(vty, bgp->name); | |
2560 | } | |
8bd9d948 | 2561 | |
d62a17ae | 2562 | return CMD_SUCCESS; |
8bd9d948 DS |
2563 | } |
2564 | ||
f14e6fdb DS |
2565 | DEFUN (bgp_listen_limit, |
2566 | bgp_listen_limit_cmd, | |
9ccf14f7 | 2567 | "bgp listen limit (1-5000)", |
f14e6fdb DS |
2568 | "BGP specific commands\n" |
2569 | "Configure BGP defaults\n" | |
2570 | "maximum number of BGP Dynamic Neighbors that can be created\n" | |
2571 | "Configure Dynamic Neighbors listen limit value\n") | |
2572 | { | |
d62a17ae | 2573 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2574 | int idx_number = 3; | |
2575 | int listen_limit; | |
f14e6fdb | 2576 | |
d62a17ae | 2577 | listen_limit = strtoul(argv[idx_number]->arg, NULL, 10); |
f14e6fdb | 2578 | |
d62a17ae | 2579 | bgp_listen_limit_set(bgp, listen_limit); |
f14e6fdb | 2580 | |
d62a17ae | 2581 | return CMD_SUCCESS; |
f14e6fdb DS |
2582 | } |
2583 | ||
2584 | DEFUN (no_bgp_listen_limit, | |
2585 | no_bgp_listen_limit_cmd, | |
838758ac | 2586 | "no bgp listen limit [(1-5000)]", |
f14e6fdb DS |
2587 | "BGP specific commands\n" |
2588 | "Configure BGP defaults\n" | |
2589 | "unset maximum number of BGP Dynamic Neighbors that can be created\n" | |
838758ac DW |
2590 | "Configure Dynamic Neighbors listen limit value to default\n" |
2591 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 2592 | { |
d62a17ae | 2593 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2594 | bgp_listen_limit_unset(bgp); | |
2595 | return CMD_SUCCESS; | |
f14e6fdb DS |
2596 | } |
2597 | ||
2598 | ||
20eb8864 | 2599 | /* |
2600 | * Check if this listen range is already configured. Check for exact | |
2601 | * match or overlap based on input. | |
2602 | */ | |
d62a17ae | 2603 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
2604 | struct prefix *range, int exact) | |
2605 | { | |
2606 | struct listnode *node, *nnode; | |
2607 | struct listnode *node1, *nnode1; | |
2608 | struct peer_group *group; | |
2609 | struct prefix *lr; | |
2610 | afi_t afi; | |
2611 | int match; | |
2612 | ||
2613 | afi = family2afi(range->family); | |
2614 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2615 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
2616 | lr)) { | |
2617 | if (exact) | |
2618 | match = prefix_same(range, lr); | |
2619 | else | |
2620 | match = (prefix_match(range, lr) | |
2621 | || prefix_match(lr, range)); | |
2622 | if (match) | |
2623 | return group; | |
2624 | } | |
2625 | } | |
2626 | ||
2627 | return NULL; | |
20eb8864 | 2628 | } |
2629 | ||
f14e6fdb DS |
2630 | DEFUN (bgp_listen_range, |
2631 | bgp_listen_range_cmd, | |
9ccf14f7 | 2632 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
f14e6fdb | 2633 | "BGP specific commands\n" |
d7fa34c1 QY |
2634 | "Configure BGP dynamic neighbors listen range\n" |
2635 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
2636 | NEIGHBOR_ADDR_STR |
2637 | "Member of the peer-group\n" | |
2638 | "Peer-group name\n") | |
f14e6fdb | 2639 | { |
d62a17ae | 2640 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2641 | struct prefix range; | |
2642 | struct peer_group *group, *existing_group; | |
2643 | afi_t afi; | |
2644 | int ret; | |
2645 | int idx = 0; | |
2646 | ||
2647 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2648 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2649 | char *prefix = argv[idx]->arg; | |
2650 | argv_find(argv, argc, "WORD", &idx); | |
2651 | char *peergroup = argv[idx]->arg; | |
2652 | ||
2653 | /* Convert IP prefix string to struct prefix. */ | |
2654 | ret = str2prefix(prefix, &range); | |
2655 | if (!ret) { | |
2656 | vty_out(vty, "%% Malformed listen range\n"); | |
2657 | return CMD_WARNING_CONFIG_FAILED; | |
2658 | } | |
2659 | ||
2660 | afi = family2afi(range.family); | |
2661 | ||
2662 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2663 | vty_out(vty, | |
2664 | "%% Malformed listen range (link-local address)\n"); | |
2665 | return CMD_WARNING_CONFIG_FAILED; | |
2666 | } | |
2667 | ||
2668 | apply_mask(&range); | |
2669 | ||
2670 | /* Check if same listen range is already configured. */ | |
2671 | existing_group = listen_range_exists(bgp, &range, 1); | |
2672 | if (existing_group) { | |
2673 | if (strcmp(existing_group->name, peergroup) == 0) | |
2674 | return CMD_SUCCESS; | |
2675 | else { | |
2676 | vty_out(vty, | |
2677 | "%% Same listen range is attached to peer-group %s\n", | |
2678 | existing_group->name); | |
2679 | return CMD_WARNING_CONFIG_FAILED; | |
2680 | } | |
2681 | } | |
2682 | ||
2683 | /* Check if an overlapping listen range exists. */ | |
2684 | if (listen_range_exists(bgp, &range, 0)) { | |
2685 | vty_out(vty, | |
2686 | "%% Listen range overlaps with existing listen range\n"); | |
2687 | return CMD_WARNING_CONFIG_FAILED; | |
2688 | } | |
2689 | ||
2690 | group = peer_group_lookup(bgp, peergroup); | |
2691 | if (!group) { | |
2692 | vty_out(vty, "%% Configure the peer-group first\n"); | |
2693 | return CMD_WARNING_CONFIG_FAILED; | |
2694 | } | |
2695 | ||
2696 | ret = peer_group_listen_range_add(group, &range); | |
2697 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
2698 | } |
2699 | ||
2700 | DEFUN (no_bgp_listen_range, | |
2701 | no_bgp_listen_range_cmd, | |
d7fa34c1 QY |
2702 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
2703 | NO_STR | |
f14e6fdb | 2704 | "BGP specific commands\n" |
d7fa34c1 QY |
2705 | "Unconfigure BGP dynamic neighbors listen range\n" |
2706 | "Unconfigure BGP dynamic neighbors listen range\n" | |
2707 | NEIGHBOR_ADDR_STR | |
2708 | "Member of the peer-group\n" | |
2709 | "Peer-group name\n") | |
f14e6fdb | 2710 | { |
d62a17ae | 2711 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2712 | struct prefix range; | |
2713 | struct peer_group *group; | |
2714 | afi_t afi; | |
2715 | int ret; | |
2716 | int idx = 0; | |
2717 | ||
2718 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2719 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2720 | char *prefix = argv[idx]->arg; | |
2721 | argv_find(argv, argc, "WORD", &idx); | |
2722 | char *peergroup = argv[idx]->arg; | |
2723 | ||
2724 | /* Convert IP prefix string to struct prefix. */ | |
2725 | ret = str2prefix(prefix, &range); | |
2726 | if (!ret) { | |
2727 | vty_out(vty, "%% Malformed listen range\n"); | |
2728 | return CMD_WARNING_CONFIG_FAILED; | |
2729 | } | |
2730 | ||
2731 | afi = family2afi(range.family); | |
2732 | ||
2733 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2734 | vty_out(vty, | |
2735 | "%% Malformed listen range (link-local address)\n"); | |
2736 | return CMD_WARNING_CONFIG_FAILED; | |
2737 | } | |
2738 | ||
2739 | apply_mask(&range); | |
2740 | ||
2741 | group = peer_group_lookup(bgp, peergroup); | |
2742 | if (!group) { | |
2743 | vty_out(vty, "%% Peer-group does not exist\n"); | |
2744 | return CMD_WARNING_CONFIG_FAILED; | |
2745 | } | |
2746 | ||
2747 | ret = peer_group_listen_range_del(group, &range); | |
2748 | return bgp_vty_return(vty, ret); | |
2749 | } | |
2750 | ||
2b791107 | 2751 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 2752 | { |
2753 | struct peer_group *group; | |
2754 | struct listnode *node, *nnode, *rnode, *nrnode; | |
2755 | struct prefix *range; | |
2756 | afi_t afi; | |
2757 | char buf[PREFIX2STR_BUFFER]; | |
2758 | ||
2759 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
2760 | vty_out(vty, " bgp listen limit %d\n", | |
2761 | bgp->dynamic_neighbors_limit); | |
2762 | ||
2763 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2764 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
2765 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
2766 | nrnode, range)) { | |
2767 | prefix2str(range, buf, sizeof(buf)); | |
2768 | vty_out(vty, | |
2769 | " bgp listen range %s peer-group %s\n", | |
2770 | buf, group->name); | |
2771 | } | |
2772 | } | |
2773 | } | |
f14e6fdb DS |
2774 | } |
2775 | ||
2776 | ||
907f92c8 DS |
2777 | DEFUN (bgp_disable_connected_route_check, |
2778 | bgp_disable_connected_route_check_cmd, | |
2779 | "bgp disable-ebgp-connected-route-check", | |
2780 | "BGP specific commands\n" | |
2781 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2782 | { | |
d62a17ae | 2783 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2784 | bgp_flag_set(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2785 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2786 | |
d62a17ae | 2787 | return CMD_SUCCESS; |
907f92c8 DS |
2788 | } |
2789 | ||
2790 | DEFUN (no_bgp_disable_connected_route_check, | |
2791 | no_bgp_disable_connected_route_check_cmd, | |
2792 | "no bgp disable-ebgp-connected-route-check", | |
2793 | NO_STR | |
2794 | "BGP specific commands\n" | |
2795 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2796 | { | |
d62a17ae | 2797 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2798 | bgp_flag_unset(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2799 | bgp_clear_star_soft_in(vty, bgp->name); | |
2800 | ||
2801 | return CMD_SUCCESS; | |
2802 | } | |
2803 | ||
2804 | ||
2805 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, | |
2806 | const char *as_str, afi_t afi, safi_t safi) | |
2807 | { | |
2808 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2809 | int ret; | |
2810 | as_t as; | |
2811 | int as_type = AS_SPECIFIED; | |
2812 | union sockunion su; | |
2813 | ||
2814 | if (as_str[0] == 'i') { | |
2815 | as = 0; | |
2816 | as_type = AS_INTERNAL; | |
2817 | } else if (as_str[0] == 'e') { | |
2818 | as = 0; | |
2819 | as_type = AS_EXTERNAL; | |
2820 | } else { | |
2821 | /* Get AS number. */ | |
2822 | as = strtoul(as_str, NULL, 10); | |
2823 | } | |
2824 | ||
390485fd | 2825 | /* If peer is peer group or interface peer, call proper function. */ |
d62a17ae | 2826 | ret = str2sockunion(peer_str, &su); |
2827 | if (ret < 0) { | |
390485fd DS |
2828 | struct peer *peer; |
2829 | ||
2830 | /* Check if existing interface peer */ | |
2831 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
2832 | ||
d62a17ae | 2833 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type, afi, |
2834 | safi); | |
390485fd DS |
2835 | |
2836 | /* if not interface peer, check peer-group settings */ | |
2837 | if (ret < 0 && !peer) { | |
d62a17ae | 2838 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); |
2839 | if (ret < 0) { | |
2840 | vty_out(vty, | |
390485fd | 2841 | "%% Create the peer-group or interface first\n"); |
d62a17ae | 2842 | return CMD_WARNING_CONFIG_FAILED; |
2843 | } | |
2844 | return CMD_SUCCESS; | |
2845 | } | |
2846 | } else { | |
2847 | if (peer_address_self_check(bgp, &su)) { | |
2848 | vty_out(vty, | |
2849 | "%% Can not configure the local system as neighbor\n"); | |
2850 | return CMD_WARNING_CONFIG_FAILED; | |
2851 | } | |
2852 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type, afi, safi); | |
2853 | } | |
2854 | ||
2855 | /* This peer belongs to peer group. */ | |
2856 | switch (ret) { | |
2857 | case BGP_ERR_PEER_GROUP_MEMBER: | |
2858 | vty_out(vty, | |
faa16034 | 2859 | "%% Peer-group member cannot override remote-as of peer-group\n"); |
d62a17ae | 2860 | return CMD_WARNING_CONFIG_FAILED; |
2861 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
2862 | vty_out(vty, | |
faa16034 | 2863 | "%% Peer-group members must be all internal or all external\n"); |
d62a17ae | 2864 | return CMD_WARNING_CONFIG_FAILED; |
2865 | } | |
2866 | return bgp_vty_return(vty, ret); | |
718e3744 | 2867 | } |
2868 | ||
f26845f9 QY |
2869 | DEFUN (bgp_default_shutdown, |
2870 | bgp_default_shutdown_cmd, | |
2871 | "[no] bgp default shutdown", | |
2872 | NO_STR | |
2873 | BGP_STR | |
2874 | "Configure BGP defaults\n" | |
b012cbe2 | 2875 | "Apply administrative shutdown to newly configured peers\n") |
f26845f9 QY |
2876 | { |
2877 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2878 | bgp->autoshutdown = !strmatch(argv[0]->text, "no"); | |
2879 | return CMD_SUCCESS; | |
2880 | } | |
2881 | ||
718e3744 | 2882 | DEFUN (neighbor_remote_as, |
2883 | neighbor_remote_as_cmd, | |
3a2d747c | 2884 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2885 | NEIGHBOR_STR |
2886 | NEIGHBOR_ADDR_STR2 | |
2887 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 2888 | AS_STR |
3a2d747c QY |
2889 | "Internal BGP peer\n" |
2890 | "External BGP peer\n") | |
718e3744 | 2891 | { |
d62a17ae | 2892 | int idx_peer = 1; |
2893 | int idx_remote_as = 3; | |
2894 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, | |
2895 | argv[idx_remote_as]->arg, AFI_IP, | |
2896 | SAFI_UNICAST); | |
2897 | } | |
2898 | ||
2899 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, | |
2900 | afi_t afi, safi_t safi, int v6only, | |
2901 | const char *peer_group_name, | |
2902 | const char *as_str) | |
2903 | { | |
2904 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2905 | as_t as = 0; | |
2906 | int as_type = AS_UNSPECIFIED; | |
2907 | struct peer *peer; | |
2908 | struct peer_group *group; | |
2909 | int ret = 0; | |
2910 | union sockunion su; | |
2911 | ||
2912 | group = peer_group_lookup(bgp, conf_if); | |
2913 | ||
2914 | if (group) { | |
2915 | vty_out(vty, "%% Name conflict with peer-group \n"); | |
2916 | return CMD_WARNING_CONFIG_FAILED; | |
2917 | } | |
2918 | ||
2919 | if (as_str) { | |
2920 | if (as_str[0] == 'i') { | |
2921 | as_type = AS_INTERNAL; | |
2922 | } else if (as_str[0] == 'e') { | |
2923 | as_type = AS_EXTERNAL; | |
2924 | } else { | |
2925 | /* Get AS number. */ | |
2926 | as = strtoul(as_str, NULL, 10); | |
2927 | as_type = AS_SPECIFIED; | |
2928 | } | |
2929 | } | |
2930 | ||
2931 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
2932 | if (peer) { | |
2933 | if (as_str) | |
cc4d4ce8 | 2934 | ret = peer_remote_as(bgp, NULL, conf_if, &as, as_type, |
d62a17ae | 2935 | afi, safi); |
2936 | } else { | |
2937 | if (bgp_flag_check(bgp, BGP_FLAG_NO_DEFAULT_IPV4) | |
2938 | && afi == AFI_IP && safi == SAFI_UNICAST) | |
2939 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
2940 | as_type, 0, 0, NULL); | |
2941 | else | |
2942 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
2943 | as_type, afi, safi, NULL); | |
2944 | ||
2945 | if (!peer) { | |
2946 | vty_out(vty, "%% BGP failed to create peer\n"); | |
2947 | return CMD_WARNING_CONFIG_FAILED; | |
2948 | } | |
2949 | ||
2950 | if (v6only) | |
527de3dc | 2951 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 2952 | |
2953 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
2954 | * this | |
2955 | * any unnumbered peer in order to not worry about run-time | |
2956 | * transitions | |
2957 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
2958 | * address | |
2959 | * gets deleted later etc.) | |
2960 | */ | |
2961 | if (peer->ifp) | |
2962 | bgp_zebra_initiate_radv(bgp, peer); | |
2963 | } | |
2964 | ||
2965 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
2966 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
2967 | if (v6only) | |
527de3dc | 2968 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 2969 | else |
527de3dc | 2970 | peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 2971 | |
2972 | /* v6only flag changed. Reset bgp seesion */ | |
2973 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2974 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
2975 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2976 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2977 | } else | |
2978 | bgp_session_reset(peer); | |
2979 | } | |
2980 | ||
9fb964de PM |
2981 | if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) { |
2982 | SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE); | |
2983 | SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE); | |
dc2f50f3 | 2984 | SET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE); |
9fb964de | 2985 | } |
d62a17ae | 2986 | |
2987 | if (peer_group_name) { | |
2988 | group = peer_group_lookup(bgp, peer_group_name); | |
2989 | if (!group) { | |
2990 | vty_out(vty, "%% Configure the peer-group first\n"); | |
2991 | return CMD_WARNING_CONFIG_FAILED; | |
2992 | } | |
2993 | ||
2994 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
2995 | } | |
2996 | ||
2997 | return bgp_vty_return(vty, ret); | |
a80beece DS |
2998 | } |
2999 | ||
4c48cf63 DW |
3000 | DEFUN (neighbor_interface_config, |
3001 | neighbor_interface_config_cmd, | |
31500417 | 3002 | "neighbor WORD interface [peer-group WORD]", |
4c48cf63 DW |
3003 | NEIGHBOR_STR |
3004 | "Interface name or neighbor tag\n" | |
31500417 DW |
3005 | "Enable BGP on interface\n" |
3006 | "Member of the peer-group\n" | |
16cedbb0 | 3007 | "Peer-group name\n") |
4c48cf63 | 3008 | { |
d62a17ae | 3009 | int idx_word = 1; |
3010 | int idx_peer_group_word = 4; | |
31500417 | 3011 | |
d62a17ae | 3012 | if (argc > idx_peer_group_word) |
3013 | return peer_conf_interface_get( | |
3014 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
3015 | argv[idx_peer_group_word]->arg, NULL); | |
3016 | else | |
3017 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3018 | SAFI_UNICAST, 0, NULL, NULL); | |
4c48cf63 DW |
3019 | } |
3020 | ||
4c48cf63 DW |
3021 | DEFUN (neighbor_interface_config_v6only, |
3022 | neighbor_interface_config_v6only_cmd, | |
31500417 | 3023 | "neighbor WORD interface v6only [peer-group WORD]", |
4c48cf63 DW |
3024 | NEIGHBOR_STR |
3025 | "Interface name or neighbor tag\n" | |
3026 | "Enable BGP on interface\n" | |
31500417 DW |
3027 | "Enable BGP with v6 link-local only\n" |
3028 | "Member of the peer-group\n" | |
16cedbb0 | 3029 | "Peer-group name\n") |
4c48cf63 | 3030 | { |
d62a17ae | 3031 | int idx_word = 1; |
3032 | int idx_peer_group_word = 5; | |
31500417 | 3033 | |
d62a17ae | 3034 | if (argc > idx_peer_group_word) |
3035 | return peer_conf_interface_get( | |
3036 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
3037 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 3038 | |
d62a17ae | 3039 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, |
3040 | SAFI_UNICAST, 1, NULL, NULL); | |
4c48cf63 DW |
3041 | } |
3042 | ||
a80beece | 3043 | |
b3a39dc5 DD |
3044 | DEFUN (neighbor_interface_config_remote_as, |
3045 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 3046 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
3047 | NEIGHBOR_STR |
3048 | "Interface name or neighbor tag\n" | |
3049 | "Enable BGP on interface\n" | |
3a2d747c | 3050 | "Specify a BGP neighbor\n" |
d7fa34c1 | 3051 | AS_STR |
3a2d747c QY |
3052 | "Internal BGP peer\n" |
3053 | "External BGP peer\n") | |
b3a39dc5 | 3054 | { |
d62a17ae | 3055 | int idx_word = 1; |
3056 | int idx_remote_as = 4; | |
3057 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3058 | SAFI_UNICAST, 0, NULL, | |
3059 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
3060 | } |
3061 | ||
3062 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
3063 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 3064 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
3065 | NEIGHBOR_STR |
3066 | "Interface name or neighbor tag\n" | |
3a2d747c | 3067 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 3068 | "Enable BGP on interface\n" |
3a2d747c | 3069 | "Specify a BGP neighbor\n" |
d7fa34c1 | 3070 | AS_STR |
3a2d747c QY |
3071 | "Internal BGP peer\n" |
3072 | "External BGP peer\n") | |
b3a39dc5 | 3073 | { |
d62a17ae | 3074 | int idx_word = 1; |
3075 | int idx_remote_as = 5; | |
3076 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3077 | SAFI_UNICAST, 1, NULL, | |
3078 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
3079 | } |
3080 | ||
718e3744 | 3081 | DEFUN (neighbor_peer_group, |
3082 | neighbor_peer_group_cmd, | |
3083 | "neighbor WORD peer-group", | |
3084 | NEIGHBOR_STR | |
a80beece | 3085 | "Interface name or neighbor tag\n" |
718e3744 | 3086 | "Configure peer-group\n") |
3087 | { | |
d62a17ae | 3088 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3089 | int idx_word = 1; | |
3090 | struct peer *peer; | |
3091 | struct peer_group *group; | |
718e3744 | 3092 | |
d62a17ae | 3093 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
3094 | if (peer) { | |
3095 | vty_out(vty, "%% Name conflict with interface: \n"); | |
3096 | return CMD_WARNING_CONFIG_FAILED; | |
3097 | } | |
718e3744 | 3098 | |
d62a17ae | 3099 | group = peer_group_get(bgp, argv[idx_word]->arg); |
3100 | if (!group) { | |
3101 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
3102 | return CMD_WARNING_CONFIG_FAILED; | |
3103 | } | |
718e3744 | 3104 | |
d62a17ae | 3105 | return CMD_SUCCESS; |
718e3744 | 3106 | } |
3107 | ||
3108 | DEFUN (no_neighbor, | |
3109 | no_neighbor_cmd, | |
dab8cd00 | 3110 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 3111 | NO_STR |
3112 | NEIGHBOR_STR | |
3a2d747c QY |
3113 | NEIGHBOR_ADDR_STR2 |
3114 | "Specify a BGP neighbor\n" | |
3115 | AS_STR | |
3116 | "Internal BGP peer\n" | |
3117 | "External BGP peer\n") | |
718e3744 | 3118 | { |
d62a17ae | 3119 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3120 | int idx_peer = 2; | |
3121 | int ret; | |
3122 | union sockunion su; | |
3123 | struct peer_group *group; | |
3124 | struct peer *peer; | |
3125 | struct peer *other; | |
3126 | ||
3127 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
3128 | if (ret < 0) { | |
3129 | /* look up for neighbor by interface name config. */ | |
3130 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3131 | if (peer) { | |
3132 | /* Request zebra to terminate IPv6 RAs on this | |
3133 | * interface. */ | |
3134 | if (peer->ifp) | |
3135 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
3136 | peer_delete(peer); | |
3137 | return CMD_SUCCESS; | |
3138 | } | |
f14e6fdb | 3139 | |
d62a17ae | 3140 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); |
3141 | if (group) | |
3142 | peer_group_delete(group); | |
3143 | else { | |
3144 | vty_out(vty, "%% Create the peer-group first\n"); | |
3145 | return CMD_WARNING_CONFIG_FAILED; | |
3146 | } | |
3147 | } else { | |
3148 | peer = peer_lookup(bgp, &su); | |
3149 | if (peer) { | |
3150 | if (peer_dynamic_neighbor(peer)) { | |
3151 | vty_out(vty, | |
3152 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3153 | return CMD_WARNING_CONFIG_FAILED; | |
3154 | } | |
3155 | ||
3156 | other = peer->doppelganger; | |
3157 | peer_delete(peer); | |
3158 | if (other && other->status != Deleted) | |
3159 | peer_delete(other); | |
3160 | } | |
1ff9a340 | 3161 | } |
718e3744 | 3162 | |
d62a17ae | 3163 | return CMD_SUCCESS; |
718e3744 | 3164 | } |
3165 | ||
a80beece DS |
3166 | DEFUN (no_neighbor_interface_config, |
3167 | no_neighbor_interface_config_cmd, | |
31500417 | 3168 | "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
3169 | NO_STR |
3170 | NEIGHBOR_STR | |
3171 | "Interface name\n" | |
31500417 DW |
3172 | "Configure BGP on interface\n" |
3173 | "Enable BGP with v6 link-local only\n" | |
3174 | "Member of the peer-group\n" | |
16cedbb0 | 3175 | "Peer-group name\n" |
3a2d747c QY |
3176 | "Specify a BGP neighbor\n" |
3177 | AS_STR | |
3178 | "Internal BGP peer\n" | |
3179 | "External BGP peer\n") | |
a80beece | 3180 | { |
d62a17ae | 3181 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3182 | int idx_word = 2; | |
3183 | struct peer *peer; | |
3184 | ||
3185 | /* look up for neighbor by interface name config. */ | |
3186 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3187 | if (peer) { | |
3188 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
3189 | if (peer->ifp) | |
3190 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
3191 | peer_delete(peer); | |
3192 | } else { | |
3193 | vty_out(vty, "%% Create the bgp interface first\n"); | |
3194 | return CMD_WARNING_CONFIG_FAILED; | |
3195 | } | |
3196 | return CMD_SUCCESS; | |
a80beece DS |
3197 | } |
3198 | ||
718e3744 | 3199 | DEFUN (no_neighbor_peer_group, |
3200 | no_neighbor_peer_group_cmd, | |
3201 | "no neighbor WORD peer-group", | |
3202 | NO_STR | |
3203 | NEIGHBOR_STR | |
3204 | "Neighbor tag\n" | |
3205 | "Configure peer-group\n") | |
3206 | { | |
d62a17ae | 3207 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3208 | int idx_word = 2; | |
3209 | struct peer_group *group; | |
718e3744 | 3210 | |
d62a17ae | 3211 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
3212 | if (group) | |
3213 | peer_group_delete(group); | |
3214 | else { | |
3215 | vty_out(vty, "%% Create the peer-group first\n"); | |
3216 | return CMD_WARNING_CONFIG_FAILED; | |
3217 | } | |
3218 | return CMD_SUCCESS; | |
718e3744 | 3219 | } |
3220 | ||
a80beece DS |
3221 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
3222 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 3223 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3224 | NO_STR |
3225 | NEIGHBOR_STR | |
a80beece | 3226 | "Interface name or neighbor tag\n" |
718e3744 | 3227 | "Specify a BGP neighbor\n" |
3a2d747c QY |
3228 | AS_STR |
3229 | "Internal BGP peer\n" | |
3230 | "External BGP peer\n") | |
718e3744 | 3231 | { |
d62a17ae | 3232 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3233 | int idx_word = 2; | |
3234 | struct peer_group *group; | |
3235 | struct peer *peer; | |
3236 | ||
3237 | /* look up for neighbor by interface name config. */ | |
3238 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3239 | if (peer) { | |
390485fd | 3240 | peer_as_change(peer, 0, AS_UNSPECIFIED); |
d62a17ae | 3241 | return CMD_SUCCESS; |
3242 | } | |
3243 | ||
3244 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3245 | if (group) | |
3246 | peer_group_remote_as_delete(group); | |
3247 | else { | |
3248 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
3249 | return CMD_WARNING_CONFIG_FAILED; | |
3250 | } | |
3251 | return CMD_SUCCESS; | |
718e3744 | 3252 | } |
6b0655a2 | 3253 | |
718e3744 | 3254 | DEFUN (neighbor_local_as, |
3255 | neighbor_local_as_cmd, | |
9ccf14f7 | 3256 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 3257 | NEIGHBOR_STR |
3258 | NEIGHBOR_ADDR_STR2 | |
3259 | "Specify a local-as number\n" | |
3260 | "AS number used as local AS\n") | |
3261 | { | |
d62a17ae | 3262 | int idx_peer = 1; |
3263 | int idx_number = 3; | |
3264 | struct peer *peer; | |
3265 | int ret; | |
3266 | as_t as; | |
718e3744 | 3267 | |
d62a17ae | 3268 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3269 | if (!peer) | |
3270 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3271 | |
d62a17ae | 3272 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3273 | ret = peer_local_as_set(peer, as, 0, 0); | |
3274 | return bgp_vty_return(vty, ret); | |
718e3744 | 3275 | } |
3276 | ||
3277 | DEFUN (neighbor_local_as_no_prepend, | |
3278 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 3279 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 3280 | NEIGHBOR_STR |
3281 | NEIGHBOR_ADDR_STR2 | |
3282 | "Specify a local-as number\n" | |
3283 | "AS number used as local AS\n" | |
3284 | "Do not prepend local-as to updates from ebgp peers\n") | |
3285 | { | |
d62a17ae | 3286 | int idx_peer = 1; |
3287 | int idx_number = 3; | |
3288 | struct peer *peer; | |
3289 | int ret; | |
3290 | as_t as; | |
718e3744 | 3291 | |
d62a17ae | 3292 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3293 | if (!peer) | |
3294 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3295 | |
d62a17ae | 3296 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3297 | ret = peer_local_as_set(peer, as, 1, 0); | |
3298 | return bgp_vty_return(vty, ret); | |
718e3744 | 3299 | } |
3300 | ||
9d3f9705 AC |
3301 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
3302 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 3303 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
3304 | NEIGHBOR_STR |
3305 | NEIGHBOR_ADDR_STR2 | |
3306 | "Specify a local-as number\n" | |
3307 | "AS number used as local AS\n" | |
3308 | "Do not prepend local-as to updates from ebgp peers\n" | |
3309 | "Do not prepend local-as to updates from ibgp peers\n") | |
3310 | { | |
d62a17ae | 3311 | int idx_peer = 1; |
3312 | int idx_number = 3; | |
3313 | struct peer *peer; | |
3314 | int ret; | |
3315 | as_t as; | |
9d3f9705 | 3316 | |
d62a17ae | 3317 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3318 | if (!peer) | |
3319 | return CMD_WARNING_CONFIG_FAILED; | |
9d3f9705 | 3320 | |
d62a17ae | 3321 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3322 | ret = peer_local_as_set(peer, as, 1, 1); | |
3323 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
3324 | } |
3325 | ||
718e3744 | 3326 | DEFUN (no_neighbor_local_as, |
3327 | no_neighbor_local_as_cmd, | |
a636c635 | 3328 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 3329 | NO_STR |
3330 | NEIGHBOR_STR | |
3331 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
3332 | "Specify a local-as number\n" |
3333 | "AS number used as local AS\n" | |
3334 | "Do not prepend local-as to updates from ebgp peers\n" | |
3335 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 3336 | { |
d62a17ae | 3337 | int idx_peer = 2; |
3338 | struct peer *peer; | |
3339 | int ret; | |
718e3744 | 3340 | |
d62a17ae | 3341 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3342 | if (!peer) | |
3343 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3344 | |
d62a17ae | 3345 | ret = peer_local_as_unset(peer); |
3346 | return bgp_vty_return(vty, ret); | |
718e3744 | 3347 | } |
3348 | ||
718e3744 | 3349 | |
3f9c7369 DS |
3350 | DEFUN (neighbor_solo, |
3351 | neighbor_solo_cmd, | |
9ccf14f7 | 3352 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3353 | NEIGHBOR_STR |
3354 | NEIGHBOR_ADDR_STR2 | |
3355 | "Solo peer - part of its own update group\n") | |
3356 | { | |
d62a17ae | 3357 | int idx_peer = 1; |
3358 | struct peer *peer; | |
3359 | int ret; | |
3f9c7369 | 3360 | |
d62a17ae | 3361 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3362 | if (!peer) | |
3363 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3364 | |
d62a17ae | 3365 | ret = update_group_adjust_soloness(peer, 1); |
3366 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3367 | } |
3368 | ||
3369 | DEFUN (no_neighbor_solo, | |
3370 | no_neighbor_solo_cmd, | |
9ccf14f7 | 3371 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3372 | NO_STR |
3373 | NEIGHBOR_STR | |
3374 | NEIGHBOR_ADDR_STR2 | |
3375 | "Solo peer - part of its own update group\n") | |
3376 | { | |
d62a17ae | 3377 | int idx_peer = 2; |
3378 | struct peer *peer; | |
3379 | int ret; | |
3f9c7369 | 3380 | |
d62a17ae | 3381 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3382 | if (!peer) | |
3383 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3384 | |
d62a17ae | 3385 | ret = update_group_adjust_soloness(peer, 0); |
3386 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3387 | } |
3388 | ||
0df7c91f PJ |
3389 | DEFUN (neighbor_password, |
3390 | neighbor_password_cmd, | |
9ccf14f7 | 3391 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
3392 | NEIGHBOR_STR |
3393 | NEIGHBOR_ADDR_STR2 | |
3394 | "Set a password\n" | |
3395 | "The password\n") | |
3396 | { | |
d62a17ae | 3397 | int idx_peer = 1; |
3398 | int idx_line = 3; | |
3399 | struct peer *peer; | |
3400 | int ret; | |
0df7c91f | 3401 | |
d62a17ae | 3402 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3403 | if (!peer) | |
3404 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3405 | |
d62a17ae | 3406 | ret = peer_password_set(peer, argv[idx_line]->arg); |
3407 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
3408 | } |
3409 | ||
3410 | DEFUN (no_neighbor_password, | |
3411 | no_neighbor_password_cmd, | |
a636c635 | 3412 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
3413 | NO_STR |
3414 | NEIGHBOR_STR | |
3415 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
3416 | "Set a password\n" |
3417 | "The password\n") | |
0df7c91f | 3418 | { |
d62a17ae | 3419 | int idx_peer = 2; |
3420 | struct peer *peer; | |
3421 | int ret; | |
0df7c91f | 3422 | |
d62a17ae | 3423 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3424 | if (!peer) | |
3425 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3426 | |
d62a17ae | 3427 | ret = peer_password_unset(peer); |
3428 | return bgp_vty_return(vty, ret); | |
0df7c91f | 3429 | } |
6b0655a2 | 3430 | |
718e3744 | 3431 | DEFUN (neighbor_activate, |
3432 | neighbor_activate_cmd, | |
9ccf14f7 | 3433 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3434 | NEIGHBOR_STR |
3435 | NEIGHBOR_ADDR_STR2 | |
3436 | "Enable the Address Family for this Neighbor\n") | |
3437 | { | |
d62a17ae | 3438 | int idx_peer = 1; |
3439 | int ret; | |
3440 | struct peer *peer; | |
718e3744 | 3441 | |
d62a17ae | 3442 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3443 | if (!peer) | |
3444 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3445 | |
d62a17ae | 3446 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3447 | return bgp_vty_return(vty, ret); | |
718e3744 | 3448 | } |
3449 | ||
d62a17ae | 3450 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
3451 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3452 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3453 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3454 | |
718e3744 | 3455 | DEFUN (no_neighbor_activate, |
3456 | no_neighbor_activate_cmd, | |
9ccf14f7 | 3457 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3458 | NO_STR |
3459 | NEIGHBOR_STR | |
3460 | NEIGHBOR_ADDR_STR2 | |
3461 | "Enable the Address Family for this Neighbor\n") | |
3462 | { | |
d62a17ae | 3463 | int idx_peer = 2; |
3464 | int ret; | |
3465 | struct peer *peer; | |
718e3744 | 3466 | |
d62a17ae | 3467 | /* Lookup peer. */ |
3468 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3469 | if (!peer) | |
3470 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3471 | |
d62a17ae | 3472 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3473 | return bgp_vty_return(vty, ret); | |
718e3744 | 3474 | } |
6b0655a2 | 3475 | |
d62a17ae | 3476 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
3477 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3478 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3479 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3480 | |
718e3744 | 3481 | DEFUN (neighbor_set_peer_group, |
3482 | neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3483 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3484 | NEIGHBOR_STR |
a80beece | 3485 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3486 | "Member of the peer-group\n" |
16cedbb0 | 3487 | "Peer-group name\n") |
718e3744 | 3488 | { |
d62a17ae | 3489 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3490 | int idx_peer = 1; | |
3491 | int idx_word = 3; | |
3492 | int ret; | |
3493 | as_t as; | |
3494 | union sockunion su; | |
3495 | struct peer *peer; | |
3496 | struct peer_group *group; | |
3497 | ||
d62a17ae | 3498 | ret = str2sockunion(argv[idx_peer]->arg, &su); |
3499 | if (ret < 0) { | |
3500 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3501 | if (!peer) { | |
3502 | vty_out(vty, "%% Malformed address or name: %s\n", | |
3503 | argv[idx_peer]->arg); | |
3504 | return CMD_WARNING_CONFIG_FAILED; | |
3505 | } | |
3506 | } else { | |
3507 | if (peer_address_self_check(bgp, &su)) { | |
3508 | vty_out(vty, | |
3509 | "%% Can not configure the local system as neighbor\n"); | |
3510 | return CMD_WARNING_CONFIG_FAILED; | |
3511 | } | |
3512 | ||
3513 | /* Disallow for dynamic neighbor. */ | |
3514 | peer = peer_lookup(bgp, &su); | |
3515 | if (peer && peer_dynamic_neighbor(peer)) { | |
3516 | vty_out(vty, | |
3517 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3518 | return CMD_WARNING_CONFIG_FAILED; | |
3519 | } | |
3520 | } | |
3521 | ||
3522 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3523 | if (!group) { | |
3524 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3525 | return CMD_WARNING_CONFIG_FAILED; | |
3526 | } | |
3527 | ||
3528 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
3529 | ||
3530 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { | |
3531 | vty_out(vty, | |
3532 | "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", | |
3533 | as); | |
3534 | return CMD_WARNING_CONFIG_FAILED; | |
3535 | } | |
3536 | ||
3537 | return bgp_vty_return(vty, ret); | |
3538 | } | |
3539 | ||
3540 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
3541 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", | |
3542 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3543 | "Member of the peer-group\n" | |
3544 | "Peer-group name\n") | |
596c17ba | 3545 | |
718e3744 | 3546 | DEFUN (no_neighbor_set_peer_group, |
3547 | no_neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3548 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3549 | NO_STR |
3550 | NEIGHBOR_STR | |
a80beece | 3551 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3552 | "Member of the peer-group\n" |
16cedbb0 | 3553 | "Peer-group name\n") |
718e3744 | 3554 | { |
d62a17ae | 3555 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3556 | int idx_peer = 2; | |
3557 | int idx_word = 4; | |
3558 | int ret; | |
3559 | struct peer *peer; | |
3560 | struct peer_group *group; | |
3561 | ||
3562 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); | |
3563 | if (!peer) | |
3564 | return CMD_WARNING_CONFIG_FAILED; | |
3565 | ||
3566 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3567 | if (!group) { | |
3568 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3569 | return CMD_WARNING_CONFIG_FAILED; | |
3570 | } | |
718e3744 | 3571 | |
827ed707 | 3572 | ret = peer_delete(peer); |
718e3744 | 3573 | |
d62a17ae | 3574 | return bgp_vty_return(vty, ret); |
718e3744 | 3575 | } |
6b0655a2 | 3576 | |
d62a17ae | 3577 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
3578 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", | |
3579 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3580 | "Member of the peer-group\n" | |
3581 | "Peer-group name\n") | |
596c17ba | 3582 | |
d62a17ae | 3583 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 3584 | uint32_t flag, int set) |
718e3744 | 3585 | { |
d62a17ae | 3586 | int ret; |
3587 | struct peer *peer; | |
718e3744 | 3588 | |
d62a17ae | 3589 | peer = peer_and_group_lookup_vty(vty, ip_str); |
3590 | if (!peer) | |
3591 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3592 | |
7ebe625c QY |
3593 | /* |
3594 | * If 'neighbor <interface>', then this is for directly connected peers, | |
3595 | * we should not accept disable-connected-check. | |
3596 | */ | |
3597 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
3598 | vty_out(vty, | |
3599 | "%s is directly connected peer, cannot accept disable-" | |
3600 | "connected-check\n", | |
3601 | ip_str); | |
3602 | return CMD_WARNING_CONFIG_FAILED; | |
3603 | } | |
3604 | ||
d62a17ae | 3605 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
3606 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 3607 | |
d62a17ae | 3608 | if (set) |
3609 | ret = peer_flag_set(peer, flag); | |
3610 | else | |
3611 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 3612 | |
d62a17ae | 3613 | return bgp_vty_return(vty, ret); |
718e3744 | 3614 | } |
3615 | ||
47cbc09b | 3616 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint32_t flag) |
718e3744 | 3617 | { |
d62a17ae | 3618 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 3619 | } |
3620 | ||
d62a17ae | 3621 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 3622 | uint32_t flag) |
718e3744 | 3623 | { |
d62a17ae | 3624 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 3625 | } |
3626 | ||
3627 | /* neighbor passive. */ | |
3628 | DEFUN (neighbor_passive, | |
3629 | neighbor_passive_cmd, | |
9ccf14f7 | 3630 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3631 | NEIGHBOR_STR |
3632 | NEIGHBOR_ADDR_STR2 | |
3633 | "Don't send open messages to this neighbor\n") | |
3634 | { | |
d62a17ae | 3635 | int idx_peer = 1; |
3636 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3637 | } |
3638 | ||
3639 | DEFUN (no_neighbor_passive, | |
3640 | no_neighbor_passive_cmd, | |
9ccf14f7 | 3641 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3642 | NO_STR |
3643 | NEIGHBOR_STR | |
3644 | NEIGHBOR_ADDR_STR2 | |
3645 | "Don't send open messages to this neighbor\n") | |
3646 | { | |
d62a17ae | 3647 | int idx_peer = 2; |
3648 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3649 | } |
6b0655a2 | 3650 | |
718e3744 | 3651 | /* neighbor shutdown. */ |
73d70fa6 DL |
3652 | DEFUN (neighbor_shutdown_msg, |
3653 | neighbor_shutdown_msg_cmd, | |
3654 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
718e3744 | 3655 | NEIGHBOR_STR |
3656 | NEIGHBOR_ADDR_STR2 | |
73d70fa6 DL |
3657 | "Administratively shut down this neighbor\n" |
3658 | "Add a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3659 | "Shutdown message\n") | |
718e3744 | 3660 | { |
d62a17ae | 3661 | int idx_peer = 1; |
73d70fa6 | 3662 | |
d62a17ae | 3663 | if (argc >= 5) { |
3664 | struct peer *peer = | |
3665 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3666 | char *message; | |
73d70fa6 | 3667 | |
d62a17ae | 3668 | if (!peer) |
3669 | return CMD_WARNING_CONFIG_FAILED; | |
3670 | message = argv_concat(argv, argc, 4); | |
3671 | peer_tx_shutdown_message_set(peer, message); | |
3672 | XFREE(MTYPE_TMP, message); | |
3673 | } | |
73d70fa6 | 3674 | |
d62a17ae | 3675 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 3676 | } |
3677 | ||
d62a17ae | 3678 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
3679 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3680 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3681 | "Administratively shut down this neighbor\n") | |
73d70fa6 DL |
3682 | |
3683 | DEFUN (no_neighbor_shutdown_msg, | |
3684 | no_neighbor_shutdown_msg_cmd, | |
3685 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
3686 | NO_STR | |
3687 | NEIGHBOR_STR | |
3688 | NEIGHBOR_ADDR_STR2 | |
3689 | "Administratively shut down this neighbor\n" | |
3690 | "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3691 | "Shutdown message\n") | |
718e3744 | 3692 | { |
d62a17ae | 3693 | int idx_peer = 2; |
73d70fa6 | 3694 | |
d62a17ae | 3695 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
3696 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 3697 | } |
6b0655a2 | 3698 | |
d62a17ae | 3699 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
3700 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3701 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3702 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 3703 | |
718e3744 | 3704 | /* neighbor capability dynamic. */ |
3705 | DEFUN (neighbor_capability_dynamic, | |
3706 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3707 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3708 | NEIGHBOR_STR |
3709 | NEIGHBOR_ADDR_STR2 | |
3710 | "Advertise capability to the peer\n" | |
3711 | "Advertise dynamic capability to this neighbor\n") | |
3712 | { | |
d62a17ae | 3713 | int idx_peer = 1; |
3714 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3715 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3716 | } |
3717 | ||
3718 | DEFUN (no_neighbor_capability_dynamic, | |
3719 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3720 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3721 | NO_STR |
3722 | NEIGHBOR_STR | |
3723 | NEIGHBOR_ADDR_STR2 | |
3724 | "Advertise capability to the peer\n" | |
3725 | "Advertise dynamic capability to this neighbor\n") | |
3726 | { | |
d62a17ae | 3727 | int idx_peer = 2; |
3728 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3729 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3730 | } |
6b0655a2 | 3731 | |
718e3744 | 3732 | /* neighbor dont-capability-negotiate */ |
3733 | DEFUN (neighbor_dont_capability_negotiate, | |
3734 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3735 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3736 | NEIGHBOR_STR |
3737 | NEIGHBOR_ADDR_STR2 | |
3738 | "Do not perform capability negotiation\n") | |
3739 | { | |
d62a17ae | 3740 | int idx_peer = 1; |
3741 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3742 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3743 | } |
3744 | ||
3745 | DEFUN (no_neighbor_dont_capability_negotiate, | |
3746 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3747 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3748 | NO_STR |
3749 | NEIGHBOR_STR | |
3750 | NEIGHBOR_ADDR_STR2 | |
3751 | "Do not perform capability negotiation\n") | |
3752 | { | |
d62a17ae | 3753 | int idx_peer = 2; |
3754 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3755 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3756 | } |
6b0655a2 | 3757 | |
8a92a8a0 DS |
3758 | /* neighbor capability extended next hop encoding */ |
3759 | DEFUN (neighbor_capability_enhe, | |
3760 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3761 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3762 | NEIGHBOR_STR |
3763 | NEIGHBOR_ADDR_STR2 | |
3764 | "Advertise capability to the peer\n" | |
3765 | "Advertise extended next-hop capability to the peer\n") | |
3766 | { | |
d62a17ae | 3767 | int idx_peer = 1; |
3768 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3769 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3770 | } |
3771 | ||
3772 | DEFUN (no_neighbor_capability_enhe, | |
3773 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3774 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3775 | NO_STR |
3776 | NEIGHBOR_STR | |
3777 | NEIGHBOR_ADDR_STR2 | |
3778 | "Advertise capability to the peer\n" | |
3779 | "Advertise extended next-hop capability to the peer\n") | |
3780 | { | |
d62a17ae | 3781 | int idx_peer = 2; |
3782 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3783 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3784 | } |
3785 | ||
d62a17ae | 3786 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3787 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 3788 | int set) |
718e3744 | 3789 | { |
d62a17ae | 3790 | int ret; |
3791 | struct peer *peer; | |
718e3744 | 3792 | |
d62a17ae | 3793 | peer = peer_and_group_lookup_vty(vty, peer_str); |
3794 | if (!peer) | |
3795 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3796 | |
d62a17ae | 3797 | if (set) |
3798 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
3799 | else | |
3800 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 3801 | |
d62a17ae | 3802 | return bgp_vty_return(vty, ret); |
718e3744 | 3803 | } |
3804 | ||
d62a17ae | 3805 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3806 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 3807 | { |
d62a17ae | 3808 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 3809 | } |
3810 | ||
d62a17ae | 3811 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3812 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 3813 | { |
d62a17ae | 3814 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 3815 | } |
6b0655a2 | 3816 | |
718e3744 | 3817 | /* neighbor capability orf prefix-list. */ |
3818 | DEFUN (neighbor_capability_orf_prefix, | |
3819 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3820 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3821 | NEIGHBOR_STR |
3822 | NEIGHBOR_ADDR_STR2 | |
3823 | "Advertise capability to the peer\n" | |
3824 | "Advertise ORF capability to the peer\n" | |
3825 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3826 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3827 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3828 | "Capability to SEND the ORF to this neighbor\n") | |
3829 | { | |
d62a17ae | 3830 | int idx_peer = 1; |
3831 | int idx_send_recv = 5; | |
d7c0a89a | 3832 | uint16_t flag = 0; |
d62a17ae | 3833 | |
3834 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3835 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3836 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3837 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3838 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3839 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3840 | else { | |
3841 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3842 | return CMD_WARNING_CONFIG_FAILED; | |
3843 | } | |
3844 | ||
3845 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3846 | bgp_node_safi(vty), flag); | |
3847 | } | |
3848 | ||
3849 | ALIAS_HIDDEN( | |
3850 | neighbor_capability_orf_prefix, | |
3851 | neighbor_capability_orf_prefix_hidden_cmd, | |
3852 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3853 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3854 | "Advertise capability to the peer\n" | |
3855 | "Advertise ORF capability to the peer\n" | |
3856 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3857 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3858 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3859 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 3860 | |
718e3744 | 3861 | DEFUN (no_neighbor_capability_orf_prefix, |
3862 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3863 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3864 | NO_STR |
3865 | NEIGHBOR_STR | |
3866 | NEIGHBOR_ADDR_STR2 | |
3867 | "Advertise capability to the peer\n" | |
3868 | "Advertise ORF capability to the peer\n" | |
3869 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3870 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3871 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3872 | "Capability to SEND the ORF to this neighbor\n") | |
3873 | { | |
d62a17ae | 3874 | int idx_peer = 2; |
3875 | int idx_send_recv = 6; | |
d7c0a89a | 3876 | uint16_t flag = 0; |
d62a17ae | 3877 | |
3878 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3879 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3880 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3881 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3882 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3883 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3884 | else { | |
3885 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3886 | return CMD_WARNING_CONFIG_FAILED; | |
3887 | } | |
3888 | ||
3889 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3890 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3891 | flag); | |
3892 | } | |
3893 | ||
3894 | ALIAS_HIDDEN( | |
3895 | no_neighbor_capability_orf_prefix, | |
3896 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
3897 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3898 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3899 | "Advertise capability to the peer\n" | |
3900 | "Advertise ORF capability to the peer\n" | |
3901 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3902 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3903 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3904 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 3905 | |
718e3744 | 3906 | /* neighbor next-hop-self. */ |
3907 | DEFUN (neighbor_nexthop_self, | |
3908 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3909 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3910 | NEIGHBOR_STR |
3911 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3912 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3913 | { |
d62a17ae | 3914 | int idx_peer = 1; |
3915 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3916 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 3917 | } |
9e7a53c1 | 3918 | |
d62a17ae | 3919 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
3920 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3921 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3922 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 3923 | |
a538debe DS |
3924 | /* neighbor next-hop-self. */ |
3925 | DEFUN (neighbor_nexthop_self_force, | |
3926 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 3927 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3928 | NEIGHBOR_STR |
3929 | NEIGHBOR_ADDR_STR2 | |
3930 | "Disable the next hop calculation for this neighbor\n" | |
3931 | "Set the next hop to self for reflected routes\n") | |
3932 | { | |
d62a17ae | 3933 | int idx_peer = 1; |
3934 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3935 | bgp_node_safi(vty), | |
3936 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 3937 | } |
3938 | ||
d62a17ae | 3939 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
3940 | neighbor_nexthop_self_force_hidden_cmd, | |
3941 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3942 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3943 | "Disable the next hop calculation for this neighbor\n" | |
3944 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 3945 | |
1bc4e531 DA |
3946 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
3947 | neighbor_nexthop_self_all_hidden_cmd, | |
3948 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
3949 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3950 | "Disable the next hop calculation for this neighbor\n" | |
3951 | "Set the next hop to self for reflected routes\n") | |
3952 | ||
718e3744 | 3953 | DEFUN (no_neighbor_nexthop_self, |
3954 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3955 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3956 | NO_STR |
3957 | NEIGHBOR_STR | |
3958 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3959 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3960 | { |
d62a17ae | 3961 | int idx_peer = 2; |
3962 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3963 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3964 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 3965 | } |
6b0655a2 | 3966 | |
d62a17ae | 3967 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
3968 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3969 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3970 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 3971 | |
88b8ed8d | 3972 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 3973 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 3974 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3975 | NO_STR |
3976 | NEIGHBOR_STR | |
3977 | NEIGHBOR_ADDR_STR2 | |
3978 | "Disable the next hop calculation for this neighbor\n" | |
3979 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 3980 | { |
d62a17ae | 3981 | int idx_peer = 2; |
3982 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3983 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3984 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 3985 | } |
a538debe | 3986 | |
d62a17ae | 3987 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
3988 | no_neighbor_nexthop_self_force_hidden_cmd, | |
3989 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3990 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3991 | "Disable the next hop calculation for this neighbor\n" | |
3992 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 3993 | |
1bc4e531 DA |
3994 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
3995 | no_neighbor_nexthop_self_all_hidden_cmd, | |
3996 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
3997 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3998 | "Disable the next hop calculation for this neighbor\n" | |
3999 | "Set the next hop to self for reflected routes\n") | |
4000 | ||
c7122e14 DS |
4001 | /* neighbor as-override */ |
4002 | DEFUN (neighbor_as_override, | |
4003 | neighbor_as_override_cmd, | |
9ccf14f7 | 4004 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
4005 | NEIGHBOR_STR |
4006 | NEIGHBOR_ADDR_STR2 | |
4007 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
4008 | { | |
d62a17ae | 4009 | int idx_peer = 1; |
4010 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4011 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
4012 | } |
4013 | ||
d62a17ae | 4014 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
4015 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
4016 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4017 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 4018 | |
c7122e14 DS |
4019 | DEFUN (no_neighbor_as_override, |
4020 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 4021 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
4022 | NO_STR |
4023 | NEIGHBOR_STR | |
4024 | NEIGHBOR_ADDR_STR2 | |
4025 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
4026 | { | |
d62a17ae | 4027 | int idx_peer = 2; |
4028 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4029 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4030 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
4031 | } |
4032 | ||
d62a17ae | 4033 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
4034 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
4035 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4036 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 4037 | |
718e3744 | 4038 | /* neighbor remove-private-AS. */ |
4039 | DEFUN (neighbor_remove_private_as, | |
4040 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4041 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4042 | NEIGHBOR_STR |
4043 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4044 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4045 | { |
d62a17ae | 4046 | int idx_peer = 1; |
4047 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4048 | bgp_node_safi(vty), | |
4049 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4050 | } |
4051 | ||
d62a17ae | 4052 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
4053 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4054 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4055 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4056 | |
5000f21c DS |
4057 | DEFUN (neighbor_remove_private_as_all, |
4058 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 4059 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4060 | NEIGHBOR_STR |
4061 | NEIGHBOR_ADDR_STR2 | |
4062 | "Remove private ASNs in outbound updates\n" | |
efd7904e | 4063 | "Apply to all AS numbers\n") |
5000f21c | 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_ALL); | |
5000f21c DS |
4069 | } |
4070 | ||
d62a17ae | 4071 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
4072 | neighbor_remove_private_as_all_hidden_cmd, | |
4073 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4074 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4075 | "Remove private ASNs in outbound updates\n" | |
4076 | "Apply to all AS numbers") | |
596c17ba | 4077 | |
5000f21c DS |
4078 | DEFUN (neighbor_remove_private_as_replace_as, |
4079 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 4080 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4081 | NEIGHBOR_STR |
4082 | NEIGHBOR_ADDR_STR2 | |
4083 | "Remove private ASNs in outbound updates\n" | |
4084 | "Replace private ASNs with our ASN in outbound updates\n") | |
4085 | { | |
d62a17ae | 4086 | int idx_peer = 1; |
4087 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4088 | bgp_node_safi(vty), | |
4089 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
4090 | } |
4091 | ||
d62a17ae | 4092 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
4093 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
4094 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4095 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4096 | "Remove private ASNs in outbound updates\n" | |
4097 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4098 | |
5000f21c DS |
4099 | DEFUN (neighbor_remove_private_as_all_replace_as, |
4100 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 4101 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4102 | NEIGHBOR_STR |
4103 | NEIGHBOR_ADDR_STR2 | |
4104 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4105 | "Apply to all AS numbers\n" |
5000f21c DS |
4106 | "Replace private ASNs with our ASN in outbound updates\n") |
4107 | { | |
d62a17ae | 4108 | int idx_peer = 1; |
4109 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4110 | bgp_node_safi(vty), | |
4111 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
4112 | } |
4113 | ||
d62a17ae | 4114 | ALIAS_HIDDEN( |
4115 | neighbor_remove_private_as_all_replace_as, | |
4116 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4117 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4118 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4119 | "Remove private ASNs in outbound updates\n" | |
4120 | "Apply to all AS numbers\n" | |
4121 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4122 | |
718e3744 | 4123 | DEFUN (no_neighbor_remove_private_as, |
4124 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4125 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4126 | NO_STR |
4127 | NEIGHBOR_STR | |
4128 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4129 | "Remove private ASNs in outbound updates\n") |
718e3744 | 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); | |
718e3744 | 4135 | } |
6b0655a2 | 4136 | |
d62a17ae | 4137 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
4138 | no_neighbor_remove_private_as_hidden_cmd, | |
4139 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4140 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4141 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4142 | |
88b8ed8d | 4143 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 4144 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 4145 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4146 | NO_STR |
4147 | NEIGHBOR_STR | |
4148 | NEIGHBOR_ADDR_STR2 | |
4149 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4150 | "Apply to all AS numbers\n") |
88b8ed8d | 4151 | { |
d62a17ae | 4152 | int idx_peer = 2; |
4153 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4154 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4155 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 4156 | } |
5000f21c | 4157 | |
d62a17ae | 4158 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
4159 | no_neighbor_remove_private_as_all_hidden_cmd, | |
4160 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4161 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4162 | "Remove private ASNs in outbound updates\n" | |
4163 | "Apply to all AS numbers\n") | |
596c17ba | 4164 | |
88b8ed8d | 4165 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 4166 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 4167 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4168 | NO_STR |
4169 | NEIGHBOR_STR | |
4170 | NEIGHBOR_ADDR_STR2 | |
4171 | "Remove private ASNs in outbound updates\n" | |
4172 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 4173 | { |
d62a17ae | 4174 | int idx_peer = 2; |
4175 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4176 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4177 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 4178 | } |
5000f21c | 4179 | |
d62a17ae | 4180 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
4181 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
4182 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4183 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4184 | "Remove private ASNs in outbound updates\n" | |
4185 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4186 | |
88b8ed8d | 4187 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 4188 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 4189 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4190 | NO_STR |
4191 | NEIGHBOR_STR | |
4192 | NEIGHBOR_ADDR_STR2 | |
4193 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4194 | "Apply to all AS numbers\n" |
5000f21c | 4195 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 4196 | { |
d62a17ae | 4197 | int idx_peer = 2; |
4198 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4199 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4200 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 4201 | } |
5000f21c | 4202 | |
d62a17ae | 4203 | ALIAS_HIDDEN( |
4204 | no_neighbor_remove_private_as_all_replace_as, | |
4205 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4206 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4207 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4208 | "Remove private ASNs in outbound updates\n" | |
4209 | "Apply to all AS numbers\n" | |
4210 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4211 | |
5000f21c | 4212 | |
718e3744 | 4213 | /* neighbor send-community. */ |
4214 | DEFUN (neighbor_send_community, | |
4215 | neighbor_send_community_cmd, | |
9ccf14f7 | 4216 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4217 | NEIGHBOR_STR |
4218 | NEIGHBOR_ADDR_STR2 | |
4219 | "Send Community attribute to this neighbor\n") | |
4220 | { | |
d62a17ae | 4221 | int idx_peer = 1; |
27c05d4d | 4222 | |
d62a17ae | 4223 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4224 | bgp_node_safi(vty), | |
4225 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4226 | } |
4227 | ||
d62a17ae | 4228 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
4229 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4230 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4231 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4232 | |
718e3744 | 4233 | DEFUN (no_neighbor_send_community, |
4234 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 4235 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4236 | NO_STR |
4237 | NEIGHBOR_STR | |
4238 | NEIGHBOR_ADDR_STR2 | |
4239 | "Send Community attribute to this neighbor\n") | |
4240 | { | |
d62a17ae | 4241 | int idx_peer = 2; |
27c05d4d | 4242 | |
d62a17ae | 4243 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
4244 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4245 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4246 | } |
6b0655a2 | 4247 | |
d62a17ae | 4248 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
4249 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4250 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4251 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4252 | |
718e3744 | 4253 | /* neighbor send-community extended. */ |
4254 | DEFUN (neighbor_send_community_type, | |
4255 | neighbor_send_community_type_cmd, | |
57d187bc | 4256 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4257 | NEIGHBOR_STR |
4258 | NEIGHBOR_ADDR_STR2 | |
4259 | "Send Community attribute to this neighbor\n" | |
4260 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4261 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4262 | "Send Extended Community attributes\n" |
57d187bc JS |
4263 | "Send Standard Community attributes\n" |
4264 | "Send Large Community attributes\n") | |
718e3744 | 4265 | { |
27c05d4d | 4266 | int idx_peer = 1; |
d7c0a89a | 4267 | uint32_t flag = 0; |
27c05d4d | 4268 | const char *type = argv[argc - 1]->text; |
d62a17ae | 4269 | |
27c05d4d | 4270 | if (strmatch(type, "standard")) { |
d62a17ae | 4271 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
27c05d4d | 4272 | } else if (strmatch(type, "extended")) { |
d62a17ae | 4273 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); |
27c05d4d | 4274 | } else if (strmatch(type, "large")) { |
d62a17ae | 4275 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); |
27c05d4d | 4276 | } else if (strmatch(type, "both")) { |
d62a17ae | 4277 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4278 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
27c05d4d | 4279 | } else { /* if (strmatch(type, "all")) */ |
d62a17ae | 4280 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4281 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4282 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4283 | } | |
4284 | ||
27c05d4d | 4285 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
d62a17ae | 4286 | bgp_node_safi(vty), flag); |
4287 | } | |
4288 | ||
4289 | ALIAS_HIDDEN( | |
4290 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
4291 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4292 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4293 | "Send Community attribute to this neighbor\n" | |
4294 | "Send Standard and Extended Community attributes\n" | |
4295 | "Send Standard, Large and Extended Community attributes\n" | |
4296 | "Send Extended Community attributes\n" | |
4297 | "Send Standard Community attributes\n" | |
4298 | "Send Large Community attributes\n") | |
596c17ba | 4299 | |
718e3744 | 4300 | DEFUN (no_neighbor_send_community_type, |
4301 | no_neighbor_send_community_type_cmd, | |
57d187bc | 4302 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4303 | NO_STR |
4304 | NEIGHBOR_STR | |
4305 | NEIGHBOR_ADDR_STR2 | |
4306 | "Send Community attribute to this neighbor\n" | |
4307 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4308 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4309 | "Send Extended Community attributes\n" |
57d187bc JS |
4310 | "Send Standard Community attributes\n" |
4311 | "Send Large Community attributes\n") | |
718e3744 | 4312 | { |
d62a17ae | 4313 | int idx_peer = 2; |
27c05d4d | 4314 | uint32_t flag = 0; |
d62a17ae | 4315 | const char *type = argv[argc - 1]->text; |
4316 | ||
27c05d4d PM |
4317 | if (strmatch(type, "standard")) { |
4318 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4319 | } else if (strmatch(type, "extended")) { | |
4320 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4321 | } else if (strmatch(type, "large")) { | |
4322 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4323 | } else if (strmatch(type, "both")) { | |
4324 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4325 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4326 | } else { /* if (strmatch(type, "all")) */ | |
4327 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4328 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4329 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4330 | } | |
4331 | ||
4332 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4333 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4334 | flag); | |
d62a17ae | 4335 | } |
4336 | ||
4337 | ALIAS_HIDDEN( | |
4338 | no_neighbor_send_community_type, | |
4339 | no_neighbor_send_community_type_hidden_cmd, | |
4340 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4341 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4342 | "Send Community attribute to this neighbor\n" | |
4343 | "Send Standard and Extended Community attributes\n" | |
4344 | "Send Standard, Large and Extended Community attributes\n" | |
4345 | "Send Extended Community attributes\n" | |
4346 | "Send Standard Community attributes\n" | |
4347 | "Send Large Community attributes\n") | |
596c17ba | 4348 | |
718e3744 | 4349 | /* neighbor soft-reconfig. */ |
4350 | DEFUN (neighbor_soft_reconfiguration, | |
4351 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4352 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4353 | NEIGHBOR_STR |
4354 | NEIGHBOR_ADDR_STR2 | |
4355 | "Per neighbor soft reconfiguration\n" | |
4356 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4357 | { | |
d62a17ae | 4358 | int idx_peer = 1; |
4359 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4360 | bgp_node_safi(vty), | |
4361 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4362 | } |
4363 | ||
d62a17ae | 4364 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
4365 | neighbor_soft_reconfiguration_hidden_cmd, | |
4366 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4367 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4368 | "Per neighbor soft reconfiguration\n" | |
4369 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4370 | |
718e3744 | 4371 | DEFUN (no_neighbor_soft_reconfiguration, |
4372 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4373 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4374 | NO_STR |
4375 | NEIGHBOR_STR | |
4376 | NEIGHBOR_ADDR_STR2 | |
4377 | "Per neighbor soft reconfiguration\n" | |
4378 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4379 | { | |
d62a17ae | 4380 | int idx_peer = 2; |
4381 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4382 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4383 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4384 | } |
6b0655a2 | 4385 | |
d62a17ae | 4386 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
4387 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
4388 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4389 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4390 | "Per neighbor soft reconfiguration\n" | |
4391 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4392 | |
718e3744 | 4393 | DEFUN (neighbor_route_reflector_client, |
4394 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4395 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4396 | NEIGHBOR_STR |
4397 | NEIGHBOR_ADDR_STR2 | |
4398 | "Configure a neighbor as Route Reflector client\n") | |
4399 | { | |
d62a17ae | 4400 | int idx_peer = 1; |
4401 | struct peer *peer; | |
718e3744 | 4402 | |
4403 | ||
d62a17ae | 4404 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4405 | if (!peer) | |
4406 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4407 | |
d62a17ae | 4408 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4409 | bgp_node_safi(vty), | |
4410 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4411 | } |
4412 | ||
d62a17ae | 4413 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
4414 | neighbor_route_reflector_client_hidden_cmd, | |
4415 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4416 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4417 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4418 | |
718e3744 | 4419 | DEFUN (no_neighbor_route_reflector_client, |
4420 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4421 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4422 | NO_STR |
4423 | NEIGHBOR_STR | |
4424 | NEIGHBOR_ADDR_STR2 | |
4425 | "Configure a neighbor as Route Reflector client\n") | |
4426 | { | |
d62a17ae | 4427 | int idx_peer = 2; |
4428 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4429 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4430 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4431 | } |
6b0655a2 | 4432 | |
d62a17ae | 4433 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
4434 | no_neighbor_route_reflector_client_hidden_cmd, | |
4435 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4436 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4437 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4438 | |
718e3744 | 4439 | /* neighbor route-server-client. */ |
4440 | DEFUN (neighbor_route_server_client, | |
4441 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 4442 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4443 | NEIGHBOR_STR |
4444 | NEIGHBOR_ADDR_STR2 | |
4445 | "Configure a neighbor as Route Server client\n") | |
4446 | { | |
d62a17ae | 4447 | int idx_peer = 1; |
4448 | struct peer *peer; | |
2a3d5731 | 4449 | |
d62a17ae | 4450 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4451 | if (!peer) | |
4452 | return CMD_WARNING_CONFIG_FAILED; | |
4453 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4454 | bgp_node_safi(vty), | |
4455 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 4456 | } |
4457 | ||
d62a17ae | 4458 | ALIAS_HIDDEN(neighbor_route_server_client, |
4459 | neighbor_route_server_client_hidden_cmd, | |
4460 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4461 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4462 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4463 | |
718e3744 | 4464 | DEFUN (no_neighbor_route_server_client, |
4465 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 4466 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4467 | NO_STR |
4468 | NEIGHBOR_STR | |
4469 | NEIGHBOR_ADDR_STR2 | |
4470 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 4471 | { |
d62a17ae | 4472 | int idx_peer = 2; |
4473 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4474 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4475 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 4476 | } |
6b0655a2 | 4477 | |
d62a17ae | 4478 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
4479 | no_neighbor_route_server_client_hidden_cmd, | |
4480 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4481 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4482 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4483 | |
fee0f4c6 | 4484 | DEFUN (neighbor_nexthop_local_unchanged, |
4485 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4486 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4487 | NEIGHBOR_STR |
4488 | NEIGHBOR_ADDR_STR2 | |
4489 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
4490 | "Leave link-local nexthop unchanged for this peer\n") | |
4491 | { | |
d62a17ae | 4492 | int idx_peer = 1; |
4493 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4494 | bgp_node_safi(vty), | |
4495 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 4496 | } |
6b0655a2 | 4497 | |
fee0f4c6 | 4498 | DEFUN (no_neighbor_nexthop_local_unchanged, |
4499 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4500 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4501 | NO_STR |
4502 | NEIGHBOR_STR | |
4503 | NEIGHBOR_ADDR_STR2 | |
4504 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
4505 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 4506 | { |
d62a17ae | 4507 | int idx_peer = 2; |
4508 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4509 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4510 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 4511 | } |
6b0655a2 | 4512 | |
718e3744 | 4513 | DEFUN (neighbor_attr_unchanged, |
4514 | neighbor_attr_unchanged_cmd, | |
a8206004 | 4515 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
718e3744 | 4516 | NEIGHBOR_STR |
4517 | NEIGHBOR_ADDR_STR2 | |
4518 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4519 | "As-path attribute\n" | |
4520 | "Nexthop attribute\n" | |
a8206004 | 4521 | "Med attribute\n") |
718e3744 | 4522 | { |
d62a17ae | 4523 | int idx = 0; |
8eeb0335 DW |
4524 | char *peer_str = argv[1]->arg; |
4525 | struct peer *peer; | |
d7c0a89a | 4526 | uint16_t flags = 0; |
8eeb0335 DW |
4527 | afi_t afi = bgp_node_afi(vty); |
4528 | safi_t safi = bgp_node_safi(vty); | |
4529 | ||
4530 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
4531 | if (!peer) | |
4532 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4533 | |
4534 | if (argv_find(argv, argc, "as-path", &idx)) | |
4535 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4536 | idx = 0; | |
4537 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4538 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4539 | idx = 0; | |
4540 | if (argv_find(argv, argc, "med", &idx)) | |
4541 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4542 | ||
8eeb0335 DW |
4543 | /* no flags means all of them! */ |
4544 | if (!flags) { | |
d62a17ae | 4545 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); |
4546 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4547 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 | 4548 | } else { |
a4d82a8a PZ |
4549 | if (!CHECK_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED) |
4550 | && peer_af_flag_check(peer, afi, safi, | |
4551 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
8eeb0335 DW |
4552 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4553 | PEER_FLAG_AS_PATH_UNCHANGED); | |
4554 | } | |
4555 | ||
a4d82a8a PZ |
4556 | if (!CHECK_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED) |
4557 | && peer_af_flag_check(peer, afi, safi, | |
4558 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
8eeb0335 DW |
4559 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4560 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
4561 | } | |
4562 | ||
a4d82a8a PZ |
4563 | if (!CHECK_FLAG(flags, PEER_FLAG_MED_UNCHANGED) |
4564 | && peer_af_flag_check(peer, afi, safi, | |
4565 | PEER_FLAG_MED_UNCHANGED)) { | |
8eeb0335 DW |
4566 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4567 | PEER_FLAG_MED_UNCHANGED); | |
4568 | } | |
d62a17ae | 4569 | } |
4570 | ||
8eeb0335 | 4571 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, flags); |
d62a17ae | 4572 | } |
4573 | ||
4574 | ALIAS_HIDDEN( | |
4575 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
4576 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4577 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4578 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4579 | "As-path attribute\n" | |
4580 | "Nexthop attribute\n" | |
4581 | "Med attribute\n") | |
596c17ba | 4582 | |
718e3744 | 4583 | DEFUN (no_neighbor_attr_unchanged, |
4584 | no_neighbor_attr_unchanged_cmd, | |
a8206004 | 4585 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
e52702f2 | 4586 | NO_STR |
718e3744 | 4587 | NEIGHBOR_STR |
4588 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
4589 | "BGP attribute is propagated unchanged to this neighbor\n" |
4590 | "As-path attribute\n" | |
40e718b5 | 4591 | "Nexthop attribute\n" |
a8206004 | 4592 | "Med attribute\n") |
718e3744 | 4593 | { |
d62a17ae | 4594 | int idx = 0; |
4595 | char *peer = argv[2]->arg; | |
d7c0a89a | 4596 | uint16_t flags = 0; |
d62a17ae | 4597 | |
4598 | if (argv_find(argv, argc, "as-path", &idx)) | |
4599 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4600 | idx = 0; | |
4601 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4602 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4603 | idx = 0; | |
4604 | if (argv_find(argv, argc, "med", &idx)) | |
4605 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4606 | ||
4607 | if (!flags) // no flags means all of them! | |
4608 | { | |
4609 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4610 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4611 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4612 | } | |
4613 | ||
4614 | return peer_af_flag_unset_vty(vty, peer, bgp_node_afi(vty), | |
4615 | bgp_node_safi(vty), flags); | |
4616 | } | |
4617 | ||
4618 | ALIAS_HIDDEN( | |
4619 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
4620 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4621 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4622 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4623 | "As-path attribute\n" | |
4624 | "Nexthop attribute\n" | |
4625 | "Med attribute\n") | |
718e3744 | 4626 | |
718e3744 | 4627 | /* EBGP multihop configuration. */ |
d62a17ae | 4628 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, |
4629 | const char *ttl_str) | |
718e3744 | 4630 | { |
d62a17ae | 4631 | struct peer *peer; |
4632 | unsigned int ttl; | |
718e3744 | 4633 | |
d62a17ae | 4634 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4635 | if (!peer) | |
4636 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4637 | |
d62a17ae | 4638 | if (peer->conf_if) |
4639 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
63fa10b5 | 4640 | |
d62a17ae | 4641 | if (!ttl_str) |
4642 | ttl = MAXTTL; | |
4643 | else | |
4644 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 4645 | |
d62a17ae | 4646 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 4647 | } |
4648 | ||
d62a17ae | 4649 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 4650 | { |
d62a17ae | 4651 | struct peer *peer; |
718e3744 | 4652 | |
d62a17ae | 4653 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4654 | if (!peer) | |
4655 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4656 | |
d62a17ae | 4657 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 4658 | } |
4659 | ||
4660 | /* neighbor ebgp-multihop. */ | |
4661 | DEFUN (neighbor_ebgp_multihop, | |
4662 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 4663 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 4664 | NEIGHBOR_STR |
4665 | NEIGHBOR_ADDR_STR2 | |
4666 | "Allow EBGP neighbors not on directly connected networks\n") | |
4667 | { | |
d62a17ae | 4668 | int idx_peer = 1; |
4669 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4670 | } |
4671 | ||
4672 | DEFUN (neighbor_ebgp_multihop_ttl, | |
4673 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 4674 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 4675 | NEIGHBOR_STR |
4676 | NEIGHBOR_ADDR_STR2 | |
4677 | "Allow EBGP neighbors not on directly connected networks\n" | |
4678 | "maximum hop count\n") | |
4679 | { | |
d62a17ae | 4680 | int idx_peer = 1; |
4681 | int idx_number = 3; | |
4682 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
4683 | argv[idx_number]->arg); | |
718e3744 | 4684 | } |
4685 | ||
4686 | DEFUN (no_neighbor_ebgp_multihop, | |
4687 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 4688 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 4689 | NO_STR |
4690 | NEIGHBOR_STR | |
4691 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4692 | "Allow EBGP neighbors not on directly connected networks\n" |
4693 | "maximum hop count\n") | |
718e3744 | 4694 | { |
d62a17ae | 4695 | int idx_peer = 2; |
4696 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 4697 | } |
4698 | ||
6b0655a2 | 4699 | |
6ffd2079 | 4700 | /* disable-connected-check */ |
4701 | DEFUN (neighbor_disable_connected_check, | |
4702 | neighbor_disable_connected_check_cmd, | |
7ebe625c | 4703 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4704 | NEIGHBOR_STR |
7ebe625c | 4705 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
4706 | "one-hop away EBGP peer using loopback address\n" |
4707 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4708 | { |
d62a17ae | 4709 | int idx_peer = 1; |
4710 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4711 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4712 | } |
4713 | ||
4714 | DEFUN (no_neighbor_disable_connected_check, | |
4715 | no_neighbor_disable_connected_check_cmd, | |
7ebe625c | 4716 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4717 | NO_STR |
4718 | NEIGHBOR_STR | |
7ebe625c | 4719 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
4720 | "one-hop away EBGP peer using loopback address\n" |
4721 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4722 | { |
d62a17ae | 4723 | int idx_peer = 2; |
4724 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4725 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4726 | } |
4727 | ||
47cbc09b PM |
4728 | |
4729 | /* enforce-first-as */ | |
4730 | DEFUN (neighbor_enforce_first_as, | |
4731 | neighbor_enforce_first_as_cmd, | |
4732 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
4733 | NEIGHBOR_STR | |
4734 | NEIGHBOR_ADDR_STR2 | |
4735 | "Enforce the first AS for EBGP routes\n") | |
4736 | { | |
4737 | int idx_peer = 1; | |
4738 | ||
4739 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4740 | PEER_FLAG_ENFORCE_FIRST_AS); | |
4741 | } | |
4742 | ||
4743 | DEFUN (no_neighbor_enforce_first_as, | |
4744 | no_neighbor_enforce_first_as_cmd, | |
4745 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
4746 | NO_STR | |
4747 | NEIGHBOR_STR | |
4748 | NEIGHBOR_ADDR_STR2 | |
4749 | "Enforce the first AS for EBGP routes\n") | |
4750 | { | |
4751 | int idx_peer = 2; | |
4752 | ||
4753 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4754 | PEER_FLAG_ENFORCE_FIRST_AS); | |
4755 | } | |
4756 | ||
4757 | ||
718e3744 | 4758 | DEFUN (neighbor_description, |
4759 | neighbor_description_cmd, | |
e961923c | 4760 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 4761 | NEIGHBOR_STR |
4762 | NEIGHBOR_ADDR_STR2 | |
4763 | "Neighbor specific description\n" | |
4764 | "Up to 80 characters describing this neighbor\n") | |
4765 | { | |
d62a17ae | 4766 | int idx_peer = 1; |
4767 | int idx_line = 3; | |
4768 | struct peer *peer; | |
4769 | char *str; | |
718e3744 | 4770 | |
d62a17ae | 4771 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4772 | if (!peer) | |
4773 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4774 | |
d62a17ae | 4775 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 4776 | |
d62a17ae | 4777 | peer_description_set(peer, str); |
718e3744 | 4778 | |
d62a17ae | 4779 | XFREE(MTYPE_TMP, str); |
718e3744 | 4780 | |
d62a17ae | 4781 | return CMD_SUCCESS; |
718e3744 | 4782 | } |
4783 | ||
4784 | DEFUN (no_neighbor_description, | |
4785 | no_neighbor_description_cmd, | |
a14810f4 | 4786 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", |
718e3744 | 4787 | NO_STR |
4788 | NEIGHBOR_STR | |
4789 | NEIGHBOR_ADDR_STR2 | |
a14810f4 | 4790 | "Neighbor specific description\n") |
718e3744 | 4791 | { |
d62a17ae | 4792 | int idx_peer = 2; |
4793 | struct peer *peer; | |
718e3744 | 4794 | |
d62a17ae | 4795 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4796 | if (!peer) | |
4797 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4798 | |
d62a17ae | 4799 | peer_description_unset(peer); |
718e3744 | 4800 | |
d62a17ae | 4801 | return CMD_SUCCESS; |
718e3744 | 4802 | } |
4803 | ||
a14810f4 PM |
4804 | ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd, |
4805 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
4806 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4807 | "Neighbor specific description\n" | |
4808 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 4809 | |
718e3744 | 4810 | /* Neighbor update-source. */ |
d62a17ae | 4811 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, |
4812 | const char *source_str) | |
4813 | { | |
4814 | struct peer *peer; | |
4815 | struct prefix p; | |
a14810f4 | 4816 | union sockunion su; |
d62a17ae | 4817 | |
4818 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
4819 | if (!peer) | |
4820 | return CMD_WARNING_CONFIG_FAILED; | |
4821 | ||
4822 | if (peer->conf_if) | |
4823 | return CMD_WARNING; | |
4824 | ||
4825 | if (source_str) { | |
a14810f4 | 4826 | if (str2sockunion(source_str, &su) == 0) |
d62a17ae | 4827 | peer_update_source_addr_set(peer, &su); |
4828 | else { | |
4829 | if (str2prefix(source_str, &p)) { | |
4830 | vty_out(vty, | |
4831 | "%% Invalid update-source, remove prefix length \n"); | |
4832 | return CMD_WARNING_CONFIG_FAILED; | |
4833 | } else | |
4834 | peer_update_source_if_set(peer, source_str); | |
4835 | } | |
4836 | } else | |
4837 | peer_update_source_unset(peer); | |
4838 | ||
4839 | return CMD_SUCCESS; | |
4840 | } | |
4841 | ||
4842 | #define BGP_UPDATE_SOURCE_HELP_STR \ | |
4843 | "IPv4 address\n" \ | |
4844 | "IPv6 address\n" \ | |
4845 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 4846 | |
718e3744 | 4847 | DEFUN (neighbor_update_source, |
4848 | neighbor_update_source_cmd, | |
9ccf14f7 | 4849 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 4850 | NEIGHBOR_STR |
4851 | NEIGHBOR_ADDR_STR2 | |
4852 | "Source of routing updates\n" | |
369688c0 | 4853 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 4854 | { |
d62a17ae | 4855 | int idx_peer = 1; |
4856 | int idx_peer_2 = 3; | |
4857 | return peer_update_source_vty(vty, argv[idx_peer]->arg, | |
4858 | argv[idx_peer_2]->arg); | |
718e3744 | 4859 | } |
4860 | ||
4861 | DEFUN (no_neighbor_update_source, | |
4862 | no_neighbor_update_source_cmd, | |
c7178fe7 | 4863 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 4864 | NO_STR |
4865 | NEIGHBOR_STR | |
4866 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
4867 | "Source of routing updates\n" |
4868 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 4869 | { |
d62a17ae | 4870 | int idx_peer = 2; |
4871 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4872 | } |
6b0655a2 | 4873 | |
d62a17ae | 4874 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
4875 | afi_t afi, safi_t safi, | |
4876 | const char *rmap, int set) | |
718e3744 | 4877 | { |
d62a17ae | 4878 | int ret; |
4879 | struct peer *peer; | |
1de27621 | 4880 | struct route_map *route_map; |
718e3744 | 4881 | |
d62a17ae | 4882 | peer = peer_and_group_lookup_vty(vty, peer_str); |
4883 | if (!peer) | |
4884 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4885 | |
1de27621 DA |
4886 | if (set) { |
4887 | route_map = route_map_lookup_warn_noexist(vty, rmap); | |
4888 | ret = peer_default_originate_set(peer, afi, safi, | |
4889 | rmap, route_map); | |
4890 | } else | |
d62a17ae | 4891 | ret = peer_default_originate_unset(peer, afi, safi); |
718e3744 | 4892 | |
d62a17ae | 4893 | return bgp_vty_return(vty, ret); |
718e3744 | 4894 | } |
4895 | ||
4896 | /* neighbor default-originate. */ | |
4897 | DEFUN (neighbor_default_originate, | |
4898 | neighbor_default_originate_cmd, | |
9ccf14f7 | 4899 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 4900 | NEIGHBOR_STR |
4901 | NEIGHBOR_ADDR_STR2 | |
4902 | "Originate default route to this neighbor\n") | |
4903 | { | |
d62a17ae | 4904 | int idx_peer = 1; |
4905 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
4906 | bgp_node_afi(vty), | |
4907 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 4908 | } |
4909 | ||
d62a17ae | 4910 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
4911 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
4912 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4913 | "Originate default route to this neighbor\n") | |
596c17ba | 4914 | |
718e3744 | 4915 | DEFUN (neighbor_default_originate_rmap, |
4916 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 4917 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 4918 | NEIGHBOR_STR |
4919 | NEIGHBOR_ADDR_STR2 | |
4920 | "Originate default route to this neighbor\n" | |
4921 | "Route-map to specify criteria to originate default\n" | |
4922 | "route-map name\n") | |
4923 | { | |
d62a17ae | 4924 | int idx_peer = 1; |
4925 | int idx_word = 4; | |
4926 | return peer_default_originate_set_vty( | |
4927 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
4928 | argv[idx_word]->arg, 1); | |
718e3744 | 4929 | } |
4930 | ||
d62a17ae | 4931 | ALIAS_HIDDEN( |
4932 | neighbor_default_originate_rmap, | |
4933 | neighbor_default_originate_rmap_hidden_cmd, | |
4934 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
4935 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4936 | "Originate default route to this neighbor\n" | |
4937 | "Route-map to specify criteria to originate default\n" | |
4938 | "route-map name\n") | |
596c17ba | 4939 | |
718e3744 | 4940 | DEFUN (no_neighbor_default_originate, |
4941 | no_neighbor_default_originate_cmd, | |
a636c635 | 4942 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 4943 | NO_STR |
4944 | NEIGHBOR_STR | |
4945 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4946 | "Originate default route to this neighbor\n" |
4947 | "Route-map to specify criteria to originate default\n" | |
4948 | "route-map name\n") | |
718e3744 | 4949 | { |
d62a17ae | 4950 | int idx_peer = 2; |
4951 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
4952 | bgp_node_afi(vty), | |
4953 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 4954 | } |
4955 | ||
d62a17ae | 4956 | ALIAS_HIDDEN( |
4957 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
4958 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
4959 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4960 | "Originate default route to this neighbor\n" | |
4961 | "Route-map to specify criteria to originate default\n" | |
4962 | "route-map name\n") | |
596c17ba | 4963 | |
6b0655a2 | 4964 | |
718e3744 | 4965 | /* Set neighbor's BGP port. */ |
d62a17ae | 4966 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, |
4967 | const char *port_str) | |
4968 | { | |
4969 | struct peer *peer; | |
d7c0a89a | 4970 | uint16_t port; |
d62a17ae | 4971 | struct servent *sp; |
4972 | ||
4973 | peer = peer_lookup_vty(vty, ip_str); | |
4974 | if (!peer) | |
4975 | return CMD_WARNING_CONFIG_FAILED; | |
4976 | ||
4977 | if (!port_str) { | |
4978 | sp = getservbyname("bgp", "tcp"); | |
4979 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
4980 | } else { | |
4981 | port = strtoul(port_str, NULL, 10); | |
4982 | } | |
718e3744 | 4983 | |
d62a17ae | 4984 | peer_port_set(peer, port); |
718e3744 | 4985 | |
d62a17ae | 4986 | return CMD_SUCCESS; |
718e3744 | 4987 | } |
4988 | ||
f418446b | 4989 | /* Set specified peer's BGP port. */ |
718e3744 | 4990 | DEFUN (neighbor_port, |
4991 | neighbor_port_cmd, | |
9ccf14f7 | 4992 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 4993 | NEIGHBOR_STR |
4994 | NEIGHBOR_ADDR_STR | |
4995 | "Neighbor's BGP port\n" | |
4996 | "TCP port number\n") | |
4997 | { | |
d62a17ae | 4998 | int idx_ip = 1; |
4999 | int idx_number = 3; | |
5000 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
5001 | argv[idx_number]->arg); | |
718e3744 | 5002 | } |
5003 | ||
5004 | DEFUN (no_neighbor_port, | |
5005 | no_neighbor_port_cmd, | |
9ccf14f7 | 5006 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 5007 | NO_STR |
5008 | NEIGHBOR_STR | |
5009 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
5010 | "Neighbor's BGP port\n" |
5011 | "TCP port number\n") | |
718e3744 | 5012 | { |
d62a17ae | 5013 | int idx_ip = 2; |
5014 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 5015 | } |
5016 | ||
6b0655a2 | 5017 | |
718e3744 | 5018 | /* neighbor weight. */ |
d62a17ae | 5019 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5020 | safi_t safi, const char *weight_str) | |
718e3744 | 5021 | { |
d62a17ae | 5022 | int ret; |
5023 | struct peer *peer; | |
5024 | unsigned long weight; | |
718e3744 | 5025 | |
d62a17ae | 5026 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5027 | if (!peer) | |
5028 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5029 | |
d62a17ae | 5030 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 5031 | |
d62a17ae | 5032 | ret = peer_weight_set(peer, afi, safi, weight); |
5033 | return bgp_vty_return(vty, ret); | |
718e3744 | 5034 | } |
5035 | ||
d62a17ae | 5036 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5037 | safi_t safi) | |
718e3744 | 5038 | { |
d62a17ae | 5039 | int ret; |
5040 | struct peer *peer; | |
718e3744 | 5041 | |
d62a17ae | 5042 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5043 | if (!peer) | |
5044 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5045 | |
d62a17ae | 5046 | ret = peer_weight_unset(peer, afi, safi); |
5047 | return bgp_vty_return(vty, ret); | |
718e3744 | 5048 | } |
5049 | ||
5050 | DEFUN (neighbor_weight, | |
5051 | neighbor_weight_cmd, | |
9ccf14f7 | 5052 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 5053 | NEIGHBOR_STR |
5054 | NEIGHBOR_ADDR_STR2 | |
5055 | "Set default weight for routes from this neighbor\n" | |
5056 | "default weight\n") | |
5057 | { | |
d62a17ae | 5058 | int idx_peer = 1; |
5059 | int idx_number = 3; | |
5060 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5061 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 5062 | } |
5063 | ||
d62a17ae | 5064 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
5065 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
5066 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5067 | "Set default weight for routes from this neighbor\n" | |
5068 | "default weight\n") | |
596c17ba | 5069 | |
718e3744 | 5070 | DEFUN (no_neighbor_weight, |
5071 | no_neighbor_weight_cmd, | |
9ccf14f7 | 5072 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 5073 | NO_STR |
5074 | NEIGHBOR_STR | |
5075 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5076 | "Set default weight for routes from this neighbor\n" |
5077 | "default weight\n") | |
718e3744 | 5078 | { |
d62a17ae | 5079 | int idx_peer = 2; |
5080 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, | |
5081 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 5082 | } |
5083 | ||
d62a17ae | 5084 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
5085 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
5086 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5087 | "Set default weight for routes from this neighbor\n" | |
5088 | "default weight\n") | |
596c17ba | 5089 | |
6b0655a2 | 5090 | |
718e3744 | 5091 | /* Override capability negotiation. */ |
5092 | DEFUN (neighbor_override_capability, | |
5093 | neighbor_override_capability_cmd, | |
9ccf14f7 | 5094 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5095 | NEIGHBOR_STR |
5096 | NEIGHBOR_ADDR_STR2 | |
5097 | "Override capability negotiation result\n") | |
5098 | { | |
d62a17ae | 5099 | int idx_peer = 1; |
5100 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5101 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5102 | } |
5103 | ||
5104 | DEFUN (no_neighbor_override_capability, | |
5105 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 5106 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5107 | NO_STR |
5108 | NEIGHBOR_STR | |
5109 | NEIGHBOR_ADDR_STR2 | |
5110 | "Override capability negotiation result\n") | |
5111 | { | |
d62a17ae | 5112 | int idx_peer = 2; |
5113 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5114 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5115 | } |
6b0655a2 | 5116 | |
718e3744 | 5117 | DEFUN (neighbor_strict_capability, |
5118 | neighbor_strict_capability_cmd, | |
9fb964de | 5119 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5120 | NEIGHBOR_STR |
9fb964de | 5121 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5122 | "Strict capability negotiation match\n") |
5123 | { | |
9fb964de PM |
5124 | int idx_peer = 1; |
5125 | ||
5126 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5127 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5128 | } |
5129 | ||
5130 | DEFUN (no_neighbor_strict_capability, | |
5131 | no_neighbor_strict_capability_cmd, | |
9fb964de | 5132 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5133 | NO_STR |
5134 | NEIGHBOR_STR | |
9fb964de | 5135 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5136 | "Strict capability negotiation match\n") |
5137 | { | |
9fb964de PM |
5138 | int idx_peer = 2; |
5139 | ||
5140 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5141 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5142 | } |
6b0655a2 | 5143 | |
d62a17ae | 5144 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
5145 | const char *keep_str, const char *hold_str) | |
718e3744 | 5146 | { |
d62a17ae | 5147 | int ret; |
5148 | struct peer *peer; | |
d7c0a89a QY |
5149 | uint32_t keepalive; |
5150 | uint32_t holdtime; | |
718e3744 | 5151 | |
d62a17ae | 5152 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5153 | if (!peer) | |
5154 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5155 | |
d62a17ae | 5156 | keepalive = strtoul(keep_str, NULL, 10); |
5157 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 5158 | |
d62a17ae | 5159 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 5160 | |
d62a17ae | 5161 | return bgp_vty_return(vty, ret); |
718e3744 | 5162 | } |
6b0655a2 | 5163 | |
d62a17ae | 5164 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5165 | { |
d62a17ae | 5166 | int ret; |
5167 | struct peer *peer; | |
718e3744 | 5168 | |
d62a17ae | 5169 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5170 | if (!peer) | |
5171 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5172 | |
d62a17ae | 5173 | ret = peer_timers_unset(peer); |
718e3744 | 5174 | |
d62a17ae | 5175 | return bgp_vty_return(vty, ret); |
718e3744 | 5176 | } |
5177 | ||
5178 | DEFUN (neighbor_timers, | |
5179 | neighbor_timers_cmd, | |
9ccf14f7 | 5180 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 5181 | NEIGHBOR_STR |
5182 | NEIGHBOR_ADDR_STR2 | |
5183 | "BGP per neighbor timers\n" | |
5184 | "Keepalive interval\n" | |
5185 | "Holdtime\n") | |
5186 | { | |
d62a17ae | 5187 | int idx_peer = 1; |
5188 | int idx_number = 3; | |
5189 | int idx_number_2 = 4; | |
5190 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
5191 | argv[idx_number]->arg, | |
5192 | argv[idx_number_2]->arg); | |
718e3744 | 5193 | } |
5194 | ||
5195 | DEFUN (no_neighbor_timers, | |
5196 | no_neighbor_timers_cmd, | |
9ccf14f7 | 5197 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 5198 | NO_STR |
5199 | NEIGHBOR_STR | |
5200 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5201 | "BGP per neighbor timers\n" |
5202 | "Keepalive interval\n" | |
5203 | "Holdtime\n") | |
718e3744 | 5204 | { |
d62a17ae | 5205 | int idx_peer = 2; |
5206 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5207 | } |
6b0655a2 | 5208 | |
813d4307 | 5209 | |
d62a17ae | 5210 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, |
5211 | const char *time_str) | |
718e3744 | 5212 | { |
d62a17ae | 5213 | int ret; |
5214 | struct peer *peer; | |
d7c0a89a | 5215 | uint32_t connect; |
718e3744 | 5216 | |
d62a17ae | 5217 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5218 | if (!peer) | |
5219 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5220 | |
d62a17ae | 5221 | connect = strtoul(time_str, NULL, 10); |
718e3744 | 5222 | |
d62a17ae | 5223 | ret = peer_timers_connect_set(peer, connect); |
718e3744 | 5224 | |
d62a17ae | 5225 | return bgp_vty_return(vty, ret); |
718e3744 | 5226 | } |
5227 | ||
d62a17ae | 5228 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5229 | { |
d62a17ae | 5230 | int ret; |
5231 | struct peer *peer; | |
718e3744 | 5232 | |
d62a17ae | 5233 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5234 | if (!peer) | |
5235 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5236 | |
d62a17ae | 5237 | ret = peer_timers_connect_unset(peer); |
718e3744 | 5238 | |
d62a17ae | 5239 | return bgp_vty_return(vty, ret); |
718e3744 | 5240 | } |
5241 | ||
5242 | DEFUN (neighbor_timers_connect, | |
5243 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 5244 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 5245 | NEIGHBOR_STR |
966f821c | 5246 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5247 | "BGP per neighbor timers\n" |
5248 | "BGP connect timer\n" | |
5249 | "Connect timer\n") | |
5250 | { | |
d62a17ae | 5251 | int idx_peer = 1; |
5252 | int idx_number = 4; | |
5253 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
5254 | argv[idx_number]->arg); | |
718e3744 | 5255 | } |
5256 | ||
5257 | DEFUN (no_neighbor_timers_connect, | |
5258 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 5259 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 5260 | NO_STR |
5261 | NEIGHBOR_STR | |
966f821c | 5262 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5263 | "BGP per neighbor timers\n" |
8334fd5a DW |
5264 | "BGP connect timer\n" |
5265 | "Connect timer\n") | |
718e3744 | 5266 | { |
d62a17ae | 5267 | int idx_peer = 2; |
5268 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5269 | } |
5270 | ||
6b0655a2 | 5271 | |
d62a17ae | 5272 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
5273 | const char *time_str, int set) | |
718e3744 | 5274 | { |
d62a17ae | 5275 | int ret; |
5276 | struct peer *peer; | |
d7c0a89a | 5277 | uint32_t routeadv = 0; |
718e3744 | 5278 | |
d62a17ae | 5279 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5280 | if (!peer) | |
5281 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5282 | |
d62a17ae | 5283 | if (time_str) |
5284 | routeadv = strtoul(time_str, NULL, 10); | |
718e3744 | 5285 | |
d62a17ae | 5286 | if (set) |
5287 | ret = peer_advertise_interval_set(peer, routeadv); | |
5288 | else | |
5289 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 5290 | |
d62a17ae | 5291 | return bgp_vty_return(vty, ret); |
718e3744 | 5292 | } |
5293 | ||
5294 | DEFUN (neighbor_advertise_interval, | |
5295 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5296 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 5297 | NEIGHBOR_STR |
966f821c | 5298 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5299 | "Minimum interval between sending BGP routing updates\n" |
5300 | "time in seconds\n") | |
5301 | { | |
d62a17ae | 5302 | int idx_peer = 1; |
5303 | int idx_number = 3; | |
5304 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
5305 | argv[idx_number]->arg, 1); | |
718e3744 | 5306 | } |
5307 | ||
5308 | DEFUN (no_neighbor_advertise_interval, | |
5309 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5310 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 5311 | NO_STR |
5312 | NEIGHBOR_STR | |
966f821c | 5313 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
5314 | "Minimum interval between sending BGP routing updates\n" |
5315 | "time in seconds\n") | |
718e3744 | 5316 | { |
d62a17ae | 5317 | int idx_peer = 2; |
5318 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 5319 | } |
5320 | ||
6b0655a2 | 5321 | |
518f0eb1 DS |
5322 | /* Time to wait before processing route-map updates */ |
5323 | DEFUN (bgp_set_route_map_delay_timer, | |
5324 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 5325 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
5326 | SET_STR |
5327 | "BGP route-map delay timer\n" | |
5328 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 5329 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 5330 | { |
d62a17ae | 5331 | int idx_number = 3; |
d7c0a89a | 5332 | uint32_t rmap_delay_timer; |
d62a17ae | 5333 | |
5334 | if (argv[idx_number]->arg) { | |
5335 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
5336 | bm->rmap_update_timer = rmap_delay_timer; | |
5337 | ||
5338 | /* if the dynamic update handling is being disabled, and a timer | |
5339 | * is | |
5340 | * running, stop the timer and act as if the timer has already | |
5341 | * fired. | |
5342 | */ | |
5343 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
5344 | BGP_TIMER_OFF(bm->t_rmap_update); | |
5345 | thread_execute(bm->master, bgp_route_map_update_timer, | |
5346 | NULL, 0); | |
5347 | } | |
5348 | return CMD_SUCCESS; | |
5349 | } else { | |
5350 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
5351 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 5352 | } |
518f0eb1 DS |
5353 | } |
5354 | ||
5355 | DEFUN (no_bgp_set_route_map_delay_timer, | |
5356 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 5357 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 5358 | NO_STR |
3a2d747c | 5359 | BGP_STR |
518f0eb1 | 5360 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
5361 | "Reset to default time to wait for processing route-map changes\n" |
5362 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 5363 | { |
518f0eb1 | 5364 | |
d62a17ae | 5365 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 5366 | |
d62a17ae | 5367 | return CMD_SUCCESS; |
518f0eb1 DS |
5368 | } |
5369 | ||
f414725f | 5370 | |
718e3744 | 5371 | /* neighbor interface */ |
d62a17ae | 5372 | static int peer_interface_vty(struct vty *vty, const char *ip_str, |
5373 | const char *str) | |
718e3744 | 5374 | { |
d62a17ae | 5375 | struct peer *peer; |
718e3744 | 5376 | |
d62a17ae | 5377 | peer = peer_lookup_vty(vty, ip_str); |
5378 | if (!peer || peer->conf_if) { | |
5379 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
5380 | return CMD_WARNING_CONFIG_FAILED; | |
5381 | } | |
718e3744 | 5382 | |
d62a17ae | 5383 | if (str) |
5384 | peer_interface_set(peer, str); | |
5385 | else | |
5386 | peer_interface_unset(peer); | |
718e3744 | 5387 | |
d62a17ae | 5388 | return CMD_SUCCESS; |
718e3744 | 5389 | } |
5390 | ||
5391 | DEFUN (neighbor_interface, | |
5392 | neighbor_interface_cmd, | |
9ccf14f7 | 5393 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 5394 | NEIGHBOR_STR |
5395 | NEIGHBOR_ADDR_STR | |
5396 | "Interface\n" | |
5397 | "Interface name\n") | |
5398 | { | |
d62a17ae | 5399 | int idx_ip = 1; |
5400 | int idx_word = 3; | |
5401 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); | |
718e3744 | 5402 | } |
5403 | ||
5404 | DEFUN (no_neighbor_interface, | |
5405 | no_neighbor_interface_cmd, | |
9ccf14f7 | 5406 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 5407 | NO_STR |
5408 | NEIGHBOR_STR | |
16cedbb0 | 5409 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5410 | "Interface\n" |
5411 | "Interface name\n") | |
5412 | { | |
d62a17ae | 5413 | int idx_peer = 2; |
5414 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5415 | } |
6b0655a2 | 5416 | |
718e3744 | 5417 | DEFUN (neighbor_distribute_list, |
5418 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 5419 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5420 | NEIGHBOR_STR |
5421 | NEIGHBOR_ADDR_STR2 | |
5422 | "Filter updates to/from this neighbor\n" | |
5423 | "IP access-list number\n" | |
5424 | "IP access-list number (expanded range)\n" | |
5425 | "IP Access-list name\n" | |
5426 | "Filter incoming updates\n" | |
5427 | "Filter outgoing updates\n") | |
5428 | { | |
d62a17ae | 5429 | int idx_peer = 1; |
5430 | int idx_acl = 3; | |
5431 | int direct, ret; | |
5432 | struct peer *peer; | |
a8206004 | 5433 | |
d62a17ae | 5434 | const char *pstr = argv[idx_peer]->arg; |
5435 | const char *acl = argv[idx_acl]->arg; | |
5436 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5437 | |
d62a17ae | 5438 | peer = peer_and_group_lookup_vty(vty, pstr); |
5439 | if (!peer) | |
5440 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5441 | |
d62a17ae | 5442 | /* Check filter direction. */ |
5443 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5444 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5445 | direct, acl); | |
a8206004 | 5446 | |
d62a17ae | 5447 | return bgp_vty_return(vty, ret); |
718e3744 | 5448 | } |
5449 | ||
d62a17ae | 5450 | ALIAS_HIDDEN( |
5451 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
5452 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5453 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5454 | "Filter updates to/from this neighbor\n" | |
5455 | "IP access-list number\n" | |
5456 | "IP access-list number (expanded range)\n" | |
5457 | "IP Access-list name\n" | |
5458 | "Filter incoming updates\n" | |
5459 | "Filter outgoing updates\n") | |
596c17ba | 5460 | |
718e3744 | 5461 | DEFUN (no_neighbor_distribute_list, |
5462 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 5463 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5464 | NO_STR |
5465 | NEIGHBOR_STR | |
5466 | NEIGHBOR_ADDR_STR2 | |
5467 | "Filter updates to/from this neighbor\n" | |
5468 | "IP access-list number\n" | |
5469 | "IP access-list number (expanded range)\n" | |
5470 | "IP Access-list name\n" | |
5471 | "Filter incoming updates\n" | |
5472 | "Filter outgoing updates\n") | |
5473 | { | |
d62a17ae | 5474 | int idx_peer = 2; |
5475 | int direct, ret; | |
5476 | struct peer *peer; | |
a8206004 | 5477 | |
d62a17ae | 5478 | const char *pstr = argv[idx_peer]->arg; |
5479 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5480 | |
d62a17ae | 5481 | peer = peer_and_group_lookup_vty(vty, pstr); |
5482 | if (!peer) | |
5483 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5484 | |
d62a17ae | 5485 | /* Check filter direction. */ |
5486 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5487 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5488 | direct); | |
a8206004 | 5489 | |
d62a17ae | 5490 | return bgp_vty_return(vty, ret); |
718e3744 | 5491 | } |
6b0655a2 | 5492 | |
d62a17ae | 5493 | ALIAS_HIDDEN( |
5494 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
5495 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5496 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5497 | "Filter updates to/from this neighbor\n" | |
5498 | "IP access-list number\n" | |
5499 | "IP access-list number (expanded range)\n" | |
5500 | "IP Access-list name\n" | |
5501 | "Filter incoming updates\n" | |
5502 | "Filter outgoing updates\n") | |
596c17ba | 5503 | |
718e3744 | 5504 | /* Set prefix list to the peer. */ |
d62a17ae | 5505 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
5506 | afi_t afi, safi_t safi, | |
5507 | const char *name_str, | |
5508 | const char *direct_str) | |
718e3744 | 5509 | { |
d62a17ae | 5510 | int ret; |
d62a17ae | 5511 | int direct = FILTER_IN; |
cf9ac8bf | 5512 | struct peer *peer; |
718e3744 | 5513 | |
d62a17ae | 5514 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5515 | if (!peer) | |
5516 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5517 | |
d62a17ae | 5518 | /* Check filter direction. */ |
5519 | if (strncmp(direct_str, "i", 1) == 0) | |
5520 | direct = FILTER_IN; | |
5521 | else if (strncmp(direct_str, "o", 1) == 0) | |
5522 | direct = FILTER_OUT; | |
718e3744 | 5523 | |
d62a17ae | 5524 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 5525 | |
d62a17ae | 5526 | return bgp_vty_return(vty, ret); |
718e3744 | 5527 | } |
5528 | ||
d62a17ae | 5529 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, |
5530 | afi_t afi, safi_t safi, | |
5531 | const char *direct_str) | |
718e3744 | 5532 | { |
d62a17ae | 5533 | int ret; |
5534 | struct peer *peer; | |
5535 | int direct = FILTER_IN; | |
718e3744 | 5536 | |
d62a17ae | 5537 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5538 | if (!peer) | |
5539 | return CMD_WARNING_CONFIG_FAILED; | |
e52702f2 | 5540 | |
d62a17ae | 5541 | /* Check filter direction. */ |
5542 | if (strncmp(direct_str, "i", 1) == 0) | |
5543 | direct = FILTER_IN; | |
5544 | else if (strncmp(direct_str, "o", 1) == 0) | |
5545 | direct = FILTER_OUT; | |
718e3744 | 5546 | |
d62a17ae | 5547 | ret = peer_prefix_list_unset(peer, afi, safi, direct); |
718e3744 | 5548 | |
d62a17ae | 5549 | return bgp_vty_return(vty, ret); |
718e3744 | 5550 | } |
5551 | ||
5552 | DEFUN (neighbor_prefix_list, | |
5553 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 5554 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5555 | NEIGHBOR_STR |
5556 | NEIGHBOR_ADDR_STR2 | |
5557 | "Filter updates to/from this neighbor\n" | |
5558 | "Name of a prefix list\n" | |
5559 | "Filter incoming updates\n" | |
5560 | "Filter outgoing updates\n") | |
5561 | { | |
d62a17ae | 5562 | int idx_peer = 1; |
5563 | int idx_word = 3; | |
5564 | int idx_in_out = 4; | |
5565 | return peer_prefix_list_set_vty( | |
5566 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5567 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5568 | } |
5569 | ||
d62a17ae | 5570 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
5571 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5572 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5573 | "Filter updates to/from this neighbor\n" | |
5574 | "Name of a prefix list\n" | |
5575 | "Filter incoming updates\n" | |
5576 | "Filter outgoing updates\n") | |
596c17ba | 5577 | |
718e3744 | 5578 | DEFUN (no_neighbor_prefix_list, |
5579 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 5580 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5581 | NO_STR |
5582 | NEIGHBOR_STR | |
5583 | NEIGHBOR_ADDR_STR2 | |
5584 | "Filter updates to/from this neighbor\n" | |
5585 | "Name of a prefix list\n" | |
5586 | "Filter incoming updates\n" | |
5587 | "Filter outgoing updates\n") | |
5588 | { | |
d62a17ae | 5589 | int idx_peer = 2; |
5590 | int idx_in_out = 5; | |
5591 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
5592 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5593 | argv[idx_in_out]->arg); | |
718e3744 | 5594 | } |
6b0655a2 | 5595 | |
d62a17ae | 5596 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, |
5597 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5598 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5599 | "Filter updates to/from this neighbor\n" | |
5600 | "Name of a prefix list\n" | |
5601 | "Filter incoming updates\n" | |
5602 | "Filter outgoing updates\n") | |
596c17ba | 5603 | |
d62a17ae | 5604 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5605 | safi_t safi, const char *name_str, | |
5606 | const char *direct_str) | |
718e3744 | 5607 | { |
d62a17ae | 5608 | int ret; |
5609 | struct peer *peer; | |
5610 | int direct = FILTER_IN; | |
718e3744 | 5611 | |
d62a17ae | 5612 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5613 | if (!peer) | |
5614 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5615 | |
d62a17ae | 5616 | /* Check filter direction. */ |
5617 | if (strncmp(direct_str, "i", 1) == 0) | |
5618 | direct = FILTER_IN; | |
5619 | else if (strncmp(direct_str, "o", 1) == 0) | |
5620 | direct = FILTER_OUT; | |
718e3744 | 5621 | |
d62a17ae | 5622 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 5623 | |
d62a17ae | 5624 | return bgp_vty_return(vty, ret); |
718e3744 | 5625 | } |
5626 | ||
d62a17ae | 5627 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5628 | safi_t safi, const char *direct_str) | |
718e3744 | 5629 | { |
d62a17ae | 5630 | int ret; |
5631 | struct peer *peer; | |
5632 | int direct = FILTER_IN; | |
718e3744 | 5633 | |
d62a17ae | 5634 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5635 | if (!peer) | |
5636 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5637 | |
d62a17ae | 5638 | /* Check filter direction. */ |
5639 | if (strncmp(direct_str, "i", 1) == 0) | |
5640 | direct = FILTER_IN; | |
5641 | else if (strncmp(direct_str, "o", 1) == 0) | |
5642 | direct = FILTER_OUT; | |
718e3744 | 5643 | |
d62a17ae | 5644 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 5645 | |
d62a17ae | 5646 | return bgp_vty_return(vty, ret); |
718e3744 | 5647 | } |
5648 | ||
5649 | DEFUN (neighbor_filter_list, | |
5650 | neighbor_filter_list_cmd, | |
9ccf14f7 | 5651 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5652 | NEIGHBOR_STR |
5653 | NEIGHBOR_ADDR_STR2 | |
5654 | "Establish BGP filters\n" | |
5655 | "AS path access-list name\n" | |
5656 | "Filter incoming routes\n" | |
5657 | "Filter outgoing routes\n") | |
5658 | { | |
d62a17ae | 5659 | int idx_peer = 1; |
5660 | int idx_word = 3; | |
5661 | int idx_in_out = 4; | |
5662 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5663 | bgp_node_safi(vty), argv[idx_word]->arg, | |
5664 | argv[idx_in_out]->arg); | |
718e3744 | 5665 | } |
5666 | ||
d62a17ae | 5667 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
5668 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5669 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5670 | "Establish BGP filters\n" | |
5671 | "AS path access-list name\n" | |
5672 | "Filter incoming routes\n" | |
5673 | "Filter outgoing routes\n") | |
596c17ba | 5674 | |
718e3744 | 5675 | DEFUN (no_neighbor_filter_list, |
5676 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 5677 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5678 | NO_STR |
5679 | NEIGHBOR_STR | |
5680 | NEIGHBOR_ADDR_STR2 | |
5681 | "Establish BGP filters\n" | |
5682 | "AS path access-list name\n" | |
5683 | "Filter incoming routes\n" | |
5684 | "Filter outgoing routes\n") | |
5685 | { | |
d62a17ae | 5686 | int idx_peer = 2; |
5687 | int idx_in_out = 5; | |
5688 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
5689 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5690 | argv[idx_in_out]->arg); | |
718e3744 | 5691 | } |
6b0655a2 | 5692 | |
d62a17ae | 5693 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
5694 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5695 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5696 | "Establish BGP filters\n" | |
5697 | "AS path access-list name\n" | |
5698 | "Filter incoming routes\n" | |
5699 | "Filter outgoing routes\n") | |
596c17ba | 5700 | |
718e3744 | 5701 | /* Set route-map to the peer. */ |
d62a17ae | 5702 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
5703 | afi_t afi, safi_t safi, const char *name_str, | |
5704 | const char *direct_str) | |
718e3744 | 5705 | { |
d62a17ae | 5706 | int ret; |
5707 | struct peer *peer; | |
5708 | int direct = RMAP_IN; | |
1de27621 | 5709 | struct route_map *route_map; |
718e3744 | 5710 | |
d62a17ae | 5711 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5712 | if (!peer) | |
5713 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5714 | |
d62a17ae | 5715 | /* Check filter direction. */ |
5716 | if (strncmp(direct_str, "in", 2) == 0) | |
5717 | direct = RMAP_IN; | |
5718 | else if (strncmp(direct_str, "o", 1) == 0) | |
5719 | direct = RMAP_OUT; | |
718e3744 | 5720 | |
1de27621 DA |
5721 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
5722 | ret = peer_route_map_set(peer, afi, safi, direct, name_str, route_map); | |
718e3744 | 5723 | |
d62a17ae | 5724 | return bgp_vty_return(vty, ret); |
718e3744 | 5725 | } |
5726 | ||
d62a17ae | 5727 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, |
5728 | afi_t afi, safi_t safi, | |
5729 | const char *direct_str) | |
718e3744 | 5730 | { |
d62a17ae | 5731 | int ret; |
5732 | struct peer *peer; | |
5733 | int direct = RMAP_IN; | |
718e3744 | 5734 | |
d62a17ae | 5735 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5736 | if (!peer) | |
5737 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5738 | |
d62a17ae | 5739 | /* Check filter direction. */ |
5740 | if (strncmp(direct_str, "in", 2) == 0) | |
5741 | direct = RMAP_IN; | |
5742 | else if (strncmp(direct_str, "o", 1) == 0) | |
5743 | direct = RMAP_OUT; | |
718e3744 | 5744 | |
d62a17ae | 5745 | ret = peer_route_map_unset(peer, afi, safi, direct); |
718e3744 | 5746 | |
d62a17ae | 5747 | return bgp_vty_return(vty, ret); |
718e3744 | 5748 | } |
5749 | ||
5750 | DEFUN (neighbor_route_map, | |
5751 | neighbor_route_map_cmd, | |
9ccf14f7 | 5752 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5753 | NEIGHBOR_STR |
5754 | NEIGHBOR_ADDR_STR2 | |
5755 | "Apply route map to neighbor\n" | |
5756 | "Name of route map\n" | |
5757 | "Apply map to incoming routes\n" | |
2a3d5731 | 5758 | "Apply map to outbound routes\n") |
718e3744 | 5759 | { |
d62a17ae | 5760 | int idx_peer = 1; |
5761 | int idx_word = 3; | |
5762 | int idx_in_out = 4; | |
5763 | return peer_route_map_set_vty( | |
5764 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5765 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5766 | } |
5767 | ||
d62a17ae | 5768 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
5769 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5770 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5771 | "Apply route map to neighbor\n" | |
5772 | "Name of route map\n" | |
5773 | "Apply map to incoming routes\n" | |
5774 | "Apply map to outbound routes\n") | |
596c17ba | 5775 | |
718e3744 | 5776 | DEFUN (no_neighbor_route_map, |
5777 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 5778 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5779 | NO_STR |
5780 | NEIGHBOR_STR | |
5781 | NEIGHBOR_ADDR_STR2 | |
5782 | "Apply route map to neighbor\n" | |
5783 | "Name of route map\n" | |
5784 | "Apply map to incoming routes\n" | |
2a3d5731 | 5785 | "Apply map to outbound routes\n") |
718e3744 | 5786 | { |
d62a17ae | 5787 | int idx_peer = 2; |
5788 | int idx_in_out = 5; | |
5789 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
5790 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5791 | argv[idx_in_out]->arg); | |
718e3744 | 5792 | } |
6b0655a2 | 5793 | |
d62a17ae | 5794 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, |
5795 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5796 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5797 | "Apply route map to neighbor\n" | |
5798 | "Name of route map\n" | |
5799 | "Apply map to incoming routes\n" | |
5800 | "Apply map to outbound routes\n") | |
596c17ba | 5801 | |
718e3744 | 5802 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 5803 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
5804 | afi_t afi, safi_t safi, | |
5805 | const char *name_str) | |
718e3744 | 5806 | { |
d62a17ae | 5807 | int ret; |
5808 | struct peer *peer; | |
1de27621 | 5809 | struct route_map *route_map; |
718e3744 | 5810 | |
d62a17ae | 5811 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5812 | if (!peer) | |
5813 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5814 | |
1de27621 DA |
5815 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
5816 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str, route_map); | |
718e3744 | 5817 | |
d62a17ae | 5818 | return bgp_vty_return(vty, ret); |
718e3744 | 5819 | } |
5820 | ||
5821 | /* Unset route-map from the peer. */ | |
d62a17ae | 5822 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
5823 | afi_t afi, safi_t safi) | |
718e3744 | 5824 | { |
d62a17ae | 5825 | int ret; |
5826 | struct peer *peer; | |
718e3744 | 5827 | |
d62a17ae | 5828 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5829 | if (!peer) | |
5830 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5831 | |
d62a17ae | 5832 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 5833 | |
d62a17ae | 5834 | return bgp_vty_return(vty, ret); |
718e3744 | 5835 | } |
5836 | ||
5837 | DEFUN (neighbor_unsuppress_map, | |
5838 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5839 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5840 | NEIGHBOR_STR |
5841 | NEIGHBOR_ADDR_STR2 | |
5842 | "Route-map to selectively unsuppress suppressed routes\n" | |
5843 | "Name of route map\n") | |
5844 | { | |
d62a17ae | 5845 | int idx_peer = 1; |
5846 | int idx_word = 3; | |
5847 | return peer_unsuppress_map_set_vty( | |
5848 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5849 | argv[idx_word]->arg); | |
718e3744 | 5850 | } |
5851 | ||
d62a17ae | 5852 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
5853 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5854 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5855 | "Route-map to selectively unsuppress suppressed routes\n" | |
5856 | "Name of route map\n") | |
596c17ba | 5857 | |
718e3744 | 5858 | DEFUN (no_neighbor_unsuppress_map, |
5859 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5860 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5861 | NO_STR |
5862 | NEIGHBOR_STR | |
5863 | NEIGHBOR_ADDR_STR2 | |
5864 | "Route-map to selectively unsuppress suppressed routes\n" | |
5865 | "Name of route map\n") | |
5866 | { | |
d62a17ae | 5867 | int idx_peer = 2; |
5868 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
5869 | bgp_node_afi(vty), | |
5870 | bgp_node_safi(vty)); | |
718e3744 | 5871 | } |
6b0655a2 | 5872 | |
d62a17ae | 5873 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
5874 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5875 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5876 | "Route-map to selectively unsuppress suppressed routes\n" | |
5877 | "Name of route map\n") | |
596c17ba | 5878 | |
d62a17ae | 5879 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
5880 | afi_t afi, safi_t safi, | |
5881 | const char *num_str, | |
5882 | const char *threshold_str, int warning, | |
5883 | const char *restart_str) | |
718e3744 | 5884 | { |
d62a17ae | 5885 | int ret; |
5886 | struct peer *peer; | |
d7c0a89a QY |
5887 | uint32_t max; |
5888 | uint8_t threshold; | |
5889 | uint16_t restart; | |
718e3744 | 5890 | |
d62a17ae | 5891 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5892 | if (!peer) | |
5893 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5894 | |
d62a17ae | 5895 | max = strtoul(num_str, NULL, 10); |
5896 | if (threshold_str) | |
5897 | threshold = atoi(threshold_str); | |
5898 | else | |
5899 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 5900 | |
d62a17ae | 5901 | if (restart_str) |
5902 | restart = atoi(restart_str); | |
5903 | else | |
5904 | restart = 0; | |
0a486e5f | 5905 | |
d62a17ae | 5906 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, |
5907 | restart); | |
718e3744 | 5908 | |
d62a17ae | 5909 | return bgp_vty_return(vty, ret); |
718e3744 | 5910 | } |
5911 | ||
d62a17ae | 5912 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, |
5913 | afi_t afi, safi_t safi) | |
718e3744 | 5914 | { |
d62a17ae | 5915 | int ret; |
5916 | struct peer *peer; | |
718e3744 | 5917 | |
d62a17ae | 5918 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5919 | if (!peer) | |
5920 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5921 | |
d62a17ae | 5922 | ret = peer_maximum_prefix_unset(peer, afi, safi); |
718e3744 | 5923 | |
d62a17ae | 5924 | return bgp_vty_return(vty, ret); |
718e3744 | 5925 | } |
5926 | ||
5927 | /* Maximum number of prefix configuration. prefix count is different | |
5928 | for each peer configuration. So this configuration can be set for | |
5929 | each peer configuration. */ | |
5930 | DEFUN (neighbor_maximum_prefix, | |
5931 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 5932 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 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 | { | |
d62a17ae | 5938 | int idx_peer = 1; |
5939 | int idx_number = 3; | |
5940 | return peer_maximum_prefix_set_vty( | |
5941 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5942 | argv[idx_number]->arg, NULL, 0, NULL); | |
718e3744 | 5943 | } |
5944 | ||
d62a17ae | 5945 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
5946 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", | |
5947 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5948 | "Maximum number of prefix accept from this peer\n" | |
5949 | "maximum no. of prefix limit\n") | |
596c17ba | 5950 | |
e0701b79 | 5951 | DEFUN (neighbor_maximum_prefix_threshold, |
5952 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 5953 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 5954 | NEIGHBOR_STR |
5955 | NEIGHBOR_ADDR_STR2 | |
5956 | "Maximum number of prefix accept from this peer\n" | |
5957 | "maximum no. of prefix limit\n" | |
5958 | "Threshold value (%) at which to generate a warning msg\n") | |
5959 | { | |
d62a17ae | 5960 | int idx_peer = 1; |
5961 | int idx_number = 3; | |
5962 | int idx_number_2 = 4; | |
5963 | return peer_maximum_prefix_set_vty( | |
5964 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5965 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL); | |
0a486e5f | 5966 | } |
e0701b79 | 5967 | |
d62a17ae | 5968 | ALIAS_HIDDEN( |
5969 | neighbor_maximum_prefix_threshold, | |
5970 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
5971 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", | |
5972 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5973 | "Maximum number of prefix accept from this peer\n" | |
5974 | "maximum no. of prefix limit\n" | |
5975 | "Threshold value (%) at which to generate a warning msg\n") | |
596c17ba | 5976 | |
718e3744 | 5977 | DEFUN (neighbor_maximum_prefix_warning, |
5978 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 5979 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 5980 | NEIGHBOR_STR |
5981 | NEIGHBOR_ADDR_STR2 | |
5982 | "Maximum number of prefix accept from this peer\n" | |
5983 | "maximum no. of prefix limit\n" | |
5984 | "Only give warning message when limit is exceeded\n") | |
5985 | { | |
d62a17ae | 5986 | int idx_peer = 1; |
5987 | int idx_number = 3; | |
5988 | return peer_maximum_prefix_set_vty( | |
5989 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5990 | argv[idx_number]->arg, NULL, 1, NULL); | |
718e3744 | 5991 | } |
5992 | ||
d62a17ae | 5993 | ALIAS_HIDDEN( |
5994 | neighbor_maximum_prefix_warning, | |
5995 | neighbor_maximum_prefix_warning_hidden_cmd, | |
5996 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", | |
5997 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5998 | "Maximum number of prefix accept from this peer\n" | |
5999 | "maximum no. of prefix limit\n" | |
6000 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6001 | |
e0701b79 | 6002 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
6003 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 6004 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 6005 | NEIGHBOR_STR |
6006 | NEIGHBOR_ADDR_STR2 | |
6007 | "Maximum number of prefix accept from this peer\n" | |
6008 | "maximum no. of prefix limit\n" | |
6009 | "Threshold value (%) at which to generate a warning msg\n" | |
6010 | "Only give warning message when limit is exceeded\n") | |
6011 | { | |
d62a17ae | 6012 | int idx_peer = 1; |
6013 | int idx_number = 3; | |
6014 | int idx_number_2 = 4; | |
6015 | return peer_maximum_prefix_set_vty( | |
6016 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6017 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 6018 | } |
6019 | ||
d62a17ae | 6020 | ALIAS_HIDDEN( |
6021 | neighbor_maximum_prefix_threshold_warning, | |
6022 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
6023 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", | |
6024 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6025 | "Maximum number of prefix accept from this peer\n" | |
6026 | "maximum no. of prefix limit\n" | |
6027 | "Threshold value (%) at which to generate a warning msg\n" | |
6028 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6029 | |
0a486e5f | 6030 | DEFUN (neighbor_maximum_prefix_restart, |
6031 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 6032 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 6033 | NEIGHBOR_STR |
6034 | NEIGHBOR_ADDR_STR2 | |
6035 | "Maximum number of prefix accept from this peer\n" | |
6036 | "maximum no. of prefix limit\n" | |
6037 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 6038 | "Restart interval in minutes\n") |
0a486e5f | 6039 | { |
d62a17ae | 6040 | int idx_peer = 1; |
6041 | int idx_number = 3; | |
6042 | int idx_number_2 = 5; | |
6043 | return peer_maximum_prefix_set_vty( | |
6044 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6045 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 6046 | } |
6047 | ||
d62a17ae | 6048 | ALIAS_HIDDEN( |
6049 | neighbor_maximum_prefix_restart, | |
6050 | neighbor_maximum_prefix_restart_hidden_cmd, | |
6051 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", | |
6052 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6053 | "Maximum number of prefix accept from this peer\n" | |
6054 | "maximum no. of prefix limit\n" | |
6055 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 6056 | "Restart interval in minutes\n") |
596c17ba | 6057 | |
0a486e5f | 6058 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
6059 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 6060 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 6061 | NEIGHBOR_STR |
6062 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6063 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 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" | |
16cedbb0 | 6067 | "Restart interval in minutes\n") |
0a486e5f | 6068 | { |
d62a17ae | 6069 | int idx_peer = 1; |
6070 | int idx_number = 3; | |
6071 | int idx_number_2 = 4; | |
6072 | int idx_number_3 = 6; | |
6073 | return peer_maximum_prefix_set_vty( | |
6074 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6075 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
6076 | argv[idx_number_3]->arg); | |
6077 | } | |
6078 | ||
6079 | ALIAS_HIDDEN( | |
6080 | neighbor_maximum_prefix_threshold_restart, | |
6081 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
6082 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", | |
6083 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6084 | "Maximum number of prefixes to accept from this peer\n" | |
6085 | "maximum no. of prefix limit\n" | |
6086 | "Threshold value (%) at which to generate a warning msg\n" | |
6087 | "Restart bgp connection after limit is exceeded\n" | |
6088 | "Restart interval in minutes\n") | |
596c17ba | 6089 | |
718e3744 | 6090 | DEFUN (no_neighbor_maximum_prefix, |
6091 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 6092 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 6093 | NO_STR |
6094 | NEIGHBOR_STR | |
6095 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6096 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
6097 | "maximum no. of prefix limit\n" |
6098 | "Threshold value (%) at which to generate a warning msg\n" | |
6099 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6100 | "Restart interval in minutes\n" |
31500417 | 6101 | "Only give warning message when limit is exceeded\n") |
718e3744 | 6102 | { |
d62a17ae | 6103 | int idx_peer = 2; |
6104 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, | |
6105 | bgp_node_afi(vty), | |
6106 | bgp_node_safi(vty)); | |
718e3744 | 6107 | } |
e52702f2 | 6108 | |
d62a17ae | 6109 | ALIAS_HIDDEN( |
6110 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
6111 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", | |
6112 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6113 | "Maximum number of prefixes to accept from this peer\n" | |
6114 | "maximum no. of prefix limit\n" | |
6115 | "Threshold value (%) at which to generate a warning msg\n" | |
6116 | "Restart bgp connection after limit is exceeded\n" | |
6117 | "Restart interval in minutes\n" | |
6118 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6119 | |
718e3744 | 6120 | |
718e3744 | 6121 | /* "neighbor allowas-in" */ |
6122 | DEFUN (neighbor_allowas_in, | |
6123 | neighbor_allowas_in_cmd, | |
fd8503f5 | 6124 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6125 | NEIGHBOR_STR |
6126 | NEIGHBOR_ADDR_STR2 | |
31500417 | 6127 | "Accept as-path with my AS present in it\n" |
0437e105 | 6128 | "Number of occurences of AS number\n" |
fd8503f5 | 6129 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 6130 | { |
d62a17ae | 6131 | int idx_peer = 1; |
6132 | int idx_number_origin = 3; | |
6133 | int ret; | |
6134 | int origin = 0; | |
6135 | struct peer *peer; | |
6136 | int allow_num = 0; | |
6137 | ||
6138 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6139 | if (!peer) | |
6140 | return CMD_WARNING_CONFIG_FAILED; | |
6141 | ||
6142 | if (argc <= idx_number_origin) | |
6143 | allow_num = 3; | |
6144 | else { | |
6145 | if (argv[idx_number_origin]->type == WORD_TKN) | |
6146 | origin = 1; | |
6147 | else | |
6148 | allow_num = atoi(argv[idx_number_origin]->arg); | |
6149 | } | |
6150 | ||
6151 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6152 | allow_num, origin); | |
6153 | ||
6154 | return bgp_vty_return(vty, ret); | |
6155 | } | |
6156 | ||
6157 | ALIAS_HIDDEN( | |
6158 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
6159 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6160 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6161 | "Accept as-path with my AS present in it\n" | |
0437e105 | 6162 | "Number of occurences of AS number\n" |
d62a17ae | 6163 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 6164 | |
718e3744 | 6165 | DEFUN (no_neighbor_allowas_in, |
6166 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 6167 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6168 | NO_STR |
6169 | NEIGHBOR_STR | |
6170 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 6171 | "allow local ASN appears in aspath attribute\n" |
0437e105 | 6172 | "Number of occurences of AS number\n" |
fd8503f5 | 6173 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 6174 | { |
d62a17ae | 6175 | int idx_peer = 2; |
6176 | int ret; | |
6177 | struct peer *peer; | |
718e3744 | 6178 | |
d62a17ae | 6179 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6180 | if (!peer) | |
6181 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6182 | |
d62a17ae | 6183 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
6184 | bgp_node_safi(vty)); | |
718e3744 | 6185 | |
d62a17ae | 6186 | return bgp_vty_return(vty, ret); |
718e3744 | 6187 | } |
6b0655a2 | 6188 | |
d62a17ae | 6189 | ALIAS_HIDDEN( |
6190 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
6191 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6192 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6193 | "allow local ASN appears in aspath attribute\n" | |
0437e105 | 6194 | "Number of occurences of AS number\n" |
d62a17ae | 6195 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 6196 | |
fa411a21 NH |
6197 | DEFUN (neighbor_ttl_security, |
6198 | neighbor_ttl_security_cmd, | |
7ebe625c | 6199 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 | 6200 | NEIGHBOR_STR |
7ebe625c | 6201 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6202 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
6203 | "Specify the maximum number of hops to the BGP peer\n" |
6204 | "Number of hops to BGP peer\n") | |
fa411a21 | 6205 | { |
d62a17ae | 6206 | int idx_peer = 1; |
6207 | int idx_number = 4; | |
6208 | struct peer *peer; | |
6209 | int gtsm_hops; | |
6210 | ||
6211 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6212 | if (!peer) | |
6213 | return CMD_WARNING_CONFIG_FAILED; | |
6214 | ||
6215 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); | |
6216 | ||
7ebe625c QY |
6217 | /* |
6218 | * If 'neighbor swpX', then this is for directly connected peers, | |
6219 | * we should not accept a ttl-security hops value greater than 1. | |
6220 | */ | |
6221 | if (peer->conf_if && (gtsm_hops > 1)) { | |
6222 | vty_out(vty, | |
6223 | "%s is directly connected peer, hops cannot exceed 1\n", | |
6224 | argv[idx_peer]->arg); | |
6225 | return CMD_WARNING_CONFIG_FAILED; | |
6226 | } | |
6227 | ||
d62a17ae | 6228 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
6229 | } |
6230 | ||
6231 | DEFUN (no_neighbor_ttl_security, | |
6232 | no_neighbor_ttl_security_cmd, | |
7ebe625c | 6233 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
6234 | NO_STR |
6235 | NEIGHBOR_STR | |
7ebe625c | 6236 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6237 | "BGP ttl-security parameters\n" |
3a2d747c QY |
6238 | "Specify the maximum number of hops to the BGP peer\n" |
6239 | "Number of hops to BGP peer\n") | |
fa411a21 | 6240 | { |
d62a17ae | 6241 | int idx_peer = 2; |
6242 | struct peer *peer; | |
fa411a21 | 6243 | |
d62a17ae | 6244 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6245 | if (!peer) | |
6246 | return CMD_WARNING_CONFIG_FAILED; | |
fa411a21 | 6247 | |
d62a17ae | 6248 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 6249 | } |
6b0655a2 | 6250 | |
adbac85e DW |
6251 | DEFUN (neighbor_addpath_tx_all_paths, |
6252 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6253 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6254 | NEIGHBOR_STR |
6255 | NEIGHBOR_ADDR_STR2 | |
6256 | "Use addpath to advertise all paths to a neighbor\n") | |
6257 | { | |
d62a17ae | 6258 | int idx_peer = 1; |
6259 | struct peer *peer; | |
adbac85e | 6260 | |
d62a17ae | 6261 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6262 | if (!peer) | |
6263 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 6264 | |
dcc68b5e MS |
6265 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
6266 | BGP_ADDPATH_ALL); | |
6267 | return CMD_SUCCESS; | |
adbac85e DW |
6268 | } |
6269 | ||
d62a17ae | 6270 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
6271 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
6272 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6273 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6274 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6275 | |
adbac85e DW |
6276 | DEFUN (no_neighbor_addpath_tx_all_paths, |
6277 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6278 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6279 | NO_STR |
6280 | NEIGHBOR_STR | |
6281 | NEIGHBOR_ADDR_STR2 | |
6282 | "Use addpath to advertise all paths to a neighbor\n") | |
6283 | { | |
d62a17ae | 6284 | int idx_peer = 2; |
dcc68b5e MS |
6285 | struct peer *peer; |
6286 | ||
6287 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6288 | if (!peer) | |
6289 | return CMD_WARNING_CONFIG_FAILED; | |
6290 | ||
6291 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
6292 | != BGP_ADDPATH_ALL) { | |
6293 | vty_out(vty, | |
6294 | "%% Peer not currently configured to transmit all paths."); | |
6295 | return CMD_WARNING_CONFIG_FAILED; | |
6296 | } | |
6297 | ||
6298 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6299 | BGP_ADDPATH_NONE); | |
6300 | ||
6301 | return CMD_SUCCESS; | |
adbac85e DW |
6302 | } |
6303 | ||
d62a17ae | 6304 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
6305 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
6306 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6307 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6308 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6309 | |
06370dac DW |
6310 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
6311 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6312 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6313 | NEIGHBOR_STR |
6314 | NEIGHBOR_ADDR_STR2 | |
6315 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6316 | { | |
d62a17ae | 6317 | int idx_peer = 1; |
6318 | struct peer *peer; | |
06370dac | 6319 | |
d62a17ae | 6320 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6321 | if (!peer) | |
6322 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 6323 | |
dcc68b5e MS |
6324 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
6325 | BGP_ADDPATH_BEST_PER_AS); | |
6326 | ||
6327 | return CMD_SUCCESS; | |
06370dac DW |
6328 | } |
6329 | ||
d62a17ae | 6330 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
6331 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6332 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6333 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6334 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 6335 | |
06370dac DW |
6336 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
6337 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6338 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6339 | NO_STR |
6340 | NEIGHBOR_STR | |
6341 | NEIGHBOR_ADDR_STR2 | |
6342 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6343 | { | |
d62a17ae | 6344 | int idx_peer = 2; |
dcc68b5e MS |
6345 | struct peer *peer; |
6346 | ||
6347 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6348 | if (!peer) | |
6349 | return CMD_WARNING_CONFIG_FAILED; | |
6350 | ||
6351 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
6352 | != BGP_ADDPATH_BEST_PER_AS) { | |
6353 | vty_out(vty, | |
6354 | "%% Peer not currently configured to transmit all best path per as."); | |
6355 | return CMD_WARNING_CONFIG_FAILED; | |
6356 | } | |
6357 | ||
6358 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6359 | BGP_ADDPATH_NONE); | |
6360 | ||
6361 | return CMD_SUCCESS; | |
06370dac DW |
6362 | } |
6363 | ||
d62a17ae | 6364 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
6365 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6366 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6367 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6368 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 6369 | |
b9c7bc5a PZ |
6370 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
6371 | struct ecommunity **list) | |
ddb5b488 | 6372 | { |
b9c7bc5a PZ |
6373 | struct ecommunity *ecom = NULL; |
6374 | struct ecommunity *ecomadd; | |
ddb5b488 | 6375 | |
b9c7bc5a | 6376 | for (; argc; --argc, ++argv) { |
ddb5b488 | 6377 | |
b9c7bc5a PZ |
6378 | ecomadd = ecommunity_str2com(argv[0]->arg, |
6379 | ECOMMUNITY_ROUTE_TARGET, 0); | |
6380 | if (!ecomadd) { | |
6381 | vty_out(vty, "Malformed community-list value\n"); | |
6382 | if (ecom) | |
6383 | ecommunity_free(&ecom); | |
6384 | return CMD_WARNING_CONFIG_FAILED; | |
6385 | } | |
ddb5b488 | 6386 | |
b9c7bc5a PZ |
6387 | if (ecom) { |
6388 | ecommunity_merge(ecom, ecomadd); | |
6389 | ecommunity_free(&ecomadd); | |
6390 | } else { | |
6391 | ecom = ecomadd; | |
6392 | } | |
6393 | } | |
6394 | ||
6395 | if (*list) { | |
6396 | ecommunity_free(&*list); | |
ddb5b488 | 6397 | } |
b9c7bc5a PZ |
6398 | *list = ecom; |
6399 | ||
6400 | return CMD_SUCCESS; | |
ddb5b488 PZ |
6401 | } |
6402 | ||
0ca70ba5 DS |
6403 | /* |
6404 | * v2vimport is true if we are handling a `import vrf ...` command | |
6405 | */ | |
6406 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 6407 | { |
0ca70ba5 DS |
6408 | afi_t afi; |
6409 | ||
ddb5b488 | 6410 | switch (vty->node) { |
b9c7bc5a | 6411 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
6412 | afi = AFI_IP; |
6413 | break; | |
b9c7bc5a | 6414 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
6415 | afi = AFI_IP6; |
6416 | break; | |
ddb5b488 PZ |
6417 | default: |
6418 | vty_out(vty, | |
b9c7bc5a | 6419 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 6420 | return AFI_MAX; |
ddb5b488 | 6421 | } |
69b07479 | 6422 | |
0ca70ba5 DS |
6423 | if (!v2vimport) { |
6424 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6425 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
6426 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6427 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
6428 | vty_out(vty, | |
6429 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
6430 | return AFI_MAX; | |
6431 | } | |
6432 | } else { | |
6433 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6434 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
6435 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6436 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
6437 | vty_out(vty, | |
6438 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
6439 | return AFI_MAX; | |
6440 | } | |
6441 | } | |
6442 | return afi; | |
ddb5b488 PZ |
6443 | } |
6444 | ||
b9c7bc5a PZ |
6445 | DEFPY (af_rd_vpn_export, |
6446 | af_rd_vpn_export_cmd, | |
6447 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
6448 | NO_STR | |
ddb5b488 | 6449 | "Specify route distinguisher\n" |
b9c7bc5a PZ |
6450 | "Between current address-family and vpn\n" |
6451 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6452 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") |
6453 | { | |
6454 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6455 | struct prefix_rd prd; | |
6456 | int ret; | |
ddb5b488 | 6457 | afi_t afi; |
b9c7bc5a PZ |
6458 | int idx = 0; |
6459 | int yes = 1; | |
ddb5b488 | 6460 | |
b9c7bc5a | 6461 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6462 | yes = 0; |
b9c7bc5a PZ |
6463 | |
6464 | if (yes) { | |
6465 | ret = str2prefix_rd(rd_str, &prd); | |
6466 | if (!ret) { | |
6467 | vty_out(vty, "%% Malformed rd\n"); | |
6468 | return CMD_WARNING_CONFIG_FAILED; | |
6469 | } | |
ddb5b488 PZ |
6470 | } |
6471 | ||
0ca70ba5 | 6472 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6473 | if (afi == AFI_MAX) |
6474 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6475 | |
69b07479 DS |
6476 | /* |
6477 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6478 | */ | |
6479 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6480 | bgp_get_default(), bgp); | |
ddb5b488 | 6481 | |
69b07479 DS |
6482 | if (yes) { |
6483 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
6484 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6485 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
6486 | } else { | |
6487 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
6488 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
ddb5b488 PZ |
6489 | } |
6490 | ||
69b07479 DS |
6491 | /* post-change: re-export vpn routes */ |
6492 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6493 | bgp_get_default(), bgp); | |
6494 | ||
ddb5b488 PZ |
6495 | return CMD_SUCCESS; |
6496 | } | |
6497 | ||
b9c7bc5a PZ |
6498 | ALIAS (af_rd_vpn_export, |
6499 | af_no_rd_vpn_export_cmd, | |
6500 | "no rd vpn export", | |
ddb5b488 | 6501 | NO_STR |
b9c7bc5a PZ |
6502 | "Specify route distinguisher\n" |
6503 | "Between current address-family and vpn\n" | |
6504 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6505 | |
b9c7bc5a PZ |
6506 | DEFPY (af_label_vpn_export, |
6507 | af_label_vpn_export_cmd, | |
e70e9f8e | 6508 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 6509 | NO_STR |
ddb5b488 | 6510 | "label value for VRF\n" |
b9c7bc5a PZ |
6511 | "Between current address-family and vpn\n" |
6512 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
6513 | "Label Value <0-1048575>\n" |
6514 | "Automatically assign a label\n") | |
ddb5b488 PZ |
6515 | { |
6516 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 6517 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 6518 | afi_t afi; |
b9c7bc5a PZ |
6519 | int idx = 0; |
6520 | int yes = 1; | |
6521 | ||
6522 | if (argv_find(argv, argc, "no", &idx)) | |
d555f3e9 | 6523 | yes = 0; |
ddb5b488 | 6524 | |
21a16cc2 PZ |
6525 | /* If "no ...", squash trailing parameter */ |
6526 | if (!yes) | |
6527 | label_auto = NULL; | |
6528 | ||
e70e9f8e PZ |
6529 | if (yes) { |
6530 | if (!label_auto) | |
6531 | label = label_val; /* parser should force unsigned */ | |
6532 | } | |
ddb5b488 | 6533 | |
0ca70ba5 | 6534 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6535 | if (afi == AFI_MAX) |
6536 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 6537 | |
e70e9f8e | 6538 | |
69b07479 DS |
6539 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
6540 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
6541 | /* no change */ | |
6542 | return CMD_SUCCESS; | |
e70e9f8e | 6543 | |
69b07479 DS |
6544 | /* |
6545 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6546 | */ | |
6547 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6548 | bgp_get_default(), bgp); | |
6549 | ||
6550 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
6551 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
6552 | ||
6553 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
6554 | ||
6555 | /* | |
6556 | * label has previously been automatically | |
6557 | * assigned by labelpool: release it | |
6558 | * | |
6559 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
6560 | * means the automatic assignment is in flight | |
6561 | * and therefore the labelpool callback must | |
6562 | * detect that the auto label is not needed. | |
6563 | */ | |
6564 | ||
6565 | bgp_lp_release(LP_TYPE_VRF, | |
6566 | &bgp->vpn_policy[afi], | |
6567 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 6568 | } |
69b07479 DS |
6569 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
6570 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
6571 | } | |
ddb5b488 | 6572 | |
69b07479 DS |
6573 | bgp->vpn_policy[afi].tovpn_label = label; |
6574 | if (label_auto) { | |
6575 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6576 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
6577 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
6578 | vpn_leak_label_callback); | |
ddb5b488 PZ |
6579 | } |
6580 | ||
69b07479 DS |
6581 | /* post-change: re-export vpn routes */ |
6582 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6583 | bgp_get_default(), bgp); | |
6584 | ||
ddb5b488 PZ |
6585 | return CMD_SUCCESS; |
6586 | } | |
6587 | ||
b9c7bc5a PZ |
6588 | ALIAS (af_label_vpn_export, |
6589 | af_no_label_vpn_export_cmd, | |
6590 | "no label vpn export", | |
6591 | NO_STR | |
6592 | "label value for VRF\n" | |
6593 | "Between current address-family and vpn\n" | |
6594 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6595 | |
b9c7bc5a PZ |
6596 | DEFPY (af_nexthop_vpn_export, |
6597 | af_nexthop_vpn_export_cmd, | |
6598 | "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str", | |
6599 | NO_STR | |
ddb5b488 | 6600 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
6601 | "Between current address-family and vpn\n" |
6602 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6603 | "IPv4 prefix\n" |
6604 | "IPv6 prefix\n") | |
6605 | { | |
6606 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
ddb5b488 | 6607 | afi_t afi; |
ddb5b488 | 6608 | struct prefix p; |
b9c7bc5a PZ |
6609 | int idx = 0; |
6610 | int yes = 1; | |
ddb5b488 | 6611 | |
b9c7bc5a | 6612 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6613 | yes = 0; |
b9c7bc5a PZ |
6614 | |
6615 | if (yes) { | |
6616 | if (!sockunion2hostprefix(nexthop_str, &p)) | |
6617 | return CMD_WARNING_CONFIG_FAILED; | |
6618 | } | |
ddb5b488 | 6619 | |
0ca70ba5 | 6620 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6621 | if (afi == AFI_MAX) |
6622 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6623 | |
69b07479 DS |
6624 | /* |
6625 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6626 | */ | |
6627 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6628 | bgp_get_default(), bgp); | |
ddb5b488 | 6629 | |
69b07479 DS |
6630 | if (yes) { |
6631 | bgp->vpn_policy[afi].tovpn_nexthop = p; | |
6632 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6633 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
6634 | } else { | |
6635 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
6636 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
ddb5b488 PZ |
6637 | } |
6638 | ||
69b07479 DS |
6639 | /* post-change: re-export vpn routes */ |
6640 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6641 | bgp_get_default(), bgp); | |
6642 | ||
ddb5b488 PZ |
6643 | return CMD_SUCCESS; |
6644 | } | |
6645 | ||
b9c7bc5a PZ |
6646 | ALIAS (af_nexthop_vpn_export, |
6647 | af_no_nexthop_vpn_export_cmd, | |
6648 | "no nexthop vpn export", | |
ddb5b488 | 6649 | NO_STR |
b9c7bc5a PZ |
6650 | "Specify next hop to use for VRF advertised prefixes\n" |
6651 | "Between current address-family and vpn\n" | |
6652 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6653 | |
b9c7bc5a | 6654 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 6655 | { |
b9c7bc5a PZ |
6656 | if (!strcmp(dstr, "import")) { |
6657 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
6658 | } else if (!strcmp(dstr, "export")) { | |
6659 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
6660 | } else if (!strcmp(dstr, "both")) { | |
6661 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
6662 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
6663 | } else { | |
6664 | vty_out(vty, "%% direction parse error\n"); | |
6665 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6666 | } |
ddb5b488 PZ |
6667 | return CMD_SUCCESS; |
6668 | } | |
6669 | ||
b9c7bc5a PZ |
6670 | DEFPY (af_rt_vpn_imexport, |
6671 | af_rt_vpn_imexport_cmd, | |
6672 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
6673 | NO_STR | |
6674 | "Specify route target list\n" | |
ddb5b488 | 6675 | "Specify route target list\n" |
b9c7bc5a PZ |
6676 | "Between current address-family and vpn\n" |
6677 | "For routes leaked from vpn to current address-family: match any\n" | |
6678 | "For routes leaked from current address-family to vpn: set\n" | |
6679 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
6680 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
6681 | { | |
6682 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6683 | int ret; | |
6684 | struct ecommunity *ecom = NULL; | |
6685 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
6686 | vpn_policy_direction_t dir; |
6687 | afi_t afi; | |
6688 | int idx = 0; | |
b9c7bc5a | 6689 | int yes = 1; |
ddb5b488 | 6690 | |
b9c7bc5a | 6691 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6692 | yes = 0; |
b9c7bc5a | 6693 | |
0ca70ba5 | 6694 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6695 | if (afi == AFI_MAX) |
6696 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6697 | |
b9c7bc5a | 6698 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
6699 | if (ret != CMD_SUCCESS) |
6700 | return ret; | |
6701 | ||
b9c7bc5a PZ |
6702 | if (yes) { |
6703 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
6704 | vty_out(vty, "%% Missing RTLIST\n"); | |
6705 | return CMD_WARNING_CONFIG_FAILED; | |
6706 | } | |
6707 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
6708 | if (ret != CMD_SUCCESS) { | |
6709 | return ret; | |
6710 | } | |
ddb5b488 PZ |
6711 | } |
6712 | ||
69b07479 DS |
6713 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
6714 | if (!dodir[dir]) | |
ddb5b488 | 6715 | continue; |
ddb5b488 | 6716 | |
69b07479 | 6717 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 6718 | |
69b07479 DS |
6719 | if (yes) { |
6720 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
6721 | ecommunity_free( | |
6722 | &bgp->vpn_policy[afi].rtlist[dir]); | |
6723 | bgp->vpn_policy[afi].rtlist[dir] = | |
6724 | ecommunity_dup(ecom); | |
6725 | } else { | |
6726 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
6727 | ecommunity_free( | |
6728 | &bgp->vpn_policy[afi].rtlist[dir]); | |
6729 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 6730 | } |
69b07479 DS |
6731 | |
6732 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 6733 | } |
69b07479 | 6734 | |
d555f3e9 PZ |
6735 | if (ecom) |
6736 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
6737 | |
6738 | return CMD_SUCCESS; | |
6739 | } | |
6740 | ||
b9c7bc5a PZ |
6741 | ALIAS (af_rt_vpn_imexport, |
6742 | af_no_rt_vpn_imexport_cmd, | |
6743 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
6744 | NO_STR |
6745 | "Specify route target list\n" | |
b9c7bc5a PZ |
6746 | "Specify route target list\n" |
6747 | "Between current address-family and vpn\n" | |
6748 | "For routes leaked from vpn to current address-family\n" | |
6749 | "For routes leaked from current address-family to vpn\n" | |
6750 | "both import and export\n") | |
6751 | ||
6752 | DEFPY (af_route_map_vpn_imexport, | |
6753 | af_route_map_vpn_imexport_cmd, | |
6754 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
6755 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
6756 | NO_STR | |
ddb5b488 | 6757 | "Specify route map\n" |
b9c7bc5a PZ |
6758 | "Between current address-family and vpn\n" |
6759 | "For routes leaked from vpn to current address-family\n" | |
6760 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6761 | "name of route-map\n") |
6762 | { | |
6763 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6764 | int ret; | |
6765 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
6766 | vpn_policy_direction_t dir; |
6767 | afi_t afi; | |
ddb5b488 | 6768 | int idx = 0; |
b9c7bc5a | 6769 | int yes = 1; |
ddb5b488 | 6770 | |
b9c7bc5a | 6771 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6772 | yes = 0; |
b9c7bc5a | 6773 | |
0ca70ba5 | 6774 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6775 | if (afi == AFI_MAX) |
6776 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6777 | |
b9c7bc5a | 6778 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
6779 | if (ret != CMD_SUCCESS) |
6780 | return ret; | |
6781 | ||
69b07479 DS |
6782 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
6783 | if (!dodir[dir]) | |
ddb5b488 | 6784 | continue; |
ddb5b488 | 6785 | |
69b07479 | 6786 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 6787 | |
69b07479 DS |
6788 | if (yes) { |
6789 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6790 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6791 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6792 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
6793 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
6794 | bgp->vpn_policy[afi].rmap[dir] = | |
1de27621 | 6795 | route_map_lookup_warn_noexist(vty, rmap_str); |
69b07479 DS |
6796 | if (!bgp->vpn_policy[afi].rmap[dir]) |
6797 | return CMD_SUCCESS; | |
6798 | } else { | |
6799 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6800 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6801 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6802 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
6803 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
ddb5b488 | 6804 | } |
69b07479 DS |
6805 | |
6806 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 PZ |
6807 | } |
6808 | ||
6809 | return CMD_SUCCESS; | |
6810 | } | |
6811 | ||
b9c7bc5a PZ |
6812 | ALIAS (af_route_map_vpn_imexport, |
6813 | af_no_route_map_vpn_imexport_cmd, | |
6814 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
6815 | NO_STR |
6816 | "Specify route map\n" | |
b9c7bc5a PZ |
6817 | "Between current address-family and vpn\n" |
6818 | "For routes leaked from vpn to current address-family\n" | |
6819 | "For routes leaked from current address-family to vpn\n") | |
6820 | ||
bb4f6190 DS |
6821 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
6822 | "[no] import vrf route-map RMAP$rmap_str", | |
6823 | NO_STR | |
6824 | "Import routes from another VRF\n" | |
6825 | "Vrf routes being filtered\n" | |
6826 | "Specify route map\n" | |
6827 | "name of route-map\n") | |
6828 | { | |
6829 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
bb4f6190 DS |
6830 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; |
6831 | afi_t afi; | |
6832 | int idx = 0; | |
6833 | int yes = 1; | |
6834 | struct bgp *bgp_default; | |
6835 | ||
6836 | if (argv_find(argv, argc, "no", &idx)) | |
6837 | yes = 0; | |
6838 | ||
0ca70ba5 | 6839 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
6840 | if (afi == AFI_MAX) |
6841 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
6842 | |
6843 | bgp_default = bgp_get_default(); | |
6844 | if (!bgp_default) { | |
6845 | int32_t ret; | |
6846 | as_t as = bgp->as; | |
6847 | ||
6848 | /* Auto-create assuming the same AS */ | |
6849 | ret = bgp_get(&bgp_default, &as, NULL, | |
6850 | BGP_INSTANCE_TYPE_DEFAULT); | |
6851 | ||
6852 | if (ret) { | |
6853 | vty_out(vty, | |
6854 | "VRF default is not configured as a bgp instance\n"); | |
6855 | return CMD_WARNING; | |
6856 | } | |
6857 | } | |
6858 | ||
69b07479 | 6859 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 6860 | |
69b07479 DS |
6861 | if (yes) { |
6862 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6863 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6864 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6865 | bgp->vpn_policy[afi].rmap_name[dir] = | |
6866 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
6867 | bgp->vpn_policy[afi].rmap[dir] = | |
1de27621 | 6868 | route_map_lookup_warn_noexist(vty, rmap_str); |
69b07479 DS |
6869 | if (!bgp->vpn_policy[afi].rmap[dir]) |
6870 | return CMD_SUCCESS; | |
6871 | } else { | |
6872 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6873 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6874 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6875 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
6876 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
bb4f6190 DS |
6877 | } |
6878 | ||
69b07479 DS |
6879 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
6880 | ||
bb4f6190 DS |
6881 | return CMD_SUCCESS; |
6882 | } | |
6883 | ||
6884 | ALIAS(af_import_vrf_route_map, af_no_import_vrf_route_map_cmd, | |
6885 | "no import vrf route-map", | |
6886 | NO_STR | |
6887 | "Import routes from another VRF\n" | |
6888 | "Vrf routes being filtered\n" | |
6889 | "Specify route map\n") | |
6890 | ||
4d1b335c DA |
6891 | DEFPY(bgp_imexport_vrf, bgp_imexport_vrf_cmd, |
6892 | "[no] import vrf VIEWVRFNAME$import_name", | |
6893 | NO_STR | |
6894 | "Import routes from another VRF\n" | |
6895 | "VRF to import from\n" | |
6896 | "The name of the VRF\n") | |
12a844a5 DS |
6897 | { |
6898 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6899 | struct listnode *node; | |
79ef8664 DS |
6900 | struct bgp *vrf_bgp, *bgp_default; |
6901 | int32_t ret = 0; | |
6902 | as_t as = bgp->as; | |
12a844a5 DS |
6903 | bool remove = false; |
6904 | int32_t idx = 0; | |
6905 | char *vname; | |
a8dadcf6 | 6906 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; |
12a844a5 DS |
6907 | safi_t safi; |
6908 | afi_t afi; | |
6909 | ||
867f0cca | 6910 | if (import_name == NULL) { |
6911 | vty_out(vty, "%% Missing import name\n"); | |
6912 | return CMD_WARNING; | |
6913 | } | |
6914 | ||
12a844a5 DS |
6915 | if (argv_find(argv, argc, "no", &idx)) |
6916 | remove = true; | |
6917 | ||
0ca70ba5 DS |
6918 | afi = vpn_policy_getafi(vty, bgp, true); |
6919 | if (afi == AFI_MAX) | |
6920 | return CMD_WARNING_CONFIG_FAILED; | |
6921 | ||
12a844a5 DS |
6922 | safi = bgp_node_safi(vty); |
6923 | ||
25679caa | 6924 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) |
5742e42b | 6925 | && (strcmp(import_name, VRF_DEFAULT_NAME) == 0)) |
25679caa DS |
6926 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { |
6927 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
6928 | remove ? "unimport" : "import", import_name); | |
6929 | return CMD_WARNING; | |
6930 | } | |
6931 | ||
79ef8664 DS |
6932 | bgp_default = bgp_get_default(); |
6933 | if (!bgp_default) { | |
6934 | /* Auto-create assuming the same AS */ | |
6935 | ret = bgp_get(&bgp_default, &as, NULL, | |
6936 | BGP_INSTANCE_TYPE_DEFAULT); | |
6937 | ||
6938 | if (ret) { | |
6939 | vty_out(vty, | |
6940 | "VRF default is not configured as a bgp instance\n"); | |
6941 | return CMD_WARNING; | |
6942 | } | |
6943 | } | |
6944 | ||
12a844a5 DS |
6945 | vrf_bgp = bgp_lookup_by_name(import_name); |
6946 | if (!vrf_bgp) { | |
5742e42b | 6947 | if (strcmp(import_name, VRF_DEFAULT_NAME) == 0) |
79ef8664 DS |
6948 | vrf_bgp = bgp_default; |
6949 | else | |
0fb8d6e6 DS |
6950 | /* Auto-create assuming the same AS */ |
6951 | ret = bgp_get(&vrf_bgp, &as, import_name, bgp_type); | |
a8dadcf6 | 6952 | |
6e2c7fe6 | 6953 | if (ret) { |
020a3f60 DS |
6954 | vty_out(vty, |
6955 | "VRF %s is not configured as a bgp instance\n", | |
6e2c7fe6 DS |
6956 | import_name); |
6957 | return CMD_WARNING; | |
6958 | } | |
12a844a5 DS |
6959 | } |
6960 | ||
12a844a5 | 6961 | if (remove) { |
44338987 | 6962 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 | 6963 | } else { |
44338987 | 6964 | /* Already importing from "import_vrf"? */ |
12a844a5 DS |
6965 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, |
6966 | vname)) { | |
6967 | if (strcmp(vname, import_name) == 0) | |
6968 | return CMD_WARNING; | |
6969 | } | |
6970 | ||
44338987 | 6971 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 DS |
6972 | } |
6973 | ||
6974 | return CMD_SUCCESS; | |
6975 | } | |
6976 | ||
b9c7bc5a PZ |
6977 | /* This command is valid only in a bgp vrf instance or the default instance */ |
6978 | DEFPY (bgp_imexport_vpn, | |
6979 | bgp_imexport_vpn_cmd, | |
6980 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
6981 | NO_STR |
6982 | "Import routes to this address-family\n" | |
6983 | "Export routes from this address-family\n" | |
6984 | "to/from default instance VPN RIB\n") | |
ddb5b488 PZ |
6985 | { |
6986 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 6987 | int previous_state; |
ddb5b488 | 6988 | afi_t afi; |
b9c7bc5a | 6989 | safi_t safi; |
ddb5b488 | 6990 | int idx = 0; |
b9c7bc5a PZ |
6991 | int yes = 1; |
6992 | int flag; | |
6993 | vpn_policy_direction_t dir; | |
ddb5b488 | 6994 | |
b9c7bc5a | 6995 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6996 | yes = 0; |
ddb5b488 | 6997 | |
b9c7bc5a PZ |
6998 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && |
6999 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
ddb5b488 | 7000 | |
b9c7bc5a PZ |
7001 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); |
7002 | return CMD_WARNING_CONFIG_FAILED; | |
7003 | } | |
ddb5b488 | 7004 | |
b9c7bc5a PZ |
7005 | afi = bgp_node_afi(vty); |
7006 | safi = bgp_node_safi(vty); | |
7007 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { | |
7008 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
7009 | return CMD_WARNING_CONFIG_FAILED; | |
7010 | } | |
ddb5b488 | 7011 | |
b9c7bc5a PZ |
7012 | if (!strcmp(direction_str, "import")) { |
7013 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; | |
7014 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
7015 | } else if (!strcmp(direction_str, "export")) { | |
7016 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; | |
7017 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
7018 | } else { | |
7019 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
7020 | return CMD_WARNING_CONFIG_FAILED; | |
7021 | } | |
7022 | ||
7023 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 | 7024 | |
b9c7bc5a PZ |
7025 | if (yes) { |
7026 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
7027 | if (!previous_state) { | |
7028 | /* trigger export current vrf */ | |
ddb5b488 PZ |
7029 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
7030 | } | |
b9c7bc5a PZ |
7031 | } else { |
7032 | if (previous_state) { | |
7033 | /* trigger un-export current vrf */ | |
7034 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
7035 | } | |
7036 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 PZ |
7037 | } |
7038 | ||
7039 | return CMD_SUCCESS; | |
7040 | } | |
7041 | ||
301ad80a PG |
7042 | DEFPY (af_routetarget_import, |
7043 | af_routetarget_import_cmd, | |
7044 | "[no] <rt|route-target> redirect import RTLIST...", | |
7045 | NO_STR | |
7046 | "Specify route target list\n" | |
7047 | "Specify route target list\n" | |
7048 | "Flow-spec redirect type route target\n" | |
7049 | "Import routes to this address-family\n" | |
7050 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") | |
7051 | { | |
7052 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7053 | int ret; | |
7054 | struct ecommunity *ecom = NULL; | |
301ad80a PG |
7055 | afi_t afi; |
7056 | int idx = 0; | |
7057 | int yes = 1; | |
7058 | ||
7059 | if (argv_find(argv, argc, "no", &idx)) | |
7060 | yes = 0; | |
7061 | ||
0ca70ba5 | 7062 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7063 | if (afi == AFI_MAX) |
7064 | return CMD_WARNING_CONFIG_FAILED; | |
7065 | ||
301ad80a PG |
7066 | if (yes) { |
7067 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
7068 | vty_out(vty, "%% Missing RTLIST\n"); | |
7069 | return CMD_WARNING_CONFIG_FAILED; | |
7070 | } | |
7071 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
7072 | if (ret != CMD_SUCCESS) | |
7073 | return ret; | |
7074 | } | |
69b07479 DS |
7075 | |
7076 | if (yes) { | |
7077 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
7078 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 7079 | .import_redirect_rtlist); |
69b07479 DS |
7080 | bgp->vpn_policy[afi].import_redirect_rtlist = |
7081 | ecommunity_dup(ecom); | |
7082 | } else { | |
7083 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
7084 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 7085 | .import_redirect_rtlist); |
69b07479 | 7086 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 7087 | } |
69b07479 | 7088 | |
301ad80a PG |
7089 | if (ecom) |
7090 | ecommunity_free(&ecom); | |
7091 | ||
7092 | return CMD_SUCCESS; | |
7093 | } | |
7094 | ||
505e5056 | 7095 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 7096 | address_family_ipv4_safi_cmd, |
7097 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
7098 | "Enter Address Family command mode\n" | |
7099 | "Address Family\n" | |
7100 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
718e3744 | 7101 | { |
f51bae9c | 7102 | |
d62a17ae | 7103 | if (argc == 3) { |
2131d5cf | 7104 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7105 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
7106 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
7107 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 7108 | && safi != SAFI_EVPN) { |
31947174 MK |
7109 | vty_out(vty, |
7110 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
7111 | return CMD_WARNING_CONFIG_FAILED; |
7112 | } | |
d62a17ae | 7113 | vty->node = bgp_node_type(AFI_IP, safi); |
7114 | } else | |
7115 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 7116 | |
d62a17ae | 7117 | return CMD_SUCCESS; |
718e3744 | 7118 | } |
7119 | ||
505e5056 | 7120 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 7121 | address_family_ipv6_safi_cmd, |
7122 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
7123 | "Enter Address Family command mode\n" | |
7124 | "Address Family\n" | |
7125 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
25ffbdc1 | 7126 | { |
d62a17ae | 7127 | if (argc == 3) { |
2131d5cf | 7128 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7129 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
7130 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
7131 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 7132 | && safi != SAFI_EVPN) { |
31947174 MK |
7133 | vty_out(vty, |
7134 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
7135 | return CMD_WARNING_CONFIG_FAILED; |
7136 | } | |
d62a17ae | 7137 | vty->node = bgp_node_type(AFI_IP6, safi); |
7138 | } else | |
7139 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 7140 | |
d62a17ae | 7141 | return CMD_SUCCESS; |
25ffbdc1 | 7142 | } |
718e3744 | 7143 | |
d6902373 | 7144 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 7145 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 7146 | address_family_vpnv4_cmd, |
8334fd5a | 7147 | "address-family vpnv4 [unicast]", |
718e3744 | 7148 | "Enter Address Family command mode\n" |
8c3deaae | 7149 | "Address Family\n" |
3a2d747c | 7150 | "Address Family modifier\n") |
718e3744 | 7151 | { |
d62a17ae | 7152 | vty->node = BGP_VPNV4_NODE; |
7153 | return CMD_SUCCESS; | |
718e3744 | 7154 | } |
7155 | ||
505e5056 | 7156 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 7157 | address_family_vpnv6_cmd, |
8334fd5a | 7158 | "address-family vpnv6 [unicast]", |
8ecd3266 | 7159 | "Enter Address Family command mode\n" |
8c3deaae | 7160 | "Address Family\n" |
3a2d747c | 7161 | "Address Family modifier\n") |
8ecd3266 | 7162 | { |
d62a17ae | 7163 | vty->node = BGP_VPNV6_NODE; |
7164 | return CMD_SUCCESS; | |
8ecd3266 | 7165 | } |
64e4a6c5 | 7166 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
d6902373 | 7167 | |
505e5056 | 7168 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 7169 | address_family_evpn_cmd, |
7111c1a0 | 7170 | "address-family l2vpn evpn", |
4e0b7b6d | 7171 | "Enter Address Family command mode\n" |
7111c1a0 QY |
7172 | "Address Family\n" |
7173 | "Address Family modifier\n") | |
4e0b7b6d | 7174 | { |
2131d5cf | 7175 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7176 | vty->node = BGP_EVPN_NODE; |
7177 | return CMD_SUCCESS; | |
4e0b7b6d PG |
7178 | } |
7179 | ||
505e5056 | 7180 | DEFUN_NOSH (exit_address_family, |
718e3744 | 7181 | exit_address_family_cmd, |
7182 | "exit-address-family", | |
7183 | "Exit from Address Family configuration mode\n") | |
7184 | { | |
d62a17ae | 7185 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
7186 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
7187 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
7188 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
7189 | || vty->node == BGP_EVPN_NODE |
7190 | || vty->node == BGP_FLOWSPECV4_NODE | |
7191 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 7192 | vty->node = BGP_NODE; |
7193 | return CMD_SUCCESS; | |
718e3744 | 7194 | } |
6b0655a2 | 7195 | |
8ad7271d | 7196 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 7197 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
7198 | const char *ip_str, afi_t afi, safi_t safi, | |
7199 | struct prefix_rd *prd) | |
7200 | { | |
7201 | int ret; | |
7202 | struct prefix match; | |
7203 | struct bgp_node *rn; | |
7204 | struct bgp_node *rm; | |
7205 | struct bgp *bgp; | |
7206 | struct bgp_table *table; | |
7207 | struct bgp_table *rib; | |
7208 | ||
7209 | /* BGP structure lookup. */ | |
7210 | if (view_name) { | |
7211 | bgp = bgp_lookup_by_name(view_name); | |
7212 | if (bgp == NULL) { | |
7213 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
7214 | view_name); | |
7215 | return CMD_WARNING; | |
7216 | } | |
7217 | } else { | |
7218 | bgp = bgp_get_default(); | |
7219 | if (bgp == NULL) { | |
7220 | vty_out(vty, "%% No BGP process is configured\n"); | |
7221 | return CMD_WARNING; | |
7222 | } | |
7223 | } | |
7224 | ||
7225 | /* Check IP address argument. */ | |
7226 | ret = str2prefix(ip_str, &match); | |
7227 | if (!ret) { | |
7228 | vty_out(vty, "%% address is malformed\n"); | |
7229 | return CMD_WARNING; | |
7230 | } | |
7231 | ||
7232 | match.family = afi2family(afi); | |
7233 | rib = bgp->rib[afi][safi]; | |
7234 | ||
7235 | if (safi == SAFI_MPLS_VPN) { | |
7236 | for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) { | |
7237 | if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0) | |
7238 | continue; | |
7239 | ||
67009e22 DS |
7240 | table = bgp_node_get_bgp_table_info(rn); |
7241 | if (table != NULL) { | |
7242 | ||
d62a17ae | 7243 | if ((rm = bgp_node_match(table, &match)) |
7244 | != NULL) { | |
7245 | if (rm->p.prefixlen | |
7246 | == match.prefixlen) { | |
343cdb61 | 7247 | SET_FLAG(rm->flags, |
d62a17ae | 7248 | BGP_NODE_USER_CLEAR); |
7249 | bgp_process(bgp, rm, afi, safi); | |
7250 | } | |
7251 | bgp_unlock_node(rm); | |
7252 | } | |
7253 | } | |
7254 | } | |
7255 | } else { | |
7256 | if ((rn = bgp_node_match(rib, &match)) != NULL) { | |
7257 | if (rn->p.prefixlen == match.prefixlen) { | |
7258 | SET_FLAG(rn->flags, BGP_NODE_USER_CLEAR); | |
7259 | bgp_process(bgp, rn, afi, safi); | |
7260 | } | |
7261 | bgp_unlock_node(rn); | |
7262 | } | |
7263 | } | |
7264 | ||
7265 | return CMD_SUCCESS; | |
8ad7271d DS |
7266 | } |
7267 | ||
b09b5ae0 | 7268 | /* one clear bgp command to rule them all */ |
718e3744 | 7269 | DEFUN (clear_ip_bgp_all, |
7270 | clear_ip_bgp_all_cmd, | |
fd5e7b70 | 7271 | "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 | 7272 | CLEAR_STR |
7273 | IP_STR | |
7274 | BGP_STR | |
838758ac | 7275 | BGP_INSTANCE_HELP_STR |
510afcd6 | 7276 | BGP_AFI_HELP_STR |
fd5e7b70 | 7277 | "Address Family\n" |
510afcd6 | 7278 | BGP_SAFI_WITH_LABEL_HELP_STR |
fd5e7b70 | 7279 | "Address Family modifier\n" |
b09b5ae0 DW |
7280 | "Clear all peers\n" |
7281 | "BGP neighbor address to clear\n" | |
a80beece | 7282 | "BGP IPv6 neighbor to clear\n" |
838758ac | 7283 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
7284 | "Clear peers with the AS number\n" |
7285 | "Clear all external peers\n" | |
718e3744 | 7286 | "Clear all members of peer-group\n" |
b09b5ae0 | 7287 | "BGP peer-group name\n" |
b09b5ae0 DW |
7288 | BGP_SOFT_STR |
7289 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
7290 | BGP_SOFT_OUT_STR |
7291 | BGP_SOFT_IN_STR | |
7292 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 7293 | BGP_SOFT_OUT_STR) |
718e3744 | 7294 | { |
d62a17ae | 7295 | char *vrf = NULL; |
7296 | ||
7297 | afi_t afi = AFI_IP6; | |
7298 | safi_t safi = SAFI_UNICAST; | |
7299 | enum clear_sort clr_sort = clear_peer; | |
7300 | enum bgp_clear_type clr_type; | |
7301 | char *clr_arg = NULL; | |
7302 | ||
7303 | int idx = 0; | |
7304 | ||
7305 | /* clear [ip] bgp */ | |
7306 | if (argv_find(argv, argc, "ip", &idx)) | |
7307 | afi = AFI_IP; | |
7308 | ||
9a8bdf1c PG |
7309 | /* [<vrf> VIEWVRFNAME] */ |
7310 | if (argv_find(argv, argc, "vrf", &idx)) { | |
7311 | vrf = argv[idx + 1]->arg; | |
7312 | idx += 2; | |
7313 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
7314 | vrf = NULL; | |
7315 | } else if (argv_find(argv, argc, "view", &idx)) { | |
7316 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 7317 | vrf = argv[idx + 1]->arg; |
7318 | idx += 2; | |
7319 | } | |
d62a17ae | 7320 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
7321 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
7322 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
7323 | ||
7324 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */ | |
7325 | if (argv_find(argv, argc, "*", &idx)) { | |
7326 | clr_sort = clear_all; | |
7327 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
7328 | clr_sort = clear_peer; | |
7329 | clr_arg = argv[idx]->arg; | |
7330 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
7331 | clr_sort = clear_peer; | |
7332 | clr_arg = argv[idx]->arg; | |
7333 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
7334 | clr_sort = clear_group; | |
7335 | idx++; | |
7336 | clr_arg = argv[idx]->arg; | |
7337 | } else if (argv_find(argv, argc, "WORD", &idx)) { | |
7338 | clr_sort = clear_peer; | |
7339 | clr_arg = argv[idx]->arg; | |
7340 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { | |
7341 | clr_sort = clear_as; | |
7342 | clr_arg = argv[idx]->arg; | |
7343 | } else if (argv_find(argv, argc, "external", &idx)) { | |
7344 | clr_sort = clear_external; | |
7345 | } | |
7346 | ||
7347 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
7348 | if (argv_find(argv, argc, "soft", &idx)) { | |
7349 | if (argv_find(argv, argc, "in", &idx) | |
7350 | || argv_find(argv, argc, "out", &idx)) | |
7351 | clr_type = strmatch(argv[idx]->text, "in") | |
7352 | ? BGP_CLEAR_SOFT_IN | |
7353 | : BGP_CLEAR_SOFT_OUT; | |
7354 | else | |
7355 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
7356 | } else if (argv_find(argv, argc, "in", &idx)) { | |
7357 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
7358 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
7359 | : BGP_CLEAR_SOFT_IN; | |
7360 | } else if (argv_find(argv, argc, "out", &idx)) { | |
7361 | clr_type = BGP_CLEAR_SOFT_OUT; | |
7362 | } else | |
7363 | clr_type = BGP_CLEAR_SOFT_NONE; | |
7364 | ||
7365 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); | |
838758ac | 7366 | } |
01080f7c | 7367 | |
8ad7271d DS |
7368 | DEFUN (clear_ip_bgp_prefix, |
7369 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 7370 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
7371 | CLEAR_STR |
7372 | IP_STR | |
7373 | BGP_STR | |
838758ac | 7374 | BGP_INSTANCE_HELP_STR |
8ad7271d | 7375 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7376 | "IPv4 prefix\n") |
8ad7271d | 7377 | { |
d62a17ae | 7378 | char *vrf = NULL; |
7379 | char *prefix = NULL; | |
8ad7271d | 7380 | |
d62a17ae | 7381 | int idx = 0; |
01080f7c | 7382 | |
d62a17ae | 7383 | /* [<view|vrf> VIEWVRFNAME] */ |
9a8bdf1c PG |
7384 | if (argv_find(argv, argc, "vrf", &idx)) { |
7385 | vrf = argv[idx + 1]->arg; | |
7386 | idx += 2; | |
7387 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
7388 | vrf = NULL; | |
7389 | } else if (argv_find(argv, argc, "view", &idx)) { | |
7390 | /* [<view> VIEWVRFNAME] */ | |
7391 | vrf = argv[idx + 1]->arg; | |
7392 | idx += 2; | |
7393 | } | |
0c7b1b01 | 7394 | |
d62a17ae | 7395 | prefix = argv[argc - 1]->arg; |
8ad7271d | 7396 | |
d62a17ae | 7397 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 7398 | } |
8ad7271d | 7399 | |
b09b5ae0 DW |
7400 | DEFUN (clear_bgp_ipv6_safi_prefix, |
7401 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 7402 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 7403 | CLEAR_STR |
3a2d747c | 7404 | IP_STR |
718e3744 | 7405 | BGP_STR |
8c3deaae | 7406 | "Address Family\n" |
46f296b4 | 7407 | BGP_SAFI_HELP_STR |
b09b5ae0 | 7408 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7409 | "IPv6 prefix\n") |
718e3744 | 7410 | { |
9b475e76 PG |
7411 | int idx_safi = 0; |
7412 | int idx_ipv6_prefix = 0; | |
7413 | safi_t safi = SAFI_UNICAST; | |
7414 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
7415 | argv[idx_ipv6_prefix]->arg : NULL; | |
7416 | ||
7417 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 7418 | return bgp_clear_prefix( |
9b475e76 PG |
7419 | vty, NULL, prefix, AFI_IP6, |
7420 | safi, NULL); | |
838758ac | 7421 | } |
01080f7c | 7422 | |
b09b5ae0 DW |
7423 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
7424 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 7425 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 7426 | CLEAR_STR |
3a2d747c | 7427 | IP_STR |
718e3744 | 7428 | BGP_STR |
838758ac | 7429 | BGP_INSTANCE_HELP_STR |
8c3deaae | 7430 | "Address Family\n" |
46f296b4 | 7431 | BGP_SAFI_HELP_STR |
b09b5ae0 | 7432 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7433 | "IPv6 prefix\n") |
718e3744 | 7434 | { |
9b475e76 | 7435 | int idx_safi = 0; |
9a8bdf1c | 7436 | int idx_vrfview = 0; |
9b475e76 PG |
7437 | int idx_ipv6_prefix = 0; |
7438 | safi_t safi = SAFI_UNICAST; | |
7439 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
7440 | argv[idx_ipv6_prefix]->arg : NULL; | |
9a8bdf1c | 7441 | char *vrfview = NULL; |
9b475e76 | 7442 | |
9a8bdf1c PG |
7443 | /* [<view|vrf> VIEWVRFNAME] */ |
7444 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
7445 | vrfview = argv[idx_vrfview + 1]->arg; | |
7446 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
7447 | vrfview = NULL; | |
7448 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
7449 | /* [<view> VIEWVRFNAME] */ | |
7450 | vrfview = argv[idx_vrfview + 1]->arg; | |
7451 | } | |
9b475e76 PG |
7452 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); |
7453 | ||
d62a17ae | 7454 | return bgp_clear_prefix( |
9b475e76 PG |
7455 | vty, vrfview, prefix, |
7456 | AFI_IP6, safi, NULL); | |
718e3744 | 7457 | } |
7458 | ||
b09b5ae0 DW |
7459 | DEFUN (show_bgp_views, |
7460 | show_bgp_views_cmd, | |
d6e3c605 | 7461 | "show [ip] bgp views", |
b09b5ae0 | 7462 | SHOW_STR |
d6e3c605 | 7463 | IP_STR |
01080f7c | 7464 | BGP_STR |
b09b5ae0 | 7465 | "Show the defined BGP views\n") |
01080f7c | 7466 | { |
d62a17ae | 7467 | struct list *inst = bm->bgp; |
7468 | struct listnode *node; | |
7469 | struct bgp *bgp; | |
01080f7c | 7470 | |
d62a17ae | 7471 | if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE)) { |
7472 | vty_out(vty, "BGP Multiple Instance is not enabled\n"); | |
7473 | return CMD_WARNING; | |
7474 | } | |
e52702f2 | 7475 | |
d62a17ae | 7476 | vty_out(vty, "Defined BGP views:\n"); |
7477 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
7478 | /* Skip VRFs. */ | |
7479 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
7480 | continue; | |
7481 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
7482 | bgp->as); | |
7483 | } | |
e52702f2 | 7484 | |
d62a17ae | 7485 | return CMD_SUCCESS; |
e0081f70 ML |
7486 | } |
7487 | ||
8386ac43 | 7488 | DEFUN (show_bgp_vrfs, |
7489 | show_bgp_vrfs_cmd, | |
d6e3c605 | 7490 | "show [ip] bgp vrfs [json]", |
8386ac43 | 7491 | SHOW_STR |
d6e3c605 | 7492 | IP_STR |
8386ac43 | 7493 | BGP_STR |
7494 | "Show BGP VRFs\n" | |
9973d184 | 7495 | JSON_STR) |
8386ac43 | 7496 | { |
fe1dc5a3 | 7497 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 7498 | struct list *inst = bm->bgp; |
7499 | struct listnode *node; | |
7500 | struct bgp *bgp; | |
9f049418 | 7501 | bool uj = use_json(argc, argv); |
d62a17ae | 7502 | json_object *json = NULL; |
7503 | json_object *json_vrfs = NULL; | |
7504 | int count = 0; | |
d62a17ae | 7505 | |
7506 | if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE)) { | |
7507 | vty_out(vty, "BGP Multiple Instance is not enabled\n"); | |
7508 | return CMD_WARNING; | |
7509 | } | |
7510 | ||
7511 | if (uj) { | |
7512 | json = json_object_new_object(); | |
7513 | json_vrfs = json_object_new_object(); | |
7514 | } | |
7515 | ||
7516 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
7517 | const char *name, *type; | |
7518 | struct peer *peer; | |
7fe96307 | 7519 | struct listnode *node2, *nnode2; |
d62a17ae | 7520 | int peers_cfg, peers_estb; |
7521 | json_object *json_vrf = NULL; | |
d62a17ae | 7522 | |
7523 | /* Skip Views. */ | |
7524 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
7525 | continue; | |
7526 | ||
7527 | count++; | |
7528 | if (!uj && count == 1) | |
fe1dc5a3 MK |
7529 | vty_out(vty, |
7530 | "%4s %-5s %-16s %9s %10s %-37s %-10s %-15s\n", | |
a4d82a8a PZ |
7531 | "Type", "Id", "routerId", "#PeersVfg", |
7532 | "#PeersEstb", "Name", "L3-VNI", "Rmac"); | |
d62a17ae | 7533 | |
7534 | peers_cfg = peers_estb = 0; | |
7535 | if (uj) | |
7536 | json_vrf = json_object_new_object(); | |
7537 | ||
7538 | ||
7fe96307 | 7539 | for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { |
d62a17ae | 7540 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
7541 | continue; | |
7542 | peers_cfg++; | |
7543 | if (peer->status == Established) | |
7544 | peers_estb++; | |
7545 | } | |
7546 | ||
7547 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
5742e42b | 7548 | name = VRF_DEFAULT_NAME; |
d62a17ae | 7549 | type = "DFLT"; |
7550 | } else { | |
7551 | name = bgp->name; | |
7552 | type = "VRF"; | |
7553 | } | |
7554 | ||
a8bf7d9c | 7555 | |
d62a17ae | 7556 | if (uj) { |
a4d82a8a PZ |
7557 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
7558 | ? -1 | |
7559 | : (int64_t)bgp->vrf_id; | |
d62a17ae | 7560 | json_object_string_add(json_vrf, "type", type); |
7561 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
7562 | json_object_string_add(json_vrf, "routerId", | |
7563 | inet_ntoa(bgp->router_id)); | |
7564 | json_object_int_add(json_vrf, "numConfiguredPeers", | |
7565 | peers_cfg); | |
7566 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
7567 | peers_estb); | |
7568 | ||
fe1dc5a3 | 7569 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
7570 | json_object_string_add( |
7571 | json_vrf, "rmac", | |
7572 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
d62a17ae | 7573 | json_object_object_add(json_vrfs, name, json_vrf); |
7574 | } else | |
fe1dc5a3 MK |
7575 | vty_out(vty, |
7576 | "%4s %-5d %-16s %9u %10u %-37s %-10u %-15s\n", | |
a4d82a8a PZ |
7577 | type, |
7578 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
7579 | : (int)bgp->vrf_id, | |
7580 | inet_ntoa(bgp->router_id), peers_cfg, | |
7581 | peers_estb, name, bgp->l3vni, | |
fe1dc5a3 | 7582 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); |
d62a17ae | 7583 | } |
7584 | ||
7585 | if (uj) { | |
7586 | json_object_object_add(json, "vrfs", json_vrfs); | |
7587 | ||
7588 | json_object_int_add(json, "totalVrfs", count); | |
7589 | ||
996c9314 LB |
7590 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
7591 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 7592 | json_object_free(json); |
7593 | } else { | |
7594 | if (count) | |
7595 | vty_out(vty, | |
7596 | "\nTotal number of VRFs (including default): %d\n", | |
7597 | count); | |
7598 | } | |
7599 | ||
7600 | return CMD_SUCCESS; | |
8386ac43 | 7601 | } |
7602 | ||
48ecf8f5 DS |
7603 | DEFUN (show_bgp_mac_hash, |
7604 | show_bgp_mac_hash_cmd, | |
7605 | "show bgp mac hash", | |
7606 | SHOW_STR | |
7607 | BGP_STR | |
7608 | "Mac Address\n" | |
7609 | "Mac Address database\n") | |
7610 | { | |
7611 | bgp_mac_dump_table(vty); | |
7612 | ||
7613 | return CMD_SUCCESS; | |
7614 | } | |
acf71666 | 7615 | |
e3b78da8 | 7616 | static void show_tip_entry(struct hash_bucket *bucket, void *args) |
acf71666 | 7617 | { |
0291c246 | 7618 | struct vty *vty = (struct vty *)args; |
e3b78da8 | 7619 | struct tip_addr *tip = (struct tip_addr *)bucket->data; |
acf71666 | 7620 | |
60466a63 | 7621 | vty_out(vty, "addr: %s, count: %d\n", inet_ntoa(tip->addr), |
acf71666 MK |
7622 | tip->refcnt); |
7623 | } | |
7624 | ||
7625 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
7626 | { | |
7627 | vty_out(vty, "self nexthop database:\n"); | |
af97a18b | 7628 | bgp_nexthop_show_address_hash(vty, bgp); |
acf71666 MK |
7629 | |
7630 | vty_out(vty, "Tunnel-ip database:\n"); | |
7631 | hash_iterate(bgp->tip_hash, | |
e3b78da8 | 7632 | (void (*)(struct hash_bucket *, void *))show_tip_entry, |
acf71666 MK |
7633 | vty); |
7634 | } | |
7635 | ||
15c81ca4 DS |
7636 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
7637 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
7638 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
7639 | "martian next-hops\n" |
7640 | "martian next-hop database\n") | |
acf71666 | 7641 | { |
0291c246 | 7642 | struct bgp *bgp = NULL; |
15c81ca4 | 7643 | int idx = 0; |
9a8bdf1c PG |
7644 | char *name = NULL; |
7645 | ||
7646 | /* [<vrf> VIEWVRFNAME] */ | |
7647 | if (argv_find(argv, argc, "vrf", &idx)) { | |
7648 | name = argv[idx + 1]->arg; | |
7649 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
7650 | name = NULL; | |
7651 | } else if (argv_find(argv, argc, "view", &idx)) | |
7652 | /* [<view> VIEWVRFNAME] */ | |
7653 | name = argv[idx + 1]->arg; | |
7654 | if (name) | |
7655 | bgp = bgp_lookup_by_name(name); | |
15c81ca4 DS |
7656 | else |
7657 | bgp = bgp_get_default(); | |
acf71666 | 7658 | |
acf71666 MK |
7659 | if (!bgp) { |
7660 | vty_out(vty, "%% No BGP process is configured\n"); | |
7661 | return CMD_WARNING; | |
7662 | } | |
7663 | bgp_show_martian_nexthops(vty, bgp); | |
7664 | ||
7665 | return CMD_SUCCESS; | |
7666 | } | |
7667 | ||
f412b39a | 7668 | DEFUN (show_bgp_memory, |
4bf6a362 | 7669 | show_bgp_memory_cmd, |
7fa12b13 | 7670 | "show [ip] bgp memory", |
4bf6a362 | 7671 | SHOW_STR |
3a2d747c | 7672 | IP_STR |
4bf6a362 PJ |
7673 | BGP_STR |
7674 | "Global BGP memory statistics\n") | |
7675 | { | |
d62a17ae | 7676 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
7677 | unsigned long count; | |
7678 | ||
7679 | /* RIB related usage stats */ | |
7680 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
7681 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
7682 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7683 | count * sizeof(struct bgp_node))); | |
7684 | ||
7685 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
7686 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
7687 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
4b7e6066 | 7688 | count * sizeof(struct bgp_path_info))); |
d62a17ae | 7689 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) |
7690 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
7691 | count, | |
4b7e6066 DS |
7692 | mtype_memstr( |
7693 | memstrbuf, sizeof(memstrbuf), | |
7694 | count * sizeof(struct bgp_path_info_extra))); | |
d62a17ae | 7695 | |
7696 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
7697 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
7698 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7699 | count * sizeof(struct bgp_static))); | |
7700 | ||
7701 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
7702 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
7703 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7704 | count * sizeof(struct bpacket))); | |
7705 | ||
7706 | /* Adj-In/Out */ | |
7707 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
7708 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
7709 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7710 | count * sizeof(struct bgp_adj_in))); | |
7711 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
7712 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
7713 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7714 | count * sizeof(struct bgp_adj_out))); | |
7715 | ||
7716 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
7717 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
7718 | count, | |
7719 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7720 | count * sizeof(struct bgp_nexthop_cache))); | |
7721 | ||
7722 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
7723 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
7724 | count, | |
7725 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7726 | count * sizeof(struct bgp_damp_info))); | |
7727 | ||
7728 | /* Attributes */ | |
7729 | count = attr_count(); | |
7730 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
7731 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7732 | count * sizeof(struct attr))); | |
7733 | ||
7734 | if ((count = attr_unknown_count())) | |
7735 | vty_out(vty, "%ld unknown attributes\n", count); | |
7736 | ||
7737 | /* AS_PATH attributes */ | |
7738 | count = aspath_count(); | |
7739 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
7740 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7741 | count * sizeof(struct aspath))); | |
7742 | ||
7743 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
7744 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
7745 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7746 | count * sizeof(struct assegment))); | |
7747 | ||
7748 | /* Other attributes */ | |
7749 | if ((count = community_count())) | |
7750 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
7751 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7752 | count * sizeof(struct community))); | |
d62a17ae | 7753 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
7754 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
7755 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7756 | count * sizeof(struct ecommunity))); | |
d62a17ae | 7757 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
7758 | vty_out(vty, | |
7759 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
7760 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7761 | count * sizeof(struct lcommunity))); | |
d62a17ae | 7762 | |
7763 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
7764 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
7765 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7766 | count * sizeof(struct cluster_list))); | |
7767 | ||
7768 | /* Peer related usage */ | |
7769 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
7770 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
7771 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7772 | count * sizeof(struct peer))); | |
7773 | ||
7774 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
7775 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
7776 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7777 | count * sizeof(struct peer_group))); | |
7778 | ||
7779 | /* Other */ | |
7780 | if ((count = mtype_stats_alloc(MTYPE_HASH))) | |
7781 | vty_out(vty, "%ld hash tables, using %s of memory\n", count, | |
7782 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7783 | count * sizeof(struct hash))); | |
7784 | if ((count = mtype_stats_alloc(MTYPE_HASH_BACKET))) | |
7785 | vty_out(vty, "%ld hash buckets, using %s of memory\n", count, | |
7786 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
e3b78da8 | 7787 | count * sizeof(struct hash_bucket))); |
d62a17ae | 7788 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) |
7789 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
7790 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7791 | count * sizeof(regex_t))); | |
d62a17ae | 7792 | return CMD_SUCCESS; |
4bf6a362 | 7793 | } |
fee0f4c6 | 7794 | |
57a9c8a8 DS |
7795 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
7796 | { | |
7797 | json_object *bestpath = json_object_new_object(); | |
7798 | ||
7799 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_IGNORE)) | |
7800 | json_object_string_add(bestpath, "asPath", "ignore"); | |
7801 | ||
7802 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_CONFED)) | |
7803 | json_object_string_add(bestpath, "asPath", "confed"); | |
7804 | ||
7805 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { | |
a4d82a8a PZ |
7806 | if (bgp_flag_check(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) |
7807 | json_object_string_add(bestpath, "multiPathRelax", | |
57a9c8a8 DS |
7808 | "as-set"); |
7809 | else | |
a4d82a8a | 7810 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
7811 | "true"); |
7812 | } else | |
a4d82a8a | 7813 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 DS |
7814 | |
7815 | if (bgp_flag_check(bgp, BGP_FLAG_COMPARE_ROUTER_ID)) | |
7816 | json_object_string_add(bestpath, "compareRouterId", "true"); | |
7817 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED) | |
7818 | || bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
7819 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 7820 | json_object_string_add(bestpath, "med", "confed"); |
57a9c8a8 DS |
7821 | if (bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) |
7822 | json_object_string_add(bestpath, "med", | |
7823 | "missing-as-worst"); | |
7824 | else | |
7825 | json_object_string_add(bestpath, "med", "true"); | |
7826 | } | |
7827 | ||
7828 | json_object_object_add(json, "bestPath", bestpath); | |
7829 | } | |
7830 | ||
718e3744 | 7831 | /* Show BGP peer's summary information. */ |
d62a17ae | 7832 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
9f049418 | 7833 | bool use_json, json_object *json) |
d62a17ae | 7834 | { |
7835 | struct peer *peer; | |
7836 | struct listnode *node, *nnode; | |
7837 | unsigned int count = 0, dn_count = 0; | |
7838 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
7839 | char neighbor_buf[VTY_BUFSIZ]; | |
7840 | int neighbor_col_default_width = 16; | |
7841 | int len; | |
7842 | int max_neighbor_width = 0; | |
7843 | int pfx_rcd_safi; | |
7844 | json_object *json_peer = NULL; | |
7845 | json_object *json_peers = NULL; | |
50e05855 | 7846 | struct peer_af *paf; |
d62a17ae | 7847 | |
7848 | /* labeled-unicast routes are installed in the unicast table so in order | |
7849 | * to | |
7850 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
7851 | */ | |
7852 | if (safi == SAFI_LABELED_UNICAST) | |
7853 | pfx_rcd_safi = SAFI_UNICAST; | |
7854 | else | |
7855 | pfx_rcd_safi = safi; | |
7856 | ||
7857 | if (use_json) { | |
7858 | if (json == NULL) | |
7859 | json = json_object_new_object(); | |
7860 | ||
7861 | json_peers = json_object_new_object(); | |
7862 | } else { | |
7863 | /* Loop over all neighbors that will be displayed to determine | |
7864 | * how many | |
7865 | * characters are needed for the Neighbor column | |
7866 | */ | |
7867 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
7868 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
7869 | continue; | |
7870 | ||
7871 | if (peer->afc[afi][safi]) { | |
7872 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
7873 | if (peer_dynamic_neighbor(peer)) | |
7874 | dn_flag[0] = '*'; | |
7875 | ||
7876 | if (peer->hostname | |
7877 | && bgp_flag_check(bgp, | |
7878 | BGP_FLAG_SHOW_HOSTNAME)) | |
7879 | sprintf(neighbor_buf, "%s%s(%s) ", | |
7880 | dn_flag, peer->hostname, | |
7881 | peer->host); | |
7882 | else | |
7883 | sprintf(neighbor_buf, "%s%s ", dn_flag, | |
7884 | peer->host); | |
7885 | ||
7886 | len = strlen(neighbor_buf); | |
7887 | ||
7888 | if (len > max_neighbor_width) | |
7889 | max_neighbor_width = len; | |
7890 | } | |
7891 | } | |
f933309e | 7892 | |
d62a17ae | 7893 | /* Originally we displayed the Neighbor column as 16 |
7894 | * characters wide so make that the default | |
7895 | */ | |
7896 | if (max_neighbor_width < neighbor_col_default_width) | |
7897 | max_neighbor_width = neighbor_col_default_width; | |
7898 | } | |
f933309e | 7899 | |
d62a17ae | 7900 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
7901 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
7902 | continue; | |
7903 | ||
ea47320b DL |
7904 | if (!peer->afc[afi][safi]) |
7905 | continue; | |
d62a17ae | 7906 | |
ea47320b DL |
7907 | if (!count) { |
7908 | unsigned long ents; | |
7909 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 7910 | int64_t vrf_id_ui; |
d62a17ae | 7911 | |
a4d82a8a PZ |
7912 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
7913 | ? -1 | |
7914 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
7915 | |
7916 | /* Usage summary and header */ | |
7917 | if (use_json) { | |
7918 | json_object_string_add( | |
7919 | json, "routerId", | |
7920 | inet_ntoa(bgp->router_id)); | |
60466a63 QY |
7921 | json_object_int_add(json, "as", bgp->as); |
7922 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
7923 | json_object_string_add( |
7924 | json, "vrfName", | |
7925 | (bgp->inst_type | |
7926 | == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 7927 | ? VRF_DEFAULT_NAME |
ea47320b DL |
7928 | : bgp->name); |
7929 | } else { | |
7930 | vty_out(vty, | |
7931 | "BGP router identifier %s, local AS number %u vrf-id %d", | |
60466a63 | 7932 | inet_ntoa(bgp->router_id), bgp->as, |
a4d82a8a PZ |
7933 | bgp->vrf_id == VRF_UNKNOWN |
7934 | ? -1 | |
7935 | : (int)bgp->vrf_id); | |
ea47320b DL |
7936 | vty_out(vty, "\n"); |
7937 | } | |
d62a17ae | 7938 | |
ea47320b | 7939 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 7940 | if (use_json) { |
ea47320b | 7941 | json_object_int_add( |
60466a63 | 7942 | json, "updateDelayLimit", |
ea47320b | 7943 | bgp->v_update_delay); |
d62a17ae | 7944 | |
ea47320b DL |
7945 | if (bgp->v_update_delay |
7946 | != bgp->v_establish_wait) | |
d62a17ae | 7947 | json_object_int_add( |
7948 | json, | |
ea47320b DL |
7949 | "updateDelayEstablishWait", |
7950 | bgp->v_establish_wait); | |
d62a17ae | 7951 | |
60466a63 | 7952 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
7953 | json_object_string_add( |
7954 | json, | |
7955 | "updateDelayFirstNeighbor", | |
7956 | bgp->update_delay_begin_time); | |
7957 | json_object_boolean_true_add( | |
7958 | json, | |
7959 | "updateDelayInProgress"); | |
7960 | } else { | |
7961 | if (bgp->update_delay_over) { | |
d62a17ae | 7962 | json_object_string_add( |
7963 | json, | |
7964 | "updateDelayFirstNeighbor", | |
7965 | bgp->update_delay_begin_time); | |
ea47320b | 7966 | json_object_string_add( |
d62a17ae | 7967 | json, |
ea47320b DL |
7968 | "updateDelayBestpathResumed", |
7969 | bgp->update_delay_end_time); | |
7970 | json_object_string_add( | |
d62a17ae | 7971 | json, |
ea47320b DL |
7972 | "updateDelayZebraUpdateResume", |
7973 | bgp->update_delay_zebra_resume_time); | |
7974 | json_object_string_add( | |
7975 | json, | |
7976 | "updateDelayPeerUpdateResume", | |
7977 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 7978 | } |
ea47320b DL |
7979 | } |
7980 | } else { | |
7981 | vty_out(vty, | |
7982 | "Read-only mode update-delay limit: %d seconds\n", | |
7983 | bgp->v_update_delay); | |
7984 | if (bgp->v_update_delay | |
7985 | != bgp->v_establish_wait) | |
d62a17ae | 7986 | vty_out(vty, |
ea47320b DL |
7987 | " Establish wait: %d seconds\n", |
7988 | bgp->v_establish_wait); | |
d62a17ae | 7989 | |
60466a63 | 7990 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
7991 | vty_out(vty, |
7992 | " First neighbor established: %s\n", | |
7993 | bgp->update_delay_begin_time); | |
7994 | vty_out(vty, | |
7995 | " Delay in progress\n"); | |
7996 | } else { | |
7997 | if (bgp->update_delay_over) { | |
d62a17ae | 7998 | vty_out(vty, |
7999 | " First neighbor established: %s\n", | |
8000 | bgp->update_delay_begin_time); | |
8001 | vty_out(vty, | |
ea47320b DL |
8002 | " Best-paths resumed: %s\n", |
8003 | bgp->update_delay_end_time); | |
8004 | vty_out(vty, | |
8005 | " zebra update resumed: %s\n", | |
8006 | bgp->update_delay_zebra_resume_time); | |
8007 | vty_out(vty, | |
8008 | " peers update resumed: %s\n", | |
8009 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 8010 | } |
8011 | } | |
8012 | } | |
ea47320b | 8013 | } |
d62a17ae | 8014 | |
ea47320b DL |
8015 | if (use_json) { |
8016 | if (bgp_maxmed_onstartup_configured(bgp) | |
8017 | && bgp->maxmed_active) | |
8018 | json_object_boolean_true_add( | |
60466a63 | 8019 | json, "maxMedOnStartup"); |
ea47320b DL |
8020 | if (bgp->v_maxmed_admin) |
8021 | json_object_boolean_true_add( | |
60466a63 | 8022 | json, "maxMedAdministrative"); |
d62a17ae | 8023 | |
ea47320b DL |
8024 | json_object_int_add( |
8025 | json, "tableVersion", | |
60466a63 | 8026 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 8027 | |
60466a63 QY |
8028 | ents = bgp_table_count(bgp->rib[afi][safi]); |
8029 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
8030 | json_object_int_add( |
8031 | json, "ribMemory", | |
8032 | ents * sizeof(struct bgp_node)); | |
d62a17ae | 8033 | |
210ec2a0 | 8034 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 QY |
8035 | json_object_int_add(json, "peerCount", ents); |
8036 | json_object_int_add(json, "peerMemory", | |
8037 | ents * sizeof(struct peer)); | |
d62a17ae | 8038 | |
ea47320b DL |
8039 | if ((ents = listcount(bgp->group))) { |
8040 | json_object_int_add( | |
60466a63 | 8041 | json, "peerGroupCount", ents); |
ea47320b DL |
8042 | json_object_int_add( |
8043 | json, "peerGroupMemory", | |
996c9314 LB |
8044 | ents * sizeof(struct |
8045 | peer_group)); | |
ea47320b | 8046 | } |
d62a17ae | 8047 | |
ea47320b DL |
8048 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
8049 | BGP_CONFIG_DAMPENING)) | |
8050 | json_object_boolean_true_add( | |
60466a63 | 8051 | json, "dampeningEnabled"); |
ea47320b DL |
8052 | } else { |
8053 | if (bgp_maxmed_onstartup_configured(bgp) | |
8054 | && bgp->maxmed_active) | |
d62a17ae | 8055 | vty_out(vty, |
ea47320b DL |
8056 | "Max-med on-startup active\n"); |
8057 | if (bgp->v_maxmed_admin) | |
d62a17ae | 8058 | vty_out(vty, |
ea47320b | 8059 | "Max-med administrative active\n"); |
d62a17ae | 8060 | |
60466a63 QY |
8061 | vty_out(vty, "BGP table version %" PRIu64 "\n", |
8062 | bgp_table_version(bgp->rib[afi][safi])); | |
d62a17ae | 8063 | |
60466a63 | 8064 | ents = bgp_table_count(bgp->rib[afi][safi]); |
ea47320b DL |
8065 | vty_out(vty, |
8066 | "RIB entries %ld, using %s of memory\n", | |
8067 | ents, | |
996c9314 LB |
8068 | mtype_memstr(memstrbuf, |
8069 | sizeof(memstrbuf), | |
8070 | ents * sizeof(struct | |
8071 | bgp_node))); | |
ea47320b DL |
8072 | |
8073 | /* Peer related usage */ | |
210ec2a0 | 8074 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 | 8075 | vty_out(vty, "Peers %ld, using %s of memory\n", |
ea47320b DL |
8076 | ents, |
8077 | mtype_memstr( | |
60466a63 QY |
8078 | memstrbuf, sizeof(memstrbuf), |
8079 | ents * sizeof(struct peer))); | |
ea47320b DL |
8080 | |
8081 | if ((ents = listcount(bgp->group))) | |
d62a17ae | 8082 | vty_out(vty, |
ea47320b | 8083 | "Peer groups %ld, using %s of memory\n", |
d62a17ae | 8084 | ents, |
8085 | mtype_memstr( | |
8086 | memstrbuf, | |
8087 | sizeof(memstrbuf), | |
996c9314 LB |
8088 | ents * sizeof(struct |
8089 | peer_group))); | |
d62a17ae | 8090 | |
ea47320b DL |
8091 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
8092 | BGP_CONFIG_DAMPENING)) | |
60466a63 | 8093 | vty_out(vty, "Dampening enabled.\n"); |
ea47320b | 8094 | vty_out(vty, "\n"); |
d62a17ae | 8095 | |
ea47320b DL |
8096 | /* Subtract 8 here because 'Neighbor' is |
8097 | * 8 characters */ | |
8098 | vty_out(vty, "Neighbor"); | |
60466a63 QY |
8099 | vty_out(vty, "%*s", max_neighbor_width - 8, |
8100 | " "); | |
ea47320b DL |
8101 | vty_out(vty, |
8102 | "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n"); | |
d62a17ae | 8103 | } |
ea47320b | 8104 | } |
d62a17ae | 8105 | |
ea47320b | 8106 | count++; |
d62a17ae | 8107 | |
ea47320b DL |
8108 | if (use_json) { |
8109 | json_peer = json_object_new_object(); | |
d62a17ae | 8110 | |
b4e9dcba DD |
8111 | if (peer_dynamic_neighbor(peer)) { |
8112 | dn_count++; | |
60466a63 QY |
8113 | json_object_boolean_true_add(json_peer, |
8114 | "dynamicPeer"); | |
b4e9dcba | 8115 | } |
d62a17ae | 8116 | |
ea47320b | 8117 | if (peer->hostname) |
60466a63 | 8118 | json_object_string_add(json_peer, "hostname", |
ea47320b | 8119 | peer->hostname); |
d62a17ae | 8120 | |
ea47320b | 8121 | if (peer->domainname) |
60466a63 QY |
8122 | json_object_string_add(json_peer, "domainname", |
8123 | peer->domainname); | |
d62a17ae | 8124 | |
60466a63 | 8125 | json_object_int_add(json_peer, "remoteAs", peer->as); |
ea47320b | 8126 | json_object_int_add(json_peer, "version", 4); |
60466a63 | 8127 | json_object_int_add(json_peer, "msgRcvd", |
0112e9e0 | 8128 | PEER_TOTAL_RX(peer)); |
60466a63 | 8129 | json_object_int_add(json_peer, "msgSent", |
0112e9e0 | 8130 | PEER_TOTAL_TX(peer)); |
ea47320b DL |
8131 | |
8132 | json_object_int_add(json_peer, "tableVersion", | |
8133 | peer->version[afi][safi]); | |
8134 | json_object_int_add(json_peer, "outq", | |
8135 | peer->obuf->count); | |
8136 | json_object_int_add(json_peer, "inq", 0); | |
60466a63 QY |
8137 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, |
8138 | use_json, json_peer); | |
50e05855 AD |
8139 | |
8140 | /* | |
8141 | * Adding "pfxRcd" field to match with the corresponding | |
8142 | * CLI. "prefixReceivedCount" will be deprecated in | |
8143 | * future. | |
8144 | */ | |
60466a63 QY |
8145 | json_object_int_add(json_peer, "prefixReceivedCount", |
8146 | peer->pcount[afi][pfx_rcd_safi]); | |
50e05855 AD |
8147 | json_object_int_add(json_peer, "pfxRcd", |
8148 | peer->pcount[afi][pfx_rcd_safi]); | |
8149 | ||
8150 | paf = peer_af_find(peer, afi, pfx_rcd_safi); | |
8151 | if (paf && PAF_SUBGRP(paf)) | |
8152 | json_object_int_add(json_peer, | |
8153 | "pfxSnt", | |
8154 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 8155 | |
ea47320b | 8156 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) |
60466a63 | 8157 | json_object_string_add(json_peer, "state", |
ea47320b | 8158 | "Idle (Admin)"); |
9199a725 TM |
8159 | else if (peer->afc_recv[afi][safi]) |
8160 | json_object_string_add( | |
8161 | json_peer, "state", | |
8162 | lookup_msg(bgp_status_msg, peer->status, | |
8163 | NULL)); | |
60466a63 QY |
8164 | else if (CHECK_FLAG(peer->sflags, |
8165 | PEER_STATUS_PREFIX_OVERFLOW)) | |
8166 | json_object_string_add(json_peer, "state", | |
ea47320b DL |
8167 | "Idle (PfxCt)"); |
8168 | else | |
8169 | json_object_string_add( | |
8170 | json_peer, "state", | |
60466a63 QY |
8171 | lookup_msg(bgp_status_msg, peer->status, |
8172 | NULL)); | |
ea47320b DL |
8173 | |
8174 | if (peer->conf_if) | |
60466a63 | 8175 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
8176 | "interface"); |
8177 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
8178 | json_object_string_add(json_peer, "idType", |
8179 | "ipv4"); | |
ea47320b | 8180 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
8181 | json_object_string_add(json_peer, "idType", |
8182 | "ipv6"); | |
d62a17ae | 8183 | |
ea47320b DL |
8184 | json_object_object_add(json_peers, peer->host, |
8185 | json_peer); | |
8186 | } else { | |
8187 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
8188 | if (peer_dynamic_neighbor(peer)) { | |
8189 | dn_count++; | |
8190 | dn_flag[0] = '*'; | |
8191 | } | |
d62a17ae | 8192 | |
ea47320b | 8193 | if (peer->hostname |
60466a63 | 8194 | && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) |
ea47320b | 8195 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
60466a63 | 8196 | peer->hostname, peer->host); |
ea47320b | 8197 | else |
60466a63 | 8198 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
ea47320b DL |
8199 | |
8200 | /* pad the neighbor column with spaces */ | |
8201 | if (len < max_neighbor_width) | |
60466a63 QY |
8202 | vty_out(vty, "%*s", max_neighbor_width - len, |
8203 | " "); | |
ea47320b | 8204 | |
86a55b99 | 8205 | vty_out(vty, "4 %10u %7u %7u %8" PRIu64 " %4d %4zd %8s", |
0112e9e0 QY |
8206 | peer->as, PEER_TOTAL_RX(peer), |
8207 | PEER_TOTAL_TX(peer), peer->version[afi][safi], | |
8208 | 0, peer->obuf->count, | |
d62a17ae | 8209 | peer_uptime(peer->uptime, timebuf, |
ea47320b | 8210 | BGP_UPTIME_LEN, 0, NULL)); |
d62a17ae | 8211 | |
ea47320b | 8212 | if (peer->status == Established) |
2f8f4f10 | 8213 | if (peer->afc_recv[afi][safi]) |
95077abf | 8214 | vty_out(vty, " %12ld", |
a4d82a8a PZ |
8215 | peer->pcount[afi] |
8216 | [pfx_rcd_safi]); | |
95077abf DW |
8217 | else |
8218 | vty_out(vty, " NoNeg"); | |
ea47320b | 8219 | else { |
60466a63 | 8220 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) |
ea47320b | 8221 | vty_out(vty, " Idle (Admin)"); |
60466a63 QY |
8222 | else if (CHECK_FLAG( |
8223 | peer->sflags, | |
8224 | PEER_STATUS_PREFIX_OVERFLOW)) | |
ea47320b | 8225 | vty_out(vty, " Idle (PfxCt)"); |
d62a17ae | 8226 | else |
ea47320b | 8227 | vty_out(vty, " %12s", |
60466a63 QY |
8228 | lookup_msg(bgp_status_msg, |
8229 | peer->status, NULL)); | |
d62a17ae | 8230 | } |
ea47320b | 8231 | vty_out(vty, "\n"); |
d62a17ae | 8232 | } |
8233 | } | |
f933309e | 8234 | |
d62a17ae | 8235 | if (use_json) { |
8236 | json_object_object_add(json, "peers", json_peers); | |
8237 | ||
8238 | json_object_int_add(json, "totalPeers", count); | |
8239 | json_object_int_add(json, "dynamicPeers", dn_count); | |
8240 | ||
57a9c8a8 DS |
8241 | bgp_show_bestpath_json(bgp, json); |
8242 | ||
996c9314 LB |
8243 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
8244 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 8245 | json_object_free(json); |
8246 | } else { | |
8247 | if (count) | |
8248 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
8249 | else { | |
d6ceaca3 | 8250 | vty_out(vty, "No %s neighbor is configured\n", |
8251 | afi_safi_print(afi, safi)); | |
d62a17ae | 8252 | } |
b05a1c8b | 8253 | |
d6ceaca3 | 8254 | if (dn_count) { |
d62a17ae | 8255 | vty_out(vty, "* - dynamic neighbor\n"); |
8256 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
8257 | dn_count, bgp->dynamic_neighbors_limit); | |
8258 | } | |
8259 | } | |
1ff9a340 | 8260 | |
d62a17ae | 8261 | return CMD_SUCCESS; |
718e3744 | 8262 | } |
8263 | ||
d62a17ae | 8264 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
9f049418 | 8265 | int safi, bool use_json, |
d62a17ae | 8266 | json_object *json) |
8267 | { | |
8268 | int is_first = 1; | |
8269 | int afi_wildcard = (afi == AFI_MAX); | |
8270 | int safi_wildcard = (safi == SAFI_MAX); | |
8271 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 8272 | bool nbr_output = false; |
d62a17ae | 8273 | |
8274 | if (use_json && is_wildcard) | |
8275 | vty_out(vty, "{\n"); | |
8276 | if (afi_wildcard) | |
8277 | afi = 1; /* AFI_IP */ | |
8278 | while (afi < AFI_MAX) { | |
8279 | if (safi_wildcard) | |
8280 | safi = 1; /* SAFI_UNICAST */ | |
8281 | while (safi < SAFI_MAX) { | |
318cac96 | 8282 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 8283 | nbr_output = true; |
d62a17ae | 8284 | if (is_wildcard) { |
8285 | /* | |
8286 | * So limit output to those afi/safi | |
8287 | * pairs that | |
8288 | * actualy have something interesting in | |
8289 | * them | |
8290 | */ | |
8291 | if (use_json) { | |
8292 | json = json_object_new_object(); | |
8293 | ||
8294 | if (!is_first) | |
8295 | vty_out(vty, ",\n"); | |
8296 | else | |
8297 | is_first = 0; | |
8298 | ||
8299 | vty_out(vty, "\"%s\":", | |
8300 | afi_safi_json(afi, | |
8301 | safi)); | |
8302 | } else { | |
8303 | vty_out(vty, "\n%s Summary:\n", | |
8304 | afi_safi_print(afi, | |
8305 | safi)); | |
8306 | } | |
8307 | } | |
8308 | bgp_show_summary(vty, bgp, afi, safi, use_json, | |
8309 | json); | |
8310 | } | |
8311 | safi++; | |
d62a17ae | 8312 | if (!safi_wildcard) |
8313 | safi = SAFI_MAX; | |
8314 | } | |
8315 | afi++; | |
ee851c8c | 8316 | if (!afi_wildcard) |
d62a17ae | 8317 | afi = AFI_MAX; |
8318 | } | |
8319 | ||
8320 | if (use_json && is_wildcard) | |
8321 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
8322 | else if (!nbr_output) { |
8323 | if (use_json) | |
8324 | vty_out(vty, "{}\n"); | |
8325 | else | |
8326 | vty_out(vty, "%% No BGP neighbors found\n"); | |
8327 | } | |
d62a17ae | 8328 | } |
8329 | ||
8330 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
9f049418 | 8331 | safi_t safi, bool use_json) |
d62a17ae | 8332 | { |
8333 | struct listnode *node, *nnode; | |
8334 | struct bgp *bgp; | |
8335 | json_object *json = NULL; | |
8336 | int is_first = 1; | |
9f049418 | 8337 | bool nbr_output = false; |
d62a17ae | 8338 | |
8339 | if (use_json) | |
8340 | vty_out(vty, "{\n"); | |
8341 | ||
8342 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 8343 | nbr_output = true; |
d62a17ae | 8344 | if (use_json) { |
8345 | json = json_object_new_object(); | |
8346 | ||
8347 | if (!is_first) | |
8348 | vty_out(vty, ",\n"); | |
8349 | else | |
8350 | is_first = 0; | |
8351 | ||
8352 | vty_out(vty, "\"%s\":", | |
8353 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 8354 | ? VRF_DEFAULT_NAME |
d62a17ae | 8355 | : bgp->name); |
8356 | } else { | |
8357 | vty_out(vty, "\nInstance %s:\n", | |
8358 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 8359 | ? VRF_DEFAULT_NAME |
d62a17ae | 8360 | : bgp->name); |
8361 | } | |
8362 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, json); | |
8363 | } | |
8364 | ||
8365 | if (use_json) | |
8366 | vty_out(vty, "}\n"); | |
9f049418 DS |
8367 | else if (!nbr_output) |
8368 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 8369 | } |
8370 | ||
8371 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
9f049418 | 8372 | safi_t safi, bool use_json) |
d62a17ae | 8373 | { |
8374 | struct bgp *bgp; | |
8375 | ||
8376 | if (name) { | |
8377 | if (strmatch(name, "all")) { | |
8378 | bgp_show_all_instances_summary_vty(vty, afi, safi, | |
8379 | use_json); | |
8380 | return CMD_SUCCESS; | |
8381 | } else { | |
8382 | bgp = bgp_lookup_by_name(name); | |
8383 | ||
8384 | if (!bgp) { | |
8385 | if (use_json) | |
8386 | vty_out(vty, "{}\n"); | |
8387 | else | |
8388 | vty_out(vty, | |
ca61fd25 | 8389 | "%% BGP instance not found\n"); |
d62a17ae | 8390 | return CMD_WARNING; |
8391 | } | |
8392 | ||
8393 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, | |
8394 | NULL); | |
8395 | return CMD_SUCCESS; | |
8396 | } | |
8397 | } | |
8398 | ||
8399 | bgp = bgp_get_default(); | |
8400 | ||
8401 | if (bgp) | |
8402 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, NULL); | |
9f049418 | 8403 | else { |
ca61fd25 DS |
8404 | if (use_json) |
8405 | vty_out(vty, "{}\n"); | |
8406 | else | |
8407 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
8408 | return CMD_WARNING; |
8409 | } | |
d62a17ae | 8410 | |
8411 | return CMD_SUCCESS; | |
4fb25c53 DW |
8412 | } |
8413 | ||
716b2d8a | 8414 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 8415 | DEFUN (show_ip_bgp_summary, |
718e3744 | 8416 | show_ip_bgp_summary_cmd, |
dd6bd0f1 | 8417 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] summary [json]", |
718e3744 | 8418 | SHOW_STR |
8419 | IP_STR | |
8420 | BGP_STR | |
8386ac43 | 8421 | BGP_INSTANCE_HELP_STR |
46f296b4 | 8422 | BGP_AFI_HELP_STR |
dd6bd0f1 | 8423 | BGP_SAFI_WITH_LABEL_HELP_STR |
b05a1c8b | 8424 | "Summary of BGP neighbor status\n" |
9973d184 | 8425 | JSON_STR) |
718e3744 | 8426 | { |
d62a17ae | 8427 | char *vrf = NULL; |
8428 | afi_t afi = AFI_MAX; | |
8429 | safi_t safi = SAFI_MAX; | |
8430 | ||
8431 | int idx = 0; | |
8432 | ||
8433 | /* show [ip] bgp */ | |
8434 | if (argv_find(argv, argc, "ip", &idx)) | |
8435 | afi = AFI_IP; | |
9a8bdf1c PG |
8436 | /* [<vrf> VIEWVRFNAME] */ |
8437 | if (argv_find(argv, argc, "vrf", &idx)) { | |
8438 | vrf = argv[idx + 1]->arg; | |
8439 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
8440 | vrf = NULL; | |
8441 | } else if (argv_find(argv, argc, "view", &idx)) | |
8442 | /* [<view> VIEWVRFNAME] */ | |
8443 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 8444 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
8445 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
8446 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
8447 | } | |
8448 | ||
9f049418 | 8449 | bool uj = use_json(argc, argv); |
d62a17ae | 8450 | |
8451 | return bgp_show_summary_vty(vty, vrf, afi, safi, uj); | |
8452 | } | |
8453 | ||
8454 | const char *afi_safi_print(afi_t afi, safi_t safi) | |
8455 | { | |
8456 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
8457 | return "IPv4 Unicast"; | |
8458 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
8459 | return "IPv4 Multicast"; | |
8460 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
8461 | return "IPv4 Labeled Unicast"; | |
8462 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
8463 | return "IPv4 VPN"; | |
8464 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
8465 | return "IPv4 Encap"; | |
7c40bf39 | 8466 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) |
8467 | return "IPv4 Flowspec"; | |
d62a17ae | 8468 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
8469 | return "IPv6 Unicast"; | |
8470 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
8471 | return "IPv6 Multicast"; | |
8472 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
8473 | return "IPv6 Labeled Unicast"; | |
8474 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
8475 | return "IPv6 VPN"; | |
8476 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
8477 | return "IPv6 Encap"; | |
7c40bf39 | 8478 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) |
8479 | return "IPv6 Flowspec"; | |
d62a17ae | 8480 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) |
8481 | return "L2VPN EVPN"; | |
8482 | else | |
8483 | return "Unknown"; | |
538621f2 | 8484 | } |
8485 | ||
b9f77ec8 DS |
8486 | /* |
8487 | * Please note that we have intentionally camelCased | |
8488 | * the return strings here. So if you want | |
8489 | * to use this function, please ensure you | |
8490 | * are doing this within json output | |
8491 | */ | |
d62a17ae | 8492 | const char *afi_safi_json(afi_t afi, safi_t safi) |
8493 | { | |
8494 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
8495 | return "ipv4Unicast"; | |
8496 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
8497 | return "ipv4Multicast"; | |
8498 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
8499 | return "ipv4LabeledUnicast"; | |
8500 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
8501 | return "ipv4Vpn"; | |
8502 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
8503 | return "ipv4Encap"; | |
7c40bf39 | 8504 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) |
8505 | return "ipv4Flowspec"; | |
d62a17ae | 8506 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
8507 | return "ipv6Unicast"; | |
8508 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
8509 | return "ipv6Multicast"; | |
8510 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
8511 | return "ipv6LabeledUnicast"; | |
8512 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
8513 | return "ipv6Vpn"; | |
8514 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
8515 | return "ipv6Encap"; | |
7c40bf39 | 8516 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) |
8517 | return "ipv6Flowspec"; | |
d62a17ae | 8518 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) |
8519 | return "l2VpnEvpn"; | |
8520 | else | |
8521 | return "Unknown"; | |
27162734 LB |
8522 | } |
8523 | ||
718e3744 | 8524 | /* Show BGP peer's information. */ |
d1927ebe | 8525 | enum show_type { show_all, show_peer, show_ipv4_all, show_ipv6_all, show_ipv4_peer, show_ipv6_peer }; |
d62a17ae | 8526 | |
8527 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
8528 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
8529 | uint16_t adv_smcap, uint16_t adv_rmcap, |
8530 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 8531 | bool use_json, json_object *json_pref) |
d62a17ae | 8532 | { |
8533 | /* Send-Mode */ | |
8534 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
8535 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
8536 | if (use_json) { | |
8537 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
8538 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8539 | json_object_string_add(json_pref, "sendMode", | |
8540 | "advertisedAndReceived"); | |
8541 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
8542 | json_object_string_add(json_pref, "sendMode", | |
8543 | "advertised"); | |
8544 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8545 | json_object_string_add(json_pref, "sendMode", | |
8546 | "received"); | |
8547 | } else { | |
8548 | vty_out(vty, " Send-mode: "); | |
8549 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
8550 | vty_out(vty, "advertised"); | |
8551 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8552 | vty_out(vty, "%sreceived", | |
8553 | CHECK_FLAG(p->af_cap[afi][safi], | |
8554 | adv_smcap) | |
8555 | ? ", " | |
8556 | : ""); | |
8557 | vty_out(vty, "\n"); | |
8558 | } | |
8559 | } | |
8560 | ||
8561 | /* Receive-Mode */ | |
8562 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
8563 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
8564 | if (use_json) { | |
8565 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
8566 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8567 | json_object_string_add(json_pref, "recvMode", | |
8568 | "advertisedAndReceived"); | |
8569 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
8570 | json_object_string_add(json_pref, "recvMode", | |
8571 | "advertised"); | |
8572 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8573 | json_object_string_add(json_pref, "recvMode", | |
8574 | "received"); | |
8575 | } else { | |
8576 | vty_out(vty, " Receive-mode: "); | |
8577 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
8578 | vty_out(vty, "advertised"); | |
8579 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8580 | vty_out(vty, "%sreceived", | |
8581 | CHECK_FLAG(p->af_cap[afi][safi], | |
8582 | adv_rmcap) | |
8583 | ? ", " | |
8584 | : ""); | |
8585 | vty_out(vty, "\n"); | |
8586 | } | |
8587 | } | |
8588 | } | |
8589 | ||
8590 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, | |
9f049418 | 8591 | safi_t safi, bool use_json, |
d62a17ae | 8592 | json_object *json_neigh) |
8593 | { | |
0291c246 MK |
8594 | struct bgp_filter *filter; |
8595 | struct peer_af *paf; | |
8596 | char orf_pfx_name[BUFSIZ]; | |
8597 | int orf_pfx_count; | |
8598 | json_object *json_af = NULL; | |
8599 | json_object *json_prefA = NULL; | |
8600 | json_object *json_prefB = NULL; | |
8601 | json_object *json_addr = NULL; | |
d62a17ae | 8602 | |
8603 | if (use_json) { | |
8604 | json_addr = json_object_new_object(); | |
8605 | json_af = json_object_new_object(); | |
8606 | filter = &p->filter[afi][safi]; | |
8607 | ||
8608 | if (peer_group_active(p)) | |
8609 | json_object_string_add(json_addr, "peerGroupMember", | |
8610 | p->group->name); | |
8611 | ||
8612 | paf = peer_af_find(p, afi, safi); | |
8613 | if (paf && PAF_SUBGRP(paf)) { | |
8614 | json_object_int_add(json_addr, "updateGroupId", | |
8615 | PAF_UPDGRP(paf)->id); | |
8616 | json_object_int_add(json_addr, "subGroupId", | |
8617 | PAF_SUBGRP(paf)->id); | |
8618 | json_object_int_add(json_addr, "packetQueueLength", | |
8619 | bpacket_queue_virtual_length(paf)); | |
8620 | } | |
8621 | ||
8622 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8623 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8624 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8625 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8626 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8627 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8628 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
8629 | json_object_int_add(json_af, "orfType", | |
8630 | ORF_TYPE_PREFIX); | |
8631 | json_prefA = json_object_new_object(); | |
8632 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
8633 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
8634 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8635 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
8636 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
8637 | use_json, json_prefA); | |
8638 | json_object_object_add(json_af, "orfPrefixList", | |
8639 | json_prefA); | |
8640 | } | |
8641 | ||
8642 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8643 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8644 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8645 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8646 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8647 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8648 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
8649 | json_object_int_add(json_af, "orfOldType", | |
8650 | ORF_TYPE_PREFIX_OLD); | |
8651 | json_prefB = json_object_new_object(); | |
8652 | bgp_show_peer_afi_orf_cap( | |
8653 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
8654 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8655 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
8656 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
8657 | json_prefB); | |
8658 | json_object_object_add(json_af, "orfOldPrefixList", | |
8659 | json_prefB); | |
8660 | } | |
8661 | ||
8662 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8663 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8664 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8665 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8666 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8667 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8668 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8669 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8670 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
8671 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8672 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
8673 | json_object_object_add(json_addr, "afDependentCap", | |
8674 | json_af); | |
8675 | else | |
8676 | json_object_free(json_af); | |
8677 | ||
8678 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
8679 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
8680 | NULL, afi, orf_pfx_name, use_json); | |
8681 | ||
8682 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8683 | PEER_STATUS_ORF_PREFIX_SEND) | |
8684 | || orf_pfx_count) { | |
8685 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8686 | PEER_STATUS_ORF_PREFIX_SEND)) | |
8687 | json_object_boolean_true_add(json_neigh, | |
8688 | "orfSent"); | |
8689 | if (orf_pfx_count) | |
8690 | json_object_int_add(json_addr, "orfRecvCounter", | |
8691 | orf_pfx_count); | |
8692 | } | |
8693 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8694 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
8695 | json_object_string_add( | |
8696 | json_addr, "orfFirstUpdate", | |
8697 | "deferredUntilORFOrRouteRefreshRecvd"); | |
8698 | ||
8699 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8700 | PEER_FLAG_REFLECTOR_CLIENT)) | |
8701 | json_object_boolean_true_add(json_addr, | |
8702 | "routeReflectorClient"); | |
8703 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8704 | PEER_FLAG_RSERVER_CLIENT)) | |
8705 | json_object_boolean_true_add(json_addr, | |
8706 | "routeServerClient"); | |
8707 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
8708 | json_object_boolean_true_add(json_addr, | |
8709 | "inboundSoftConfigPermit"); | |
8710 | ||
8711 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8712 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
8713 | json_object_boolean_true_add( | |
8714 | json_addr, | |
8715 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
8716 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8717 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
8718 | json_object_boolean_true_add( | |
8719 | json_addr, | |
8720 | "privateAsNumsReplacedInUpdatesToNbr"); | |
8721 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8722 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
8723 | json_object_boolean_true_add( | |
8724 | json_addr, | |
8725 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
8726 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8727 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
8728 | json_object_boolean_true_add( | |
8729 | json_addr, | |
8730 | "privateAsNumsRemovedInUpdatesToNbr"); | |
8731 | ||
dcc68b5e MS |
8732 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
8733 | json_object_boolean_true_add( | |
8734 | json_addr, | |
8735 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
8736 | ->type_json_name); | |
d62a17ae | 8737 | |
8738 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
8739 | json_object_string_add(json_addr, | |
8740 | "overrideASNsInOutboundUpdates", | |
8741 | "ifAspathEqualRemoteAs"); | |
8742 | ||
8743 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
8744 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8745 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
8746 | json_object_boolean_true_add(json_addr, | |
8747 | "routerAlwaysNextHop"); | |
8748 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8749 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
8750 | json_object_boolean_true_add( | |
8751 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
8752 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8753 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
8754 | json_object_boolean_true_add( | |
8755 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
8756 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
8757 | json_object_boolean_true_add( | |
8758 | json_addr, "unchangedMedPropogatedToNbr"); | |
8759 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
8760 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8761 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
8762 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8763 | PEER_FLAG_SEND_COMMUNITY) | |
8764 | && CHECK_FLAG(p->af_flags[afi][safi], | |
8765 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
8766 | json_object_string_add(json_addr, | |
8767 | "commAttriSentToNbr", | |
8768 | "extendedAndStandard"); | |
8769 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8770 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
8771 | json_object_string_add(json_addr, | |
8772 | "commAttriSentToNbr", | |
8773 | "extended"); | |
8774 | else | |
8775 | json_object_string_add(json_addr, | |
8776 | "commAttriSentToNbr", | |
8777 | "standard"); | |
8778 | } | |
8779 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8780 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
8781 | if (p->default_rmap[afi][safi].name) | |
8782 | json_object_string_add( | |
8783 | json_addr, "defaultRouteMap", | |
8784 | p->default_rmap[afi][safi].name); | |
8785 | ||
8786 | if (paf && PAF_SUBGRP(paf) | |
8787 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
8788 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
8789 | json_object_boolean_true_add(json_addr, | |
8790 | "defaultSent"); | |
8791 | else | |
8792 | json_object_boolean_true_add(json_addr, | |
8793 | "defaultNotSent"); | |
8794 | } | |
8795 | ||
dff8f48d | 8796 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 8797 | if (is_evpn_enabled()) |
60466a63 QY |
8798 | json_object_boolean_true_add( |
8799 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
8800 | } |
8801 | ||
d62a17ae | 8802 | if (filter->plist[FILTER_IN].name |
8803 | || filter->dlist[FILTER_IN].name | |
8804 | || filter->aslist[FILTER_IN].name | |
8805 | || filter->map[RMAP_IN].name) | |
8806 | json_object_boolean_true_add(json_addr, | |
8807 | "inboundPathPolicyConfig"); | |
8808 | if (filter->plist[FILTER_OUT].name | |
8809 | || filter->dlist[FILTER_OUT].name | |
8810 | || filter->aslist[FILTER_OUT].name | |
8811 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
8812 | json_object_boolean_true_add( | |
8813 | json_addr, "outboundPathPolicyConfig"); | |
8814 | ||
8815 | /* prefix-list */ | |
8816 | if (filter->plist[FILTER_IN].name) | |
8817 | json_object_string_add(json_addr, | |
8818 | "incomingUpdatePrefixFilterList", | |
8819 | filter->plist[FILTER_IN].name); | |
8820 | if (filter->plist[FILTER_OUT].name) | |
8821 | json_object_string_add(json_addr, | |
8822 | "outgoingUpdatePrefixFilterList", | |
8823 | filter->plist[FILTER_OUT].name); | |
8824 | ||
8825 | /* distribute-list */ | |
8826 | if (filter->dlist[FILTER_IN].name) | |
8827 | json_object_string_add( | |
8828 | json_addr, "incomingUpdateNetworkFilterList", | |
8829 | filter->dlist[FILTER_IN].name); | |
8830 | if (filter->dlist[FILTER_OUT].name) | |
8831 | json_object_string_add( | |
8832 | json_addr, "outgoingUpdateNetworkFilterList", | |
8833 | filter->dlist[FILTER_OUT].name); | |
8834 | ||
8835 | /* filter-list. */ | |
8836 | if (filter->aslist[FILTER_IN].name) | |
8837 | json_object_string_add(json_addr, | |
8838 | "incomingUpdateAsPathFilterList", | |
8839 | filter->aslist[FILTER_IN].name); | |
8840 | if (filter->aslist[FILTER_OUT].name) | |
8841 | json_object_string_add(json_addr, | |
8842 | "outgoingUpdateAsPathFilterList", | |
8843 | filter->aslist[FILTER_OUT].name); | |
8844 | ||
8845 | /* route-map. */ | |
8846 | if (filter->map[RMAP_IN].name) | |
8847 | json_object_string_add( | |
8848 | json_addr, "routeMapForIncomingAdvertisements", | |
8849 | filter->map[RMAP_IN].name); | |
8850 | if (filter->map[RMAP_OUT].name) | |
8851 | json_object_string_add( | |
8852 | json_addr, "routeMapForOutgoingAdvertisements", | |
8853 | filter->map[RMAP_OUT].name); | |
8854 | ||
9dac9fc8 DA |
8855 | /* ebgp-requires-policy (inbound) */ |
8856 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
8857 | && !bgp_inbound_policy_exists(p, filter)) | |
8858 | json_object_string_add( | |
8859 | json_addr, "inboundEbgpRequiresPolicy", | |
8860 | "Inbound updates discarded due to missing policy"); | |
8861 | ||
8862 | /* ebgp-requires-policy (outbound) */ | |
8863 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
8864 | && (!bgp_outbound_policy_exists(p, filter))) | |
8865 | json_object_string_add( | |
8866 | json_addr, "outboundEbgpRequiresPolicy", | |
8867 | "Outbound updates discarded due to missing policy"); | |
8868 | ||
d62a17ae | 8869 | /* unsuppress-map */ |
8870 | if (filter->usmap.name) | |
8871 | json_object_string_add(json_addr, | |
8872 | "selectiveUnsuppressRouteMap", | |
8873 | filter->usmap.name); | |
8874 | ||
8875 | /* Receive prefix count */ | |
8876 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
8877 | p->pcount[afi][safi]); | |
50e05855 AD |
8878 | if (paf && PAF_SUBGRP(paf)) |
8879 | json_object_int_add(json_addr, "sentPrefixCounter", | |
8880 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 8881 | |
8882 | /* Maximum prefix */ | |
8883 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
8884 | json_object_int_add(json_addr, "prefixAllowedMax", | |
8885 | p->pmax[afi][safi]); | |
8886 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8887 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
8888 | json_object_boolean_true_add( | |
8889 | json_addr, "prefixAllowedMaxWarning"); | |
8890 | json_object_int_add(json_addr, | |
8891 | "prefixAllowedWarningThresh", | |
8892 | p->pmax_threshold[afi][safi]); | |
8893 | if (p->pmax_restart[afi][safi]) | |
8894 | json_object_int_add( | |
8895 | json_addr, | |
8896 | "prefixAllowedRestartIntervalMsecs", | |
8897 | p->pmax_restart[afi][safi] * 60000); | |
8898 | } | |
8899 | json_object_object_add(json_neigh, afi_safi_print(afi, safi), | |
8900 | json_addr); | |
8901 | ||
8902 | } else { | |
8903 | filter = &p->filter[afi][safi]; | |
8904 | ||
8905 | vty_out(vty, " For address family: %s\n", | |
8906 | afi_safi_print(afi, safi)); | |
8907 | ||
8908 | if (peer_group_active(p)) | |
8909 | vty_out(vty, " %s peer-group member\n", | |
8910 | p->group->name); | |
8911 | ||
8912 | paf = peer_af_find(p, afi, safi); | |
8913 | if (paf && PAF_SUBGRP(paf)) { | |
996c9314 LB |
8914 | vty_out(vty, " Update group %" PRIu64 |
8915 | ", subgroup %" PRIu64 "\n", | |
d62a17ae | 8916 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
8917 | vty_out(vty, " Packet Queue length %d\n", | |
8918 | bpacket_queue_virtual_length(paf)); | |
8919 | } else { | |
8920 | vty_out(vty, " Not part of any update group\n"); | |
8921 | } | |
8922 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8923 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8924 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8925 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8926 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8927 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8928 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8929 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8930 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
8931 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8932 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
8933 | vty_out(vty, " AF-dependant capabilities:\n"); | |
8934 | ||
8935 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8936 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8937 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8938 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8939 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8940 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8941 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
8942 | vty_out(vty, | |
8943 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
8944 | ORF_TYPE_PREFIX); | |
8945 | bgp_show_peer_afi_orf_cap( | |
8946 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
8947 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8948 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
8949 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
8950 | } | |
8951 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8952 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8953 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8954 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8955 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8956 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8957 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
8958 | vty_out(vty, | |
8959 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
8960 | ORF_TYPE_PREFIX_OLD); | |
8961 | bgp_show_peer_afi_orf_cap( | |
8962 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
8963 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8964 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
8965 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
8966 | } | |
8967 | ||
8968 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
8969 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
8970 | NULL, afi, orf_pfx_name, use_json); | |
8971 | ||
8972 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8973 | PEER_STATUS_ORF_PREFIX_SEND) | |
8974 | || orf_pfx_count) { | |
8975 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
8976 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8977 | PEER_STATUS_ORF_PREFIX_SEND)) | |
8978 | vty_out(vty, " sent;"); | |
8979 | if (orf_pfx_count) | |
8980 | vty_out(vty, " received (%d entries)", | |
8981 | orf_pfx_count); | |
8982 | vty_out(vty, "\n"); | |
8983 | } | |
8984 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8985 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
8986 | vty_out(vty, | |
8987 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
8988 | ||
8989 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8990 | PEER_FLAG_REFLECTOR_CLIENT)) | |
8991 | vty_out(vty, " Route-Reflector Client\n"); | |
8992 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8993 | PEER_FLAG_RSERVER_CLIENT)) | |
8994 | vty_out(vty, " Route-Server Client\n"); | |
8995 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
8996 | vty_out(vty, | |
8997 | " Inbound soft reconfiguration allowed\n"); | |
8998 | ||
8999 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9000 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
9001 | vty_out(vty, | |
9002 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
9003 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9004 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
9005 | vty_out(vty, | |
9006 | " Private AS numbers replaced in updates to this neighbor\n"); | |
9007 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9008 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
9009 | vty_out(vty, | |
9010 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
9011 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9012 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
9013 | vty_out(vty, | |
9014 | " Private AS numbers removed in updates to this neighbor\n"); | |
9015 | ||
dcc68b5e MS |
9016 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
9017 | vty_out(vty, " %s\n", | |
9018 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
9019 | ->human_description); | |
d62a17ae | 9020 | |
9021 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
9022 | vty_out(vty, | |
9023 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
9024 | ||
9025 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
9026 | || CHECK_FLAG(p->af_flags[afi][safi], | |
9027 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
9028 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
9029 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9030 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
9031 | vty_out(vty, | |
9032 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
9033 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9034 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
9035 | vty_out(vty, | |
9036 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
9037 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
9038 | vty_out(vty, | |
9039 | " MED is propagated unchanged to this neighbor\n"); | |
9040 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
9041 | || CHECK_FLAG(p->af_flags[afi][safi], | |
9042 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
9043 | || CHECK_FLAG(p->af_flags[afi][safi], | |
9044 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
9045 | vty_out(vty, | |
9046 | " Community attribute sent to this neighbor"); | |
9047 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9048 | PEER_FLAG_SEND_COMMUNITY) | |
9049 | && CHECK_FLAG(p->af_flags[afi][safi], | |
9050 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
9051 | && CHECK_FLAG(p->af_flags[afi][safi], | |
9052 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
9053 | vty_out(vty, "(all)\n"); | |
9054 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9055 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
9056 | vty_out(vty, "(large)\n"); | |
9057 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9058 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
9059 | vty_out(vty, "(extended)\n"); | |
9060 | else | |
9061 | vty_out(vty, "(standard)\n"); | |
9062 | } | |
9063 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9064 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
9065 | vty_out(vty, " Default information originate,"); | |
9066 | ||
9067 | if (p->default_rmap[afi][safi].name) | |
9068 | vty_out(vty, " default route-map %s%s,", | |
9069 | p->default_rmap[afi][safi].map ? "*" | |
9070 | : "", | |
9071 | p->default_rmap[afi][safi].name); | |
9072 | if (paf && PAF_SUBGRP(paf) | |
9073 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
9074 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
9075 | vty_out(vty, " default sent\n"); | |
9076 | else | |
9077 | vty_out(vty, " default not sent\n"); | |
9078 | } | |
9079 | ||
dff8f48d MK |
9080 | /* advertise-vni-all */ |
9081 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 9082 | if (is_evpn_enabled()) |
dff8f48d MK |
9083 | vty_out(vty, " advertise-all-vni\n"); |
9084 | } | |
9085 | ||
d62a17ae | 9086 | if (filter->plist[FILTER_IN].name |
9087 | || filter->dlist[FILTER_IN].name | |
9088 | || filter->aslist[FILTER_IN].name | |
9089 | || filter->map[RMAP_IN].name) | |
9090 | vty_out(vty, " Inbound path policy configured\n"); | |
9091 | if (filter->plist[FILTER_OUT].name | |
9092 | || filter->dlist[FILTER_OUT].name | |
9093 | || filter->aslist[FILTER_OUT].name | |
9094 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
9095 | vty_out(vty, " Outbound path policy configured\n"); | |
9096 | ||
9097 | /* prefix-list */ | |
9098 | if (filter->plist[FILTER_IN].name) | |
9099 | vty_out(vty, | |
9100 | " Incoming update prefix filter list is %s%s\n", | |
9101 | filter->plist[FILTER_IN].plist ? "*" : "", | |
9102 | filter->plist[FILTER_IN].name); | |
9103 | if (filter->plist[FILTER_OUT].name) | |
9104 | vty_out(vty, | |
9105 | " Outgoing update prefix filter list is %s%s\n", | |
9106 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
9107 | filter->plist[FILTER_OUT].name); | |
9108 | ||
9109 | /* distribute-list */ | |
9110 | if (filter->dlist[FILTER_IN].name) | |
9111 | vty_out(vty, | |
9112 | " Incoming update network filter list is %s%s\n", | |
9113 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
9114 | filter->dlist[FILTER_IN].name); | |
9115 | if (filter->dlist[FILTER_OUT].name) | |
9116 | vty_out(vty, | |
9117 | " Outgoing update network filter list is %s%s\n", | |
9118 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
9119 | filter->dlist[FILTER_OUT].name); | |
9120 | ||
9121 | /* filter-list. */ | |
9122 | if (filter->aslist[FILTER_IN].name) | |
9123 | vty_out(vty, | |
9124 | " Incoming update AS path filter list is %s%s\n", | |
9125 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
9126 | filter->aslist[FILTER_IN].name); | |
9127 | if (filter->aslist[FILTER_OUT].name) | |
9128 | vty_out(vty, | |
9129 | " Outgoing update AS path filter list is %s%s\n", | |
9130 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
9131 | filter->aslist[FILTER_OUT].name); | |
9132 | ||
9133 | /* route-map. */ | |
9134 | if (filter->map[RMAP_IN].name) | |
9135 | vty_out(vty, | |
9136 | " Route map for incoming advertisements is %s%s\n", | |
9137 | filter->map[RMAP_IN].map ? "*" : "", | |
9138 | filter->map[RMAP_IN].name); | |
9139 | if (filter->map[RMAP_OUT].name) | |
9140 | vty_out(vty, | |
9141 | " Route map for outgoing advertisements is %s%s\n", | |
9142 | filter->map[RMAP_OUT].map ? "*" : "", | |
9143 | filter->map[RMAP_OUT].name); | |
9144 | ||
9dac9fc8 DA |
9145 | /* ebgp-requires-policy (inbound) */ |
9146 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
9147 | && !bgp_inbound_policy_exists(p, filter)) | |
9148 | vty_out(vty, | |
9149 | " Inbound updates discarded due to missing policy\n"); | |
9150 | ||
9151 | /* ebgp-requires-policy (outbound) */ | |
9152 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
9153 | && !bgp_outbound_policy_exists(p, filter)) | |
9154 | vty_out(vty, | |
9155 | " Outbound updates discarded due to missing policy\n"); | |
9156 | ||
d62a17ae | 9157 | /* unsuppress-map */ |
9158 | if (filter->usmap.name) | |
9159 | vty_out(vty, | |
9160 | " Route map for selective unsuppress is %s%s\n", | |
9161 | filter->usmap.map ? "*" : "", | |
9162 | filter->usmap.name); | |
9163 | ||
9164 | /* Receive prefix count */ | |
9165 | vty_out(vty, " %ld accepted prefixes\n", p->pcount[afi][safi]); | |
9166 | ||
9167 | /* Maximum prefix */ | |
9168 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
9169 | vty_out(vty, " Maximum prefixes allowed %ld%s\n", | |
9170 | p->pmax[afi][safi], | |
9171 | CHECK_FLAG(p->af_flags[afi][safi], | |
9172 | PEER_FLAG_MAX_PREFIX_WARNING) | |
9173 | ? " (warning-only)" | |
9174 | : ""); | |
9175 | vty_out(vty, " Threshold for warning message %d%%", | |
9176 | p->pmax_threshold[afi][safi]); | |
9177 | if (p->pmax_restart[afi][safi]) | |
9178 | vty_out(vty, ", restart interval %d min", | |
9179 | p->pmax_restart[afi][safi]); | |
9180 | vty_out(vty, "\n"); | |
9181 | } | |
9182 | ||
9183 | vty_out(vty, "\n"); | |
9184 | } | |
9185 | } | |
9186 | ||
9f049418 | 9187 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 9188 | json_object *json) |
718e3744 | 9189 | { |
d62a17ae | 9190 | struct bgp *bgp; |
9191 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
9192 | char timebuf[BGP_UPTIME_LEN]; | |
9193 | char dn_flag[2]; | |
9194 | const char *subcode_str; | |
9195 | const char *code_str; | |
9196 | afi_t afi; | |
9197 | safi_t safi; | |
d7c0a89a QY |
9198 | uint16_t i; |
9199 | uint8_t *msg; | |
d62a17ae | 9200 | json_object *json_neigh = NULL; |
9201 | time_t epoch_tbuf; | |
718e3744 | 9202 | |
d62a17ae | 9203 | bgp = p->bgp; |
9204 | ||
9205 | if (use_json) | |
9206 | json_neigh = json_object_new_object(); | |
9207 | ||
9208 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
9209 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
9210 | dn_flag[0] = '*'; | |
9211 | ||
9212 | if (!use_json) { | |
9213 | if (p->conf_if) /* Configured interface name. */ | |
9214 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
9215 | BGP_PEER_SU_UNSPEC(p) | |
9216 | ? "None" | |
9217 | : sockunion2str(&p->su, buf, | |
9218 | SU_ADDRSTRLEN)); | |
9219 | else /* Configured IP address. */ | |
9220 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
9221 | p->host); | |
9222 | } | |
9223 | ||
9224 | if (use_json) { | |
9225 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
9226 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
9227 | "none"); | |
9228 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
9229 | json_object_string_add( | |
9230 | json_neigh, "bgpNeighborAddr", | |
9231 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
9232 | ||
9233 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
9234 | ||
9235 | if (p->change_local_as) | |
9236 | json_object_int_add(json_neigh, "localAs", | |
9237 | p->change_local_as); | |
9238 | else | |
9239 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
9240 | ||
9241 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
9242 | json_object_boolean_true_add(json_neigh, | |
9243 | "localAsNoPrepend"); | |
9244 | ||
9245 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
9246 | json_object_boolean_true_add(json_neigh, | |
9247 | "localAsReplaceAs"); | |
9248 | } else { | |
9249 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
9250 | || (p->as_type == AS_INTERNAL)) | |
9251 | vty_out(vty, "remote AS %u, ", p->as); | |
9252 | else | |
9253 | vty_out(vty, "remote AS Unspecified, "); | |
9254 | vty_out(vty, "local AS %u%s%s, ", | |
9255 | p->change_local_as ? p->change_local_as : p->local_as, | |
9256 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
9257 | ? " no-prepend" | |
9258 | : "", | |
9259 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
9260 | ? " replace-as" | |
9261 | : ""); | |
9262 | } | |
faa16034 DS |
9263 | /* peer type internal or confed-internal */ |
9264 | if ((p->as == p->local_as) || (p->as_type == AS_INTERNAL)) { | |
d62a17ae | 9265 | if (use_json) { |
9266 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9267 | json_object_boolean_true_add( | |
9268 | json_neigh, "nbrConfedInternalLink"); | |
9269 | else | |
9270 | json_object_boolean_true_add(json_neigh, | |
9271 | "nbrInternalLink"); | |
9272 | } else { | |
9273 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9274 | vty_out(vty, "confed-internal link\n"); | |
9275 | else | |
9276 | vty_out(vty, "internal link\n"); | |
9277 | } | |
faa16034 DS |
9278 | /* peer type external or confed-external */ |
9279 | } else if (p->as || (p->as_type == AS_EXTERNAL)) { | |
d62a17ae | 9280 | if (use_json) { |
9281 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9282 | json_object_boolean_true_add( | |
9283 | json_neigh, "nbrConfedExternalLink"); | |
9284 | else | |
9285 | json_object_boolean_true_add(json_neigh, | |
9286 | "nbrExternalLink"); | |
9287 | } else { | |
9288 | if (bgp_confederation_peers_check(bgp, p->as)) | |
9289 | vty_out(vty, "confed-external link\n"); | |
9290 | else | |
9291 | vty_out(vty, "external link\n"); | |
9292 | } | |
faa16034 DS |
9293 | } else { |
9294 | if (use_json) | |
9295 | json_object_boolean_true_add(json_neigh, | |
9296 | "nbrUnspecifiedLink"); | |
9297 | else | |
9298 | vty_out(vty, "unspecified link\n"); | |
d62a17ae | 9299 | } |
9300 | ||
9301 | /* Description. */ | |
9302 | if (p->desc) { | |
9303 | if (use_json) | |
9304 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
9305 | else | |
9306 | vty_out(vty, " Description: %s\n", p->desc); | |
9307 | } | |
9308 | ||
9309 | if (p->hostname) { | |
9310 | if (use_json) { | |
9311 | if (p->hostname) | |
9312 | json_object_string_add(json_neigh, "hostname", | |
9313 | p->hostname); | |
9314 | ||
9315 | if (p->domainname) | |
9316 | json_object_string_add(json_neigh, "domainname", | |
9317 | p->domainname); | |
9318 | } else { | |
9319 | if (p->domainname && (p->domainname[0] != '\0')) | |
9320 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
9321 | p->domainname); | |
9322 | else | |
9323 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
9324 | } | |
9325 | } | |
9326 | ||
9327 | /* Peer-group */ | |
9328 | if (p->group) { | |
9329 | if (use_json) { | |
9330 | json_object_string_add(json_neigh, "peerGroup", | |
9331 | p->group->name); | |
9332 | ||
9333 | if (dn_flag[0]) { | |
9334 | struct prefix prefix, *range = NULL; | |
9335 | ||
9336 | sockunion2hostprefix(&(p->su), &prefix); | |
9337 | range = peer_group_lookup_dynamic_neighbor_range( | |
9338 | p->group, &prefix); | |
9339 | ||
9340 | if (range) { | |
9341 | prefix2str(range, buf1, sizeof(buf1)); | |
9342 | json_object_string_add( | |
9343 | json_neigh, | |
9344 | "peerSubnetRangeGroup", buf1); | |
9345 | } | |
9346 | } | |
9347 | } else { | |
9348 | vty_out(vty, | |
9349 | " Member of peer-group %s for session parameters\n", | |
9350 | p->group->name); | |
9351 | ||
9352 | if (dn_flag[0]) { | |
9353 | struct prefix prefix, *range = NULL; | |
9354 | ||
9355 | sockunion2hostprefix(&(p->su), &prefix); | |
9356 | range = peer_group_lookup_dynamic_neighbor_range( | |
9357 | p->group, &prefix); | |
9358 | ||
9359 | if (range) { | |
9360 | prefix2str(range, buf1, sizeof(buf1)); | |
9361 | vty_out(vty, | |
9362 | " Belongs to the subnet range group: %s\n", | |
9363 | buf1); | |
9364 | } | |
9365 | } | |
9366 | } | |
9367 | } | |
9368 | ||
9369 | if (use_json) { | |
9370 | /* Administrative shutdown. */ | |
9371 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
9372 | json_object_boolean_true_add(json_neigh, | |
9373 | "adminShutDown"); | |
9374 | ||
9375 | /* BGP Version. */ | |
9376 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
9377 | json_object_string_add( | |
9378 | json_neigh, "remoteRouterId", | |
9379 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
d0086e8e AD |
9380 | json_object_string_add( |
9381 | json_neigh, "localRouterId", | |
9382 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
9383 | sizeof(buf1))); | |
d62a17ae | 9384 | |
9385 | /* Confederation */ | |
9386 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
9387 | && bgp_confederation_peers_check(bgp, p->as)) | |
9388 | json_object_boolean_true_add(json_neigh, | |
9389 | "nbrCommonAdmin"); | |
9390 | ||
9391 | /* Status. */ | |
9392 | json_object_string_add( | |
9393 | json_neigh, "bgpState", | |
9394 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
9395 | ||
9396 | if (p->status == Established) { | |
9397 | time_t uptime; | |
d62a17ae | 9398 | |
9399 | uptime = bgp_clock(); | |
9400 | uptime -= p->uptime; | |
d62a17ae | 9401 | epoch_tbuf = time(NULL) - uptime; |
9402 | ||
bee57a7a | 9403 | #if CONFDATE > 20200101 |
a4d82a8a PZ |
9404 | CPP_NOTICE( |
9405 | "bgpTimerUp should be deprecated and can be removed now"); | |
d3c7efed DS |
9406 | #endif |
9407 | /* | |
9408 | * bgpTimerUp was miliseconds that was accurate | |
9409 | * up to 1 day, then the value returned | |
9410 | * became garbage. So in order to provide | |
9411 | * some level of backwards compatability, | |
9412 | * we still provde the data, but now | |
9413 | * we are returning the correct value | |
9414 | * and also adding a new bgpTimerUpMsec | |
9415 | * which will allow us to deprecate | |
9416 | * this eventually | |
9417 | */ | |
d62a17ae | 9418 | json_object_int_add(json_neigh, "bgpTimerUp", |
e0330274 | 9419 | uptime * 1000); |
d3c7efed DS |
9420 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
9421 | uptime * 1000); | |
d62a17ae | 9422 | json_object_string_add(json_neigh, "bgpTimerUpString", |
9423 | peer_uptime(p->uptime, timebuf, | |
9424 | BGP_UPTIME_LEN, 0, | |
9425 | NULL)); | |
9426 | json_object_int_add(json_neigh, | |
9427 | "bgpTimerUpEstablishedEpoch", | |
9428 | epoch_tbuf); | |
9429 | } | |
9430 | ||
9431 | else if (p->status == Active) { | |
9432 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
9433 | json_object_string_add(json_neigh, "bgpStateIs", | |
9434 | "passive"); | |
9435 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
9436 | json_object_string_add(json_neigh, "bgpStateIs", | |
9437 | "passiveNSF"); | |
9438 | } | |
9439 | ||
9440 | /* read timer */ | |
9441 | time_t uptime; | |
9442 | struct tm *tm; | |
9443 | ||
9444 | uptime = bgp_clock(); | |
9445 | uptime -= p->readtime; | |
9446 | tm = gmtime(&uptime); | |
9447 | json_object_int_add(json_neigh, "bgpTimerLastRead", | |
9448 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9449 | + (tm->tm_hour * 3600000)); | |
9450 | ||
9451 | uptime = bgp_clock(); | |
9452 | uptime -= p->last_write; | |
9453 | tm = gmtime(&uptime); | |
9454 | json_object_int_add(json_neigh, "bgpTimerLastWrite", | |
9455 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9456 | + (tm->tm_hour * 3600000)); | |
9457 | ||
9458 | uptime = bgp_clock(); | |
9459 | uptime -= p->update_time; | |
9460 | tm = gmtime(&uptime); | |
9461 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", | |
9462 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9463 | + (tm->tm_hour * 3600000)); | |
9464 | ||
9465 | /* Configured timer values. */ | |
9466 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
9467 | p->v_holdtime * 1000); | |
9468 | json_object_int_add(json_neigh, | |
9469 | "bgpTimerKeepAliveIntervalMsecs", | |
9470 | p->v_keepalive * 1000); | |
b90a8e13 | 9471 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 9472 | json_object_int_add(json_neigh, |
9473 | "bgpTimerConfiguredHoldTimeMsecs", | |
9474 | p->holdtime * 1000); | |
9475 | json_object_int_add( | |
9476 | json_neigh, | |
9477 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
9478 | p->keepalive * 1000); | |
d25e4efc | 9479 | } else if ((bgp->default_holdtime != BGP_DEFAULT_HOLDTIME) |
a4d82a8a PZ |
9480 | || (bgp->default_keepalive |
9481 | != BGP_DEFAULT_KEEPALIVE)) { | |
d25e4efc DS |
9482 | json_object_int_add(json_neigh, |
9483 | "bgpTimerConfiguredHoldTimeMsecs", | |
9484 | bgp->default_holdtime); | |
9485 | json_object_int_add( | |
9486 | json_neigh, | |
9487 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
9488 | bgp->default_keepalive); | |
d62a17ae | 9489 | } |
9490 | } else { | |
9491 | /* Administrative shutdown. */ | |
9492 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
9493 | vty_out(vty, " Administratively shut down\n"); | |
9494 | ||
9495 | /* BGP Version. */ | |
9496 | vty_out(vty, " BGP version 4"); | |
0e38aeb4 | 9497 | vty_out(vty, ", remote router ID %s", |
d62a17ae | 9498 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
0e38aeb4 AD |
9499 | vty_out(vty, ", local router ID %s\n", |
9500 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
9501 | sizeof(buf1))); | |
d62a17ae | 9502 | |
9503 | /* Confederation */ | |
9504 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
9505 | && bgp_confederation_peers_check(bgp, p->as)) | |
9506 | vty_out(vty, | |
9507 | " Neighbor under common administration\n"); | |
9508 | ||
9509 | /* Status. */ | |
9510 | vty_out(vty, " BGP state = %s", | |
9511 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
9512 | ||
9513 | if (p->status == Established) | |
9514 | vty_out(vty, ", up for %8s", | |
9515 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
9516 | 0, NULL)); | |
9517 | ||
9518 | else if (p->status == Active) { | |
9519 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
9520 | vty_out(vty, " (passive)"); | |
9521 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
9522 | vty_out(vty, " (NSF passive)"); | |
9523 | } | |
9524 | vty_out(vty, "\n"); | |
9525 | ||
9526 | /* read timer */ | |
9527 | vty_out(vty, " Last read %s", | |
9528 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
9529 | NULL)); | |
9530 | vty_out(vty, ", Last write %s\n", | |
9531 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
9532 | NULL)); | |
9533 | ||
9534 | /* Configured timer values. */ | |
9535 | vty_out(vty, | |
9536 | " Hold time is %d, keepalive interval is %d seconds\n", | |
9537 | p->v_holdtime, p->v_keepalive); | |
b90a8e13 | 9538 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 9539 | vty_out(vty, " Configured hold time is %d", |
9540 | p->holdtime); | |
9541 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
9542 | p->keepalive); | |
d25e4efc | 9543 | } else if ((bgp->default_holdtime != BGP_DEFAULT_HOLDTIME) |
a4d82a8a PZ |
9544 | || (bgp->default_keepalive |
9545 | != BGP_DEFAULT_KEEPALIVE)) { | |
d25e4efc DS |
9546 | vty_out(vty, " Configured hold time is %d", |
9547 | bgp->default_holdtime); | |
9548 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
9549 | bgp->default_keepalive); | |
d62a17ae | 9550 | } |
9551 | } | |
9552 | /* Capability. */ | |
9553 | if (p->status == Established) { | |
9554 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] | |
9555 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
9556 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
9557 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
9558 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
9559 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
9560 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
9561 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
9562 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
9563 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
9564 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
9565 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
7c40bf39 | 9566 | || p->afc_adv[AFI_IP6][SAFI_FLOWSPEC] |
9567 | || p->afc_recv[AFI_IP6][SAFI_FLOWSPEC] | |
d62a17ae | 9568 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
9569 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
7c40bf39 | 9570 | || p->afc_adv[AFI_IP][SAFI_FLOWSPEC] |
9571 | || p->afc_recv[AFI_IP][SAFI_FLOWSPEC] | |
d62a17ae | 9572 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
9573 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
9574 | if (use_json) { | |
9575 | json_object *json_cap = NULL; | |
9576 | ||
9577 | json_cap = json_object_new_object(); | |
9578 | ||
9579 | /* AS4 */ | |
9580 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
9581 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
9582 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
9583 | && CHECK_FLAG(p->cap, | |
9584 | PEER_CAP_AS4_RCV)) | |
9585 | json_object_string_add( | |
9586 | json_cap, "4byteAs", | |
9587 | "advertisedAndReceived"); | |
9588 | else if (CHECK_FLAG(p->cap, | |
9589 | PEER_CAP_AS4_ADV)) | |
9590 | json_object_string_add( | |
9591 | json_cap, "4byteAs", | |
9592 | "advertised"); | |
9593 | else if (CHECK_FLAG(p->cap, | |
9594 | PEER_CAP_AS4_RCV)) | |
9595 | json_object_string_add( | |
9596 | json_cap, "4byteAs", | |
9597 | "received"); | |
9598 | } | |
9599 | ||
9600 | /* AddPath */ | |
9601 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
9602 | || CHECK_FLAG(p->cap, | |
9603 | PEER_CAP_ADDPATH_ADV)) { | |
9604 | json_object *json_add = NULL; | |
9605 | const char *print_store; | |
9606 | ||
9607 | json_add = json_object_new_object(); | |
9608 | ||
05c7a1cc QY |
9609 | FOREACH_AFI_SAFI (afi, safi) { |
9610 | json_object *json_sub = NULL; | |
9611 | json_sub = | |
9612 | json_object_new_object(); | |
9613 | print_store = afi_safi_print( | |
9614 | afi, safi); | |
d62a17ae | 9615 | |
05c7a1cc QY |
9616 | if (CHECK_FLAG( |
9617 | p->af_cap[afi] | |
9618 | [safi], | |
9619 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9620 | || CHECK_FLAG( | |
9621 | p->af_cap[afi] | |
9622 | [safi], | |
9623 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 9624 | if (CHECK_FLAG( |
9625 | p->af_cap | |
9626 | [afi] | |
9627 | [safi], | |
9628 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 9629 | && CHECK_FLAG( |
d62a17ae | 9630 | p->af_cap |
9631 | [afi] | |
9632 | [safi], | |
05c7a1cc QY |
9633 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
9634 | json_object_boolean_true_add( | |
9635 | json_sub, | |
9636 | "txAdvertisedAndReceived"); | |
9637 | else if ( | |
9638 | CHECK_FLAG( | |
9639 | p->af_cap | |
9640 | [afi] | |
9641 | [safi], | |
9642 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
9643 | json_object_boolean_true_add( | |
9644 | json_sub, | |
9645 | "txAdvertised"); | |
9646 | else if ( | |
9647 | CHECK_FLAG( | |
9648 | p->af_cap | |
9649 | [afi] | |
9650 | [safi], | |
9651 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
9652 | json_object_boolean_true_add( | |
9653 | json_sub, | |
9654 | "txReceived"); | |
9655 | } | |
d62a17ae | 9656 | |
05c7a1cc QY |
9657 | if (CHECK_FLAG( |
9658 | p->af_cap[afi] | |
9659 | [safi], | |
9660 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9661 | || CHECK_FLAG( | |
9662 | p->af_cap[afi] | |
9663 | [safi], | |
9664 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 9665 | if (CHECK_FLAG( |
9666 | p->af_cap | |
9667 | [afi] | |
9668 | [safi], | |
9669 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 9670 | && CHECK_FLAG( |
d62a17ae | 9671 | p->af_cap |
9672 | [afi] | |
9673 | [safi], | |
9674 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
9675 | json_object_boolean_true_add( |
9676 | json_sub, | |
9677 | "rxAdvertisedAndReceived"); | |
9678 | else if ( | |
9679 | CHECK_FLAG( | |
9680 | p->af_cap | |
9681 | [afi] | |
9682 | [safi], | |
9683 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
9684 | json_object_boolean_true_add( | |
9685 | json_sub, | |
9686 | "rxAdvertised"); | |
9687 | else if ( | |
9688 | CHECK_FLAG( | |
9689 | p->af_cap | |
9690 | [afi] | |
9691 | [safi], | |
9692 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
9693 | json_object_boolean_true_add( | |
9694 | json_sub, | |
9695 | "rxReceived"); | |
d62a17ae | 9696 | } |
9697 | ||
05c7a1cc QY |
9698 | if (CHECK_FLAG( |
9699 | p->af_cap[afi] | |
9700 | [safi], | |
9701 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9702 | || CHECK_FLAG( | |
9703 | p->af_cap[afi] | |
9704 | [safi], | |
9705 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
9706 | || CHECK_FLAG( | |
9707 | p->af_cap[afi] | |
9708 | [safi], | |
9709 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9710 | || CHECK_FLAG( | |
9711 | p->af_cap[afi] | |
9712 | [safi], | |
9713 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
9714 | json_object_object_add( | |
9715 | json_add, | |
9716 | print_store, | |
9717 | json_sub); | |
9718 | else | |
9719 | json_object_free( | |
9720 | json_sub); | |
9721 | } | |
9722 | ||
d62a17ae | 9723 | json_object_object_add( |
9724 | json_cap, "addPath", json_add); | |
9725 | } | |
9726 | ||
9727 | /* Dynamic */ | |
9728 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
9729 | || CHECK_FLAG(p->cap, | |
9730 | PEER_CAP_DYNAMIC_ADV)) { | |
9731 | if (CHECK_FLAG(p->cap, | |
9732 | PEER_CAP_DYNAMIC_ADV) | |
9733 | && CHECK_FLAG(p->cap, | |
9734 | PEER_CAP_DYNAMIC_RCV)) | |
9735 | json_object_string_add( | |
9736 | json_cap, "dynamic", | |
9737 | "advertisedAndReceived"); | |
9738 | else if (CHECK_FLAG( | |
9739 | p->cap, | |
9740 | PEER_CAP_DYNAMIC_ADV)) | |
9741 | json_object_string_add( | |
9742 | json_cap, "dynamic", | |
9743 | "advertised"); | |
9744 | else if (CHECK_FLAG( | |
9745 | p->cap, | |
9746 | PEER_CAP_DYNAMIC_RCV)) | |
9747 | json_object_string_add( | |
9748 | json_cap, "dynamic", | |
9749 | "received"); | |
9750 | } | |
9751 | ||
9752 | /* Extended nexthop */ | |
9753 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
9754 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
9755 | json_object *json_nxt = NULL; | |
9756 | const char *print_store; | |
9757 | ||
9758 | ||
9759 | if (CHECK_FLAG(p->cap, | |
9760 | PEER_CAP_ENHE_ADV) | |
9761 | && CHECK_FLAG(p->cap, | |
9762 | PEER_CAP_ENHE_RCV)) | |
9763 | json_object_string_add( | |
9764 | json_cap, | |
9765 | "extendedNexthop", | |
9766 | "advertisedAndReceived"); | |
9767 | else if (CHECK_FLAG(p->cap, | |
9768 | PEER_CAP_ENHE_ADV)) | |
9769 | json_object_string_add( | |
9770 | json_cap, | |
9771 | "extendedNexthop", | |
9772 | "advertised"); | |
9773 | else if (CHECK_FLAG(p->cap, | |
9774 | PEER_CAP_ENHE_RCV)) | |
9775 | json_object_string_add( | |
9776 | json_cap, | |
9777 | "extendedNexthop", | |
9778 | "received"); | |
9779 | ||
9780 | if (CHECK_FLAG(p->cap, | |
9781 | PEER_CAP_ENHE_RCV)) { | |
9782 | json_nxt = | |
9783 | json_object_new_object(); | |
9784 | ||
9785 | for (safi = SAFI_UNICAST; | |
9786 | safi < SAFI_MAX; safi++) { | |
9787 | if (CHECK_FLAG( | |
9788 | p->af_cap | |
9789 | [AFI_IP] | |
9790 | [safi], | |
9791 | PEER_CAP_ENHE_AF_RCV)) { | |
9792 | print_store = afi_safi_print( | |
9793 | AFI_IP, | |
9794 | safi); | |
9795 | json_object_string_add( | |
9796 | json_nxt, | |
9797 | print_store, | |
54f29523 | 9798 | "recieved"); /* misspelled for compatibility */ |
d62a17ae | 9799 | } |
9800 | } | |
9801 | json_object_object_add( | |
9802 | json_cap, | |
9803 | "extendedNexthopFamililesByPeer", | |
9804 | json_nxt); | |
9805 | } | |
9806 | } | |
9807 | ||
9808 | /* Route Refresh */ | |
9809 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
9810 | || CHECK_FLAG(p->cap, | |
9811 | PEER_CAP_REFRESH_NEW_RCV) | |
9812 | || CHECK_FLAG(p->cap, | |
9813 | PEER_CAP_REFRESH_OLD_RCV)) { | |
9814 | if (CHECK_FLAG(p->cap, | |
9815 | PEER_CAP_REFRESH_ADV) | |
9816 | && (CHECK_FLAG( | |
9817 | p->cap, | |
9818 | PEER_CAP_REFRESH_NEW_RCV) | |
9819 | || CHECK_FLAG( | |
9820 | p->cap, | |
9821 | PEER_CAP_REFRESH_OLD_RCV))) { | |
9822 | if (CHECK_FLAG( | |
9823 | p->cap, | |
9824 | PEER_CAP_REFRESH_OLD_RCV) | |
9825 | && CHECK_FLAG( | |
9826 | p->cap, | |
9827 | PEER_CAP_REFRESH_NEW_RCV)) | |
9828 | json_object_string_add( | |
9829 | json_cap, | |
9830 | "routeRefresh", | |
9831 | "advertisedAndReceivedOldNew"); | |
9832 | else { | |
9833 | if (CHECK_FLAG( | |
9834 | p->cap, | |
9835 | PEER_CAP_REFRESH_OLD_RCV)) | |
9836 | json_object_string_add( | |
9837 | json_cap, | |
9838 | "routeRefresh", | |
9839 | "advertisedAndReceivedOld"); | |
9840 | else | |
9841 | json_object_string_add( | |
9842 | json_cap, | |
9843 | "routeRefresh", | |
9844 | "advertisedAndReceivedNew"); | |
9845 | } | |
9846 | } else if ( | |
9847 | CHECK_FLAG( | |
9848 | p->cap, | |
9849 | PEER_CAP_REFRESH_ADV)) | |
9850 | json_object_string_add( | |
9851 | json_cap, | |
9852 | "routeRefresh", | |
9853 | "advertised"); | |
9854 | else if ( | |
9855 | CHECK_FLAG( | |
9856 | p->cap, | |
9857 | PEER_CAP_REFRESH_NEW_RCV) | |
9858 | || CHECK_FLAG( | |
9859 | p->cap, | |
9860 | PEER_CAP_REFRESH_OLD_RCV)) | |
9861 | json_object_string_add( | |
9862 | json_cap, | |
9863 | "routeRefresh", | |
9864 | "received"); | |
9865 | } | |
9866 | ||
9867 | /* Multiprotocol Extensions */ | |
9868 | json_object *json_multi = NULL; | |
9869 | json_multi = json_object_new_object(); | |
9870 | ||
05c7a1cc QY |
9871 | FOREACH_AFI_SAFI (afi, safi) { |
9872 | if (p->afc_adv[afi][safi] | |
9873 | || p->afc_recv[afi][safi]) { | |
9874 | json_object *json_exten = NULL; | |
9875 | json_exten = | |
9876 | json_object_new_object(); | |
9877 | ||
d62a17ae | 9878 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
9879 | && p->afc_recv[afi][safi]) |
9880 | json_object_boolean_true_add( | |
9881 | json_exten, | |
9882 | "advertisedAndReceived"); | |
9883 | else if (p->afc_adv[afi][safi]) | |
9884 | json_object_boolean_true_add( | |
9885 | json_exten, | |
9886 | "advertised"); | |
9887 | else if (p->afc_recv[afi][safi]) | |
9888 | json_object_boolean_true_add( | |
9889 | json_exten, | |
9890 | "received"); | |
d62a17ae | 9891 | |
05c7a1cc QY |
9892 | json_object_object_add( |
9893 | json_multi, | |
9894 | afi_safi_print(afi, | |
9895 | safi), | |
9896 | json_exten); | |
d62a17ae | 9897 | } |
9898 | } | |
9899 | json_object_object_add( | |
9900 | json_cap, "multiprotocolExtensions", | |
9901 | json_multi); | |
9902 | ||
d77114b7 | 9903 | /* Hostname capabilities */ |
60466a63 | 9904 | json_object *json_hname = NULL; |
d77114b7 MK |
9905 | |
9906 | json_hname = json_object_new_object(); | |
9907 | ||
9908 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
9909 | json_object_string_add( | |
60466a63 QY |
9910 | json_hname, "advHostName", |
9911 | bgp->peer_self->hostname | |
9912 | ? bgp->peer_self | |
9913 | ->hostname | |
d77114b7 MK |
9914 | : "n/a"); |
9915 | json_object_string_add( | |
60466a63 QY |
9916 | json_hname, "advDomainName", |
9917 | bgp->peer_self->domainname | |
9918 | ? bgp->peer_self | |
9919 | ->domainname | |
d77114b7 MK |
9920 | : "n/a"); |
9921 | } | |
9922 | ||
9923 | ||
9924 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
9925 | json_object_string_add( | |
60466a63 QY |
9926 | json_hname, "rcvHostName", |
9927 | p->hostname ? p->hostname | |
9928 | : "n/a"); | |
d77114b7 | 9929 | json_object_string_add( |
60466a63 QY |
9930 | json_hname, "rcvDomainName", |
9931 | p->domainname ? p->domainname | |
9932 | : "n/a"); | |
d77114b7 MK |
9933 | } |
9934 | ||
60466a63 | 9935 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
9936 | json_hname); |
9937 | ||
d62a17ae | 9938 | /* Gracefull Restart */ |
9939 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
9940 | || CHECK_FLAG(p->cap, | |
9941 | PEER_CAP_RESTART_ADV)) { | |
9942 | if (CHECK_FLAG(p->cap, | |
9943 | PEER_CAP_RESTART_ADV) | |
9944 | && CHECK_FLAG(p->cap, | |
9945 | PEER_CAP_RESTART_RCV)) | |
9946 | json_object_string_add( | |
9947 | json_cap, | |
9948 | "gracefulRestart", | |
9949 | "advertisedAndReceived"); | |
9950 | else if (CHECK_FLAG( | |
9951 | p->cap, | |
9952 | PEER_CAP_RESTART_ADV)) | |
9953 | json_object_string_add( | |
9954 | json_cap, | |
9955 | "gracefulRestartCapability", | |
9956 | "advertised"); | |
9957 | else if (CHECK_FLAG( | |
9958 | p->cap, | |
9959 | PEER_CAP_RESTART_RCV)) | |
9960 | json_object_string_add( | |
9961 | json_cap, | |
9962 | "gracefulRestartCapability", | |
9963 | "received"); | |
9964 | ||
9965 | if (CHECK_FLAG(p->cap, | |
9966 | PEER_CAP_RESTART_RCV)) { | |
9967 | int restart_af_count = 0; | |
9968 | json_object *json_restart = | |
9969 | NULL; | |
9970 | json_restart = | |
9971 | json_object_new_object(); | |
9972 | ||
9973 | json_object_int_add( | |
9974 | json_cap, | |
9975 | "gracefulRestartRemoteTimerMsecs", | |
9976 | p->v_gr_restart * 1000); | |
9977 | ||
05c7a1cc QY |
9978 | FOREACH_AFI_SAFI (afi, safi) { |
9979 | if (CHECK_FLAG( | |
9980 | p->af_cap | |
9981 | [afi] | |
9982 | [safi], | |
9983 | PEER_CAP_RESTART_AF_RCV)) { | |
9984 | json_object * | |
9985 | json_sub = | |
9986 | NULL; | |
9987 | json_sub = | |
9988 | json_object_new_object(); | |
9989 | ||
d62a17ae | 9990 | if (CHECK_FLAG( |
9991 | p->af_cap | |
9992 | [afi] | |
9993 | [safi], | |
05c7a1cc QY |
9994 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
9995 | json_object_boolean_true_add( | |
9996 | json_sub, | |
9997 | "preserved"); | |
9998 | restart_af_count++; | |
9999 | json_object_object_add( | |
10000 | json_restart, | |
10001 | afi_safi_print( | |
10002 | afi, | |
10003 | safi), | |
10004 | json_sub); | |
d62a17ae | 10005 | } |
10006 | } | |
10007 | if (!restart_af_count) { | |
10008 | json_object_string_add( | |
10009 | json_cap, | |
10010 | "addressFamiliesByPeer", | |
10011 | "none"); | |
10012 | json_object_free( | |
10013 | json_restart); | |
10014 | } else | |
10015 | json_object_object_add( | |
10016 | json_cap, | |
10017 | "addressFamiliesByPeer", | |
10018 | json_restart); | |
10019 | } | |
10020 | } | |
10021 | json_object_object_add(json_neigh, | |
10022 | "neighborCapabilities", | |
10023 | json_cap); | |
10024 | } else { | |
10025 | vty_out(vty, " Neighbor capabilities:\n"); | |
10026 | ||
10027 | /* AS4 */ | |
10028 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
10029 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
10030 | vty_out(vty, " 4 Byte AS:"); | |
10031 | if (CHECK_FLAG(p->cap, | |
10032 | PEER_CAP_AS4_ADV)) | |
10033 | vty_out(vty, " advertised"); | |
10034 | if (CHECK_FLAG(p->cap, | |
10035 | PEER_CAP_AS4_RCV)) | |
10036 | vty_out(vty, " %sreceived", | |
10037 | CHECK_FLAG( | |
10038 | p->cap, | |
10039 | PEER_CAP_AS4_ADV) | |
10040 | ? "and " | |
10041 | : ""); | |
10042 | vty_out(vty, "\n"); | |
10043 | } | |
10044 | ||
10045 | /* AddPath */ | |
10046 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
10047 | || CHECK_FLAG(p->cap, | |
10048 | PEER_CAP_ADDPATH_ADV)) { | |
10049 | vty_out(vty, " AddPath:\n"); | |
10050 | ||
05c7a1cc QY |
10051 | FOREACH_AFI_SAFI (afi, safi) { |
10052 | if (CHECK_FLAG( | |
10053 | p->af_cap[afi] | |
10054 | [safi], | |
10055 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
10056 | || CHECK_FLAG( | |
10057 | p->af_cap[afi] | |
10058 | [safi], | |
10059 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
10060 | vty_out(vty, | |
10061 | " %s: TX ", | |
10062 | afi_safi_print( | |
10063 | afi, | |
10064 | safi)); | |
10065 | ||
d62a17ae | 10066 | if (CHECK_FLAG( |
10067 | p->af_cap | |
10068 | [afi] | |
10069 | [safi], | |
05c7a1cc | 10070 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 10071 | vty_out(vty, |
05c7a1cc | 10072 | "advertised %s", |
d62a17ae | 10073 | afi_safi_print( |
10074 | afi, | |
10075 | safi)); | |
10076 | ||
05c7a1cc QY |
10077 | if (CHECK_FLAG( |
10078 | p->af_cap | |
10079 | [afi] | |
10080 | [safi], | |
10081 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
10082 | vty_out(vty, | |
10083 | "%sreceived", | |
10084 | CHECK_FLAG( | |
10085 | p->af_cap | |
10086 | [afi] | |
10087 | [safi], | |
10088 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
10089 | ? " and " | |
10090 | : ""); | |
d62a17ae | 10091 | |
05c7a1cc QY |
10092 | vty_out(vty, "\n"); |
10093 | } | |
d62a17ae | 10094 | |
05c7a1cc QY |
10095 | if (CHECK_FLAG( |
10096 | p->af_cap[afi] | |
10097 | [safi], | |
10098 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
10099 | || CHECK_FLAG( | |
10100 | p->af_cap[afi] | |
10101 | [safi], | |
10102 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
10103 | vty_out(vty, | |
10104 | " %s: RX ", | |
10105 | afi_safi_print( | |
10106 | afi, | |
10107 | safi)); | |
d62a17ae | 10108 | |
10109 | if (CHECK_FLAG( | |
10110 | p->af_cap | |
10111 | [afi] | |
10112 | [safi], | |
05c7a1cc | 10113 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 10114 | vty_out(vty, |
05c7a1cc | 10115 | "advertised %s", |
d62a17ae | 10116 | afi_safi_print( |
10117 | afi, | |
10118 | safi)); | |
10119 | ||
05c7a1cc QY |
10120 | if (CHECK_FLAG( |
10121 | p->af_cap | |
10122 | [afi] | |
10123 | [safi], | |
10124 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 10125 | vty_out(vty, |
05c7a1cc QY |
10126 | "%sreceived", |
10127 | CHECK_FLAG( | |
10128 | p->af_cap | |
10129 | [afi] | |
10130 | [safi], | |
10131 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
10132 | ? " and " | |
10133 | : ""); | |
10134 | ||
10135 | vty_out(vty, "\n"); | |
d62a17ae | 10136 | } |
05c7a1cc | 10137 | } |
d62a17ae | 10138 | } |
10139 | ||
10140 | /* Dynamic */ | |
10141 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
10142 | || CHECK_FLAG(p->cap, | |
10143 | PEER_CAP_DYNAMIC_ADV)) { | |
10144 | vty_out(vty, " Dynamic:"); | |
10145 | if (CHECK_FLAG(p->cap, | |
10146 | PEER_CAP_DYNAMIC_ADV)) | |
10147 | vty_out(vty, " advertised"); | |
10148 | if (CHECK_FLAG(p->cap, | |
10149 | PEER_CAP_DYNAMIC_RCV)) | |
10150 | vty_out(vty, " %sreceived", | |
10151 | CHECK_FLAG( | |
10152 | p->cap, | |
10153 | PEER_CAP_DYNAMIC_ADV) | |
10154 | ? "and " | |
10155 | : ""); | |
10156 | vty_out(vty, "\n"); | |
10157 | } | |
10158 | ||
10159 | /* Extended nexthop */ | |
10160 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
10161 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
10162 | vty_out(vty, " Extended nexthop:"); | |
10163 | if (CHECK_FLAG(p->cap, | |
10164 | PEER_CAP_ENHE_ADV)) | |
10165 | vty_out(vty, " advertised"); | |
10166 | if (CHECK_FLAG(p->cap, | |
10167 | PEER_CAP_ENHE_RCV)) | |
10168 | vty_out(vty, " %sreceived", | |
10169 | CHECK_FLAG( | |
10170 | p->cap, | |
10171 | PEER_CAP_ENHE_ADV) | |
10172 | ? "and " | |
10173 | : ""); | |
10174 | vty_out(vty, "\n"); | |
10175 | ||
10176 | if (CHECK_FLAG(p->cap, | |
10177 | PEER_CAP_ENHE_RCV)) { | |
10178 | vty_out(vty, | |
10179 | " Address families by peer:\n "); | |
10180 | for (safi = SAFI_UNICAST; | |
10181 | safi < SAFI_MAX; safi++) | |
10182 | if (CHECK_FLAG( | |
10183 | p->af_cap | |
10184 | [AFI_IP] | |
10185 | [safi], | |
10186 | PEER_CAP_ENHE_AF_RCV)) | |
10187 | vty_out(vty, | |
10188 | " %s\n", | |
10189 | afi_safi_print( | |
10190 | AFI_IP, | |
10191 | safi)); | |
10192 | } | |
10193 | } | |
10194 | ||
10195 | /* Route Refresh */ | |
10196 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
10197 | || CHECK_FLAG(p->cap, | |
10198 | PEER_CAP_REFRESH_NEW_RCV) | |
10199 | || CHECK_FLAG(p->cap, | |
10200 | PEER_CAP_REFRESH_OLD_RCV)) { | |
10201 | vty_out(vty, " Route refresh:"); | |
10202 | if (CHECK_FLAG(p->cap, | |
10203 | PEER_CAP_REFRESH_ADV)) | |
10204 | vty_out(vty, " advertised"); | |
10205 | if (CHECK_FLAG(p->cap, | |
10206 | PEER_CAP_REFRESH_NEW_RCV) | |
10207 | || CHECK_FLAG( | |
10208 | p->cap, | |
10209 | PEER_CAP_REFRESH_OLD_RCV)) | |
10210 | vty_out(vty, " %sreceived(%s)", | |
10211 | CHECK_FLAG( | |
10212 | p->cap, | |
10213 | PEER_CAP_REFRESH_ADV) | |
10214 | ? "and " | |
10215 | : "", | |
10216 | (CHECK_FLAG( | |
10217 | p->cap, | |
10218 | PEER_CAP_REFRESH_OLD_RCV) | |
10219 | && CHECK_FLAG( | |
10220 | p->cap, | |
10221 | PEER_CAP_REFRESH_NEW_RCV)) | |
10222 | ? "old & new" | |
10223 | : CHECK_FLAG( | |
10224 | p->cap, | |
10225 | PEER_CAP_REFRESH_OLD_RCV) | |
10226 | ? "old" | |
10227 | : "new"); | |
10228 | ||
10229 | vty_out(vty, "\n"); | |
10230 | } | |
10231 | ||
10232 | /* Multiprotocol Extensions */ | |
05c7a1cc QY |
10233 | FOREACH_AFI_SAFI (afi, safi) |
10234 | if (p->afc_adv[afi][safi] | |
10235 | || p->afc_recv[afi][safi]) { | |
10236 | vty_out(vty, | |
10237 | " Address Family %s:", | |
10238 | afi_safi_print(afi, | |
10239 | safi)); | |
10240 | if (p->afc_adv[afi][safi]) | |
d62a17ae | 10241 | vty_out(vty, |
05c7a1cc QY |
10242 | " advertised"); |
10243 | if (p->afc_recv[afi][safi]) | |
10244 | vty_out(vty, | |
10245 | " %sreceived", | |
10246 | p->afc_adv[afi] | |
10247 | [safi] | |
10248 | ? "and " | |
10249 | : ""); | |
10250 | vty_out(vty, "\n"); | |
10251 | } | |
d62a17ae | 10252 | |
10253 | /* Hostname capability */ | |
60466a63 | 10254 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
10255 | |
10256 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
10257 | vty_out(vty, |
10258 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
10259 | bgp->peer_self->hostname |
10260 | ? bgp->peer_self | |
10261 | ->hostname | |
d77114b7 | 10262 | : "n/a", |
60466a63 QY |
10263 | bgp->peer_self->domainname |
10264 | ? bgp->peer_self | |
10265 | ->domainname | |
d77114b7 MK |
10266 | : "n/a"); |
10267 | } else { | |
10268 | vty_out(vty, " not advertised"); | |
d62a17ae | 10269 | } |
10270 | ||
d77114b7 | 10271 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
10272 | vty_out(vty, |
10273 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
10274 | p->hostname ? p->hostname |
10275 | : "n/a", | |
10276 | p->domainname ? p->domainname | |
10277 | : "n/a"); | |
d77114b7 MK |
10278 | } else { |
10279 | vty_out(vty, " not received"); | |
10280 | } | |
10281 | ||
10282 | vty_out(vty, "\n"); | |
10283 | ||
d62a17ae | 10284 | /* Gracefull Restart */ |
10285 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
10286 | || CHECK_FLAG(p->cap, | |
10287 | PEER_CAP_RESTART_ADV)) { | |
10288 | vty_out(vty, | |
10289 | " Graceful Restart Capabilty:"); | |
10290 | if (CHECK_FLAG(p->cap, | |
10291 | PEER_CAP_RESTART_ADV)) | |
10292 | vty_out(vty, " advertised"); | |
10293 | if (CHECK_FLAG(p->cap, | |
10294 | PEER_CAP_RESTART_RCV)) | |
10295 | vty_out(vty, " %sreceived", | |
10296 | CHECK_FLAG( | |
10297 | p->cap, | |
10298 | PEER_CAP_RESTART_ADV) | |
10299 | ? "and " | |
10300 | : ""); | |
10301 | vty_out(vty, "\n"); | |
10302 | ||
10303 | if (CHECK_FLAG(p->cap, | |
10304 | PEER_CAP_RESTART_RCV)) { | |
10305 | int restart_af_count = 0; | |
10306 | ||
10307 | vty_out(vty, | |
10308 | " Remote Restart timer is %d seconds\n", | |
10309 | p->v_gr_restart); | |
10310 | vty_out(vty, | |
10311 | " Address families by peer:\n "); | |
10312 | ||
05c7a1cc QY |
10313 | FOREACH_AFI_SAFI (afi, safi) |
10314 | if (CHECK_FLAG( | |
10315 | p->af_cap | |
10316 | [afi] | |
10317 | [safi], | |
10318 | PEER_CAP_RESTART_AF_RCV)) { | |
10319 | vty_out(vty, | |
10320 | "%s%s(%s)", | |
10321 | restart_af_count | |
10322 | ? ", " | |
10323 | : "", | |
10324 | afi_safi_print( | |
10325 | afi, | |
10326 | safi), | |
10327 | CHECK_FLAG( | |
10328 | p->af_cap | |
10329 | [afi] | |
10330 | [safi], | |
10331 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
10332 | ? "preserved" | |
10333 | : "not preserved"); | |
10334 | restart_af_count++; | |
10335 | } | |
d62a17ae | 10336 | if (!restart_af_count) |
10337 | vty_out(vty, "none"); | |
10338 | vty_out(vty, "\n"); | |
10339 | } | |
10340 | } | |
10341 | } | |
10342 | } | |
10343 | } | |
10344 | ||
10345 | /* graceful restart information */ | |
10346 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) || p->t_gr_restart | |
10347 | || p->t_gr_stale) { | |
10348 | json_object *json_grace = NULL; | |
10349 | json_object *json_grace_send = NULL; | |
10350 | json_object *json_grace_recv = NULL; | |
10351 | int eor_send_af_count = 0; | |
10352 | int eor_receive_af_count = 0; | |
10353 | ||
10354 | if (use_json) { | |
10355 | json_grace = json_object_new_object(); | |
10356 | json_grace_send = json_object_new_object(); | |
10357 | json_grace_recv = json_object_new_object(); | |
10358 | ||
10359 | if (p->status == Established) { | |
05c7a1cc QY |
10360 | FOREACH_AFI_SAFI (afi, safi) { |
10361 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10362 | PEER_STATUS_EOR_SEND)) { | |
10363 | json_object_boolean_true_add( | |
10364 | json_grace_send, | |
10365 | afi_safi_print(afi, | |
10366 | safi)); | |
10367 | eor_send_af_count++; | |
d62a17ae | 10368 | } |
10369 | } | |
05c7a1cc QY |
10370 | FOREACH_AFI_SAFI (afi, safi) { |
10371 | if (CHECK_FLAG( | |
10372 | p->af_sflags[afi][safi], | |
10373 | PEER_STATUS_EOR_RECEIVED)) { | |
10374 | json_object_boolean_true_add( | |
10375 | json_grace_recv, | |
10376 | afi_safi_print(afi, | |
10377 | safi)); | |
10378 | eor_receive_af_count++; | |
d62a17ae | 10379 | } |
10380 | } | |
10381 | } | |
10382 | ||
10383 | json_object_object_add(json_grace, "endOfRibSend", | |
10384 | json_grace_send); | |
10385 | json_object_object_add(json_grace, "endOfRibRecv", | |
10386 | json_grace_recv); | |
10387 | ||
10388 | if (p->t_gr_restart) | |
10389 | json_object_int_add(json_grace, | |
10390 | "gracefulRestartTimerMsecs", | |
10391 | thread_timer_remain_second( | |
10392 | p->t_gr_restart) | |
10393 | * 1000); | |
10394 | ||
10395 | if (p->t_gr_stale) | |
10396 | json_object_int_add( | |
10397 | json_grace, | |
10398 | "gracefulStalepathTimerMsecs", | |
10399 | thread_timer_remain_second( | |
10400 | p->t_gr_stale) | |
10401 | * 1000); | |
10402 | ||
10403 | json_object_object_add( | |
10404 | json_neigh, "gracefulRestartInfo", json_grace); | |
10405 | } else { | |
0437e105 | 10406 | vty_out(vty, " Graceful restart information:\n"); |
d62a17ae | 10407 | if (p->status == Established) { |
10408 | vty_out(vty, " End-of-RIB send: "); | |
05c7a1cc QY |
10409 | FOREACH_AFI_SAFI (afi, safi) { |
10410 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10411 | PEER_STATUS_EOR_SEND)) { | |
10412 | vty_out(vty, "%s%s", | |
10413 | eor_send_af_count ? ", " | |
10414 | : "", | |
10415 | afi_safi_print(afi, | |
10416 | safi)); | |
10417 | eor_send_af_count++; | |
d62a17ae | 10418 | } |
10419 | } | |
10420 | vty_out(vty, "\n"); | |
10421 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
10422 | FOREACH_AFI_SAFI (afi, safi) { |
10423 | if (CHECK_FLAG( | |
10424 | p->af_sflags[afi][safi], | |
10425 | PEER_STATUS_EOR_RECEIVED)) { | |
10426 | vty_out(vty, "%s%s", | |
10427 | eor_receive_af_count | |
10428 | ? ", " | |
10429 | : "", | |
10430 | afi_safi_print(afi, | |
10431 | safi)); | |
10432 | eor_receive_af_count++; | |
d62a17ae | 10433 | } |
10434 | } | |
10435 | vty_out(vty, "\n"); | |
10436 | } | |
10437 | ||
10438 | if (p->t_gr_restart) | |
10439 | vty_out(vty, | |
10440 | " The remaining time of restart timer is %ld\n", | |
10441 | thread_timer_remain_second( | |
10442 | p->t_gr_restart)); | |
10443 | ||
10444 | if (p->t_gr_stale) | |
10445 | vty_out(vty, | |
10446 | " The remaining time of stalepath timer is %ld\n", | |
10447 | thread_timer_remain_second( | |
10448 | p->t_gr_stale)); | |
10449 | } | |
10450 | } | |
10451 | if (use_json) { | |
10452 | json_object *json_stat = NULL; | |
10453 | json_stat = json_object_new_object(); | |
10454 | /* Packet counts. */ | |
10455 | json_object_int_add(json_stat, "depthInq", 0); | |
10456 | json_object_int_add(json_stat, "depthOutq", | |
10457 | (unsigned long)p->obuf->count); | |
0112e9e0 QY |
10458 | json_object_int_add(json_stat, "opensSent", |
10459 | atomic_load_explicit(&p->open_out, | |
10460 | memory_order_relaxed)); | |
10461 | json_object_int_add(json_stat, "opensRecv", | |
10462 | atomic_load_explicit(&p->open_in, | |
10463 | memory_order_relaxed)); | |
d62a17ae | 10464 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
10465 | atomic_load_explicit(&p->notify_out, |
10466 | memory_order_relaxed)); | |
d62a17ae | 10467 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
10468 | atomic_load_explicit(&p->notify_in, |
10469 | memory_order_relaxed)); | |
10470 | json_object_int_add(json_stat, "updatesSent", | |
10471 | atomic_load_explicit(&p->update_out, | |
10472 | memory_order_relaxed)); | |
10473 | json_object_int_add(json_stat, "updatesRecv", | |
10474 | atomic_load_explicit(&p->update_in, | |
10475 | memory_order_relaxed)); | |
d62a17ae | 10476 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
10477 | atomic_load_explicit(&p->keepalive_out, |
10478 | memory_order_relaxed)); | |
d62a17ae | 10479 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
10480 | atomic_load_explicit(&p->keepalive_in, |
10481 | memory_order_relaxed)); | |
d62a17ae | 10482 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
10483 | atomic_load_explicit(&p->refresh_out, |
10484 | memory_order_relaxed)); | |
d62a17ae | 10485 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
10486 | atomic_load_explicit(&p->refresh_in, |
10487 | memory_order_relaxed)); | |
d62a17ae | 10488 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
10489 | atomic_load_explicit(&p->dynamic_cap_out, |
10490 | memory_order_relaxed)); | |
d62a17ae | 10491 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
10492 | atomic_load_explicit(&p->dynamic_cap_in, |
10493 | memory_order_relaxed)); | |
10494 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
10495 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 10496 | json_object_object_add(json_neigh, "messageStats", json_stat); |
10497 | } else { | |
10498 | /* Packet counts. */ | |
10499 | vty_out(vty, " Message statistics:\n"); | |
10500 | vty_out(vty, " Inq depth is 0\n"); | |
10501 | vty_out(vty, " Outq depth is %lu\n", | |
10502 | (unsigned long)p->obuf->count); | |
10503 | vty_out(vty, " Sent Rcvd\n"); | |
0112e9e0 QY |
10504 | vty_out(vty, " Opens: %10d %10d\n", |
10505 | atomic_load_explicit(&p->open_out, | |
10506 | memory_order_relaxed), | |
10507 | atomic_load_explicit(&p->open_in, | |
10508 | memory_order_relaxed)); | |
10509 | vty_out(vty, " Notifications: %10d %10d\n", | |
10510 | atomic_load_explicit(&p->notify_out, | |
10511 | memory_order_relaxed), | |
10512 | atomic_load_explicit(&p->notify_in, | |
10513 | memory_order_relaxed)); | |
10514 | vty_out(vty, " Updates: %10d %10d\n", | |
10515 | atomic_load_explicit(&p->update_out, | |
10516 | memory_order_relaxed), | |
10517 | atomic_load_explicit(&p->update_in, | |
10518 | memory_order_relaxed)); | |
10519 | vty_out(vty, " Keepalives: %10d %10d\n", | |
10520 | atomic_load_explicit(&p->keepalive_out, | |
10521 | memory_order_relaxed), | |
10522 | atomic_load_explicit(&p->keepalive_in, | |
10523 | memory_order_relaxed)); | |
10524 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
10525 | atomic_load_explicit(&p->refresh_out, | |
10526 | memory_order_relaxed), | |
10527 | atomic_load_explicit(&p->refresh_in, | |
10528 | memory_order_relaxed)); | |
d62a17ae | 10529 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
10530 | atomic_load_explicit(&p->dynamic_cap_out, |
10531 | memory_order_relaxed), | |
10532 | atomic_load_explicit(&p->dynamic_cap_in, | |
10533 | memory_order_relaxed)); | |
10534 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
10535 | PEER_TOTAL_RX(p)); | |
d62a17ae | 10536 | } |
10537 | ||
10538 | if (use_json) { | |
10539 | /* advertisement-interval */ | |
10540 | json_object_int_add(json_neigh, | |
10541 | "minBtwnAdvertisementRunsTimerMsecs", | |
10542 | p->v_routeadv * 1000); | |
10543 | ||
10544 | /* Update-source. */ | |
10545 | if (p->update_if || p->update_source) { | |
10546 | if (p->update_if) | |
10547 | json_object_string_add(json_neigh, | |
10548 | "updateSource", | |
10549 | p->update_if); | |
10550 | else if (p->update_source) | |
10551 | json_object_string_add( | |
10552 | json_neigh, "updateSource", | |
10553 | sockunion2str(p->update_source, buf1, | |
10554 | SU_ADDRSTRLEN)); | |
10555 | } | |
10556 | } else { | |
10557 | /* advertisement-interval */ | |
10558 | vty_out(vty, | |
10559 | " Minimum time between advertisement runs is %d seconds\n", | |
10560 | p->v_routeadv); | |
10561 | ||
10562 | /* Update-source. */ | |
10563 | if (p->update_if || p->update_source) { | |
10564 | vty_out(vty, " Update source is "); | |
10565 | if (p->update_if) | |
10566 | vty_out(vty, "%s", p->update_if); | |
10567 | else if (p->update_source) | |
10568 | vty_out(vty, "%s", | |
10569 | sockunion2str(p->update_source, buf1, | |
10570 | SU_ADDRSTRLEN)); | |
10571 | vty_out(vty, "\n"); | |
10572 | } | |
10573 | ||
10574 | vty_out(vty, "\n"); | |
10575 | } | |
10576 | ||
10577 | /* Address Family Information */ | |
10578 | json_object *json_hold = NULL; | |
10579 | ||
10580 | if (use_json) | |
10581 | json_hold = json_object_new_object(); | |
10582 | ||
05c7a1cc QY |
10583 | FOREACH_AFI_SAFI (afi, safi) |
10584 | if (p->afc[afi][safi]) | |
10585 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
10586 | json_hold); | |
d62a17ae | 10587 | |
10588 | if (use_json) { | |
10589 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
10590 | json_hold); | |
10591 | json_object_int_add(json_neigh, "connectionsEstablished", | |
10592 | p->established); | |
10593 | json_object_int_add(json_neigh, "connectionsDropped", | |
10594 | p->dropped); | |
10595 | } else | |
10596 | vty_out(vty, " Connections established %d; dropped %d\n", | |
10597 | p->established, p->dropped); | |
10598 | ||
10599 | if (!p->last_reset) { | |
10600 | if (use_json) | |
10601 | json_object_string_add(json_neigh, "lastReset", | |
10602 | "never"); | |
10603 | else | |
10604 | vty_out(vty, " Last reset never\n"); | |
10605 | } else { | |
10606 | if (use_json) { | |
10607 | time_t uptime; | |
10608 | struct tm *tm; | |
10609 | ||
10610 | uptime = bgp_clock(); | |
10611 | uptime -= p->resettime; | |
10612 | tm = gmtime(&uptime); | |
10613 | json_object_int_add(json_neigh, "lastResetTimerMsecs", | |
10614 | (tm->tm_sec * 1000) | |
10615 | + (tm->tm_min * 60000) | |
10616 | + (tm->tm_hour * 3600000)); | |
10617 | json_object_string_add( | |
10618 | json_neigh, "lastResetDueTo", | |
10619 | peer_down_str[(int)p->last_reset]); | |
10620 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND | |
10621 | || p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10622 | char errorcodesubcode_hexstr[5]; | |
10623 | char errorcodesubcode_str[256]; | |
10624 | ||
10625 | code_str = bgp_notify_code_str(p->notify.code); | |
10626 | subcode_str = bgp_notify_subcode_str( | |
10627 | p->notify.code, p->notify.subcode); | |
10628 | ||
10629 | sprintf(errorcodesubcode_hexstr, "%02X%02X", | |
10630 | p->notify.code, p->notify.subcode); | |
10631 | json_object_string_add(json_neigh, | |
10632 | "lastErrorCodeSubcode", | |
10633 | errorcodesubcode_hexstr); | |
10634 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
10635 | code_str, subcode_str); | |
10636 | json_object_string_add(json_neigh, | |
10637 | "lastNotificationReason", | |
10638 | errorcodesubcode_str); | |
10639 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
10640 | && p->notify.code == BGP_NOTIFY_CEASE | |
10641 | && (p->notify.subcode | |
10642 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
10643 | || p->notify.subcode | |
10644 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
10645 | && p->notify.length) { | |
10646 | char msgbuf[1024]; | |
10647 | const char *msg_str; | |
10648 | ||
10649 | msg_str = bgp_notify_admin_message( | |
10650 | msgbuf, sizeof(msgbuf), | |
d7c0a89a | 10651 | (uint8_t *)p->notify.data, |
d62a17ae | 10652 | p->notify.length); |
10653 | if (msg_str) | |
10654 | json_object_string_add( | |
10655 | json_neigh, | |
10656 | "lastShutdownDescription", | |
10657 | msg_str); | |
10658 | } | |
10659 | } | |
10660 | } else { | |
10661 | vty_out(vty, " Last reset %s, ", | |
10662 | peer_uptime(p->resettime, timebuf, | |
10663 | BGP_UPTIME_LEN, 0, NULL)); | |
10664 | ||
10665 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND | |
10666 | || p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10667 | code_str = bgp_notify_code_str(p->notify.code); | |
10668 | subcode_str = bgp_notify_subcode_str( | |
10669 | p->notify.code, p->notify.subcode); | |
10670 | vty_out(vty, "due to NOTIFICATION %s (%s%s)\n", | |
10671 | p->last_reset == PEER_DOWN_NOTIFY_SEND | |
10672 | ? "sent" | |
10673 | : "received", | |
10674 | code_str, subcode_str); | |
10675 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
10676 | && p->notify.code == BGP_NOTIFY_CEASE | |
10677 | && (p->notify.subcode | |
10678 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
10679 | || p->notify.subcode | |
10680 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
10681 | && p->notify.length) { | |
10682 | char msgbuf[1024]; | |
10683 | const char *msg_str; | |
10684 | ||
10685 | msg_str = bgp_notify_admin_message( | |
10686 | msgbuf, sizeof(msgbuf), | |
d7c0a89a | 10687 | (uint8_t *)p->notify.data, |
d62a17ae | 10688 | p->notify.length); |
10689 | if (msg_str) | |
10690 | vty_out(vty, | |
10691 | " Message: \"%s\"\n", | |
10692 | msg_str); | |
10693 | } | |
10694 | } else { | |
10695 | vty_out(vty, "due to %s\n", | |
10696 | peer_down_str[(int)p->last_reset]); | |
10697 | } | |
10698 | ||
10699 | if (p->last_reset_cause_size) { | |
10700 | msg = p->last_reset_cause; | |
10701 | vty_out(vty, | |
10702 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
10703 | for (i = 1; i <= p->last_reset_cause_size; | |
10704 | i++) { | |
10705 | vty_out(vty, "%02X", *msg++); | |
10706 | ||
10707 | if (i != p->last_reset_cause_size) { | |
10708 | if (i % 16 == 0) { | |
10709 | vty_out(vty, "\n "); | |
10710 | } else if (i % 4 == 0) { | |
10711 | vty_out(vty, " "); | |
10712 | } | |
10713 | } | |
10714 | } | |
10715 | vty_out(vty, "\n"); | |
10716 | } | |
10717 | } | |
10718 | } | |
10719 | ||
10720 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
10721 | if (use_json) | |
10722 | json_object_boolean_true_add(json_neigh, | |
10723 | "prefixesConfigExceedMax"); | |
10724 | else | |
10725 | vty_out(vty, | |
10726 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
10727 | ||
10728 | if (p->t_pmax_restart) { | |
10729 | if (use_json) { | |
10730 | json_object_boolean_true_add( | |
10731 | json_neigh, "reducePrefixNumFrom"); | |
10732 | json_object_int_add(json_neigh, | |
10733 | "restartInTimerMsec", | |
10734 | thread_timer_remain_second( | |
10735 | p->t_pmax_restart) | |
10736 | * 1000); | |
10737 | } else | |
10738 | vty_out(vty, | |
10739 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
10740 | p->host, thread_timer_remain_second( |
10741 | p->t_pmax_restart)); | |
d62a17ae | 10742 | } else { |
10743 | if (use_json) | |
10744 | json_object_boolean_true_add( | |
10745 | json_neigh, | |
10746 | "reducePrefixNumAndClearIpBgp"); | |
10747 | else | |
10748 | vty_out(vty, | |
10749 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
10750 | p->host); | |
10751 | } | |
10752 | } | |
10753 | ||
10754 | /* EBGP Multihop and GTSM */ | |
10755 | if (p->sort != BGP_PEER_IBGP) { | |
10756 | if (use_json) { | |
10757 | if (p->gtsm_hops > 0) | |
10758 | json_object_int_add(json_neigh, | |
10759 | "externalBgpNbrMaxHopsAway", | |
10760 | p->gtsm_hops); | |
10761 | else if (p->ttl > 1) | |
10762 | json_object_int_add(json_neigh, | |
10763 | "externalBgpNbrMaxHopsAway", | |
10764 | p->ttl); | |
10765 | } else { | |
10766 | if (p->gtsm_hops > 0) | |
10767 | vty_out(vty, | |
10768 | " External BGP neighbor may be up to %d hops away.\n", | |
10769 | p->gtsm_hops); | |
10770 | else if (p->ttl > 1) | |
10771 | vty_out(vty, | |
10772 | " External BGP neighbor may be up to %d hops away.\n", | |
10773 | p->ttl); | |
10774 | } | |
10775 | } else { | |
10776 | if (p->gtsm_hops > 0) { | |
10777 | if (use_json) | |
10778 | json_object_int_add(json_neigh, | |
10779 | "internalBgpNbrMaxHopsAway", | |
10780 | p->gtsm_hops); | |
10781 | else | |
10782 | vty_out(vty, | |
10783 | " Internal BGP neighbor may be up to %d hops away.\n", | |
10784 | p->gtsm_hops); | |
10785 | } | |
10786 | } | |
10787 | ||
10788 | /* Local address. */ | |
10789 | if (p->su_local) { | |
10790 | if (use_json) { | |
10791 | json_object_string_add(json_neigh, "hostLocal", | |
10792 | sockunion2str(p->su_local, buf1, | |
10793 | SU_ADDRSTRLEN)); | |
10794 | json_object_int_add(json_neigh, "portLocal", | |
10795 | ntohs(p->su_local->sin.sin_port)); | |
10796 | } else | |
10797 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
10798 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
10799 | ntohs(p->su_local->sin.sin_port)); | |
10800 | } | |
10801 | ||
10802 | /* Remote address. */ | |
10803 | if (p->su_remote) { | |
10804 | if (use_json) { | |
10805 | json_object_string_add(json_neigh, "hostForeign", | |
10806 | sockunion2str(p->su_remote, buf1, | |
10807 | SU_ADDRSTRLEN)); | |
10808 | json_object_int_add(json_neigh, "portForeign", | |
10809 | ntohs(p->su_remote->sin.sin_port)); | |
10810 | } else | |
10811 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
10812 | sockunion2str(p->su_remote, buf1, | |
10813 | SU_ADDRSTRLEN), | |
10814 | ntohs(p->su_remote->sin.sin_port)); | |
10815 | } | |
10816 | ||
10817 | /* Nexthop display. */ | |
10818 | if (p->su_local) { | |
10819 | if (use_json) { | |
10820 | json_object_string_add(json_neigh, "nexthop", | |
10821 | inet_ntop(AF_INET, | |
10822 | &p->nexthop.v4, buf1, | |
10823 | sizeof(buf1))); | |
10824 | json_object_string_add(json_neigh, "nexthopGlobal", | |
10825 | inet_ntop(AF_INET6, | |
10826 | &p->nexthop.v6_global, | |
10827 | buf1, sizeof(buf1))); | |
10828 | json_object_string_add(json_neigh, "nexthopLocal", | |
10829 | inet_ntop(AF_INET6, | |
10830 | &p->nexthop.v6_local, | |
10831 | buf1, sizeof(buf1))); | |
10832 | if (p->shared_network) | |
10833 | json_object_string_add(json_neigh, | |
10834 | "bgpConnection", | |
10835 | "sharedNetwork"); | |
10836 | else | |
10837 | json_object_string_add(json_neigh, | |
10838 | "bgpConnection", | |
10839 | "nonSharedNetwork"); | |
10840 | } else { | |
10841 | vty_out(vty, "Nexthop: %s\n", | |
10842 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
10843 | sizeof(buf1))); | |
10844 | vty_out(vty, "Nexthop global: %s\n", | |
10845 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
10846 | sizeof(buf1))); | |
10847 | vty_out(vty, "Nexthop local: %s\n", | |
10848 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
10849 | sizeof(buf1))); | |
10850 | vty_out(vty, "BGP connection: %s\n", | |
10851 | p->shared_network ? "shared network" | |
10852 | : "non shared network"); | |
10853 | } | |
10854 | } | |
10855 | ||
10856 | /* Timer information. */ | |
10857 | if (use_json) { | |
10858 | json_object_int_add(json_neigh, "connectRetryTimer", | |
10859 | p->v_connect); | |
10860 | if (p->status == Established && p->rtt) | |
10861 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
10862 | p->rtt); | |
10863 | if (p->t_start) | |
10864 | json_object_int_add( | |
10865 | json_neigh, "nextStartTimerDueInMsecs", | |
10866 | thread_timer_remain_second(p->t_start) * 1000); | |
10867 | if (p->t_connect) | |
10868 | json_object_int_add( | |
10869 | json_neigh, "nextConnectTimerDueInMsecs", | |
10870 | thread_timer_remain_second(p->t_connect) | |
10871 | * 1000); | |
10872 | if (p->t_routeadv) { | |
10873 | json_object_int_add(json_neigh, "mraiInterval", | |
10874 | p->v_routeadv); | |
10875 | json_object_int_add( | |
10876 | json_neigh, "mraiTimerExpireInMsecs", | |
10877 | thread_timer_remain_second(p->t_routeadv) | |
10878 | * 1000); | |
10879 | } | |
10880 | if (p->password) | |
10881 | json_object_int_add(json_neigh, "authenticationEnabled", | |
10882 | 1); | |
10883 | ||
10884 | if (p->t_read) | |
10885 | json_object_string_add(json_neigh, "readThread", "on"); | |
10886 | else | |
10887 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
10888 | |
10889 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 10890 | json_object_string_add(json_neigh, "writeThread", "on"); |
10891 | else | |
10892 | json_object_string_add(json_neigh, "writeThread", | |
10893 | "off"); | |
10894 | } else { | |
10895 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
10896 | p->v_connect); | |
10897 | if (p->status == Established && p->rtt) | |
10898 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
10899 | p->rtt); | |
10900 | if (p->t_start) | |
10901 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
10902 | thread_timer_remain_second(p->t_start)); | |
10903 | if (p->t_connect) | |
10904 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
10905 | thread_timer_remain_second(p->t_connect)); | |
10906 | if (p->t_routeadv) | |
10907 | vty_out(vty, | |
10908 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
10909 | p->v_routeadv, | |
10910 | thread_timer_remain_second(p->t_routeadv)); | |
10911 | if (p->password) | |
10912 | vty_out(vty, "Peer Authentication Enabled\n"); | |
10913 | ||
10914 | vty_out(vty, "Read thread: %s Write thread: %s\n", | |
49507a6f QY |
10915 | p->t_read ? "on" : "off", |
10916 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
10917 | ? "on" | |
10918 | : "off"); | |
d62a17ae | 10919 | } |
10920 | ||
10921 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
10922 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
10923 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
10924 | ||
10925 | if (!use_json) | |
10926 | vty_out(vty, "\n"); | |
10927 | ||
10928 | /* BFD information. */ | |
10929 | bgp_bfd_show_info(vty, p, use_json, json_neigh); | |
10930 | ||
10931 | if (use_json) { | |
10932 | if (p->conf_if) /* Configured interface name. */ | |
10933 | json_object_object_add(json, p->conf_if, json_neigh); | |
10934 | else /* Configured IP address. */ | |
10935 | json_object_object_add(json, p->host, json_neigh); | |
10936 | } | |
10937 | } | |
10938 | ||
10939 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, | |
10940 | enum show_type type, union sockunion *su, | |
9f049418 | 10941 | const char *conf_if, bool use_json, |
d62a17ae | 10942 | json_object *json) |
10943 | { | |
10944 | struct listnode *node, *nnode; | |
10945 | struct peer *peer; | |
10946 | int find = 0; | |
9f049418 | 10947 | bool nbr_output = false; |
d1927ebe AS |
10948 | afi_t afi = AFI_MAX; |
10949 | safi_t safi = SAFI_MAX; | |
10950 | ||
10951 | if (type == show_ipv4_peer || type == show_ipv4_all) { | |
10952 | afi = AFI_IP; | |
10953 | } else if (type == show_ipv6_peer || type == show_ipv6_all) { | |
10954 | afi = AFI_IP6; | |
10955 | } | |
d62a17ae | 10956 | |
10957 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
10958 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
10959 | continue; | |
10960 | ||
10961 | switch (type) { | |
10962 | case show_all: | |
10963 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 10964 | nbr_output = true; |
d62a17ae | 10965 | break; |
10966 | case show_peer: | |
10967 | if (conf_if) { | |
10968 | if ((peer->conf_if | |
10969 | && !strcmp(peer->conf_if, conf_if)) | |
10970 | || (peer->hostname | |
10971 | && !strcmp(peer->hostname, conf_if))) { | |
10972 | find = 1; | |
10973 | bgp_show_peer(vty, peer, use_json, | |
10974 | json); | |
10975 | } | |
10976 | } else { | |
10977 | if (sockunion_same(&peer->su, su)) { | |
10978 | find = 1; | |
10979 | bgp_show_peer(vty, peer, use_json, | |
10980 | json); | |
10981 | } | |
10982 | } | |
10983 | break; | |
d1927ebe AS |
10984 | case show_ipv4_peer: |
10985 | case show_ipv6_peer: | |
10986 | FOREACH_SAFI (safi) { | |
10987 | if (peer->afc[afi][safi]) { | |
10988 | if (conf_if) { | |
10989 | if ((peer->conf_if | |
10990 | && !strcmp(peer->conf_if, conf_if)) | |
10991 | || (peer->hostname | |
10992 | && !strcmp(peer->hostname, conf_if))) { | |
10993 | find = 1; | |
10994 | bgp_show_peer(vty, peer, use_json, | |
10995 | json); | |
10996 | break; | |
10997 | } | |
10998 | } else { | |
10999 | if (sockunion_same(&peer->su, su)) { | |
11000 | find = 1; | |
11001 | bgp_show_peer(vty, peer, use_json, | |
11002 | json); | |
11003 | break; | |
11004 | } | |
11005 | } | |
11006 | } | |
11007 | } | |
11008 | break; | |
11009 | case show_ipv4_all: | |
11010 | case show_ipv6_all: | |
11011 | FOREACH_SAFI (safi) { | |
11012 | if (peer->afc[afi][safi]) { | |
11013 | bgp_show_peer(vty, peer, use_json, json); | |
11014 | nbr_output = true; | |
11015 | break; | |
11016 | } | |
11017 | } | |
11018 | break; | |
d62a17ae | 11019 | } |
11020 | } | |
11021 | ||
d1927ebe AS |
11022 | if ((type == show_peer || type == show_ipv4_peer || |
11023 | type == show_ipv6_peer) && !find) { | |
d62a17ae | 11024 | if (use_json) |
11025 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
11026 | else | |
88b7d255 | 11027 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 11028 | } |
11029 | ||
d1927ebe AS |
11030 | if (type != show_peer && type != show_ipv4_peer && |
11031 | type != show_ipv6_peer && !nbr_output && !use_json) | |
94d4c685 | 11032 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 11033 | |
d62a17ae | 11034 | if (use_json) { |
996c9314 LB |
11035 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
11036 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 11037 | } else { |
11038 | vty_out(vty, "\n"); | |
11039 | } | |
11040 | ||
11041 | return CMD_SUCCESS; | |
11042 | } | |
11043 | ||
11044 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, | |
71aedaa3 DS |
11045 | enum show_type type, |
11046 | const char *ip_str, | |
9f049418 | 11047 | bool use_json) |
d62a17ae | 11048 | { |
0291c246 MK |
11049 | struct listnode *node, *nnode; |
11050 | struct bgp *bgp; | |
71aedaa3 | 11051 | union sockunion su; |
0291c246 | 11052 | json_object *json = NULL; |
71aedaa3 | 11053 | int ret, is_first = 1; |
9f049418 | 11054 | bool nbr_output = false; |
d62a17ae | 11055 | |
11056 | if (use_json) | |
11057 | vty_out(vty, "{\n"); | |
11058 | ||
11059 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 11060 | nbr_output = true; |
d62a17ae | 11061 | if (use_json) { |
11062 | if (!(json = json_object_new_object())) { | |
af4c2728 | 11063 | flog_err( |
e50f7cfd | 11064 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 11065 | "Unable to allocate memory for JSON object"); |
11066 | vty_out(vty, | |
11067 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
11068 | return; | |
11069 | } | |
11070 | ||
11071 | json_object_int_add(json, "vrfId", | |
11072 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
11073 | ? -1 |
11074 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 11075 | json_object_string_add( |
11076 | json, "vrfName", | |
11077 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11078 | ? VRF_DEFAULT_NAME |
d62a17ae | 11079 | : bgp->name); |
11080 | ||
11081 | if (!is_first) | |
11082 | vty_out(vty, ",\n"); | |
11083 | else | |
11084 | is_first = 0; | |
11085 | ||
11086 | vty_out(vty, "\"%s\":", | |
11087 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11088 | ? VRF_DEFAULT_NAME |
d62a17ae | 11089 | : bgp->name); |
11090 | } else { | |
11091 | vty_out(vty, "\nInstance %s:\n", | |
11092 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11093 | ? VRF_DEFAULT_NAME |
d62a17ae | 11094 | : bgp->name); |
11095 | } | |
71aedaa3 | 11096 | |
d1927ebe AS |
11097 | if (type == show_peer || type == show_ipv4_peer || |
11098 | type == show_ipv6_peer) { | |
71aedaa3 DS |
11099 | ret = str2sockunion(ip_str, &su); |
11100 | if (ret < 0) | |
11101 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
11102 | use_json, json); | |
11103 | else | |
11104 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
11105 | use_json, json); | |
11106 | } else { | |
d1927ebe | 11107 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, |
71aedaa3 DS |
11108 | use_json, json); |
11109 | } | |
b77004d6 | 11110 | json_object_free(json); |
d62a17ae | 11111 | } |
11112 | ||
01cbfd04 | 11113 | if (use_json) { |
d62a17ae | 11114 | vty_out(vty, "}\n"); |
01cbfd04 QY |
11115 | json_object_free(json); |
11116 | } | |
9f049418 DS |
11117 | else if (!nbr_output) |
11118 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 11119 | } |
11120 | ||
11121 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
11122 | enum show_type type, const char *ip_str, | |
9f049418 | 11123 | bool use_json) |
d62a17ae | 11124 | { |
11125 | int ret; | |
11126 | struct bgp *bgp; | |
11127 | union sockunion su; | |
11128 | json_object *json = NULL; | |
11129 | ||
11130 | if (name) { | |
11131 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
11132 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
11133 | use_json); | |
d62a17ae | 11134 | return CMD_SUCCESS; |
11135 | } else { | |
11136 | bgp = bgp_lookup_by_name(name); | |
11137 | if (!bgp) { | |
11138 | if (use_json) { | |
11139 | json = json_object_new_object(); | |
d62a17ae | 11140 | vty_out(vty, "%s\n", |
11141 | json_object_to_json_string_ext( | |
11142 | json, | |
11143 | JSON_C_TO_STRING_PRETTY)); | |
11144 | json_object_free(json); | |
11145 | } else | |
11146 | vty_out(vty, | |
9f049418 | 11147 | "%% BGP instance not found\n"); |
d62a17ae | 11148 | |
11149 | return CMD_WARNING; | |
11150 | } | |
11151 | } | |
11152 | } else { | |
11153 | bgp = bgp_get_default(); | |
11154 | } | |
11155 | ||
11156 | if (bgp) { | |
11157 | json = json_object_new_object(); | |
11158 | if (ip_str) { | |
11159 | ret = str2sockunion(ip_str, &su); | |
11160 | if (ret < 0) | |
11161 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
11162 | use_json, json); | |
11163 | else | |
11164 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
11165 | use_json, json); | |
11166 | } else { | |
11167 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
11168 | json); | |
11169 | } | |
11170 | json_object_free(json); | |
ca61fd25 DS |
11171 | } else { |
11172 | if (use_json) | |
11173 | vty_out(vty, "{}\n"); | |
11174 | else | |
11175 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 11176 | } |
11177 | ||
11178 | return CMD_SUCCESS; | |
4fb25c53 DW |
11179 | } |
11180 | ||
716b2d8a | 11181 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 11182 | DEFUN (show_ip_bgp_neighbors, |
11183 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 11184 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 11185 | SHOW_STR |
11186 | IP_STR | |
11187 | BGP_STR | |
f2a8972b | 11188 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
11189 | "Address Family\n" |
11190 | "Address Family\n" | |
718e3744 | 11191 | "Detailed information on TCP and BGP neighbor connections\n" |
11192 | "Neighbor to display information about\n" | |
a80beece | 11193 | "Neighbor to display information about\n" |
91d37724 | 11194 | "Neighbor on BGP configured interface\n" |
9973d184 | 11195 | JSON_STR) |
718e3744 | 11196 | { |
d62a17ae | 11197 | char *vrf = NULL; |
11198 | char *sh_arg = NULL; | |
11199 | enum show_type sh_type; | |
d1927ebe | 11200 | afi_t afi = AFI_MAX; |
718e3744 | 11201 | |
9f049418 | 11202 | bool uj = use_json(argc, argv); |
718e3744 | 11203 | |
d62a17ae | 11204 | int idx = 0; |
718e3744 | 11205 | |
9a8bdf1c PG |
11206 | /* [<vrf> VIEWVRFNAME] */ |
11207 | if (argv_find(argv, argc, "vrf", &idx)) { | |
11208 | vrf = argv[idx + 1]->arg; | |
11209 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11210 | vrf = NULL; | |
11211 | } else if (argv_find(argv, argc, "view", &idx)) | |
11212 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 11213 | vrf = argv[idx + 1]->arg; |
718e3744 | 11214 | |
d62a17ae | 11215 | idx++; |
d1927ebe AS |
11216 | |
11217 | if (argv_find(argv, argc, "ipv4", &idx)) { | |
11218 | sh_type = show_ipv4_all; | |
11219 | afi = AFI_IP; | |
11220 | } else if (argv_find(argv, argc, "ipv6", &idx)) { | |
11221 | sh_type = show_ipv6_all; | |
11222 | afi = AFI_IP6; | |
11223 | } else { | |
11224 | sh_type = show_all; | |
11225 | } | |
11226 | ||
d62a17ae | 11227 | if (argv_find(argv, argc, "A.B.C.D", &idx) |
11228 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
11229 | || argv_find(argv, argc, "WORD", &idx)) { | |
11230 | sh_type = show_peer; | |
11231 | sh_arg = argv[idx]->arg; | |
d1927ebe AS |
11232 | } |
11233 | ||
11234 | if (sh_type == show_peer && afi == AFI_IP) { | |
11235 | sh_type = show_ipv4_peer; | |
11236 | } else if (sh_type == show_peer && afi == AFI_IP6) { | |
11237 | sh_type = show_ipv6_peer; | |
11238 | } | |
856ca177 | 11239 | |
d62a17ae | 11240 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 11241 | } |
11242 | ||
716b2d8a | 11243 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 11244 | paths' and `show ip mbgp paths'. Those functions results are the |
11245 | same.*/ | |
f412b39a | 11246 | DEFUN (show_ip_bgp_paths, |
718e3744 | 11247 | show_ip_bgp_paths_cmd, |
46f296b4 | 11248 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 11249 | SHOW_STR |
11250 | IP_STR | |
11251 | BGP_STR | |
46f296b4 | 11252 | BGP_SAFI_HELP_STR |
718e3744 | 11253 | "Path information\n") |
11254 | { | |
d62a17ae | 11255 | vty_out(vty, "Address Refcnt Path\n"); |
11256 | aspath_print_all_vty(vty); | |
11257 | return CMD_SUCCESS; | |
718e3744 | 11258 | } |
11259 | ||
718e3744 | 11260 | #include "hash.h" |
11261 | ||
e3b78da8 | 11262 | static void community_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 11263 | struct vty *vty) |
718e3744 | 11264 | { |
d62a17ae | 11265 | struct community *com; |
718e3744 | 11266 | |
e3b78da8 | 11267 | com = (struct community *)bucket->data; |
3f65c5b1 | 11268 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 11269 | community_str(com, false)); |
718e3744 | 11270 | } |
11271 | ||
11272 | /* Show BGP's community internal data. */ | |
f412b39a | 11273 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 11274 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 11275 | "show [ip] bgp community-info", |
718e3744 | 11276 | SHOW_STR |
11277 | IP_STR | |
11278 | BGP_STR | |
11279 | "List all bgp community information\n") | |
11280 | { | |
d62a17ae | 11281 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 11282 | |
d62a17ae | 11283 | hash_iterate(community_hash(), |
e3b78da8 | 11284 | (void (*)(struct hash_bucket *, |
d62a17ae | 11285 | void *))community_show_all_iterator, |
11286 | vty); | |
718e3744 | 11287 | |
d62a17ae | 11288 | return CMD_SUCCESS; |
718e3744 | 11289 | } |
11290 | ||
e3b78da8 | 11291 | static void lcommunity_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 11292 | struct vty *vty) |
57d187bc | 11293 | { |
d62a17ae | 11294 | struct lcommunity *lcom; |
57d187bc | 11295 | |
e3b78da8 | 11296 | lcom = (struct lcommunity *)bucket->data; |
3f65c5b1 | 11297 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
8d9b8ed9 | 11298 | lcommunity_str(lcom, false)); |
57d187bc JS |
11299 | } |
11300 | ||
11301 | /* Show BGP's community internal data. */ | |
11302 | DEFUN (show_ip_bgp_lcommunity_info, | |
11303 | show_ip_bgp_lcommunity_info_cmd, | |
11304 | "show ip bgp large-community-info", | |
11305 | SHOW_STR | |
11306 | IP_STR | |
11307 | BGP_STR | |
11308 | "List all bgp large-community information\n") | |
11309 | { | |
d62a17ae | 11310 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 11311 | |
d62a17ae | 11312 | hash_iterate(lcommunity_hash(), |
e3b78da8 | 11313 | (void (*)(struct hash_bucket *, |
d62a17ae | 11314 | void *))lcommunity_show_all_iterator, |
11315 | vty); | |
57d187bc | 11316 | |
d62a17ae | 11317 | return CMD_SUCCESS; |
57d187bc JS |
11318 | } |
11319 | ||
11320 | ||
f412b39a | 11321 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 11322 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 11323 | "show [ip] bgp attribute-info", |
718e3744 | 11324 | SHOW_STR |
11325 | IP_STR | |
11326 | BGP_STR | |
11327 | "List all bgp attribute information\n") | |
11328 | { | |
d62a17ae | 11329 | attr_show_all(vty); |
11330 | return CMD_SUCCESS; | |
718e3744 | 11331 | } |
6b0655a2 | 11332 | |
03915806 CS |
11333 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
11334 | afi_t afi, safi_t safi, | |
11335 | bool use_json, json_object *json) | |
53089bec | 11336 | { |
11337 | struct bgp *bgp; | |
11338 | struct listnode *node; | |
11339 | char *vname; | |
11340 | char buf1[INET6_ADDRSTRLEN]; | |
11341 | char *ecom_str; | |
11342 | vpn_policy_direction_t dir; | |
11343 | ||
03915806 | 11344 | if (json) { |
b46dfd20 DS |
11345 | json_object *json_import_vrfs = NULL; |
11346 | json_object *json_export_vrfs = NULL; | |
11347 | ||
b46dfd20 DS |
11348 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
11349 | ||
53089bec | 11350 | if (!bgp) { |
b46dfd20 DS |
11351 | vty_out(vty, "%s\n", |
11352 | json_object_to_json_string_ext( | |
11353 | json, | |
11354 | JSON_C_TO_STRING_PRETTY)); | |
11355 | json_object_free(json); | |
11356 | ||
53089bec | 11357 | return CMD_WARNING; |
11358 | } | |
b46dfd20 | 11359 | |
94d4c685 DS |
11360 | /* Provide context for the block */ |
11361 | json_object_string_add(json, "vrf", name ? name : "default"); | |
11362 | json_object_string_add(json, "afiSafi", | |
11363 | afi_safi_print(afi, safi)); | |
11364 | ||
b46dfd20 DS |
11365 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
11366 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
11367 | json_object_string_add(json, "importFromVrfs", "none"); | |
11368 | json_object_string_add(json, "importRts", "none"); | |
11369 | } else { | |
6ce24e52 DS |
11370 | json_import_vrfs = json_object_new_array(); |
11371 | ||
b46dfd20 DS |
11372 | for (ALL_LIST_ELEMENTS_RO( |
11373 | bgp->vpn_policy[afi].import_vrf, | |
11374 | node, vname)) | |
11375 | json_object_array_add(json_import_vrfs, | |
11376 | json_object_new_string(vname)); | |
11377 | ||
11378 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
11379 | ecom_str = ecommunity_ecom2str( | |
11380 | bgp->vpn_policy[afi].rtlist[dir], | |
11381 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
11382 | json_object_object_add(json, "importFromVrfs", | |
11383 | json_import_vrfs); | |
11384 | json_object_string_add(json, "importRts", ecom_str); | |
11385 | ||
11386 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
11387 | } | |
11388 | ||
11389 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
11390 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
11391 | json_object_string_add(json, "exportToVrfs", "none"); | |
11392 | json_object_string_add(json, "routeDistinguisher", | |
11393 | "none"); | |
11394 | json_object_string_add(json, "exportRts", "none"); | |
11395 | } else { | |
6ce24e52 DS |
11396 | json_export_vrfs = json_object_new_array(); |
11397 | ||
b46dfd20 DS |
11398 | for (ALL_LIST_ELEMENTS_RO( |
11399 | bgp->vpn_policy[afi].export_vrf, | |
11400 | node, vname)) | |
11401 | json_object_array_add(json_export_vrfs, | |
11402 | json_object_new_string(vname)); | |
11403 | json_object_object_add(json, "exportToVrfs", | |
11404 | json_export_vrfs); | |
11405 | json_object_string_add(json, "routeDistinguisher", | |
11406 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
11407 | buf1, RD_ADDRSTRLEN)); | |
11408 | ||
11409 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
11410 | ecom_str = ecommunity_ecom2str( | |
11411 | bgp->vpn_policy[afi].rtlist[dir], | |
11412 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
11413 | json_object_string_add(json, "exportRts", ecom_str); | |
11414 | ||
11415 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
11416 | } | |
11417 | ||
03915806 CS |
11418 | if (use_json) { |
11419 | vty_out(vty, "%s\n", | |
11420 | json_object_to_json_string_ext(json, | |
b46dfd20 | 11421 | JSON_C_TO_STRING_PRETTY)); |
03915806 CS |
11422 | json_object_free(json); |
11423 | } | |
53089bec | 11424 | } else { |
b46dfd20 DS |
11425 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
11426 | ||
53089bec | 11427 | if (!bgp) { |
b46dfd20 | 11428 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 11429 | return CMD_WARNING; |
11430 | } | |
53089bec | 11431 | |
b46dfd20 DS |
11432 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
11433 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
11434 | vty_out(vty, | |
11435 | "This VRF is not importing %s routes from any other VRF\n", | |
11436 | afi_safi_print(afi, safi)); | |
11437 | else { | |
11438 | vty_out(vty, | |
11439 | "This VRF is importing %s routes from the following VRFs:\n", | |
11440 | afi_safi_print(afi, safi)); | |
11441 | ||
11442 | for (ALL_LIST_ELEMENTS_RO( | |
11443 | bgp->vpn_policy[afi].import_vrf, | |
11444 | node, vname)) | |
11445 | vty_out(vty, " %s\n", vname); | |
11446 | ||
11447 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
11448 | ecom_str = ecommunity_ecom2str( | |
11449 | bgp->vpn_policy[afi].rtlist[dir], | |
11450 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
11451 | vty_out(vty, "Import RT(s): %s\n", ecom_str); | |
11452 | ||
11453 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
53089bec | 11454 | } |
53089bec | 11455 | |
b46dfd20 DS |
11456 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
11457 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
11458 | vty_out(vty, | |
11459 | "This VRF is not exporting %s routes to any other VRF\n", | |
53089bec | 11460 | afi_safi_print(afi, safi)); |
b46dfd20 DS |
11461 | else { |
11462 | vty_out(vty, | |
04c9077f | 11463 | "This VRF is exporting %s routes to the following VRFs:\n", |
53089bec | 11464 | afi_safi_print(afi, safi)); |
b46dfd20 DS |
11465 | |
11466 | for (ALL_LIST_ELEMENTS_RO( | |
11467 | bgp->vpn_policy[afi].export_vrf, | |
11468 | node, vname)) | |
11469 | vty_out(vty, " %s\n", vname); | |
11470 | ||
11471 | vty_out(vty, "RD: %s\n", | |
11472 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
11473 | buf1, RD_ADDRSTRLEN)); | |
11474 | ||
11475 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
11476 | ecom_str = ecommunity_ecom2str( | |
11477 | bgp->vpn_policy[afi].rtlist[dir], | |
11478 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
11479 | vty_out(vty, "Export RT: %s\n", ecom_str); | |
04c9077f | 11480 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
53089bec | 11481 | } |
53089bec | 11482 | } |
11483 | ||
11484 | return CMD_SUCCESS; | |
11485 | } | |
11486 | ||
03915806 CS |
11487 | static int bgp_show_all_instance_route_leak_vty(struct vty *vty, afi_t afi, |
11488 | safi_t safi, bool use_json) | |
11489 | { | |
11490 | struct listnode *node, *nnode; | |
11491 | struct bgp *bgp; | |
11492 | char *vrf_name = NULL; | |
11493 | json_object *json = NULL; | |
11494 | json_object *json_vrf = NULL; | |
11495 | json_object *json_vrfs = NULL; | |
11496 | ||
11497 | if (use_json) { | |
11498 | json = json_object_new_object(); | |
11499 | json_vrfs = json_object_new_object(); | |
11500 | } | |
11501 | ||
11502 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
11503 | ||
11504 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) | |
11505 | vrf_name = bgp->name; | |
11506 | ||
11507 | if (use_json) { | |
11508 | json_vrf = json_object_new_object(); | |
11509 | } else { | |
11510 | vty_out(vty, "\nInstance %s:\n", | |
11511 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
11512 | ? VRF_DEFAULT_NAME : bgp->name); | |
11513 | } | |
11514 | bgp_show_route_leak_vty(vty, vrf_name, afi, safi, 0, json_vrf); | |
11515 | if (use_json) { | |
11516 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
11517 | json_object_object_add(json_vrfs, | |
11518 | VRF_DEFAULT_NAME, json_vrf); | |
11519 | else | |
11520 | json_object_object_add(json_vrfs, vrf_name, | |
11521 | json_vrf); | |
11522 | } | |
11523 | } | |
11524 | ||
11525 | if (use_json) { | |
11526 | json_object_object_add(json, "vrfs", json_vrfs); | |
11527 | vty_out(vty, "%s\n", json_object_to_json_string_ext(json, | |
11528 | JSON_C_TO_STRING_PRETTY)); | |
11529 | json_object_free(json); | |
11530 | } | |
11531 | ||
11532 | return CMD_SUCCESS; | |
11533 | } | |
11534 | ||
53089bec | 11535 | /* "show [ip] bgp route-leak" command. */ |
11536 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
11537 | show_ip_bgp_route_leak_cmd, |
11538 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
11539 | SHOW_STR |
11540 | IP_STR | |
11541 | BGP_STR | |
11542 | BGP_INSTANCE_HELP_STR | |
11543 | BGP_AFI_HELP_STR | |
11544 | BGP_SAFI_HELP_STR | |
11545 | "Route leaking information\n" | |
11546 | JSON_STR) | |
53089bec | 11547 | { |
11548 | char *vrf = NULL; | |
11549 | afi_t afi = AFI_MAX; | |
11550 | safi_t safi = SAFI_MAX; | |
11551 | ||
9f049418 | 11552 | bool uj = use_json(argc, argv); |
53089bec | 11553 | int idx = 0; |
03915806 | 11554 | json_object *json = NULL; |
53089bec | 11555 | |
11556 | /* show [ip] bgp */ | |
11557 | if (argv_find(argv, argc, "ip", &idx)) { | |
11558 | afi = AFI_IP; | |
11559 | safi = SAFI_UNICAST; | |
11560 | } | |
11561 | /* [vrf VIEWVRFNAME] */ | |
11562 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
11563 | vty_out(vty, |
11564 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 11565 | return CMD_WARNING; |
11566 | } | |
11567 | ||
9a8bdf1c PG |
11568 | if (argv_find(argv, argc, "vrf", &idx)) { |
11569 | vrf = argv[idx + 1]->arg; | |
11570 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11571 | vrf = NULL; | |
11572 | } | |
53089bec | 11573 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
11574 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11575 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11576 | } | |
11577 | ||
11578 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
11579 | vty_out(vty, |
11580 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 11581 | return CMD_WARNING; |
11582 | } | |
11583 | ||
03915806 CS |
11584 | if (vrf && strmatch(vrf, "all")) |
11585 | return bgp_show_all_instance_route_leak_vty(vty, afi, safi, uj); | |
11586 | ||
11587 | if (uj) | |
11588 | json = json_object_new_object(); | |
11589 | ||
11590 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj, json); | |
53089bec | 11591 | } |
11592 | ||
d62a17ae | 11593 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
11594 | safi_t safi) | |
f186de26 | 11595 | { |
d62a17ae | 11596 | struct listnode *node, *nnode; |
11597 | struct bgp *bgp; | |
f186de26 | 11598 | |
d62a17ae | 11599 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
11600 | vty_out(vty, "\nInstance %s:\n", | |
11601 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11602 | ? VRF_DEFAULT_NAME |
d62a17ae | 11603 | : bgp->name); |
11604 | update_group_show(bgp, afi, safi, vty, 0); | |
11605 | } | |
f186de26 | 11606 | } |
11607 | ||
d62a17ae | 11608 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
11609 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 11610 | { |
d62a17ae | 11611 | struct bgp *bgp; |
4fb25c53 | 11612 | |
d62a17ae | 11613 | if (name) { |
11614 | if (strmatch(name, "all")) { | |
11615 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
11616 | return CMD_SUCCESS; | |
11617 | } else { | |
11618 | bgp = bgp_lookup_by_name(name); | |
11619 | } | |
11620 | } else { | |
11621 | bgp = bgp_get_default(); | |
11622 | } | |
4fb25c53 | 11623 | |
d62a17ae | 11624 | if (bgp) |
11625 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
11626 | return CMD_SUCCESS; | |
4fb25c53 DW |
11627 | } |
11628 | ||
8fe8a7f6 DS |
11629 | DEFUN (show_ip_bgp_updgrps, |
11630 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 11631 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 11632 | SHOW_STR |
11633 | IP_STR | |
11634 | BGP_STR | |
11635 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 11636 | BGP_AFI_HELP_STR |
9bedbb1e | 11637 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
11638 | "Detailed info about dynamic update groups\n" |
11639 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 11640 | { |
d62a17ae | 11641 | char *vrf = NULL; |
11642 | afi_t afi = AFI_IP6; | |
11643 | safi_t safi = SAFI_UNICAST; | |
11644 | uint64_t subgrp_id = 0; | |
11645 | ||
11646 | int idx = 0; | |
11647 | ||
11648 | /* show [ip] bgp */ | |
11649 | if (argv_find(argv, argc, "ip", &idx)) | |
11650 | afi = AFI_IP; | |
9a8bdf1c PG |
11651 | /* [<vrf> VIEWVRFNAME] */ |
11652 | if (argv_find(argv, argc, "vrf", &idx)) { | |
11653 | vrf = argv[idx + 1]->arg; | |
11654 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11655 | vrf = NULL; | |
11656 | } else if (argv_find(argv, argc, "view", &idx)) | |
11657 | /* [<view> VIEWVRFNAME] */ | |
11658 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 11659 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
11660 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11661 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11662 | } | |
5bf15956 | 11663 | |
d62a17ae | 11664 | /* get subgroup id, if provided */ |
11665 | idx = argc - 1; | |
11666 | if (argv[idx]->type == VARIABLE_TKN) | |
11667 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 11668 | |
d62a17ae | 11669 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
11670 | } |
11671 | ||
f186de26 | 11672 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
11673 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 11674 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 11675 | SHOW_STR |
716b2d8a | 11676 | IP_STR |
f186de26 | 11677 | BGP_STR |
11678 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 11679 | "Detailed info about dynamic update groups\n") |
f186de26 | 11680 | { |
d62a17ae | 11681 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
11682 | return CMD_SUCCESS; | |
f186de26 | 11683 | } |
11684 | ||
43d3f4fc DS |
11685 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
11686 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
11687 | "show [ip] bgp l2vpn evpn update-groups", | |
11688 | SHOW_STR | |
11689 | IP_STR | |
11690 | BGP_STR | |
11691 | "l2vpn address family\n" | |
11692 | "evpn sub-address family\n" | |
11693 | "Detailed info about dynamic update groups\n") | |
11694 | { | |
11695 | char *vrf = NULL; | |
11696 | uint64_t subgrp_id = 0; | |
11697 | ||
11698 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id); | |
11699 | return CMD_SUCCESS; | |
11700 | } | |
11701 | ||
5bf15956 DW |
11702 | DEFUN (show_bgp_updgrps_stats, |
11703 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 11704 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 11705 | SHOW_STR |
716b2d8a | 11706 | IP_STR |
3f9c7369 | 11707 | BGP_STR |
0c7b1b01 | 11708 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
11709 | "Statistics\n") |
11710 | { | |
d62a17ae | 11711 | struct bgp *bgp; |
3f9c7369 | 11712 | |
d62a17ae | 11713 | bgp = bgp_get_default(); |
11714 | if (bgp) | |
11715 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 11716 | |
d62a17ae | 11717 | return CMD_SUCCESS; |
3f9c7369 DS |
11718 | } |
11719 | ||
8386ac43 | 11720 | DEFUN (show_bgp_instance_updgrps_stats, |
11721 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 11722 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 11723 | SHOW_STR |
716b2d8a | 11724 | IP_STR |
8386ac43 | 11725 | BGP_STR |
11726 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 11727 | "Detailed info about dynamic update groups\n" |
8386ac43 | 11728 | "Statistics\n") |
11729 | { | |
d62a17ae | 11730 | int idx_word = 3; |
11731 | struct bgp *bgp; | |
8386ac43 | 11732 | |
d62a17ae | 11733 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
11734 | if (bgp) | |
11735 | update_group_show_stats(bgp, vty); | |
8386ac43 | 11736 | |
d62a17ae | 11737 | return CMD_SUCCESS; |
8386ac43 | 11738 | } |
11739 | ||
d62a17ae | 11740 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
11741 | afi_t afi, safi_t safi, | |
11742 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 11743 | { |
d62a17ae | 11744 | struct bgp *bgp; |
8386ac43 | 11745 | |
d62a17ae | 11746 | if (name) |
11747 | bgp = bgp_lookup_by_name(name); | |
11748 | else | |
11749 | bgp = bgp_get_default(); | |
8386ac43 | 11750 | |
d62a17ae | 11751 | if (bgp) { |
11752 | if (!strcmp(what, "advertise-queue")) | |
11753 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
11754 | subgrp_id); | |
11755 | else if (!strcmp(what, "advertised-routes")) | |
11756 | update_group_show_advertised(bgp, afi, safi, vty, | |
11757 | subgrp_id); | |
11758 | else if (!strcmp(what, "packet-queue")) | |
11759 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
11760 | subgrp_id); | |
11761 | } | |
3f9c7369 DS |
11762 | } |
11763 | ||
dc64bdec QY |
11764 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
11765 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
11766 | "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", | |
11767 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
11768 | BGP_SAFI_HELP_STR | |
11769 | "Detailed info about dynamic update groups\n" | |
11770 | "Specific subgroup to display info for\n" | |
11771 | "Advertisement queue\n" | |
11772 | "Announced routes\n" | |
11773 | "Packet queue\n") | |
3f9c7369 | 11774 | { |
dc64bdec QY |
11775 | uint64_t subgrp_id = 0; |
11776 | afi_t afiz; | |
11777 | safi_t safiz; | |
11778 | if (sgid) | |
11779 | subgrp_id = strtoull(sgid, NULL, 10); | |
11780 | ||
11781 | if (!ip && !afi) | |
11782 | afiz = AFI_IP6; | |
11783 | if (!ip && afi) | |
11784 | afiz = bgp_vty_afi_from_str(afi); | |
11785 | if (ip && !afi) | |
11786 | afiz = AFI_IP; | |
11787 | if (ip && afi) { | |
11788 | afiz = bgp_vty_afi_from_str(afi); | |
11789 | if (afiz != AFI_IP) | |
11790 | vty_out(vty, | |
11791 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
11792 | return CMD_WARNING; | |
11793 | } | |
d62a17ae | 11794 | |
dc64bdec | 11795 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 11796 | |
dc64bdec | 11797 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 11798 | return CMD_SUCCESS; |
11799 | } | |
11800 | ||
d62a17ae | 11801 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group) |
11802 | { | |
11803 | struct listnode *node, *nnode; | |
11804 | struct prefix *range; | |
11805 | struct peer *conf; | |
11806 | struct peer *peer; | |
11807 | char buf[PREFIX2STR_BUFFER]; | |
11808 | afi_t afi; | |
11809 | safi_t safi; | |
11810 | const char *peer_status; | |
11811 | const char *af_str; | |
11812 | int lr_count; | |
11813 | int dynamic; | |
11814 | int af_cfgd; | |
11815 | ||
11816 | conf = group->conf; | |
11817 | ||
11818 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
3b61f610 QY |
11819 | vty_out(vty, "\nBGP peer-group %s, remote AS %" PRIu32 "\n", |
11820 | group->name, conf->as); | |
d62a17ae | 11821 | } else if (conf->as_type == AS_INTERNAL) { |
3b61f610 QY |
11822 | vty_out(vty, "\nBGP peer-group %s, remote AS %" PRIu32 "\n", |
11823 | group->name, group->bgp->as); | |
d62a17ae | 11824 | } else { |
11825 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
11826 | } | |
f14e6fdb | 11827 | |
d62a17ae | 11828 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
11829 | vty_out(vty, " Peer-group type is internal\n"); | |
11830 | else | |
11831 | vty_out(vty, " Peer-group type is external\n"); | |
11832 | ||
11833 | /* Display AFs configured. */ | |
11834 | vty_out(vty, " Configured address-families:"); | |
05c7a1cc QY |
11835 | FOREACH_AFI_SAFI (afi, safi) { |
11836 | if (conf->afc[afi][safi]) { | |
11837 | af_cfgd = 1; | |
11838 | vty_out(vty, " %s;", afi_safi_print(afi, safi)); | |
d62a17ae | 11839 | } |
05c7a1cc | 11840 | } |
d62a17ae | 11841 | if (!af_cfgd) |
11842 | vty_out(vty, " none\n"); | |
11843 | else | |
11844 | vty_out(vty, "\n"); | |
11845 | ||
11846 | /* Display listen ranges (for dynamic neighbors), if any */ | |
11847 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
11848 | if (afi == AFI_IP) | |
11849 | af_str = "IPv4"; | |
11850 | else if (afi == AFI_IP6) | |
11851 | af_str = "IPv6"; | |
11852 | else | |
11853 | af_str = "???"; | |
11854 | lr_count = listcount(group->listen_range[afi]); | |
11855 | if (lr_count) { | |
11856 | vty_out(vty, " %d %s listen range(s)\n", lr_count, | |
11857 | af_str); | |
11858 | ||
11859 | ||
11860 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
11861 | nnode, range)) { | |
11862 | prefix2str(range, buf, sizeof(buf)); | |
11863 | vty_out(vty, " %s\n", buf); | |
11864 | } | |
11865 | } | |
11866 | } | |
f14e6fdb | 11867 | |
d62a17ae | 11868 | /* Display group members and their status */ |
11869 | if (listcount(group->peer)) { | |
11870 | vty_out(vty, " Peer-group members:\n"); | |
11871 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
11872 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
11873 | peer_status = "Idle (Admin)"; | |
11874 | else if (CHECK_FLAG(peer->sflags, | |
11875 | PEER_STATUS_PREFIX_OVERFLOW)) | |
11876 | peer_status = "Idle (PfxCt)"; | |
11877 | else | |
11878 | peer_status = lookup_msg(bgp_status_msg, | |
11879 | peer->status, NULL); | |
11880 | ||
11881 | dynamic = peer_dynamic_neighbor(peer); | |
11882 | vty_out(vty, " %s %s %s \n", peer->host, | |
11883 | dynamic ? "(dynamic)" : "", peer_status); | |
11884 | } | |
11885 | } | |
f14e6fdb | 11886 | |
d62a17ae | 11887 | return CMD_SUCCESS; |
11888 | } | |
11889 | ||
ff9959b0 QY |
11890 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
11891 | const char *group_name) | |
d62a17ae | 11892 | { |
ff9959b0 | 11893 | struct bgp *bgp; |
d62a17ae | 11894 | struct listnode *node, *nnode; |
11895 | struct peer_group *group; | |
ff9959b0 QY |
11896 | bool found = false; |
11897 | ||
11898 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
11899 | ||
11900 | if (!bgp) { | |
9f049418 | 11901 | vty_out(vty, "%% BGP instance not found\n"); |
ff9959b0 QY |
11902 | return CMD_WARNING; |
11903 | } | |
d62a17ae | 11904 | |
11905 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
11906 | if (group_name) { |
11907 | if (strmatch(group->name, group_name)) { | |
d62a17ae | 11908 | bgp_show_one_peer_group(vty, group); |
ff9959b0 QY |
11909 | found = true; |
11910 | break; | |
d62a17ae | 11911 | } |
ff9959b0 QY |
11912 | } else { |
11913 | bgp_show_one_peer_group(vty, group); | |
d62a17ae | 11914 | } |
f14e6fdb | 11915 | } |
f14e6fdb | 11916 | |
ff9959b0 | 11917 | if (group_name && !found) |
d62a17ae | 11918 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 11919 | |
d62a17ae | 11920 | return CMD_SUCCESS; |
f14e6fdb DS |
11921 | } |
11922 | ||
f14e6fdb DS |
11923 | DEFUN (show_ip_bgp_peer_groups, |
11924 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 11925 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
11926 | SHOW_STR |
11927 | IP_STR | |
11928 | BGP_STR | |
8386ac43 | 11929 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
11930 | "Detailed information on BGP peer groups\n" |
11931 | "Peer group name\n") | |
f14e6fdb | 11932 | { |
d62a17ae | 11933 | char *vrf, *pg; |
d62a17ae | 11934 | int idx = 0; |
f14e6fdb | 11935 | |
a4d82a8a PZ |
11936 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
11937 | : NULL; | |
d62a17ae | 11938 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 11939 | |
ff9959b0 | 11940 | return bgp_show_peer_group_vty(vty, vrf, pg); |
f14e6fdb | 11941 | } |
3f9c7369 | 11942 | |
d6e3c605 | 11943 | |
718e3744 | 11944 | /* Redistribute VTY commands. */ |
11945 | ||
718e3744 | 11946 | DEFUN (bgp_redistribute_ipv4, |
11947 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 11948 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 11949 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11950 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 11951 | { |
d62a17ae | 11952 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11953 | int idx_protocol = 1; | |
11954 | int type; | |
718e3744 | 11955 | |
d62a17ae | 11956 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
11957 | if (type < 0) { | |
11958 | vty_out(vty, "%% Invalid route type\n"); | |
11959 | return CMD_WARNING_CONFIG_FAILED; | |
11960 | } | |
7f323236 | 11961 | |
d62a17ae | 11962 | bgp_redist_add(bgp, AFI_IP, type, 0); |
e923dd62 | 11963 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, false); |
718e3744 | 11964 | } |
11965 | ||
d62a17ae | 11966 | ALIAS_HIDDEN( |
11967 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
11968 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
11969 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 11970 | |
718e3744 | 11971 | DEFUN (bgp_redistribute_ipv4_rmap, |
11972 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 11973 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 11974 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11975 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 11976 | "Route map reference\n" |
11977 | "Pointer to route-map entries\n") | |
11978 | { | |
d62a17ae | 11979 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11980 | int idx_protocol = 1; | |
11981 | int idx_word = 3; | |
11982 | int type; | |
11983 | struct bgp_redist *red; | |
e923dd62 | 11984 | bool changed; |
1de27621 DA |
11985 | struct route_map *route_map = route_map_lookup_warn_noexist( |
11986 | vty, argv[idx_word]->arg); | |
718e3744 | 11987 | |
d62a17ae | 11988 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
11989 | if (type < 0) { | |
11990 | vty_out(vty, "%% Invalid route type\n"); | |
11991 | return CMD_WARNING_CONFIG_FAILED; | |
11992 | } | |
718e3744 | 11993 | |
d62a17ae | 11994 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
1de27621 DA |
11995 | changed = |
11996 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 11997 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
718e3744 | 11998 | } |
11999 | ||
d62a17ae | 12000 | ALIAS_HIDDEN( |
12001 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
12002 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
12003 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
12004 | "Route map reference\n" | |
12005 | "Pointer to route-map entries\n") | |
596c17ba | 12006 | |
718e3744 | 12007 | DEFUN (bgp_redistribute_ipv4_metric, |
12008 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 12009 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 12010 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12011 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 12012 | "Metric for redistributed routes\n" |
12013 | "Default metric\n") | |
12014 | { | |
d62a17ae | 12015 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12016 | int idx_protocol = 1; | |
12017 | int idx_number = 3; | |
12018 | int type; | |
d7c0a89a | 12019 | uint32_t metric; |
d62a17ae | 12020 | struct bgp_redist *red; |
e923dd62 | 12021 | bool changed; |
d62a17ae | 12022 | |
12023 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
12024 | if (type < 0) { | |
12025 | vty_out(vty, "%% Invalid route type\n"); | |
12026 | return CMD_WARNING_CONFIG_FAILED; | |
12027 | } | |
12028 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
12029 | ||
12030 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 12031 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
12032 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 12033 | } |
12034 | ||
12035 | ALIAS_HIDDEN( | |
12036 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
12037 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
12038 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
12039 | "Metric for redistributed routes\n" | |
12040 | "Default metric\n") | |
596c17ba | 12041 | |
718e3744 | 12042 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
12043 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 12044 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 12045 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12046 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 12047 | "Route map reference\n" |
12048 | "Pointer to route-map entries\n" | |
12049 | "Metric for redistributed routes\n" | |
12050 | "Default metric\n") | |
12051 | { | |
d62a17ae | 12052 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12053 | int idx_protocol = 1; | |
12054 | int idx_word = 3; | |
12055 | int idx_number = 5; | |
12056 | int type; | |
d7c0a89a | 12057 | uint32_t metric; |
d62a17ae | 12058 | struct bgp_redist *red; |
e923dd62 | 12059 | bool changed; |
1de27621 DA |
12060 | struct route_map *route_map = |
12061 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12062 | |
12063 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
12064 | if (type < 0) { | |
12065 | vty_out(vty, "%% Invalid route type\n"); | |
12066 | return CMD_WARNING_CONFIG_FAILED; | |
12067 | } | |
12068 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
12069 | ||
12070 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
1de27621 DA |
12071 | changed = |
12072 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12073 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
12074 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 12075 | } |
12076 | ||
12077 | ALIAS_HIDDEN( | |
12078 | bgp_redistribute_ipv4_rmap_metric, | |
12079 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
12080 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
12081 | " route-map WORD metric (0-4294967295)", | |
12082 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
12083 | "Route map reference\n" | |
12084 | "Pointer to route-map entries\n" | |
12085 | "Metric for redistributed routes\n" | |
12086 | "Default metric\n") | |
596c17ba | 12087 | |
718e3744 | 12088 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
12089 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 12090 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 12091 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12092 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 12093 | "Metric for redistributed routes\n" |
12094 | "Default metric\n" | |
12095 | "Route map reference\n" | |
12096 | "Pointer to route-map entries\n") | |
12097 | { | |
d62a17ae | 12098 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12099 | int idx_protocol = 1; | |
12100 | int idx_number = 3; | |
12101 | int idx_word = 5; | |
12102 | int type; | |
d7c0a89a | 12103 | uint32_t metric; |
d62a17ae | 12104 | struct bgp_redist *red; |
e923dd62 | 12105 | bool changed; |
1de27621 DA |
12106 | struct route_map *route_map = |
12107 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12108 | |
12109 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
12110 | if (type < 0) { | |
12111 | vty_out(vty, "%% Invalid route type\n"); | |
12112 | return CMD_WARNING_CONFIG_FAILED; | |
12113 | } | |
12114 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
12115 | ||
12116 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 12117 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
1de27621 DA |
12118 | changed |= |
12119 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12120 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
d62a17ae | 12121 | } |
12122 | ||
12123 | ALIAS_HIDDEN( | |
12124 | bgp_redistribute_ipv4_metric_rmap, | |
12125 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
12126 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
12127 | " metric (0-4294967295) route-map WORD", | |
12128 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
12129 | "Metric for redistributed routes\n" | |
12130 | "Default metric\n" | |
12131 | "Route map reference\n" | |
12132 | "Pointer to route-map entries\n") | |
596c17ba | 12133 | |
7c8ff89e DS |
12134 | DEFUN (bgp_redistribute_ipv4_ospf, |
12135 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 12136 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
12137 | "Redistribute information from another routing protocol\n" |
12138 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12139 | "Non-main Kernel Routing Table\n" |
12140 | "Instance ID/Table ID\n") | |
7c8ff89e | 12141 | { |
d62a17ae | 12142 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12143 | int idx_ospf_table = 1; | |
12144 | int idx_number = 2; | |
d7c0a89a QY |
12145 | unsigned short instance; |
12146 | unsigned short protocol; | |
7c8ff89e | 12147 | |
d62a17ae | 12148 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 12149 | |
d62a17ae | 12150 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
12151 | protocol = ZEBRA_ROUTE_OSPF; | |
12152 | else | |
12153 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 12154 | |
d62a17ae | 12155 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
e923dd62 | 12156 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, false); |
7c8ff89e DS |
12157 | } |
12158 | ||
d62a17ae | 12159 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
12160 | "redistribute <ospf|table> (1-65535)", | |
12161 | "Redistribute information from another routing protocol\n" | |
12162 | "Open Shortest Path First (OSPFv2)\n" | |
12163 | "Non-main Kernel Routing Table\n" | |
12164 | "Instance ID/Table ID\n") | |
596c17ba | 12165 | |
7c8ff89e DS |
12166 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
12167 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 12168 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
12169 | "Redistribute information from another routing protocol\n" |
12170 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12171 | "Non-main Kernel Routing Table\n" |
12172 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12173 | "Route map reference\n" |
12174 | "Pointer to route-map entries\n") | |
12175 | { | |
d62a17ae | 12176 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12177 | int idx_ospf_table = 1; | |
12178 | int idx_number = 2; | |
12179 | int idx_word = 4; | |
12180 | struct bgp_redist *red; | |
d7c0a89a | 12181 | unsigned short instance; |
d62a17ae | 12182 | int protocol; |
e923dd62 | 12183 | bool changed; |
1de27621 DA |
12184 | struct route_map *route_map = |
12185 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12186 | |
12187 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12188 | protocol = ZEBRA_ROUTE_OSPF; | |
12189 | else | |
12190 | protocol = ZEBRA_ROUTE_TABLE; | |
12191 | ||
12192 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12193 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
12194 | changed = |
12195 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12196 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 12197 | } |
12198 | ||
12199 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
12200 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
12201 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
12202 | "Redistribute information from another routing protocol\n" | |
12203 | "Open Shortest Path First (OSPFv2)\n" | |
12204 | "Non-main Kernel Routing Table\n" | |
12205 | "Instance ID/Table ID\n" | |
12206 | "Route map reference\n" | |
12207 | "Pointer to route-map entries\n") | |
596c17ba | 12208 | |
7c8ff89e DS |
12209 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
12210 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 12211 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
12212 | "Redistribute information from another routing protocol\n" |
12213 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12214 | "Non-main Kernel Routing Table\n" |
12215 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12216 | "Metric for redistributed routes\n" |
12217 | "Default metric\n") | |
12218 | { | |
d62a17ae | 12219 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12220 | int idx_ospf_table = 1; | |
12221 | int idx_number = 2; | |
12222 | int idx_number_2 = 4; | |
d7c0a89a | 12223 | uint32_t metric; |
d62a17ae | 12224 | struct bgp_redist *red; |
d7c0a89a | 12225 | unsigned short instance; |
d62a17ae | 12226 | int protocol; |
e923dd62 | 12227 | bool changed; |
d62a17ae | 12228 | |
12229 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12230 | protocol = ZEBRA_ROUTE_OSPF; | |
12231 | else | |
12232 | protocol = ZEBRA_ROUTE_TABLE; | |
12233 | ||
12234 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12235 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
12236 | ||
12237 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 12238 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
12239 | metric); | |
12240 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 12241 | } |
12242 | ||
12243 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
12244 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
12245 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
12246 | "Redistribute information from another routing protocol\n" | |
12247 | "Open Shortest Path First (OSPFv2)\n" | |
12248 | "Non-main Kernel Routing Table\n" | |
12249 | "Instance ID/Table ID\n" | |
12250 | "Metric for redistributed routes\n" | |
12251 | "Default metric\n") | |
596c17ba | 12252 | |
7c8ff89e DS |
12253 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
12254 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 12255 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
12256 | "Redistribute information from another routing protocol\n" |
12257 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12258 | "Non-main Kernel Routing Table\n" |
12259 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12260 | "Route map reference\n" |
12261 | "Pointer to route-map entries\n" | |
12262 | "Metric for redistributed routes\n" | |
12263 | "Default metric\n") | |
12264 | { | |
d62a17ae | 12265 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12266 | int idx_ospf_table = 1; | |
12267 | int idx_number = 2; | |
12268 | int idx_word = 4; | |
12269 | int idx_number_2 = 6; | |
d7c0a89a | 12270 | uint32_t metric; |
d62a17ae | 12271 | struct bgp_redist *red; |
d7c0a89a | 12272 | unsigned short instance; |
d62a17ae | 12273 | int protocol; |
e923dd62 | 12274 | bool changed; |
1de27621 DA |
12275 | struct route_map *route_map = |
12276 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12277 | |
12278 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12279 | protocol = ZEBRA_ROUTE_OSPF; | |
12280 | else | |
12281 | protocol = ZEBRA_ROUTE_TABLE; | |
12282 | ||
12283 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12284 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
12285 | ||
12286 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
12287 | changed = |
12288 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12289 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
12290 | metric); | |
12291 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 12292 | } |
12293 | ||
12294 | ALIAS_HIDDEN( | |
12295 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
12296 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
12297 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
12298 | "Redistribute information from another routing protocol\n" | |
12299 | "Open Shortest Path First (OSPFv2)\n" | |
12300 | "Non-main Kernel Routing Table\n" | |
12301 | "Instance ID/Table ID\n" | |
12302 | "Route map reference\n" | |
12303 | "Pointer to route-map entries\n" | |
12304 | "Metric for redistributed routes\n" | |
12305 | "Default metric\n") | |
596c17ba | 12306 | |
7c8ff89e DS |
12307 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
12308 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 12309 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
12310 | "Redistribute information from another routing protocol\n" |
12311 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12312 | "Non-main Kernel Routing Table\n" |
12313 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12314 | "Metric for redistributed routes\n" |
12315 | "Default metric\n" | |
12316 | "Route map reference\n" | |
12317 | "Pointer to route-map entries\n") | |
12318 | { | |
d62a17ae | 12319 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12320 | int idx_ospf_table = 1; | |
12321 | int idx_number = 2; | |
12322 | int idx_number_2 = 4; | |
12323 | int idx_word = 6; | |
d7c0a89a | 12324 | uint32_t metric; |
d62a17ae | 12325 | struct bgp_redist *red; |
d7c0a89a | 12326 | unsigned short instance; |
d62a17ae | 12327 | int protocol; |
e923dd62 | 12328 | bool changed; |
1de27621 DA |
12329 | struct route_map *route_map = |
12330 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12331 | |
12332 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12333 | protocol = ZEBRA_ROUTE_OSPF; | |
12334 | else | |
12335 | protocol = ZEBRA_ROUTE_TABLE; | |
12336 | ||
12337 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12338 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
12339 | ||
12340 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 12341 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
12342 | metric); | |
1de27621 DA |
12343 | changed |= |
12344 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12345 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 12346 | } |
12347 | ||
12348 | ALIAS_HIDDEN( | |
12349 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
12350 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
12351 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
12352 | "Redistribute information from another routing protocol\n" | |
12353 | "Open Shortest Path First (OSPFv2)\n" | |
12354 | "Non-main Kernel Routing Table\n" | |
12355 | "Instance ID/Table ID\n" | |
12356 | "Metric for redistributed routes\n" | |
12357 | "Default metric\n" | |
12358 | "Route map reference\n" | |
12359 | "Pointer to route-map entries\n") | |
596c17ba | 12360 | |
7c8ff89e DS |
12361 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
12362 | no_bgp_redistribute_ipv4_ospf_cmd, | |
d04c479d | 12363 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", |
7c8ff89e DS |
12364 | NO_STR |
12365 | "Redistribute information from another routing protocol\n" | |
12366 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 12367 | "Non-main Kernel Routing Table\n" |
31500417 DW |
12368 | "Instance ID/Table ID\n" |
12369 | "Metric for redistributed routes\n" | |
12370 | "Default metric\n" | |
12371 | "Route map reference\n" | |
12372 | "Pointer to route-map entries\n") | |
7c8ff89e | 12373 | { |
d62a17ae | 12374 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12375 | int idx_ospf_table = 2; | |
12376 | int idx_number = 3; | |
d7c0a89a | 12377 | unsigned short instance; |
d62a17ae | 12378 | int protocol; |
12379 | ||
12380 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12381 | protocol = ZEBRA_ROUTE_OSPF; | |
12382 | else | |
12383 | protocol = ZEBRA_ROUTE_TABLE; | |
12384 | ||
12385 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12386 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
12387 | } | |
12388 | ||
12389 | ALIAS_HIDDEN( | |
12390 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
12391 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", | |
12392 | NO_STR | |
12393 | "Redistribute information from another routing protocol\n" | |
12394 | "Open Shortest Path First (OSPFv2)\n" | |
12395 | "Non-main Kernel Routing Table\n" | |
12396 | "Instance ID/Table ID\n" | |
12397 | "Metric for redistributed routes\n" | |
12398 | "Default metric\n" | |
12399 | "Route map reference\n" | |
12400 | "Pointer to route-map entries\n") | |
596c17ba | 12401 | |
718e3744 | 12402 | DEFUN (no_bgp_redistribute_ipv4, |
12403 | no_bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 12404 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 12405 | NO_STR |
12406 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 12407 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
12408 | "Metric for redistributed routes\n" |
12409 | "Default metric\n" | |
12410 | "Route map reference\n" | |
12411 | "Pointer to route-map entries\n") | |
718e3744 | 12412 | { |
d62a17ae | 12413 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12414 | int idx_protocol = 2; | |
12415 | int type; | |
12416 | ||
12417 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
12418 | if (type < 0) { | |
12419 | vty_out(vty, "%% Invalid route type\n"); | |
12420 | return CMD_WARNING_CONFIG_FAILED; | |
12421 | } | |
12422 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
12423 | } | |
12424 | ||
12425 | ALIAS_HIDDEN( | |
12426 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
12427 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
12428 | " [metric (0-4294967295)] [route-map WORD]", | |
12429 | NO_STR | |
12430 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
12431 | "Metric for redistributed routes\n" | |
12432 | "Default metric\n" | |
12433 | "Route map reference\n" | |
12434 | "Pointer to route-map entries\n") | |
596c17ba | 12435 | |
718e3744 | 12436 | DEFUN (bgp_redistribute_ipv6, |
12437 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 12438 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 12439 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12440 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 12441 | { |
d62a17ae | 12442 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12443 | int idx_protocol = 1; | |
12444 | int type; | |
718e3744 | 12445 | |
d62a17ae | 12446 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
12447 | if (type < 0) { | |
12448 | vty_out(vty, "%% Invalid route type\n"); | |
12449 | return CMD_WARNING_CONFIG_FAILED; | |
12450 | } | |
718e3744 | 12451 | |
d62a17ae | 12452 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 12453 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, false); |
718e3744 | 12454 | } |
12455 | ||
12456 | DEFUN (bgp_redistribute_ipv6_rmap, | |
12457 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 12458 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 12459 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12460 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12461 | "Route map reference\n" |
12462 | "Pointer to route-map entries\n") | |
12463 | { | |
d62a17ae | 12464 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12465 | int idx_protocol = 1; | |
12466 | int idx_word = 3; | |
12467 | int type; | |
12468 | struct bgp_redist *red; | |
e923dd62 | 12469 | bool changed; |
1de27621 DA |
12470 | struct route_map *route_map = |
12471 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
718e3744 | 12472 | |
d62a17ae | 12473 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
12474 | if (type < 0) { | |
12475 | vty_out(vty, "%% Invalid route type\n"); | |
12476 | return CMD_WARNING_CONFIG_FAILED; | |
12477 | } | |
718e3744 | 12478 | |
d62a17ae | 12479 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
12480 | changed = |
12481 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12482 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 12483 | } |
12484 | ||
12485 | DEFUN (bgp_redistribute_ipv6_metric, | |
12486 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 12487 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 12488 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12489 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12490 | "Metric for redistributed routes\n" |
12491 | "Default metric\n") | |
12492 | { | |
d62a17ae | 12493 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12494 | int idx_protocol = 1; | |
12495 | int idx_number = 3; | |
12496 | int type; | |
d7c0a89a | 12497 | uint32_t metric; |
d62a17ae | 12498 | struct bgp_redist *red; |
e923dd62 | 12499 | bool changed; |
d62a17ae | 12500 | |
12501 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
12502 | if (type < 0) { | |
12503 | vty_out(vty, "%% Invalid route type\n"); | |
12504 | return CMD_WARNING_CONFIG_FAILED; | |
12505 | } | |
12506 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 12507 | |
d62a17ae | 12508 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 12509 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); |
12510 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 12511 | } |
12512 | ||
12513 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
12514 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 12515 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 12516 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12517 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12518 | "Route map reference\n" |
12519 | "Pointer to route-map entries\n" | |
12520 | "Metric for redistributed routes\n" | |
12521 | "Default metric\n") | |
12522 | { | |
d62a17ae | 12523 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12524 | int idx_protocol = 1; | |
12525 | int idx_word = 3; | |
12526 | int idx_number = 5; | |
12527 | int type; | |
d7c0a89a | 12528 | uint32_t metric; |
d62a17ae | 12529 | struct bgp_redist *red; |
e923dd62 | 12530 | bool changed; |
1de27621 DA |
12531 | struct route_map *route_map = |
12532 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12533 | |
12534 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
12535 | if (type < 0) { | |
12536 | vty_out(vty, "%% Invalid route type\n"); | |
12537 | return CMD_WARNING_CONFIG_FAILED; | |
12538 | } | |
12539 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 12540 | |
d62a17ae | 12541 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
12542 | changed = |
12543 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12544 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, |
12545 | metric); | |
12546 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 12547 | } |
12548 | ||
12549 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
12550 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 12551 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 12552 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12553 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12554 | "Metric for redistributed routes\n" |
12555 | "Default metric\n" | |
12556 | "Route map reference\n" | |
12557 | "Pointer to route-map entries\n") | |
12558 | { | |
d62a17ae | 12559 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12560 | int idx_protocol = 1; | |
12561 | int idx_number = 3; | |
12562 | int idx_word = 5; | |
12563 | int type; | |
d7c0a89a | 12564 | uint32_t metric; |
d62a17ae | 12565 | struct bgp_redist *red; |
e923dd62 | 12566 | bool changed; |
1de27621 DA |
12567 | struct route_map *route_map = |
12568 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12569 | |
12570 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
12571 | if (type < 0) { | |
12572 | vty_out(vty, "%% Invalid route type\n"); | |
12573 | return CMD_WARNING_CONFIG_FAILED; | |
12574 | } | |
12575 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 12576 | |
d62a17ae | 12577 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 12578 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, |
12579 | metric); | |
1de27621 DA |
12580 | changed |= |
12581 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12582 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 12583 | } |
12584 | ||
12585 | DEFUN (no_bgp_redistribute_ipv6, | |
12586 | no_bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 12587 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 12588 | NO_STR |
12589 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 12590 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
12591 | "Metric for redistributed routes\n" |
12592 | "Default metric\n" | |
12593 | "Route map reference\n" | |
12594 | "Pointer to route-map entries\n") | |
718e3744 | 12595 | { |
d62a17ae | 12596 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12597 | int idx_protocol = 2; | |
12598 | int type; | |
718e3744 | 12599 | |
d62a17ae | 12600 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
12601 | if (type < 0) { | |
12602 | vty_out(vty, "%% Invalid route type\n"); | |
12603 | return CMD_WARNING_CONFIG_FAILED; | |
12604 | } | |
718e3744 | 12605 | |
d62a17ae | 12606 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
12607 | } | |
12608 | ||
2b791107 | 12609 | void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, afi_t afi, |
60466a63 | 12610 | safi_t safi) |
d62a17ae | 12611 | { |
12612 | int i; | |
12613 | ||
12614 | /* Unicast redistribution only. */ | |
12615 | if (safi != SAFI_UNICAST) | |
2b791107 | 12616 | return; |
d62a17ae | 12617 | |
12618 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
12619 | /* Redistribute BGP does not make sense. */ | |
12620 | if (i != ZEBRA_ROUTE_BGP) { | |
12621 | struct list *red_list; | |
12622 | struct listnode *node; | |
12623 | struct bgp_redist *red; | |
12624 | ||
12625 | red_list = bgp->redist[afi][i]; | |
12626 | if (!red_list) | |
12627 | continue; | |
12628 | ||
12629 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 12630 | /* "redistribute" configuration. */ |
12631 | vty_out(vty, " redistribute %s", | |
12632 | zebra_route_string(i)); | |
12633 | if (red->instance) | |
12634 | vty_out(vty, " %d", red->instance); | |
12635 | if (red->redist_metric_flag) | |
12636 | vty_out(vty, " metric %u", | |
12637 | red->redist_metric); | |
12638 | if (red->rmap.name) | |
12639 | vty_out(vty, " route-map %s", | |
12640 | red->rmap.name); | |
12641 | vty_out(vty, "\n"); | |
12642 | } | |
12643 | } | |
12644 | } | |
718e3744 | 12645 | } |
6b0655a2 | 12646 | |
b9c7bc5a PZ |
12647 | /* This is part of the address-family block (unicast only) */ |
12648 | void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, | |
ddb5b488 PZ |
12649 | afi_t afi) |
12650 | { | |
b9c7bc5a | 12651 | int indent = 2; |
ddb5b488 | 12652 | |
8a066a70 PG |
12653 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
12654 | if (listcount(bgp->vpn_policy[afi].import_vrf)) | |
12655 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", | |
12656 | bgp->vpn_policy[afi] | |
bb4f6190 | 12657 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
12658 | else |
12659 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
12660 | bgp->vpn_policy[afi] | |
12661 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
12662 | } | |
12a844a5 DS |
12663 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
12664 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
12665 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
12666 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
12667 | return; | |
12668 | ||
e70e9f8e PZ |
12669 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
12670 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
12671 | ||
12672 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
12673 | ||
12674 | } else { | |
12675 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
12676 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
12677 | bgp->vpn_policy[afi].tovpn_label); | |
12678 | } | |
ddb5b488 PZ |
12679 | } |
12680 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
12681 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
12682 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 12683 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
12684 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
12685 | sizeof(buf))); | |
12686 | } | |
12687 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
12688 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
12689 | ||
12690 | char buf[PREFIX_STRLEN]; | |
12691 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
12692 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
12693 | sizeof(buf))) { | |
12694 | ||
b9c7bc5a PZ |
12695 | vty_out(vty, "%*snexthop vpn export %s\n", |
12696 | indent, "", buf); | |
ddb5b488 PZ |
12697 | } |
12698 | } | |
12699 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
12700 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
12701 | && ecommunity_cmp( | |
12702 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
12703 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
12704 | ||
12705 | char *b = ecommunity_ecom2str( | |
12706 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
12707 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12708 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
12709 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12710 | } else { | |
12711 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
12712 | char *b = ecommunity_ecom2str( | |
12713 | bgp->vpn_policy[afi] | |
12714 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
12715 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12716 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12717 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
12718 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12719 | } | |
12720 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
12721 | char *b = ecommunity_ecom2str( | |
12722 | bgp->vpn_policy[afi] | |
12723 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
12724 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12725 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12726 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
12727 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12728 | } | |
12729 | } | |
bb4f6190 DS |
12730 | |
12731 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 12732 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
12733 | bgp->vpn_policy[afi] |
12734 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 12735 | |
301ad80a PG |
12736 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
12737 | char *b = ecommunity_ecom2str( | |
12738 | bgp->vpn_policy[afi] | |
12739 | .import_redirect_rtlist, | |
12740 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12741 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 12742 | |
301ad80a PG |
12743 | vty_out(vty, "%*srt redirect import %s\n", indent, "", b); |
12744 | XFREE(MTYPE_ECOMMUNITY_STR, b); | |
12745 | } | |
ddb5b488 PZ |
12746 | } |
12747 | ||
12748 | ||
718e3744 | 12749 | /* BGP node structure. */ |
d62a17ae | 12750 | static struct cmd_node bgp_node = { |
9d303b37 | 12751 | BGP_NODE, "%s(config-router)# ", 1, |
718e3744 | 12752 | }; |
12753 | ||
d62a17ae | 12754 | static struct cmd_node bgp_ipv4_unicast_node = { |
9d303b37 | 12755 | BGP_IPV4_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12756 | }; |
12757 | ||
d62a17ae | 12758 | static struct cmd_node bgp_ipv4_multicast_node = { |
9d303b37 | 12759 | BGP_IPV4M_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12760 | }; |
12761 | ||
d62a17ae | 12762 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
9d303b37 | 12763 | BGP_IPV4L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
12764 | }; |
12765 | ||
d62a17ae | 12766 | static struct cmd_node bgp_ipv6_unicast_node = { |
9d303b37 | 12767 | BGP_IPV6_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12768 | }; |
12769 | ||
d62a17ae | 12770 | static struct cmd_node bgp_ipv6_multicast_node = { |
9d303b37 | 12771 | BGP_IPV6M_NODE, "%s(config-router-af)# ", 1, |
25ffbdc1 | 12772 | }; |
12773 | ||
d62a17ae | 12774 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
9d303b37 | 12775 | BGP_IPV6L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
12776 | }; |
12777 | ||
d62a17ae | 12778 | static struct cmd_node bgp_vpnv4_node = {BGP_VPNV4_NODE, |
12779 | "%s(config-router-af)# ", 1}; | |
6b0655a2 | 12780 | |
d62a17ae | 12781 | static struct cmd_node bgp_vpnv6_node = {BGP_VPNV6_NODE, |
12782 | "%s(config-router-af-vpnv6)# ", 1}; | |
8ecd3266 | 12783 | |
d62a17ae | 12784 | static struct cmd_node bgp_evpn_node = {BGP_EVPN_NODE, |
12785 | "%s(config-router-evpn)# ", 1}; | |
4e0b7b6d | 12786 | |
d62a17ae | 12787 | static struct cmd_node bgp_evpn_vni_node = {BGP_EVPN_VNI_NODE, |
12788 | "%s(config-router-af-vni)# ", 1}; | |
90e60aa7 | 12789 | |
7c40bf39 | 12790 | static struct cmd_node bgp_flowspecv4_node = {BGP_FLOWSPECV4_NODE, |
12791 | "%s(config-router-af)# ", 1}; | |
12792 | ||
12793 | static struct cmd_node bgp_flowspecv6_node = {BGP_FLOWSPECV6_NODE, | |
12794 | "%s(config-router-af-vpnv6)# ", 1}; | |
12795 | ||
d62a17ae | 12796 | static void community_list_vty(void); |
1f8ae70b | 12797 | |
d62a17ae | 12798 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 12799 | { |
d62a17ae | 12800 | struct bgp *bgp; |
12801 | struct peer *peer; | |
d62a17ae | 12802 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 12803 | |
d62a17ae | 12804 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
12805 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
12806 | /* only provide suggestions on the appropriate input | |
12807 | * token type, | |
12808 | * they'll otherwise show up multiple times */ | |
12809 | enum cmd_token_type match_type; | |
12810 | char *name = peer->host; | |
d48ed3e0 | 12811 | |
d62a17ae | 12812 | if (peer->conf_if) { |
12813 | match_type = VARIABLE_TKN; | |
12814 | name = peer->conf_if; | |
12815 | } else if (strchr(peer->host, ':')) | |
12816 | match_type = IPV6_TKN; | |
12817 | else | |
12818 | match_type = IPV4_TKN; | |
d48ed3e0 | 12819 | |
d62a17ae | 12820 | if (token->type != match_type) |
12821 | continue; | |
d48ed3e0 | 12822 | |
d62a17ae | 12823 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
12824 | } | |
d62a17ae | 12825 | } |
b8a815e5 DL |
12826 | } |
12827 | ||
12828 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 12829 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
12830 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 12831 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 12832 | {.completions = NULL}}; |
12833 | ||
47a306a0 DS |
12834 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
12835 | { | |
12836 | struct bgp *bgp; | |
12837 | struct peer_group *group; | |
12838 | struct listnode *lnbgp, *lnpeer; | |
12839 | ||
12840 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
12841 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
12842 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
12843 | group->name)); | |
12844 | } | |
12845 | } | |
12846 | ||
12847 | static const struct cmd_variable_handler bgp_var_peergroup[] = { | |
12848 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
12849 | {.completions = NULL} }; | |
12850 | ||
d62a17ae | 12851 | void bgp_vty_init(void) |
12852 | { | |
12853 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 12854 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 12855 | |
12856 | /* Install bgp top node. */ | |
12857 | install_node(&bgp_node, bgp_config_write); | |
12858 | install_node(&bgp_ipv4_unicast_node, NULL); | |
12859 | install_node(&bgp_ipv4_multicast_node, NULL); | |
12860 | install_node(&bgp_ipv4_labeled_unicast_node, NULL); | |
12861 | install_node(&bgp_ipv6_unicast_node, NULL); | |
12862 | install_node(&bgp_ipv6_multicast_node, NULL); | |
12863 | install_node(&bgp_ipv6_labeled_unicast_node, NULL); | |
12864 | install_node(&bgp_vpnv4_node, NULL); | |
12865 | install_node(&bgp_vpnv6_node, NULL); | |
12866 | install_node(&bgp_evpn_node, NULL); | |
12867 | install_node(&bgp_evpn_vni_node, NULL); | |
7c40bf39 | 12868 | install_node(&bgp_flowspecv4_node, NULL); |
12869 | install_node(&bgp_flowspecv6_node, NULL); | |
d62a17ae | 12870 | |
12871 | /* Install default VTY commands to new nodes. */ | |
12872 | install_default(BGP_NODE); | |
12873 | install_default(BGP_IPV4_NODE); | |
12874 | install_default(BGP_IPV4M_NODE); | |
12875 | install_default(BGP_IPV4L_NODE); | |
12876 | install_default(BGP_IPV6_NODE); | |
12877 | install_default(BGP_IPV6M_NODE); | |
12878 | install_default(BGP_IPV6L_NODE); | |
12879 | install_default(BGP_VPNV4_NODE); | |
12880 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 12881 | install_default(BGP_FLOWSPECV4_NODE); |
12882 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 12883 | install_default(BGP_EVPN_NODE); |
12884 | install_default(BGP_EVPN_VNI_NODE); | |
12885 | ||
12886 | /* "bgp multiple-instance" commands. */ | |
12887 | install_element(CONFIG_NODE, &bgp_multiple_instance_cmd); | |
12888 | install_element(CONFIG_NODE, &no_bgp_multiple_instance_cmd); | |
12889 | ||
12890 | /* "bgp config-type" commands. */ | |
12891 | install_element(CONFIG_NODE, &bgp_config_type_cmd); | |
12892 | install_element(CONFIG_NODE, &no_bgp_config_type_cmd); | |
12893 | ||
8029b216 AK |
12894 | /* "bgp local-mac" hidden commands. */ |
12895 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
12896 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
12897 | ||
d62a17ae | 12898 | /* bgp route-map delay-timer commands. */ |
12899 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
12900 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
12901 | ||
12902 | /* Dummy commands (Currently not supported) */ | |
12903 | install_element(BGP_NODE, &no_synchronization_cmd); | |
12904 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
12905 | ||
12906 | /* "router bgp" commands. */ | |
12907 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
12908 | ||
12909 | /* "no router bgp" commands. */ | |
12910 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
12911 | ||
12912 | /* "bgp router-id" commands. */ | |
12913 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
12914 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
12915 | ||
12916 | /* "bgp cluster-id" commands. */ | |
12917 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
12918 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
12919 | ||
12920 | /* "bgp confederation" commands. */ | |
12921 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
12922 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
12923 | ||
12924 | /* "bgp confederation peers" commands. */ | |
12925 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
12926 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
12927 | ||
12928 | /* bgp max-med command */ | |
12929 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
12930 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
12931 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
12932 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
12933 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
12934 | ||
12935 | /* bgp disable-ebgp-connected-nh-check */ | |
12936 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
12937 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
12938 | ||
12939 | /* bgp update-delay command */ | |
12940 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
12941 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
12942 | install_element(BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
12943 | ||
12944 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
12945 | install_element(BGP_NODE, &no_bgp_wpkt_quanta_cmd); | |
555e09d4 QY |
12946 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
12947 | install_element(BGP_NODE, &no_bgp_rpkt_quanta_cmd); | |
d62a17ae | 12948 | |
12949 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
12950 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
12951 | ||
12952 | /* "maximum-paths" commands. */ | |
12953 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
12954 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
12955 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
12956 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
12957 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
12958 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
12959 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
12960 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
12961 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
12962 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
12963 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
12964 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
12965 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
12966 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
12967 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
12968 | ||
12969 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); | |
12970 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
12971 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
12972 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
12973 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
12974 | ||
12975 | /* "timers bgp" commands. */ | |
12976 | install_element(BGP_NODE, &bgp_timers_cmd); | |
12977 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
12978 | ||
12979 | /* route-map delay-timer commands - per instance for backwards compat. | |
12980 | */ | |
12981 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
12982 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
12983 | ||
12984 | /* "bgp client-to-client reflection" commands */ | |
12985 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
12986 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
12987 | ||
12988 | /* "bgp always-compare-med" commands */ | |
12989 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
12990 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
12991 | ||
9dac9fc8 DA |
12992 | /* bgp ebgp-requires-policy */ |
12993 | install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd); | |
12994 | install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd); | |
12995 | ||
d62a17ae | 12996 | /* "bgp deterministic-med" commands */ |
12997 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
12998 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
12999 | ||
13000 | /* "bgp graceful-restart" commands */ | |
13001 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); | |
13002 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
13003 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); | |
13004 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
13005 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
13006 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
13007 | ||
13008 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); | |
13009 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
13010 | ||
7f323236 DW |
13011 | /* "bgp graceful-shutdown" commands */ |
13012 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
13013 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
13014 | ||
d62a17ae | 13015 | /* "bgp fast-external-failover" commands */ |
13016 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
13017 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
13018 | ||
13019 | /* "bgp enforce-first-as" commands */ | |
13020 | install_element(BGP_NODE, &bgp_enforce_first_as_cmd); | |
d62a17ae | 13021 | |
13022 | /* "bgp bestpath compare-routerid" commands */ | |
13023 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
13024 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
13025 | ||
13026 | /* "bgp bestpath as-path ignore" commands */ | |
13027 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
13028 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
13029 | ||
13030 | /* "bgp bestpath as-path confed" commands */ | |
13031 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
13032 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
13033 | ||
13034 | /* "bgp bestpath as-path multipath-relax" commands */ | |
13035 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
13036 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
13037 | ||
13038 | /* "bgp log-neighbor-changes" commands */ | |
13039 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
13040 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
13041 | ||
13042 | /* "bgp bestpath med" commands */ | |
13043 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
13044 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
13045 | ||
13046 | /* "no bgp default ipv4-unicast" commands. */ | |
13047 | install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
13048 | install_element(BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
13049 | ||
13050 | /* "bgp network import-check" commands. */ | |
13051 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
13052 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
13053 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
13054 | ||
13055 | /* "bgp default local-preference" commands. */ | |
13056 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
13057 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
13058 | ||
13059 | /* bgp default show-hostname */ | |
13060 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
13061 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
13062 | ||
13063 | /* "bgp default subgroup-pkt-queue-max" commands. */ | |
13064 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
13065 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
13066 | ||
13067 | /* bgp ibgp-allow-policy-mods command */ | |
13068 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
13069 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
13070 | ||
13071 | /* "bgp listen limit" commands. */ | |
13072 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
13073 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
13074 | ||
13075 | /* "bgp listen range" commands. */ | |
13076 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
13077 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
13078 | ||
8175f54a | 13079 | /* "bgp default shutdown" command */ |
f26845f9 QY |
13080 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
13081 | ||
d62a17ae | 13082 | /* "neighbor remote-as" commands. */ |
13083 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
13084 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
13085 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
13086 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
13087 | install_element(BGP_NODE, | |
13088 | &neighbor_interface_v6only_config_remote_as_cmd); | |
13089 | install_element(BGP_NODE, &no_neighbor_cmd); | |
13090 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
13091 | ||
13092 | /* "neighbor peer-group" commands. */ | |
13093 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
13094 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
13095 | install_element(BGP_NODE, | |
13096 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
13097 | ||
13098 | /* "neighbor local-as" commands. */ | |
13099 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
13100 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
13101 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
13102 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
13103 | ||
13104 | /* "neighbor solo" commands. */ | |
13105 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
13106 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
13107 | ||
13108 | /* "neighbor password" commands. */ | |
13109 | install_element(BGP_NODE, &neighbor_password_cmd); | |
13110 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
13111 | ||
13112 | /* "neighbor activate" commands. */ | |
13113 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
13114 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
13115 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
13116 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
13117 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
13118 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
13119 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
13120 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
13121 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 13122 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
13123 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 13124 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
13125 | ||
13126 | /* "no neighbor activate" commands. */ | |
13127 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
13128 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
13129 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
13130 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
13131 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
13132 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
13133 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
13134 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
13135 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 13136 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
13137 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 13138 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
13139 | ||
13140 | /* "neighbor peer-group" set commands. */ | |
13141 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
13142 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13143 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13144 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13145 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13146 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13147 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13148 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 13149 | install_element(BGP_FLOWSPECV4_NODE, |
13150 | &neighbor_set_peer_group_hidden_cmd); | |
13151 | install_element(BGP_FLOWSPECV6_NODE, | |
13152 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 13153 | |
13154 | /* "no neighbor peer-group unset" commands. */ | |
13155 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
13156 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13157 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13158 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13159 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13160 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13161 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13162 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 13163 | install_element(BGP_FLOWSPECV4_NODE, |
13164 | &no_neighbor_set_peer_group_hidden_cmd); | |
13165 | install_element(BGP_FLOWSPECV6_NODE, | |
13166 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 13167 | |
13168 | /* "neighbor softreconfiguration inbound" commands.*/ | |
13169 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
13170 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
13171 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
13172 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13173 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
13174 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13175 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
13176 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13177 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
13178 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13179 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
13180 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13181 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
13182 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13183 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
13184 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13185 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
13186 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 13187 | install_element(BGP_FLOWSPECV4_NODE, |
13188 | &neighbor_soft_reconfiguration_cmd); | |
13189 | install_element(BGP_FLOWSPECV4_NODE, | |
13190 | &no_neighbor_soft_reconfiguration_cmd); | |
13191 | install_element(BGP_FLOWSPECV6_NODE, | |
13192 | &neighbor_soft_reconfiguration_cmd); | |
13193 | install_element(BGP_FLOWSPECV6_NODE, | |
13194 | &no_neighbor_soft_reconfiguration_cmd); | |
616c6ee8 PG |
13195 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); |
13196 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 13197 | |
13198 | /* "neighbor attribute-unchanged" commands. */ | |
13199 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
13200 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
13201 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
13202 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
13203 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
13204 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
13205 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
13206 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
13207 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
13208 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
13209 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
13210 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
13211 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
13212 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
13213 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
13214 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
13215 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
13216 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
13217 | ||
13218 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
13219 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
13220 | ||
13221 | /* "nexthop-local unchanged" commands */ | |
13222 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
13223 | install_element(BGP_IPV6_NODE, | |
13224 | &no_neighbor_nexthop_local_unchanged_cmd); | |
13225 | ||
13226 | /* "neighbor next-hop-self" commands. */ | |
13227 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
13228 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
13229 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
13230 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
13231 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
13232 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
13233 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
13234 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
13235 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
13236 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
13237 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
13238 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
13239 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
13240 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
13241 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
13242 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
13243 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
13244 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
13245 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
13246 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 13247 | |
13248 | /* "neighbor next-hop-self force" commands. */ | |
13249 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
13250 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
1bc4e531 DA |
13251 | install_element(BGP_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
13252 | install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 13253 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
13254 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13255 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); | |
13256 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13257 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); | |
13258 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13259 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); | |
13260 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13261 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); | |
13262 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13263 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); | |
13264 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13265 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); | |
13266 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13267 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); | |
13268 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13269 | ||
13270 | /* "neighbor as-override" commands. */ | |
13271 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
13272 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
13273 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
13274 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
13275 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
13276 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
13277 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
13278 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
13279 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
13280 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
13281 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
13282 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
13283 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
13284 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
13285 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
13286 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
13287 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
13288 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
13289 | ||
13290 | /* "neighbor remove-private-AS" commands. */ | |
13291 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
13292 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
13293 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
13294 | install_element(BGP_NODE, | |
13295 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
13296 | install_element(BGP_NODE, | |
13297 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
13298 | install_element(BGP_NODE, | |
13299 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
13300 | install_element(BGP_NODE, | |
13301 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
13302 | install_element( | |
13303 | BGP_NODE, | |
13304 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
13305 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
13306 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
13307 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
13308 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13309 | install_element(BGP_IPV4_NODE, | |
13310 | &neighbor_remove_private_as_replace_as_cmd); | |
13311 | install_element(BGP_IPV4_NODE, | |
13312 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13313 | install_element(BGP_IPV4_NODE, | |
13314 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13315 | install_element(BGP_IPV4_NODE, | |
13316 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13317 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
13318 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
13319 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
13320 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13321 | install_element(BGP_IPV4M_NODE, | |
13322 | &neighbor_remove_private_as_replace_as_cmd); | |
13323 | install_element(BGP_IPV4M_NODE, | |
13324 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13325 | install_element(BGP_IPV4M_NODE, | |
13326 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13327 | install_element(BGP_IPV4M_NODE, | |
13328 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13329 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
13330 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
13331 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
13332 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13333 | install_element(BGP_IPV4L_NODE, | |
13334 | &neighbor_remove_private_as_replace_as_cmd); | |
13335 | install_element(BGP_IPV4L_NODE, | |
13336 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13337 | install_element(BGP_IPV4L_NODE, | |
13338 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13339 | install_element(BGP_IPV4L_NODE, | |
13340 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13341 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
13342 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
13343 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
13344 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13345 | install_element(BGP_IPV6_NODE, | |
13346 | &neighbor_remove_private_as_replace_as_cmd); | |
13347 | install_element(BGP_IPV6_NODE, | |
13348 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13349 | install_element(BGP_IPV6_NODE, | |
13350 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13351 | install_element(BGP_IPV6_NODE, | |
13352 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13353 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
13354 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
13355 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
13356 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13357 | install_element(BGP_IPV6M_NODE, | |
13358 | &neighbor_remove_private_as_replace_as_cmd); | |
13359 | install_element(BGP_IPV6M_NODE, | |
13360 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13361 | install_element(BGP_IPV6M_NODE, | |
13362 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13363 | install_element(BGP_IPV6M_NODE, | |
13364 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13365 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
13366 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
13367 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
13368 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13369 | install_element(BGP_IPV6L_NODE, | |
13370 | &neighbor_remove_private_as_replace_as_cmd); | |
13371 | install_element(BGP_IPV6L_NODE, | |
13372 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13373 | install_element(BGP_IPV6L_NODE, | |
13374 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13375 | install_element(BGP_IPV6L_NODE, | |
13376 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13377 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
13378 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
13379 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
13380 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13381 | install_element(BGP_VPNV4_NODE, | |
13382 | &neighbor_remove_private_as_replace_as_cmd); | |
13383 | install_element(BGP_VPNV4_NODE, | |
13384 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13385 | install_element(BGP_VPNV4_NODE, | |
13386 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13387 | install_element(BGP_VPNV4_NODE, | |
13388 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13389 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
13390 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
13391 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
13392 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13393 | install_element(BGP_VPNV6_NODE, | |
13394 | &neighbor_remove_private_as_replace_as_cmd); | |
13395 | install_element(BGP_VPNV6_NODE, | |
13396 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13397 | install_element(BGP_VPNV6_NODE, | |
13398 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13399 | install_element(BGP_VPNV6_NODE, | |
13400 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13401 | ||
13402 | /* "neighbor send-community" commands.*/ | |
13403 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
13404 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
13405 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
13406 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
13407 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
13408 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
13409 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
13410 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
13411 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
13412 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
13413 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
13414 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
13415 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
13416 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
13417 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
13418 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
13419 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
13420 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
13421 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
13422 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
13423 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
13424 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
13425 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
13426 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
13427 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
13428 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
13429 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
13430 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
13431 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
13432 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
13433 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
13434 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
13435 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
13436 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
13437 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
13438 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
13439 | ||
13440 | /* "neighbor route-reflector" commands.*/ | |
13441 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
13442 | install_element(BGP_NODE, | |
13443 | &no_neighbor_route_reflector_client_hidden_cmd); | |
13444 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
13445 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
13446 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
13447 | install_element(BGP_IPV4M_NODE, | |
13448 | &no_neighbor_route_reflector_client_cmd); | |
13449 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
13450 | install_element(BGP_IPV4L_NODE, | |
13451 | &no_neighbor_route_reflector_client_cmd); | |
13452 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
13453 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
13454 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
13455 | install_element(BGP_IPV6M_NODE, | |
13456 | &no_neighbor_route_reflector_client_cmd); | |
13457 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
13458 | install_element(BGP_IPV6L_NODE, | |
13459 | &no_neighbor_route_reflector_client_cmd); | |
13460 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
13461 | install_element(BGP_VPNV4_NODE, | |
13462 | &no_neighbor_route_reflector_client_cmd); | |
13463 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
13464 | install_element(BGP_VPNV6_NODE, | |
13465 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 13466 | install_element(BGP_FLOWSPECV4_NODE, |
13467 | &neighbor_route_reflector_client_cmd); | |
13468 | install_element(BGP_FLOWSPECV4_NODE, | |
13469 | &no_neighbor_route_reflector_client_cmd); | |
13470 | install_element(BGP_FLOWSPECV6_NODE, | |
13471 | &neighbor_route_reflector_client_cmd); | |
13472 | install_element(BGP_FLOWSPECV6_NODE, | |
13473 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 13474 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
13475 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
13476 | ||
13477 | /* "neighbor route-server" commands.*/ | |
13478 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
13479 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
13480 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
13481 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
13482 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
13483 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
13484 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
13485 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
13486 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
13487 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
13488 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
13489 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
13490 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
13491 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
13492 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
13493 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
13494 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
13495 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
13496 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
13497 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 13498 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
13499 | install_element(BGP_FLOWSPECV4_NODE, | |
13500 | &no_neighbor_route_server_client_cmd); | |
13501 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
13502 | install_element(BGP_FLOWSPECV6_NODE, | |
13503 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 13504 | |
13505 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
13506 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
13507 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
13508 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13509 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13510 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13511 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13512 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13513 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13514 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13515 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13516 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13517 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13518 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13519 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13520 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13521 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13522 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13523 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13524 | ||
13525 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
13526 | install_element(BGP_NODE, | |
13527 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
13528 | install_element(BGP_NODE, | |
13529 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
13530 | install_element(BGP_IPV4_NODE, | |
13531 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13532 | install_element(BGP_IPV4_NODE, | |
13533 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13534 | install_element(BGP_IPV4M_NODE, | |
13535 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13536 | install_element(BGP_IPV4M_NODE, | |
13537 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13538 | install_element(BGP_IPV4L_NODE, | |
13539 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13540 | install_element(BGP_IPV4L_NODE, | |
13541 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13542 | install_element(BGP_IPV6_NODE, | |
13543 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13544 | install_element(BGP_IPV6_NODE, | |
13545 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13546 | install_element(BGP_IPV6M_NODE, | |
13547 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13548 | install_element(BGP_IPV6M_NODE, | |
13549 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13550 | install_element(BGP_IPV6L_NODE, | |
13551 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13552 | install_element(BGP_IPV6L_NODE, | |
13553 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13554 | install_element(BGP_VPNV4_NODE, | |
13555 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13556 | install_element(BGP_VPNV4_NODE, | |
13557 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13558 | install_element(BGP_VPNV6_NODE, | |
13559 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13560 | install_element(BGP_VPNV6_NODE, | |
13561 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13562 | ||
13563 | /* "neighbor passive" commands. */ | |
13564 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
13565 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
13566 | ||
13567 | ||
13568 | /* "neighbor shutdown" commands. */ | |
13569 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
13570 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
13571 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
13572 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
13573 | ||
13574 | /* "neighbor capability extended-nexthop" commands.*/ | |
13575 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
13576 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
13577 | ||
13578 | /* "neighbor capability orf prefix-list" commands.*/ | |
13579 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
13580 | install_element(BGP_NODE, | |
13581 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
13582 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
13583 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13584 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
13585 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13586 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
13587 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13588 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
13589 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13590 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
13591 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13592 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
13593 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13594 | ||
13595 | /* "neighbor capability dynamic" commands.*/ | |
13596 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
13597 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
13598 | ||
13599 | /* "neighbor dont-capability-negotiate" commands. */ | |
13600 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
13601 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
13602 | ||
13603 | /* "neighbor ebgp-multihop" commands. */ | |
13604 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
13605 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
13606 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
13607 | ||
13608 | /* "neighbor disable-connected-check" commands. */ | |
13609 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
13610 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
13611 | ||
47cbc09b PM |
13612 | /* "neighbor enforce-first-as" commands. */ |
13613 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
13614 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
13615 | ||
d62a17ae | 13616 | /* "neighbor description" commands. */ |
13617 | install_element(BGP_NODE, &neighbor_description_cmd); | |
13618 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 13619 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 13620 | |
13621 | /* "neighbor update-source" commands. "*/ | |
13622 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
13623 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
13624 | ||
13625 | /* "neighbor default-originate" commands. */ | |
13626 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
13627 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
13628 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
13629 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
13630 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
13631 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
13632 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
13633 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
13634 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
13635 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
13636 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
13637 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
13638 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
13639 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
13640 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
13641 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
13642 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
13643 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
13644 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
13645 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
13646 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
13647 | ||
13648 | /* "neighbor port" commands. */ | |
13649 | install_element(BGP_NODE, &neighbor_port_cmd); | |
13650 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
13651 | ||
13652 | /* "neighbor weight" commands. */ | |
13653 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
13654 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
13655 | ||
13656 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
13657 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
13658 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
13659 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
13660 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
13661 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
13662 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
13663 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
13664 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
13665 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
13666 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
13667 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
13668 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
13669 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
13670 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
13671 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
13672 | ||
13673 | /* "neighbor override-capability" commands. */ | |
13674 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
13675 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
13676 | ||
13677 | /* "neighbor strict-capability-match" commands. */ | |
13678 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
13679 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
13680 | ||
13681 | /* "neighbor timers" commands. */ | |
13682 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
13683 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
13684 | ||
13685 | /* "neighbor timers connect" commands. */ | |
13686 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
13687 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
13688 | ||
13689 | /* "neighbor advertisement-interval" commands. */ | |
13690 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
13691 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
13692 | ||
13693 | /* "neighbor interface" commands. */ | |
13694 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
13695 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
13696 | ||
13697 | /* "neighbor distribute" commands. */ | |
13698 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
13699 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
13700 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
13701 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
13702 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
13703 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
13704 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
13705 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
13706 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
13707 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
13708 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
13709 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
13710 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
13711 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
13712 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
13713 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
13714 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
13715 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
13716 | ||
13717 | /* "neighbor prefix-list" commands. */ | |
13718 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
13719 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
13720 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
13721 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
13722 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
13723 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
13724 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); | |
13725 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
13726 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
13727 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
13728 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); | |
13729 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
13730 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); | |
13731 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
13732 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); | |
13733 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
13734 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); | |
13735 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
7c40bf39 | 13736 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
13737 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); | |
13738 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); | |
13739 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); | |
d62a17ae | 13740 | |
13741 | /* "neighbor filter-list" commands. */ | |
13742 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
13743 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
13744 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
13745 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
13746 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
13747 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
13748 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
13749 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
13750 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
13751 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
13752 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
13753 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
13754 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
13755 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
13756 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
13757 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
13758 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
13759 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 13760 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
13761 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
13762 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
13763 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 13764 | |
13765 | /* "neighbor route-map" commands. */ | |
13766 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); | |
13767 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
13768 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
13769 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
13770 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
13771 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
13772 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); | |
13773 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
13774 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
13775 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
13776 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); | |
13777 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
13778 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); | |
13779 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
13780 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); | |
13781 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
13782 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); | |
13783 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
7c40bf39 | 13784 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
13785 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); | |
13786 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); | |
13787 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); | |
d37ba549 MK |
13788 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
13789 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); | |
d62a17ae | 13790 | |
13791 | /* "neighbor unsuppress-map" commands. */ | |
13792 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
13793 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
13794 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
13795 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
13796 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
13797 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
13798 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
13799 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
13800 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
13801 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
13802 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
13803 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
13804 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
13805 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
13806 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
13807 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
13808 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
13809 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
13810 | ||
13811 | /* "neighbor maximum-prefix" commands. */ | |
13812 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
13813 | install_element(BGP_NODE, | |
13814 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
13815 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
13816 | install_element(BGP_NODE, | |
13817 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
13818 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
13819 | install_element(BGP_NODE, | |
13820 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
13821 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
13822 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
13823 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13824 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13825 | install_element(BGP_IPV4_NODE, | |
13826 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13827 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13828 | install_element(BGP_IPV4_NODE, | |
13829 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13830 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
13831 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
13832 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13833 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13834 | install_element(BGP_IPV4M_NODE, | |
13835 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13836 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13837 | install_element(BGP_IPV4M_NODE, | |
13838 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13839 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
13840 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
13841 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13842 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13843 | install_element(BGP_IPV4L_NODE, | |
13844 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13845 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13846 | install_element(BGP_IPV4L_NODE, | |
13847 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13848 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
13849 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
13850 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13851 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13852 | install_element(BGP_IPV6_NODE, | |
13853 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13854 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13855 | install_element(BGP_IPV6_NODE, | |
13856 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13857 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
13858 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
13859 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13860 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13861 | install_element(BGP_IPV6M_NODE, | |
13862 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13863 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13864 | install_element(BGP_IPV6M_NODE, | |
13865 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13866 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
13867 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
13868 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13869 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13870 | install_element(BGP_IPV6L_NODE, | |
13871 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13872 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13873 | install_element(BGP_IPV6L_NODE, | |
13874 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13875 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
13876 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
13877 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13878 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13879 | install_element(BGP_VPNV4_NODE, | |
13880 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13881 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13882 | install_element(BGP_VPNV4_NODE, | |
13883 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13884 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
13885 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
13886 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13887 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13888 | install_element(BGP_VPNV6_NODE, | |
13889 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13890 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13891 | install_element(BGP_VPNV6_NODE, | |
13892 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13893 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
13894 | ||
13895 | /* "neighbor allowas-in" */ | |
13896 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
13897 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
13898 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
13899 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
13900 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
13901 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
13902 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
13903 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
13904 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
13905 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
13906 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
13907 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
13908 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
13909 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
13910 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
13911 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
13912 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
13913 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
13914 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
13915 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
13916 | ||
13917 | /* address-family commands. */ | |
13918 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
13919 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 13920 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 13921 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
13922 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 13923 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 13924 | |
d62a17ae | 13925 | install_element(BGP_NODE, &address_family_evpn_cmd); |
13926 | ||
13927 | /* "exit-address-family" command. */ | |
13928 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
13929 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
13930 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
13931 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
13932 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
13933 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
13934 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
13935 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 13936 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
13937 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 13938 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
13939 | ||
13940 | /* "clear ip bgp commands" */ | |
13941 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
13942 | ||
13943 | /* clear ip bgp prefix */ | |
13944 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
13945 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
13946 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
13947 | ||
13948 | /* "show [ip] bgp summary" commands. */ | |
13949 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 13950 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 13951 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 13952 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 13953 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
13954 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 13955 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
13956 | ||
13957 | /* "show [ip] bgp neighbors" commands. */ | |
13958 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
13959 | ||
13960 | /* "show [ip] bgp peer-group" commands. */ | |
13961 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
13962 | ||
13963 | /* "show [ip] bgp paths" commands. */ | |
13964 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
13965 | ||
13966 | /* "show [ip] bgp community" commands. */ | |
13967 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
13968 | ||
13969 | /* "show ip bgp large-community" commands. */ | |
13970 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
13971 | /* "show [ip] bgp attribute-info" commands. */ | |
13972 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 13973 | /* "show [ip] bgp route-leak" command */ |
13974 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 13975 | |
13976 | /* "redistribute" commands. */ | |
13977 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
13978 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
13979 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
13980 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
13981 | install_element(BGP_NODE, | |
13982 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
13983 | install_element(BGP_NODE, | |
13984 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
13985 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
13986 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
13987 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
13988 | install_element(BGP_NODE, | |
13989 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
13990 | install_element(BGP_NODE, | |
13991 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
13992 | install_element(BGP_NODE, | |
13993 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
13994 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
13995 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
13996 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
13997 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
13998 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
13999 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
14000 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
14001 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
14002 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
14003 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
14004 | install_element(BGP_IPV4_NODE, | |
14005 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
14006 | install_element(BGP_IPV4_NODE, | |
14007 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
14008 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
14009 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
14010 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
14011 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
14012 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
14013 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
14014 | ||
b9c7bc5a PZ |
14015 | /* import|export vpn [route-map WORD] */ |
14016 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
14017 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 14018 | |
12a844a5 DS |
14019 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
14020 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
14021 | ||
d62a17ae | 14022 | /* ttl_security commands */ |
14023 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
14024 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
14025 | ||
14026 | /* "show [ip] bgp memory" commands. */ | |
14027 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
14028 | ||
acf71666 MK |
14029 | /* "show bgp martian next-hop" */ |
14030 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
14031 | ||
48ecf8f5 DS |
14032 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); |
14033 | ||
d62a17ae | 14034 | /* "show [ip] bgp views" commands. */ |
14035 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
14036 | ||
14037 | /* "show [ip] bgp vrfs" commands. */ | |
14038 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
14039 | ||
14040 | /* Community-list. */ | |
14041 | community_list_vty(); | |
ddb5b488 PZ |
14042 | |
14043 | /* vpn-policy commands */ | |
b9c7bc5a PZ |
14044 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
14045 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
14046 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
14047 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
14048 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
14049 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
14050 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
14051 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
14052 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
14053 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
14054 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
14055 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 14056 | |
301ad80a PG |
14057 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
14058 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
14059 | ||
b9c7bc5a PZ |
14060 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
14061 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
14062 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
14063 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
14064 | install_element(BGP_IPV4_NODE, &af_no_nexthop_vpn_export_cmd); | |
14065 | install_element(BGP_IPV6_NODE, &af_no_nexthop_vpn_export_cmd); | |
14066 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); | |
14067 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
14068 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
14069 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
14070 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
14071 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
718e3744 | 14072 | } |
6b0655a2 | 14073 | |
718e3744 | 14074 | #include "memory.h" |
14075 | #include "bgp_regex.h" | |
14076 | #include "bgp_clist.h" | |
14077 | #include "bgp_ecommunity.h" | |
14078 | ||
14079 | /* VTY functions. */ | |
14080 | ||
14081 | /* Direction value to string conversion. */ | |
d62a17ae | 14082 | static const char *community_direct_str(int direct) |
14083 | { | |
14084 | switch (direct) { | |
14085 | case COMMUNITY_DENY: | |
14086 | return "deny"; | |
14087 | case COMMUNITY_PERMIT: | |
14088 | return "permit"; | |
14089 | default: | |
14090 | return "unknown"; | |
14091 | } | |
718e3744 | 14092 | } |
14093 | ||
14094 | /* Display error string. */ | |
d62a17ae | 14095 | static void community_list_perror(struct vty *vty, int ret) |
14096 | { | |
14097 | switch (ret) { | |
14098 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
14099 | vty_out(vty, "%% Can't find community-list\n"); | |
14100 | break; | |
14101 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
14102 | vty_out(vty, "%% Malformed community-list value\n"); | |
14103 | break; | |
14104 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
14105 | vty_out(vty, | |
14106 | "%% Community name conflict, previously defined as standard community\n"); | |
14107 | break; | |
14108 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
14109 | vty_out(vty, | |
14110 | "%% Community name conflict, previously defined as expanded community\n"); | |
14111 | break; | |
14112 | } | |
718e3744 | 14113 | } |
14114 | ||
5bf15956 DW |
14115 | /* "community-list" keyword help string. */ |
14116 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
14117 | ||
7336e101 SP |
14118 | /*community-list standard */ |
14119 | DEFUN (community_list_standard, | |
14120 | bgp_community_list_standard_cmd, | |
14121 | "bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
14122 | BGP_STR | |
718e3744 | 14123 | COMMUNITY_LIST_STR |
14124 | "Community list number (standard)\n" | |
5bf15956 | 14125 | "Add an standard community-list entry\n" |
718e3744 | 14126 | "Community list name\n" |
14127 | "Specify community to reject\n" | |
14128 | "Specify community to accept\n" | |
14129 | COMMUNITY_VAL_STR) | |
14130 | { | |
d62a17ae | 14131 | char *cl_name_or_number = NULL; |
14132 | int direct = 0; | |
14133 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 14134 | |
d62a17ae | 14135 | int idx = 0; |
7336e101 SP |
14136 | |
14137 | if (argv_find(argv, argc, "ip", &idx)) { | |
14138 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14139 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14140 | vty_out(vty, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n"); | |
14141 | zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used"); | |
14142 | } | |
14143 | ||
d62a17ae | 14144 | argv_find(argv, argc, "(1-99)", &idx); |
14145 | argv_find(argv, argc, "WORD", &idx); | |
14146 | cl_name_or_number = argv[idx]->arg; | |
14147 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14148 | : COMMUNITY_DENY; | |
14149 | argv_find(argv, argc, "AA:NN", &idx); | |
14150 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14151 | |
d62a17ae | 14152 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
14153 | style); | |
42f914d4 | 14154 | |
d62a17ae | 14155 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14156 | |
d62a17ae | 14157 | if (ret < 0) { |
14158 | /* Display error string. */ | |
14159 | community_list_perror(vty, ret); | |
14160 | return CMD_WARNING_CONFIG_FAILED; | |
14161 | } | |
42f914d4 | 14162 | |
d62a17ae | 14163 | return CMD_SUCCESS; |
718e3744 | 14164 | } |
14165 | ||
7336e101 SP |
14166 | #if CONFDATE > 20191005 |
14167 | CPP_NOTICE("bgpd: remove deprecated 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' command") | |
14168 | #endif | |
14169 | ALIAS (community_list_standard, | |
14170 | ip_community_list_standard_cmd, | |
14171 | "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
718e3744 | 14172 | IP_STR |
14173 | COMMUNITY_LIST_STR | |
14174 | "Community list number (standard)\n" | |
5bf15956 DW |
14175 | "Add an standard community-list entry\n" |
14176 | "Community list name\n" | |
718e3744 | 14177 | "Specify community to reject\n" |
14178 | "Specify community to accept\n" | |
14179 | COMMUNITY_VAL_STR) | |
7336e101 SP |
14180 | |
14181 | DEFUN (no_community_list_standard_all, | |
14182 | no_bgp_community_list_standard_all_cmd, | |
14183 | "no bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
14184 | NO_STR | |
14185 | BGP_STR | |
14186 | COMMUNITY_LIST_STR | |
14187 | "Community list number (standard)\n" | |
14188 | "Add an standard community-list entry\n" | |
14189 | "Community list name\n" | |
14190 | "Specify community to reject\n" | |
14191 | "Specify community to accept\n" | |
14192 | COMMUNITY_VAL_STR) | |
718e3744 | 14193 | { |
d62a17ae | 14194 | char *cl_name_or_number = NULL; |
174b5cb9 | 14195 | char *str = NULL; |
d62a17ae | 14196 | int direct = 0; |
14197 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 14198 | |
d62a17ae | 14199 | int idx = 0; |
7336e101 SP |
14200 | |
14201 | if (argv_find(argv, argc, "ip", &idx)) { | |
14202 | vty_out(vty, "This config option is deprecated, and is scheduled for removal\n"); | |
14203 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14204 | vty_out(vty, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n"); | |
14205 | zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> |AA:NN' being used"); | |
14206 | } | |
14207 | ||
174b5cb9 DA |
14208 | argv_find(argv, argc, "permit", &idx); |
14209 | argv_find(argv, argc, "deny", &idx); | |
14210 | ||
14211 | if (idx) { | |
14212 | direct = argv_find(argv, argc, "permit", &idx) | |
14213 | ? COMMUNITY_PERMIT | |
14214 | : COMMUNITY_DENY; | |
14215 | ||
14216 | idx = 0; | |
14217 | argv_find(argv, argc, "AA:NN", &idx); | |
14218 | str = argv_concat(argv, argc, idx); | |
14219 | } | |
14220 | ||
14221 | idx = 0; | |
d62a17ae | 14222 | argv_find(argv, argc, "(1-99)", &idx); |
14223 | argv_find(argv, argc, "WORD", &idx); | |
14224 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 14225 | |
d62a17ae | 14226 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
7298a8e1 | 14227 | direct, style); |
42f914d4 | 14228 | |
d62a17ae | 14229 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 14230 | |
d62a17ae | 14231 | if (ret < 0) { |
14232 | community_list_perror(vty, ret); | |
14233 | return CMD_WARNING_CONFIG_FAILED; | |
14234 | } | |
42f914d4 | 14235 | |
d62a17ae | 14236 | return CMD_SUCCESS; |
718e3744 | 14237 | } |
7336e101 SP |
14238 | ALIAS (no_community_list_standard_all, |
14239 | no_ip_community_list_standard_all_cmd, | |
14240 | "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
14241 | NO_STR | |
718e3744 | 14242 | IP_STR |
14243 | COMMUNITY_LIST_STR | |
7336e101 SP |
14244 | "Community list number (standard)\n" |
14245 | "Add an standard community-list entry\n" | |
14246 | "Community list name\n" | |
14247 | "Specify community to reject\n" | |
14248 | "Specify community to accept\n" | |
14249 | COMMUNITY_VAL_STR) | |
14250 | ||
174b5cb9 DA |
14251 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
14252 | "no bgp community-list <(1-99)|standard WORD>", | |
14253 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
14254 | "Community list number (standard)\n" | |
14255 | "Add an standard community-list entry\n" | |
14256 | "Community list name\n") | |
14257 | ||
14258 | ALIAS(no_community_list_standard_all, no_ip_community_list_standard_all_list_cmd, | |
14259 | "no ip community-list <(1-99)|standard WORD>", | |
14260 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
14261 | "Community list number (standard)\n" | |
14262 | "Add an standard community-list entry\n" | |
14263 | "Community list name\n") | |
14264 | ||
7336e101 SP |
14265 | /*community-list expanded */ |
14266 | DEFUN (community_list_expanded_all, | |
14267 | bgp_community_list_expanded_all_cmd, | |
14268 | "bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
14269 | BGP_STR | |
14270 | COMMUNITY_LIST_STR | |
718e3744 | 14271 | "Community list number (expanded)\n" |
5bf15956 | 14272 | "Add an expanded community-list entry\n" |
718e3744 | 14273 | "Community list name\n" |
14274 | "Specify community to reject\n" | |
14275 | "Specify community to accept\n" | |
14276 | COMMUNITY_VAL_STR) | |
14277 | { | |
d62a17ae | 14278 | char *cl_name_or_number = NULL; |
14279 | int direct = 0; | |
14280 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 14281 | |
d62a17ae | 14282 | int idx = 0; |
7336e101 SP |
14283 | if (argv_find(argv, argc, "ip", &idx)) { |
14284 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14285 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14286 | vty_out(vty, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n"); | |
14287 | zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used"); | |
14288 | } | |
d62a17ae | 14289 | argv_find(argv, argc, "(100-500)", &idx); |
14290 | argv_find(argv, argc, "WORD", &idx); | |
14291 | cl_name_or_number = argv[idx]->arg; | |
14292 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14293 | : COMMUNITY_DENY; | |
14294 | argv_find(argv, argc, "AA:NN", &idx); | |
14295 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14296 | |
d62a17ae | 14297 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
14298 | style); | |
42f914d4 | 14299 | |
d62a17ae | 14300 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14301 | |
d62a17ae | 14302 | if (ret < 0) { |
14303 | /* Display error string. */ | |
14304 | community_list_perror(vty, ret); | |
14305 | return CMD_WARNING_CONFIG_FAILED; | |
14306 | } | |
42f914d4 | 14307 | |
d62a17ae | 14308 | return CMD_SUCCESS; |
718e3744 | 14309 | } |
14310 | ||
7336e101 SP |
14311 | ALIAS (community_list_expanded_all, |
14312 | ip_community_list_expanded_all_cmd, | |
14313 | "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
718e3744 | 14314 | IP_STR |
14315 | COMMUNITY_LIST_STR | |
5bf15956 DW |
14316 | "Community list number (expanded)\n" |
14317 | "Add an expanded community-list entry\n" | |
718e3744 | 14318 | "Community list name\n" |
14319 | "Specify community to reject\n" | |
14320 | "Specify community to accept\n" | |
5bf15956 | 14321 | COMMUNITY_VAL_STR) |
7336e101 SP |
14322 | |
14323 | DEFUN (no_community_list_expanded_all, | |
14324 | no_bgp_community_list_expanded_all_cmd, | |
14325 | "no bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
14326 | NO_STR | |
14327 | BGP_STR | |
14328 | COMMUNITY_LIST_STR | |
14329 | "Community list number (expanded)\n" | |
14330 | "Add an expanded community-list entry\n" | |
14331 | "Community list name\n" | |
14332 | "Specify community to reject\n" | |
14333 | "Specify community to accept\n" | |
14334 | COMMUNITY_VAL_STR) | |
718e3744 | 14335 | { |
d62a17ae | 14336 | char *cl_name_or_number = NULL; |
174b5cb9 | 14337 | char *str = NULL; |
d62a17ae | 14338 | int direct = 0; |
14339 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 14340 | |
d62a17ae | 14341 | int idx = 0; |
7336e101 SP |
14342 | if (argv_find(argv, argc, "ip", &idx)) { |
14343 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14344 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
174b5cb9 DA |
14345 | vty_out(vty, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n"); |
14346 | zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used"); | |
14347 | } | |
14348 | ||
3c4b8fe2 | 14349 | idx = 0; |
174b5cb9 DA |
14350 | argv_find(argv, argc, "permit", &idx); |
14351 | argv_find(argv, argc, "deny", &idx); | |
14352 | ||
14353 | if (idx) { | |
14354 | direct = argv_find(argv, argc, "permit", &idx) | |
14355 | ? COMMUNITY_PERMIT | |
14356 | : COMMUNITY_DENY; | |
14357 | ||
14358 | idx = 0; | |
14359 | argv_find(argv, argc, "AA:NN", &idx); | |
14360 | str = argv_concat(argv, argc, idx); | |
7336e101 | 14361 | } |
174b5cb9 DA |
14362 | |
14363 | idx = 0; | |
d62a17ae | 14364 | argv_find(argv, argc, "(100-500)", &idx); |
14365 | argv_find(argv, argc, "WORD", &idx); | |
14366 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 14367 | |
d62a17ae | 14368 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
7298a8e1 | 14369 | direct, style); |
42f914d4 | 14370 | |
d62a17ae | 14371 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 14372 | |
d62a17ae | 14373 | if (ret < 0) { |
14374 | community_list_perror(vty, ret); | |
14375 | return CMD_WARNING_CONFIG_FAILED; | |
14376 | } | |
42f914d4 | 14377 | |
d62a17ae | 14378 | return CMD_SUCCESS; |
718e3744 | 14379 | } |
14380 | ||
7336e101 SP |
14381 | ALIAS (no_community_list_expanded_all, |
14382 | no_ip_community_list_expanded_all_cmd, | |
14383 | "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
14384 | NO_STR | |
14385 | IP_STR | |
14386 | COMMUNITY_LIST_STR | |
14387 | "Community list number (expanded)\n" | |
14388 | "Add an expanded community-list entry\n" | |
14389 | "Community list name\n" | |
14390 | "Specify community to reject\n" | |
14391 | "Specify community to accept\n" | |
14392 | COMMUNITY_VAL_STR) | |
14393 | ||
174b5cb9 DA |
14394 | ALIAS(no_community_list_expanded_all, no_bgp_community_list_expanded_all_list_cmd, |
14395 | "no bgp community-list <(100-500)|expanded WORD>", | |
14396 | NO_STR IP_STR COMMUNITY_LIST_STR | |
14397 | "Community list number (expanded)\n" | |
14398 | "Add an expanded community-list entry\n" | |
14399 | "Community list name\n") | |
14400 | ||
14401 | ALIAS(no_community_list_expanded_all, no_ip_community_list_expanded_all_list_cmd, | |
14402 | "no ip community-list <(100-500)|expanded WORD>", | |
14403 | NO_STR IP_STR COMMUNITY_LIST_STR | |
14404 | "Community list number (expanded)\n" | |
14405 | "Add an expanded community-list entry\n" | |
14406 | "Community list name\n") | |
14407 | ||
8d9b8ed9 PM |
14408 | /* Return configuration string of community-list entry. */ |
14409 | static const char *community_list_config_str(struct community_entry *entry) | |
14410 | { | |
14411 | const char *str; | |
14412 | ||
14413 | if (entry->any) | |
14414 | str = ""; | |
14415 | else { | |
14416 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
14417 | str = community_str(entry->u.com, false); | |
14418 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
14419 | str = lcommunity_str(entry->u.lcom, false); | |
14420 | else | |
14421 | str = entry->config; | |
14422 | } | |
14423 | return str; | |
14424 | } | |
14425 | ||
d62a17ae | 14426 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 14427 | { |
d62a17ae | 14428 | struct community_entry *entry; |
718e3744 | 14429 | |
d62a17ae | 14430 | for (entry = list->head; entry; entry = entry->next) { |
14431 | if (entry == list->head) { | |
14432 | if (all_digit(list->name)) | |
14433 | vty_out(vty, "Community %s list %s\n", | |
14434 | entry->style == COMMUNITY_LIST_STANDARD | |
14435 | ? "standard" | |
14436 | : "(expanded) access", | |
14437 | list->name); | |
14438 | else | |
14439 | vty_out(vty, "Named Community %s list %s\n", | |
14440 | entry->style == COMMUNITY_LIST_STANDARD | |
14441 | ? "standard" | |
14442 | : "expanded", | |
14443 | list->name); | |
14444 | } | |
14445 | if (entry->any) | |
14446 | vty_out(vty, " %s\n", | |
14447 | community_direct_str(entry->direct)); | |
14448 | else | |
14449 | vty_out(vty, " %s %s\n", | |
14450 | community_direct_str(entry->direct), | |
8d9b8ed9 | 14451 | community_list_config_str(entry)); |
d62a17ae | 14452 | } |
718e3744 | 14453 | } |
14454 | ||
7336e101 SP |
14455 | DEFUN (show_community_list, |
14456 | show_bgp_community_list_cmd, | |
14457 | "show bgp community-list", | |
718e3744 | 14458 | SHOW_STR |
7336e101 | 14459 | BGP_STR |
718e3744 | 14460 | "List community-list\n") |
14461 | { | |
d62a17ae | 14462 | struct community_list *list; |
14463 | struct community_list_master *cm; | |
718e3744 | 14464 | |
7336e101 SP |
14465 | int idx = 0; |
14466 | if (argv_find(argv, argc, "ip", &idx)) { | |
14467 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14468 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14469 | vty_out(vty, "'show bgp community-list <(1-500)|WORD>'\n"); | |
14470 | zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used"); | |
14471 | } | |
d62a17ae | 14472 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
14473 | if (!cm) | |
14474 | return CMD_SUCCESS; | |
718e3744 | 14475 | |
d62a17ae | 14476 | for (list = cm->num.head; list; list = list->next) |
14477 | community_list_show(vty, list); | |
718e3744 | 14478 | |
d62a17ae | 14479 | for (list = cm->str.head; list; list = list->next) |
14480 | community_list_show(vty, list); | |
718e3744 | 14481 | |
d62a17ae | 14482 | return CMD_SUCCESS; |
718e3744 | 14483 | } |
14484 | ||
7336e101 SP |
14485 | ALIAS (show_community_list, |
14486 | show_ip_community_list_cmd, | |
14487 | "show ip community-list", | |
718e3744 | 14488 | SHOW_STR |
14489 | IP_STR | |
7336e101 SP |
14490 | "List community-list\n") |
14491 | ||
14492 | DEFUN (show_community_list_arg, | |
14493 | show_bgp_community_list_arg_cmd, | |
14494 | "show bgp community-list <(1-500)|WORD>", | |
14495 | SHOW_STR | |
14496 | BGP_STR | |
718e3744 | 14497 | "List community-list\n" |
14498 | "Community-list number\n" | |
14499 | "Community-list name\n") | |
14500 | { | |
d62a17ae | 14501 | int idx_comm_list = 3; |
14502 | struct community_list *list; | |
718e3744 | 14503 | |
7336e101 SP |
14504 | int idx = 0; |
14505 | if (argv_find(argv, argc, "ip", &idx)) { | |
14506 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14507 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14508 | vty_out(vty, "'show bgp community-list <(1-500)|WORD>'\n"); | |
14509 | zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used"); | |
14510 | } | |
e237b0d2 | 14511 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 14512 | COMMUNITY_LIST_MASTER); |
14513 | if (!list) { | |
14514 | vty_out(vty, "%% Can't find community-list\n"); | |
14515 | return CMD_WARNING; | |
14516 | } | |
718e3744 | 14517 | |
d62a17ae | 14518 | community_list_show(vty, list); |
718e3744 | 14519 | |
d62a17ae | 14520 | return CMD_SUCCESS; |
718e3744 | 14521 | } |
6b0655a2 | 14522 | |
7336e101 SP |
14523 | ALIAS (show_community_list_arg, |
14524 | show_ip_community_list_arg_cmd, | |
14525 | "show ip community-list <(1-500)|WORD>", | |
14526 | SHOW_STR | |
14527 | IP_STR | |
14528 | "List community-list\n" | |
14529 | "Community-list number\n" | |
14530 | "Community-list name\n") | |
14531 | ||
57d187bc JS |
14532 | /* |
14533 | * Large Community code. | |
14534 | */ | |
d62a17ae | 14535 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
14536 | struct cmd_token **argv, int style, | |
14537 | int reject_all_digit_name) | |
14538 | { | |
14539 | int ret; | |
14540 | int direct; | |
14541 | char *str; | |
14542 | int idx = 0; | |
14543 | char *cl_name; | |
14544 | ||
7336e101 SP |
14545 | if (argv_find(argv, argc, "ip", &idx)) { |
14546 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14547 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14548 | vty_out(vty, "'bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n"); | |
14549 | zlog_warn("Deprecated option: 'large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used"); | |
14550 | } | |
d62a17ae | 14551 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
14552 | : COMMUNITY_DENY; | |
14553 | ||
14554 | /* All digit name check. */ | |
14555 | idx = 0; | |
14556 | argv_find(argv, argc, "WORD", &idx); | |
14557 | argv_find(argv, argc, "(1-99)", &idx); | |
14558 | argv_find(argv, argc, "(100-500)", &idx); | |
14559 | cl_name = argv[idx]->arg; | |
14560 | if (reject_all_digit_name && all_digit(cl_name)) { | |
14561 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
14562 | return CMD_WARNING_CONFIG_FAILED; | |
14563 | } | |
14564 | ||
14565 | idx = 0; | |
14566 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
14567 | argv_find(argv, argc, "LINE", &idx); | |
14568 | /* Concat community string argument. */ | |
14569 | if (idx) | |
14570 | str = argv_concat(argv, argc, idx); | |
14571 | else | |
14572 | str = NULL; | |
14573 | ||
14574 | ret = lcommunity_list_set(bgp_clist, cl_name, str, direct, style); | |
14575 | ||
14576 | /* Free temporary community list string allocated by | |
14577 | argv_concat(). */ | |
0a22ddfb | 14578 | XFREE(MTYPE_TMP, str); |
d62a17ae | 14579 | |
14580 | if (ret < 0) { | |
14581 | community_list_perror(vty, ret); | |
14582 | return CMD_WARNING_CONFIG_FAILED; | |
14583 | } | |
14584 | return CMD_SUCCESS; | |
14585 | } | |
14586 | ||
14587 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
14588 | struct cmd_token **argv, int style) | |
14589 | { | |
14590 | int ret; | |
14591 | int direct = 0; | |
14592 | char *str = NULL; | |
14593 | int idx = 0; | |
14594 | ||
7336e101 SP |
14595 | if (argv_find(argv, argc, "ip", &idx)) { |
14596 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14597 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14598 | vty_out(vty, "'no bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n"); | |
16941c05 | 14599 | zlog_warn("Deprecated option: 'no ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used"); |
7336e101 | 14600 | } |
d62a17ae | 14601 | argv_find(argv, argc, "permit", &idx); |
14602 | argv_find(argv, argc, "deny", &idx); | |
14603 | ||
14604 | if (idx) { | |
14605 | /* Check the list direct. */ | |
14606 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
14607 | direct = COMMUNITY_PERMIT; | |
14608 | else | |
14609 | direct = COMMUNITY_DENY; | |
14610 | ||
14611 | idx = 0; | |
14612 | argv_find(argv, argc, "LINE", &idx); | |
14613 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
14614 | /* Concat community string argument. */ | |
14615 | str = argv_concat(argv, argc, idx); | |
14616 | } | |
14617 | ||
14618 | idx = 0; | |
14619 | argv_find(argv, argc, "(1-99)", &idx); | |
14620 | argv_find(argv, argc, "(100-500)", &idx); | |
14621 | argv_find(argv, argc, "WORD", &idx); | |
14622 | ||
14623 | /* Unset community list. */ | |
14624 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, direct, | |
14625 | style); | |
14626 | ||
14627 | /* Free temporary community list string allocated by | |
14628 | argv_concat(). */ | |
0a22ddfb | 14629 | XFREE(MTYPE_TMP, str); |
d62a17ae | 14630 | |
14631 | if (ret < 0) { | |
14632 | community_list_perror(vty, ret); | |
14633 | return CMD_WARNING_CONFIG_FAILED; | |
14634 | } | |
14635 | ||
14636 | return CMD_SUCCESS; | |
57d187bc JS |
14637 | } |
14638 | ||
14639 | /* "large-community-list" keyword help string. */ | |
14640 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
14641 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
14642 | ||
7336e101 SP |
14643 | #if CONFDATE > 20191005 |
14644 | CPP_NOTICE("bgpd: remove deprecated 'ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' command") | |
14645 | #endif | |
14646 | DEFUN (lcommunity_list_standard, | |
14647 | bgp_lcommunity_list_standard_cmd, | |
14648 | "bgp large-community-list (1-99) <deny|permit>", | |
14649 | BGP_STR | |
14650 | LCOMMUNITY_LIST_STR | |
14651 | "Large Community list number (standard)\n" | |
14652 | "Specify large community to reject\n" | |
14653 | "Specify large community to accept\n") | |
14654 | { | |
14655 | return lcommunity_list_set_vty(vty, argc, argv, | |
14656 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
14657 | } | |
14658 | ||
14659 | ALIAS (lcommunity_list_standard, | |
57d187bc | 14660 | ip_lcommunity_list_standard_cmd, |
52951b63 DS |
14661 | "ip large-community-list (1-99) <deny|permit>", |
14662 | IP_STR | |
14663 | LCOMMUNITY_LIST_STR | |
14664 | "Large Community list number (standard)\n" | |
14665 | "Specify large community to reject\n" | |
7111c1a0 | 14666 | "Specify large community to accept\n") |
7336e101 SP |
14667 | |
14668 | DEFUN (lcommunity_list_standard1, | |
14669 | bgp_lcommunity_list_standard1_cmd, | |
14670 | "bgp large-community-list (1-99) <deny|permit> AA:BB:CC...", | |
14671 | BGP_STR | |
14672 | LCOMMUNITY_LIST_STR | |
14673 | "Large Community list number (standard)\n" | |
14674 | "Specify large community to reject\n" | |
14675 | "Specify large community to accept\n" | |
14676 | LCOMMUNITY_VAL_STR) | |
52951b63 | 14677 | { |
d62a17ae | 14678 | return lcommunity_list_set_vty(vty, argc, argv, |
14679 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
14680 | } |
14681 | ||
7336e101 | 14682 | ALIAS (lcommunity_list_standard1, |
52951b63 DS |
14683 | ip_lcommunity_list_standard1_cmd, |
14684 | "ip large-community-list (1-99) <deny|permit> AA:BB:CC...", | |
57d187bc JS |
14685 | IP_STR |
14686 | LCOMMUNITY_LIST_STR | |
14687 | "Large Community list number (standard)\n" | |
14688 | "Specify large community to reject\n" | |
14689 | "Specify large community to accept\n" | |
14690 | LCOMMUNITY_VAL_STR) | |
7336e101 SP |
14691 | |
14692 | DEFUN (lcommunity_list_expanded, | |
14693 | bgp_lcommunity_list_expanded_cmd, | |
14694 | "bgp large-community-list (100-500) <deny|permit> LINE...", | |
14695 | BGP_STR | |
14696 | LCOMMUNITY_LIST_STR | |
14697 | "Large Community list number (expanded)\n" | |
14698 | "Specify large community to reject\n" | |
14699 | "Specify large community to accept\n" | |
14700 | "An ordered list as a regular-expression\n") | |
57d187bc | 14701 | { |
d62a17ae | 14702 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 14703 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
14704 | } |
14705 | ||
7336e101 | 14706 | ALIAS (lcommunity_list_expanded, |
57d187bc JS |
14707 | ip_lcommunity_list_expanded_cmd, |
14708 | "ip large-community-list (100-500) <deny|permit> LINE...", | |
14709 | IP_STR | |
14710 | LCOMMUNITY_LIST_STR | |
14711 | "Large Community list number (expanded)\n" | |
14712 | "Specify large community to reject\n" | |
14713 | "Specify large community to accept\n" | |
14714 | "An ordered list as a regular-expression\n") | |
7336e101 SP |
14715 | |
14716 | DEFUN (lcommunity_list_name_standard, | |
14717 | bgp_lcommunity_list_name_standard_cmd, | |
14718 | "bgp large-community-list standard WORD <deny|permit>", | |
14719 | BGP_STR | |
14720 | LCOMMUNITY_LIST_STR | |
14721 | "Specify standard large-community-list\n" | |
14722 | "Large Community list name\n" | |
14723 | "Specify large community to reject\n" | |
14724 | "Specify large community to accept\n") | |
57d187bc | 14725 | { |
d62a17ae | 14726 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 14727 | LARGE_COMMUNITY_LIST_STANDARD, 1); |
57d187bc JS |
14728 | } |
14729 | ||
7336e101 | 14730 | ALIAS (lcommunity_list_name_standard, |
57d187bc | 14731 | ip_lcommunity_list_name_standard_cmd, |
52951b63 DS |
14732 | "ip large-community-list standard WORD <deny|permit>", |
14733 | IP_STR | |
14734 | LCOMMUNITY_LIST_STR | |
14735 | "Specify standard large-community-list\n" | |
14736 | "Large Community list name\n" | |
14737 | "Specify large community to reject\n" | |
14738 | "Specify large community to accept\n") | |
7336e101 SP |
14739 | |
14740 | DEFUN (lcommunity_list_name_standard1, | |
14741 | bgp_lcommunity_list_name_standard1_cmd, | |
14742 | "bgp large-community-list standard WORD <deny|permit> AA:BB:CC...", | |
14743 | BGP_STR | |
14744 | LCOMMUNITY_LIST_STR | |
14745 | "Specify standard large-community-list\n" | |
14746 | "Large Community list name\n" | |
14747 | "Specify large community to reject\n" | |
14748 | "Specify large community to accept\n" | |
14749 | LCOMMUNITY_VAL_STR) | |
52951b63 | 14750 | { |
d62a17ae | 14751 | return lcommunity_list_set_vty(vty, argc, argv, |
14752 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
14753 | } |
14754 | ||
7336e101 | 14755 | ALIAS (lcommunity_list_name_standard1, |
52951b63 DS |
14756 | ip_lcommunity_list_name_standard1_cmd, |
14757 | "ip large-community-list standard WORD <deny|permit> AA:BB:CC...", | |
57d187bc JS |
14758 | IP_STR |
14759 | LCOMMUNITY_LIST_STR | |
14760 | "Specify standard large-community-list\n" | |
14761 | "Large Community list name\n" | |
14762 | "Specify large community to reject\n" | |
14763 | "Specify large community to accept\n" | |
14764 | LCOMMUNITY_VAL_STR) | |
7336e101 SP |
14765 | |
14766 | DEFUN (lcommunity_list_name_expanded, | |
14767 | bgp_lcommunity_list_name_expanded_cmd, | |
14768 | "bgp large-community-list expanded WORD <deny|permit> LINE...", | |
14769 | BGP_STR | |
14770 | LCOMMUNITY_LIST_STR | |
14771 | "Specify expanded large-community-list\n" | |
14772 | "Large Community list name\n" | |
14773 | "Specify large community to reject\n" | |
14774 | "Specify large community to accept\n" | |
14775 | "An ordered list as a regular-expression\n") | |
57d187bc | 14776 | { |
d62a17ae | 14777 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 14778 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
14779 | } |
14780 | ||
7336e101 | 14781 | ALIAS (lcommunity_list_name_expanded, |
57d187bc JS |
14782 | ip_lcommunity_list_name_expanded_cmd, |
14783 | "ip large-community-list expanded WORD <deny|permit> LINE...", | |
14784 | IP_STR | |
14785 | LCOMMUNITY_LIST_STR | |
14786 | "Specify expanded large-community-list\n" | |
14787 | "Large Community list name\n" | |
14788 | "Specify large community to reject\n" | |
14789 | "Specify large community to accept\n" | |
14790 | "An ordered list as a regular-expression\n") | |
7336e101 SP |
14791 | |
14792 | DEFUN (no_lcommunity_list_standard_all, | |
14793 | no_bgp_lcommunity_list_standard_all_cmd, | |
14794 | "no bgp large-community-list <(1-99)|(100-500)|WORD>", | |
14795 | NO_STR | |
14796 | BGP_STR | |
14797 | LCOMMUNITY_LIST_STR | |
14798 | "Large Community list number (standard)\n" | |
14799 | "Large Community list number (expanded)\n" | |
14800 | "Large Community list name\n") | |
57d187bc | 14801 | { |
7336e101 SP |
14802 | return lcommunity_list_unset_vty(vty, argc, argv, |
14803 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
14804 | } |
14805 | ||
7336e101 | 14806 | ALIAS (no_lcommunity_list_standard_all, |
57d187bc JS |
14807 | no_ip_lcommunity_list_standard_all_cmd, |
14808 | "no ip large-community-list <(1-99)|(100-500)|WORD>", | |
14809 | NO_STR | |
14810 | IP_STR | |
14811 | LCOMMUNITY_LIST_STR | |
14812 | "Large Community list number (standard)\n" | |
14813 | "Large Community list number (expanded)\n" | |
14814 | "Large Community list name\n") | |
7336e101 SP |
14815 | |
14816 | DEFUN (no_lcommunity_list_name_expanded_all, | |
14817 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
14818 | "no bgp large-community-list expanded WORD", | |
14819 | NO_STR | |
14820 | BGP_STR | |
14821 | LCOMMUNITY_LIST_STR | |
14822 | "Specify expanded large-community-list\n" | |
14823 | "Large Community list name\n") | |
57d187bc | 14824 | { |
d62a17ae | 14825 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14826 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
14827 | } |
14828 | ||
7336e101 | 14829 | ALIAS (no_lcommunity_list_name_expanded_all, |
57d187bc JS |
14830 | no_ip_lcommunity_list_name_expanded_all_cmd, |
14831 | "no ip large-community-list expanded WORD", | |
14832 | NO_STR | |
14833 | IP_STR | |
14834 | LCOMMUNITY_LIST_STR | |
14835 | "Specify expanded large-community-list\n" | |
14836 | "Large Community list name\n") | |
7336e101 SP |
14837 | |
14838 | DEFUN (no_lcommunity_list_standard, | |
14839 | no_bgp_lcommunity_list_standard_cmd, | |
14840 | "no bgp large-community-list (1-99) <deny|permit> AA:AA:NN...", | |
14841 | NO_STR | |
14842 | BGP_STR | |
14843 | LCOMMUNITY_LIST_STR | |
14844 | "Large Community list number (standard)\n" | |
14845 | "Specify large community to reject\n" | |
14846 | "Specify large community to accept\n" | |
14847 | LCOMMUNITY_VAL_STR) | |
57d187bc | 14848 | { |
d62a17ae | 14849 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14850 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
14851 | } |
14852 | ||
7336e101 | 14853 | ALIAS (no_lcommunity_list_standard, |
57d187bc JS |
14854 | no_ip_lcommunity_list_standard_cmd, |
14855 | "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...", | |
14856 | NO_STR | |
14857 | IP_STR | |
14858 | LCOMMUNITY_LIST_STR | |
14859 | "Large Community list number (standard)\n" | |
14860 | "Specify large community to reject\n" | |
14861 | "Specify large community to accept\n" | |
14862 | LCOMMUNITY_VAL_STR) | |
7336e101 SP |
14863 | |
14864 | DEFUN (no_lcommunity_list_expanded, | |
14865 | no_bgp_lcommunity_list_expanded_cmd, | |
14866 | "no bgp large-community-list (100-500) <deny|permit> LINE...", | |
14867 | NO_STR | |
14868 | BGP_STR | |
14869 | LCOMMUNITY_LIST_STR | |
14870 | "Large Community list number (expanded)\n" | |
14871 | "Specify large community to reject\n" | |
14872 | "Specify large community to accept\n" | |
14873 | "An ordered list as a regular-expression\n") | |
57d187bc | 14874 | { |
d62a17ae | 14875 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14876 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
14877 | } |
14878 | ||
7336e101 | 14879 | ALIAS (no_lcommunity_list_expanded, |
57d187bc JS |
14880 | no_ip_lcommunity_list_expanded_cmd, |
14881 | "no ip large-community-list (100-500) <deny|permit> LINE...", | |
14882 | NO_STR | |
14883 | IP_STR | |
14884 | LCOMMUNITY_LIST_STR | |
14885 | "Large Community list number (expanded)\n" | |
14886 | "Specify large community to reject\n" | |
14887 | "Specify large community to accept\n" | |
14888 | "An ordered list as a regular-expression\n") | |
7336e101 SP |
14889 | |
14890 | DEFUN (no_lcommunity_list_name_standard, | |
14891 | no_bgp_lcommunity_list_name_standard_cmd, | |
14892 | "no bgp large-community-list standard WORD <deny|permit> AA:AA:NN...", | |
14893 | NO_STR | |
14894 | BGP_STR | |
14895 | LCOMMUNITY_LIST_STR | |
14896 | "Specify standard large-community-list\n" | |
14897 | "Large Community list name\n" | |
14898 | "Specify large community to reject\n" | |
14899 | "Specify large community to accept\n" | |
14900 | LCOMMUNITY_VAL_STR) | |
57d187bc | 14901 | { |
d62a17ae | 14902 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14903 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
14904 | } |
14905 | ||
7336e101 | 14906 | ALIAS (no_lcommunity_list_name_standard, |
57d187bc JS |
14907 | no_ip_lcommunity_list_name_standard_cmd, |
14908 | "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...", | |
14909 | NO_STR | |
14910 | IP_STR | |
14911 | LCOMMUNITY_LIST_STR | |
14912 | "Specify standard large-community-list\n" | |
14913 | "Large Community list name\n" | |
14914 | "Specify large community to reject\n" | |
14915 | "Specify large community to accept\n" | |
14916 | LCOMMUNITY_VAL_STR) | |
7336e101 SP |
14917 | |
14918 | DEFUN (no_lcommunity_list_name_expanded, | |
14919 | no_bgp_lcommunity_list_name_expanded_cmd, | |
14920 | "no bgp large-community-list expanded WORD <deny|permit> LINE...", | |
14921 | NO_STR | |
14922 | BGP_STR | |
14923 | LCOMMUNITY_LIST_STR | |
14924 | "Specify expanded large-community-list\n" | |
14925 | "Large community list name\n" | |
14926 | "Specify large community to reject\n" | |
14927 | "Specify large community to accept\n" | |
14928 | "An ordered list as a regular-expression\n") | |
57d187bc | 14929 | { |
d62a17ae | 14930 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14931 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
14932 | } |
14933 | ||
7336e101 | 14934 | ALIAS (no_lcommunity_list_name_expanded, |
57d187bc JS |
14935 | no_ip_lcommunity_list_name_expanded_cmd, |
14936 | "no ip large-community-list expanded WORD <deny|permit> LINE...", | |
14937 | NO_STR | |
14938 | IP_STR | |
14939 | LCOMMUNITY_LIST_STR | |
14940 | "Specify expanded large-community-list\n" | |
14941 | "Large community list name\n" | |
14942 | "Specify large community to reject\n" | |
14943 | "Specify large community to accept\n" | |
14944 | "An ordered list as a regular-expression\n") | |
d62a17ae | 14945 | |
14946 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) | |
14947 | { | |
14948 | struct community_entry *entry; | |
14949 | ||
14950 | for (entry = list->head; entry; entry = entry->next) { | |
14951 | if (entry == list->head) { | |
14952 | if (all_digit(list->name)) | |
14953 | vty_out(vty, "Large community %s list %s\n", | |
169b72c8 | 14954 | entry->style == |
14955 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 14956 | ? "standard" |
14957 | : "(expanded) access", | |
14958 | list->name); | |
14959 | else | |
14960 | vty_out(vty, | |
14961 | "Named large community %s list %s\n", | |
169b72c8 | 14962 | entry->style == |
14963 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 14964 | ? "standard" |
14965 | : "expanded", | |
14966 | list->name); | |
14967 | } | |
14968 | if (entry->any) | |
14969 | vty_out(vty, " %s\n", | |
14970 | community_direct_str(entry->direct)); | |
14971 | else | |
14972 | vty_out(vty, " %s %s\n", | |
14973 | community_direct_str(entry->direct), | |
8d9b8ed9 | 14974 | community_list_config_str(entry)); |
d62a17ae | 14975 | } |
57d187bc JS |
14976 | } |
14977 | ||
7336e101 SP |
14978 | DEFUN (show_lcommunity_list, |
14979 | show_bgp_lcommunity_list_cmd, | |
14980 | "show bgp large-community-list", | |
57d187bc | 14981 | SHOW_STR |
7336e101 | 14982 | BGP_STR |
57d187bc JS |
14983 | "List large-community list\n") |
14984 | { | |
d62a17ae | 14985 | struct community_list *list; |
14986 | struct community_list_master *cm; | |
7336e101 SP |
14987 | int idx = 0; |
14988 | ||
14989 | if (argv_find(argv, argc, "ip", &idx)) { | |
14990 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14991 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14992 | vty_out(vty, "'show bgp large-community-list <(1-500)|WORD>'\n"); | |
14993 | zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used"); | |
14994 | } | |
57d187bc | 14995 | |
d62a17ae | 14996 | cm = community_list_master_lookup(bgp_clist, |
14997 | LARGE_COMMUNITY_LIST_MASTER); | |
14998 | if (!cm) | |
14999 | return CMD_SUCCESS; | |
57d187bc | 15000 | |
d62a17ae | 15001 | for (list = cm->num.head; list; list = list->next) |
15002 | lcommunity_list_show(vty, list); | |
57d187bc | 15003 | |
d62a17ae | 15004 | for (list = cm->str.head; list; list = list->next) |
15005 | lcommunity_list_show(vty, list); | |
57d187bc | 15006 | |
d62a17ae | 15007 | return CMD_SUCCESS; |
57d187bc JS |
15008 | } |
15009 | ||
7336e101 SP |
15010 | ALIAS (show_lcommunity_list, |
15011 | show_ip_lcommunity_list_cmd, | |
15012 | "show ip large-community-list", | |
57d187bc JS |
15013 | SHOW_STR |
15014 | IP_STR | |
7336e101 SP |
15015 | "List large-community list\n") |
15016 | ||
15017 | DEFUN (show_lcommunity_list_arg, | |
15018 | show_bgp_lcommunity_list_arg_cmd, | |
15019 | "show bgp large-community-list <(1-500)|WORD>", | |
15020 | SHOW_STR | |
15021 | BGP_STR | |
57d187bc JS |
15022 | "List large-community list\n" |
15023 | "large-community-list number\n" | |
15024 | "large-community-list name\n") | |
15025 | { | |
d62a17ae | 15026 | struct community_list *list; |
7336e101 SP |
15027 | int idx = 0; |
15028 | ||
15029 | if (argv_find(argv, argc, "ip", &idx)) { | |
15030 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
15031 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15032 | vty_out(vty, "'show bgp large-community-list <(1-500)|WORD>'\n"); | |
15033 | zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used"); | |
15034 | } | |
57d187bc | 15035 | |
e237b0d2 | 15036 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, |
d62a17ae | 15037 | LARGE_COMMUNITY_LIST_MASTER); |
15038 | if (!list) { | |
15039 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
15040 | return CMD_WARNING; | |
15041 | } | |
57d187bc | 15042 | |
d62a17ae | 15043 | lcommunity_list_show(vty, list); |
57d187bc | 15044 | |
d62a17ae | 15045 | return CMD_SUCCESS; |
57d187bc JS |
15046 | } |
15047 | ||
7336e101 SP |
15048 | ALIAS (show_lcommunity_list_arg, |
15049 | show_ip_lcommunity_list_arg_cmd, | |
15050 | "show ip large-community-list <(1-500)|WORD>", | |
15051 | SHOW_STR | |
15052 | IP_STR | |
15053 | "List large-community list\n" | |
15054 | "large-community-list number\n" | |
15055 | "large-community-list name\n") | |
15056 | ||
718e3744 | 15057 | /* "extcommunity-list" keyword help string. */ |
15058 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
15059 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
15060 | ||
7336e101 SP |
15061 | DEFUN (extcommunity_list_standard, |
15062 | bgp_extcommunity_list_standard_cmd, | |
15063 | "bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
15064 | BGP_STR | |
718e3744 | 15065 | EXTCOMMUNITY_LIST_STR |
15066 | "Extended Community list number (standard)\n" | |
718e3744 | 15067 | "Specify standard extcommunity-list\n" |
5bf15956 | 15068 | "Community list name\n" |
718e3744 | 15069 | "Specify community to reject\n" |
15070 | "Specify community to accept\n" | |
15071 | EXTCOMMUNITY_VAL_STR) | |
15072 | { | |
d62a17ae | 15073 | int style = EXTCOMMUNITY_LIST_STANDARD; |
15074 | int direct = 0; | |
15075 | char *cl_number_or_name = NULL; | |
42f914d4 | 15076 | |
d62a17ae | 15077 | int idx = 0; |
7336e101 SP |
15078 | if (argv_find(argv, argc, "ip", &idx)) { |
15079 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
15080 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15081 | vty_out(vty, "'bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n"); | |
15082 | zlog_warn("Deprecated option: 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used"); | |
15083 | } | |
d62a17ae | 15084 | argv_find(argv, argc, "(1-99)", &idx); |
15085 | argv_find(argv, argc, "WORD", &idx); | |
15086 | cl_number_or_name = argv[idx]->arg; | |
15087 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
15088 | : COMMUNITY_DENY; | |
15089 | argv_find(argv, argc, "AA:NN", &idx); | |
15090 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 15091 | |
d62a17ae | 15092 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
15093 | direct, style); | |
42f914d4 | 15094 | |
d62a17ae | 15095 | XFREE(MTYPE_TMP, str); |
42f914d4 | 15096 | |
d62a17ae | 15097 | if (ret < 0) { |
15098 | community_list_perror(vty, ret); | |
15099 | return CMD_WARNING_CONFIG_FAILED; | |
15100 | } | |
42f914d4 | 15101 | |
d62a17ae | 15102 | return CMD_SUCCESS; |
718e3744 | 15103 | } |
15104 | ||
7336e101 SP |
15105 | #if CONFDATE > 20191005 |
15106 | CPP_NOTICE("bgpd: remove deprecated 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' command") | |
15107 | #endif | |
15108 | ALIAS (extcommunity_list_standard, | |
15109 | ip_extcommunity_list_standard_cmd, | |
15110 | "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
718e3744 | 15111 | IP_STR |
15112 | EXTCOMMUNITY_LIST_STR | |
7336e101 SP |
15113 | "Extended Community list number (standard)\n" |
15114 | "Specify standard extcommunity-list\n" | |
15115 | "Community list name\n" | |
15116 | "Specify community to reject\n" | |
15117 | "Specify community to accept\n" | |
15118 | EXTCOMMUNITY_VAL_STR) | |
15119 | ||
15120 | DEFUN (extcommunity_list_name_expanded, | |
15121 | bgp_extcommunity_list_name_expanded_cmd, | |
15122 | "bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
15123 | BGP_STR | |
15124 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 15125 | "Extended Community list number (expanded)\n" |
718e3744 | 15126 | "Specify expanded extcommunity-list\n" |
15127 | "Extended Community list name\n" | |
15128 | "Specify community to reject\n" | |
15129 | "Specify community to accept\n" | |
15130 | "An ordered list as a regular-expression\n") | |
15131 | { | |
d62a17ae | 15132 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
15133 | int direct = 0; | |
15134 | char *cl_number_or_name = NULL; | |
42f914d4 | 15135 | |
d62a17ae | 15136 | int idx = 0; |
7336e101 SP |
15137 | if (argv_find(argv, argc, "ip", &idx)) { |
15138 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
15139 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15140 | vty_out(vty, "'extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n"); | |
15141 | zlog_warn("Deprecated option: ‘ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used"); | |
15142 | } | |
15143 | ||
d62a17ae | 15144 | argv_find(argv, argc, "(100-500)", &idx); |
15145 | argv_find(argv, argc, "WORD", &idx); | |
15146 | cl_number_or_name = argv[idx]->arg; | |
15147 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
15148 | : COMMUNITY_DENY; | |
15149 | argv_find(argv, argc, "LINE", &idx); | |
15150 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 15151 | |
d62a17ae | 15152 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
15153 | direct, style); | |
42f914d4 | 15154 | |
d62a17ae | 15155 | XFREE(MTYPE_TMP, str); |
42f914d4 | 15156 | |
d62a17ae | 15157 | if (ret < 0) { |
15158 | community_list_perror(vty, ret); | |
15159 | return CMD_WARNING_CONFIG_FAILED; | |
15160 | } | |
42f914d4 | 15161 | |
d62a17ae | 15162 | return CMD_SUCCESS; |
718e3744 | 15163 | } |
15164 | ||
7336e101 SP |
15165 | ALIAS (extcommunity_list_name_expanded, |
15166 | ip_extcommunity_list_name_expanded_cmd, | |
15167 | "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
813d4307 DW |
15168 | IP_STR |
15169 | EXTCOMMUNITY_LIST_STR | |
7336e101 SP |
15170 | "Extended Community list number (expanded)\n" |
15171 | "Specify expanded extcommunity-list\n" | |
15172 | "Extended Community list name\n" | |
15173 | "Specify community to reject\n" | |
15174 | "Specify community to accept\n" | |
15175 | "An ordered list as a regular-expression\n") | |
15176 | ||
15177 | DEFUN (no_extcommunity_list_standard_all, | |
15178 | no_bgp_extcommunity_list_standard_all_cmd, | |
15179 | "no bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
15180 | NO_STR | |
15181 | BGP_STR | |
15182 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 15183 | "Extended Community list number (standard)\n" |
718e3744 | 15184 | "Specify standard extcommunity-list\n" |
5bf15956 | 15185 | "Community list name\n" |
718e3744 | 15186 | "Specify community to reject\n" |
15187 | "Specify community to accept\n" | |
15188 | EXTCOMMUNITY_VAL_STR) | |
15189 | { | |
d62a17ae | 15190 | int style = EXTCOMMUNITY_LIST_STANDARD; |
15191 | int direct = 0; | |
15192 | char *cl_number_or_name = NULL; | |
d4455c89 | 15193 | char *str = NULL; |
42f914d4 | 15194 | |
d62a17ae | 15195 | int idx = 0; |
7336e101 SP |
15196 | if (argv_find(argv, argc, "ip", &idx)) { |
15197 | vty_out(vty, "This config option is deprecated, and is scheduled for removal\n"); | |
15198 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15199 | vty_out(vty, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n"); | |
15200 | zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used"); | |
15201 | } | |
d4455c89 DA |
15202 | |
15203 | idx = 0; | |
15204 | argv_find(argv, argc, "permit", &idx); | |
15205 | argv_find(argv, argc, "deny", &idx); | |
15206 | ||
15207 | if (idx) { | |
15208 | direct = argv_find(argv, argc, "permit", &idx) | |
15209 | ? COMMUNITY_PERMIT | |
15210 | : COMMUNITY_DENY; | |
15211 | ||
15212 | idx = 0; | |
15213 | argv_find(argv, argc, "AA:NN", &idx); | |
15214 | str = argv_concat(argv, argc, idx); | |
15215 | } | |
15216 | ||
15217 | idx = 0; | |
d62a17ae | 15218 | argv_find(argv, argc, "(1-99)", &idx); |
15219 | argv_find(argv, argc, "WORD", &idx); | |
15220 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 15221 | |
d62a17ae | 15222 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
7298a8e1 | 15223 | direct, style); |
42f914d4 | 15224 | |
d62a17ae | 15225 | XFREE(MTYPE_TMP, str); |
42f914d4 | 15226 | |
d62a17ae | 15227 | if (ret < 0) { |
15228 | community_list_perror(vty, ret); | |
15229 | return CMD_WARNING_CONFIG_FAILED; | |
15230 | } | |
42f914d4 | 15231 | |
d62a17ae | 15232 | return CMD_SUCCESS; |
718e3744 | 15233 | } |
15234 | ||
7336e101 SP |
15235 | ALIAS (no_extcommunity_list_standard_all, |
15236 | no_ip_extcommunity_list_standard_all_cmd, | |
15237 | "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
718e3744 | 15238 | NO_STR |
15239 | IP_STR | |
15240 | EXTCOMMUNITY_LIST_STR | |
7336e101 SP |
15241 | "Extended Community list number (standard)\n" |
15242 | "Specify standard extcommunity-list\n" | |
15243 | "Community list name\n" | |
15244 | "Specify community to reject\n" | |
15245 | "Specify community to accept\n" | |
15246 | EXTCOMMUNITY_VAL_STR) | |
15247 | ||
d4455c89 DA |
15248 | ALIAS(no_extcommunity_list_standard_all, |
15249 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
15250 | "no bgp extcommunity-list <(1-99)|standard WORD>", | |
15251 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
15252 | "Extended Community list number (standard)\n" | |
15253 | "Specify standard extcommunity-list\n" | |
15254 | "Community list name\n") | |
15255 | ||
15256 | ALIAS(no_extcommunity_list_standard_all, | |
15257 | no_ip_extcommunity_list_standard_all_list_cmd, | |
15258 | "no ip extcommunity-list <(1-99)|standard WORD>", | |
15259 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
15260 | "Extended Community list number (standard)\n" | |
15261 | "Specify standard extcommunity-list\n" | |
15262 | "Community list name\n") | |
15263 | ||
7336e101 SP |
15264 | DEFUN (no_extcommunity_list_expanded_all, |
15265 | no_bgp_extcommunity_list_expanded_all_cmd, | |
15266 | "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
15267 | NO_STR | |
15268 | BGP_STR | |
15269 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 15270 | "Extended Community list number (expanded)\n" |
718e3744 | 15271 | "Specify expanded extcommunity-list\n" |
5bf15956 | 15272 | "Extended Community list name\n" |
718e3744 | 15273 | "Specify community to reject\n" |
15274 | "Specify community to accept\n" | |
15275 | "An ordered list as a regular-expression\n") | |
15276 | { | |
d62a17ae | 15277 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
15278 | int direct = 0; | |
15279 | char *cl_number_or_name = NULL; | |
d4455c89 | 15280 | char *str = NULL; |
42f914d4 | 15281 | |
d62a17ae | 15282 | int idx = 0; |
7336e101 SP |
15283 | if (argv_find(argv, argc, "ip", &idx)) { |
15284 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
15285 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15286 | vty_out(vty, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n"); | |
15287 | zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used"); | |
15288 | } | |
d4455c89 DA |
15289 | |
15290 | idx = 0; | |
15291 | argv_find(argv, argc, "permit", &idx); | |
15292 | argv_find(argv, argc, "deny", &idx); | |
15293 | ||
15294 | if (idx) { | |
15295 | direct = argv_find(argv, argc, "permit", &idx) | |
15296 | ? COMMUNITY_PERMIT | |
15297 | : COMMUNITY_DENY; | |
15298 | ||
15299 | idx = 0; | |
15300 | argv_find(argv, argc, "LINE", &idx); | |
15301 | str = argv_concat(argv, argc, idx); | |
15302 | } | |
15303 | ||
15304 | idx = 0; | |
d62a17ae | 15305 | argv_find(argv, argc, "(100-500)", &idx); |
15306 | argv_find(argv, argc, "WORD", &idx); | |
15307 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 15308 | |
d62a17ae | 15309 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
7298a8e1 | 15310 | direct, style); |
42f914d4 | 15311 | |
d62a17ae | 15312 | XFREE(MTYPE_TMP, str); |
42f914d4 | 15313 | |
d62a17ae | 15314 | if (ret < 0) { |
15315 | community_list_perror(vty, ret); | |
15316 | return CMD_WARNING_CONFIG_FAILED; | |
15317 | } | |
42f914d4 | 15318 | |
d62a17ae | 15319 | return CMD_SUCCESS; |
718e3744 | 15320 | } |
15321 | ||
7336e101 SP |
15322 | ALIAS (no_extcommunity_list_expanded_all, |
15323 | no_ip_extcommunity_list_expanded_all_cmd, | |
15324 | "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
15325 | NO_STR | |
15326 | IP_STR | |
15327 | EXTCOMMUNITY_LIST_STR | |
15328 | "Extended Community list number (expanded)\n" | |
15329 | "Specify expanded extcommunity-list\n" | |
15330 | "Extended Community list name\n" | |
15331 | "Specify community to reject\n" | |
15332 | "Specify community to accept\n" | |
15333 | "An ordered list as a regular-expression\n") | |
15334 | ||
d4455c89 DA |
15335 | ALIAS(no_extcommunity_list_expanded_all, |
15336 | no_ip_extcommunity_list_expanded_all_list_cmd, | |
15337 | "no ip extcommunity-list <(100-500)|expanded WORD>", | |
15338 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
15339 | "Extended Community list number (expanded)\n" | |
15340 | "Specify expanded extcommunity-list\n" | |
15341 | "Extended Community list name\n") | |
15342 | ||
15343 | ALIAS(no_extcommunity_list_expanded_all, | |
15344 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
15345 | "no bgp extcommunity-list <(100-500)|expanded WORD>", | |
15346 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
15347 | "Extended Community list number (expanded)\n" | |
15348 | "Specify expanded extcommunity-list\n" | |
15349 | "Extended Community list name\n") | |
15350 | ||
d62a17ae | 15351 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 15352 | { |
d62a17ae | 15353 | struct community_entry *entry; |
718e3744 | 15354 | |
d62a17ae | 15355 | for (entry = list->head; entry; entry = entry->next) { |
15356 | if (entry == list->head) { | |
15357 | if (all_digit(list->name)) | |
15358 | vty_out(vty, "Extended community %s list %s\n", | |
15359 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
15360 | ? "standard" | |
15361 | : "(expanded) access", | |
15362 | list->name); | |
15363 | else | |
15364 | vty_out(vty, | |
15365 | "Named extended community %s list %s\n", | |
15366 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
15367 | ? "standard" | |
15368 | : "expanded", | |
15369 | list->name); | |
15370 | } | |
15371 | if (entry->any) | |
15372 | vty_out(vty, " %s\n", | |
15373 | community_direct_str(entry->direct)); | |
15374 | else | |
15375 | vty_out(vty, " %s %s\n", | |
15376 | community_direct_str(entry->direct), | |
8d9b8ed9 | 15377 | community_list_config_str(entry)); |
d62a17ae | 15378 | } |
718e3744 | 15379 | } |
15380 | ||
7336e101 SP |
15381 | DEFUN (show_extcommunity_list, |
15382 | show_bgp_extcommunity_list_cmd, | |
15383 | "show bgp extcommunity-list", | |
718e3744 | 15384 | SHOW_STR |
7336e101 | 15385 | BGP_STR |
718e3744 | 15386 | "List extended-community list\n") |
15387 | { | |
d62a17ae | 15388 | struct community_list *list; |
15389 | struct community_list_master *cm; | |
7336e101 | 15390 | int idx = 0; |
718e3744 | 15391 | |
7336e101 SP |
15392 | if (argv_find(argv, argc, "ip", &idx)) { |
15393 | vty_out(vty, "This config option is deprecated, and is scheduled for removal\n"); | |
15394 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15395 | vty_out(vty, "'show bgp extcommunity-list <(1-500)|WORD>'\n"); | |
15396 | zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used"); | |
15397 | } | |
d62a17ae | 15398 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
15399 | if (!cm) | |
15400 | return CMD_SUCCESS; | |
718e3744 | 15401 | |
d62a17ae | 15402 | for (list = cm->num.head; list; list = list->next) |
15403 | extcommunity_list_show(vty, list); | |
718e3744 | 15404 | |
d62a17ae | 15405 | for (list = cm->str.head; list; list = list->next) |
15406 | extcommunity_list_show(vty, list); | |
718e3744 | 15407 | |
d62a17ae | 15408 | return CMD_SUCCESS; |
718e3744 | 15409 | } |
15410 | ||
7336e101 SP |
15411 | ALIAS (show_extcommunity_list, |
15412 | show_ip_extcommunity_list_cmd, | |
15413 | "show ip extcommunity-list", | |
718e3744 | 15414 | SHOW_STR |
15415 | IP_STR | |
7336e101 SP |
15416 | "List extended-community list\n") |
15417 | ||
15418 | DEFUN (show_extcommunity_list_arg, | |
15419 | show_bgp_extcommunity_list_arg_cmd, | |
15420 | "show bgp extcommunity-list <(1-500)|WORD>", | |
15421 | SHOW_STR | |
15422 | BGP_STR | |
718e3744 | 15423 | "List extended-community list\n" |
15424 | "Extcommunity-list number\n" | |
15425 | "Extcommunity-list name\n") | |
15426 | { | |
d62a17ae | 15427 | int idx_comm_list = 3; |
15428 | struct community_list *list; | |
7336e101 | 15429 | int idx = 0; |
718e3744 | 15430 | |
7336e101 SP |
15431 | if (argv_find(argv, argc, "ip", &idx)) { |
15432 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
15433 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15434 | vty_out(vty, "'show bgp extcommunity-list <(1-500)|WORD>'\n"); | |
15435 | zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used"); | |
15436 | } | |
e237b0d2 | 15437 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 15438 | EXTCOMMUNITY_LIST_MASTER); |
15439 | if (!list) { | |
15440 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
15441 | return CMD_WARNING; | |
15442 | } | |
718e3744 | 15443 | |
d62a17ae | 15444 | extcommunity_list_show(vty, list); |
718e3744 | 15445 | |
d62a17ae | 15446 | return CMD_SUCCESS; |
718e3744 | 15447 | } |
6b0655a2 | 15448 | |
7336e101 SP |
15449 | ALIAS (show_extcommunity_list_arg, |
15450 | show_ip_extcommunity_list_arg_cmd, | |
15451 | "show ip extcommunity-list <(1-500)|WORD>", | |
15452 | SHOW_STR | |
15453 | IP_STR | |
15454 | "List extended-community list\n" | |
15455 | "Extcommunity-list number\n" | |
15456 | "Extcommunity-list name\n") | |
15457 | ||
718e3744 | 15458 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 15459 | static int community_list_config_write(struct vty *vty) |
15460 | { | |
15461 | struct community_list *list; | |
15462 | struct community_entry *entry; | |
15463 | struct community_list_master *cm; | |
15464 | int write = 0; | |
15465 | ||
15466 | /* Community-list. */ | |
15467 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
15468 | ||
15469 | for (list = cm->num.head; list; list = list->next) | |
15470 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15471 | vty_out(vty, "bgp community-list %s %s %s\n", list->name, |
d62a17ae | 15472 | community_direct_str(entry->direct), |
15473 | community_list_config_str(entry)); | |
15474 | write++; | |
15475 | } | |
15476 | for (list = cm->str.head; list; list = list->next) | |
15477 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15478 | vty_out(vty, "bgp community-list %s %s %s %s\n", |
d62a17ae | 15479 | entry->style == COMMUNITY_LIST_STANDARD |
15480 | ? "standard" | |
15481 | : "expanded", | |
15482 | list->name, community_direct_str(entry->direct), | |
15483 | community_list_config_str(entry)); | |
15484 | write++; | |
15485 | } | |
15486 | ||
15487 | /* Extcommunity-list. */ | |
15488 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
15489 | ||
15490 | for (list = cm->num.head; list; list = list->next) | |
15491 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15492 | vty_out(vty, "bgp extcommunity-list %s %s %s\n", |
d62a17ae | 15493 | list->name, community_direct_str(entry->direct), |
15494 | community_list_config_str(entry)); | |
15495 | write++; | |
15496 | } | |
15497 | for (list = cm->str.head; list; list = list->next) | |
15498 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15499 | vty_out(vty, "bgp extcommunity-list %s %s %s %s\n", |
d62a17ae | 15500 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
15501 | ? "standard" | |
15502 | : "expanded", | |
15503 | list->name, community_direct_str(entry->direct), | |
15504 | community_list_config_str(entry)); | |
15505 | write++; | |
15506 | } | |
15507 | ||
15508 | ||
15509 | /* lcommunity-list. */ | |
15510 | cm = community_list_master_lookup(bgp_clist, | |
15511 | LARGE_COMMUNITY_LIST_MASTER); | |
15512 | ||
15513 | for (list = cm->num.head; list; list = list->next) | |
15514 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15515 | vty_out(vty, "bgp large-community-list %s %s %s\n", |
d62a17ae | 15516 | list->name, community_direct_str(entry->direct), |
15517 | community_list_config_str(entry)); | |
15518 | write++; | |
15519 | } | |
15520 | for (list = cm->str.head; list; list = list->next) | |
15521 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15522 | vty_out(vty, "bgp large-community-list %s %s %s %s\n", |
d62a17ae | 15523 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
15524 | ? "standard" | |
15525 | : "expanded", | |
15526 | list->name, community_direct_str(entry->direct), | |
15527 | community_list_config_str(entry)); | |
15528 | write++; | |
15529 | } | |
15530 | ||
15531 | return write; | |
15532 | } | |
15533 | ||
15534 | static struct cmd_node community_list_node = { | |
15535 | COMMUNITY_LIST_NODE, "", 1 /* Export to vtysh. */ | |
718e3744 | 15536 | }; |
15537 | ||
d62a17ae | 15538 | static void community_list_vty(void) |
15539 | { | |
15540 | install_node(&community_list_node, community_list_config_write); | |
15541 | ||
15542 | /* Community-list. */ | |
7336e101 SP |
15543 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
15544 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
15545 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 15546 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 15547 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 15548 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
15549 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
15550 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 15551 | install_element(CONFIG_NODE, &ip_community_list_standard_cmd); |
15552 | install_element(CONFIG_NODE, &ip_community_list_expanded_all_cmd); | |
15553 | install_element(CONFIG_NODE, &no_ip_community_list_standard_all_cmd); | |
174b5cb9 | 15554 | install_element(CONFIG_NODE, &no_ip_community_list_standard_all_list_cmd); |
d62a17ae | 15555 | install_element(CONFIG_NODE, &no_ip_community_list_expanded_all_cmd); |
174b5cb9 | 15556 | install_element(CONFIG_NODE, &no_ip_community_list_expanded_all_list_cmd); |
d62a17ae | 15557 | install_element(VIEW_NODE, &show_ip_community_list_cmd); |
15558 | install_element(VIEW_NODE, &show_ip_community_list_arg_cmd); | |
15559 | ||
15560 | /* Extcommunity-list. */ | |
7336e101 SP |
15561 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
15562 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
15563 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
d4455c89 DA |
15564 | install_element(CONFIG_NODE, |
15565 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
7336e101 | 15566 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); |
d4455c89 DA |
15567 | install_element(CONFIG_NODE, |
15568 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
7336e101 SP |
15569 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); |
15570 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 15571 | install_element(CONFIG_NODE, &ip_extcommunity_list_standard_cmd); |
15572 | install_element(CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd); | |
15573 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd); | |
d4455c89 | 15574 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_standard_all_list_cmd); |
d62a17ae | 15575 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd); |
d4455c89 | 15576 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_list_cmd); |
d62a17ae | 15577 | install_element(VIEW_NODE, &show_ip_extcommunity_list_cmd); |
15578 | install_element(VIEW_NODE, &show_ip_extcommunity_list_arg_cmd); | |
15579 | ||
15580 | /* Large Community List */ | |
7336e101 SP |
15581 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
15582 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard1_cmd); | |
15583 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); | |
15584 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
15585 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard1_cmd); | |
15586 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); | |
15587 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_all_cmd); | |
15588 | install_element(CONFIG_NODE, | |
15589 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
15590 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
15591 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
15592 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
15593 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
15594 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
15595 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
d62a17ae | 15596 | install_element(CONFIG_NODE, &ip_lcommunity_list_standard_cmd); |
15597 | install_element(CONFIG_NODE, &ip_lcommunity_list_standard1_cmd); | |
15598 | install_element(CONFIG_NODE, &ip_lcommunity_list_expanded_cmd); | |
15599 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_standard_cmd); | |
15600 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_standard1_cmd); | |
15601 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_expanded_cmd); | |
15602 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_standard_all_cmd); | |
15603 | install_element(CONFIG_NODE, | |
15604 | &no_ip_lcommunity_list_name_expanded_all_cmd); | |
15605 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_standard_cmd); | |
15606 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_expanded_cmd); | |
15607 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_name_standard_cmd); | |
15608 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_cmd); | |
15609 | install_element(VIEW_NODE, &show_ip_lcommunity_list_cmd); | |
15610 | install_element(VIEW_NODE, &show_ip_lcommunity_list_arg_cmd); | |
5bf15956 | 15611 | } |