]>
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" |
718e3744 | 25 | #include "prefix.h" |
26 | #include "plist.h" | |
27 | #include "buffer.h" | |
28 | #include "linklist.h" | |
29 | #include "stream.h" | |
30 | #include "thread.h" | |
31 | #include "log.h" | |
3b8b1855 | 32 | #include "memory.h" |
fc7948fa | 33 | #include "memory_vty.h" |
4bf6a362 | 34 | #include "hash.h" |
3f9c7369 | 35 | #include "queue.h" |
039f3a34 | 36 | #include "filter.h" |
5d5ba018 | 37 | #include "frrstr.h" |
718e3744 | 38 | |
39 | #include "bgpd/bgpd.h" | |
4bf6a362 | 40 | #include "bgpd/bgp_advertise.h" |
718e3744 | 41 | #include "bgpd/bgp_attr.h" |
42 | #include "bgpd/bgp_aspath.h" | |
43 | #include "bgpd/bgp_community.h" | |
4bf6a362 | 44 | #include "bgpd/bgp_ecommunity.h" |
57d187bc | 45 | #include "bgpd/bgp_lcommunity.h" |
4bf6a362 | 46 | #include "bgpd/bgp_damp.h" |
718e3744 | 47 | #include "bgpd/bgp_debug.h" |
14454c9f | 48 | #include "bgpd/bgp_errors.h" |
e0701b79 | 49 | #include "bgpd/bgp_fsm.h" |
4bf6a362 | 50 | #include "bgpd/bgp_nexthop.h" |
718e3744 | 51 | #include "bgpd/bgp_open.h" |
4bf6a362 | 52 | #include "bgpd/bgp_regex.h" |
718e3744 | 53 | #include "bgpd/bgp_route.h" |
c016b6c7 | 54 | #include "bgpd/bgp_mplsvpn.h" |
718e3744 | 55 | #include "bgpd/bgp_zebra.h" |
fee0f4c6 | 56 | #include "bgpd/bgp_table.h" |
94f2b392 | 57 | #include "bgpd/bgp_vty.h" |
165b5fff | 58 | #include "bgpd/bgp_mpath.h" |
cb1faec9 | 59 | #include "bgpd/bgp_packet.h" |
3f9c7369 | 60 | #include "bgpd/bgp_updgrp.h" |
c43ed2e4 | 61 | #include "bgpd/bgp_bfd.h" |
555e09d4 | 62 | #include "bgpd/bgp_io.h" |
94c2f693 | 63 | #include "bgpd/bgp_evpn.h" |
718e3744 | 64 | |
d62a17ae | 65 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
66 | struct prefix *range, int exact); | |
67 | ||
68 | static enum node_type bgp_node_type(afi_t afi, safi_t safi) | |
69 | { | |
70 | switch (afi) { | |
71 | case AFI_IP: | |
72 | switch (safi) { | |
73 | case SAFI_UNICAST: | |
74 | return BGP_IPV4_NODE; | |
75 | break; | |
76 | case SAFI_MULTICAST: | |
77 | return BGP_IPV4M_NODE; | |
78 | break; | |
79 | case SAFI_LABELED_UNICAST: | |
80 | return BGP_IPV4L_NODE; | |
81 | break; | |
82 | case SAFI_MPLS_VPN: | |
83 | return BGP_VPNV4_NODE; | |
84 | break; | |
7c40bf39 | 85 | case SAFI_FLOWSPEC: |
86 | return BGP_FLOWSPECV4_NODE; | |
5c525538 RW |
87 | default: |
88 | /* not expected */ | |
89 | return BGP_IPV4_NODE; | |
90 | break; | |
d62a17ae | 91 | } |
92 | break; | |
93 | case AFI_IP6: | |
94 | switch (safi) { | |
95 | case SAFI_UNICAST: | |
96 | return BGP_IPV6_NODE; | |
97 | break; | |
98 | case SAFI_MULTICAST: | |
99 | return BGP_IPV6M_NODE; | |
100 | break; | |
101 | case SAFI_LABELED_UNICAST: | |
102 | return BGP_IPV6L_NODE; | |
103 | break; | |
104 | case SAFI_MPLS_VPN: | |
105 | return BGP_VPNV6_NODE; | |
106 | break; | |
7c40bf39 | 107 | case SAFI_FLOWSPEC: |
108 | return BGP_FLOWSPECV6_NODE; | |
5c525538 RW |
109 | default: |
110 | /* not expected */ | |
111 | return BGP_IPV4_NODE; | |
112 | break; | |
d62a17ae | 113 | } |
114 | break; | |
115 | case AFI_L2VPN: | |
116 | return BGP_EVPN_NODE; | |
117 | break; | |
118 | case AFI_MAX: | |
119 | // We should never be here but to clarify the switch statement.. | |
120 | return BGP_IPV4_NODE; | |
121 | break; | |
122 | } | |
123 | ||
124 | // Impossible to happen | |
125 | return BGP_IPV4_NODE; | |
f51bae9c | 126 | } |
20eb8864 | 127 | |
718e3744 | 128 | /* Utility function to get address family from current node. */ |
d62a17ae | 129 | afi_t bgp_node_afi(struct vty *vty) |
130 | { | |
131 | afi_t afi; | |
132 | switch (vty->node) { | |
133 | case BGP_IPV6_NODE: | |
134 | case BGP_IPV6M_NODE: | |
135 | case BGP_IPV6L_NODE: | |
136 | case BGP_VPNV6_NODE: | |
7c40bf39 | 137 | case BGP_FLOWSPECV6_NODE: |
d62a17ae | 138 | afi = AFI_IP6; |
139 | break; | |
140 | case BGP_EVPN_NODE: | |
141 | afi = AFI_L2VPN; | |
142 | break; | |
143 | default: | |
144 | afi = AFI_IP; | |
145 | break; | |
146 | } | |
147 | return afi; | |
718e3744 | 148 | } |
149 | ||
150 | /* Utility function to get subsequent address family from current | |
151 | node. */ | |
d62a17ae | 152 | safi_t bgp_node_safi(struct vty *vty) |
153 | { | |
154 | safi_t safi; | |
155 | switch (vty->node) { | |
156 | case BGP_VPNV4_NODE: | |
157 | case BGP_VPNV6_NODE: | |
158 | safi = SAFI_MPLS_VPN; | |
159 | break; | |
160 | case BGP_IPV4M_NODE: | |
161 | case BGP_IPV6M_NODE: | |
162 | safi = SAFI_MULTICAST; | |
163 | break; | |
164 | case BGP_EVPN_NODE: | |
165 | safi = SAFI_EVPN; | |
166 | break; | |
167 | case BGP_IPV4L_NODE: | |
168 | case BGP_IPV6L_NODE: | |
169 | safi = SAFI_LABELED_UNICAST; | |
170 | break; | |
7c40bf39 | 171 | case BGP_FLOWSPECV4_NODE: |
172 | case BGP_FLOWSPECV6_NODE: | |
173 | safi = SAFI_FLOWSPEC; | |
174 | break; | |
d62a17ae | 175 | default: |
176 | safi = SAFI_UNICAST; | |
177 | break; | |
178 | } | |
179 | return safi; | |
718e3744 | 180 | } |
181 | ||
55f91488 QY |
182 | /** |
183 | * Converts an AFI in string form to afi_t | |
184 | * | |
185 | * @param afi string, one of | |
186 | * - "ipv4" | |
187 | * - "ipv6" | |
81cf0de5 | 188 | * - "l2vpn" |
55f91488 QY |
189 | * @return the corresponding afi_t |
190 | */ | |
d62a17ae | 191 | afi_t bgp_vty_afi_from_str(const char *afi_str) |
192 | { | |
193 | afi_t afi = AFI_MAX; /* unknown */ | |
194 | if (strmatch(afi_str, "ipv4")) | |
195 | afi = AFI_IP; | |
196 | else if (strmatch(afi_str, "ipv6")) | |
197 | afi = AFI_IP6; | |
81cf0de5 CS |
198 | else if (strmatch(afi_str, "l2vpn")) |
199 | afi = AFI_L2VPN; | |
d62a17ae | 200 | return afi; |
201 | } | |
202 | ||
203 | int argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, | |
204 | afi_t *afi) | |
205 | { | |
206 | int ret = 0; | |
207 | if (argv_find(argv, argc, "ipv4", index)) { | |
208 | ret = 1; | |
209 | if (afi) | |
210 | *afi = AFI_IP; | |
211 | } else if (argv_find(argv, argc, "ipv6", index)) { | |
212 | ret = 1; | |
213 | if (afi) | |
214 | *afi = AFI_IP6; | |
215 | } | |
216 | return ret; | |
46f296b4 LB |
217 | } |
218 | ||
375a2e67 | 219 | /* supports <unicast|multicast|vpn|labeled-unicast> */ |
d62a17ae | 220 | safi_t bgp_vty_safi_from_str(const char *safi_str) |
221 | { | |
222 | safi_t safi = SAFI_MAX; /* unknown */ | |
223 | if (strmatch(safi_str, "multicast")) | |
224 | safi = SAFI_MULTICAST; | |
225 | else if (strmatch(safi_str, "unicast")) | |
226 | safi = SAFI_UNICAST; | |
227 | else if (strmatch(safi_str, "vpn")) | |
228 | safi = SAFI_MPLS_VPN; | |
81cf0de5 CS |
229 | else if (strmatch(safi_str, "evpn")) |
230 | safi = SAFI_EVPN; | |
d62a17ae | 231 | else if (strmatch(safi_str, "labeled-unicast")) |
232 | safi = SAFI_LABELED_UNICAST; | |
7c40bf39 | 233 | else if (strmatch(safi_str, "flowspec")) |
234 | safi = SAFI_FLOWSPEC; | |
d62a17ae | 235 | return safi; |
236 | } | |
237 | ||
238 | int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, | |
239 | safi_t *safi) | |
240 | { | |
241 | int ret = 0; | |
242 | if (argv_find(argv, argc, "unicast", index)) { | |
243 | ret = 1; | |
244 | if (safi) | |
245 | *safi = SAFI_UNICAST; | |
246 | } else if (argv_find(argv, argc, "multicast", index)) { | |
247 | ret = 1; | |
248 | if (safi) | |
249 | *safi = SAFI_MULTICAST; | |
250 | } else if (argv_find(argv, argc, "labeled-unicast", index)) { | |
251 | ret = 1; | |
252 | if (safi) | |
253 | *safi = SAFI_LABELED_UNICAST; | |
254 | } else if (argv_find(argv, argc, "vpn", index)) { | |
255 | ret = 1; | |
256 | if (safi) | |
257 | *safi = SAFI_MPLS_VPN; | |
7c40bf39 | 258 | } else if (argv_find(argv, argc, "flowspec", index)) { |
259 | ret = 1; | |
260 | if (safi) | |
261 | *safi = SAFI_FLOWSPEC; | |
d62a17ae | 262 | } |
263 | return ret; | |
46f296b4 LB |
264 | } |
265 | ||
7eeee51e | 266 | /* |
f212a857 | 267 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 268 | * |
f212a857 DS |
269 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
270 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
271 | * to appropriate values for the calling function. This is to allow the |
272 | * calling function to make decisions appropriate for the show command | |
273 | * that is being parsed. | |
274 | * | |
275 | * The show commands are generally of the form: | |
d62a17ae | 276 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> |
277 | * [<unicast|multicast|vpn|labeled-unicast>]] ..." | |
7eeee51e DS |
278 | * |
279 | * Since we use argv_find if the show command in particular doesn't have: | |
280 | * [ip] | |
18c57037 | 281 | * [<view|vrf> VIEWVRFNAME] |
375a2e67 | 282 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] |
7eeee51e DS |
283 | * The command parsing should still be ok. |
284 | * | |
285 | * vty -> The vty for the command so we can output some useful data in | |
286 | * the event of a parse error in the vrf. | |
287 | * argv -> The command tokens | |
288 | * argc -> How many command tokens we have | |
d62a17ae | 289 | * idx -> The current place in the command, generally should be 0 for this |
290 | * function | |
7eeee51e DS |
291 | * afi -> The parsed afi if it was included in the show command, returned here |
292 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 293 | * bgp -> Pointer to the bgp data structure we need to fill in. |
7eeee51e DS |
294 | * |
295 | * The function returns the correct location in the parse tree for the | |
296 | * last token found. | |
0e37c258 DS |
297 | * |
298 | * Returns 0 for failure to parse correctly, else the idx position of where | |
299 | * it found the last token. | |
7eeee51e | 300 | */ |
d62a17ae | 301 | int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, |
302 | struct cmd_token **argv, int argc, | |
303 | int *idx, afi_t *afi, safi_t *safi, | |
304 | struct bgp **bgp) | |
305 | { | |
306 | char *vrf_name = NULL; | |
307 | ||
308 | assert(afi); | |
309 | assert(safi); | |
310 | assert(bgp); | |
311 | ||
312 | if (argv_find(argv, argc, "ip", idx)) | |
313 | *afi = AFI_IP; | |
314 | ||
315 | if (argv_find(argv, argc, "view", idx) | |
316 | || argv_find(argv, argc, "vrf", idx)) { | |
317 | vrf_name = argv[*idx + 1]->arg; | |
318 | ||
319 | if (strmatch(vrf_name, "all")) | |
320 | *bgp = NULL; | |
321 | else { | |
322 | *bgp = bgp_lookup_by_name(vrf_name); | |
323 | if (!*bgp) { | |
324 | vty_out(vty, | |
325 | "View/Vrf specified is unknown: %s\n", | |
326 | vrf_name); | |
327 | *idx = 0; | |
328 | return 0; | |
329 | } | |
330 | } | |
331 | } else { | |
332 | *bgp = bgp_get_default(); | |
333 | if (!*bgp) { | |
334 | vty_out(vty, "Unable to find default BGP instance\n"); | |
335 | *idx = 0; | |
336 | return 0; | |
337 | } | |
338 | } | |
339 | ||
340 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
341 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
342 | ||
343 | *idx += 1; | |
344 | return *idx; | |
345 | } | |
346 | ||
347 | static int peer_address_self_check(struct bgp *bgp, union sockunion *su) | |
348 | { | |
349 | struct interface *ifp = NULL; | |
350 | ||
351 | if (su->sa.sa_family == AF_INET) | |
352 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); | |
353 | else if (su->sa.sa_family == AF_INET6) | |
354 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, | |
355 | su->sin6.sin6_scope_id, | |
356 | bgp->vrf_id); | |
357 | ||
358 | if (ifp) | |
359 | return 1; | |
360 | ||
361 | return 0; | |
718e3744 | 362 | } |
363 | ||
364 | /* Utility function for looking up peer from VTY. */ | |
f14e6fdb DS |
365 | /* This is used only for configuration, so disallow if attempted on |
366 | * a dynamic neighbor. | |
367 | */ | |
d62a17ae | 368 | static struct peer *peer_lookup_vty(struct vty *vty, const char *ip_str) |
369 | { | |
370 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
371 | int ret; | |
372 | union sockunion su; | |
373 | struct peer *peer; | |
374 | ||
375 | if (!bgp) { | |
376 | return NULL; | |
377 | } | |
378 | ||
379 | ret = str2sockunion(ip_str, &su); | |
380 | if (ret < 0) { | |
381 | peer = peer_lookup_by_conf_if(bgp, ip_str); | |
382 | if (!peer) { | |
383 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) | |
384 | == NULL) { | |
385 | vty_out(vty, | |
386 | "%% Malformed address or name: %s\n", | |
387 | ip_str); | |
388 | return NULL; | |
389 | } | |
390 | } | |
391 | } else { | |
392 | peer = peer_lookup(bgp, &su); | |
393 | if (!peer) { | |
394 | vty_out(vty, | |
395 | "%% Specify remote-as or peer-group commands first\n"); | |
396 | return NULL; | |
397 | } | |
398 | if (peer_dynamic_neighbor(peer)) { | |
399 | vty_out(vty, | |
400 | "%% Operation not allowed on a dynamic neighbor\n"); | |
401 | return NULL; | |
402 | } | |
403 | } | |
404 | return peer; | |
718e3744 | 405 | } |
406 | ||
407 | /* Utility function for looking up peer or peer group. */ | |
f14e6fdb DS |
408 | /* This is used only for configuration, so disallow if attempted on |
409 | * a dynamic neighbor. | |
410 | */ | |
d62a17ae | 411 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) |
412 | { | |
413 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
414 | int ret; | |
415 | union sockunion su; | |
416 | struct peer *peer = NULL; | |
417 | struct peer_group *group = NULL; | |
418 | ||
419 | if (!bgp) { | |
420 | return NULL; | |
421 | } | |
422 | ||
423 | ret = str2sockunion(peer_str, &su); | |
424 | if (ret == 0) { | |
425 | /* IP address, locate peer. */ | |
426 | peer = peer_lookup(bgp, &su); | |
427 | } else { | |
428 | /* Not IP, could match either peer configured on interface or a | |
429 | * group. */ | |
430 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
431 | if (!peer) | |
432 | group = peer_group_lookup(bgp, peer_str); | |
433 | } | |
434 | ||
435 | if (peer) { | |
436 | if (peer_dynamic_neighbor(peer)) { | |
437 | vty_out(vty, | |
438 | "%% Operation not allowed on a dynamic neighbor\n"); | |
439 | return NULL; | |
440 | } | |
441 | ||
442 | return peer; | |
443 | } | |
444 | ||
445 | if (group) | |
446 | return group->conf; | |
447 | ||
448 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); | |
449 | ||
450 | return NULL; | |
451 | } | |
452 | ||
453 | int bgp_vty_return(struct vty *vty, int ret) | |
454 | { | |
455 | const char *str = NULL; | |
456 | ||
457 | switch (ret) { | |
458 | case BGP_ERR_INVALID_VALUE: | |
459 | str = "Invalid value"; | |
460 | break; | |
461 | case BGP_ERR_INVALID_FLAG: | |
462 | str = "Invalid flag"; | |
463 | break; | |
464 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
465 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
466 | break; | |
467 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
468 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
469 | break; | |
470 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
471 | str = "Specify remote-as or peer-group remote AS first"; | |
472 | break; | |
473 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
474 | str = "Cannot change the peer-group. Deconfigure first"; | |
475 | break; | |
476 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
477 | str = "Peer is not a member of this peer-group"; | |
478 | break; | |
479 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
480 | str = "Prefix/distribute list can not co-exist"; | |
481 | break; | |
482 | case BGP_ERR_NOT_INTERNAL_PEER: | |
483 | str = "Invalid command. Not an internal neighbor"; | |
484 | break; | |
485 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
486 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
487 | break; | |
488 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
489 | str = "Local-AS allowed only for EBGP peers"; | |
490 | break; | |
491 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
492 | str = "Cannot have local-as same as BGP AS number"; | |
493 | break; | |
494 | case BGP_ERR_TCPSIG_FAILED: | |
495 | str = "Error while applying TCP-Sig to session(s)"; | |
496 | break; | |
497 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
498 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
499 | break; | |
500 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
501 | str = "ttl-security only allowed for EBGP peers"; | |
502 | break; | |
503 | case BGP_ERR_AS_OVERRIDE: | |
504 | str = "as-override cannot be configured for IBGP peers"; | |
505 | break; | |
506 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
507 | str = "Invalid limit for number of dynamic neighbors"; | |
508 | break; | |
509 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
510 | str = "Dynamic neighbor listen range already exists"; | |
511 | break; | |
512 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
513 | str = "Operation not allowed on a dynamic neighbor"; | |
514 | break; | |
515 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
516 | str = "Operation not allowed on a directly connected neighbor"; | |
517 | break; | |
518 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
519 | str = "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'"; | |
520 | break; | |
521 | } | |
522 | if (str) { | |
523 | vty_out(vty, "%% %s\n", str); | |
524 | return CMD_WARNING_CONFIG_FAILED; | |
525 | } | |
526 | return CMD_SUCCESS; | |
718e3744 | 527 | } |
528 | ||
7aafcaca | 529 | /* BGP clear sort. */ |
d62a17ae | 530 | enum clear_sort { |
531 | clear_all, | |
532 | clear_peer, | |
533 | clear_group, | |
534 | clear_external, | |
535 | clear_as | |
7aafcaca DS |
536 | }; |
537 | ||
d62a17ae | 538 | static void bgp_clear_vty_error(struct vty *vty, struct peer *peer, afi_t afi, |
539 | safi_t safi, int error) | |
540 | { | |
541 | switch (error) { | |
542 | case BGP_ERR_AF_UNCONFIGURED: | |
543 | vty_out(vty, | |
544 | "%%BGP: Enable %s address family for the neighbor %s\n", | |
545 | afi_safi_print(afi, safi), peer->host); | |
546 | break; | |
547 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
548 | vty_out(vty, | |
549 | "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n", | |
550 | peer->host); | |
551 | break; | |
552 | default: | |
553 | break; | |
554 | } | |
7aafcaca DS |
555 | } |
556 | ||
557 | /* `clear ip bgp' functions. */ | |
d62a17ae | 558 | static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
559 | enum clear_sort sort, enum bgp_clear_type stype, | |
560 | const char *arg) | |
561 | { | |
562 | int ret; | |
3ae8bfa5 | 563 | bool found = false; |
d62a17ae | 564 | struct peer *peer; |
565 | struct listnode *node, *nnode; | |
566 | ||
567 | /* Clear all neighbors. */ | |
568 | /* | |
569 | * Pass along pointer to next node to peer_clear() when walking all | |
3ae8bfa5 PM |
570 | * nodes on the BGP instance as that may get freed if it is a |
571 | * doppelganger | |
d62a17ae | 572 | */ |
573 | if (sort == clear_all) { | |
574 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
3ae8bfa5 PM |
575 | if (!peer->afc[afi][safi]) |
576 | continue; | |
577 | ||
d62a17ae | 578 | if (stype == BGP_CLEAR_SOFT_NONE) |
579 | ret = peer_clear(peer, &nnode); | |
d62a17ae | 580 | else |
3ae8bfa5 | 581 | ret = peer_clear_soft(peer, afi, safi, stype); |
d62a17ae | 582 | |
583 | if (ret < 0) | |
584 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
585 | else |
586 | found = true; | |
04b6bdc0 | 587 | } |
d62a17ae | 588 | |
589 | /* This is to apply read-only mode on this clear. */ | |
590 | if (stype == BGP_CLEAR_SOFT_NONE) | |
591 | bgp->update_delay_over = 0; | |
592 | ||
3ae8bfa5 PM |
593 | if (!found) |
594 | vty_out(vty, "%%BGP: No %s peer configured", | |
595 | afi_safi_print(afi, safi)); | |
596 | ||
d62a17ae | 597 | return CMD_SUCCESS; |
7aafcaca DS |
598 | } |
599 | ||
3ae8bfa5 | 600 | /* Clear specified neighbor. */ |
d62a17ae | 601 | if (sort == clear_peer) { |
602 | union sockunion su; | |
d62a17ae | 603 | |
604 | /* Make sockunion for lookup. */ | |
605 | ret = str2sockunion(arg, &su); | |
606 | if (ret < 0) { | |
607 | peer = peer_lookup_by_conf_if(bgp, arg); | |
608 | if (!peer) { | |
609 | peer = peer_lookup_by_hostname(bgp, arg); | |
610 | if (!peer) { | |
611 | vty_out(vty, | |
612 | "Malformed address or name: %s\n", | |
613 | arg); | |
614 | return CMD_WARNING; | |
615 | } | |
616 | } | |
617 | } else { | |
618 | peer = peer_lookup(bgp, &su); | |
619 | if (!peer) { | |
620 | vty_out(vty, | |
621 | "%%BGP: Unknown neighbor - \"%s\"\n", | |
622 | arg); | |
623 | return CMD_WARNING; | |
624 | } | |
625 | } | |
7aafcaca | 626 | |
3ae8bfa5 PM |
627 | if (!peer->afc[afi][safi]) |
628 | ret = BGP_ERR_AF_UNCONFIGURED; | |
629 | else if (stype == BGP_CLEAR_SOFT_NONE) | |
d62a17ae | 630 | ret = peer_clear(peer, NULL); |
631 | else | |
632 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 633 | |
d62a17ae | 634 | if (ret < 0) |
635 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
7aafcaca | 636 | |
d62a17ae | 637 | return CMD_SUCCESS; |
7aafcaca | 638 | } |
7aafcaca | 639 | |
3ae8bfa5 | 640 | /* Clear all neighbors belonging to a specific peer-group. */ |
d62a17ae | 641 | if (sort == clear_group) { |
642 | struct peer_group *group; | |
7aafcaca | 643 | |
d62a17ae | 644 | group = peer_group_lookup(bgp, arg); |
645 | if (!group) { | |
646 | vty_out(vty, "%%BGP: No such peer-group %s\n", arg); | |
647 | return CMD_WARNING; | |
648 | } | |
649 | ||
650 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
d62a17ae | 651 | if (!peer->afc[afi][safi]) |
652 | continue; | |
653 | ||
3ae8bfa5 PM |
654 | if (stype == BGP_CLEAR_SOFT_NONE) |
655 | ret = peer_clear(peer, NULL); | |
656 | else | |
657 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 658 | |
d62a17ae | 659 | if (ret < 0) |
660 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
661 | else |
662 | found = true; | |
d62a17ae | 663 | } |
3ae8bfa5 PM |
664 | |
665 | if (!found) | |
666 | vty_out(vty, | |
667 | "%%BGP: No %s peer belonging to peer-group %s is configured\n", | |
668 | afi_safi_print(afi, safi), arg); | |
669 | ||
d62a17ae | 670 | return CMD_SUCCESS; |
7aafcaca | 671 | } |
7aafcaca | 672 | |
3ae8bfa5 | 673 | /* Clear all external (eBGP) neighbors. */ |
d62a17ae | 674 | if (sort == clear_external) { |
675 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
676 | if (peer->sort == BGP_PEER_IBGP) | |
677 | continue; | |
7aafcaca | 678 | |
3ae8bfa5 PM |
679 | if (!peer->afc[afi][safi]) |
680 | continue; | |
681 | ||
d62a17ae | 682 | if (stype == BGP_CLEAR_SOFT_NONE) |
683 | ret = peer_clear(peer, &nnode); | |
684 | else | |
685 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 686 | |
d62a17ae | 687 | if (ret < 0) |
688 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
689 | else |
690 | found = true; | |
d62a17ae | 691 | } |
3ae8bfa5 PM |
692 | |
693 | if (!found) | |
694 | vty_out(vty, | |
695 | "%%BGP: No external %s peer is configured\n", | |
696 | afi_safi_print(afi, safi)); | |
697 | ||
d62a17ae | 698 | return CMD_SUCCESS; |
699 | } | |
700 | ||
3ae8bfa5 | 701 | /* Clear all neighbors belonging to a specific AS. */ |
d62a17ae | 702 | if (sort == clear_as) { |
3ae8bfa5 | 703 | as_t as = strtoul(arg, NULL, 10); |
d62a17ae | 704 | |
705 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
706 | if (peer->as != as) | |
707 | continue; | |
708 | ||
3ae8bfa5 PM |
709 | if (!peer->afc[afi][safi]) |
710 | ret = BGP_ERR_AF_UNCONFIGURED; | |
711 | else if (stype == BGP_CLEAR_SOFT_NONE) | |
d62a17ae | 712 | ret = peer_clear(peer, &nnode); |
713 | else | |
714 | ret = peer_clear_soft(peer, afi, safi, stype); | |
715 | ||
716 | if (ret < 0) | |
717 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
718 | else |
719 | found = true; | |
d62a17ae | 720 | } |
3ae8bfa5 PM |
721 | |
722 | if (!found) | |
d62a17ae | 723 | vty_out(vty, |
3ae8bfa5 PM |
724 | "%%BGP: No %s peer is configured with AS %s\n", |
725 | afi_safi_print(afi, safi), arg); | |
726 | ||
d62a17ae | 727 | return CMD_SUCCESS; |
728 | } | |
729 | ||
730 | return CMD_SUCCESS; | |
731 | } | |
732 | ||
733 | static int bgp_clear_vty(struct vty *vty, const char *name, afi_t afi, | |
734 | safi_t safi, enum clear_sort sort, | |
735 | enum bgp_clear_type stype, const char *arg) | |
736 | { | |
737 | struct bgp *bgp; | |
738 | ||
739 | /* BGP structure lookup. */ | |
740 | if (name) { | |
741 | bgp = bgp_lookup_by_name(name); | |
742 | if (bgp == NULL) { | |
743 | vty_out(vty, "Can't find BGP instance %s\n", name); | |
744 | return CMD_WARNING; | |
745 | } | |
746 | } else { | |
747 | bgp = bgp_get_default(); | |
748 | if (bgp == NULL) { | |
749 | vty_out(vty, "No BGP process is configured\n"); | |
750 | return CMD_WARNING; | |
751 | } | |
752 | } | |
753 | ||
754 | return bgp_clear(vty, bgp, afi, safi, sort, stype, arg); | |
7aafcaca DS |
755 | } |
756 | ||
757 | /* clear soft inbound */ | |
d62a17ae | 758 | static void bgp_clear_star_soft_in(struct vty *vty, const char *name) |
7aafcaca | 759 | { |
d62a17ae | 760 | bgp_clear_vty(vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
761 | BGP_CLEAR_SOFT_IN, NULL); | |
762 | bgp_clear_vty(vty, name, AFI_IP6, SAFI_UNICAST, clear_all, | |
763 | BGP_CLEAR_SOFT_IN, NULL); | |
7aafcaca DS |
764 | } |
765 | ||
766 | /* clear soft outbound */ | |
d62a17ae | 767 | static void bgp_clear_star_soft_out(struct vty *vty, const char *name) |
7aafcaca | 768 | { |
d62a17ae | 769 | bgp_clear_vty(vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
770 | BGP_CLEAR_SOFT_OUT, NULL); | |
771 | bgp_clear_vty(vty, name, AFI_IP6, SAFI_UNICAST, clear_all, | |
772 | BGP_CLEAR_SOFT_OUT, NULL); | |
7aafcaca DS |
773 | } |
774 | ||
775 | ||
f787d7a0 | 776 | #ifndef VTYSH_EXTRACT_PL |
2e4c2296 | 777 | #include "bgpd/bgp_vty_clippy.c" |
f787d7a0 DL |
778 | #endif |
779 | ||
718e3744 | 780 | /* BGP global configuration. */ |
bee57a7a | 781 | #if (CONFDATE > 20190601) |
1cc40660 DS |
782 | CPP_NOTICE("bgpd: time to remove deprecated bgp multiple-instance") |
783 | CPP_NOTICE("This includes BGP_OPT_MULTIPLE_INSTANCE") | |
784 | #endif | |
785 | DEFUN_HIDDEN (bgp_multiple_instance_func, | |
786 | bgp_multiple_instance_cmd, | |
787 | "bgp multiple-instance", | |
788 | BGP_STR | |
789 | "Enable bgp multiple instance\n") | |
718e3744 | 790 | { |
d62a17ae | 791 | bgp_option_set(BGP_OPT_MULTIPLE_INSTANCE); |
792 | return CMD_SUCCESS; | |
718e3744 | 793 | } |
794 | ||
1cc40660 | 795 | DEFUN_HIDDEN (no_bgp_multiple_instance, |
718e3744 | 796 | no_bgp_multiple_instance_cmd, |
797 | "no bgp multiple-instance", | |
798 | NO_STR | |
799 | BGP_STR | |
800 | "BGP multiple instance\n") | |
801 | { | |
d62a17ae | 802 | int ret; |
718e3744 | 803 | |
1cc40660 DS |
804 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); |
805 | vty_out(vty, "if you are using this please let the developers know\n"); | |
b7cd3069 | 806 | zlog_info("Deprecated option: `bgp multiple-instance` being used"); |
d62a17ae | 807 | ret = bgp_option_unset(BGP_OPT_MULTIPLE_INSTANCE); |
808 | if (ret < 0) { | |
809 | vty_out(vty, "%% There are more than two BGP instances\n"); | |
810 | return CMD_WARNING_CONFIG_FAILED; | |
811 | } | |
812 | return CMD_SUCCESS; | |
718e3744 | 813 | } |
814 | ||
bee57a7a | 815 | #if (CONFDATE > 20190601) |
798467a2 DS |
816 | CPP_NOTICE("bgpd: time to remove deprecated cli bgp config-type cisco") |
817 | CPP_NOTICE("This includes BGP_OPT_CISCO_CONFIG") | |
818 | #endif | |
819 | DEFUN_HIDDEN (bgp_config_type, | |
820 | bgp_config_type_cmd, | |
821 | "bgp config-type <cisco|zebra>", | |
822 | BGP_STR | |
823 | "Configuration type\n" | |
824 | "cisco\n" | |
825 | "zebra\n") | |
718e3744 | 826 | { |
d62a17ae | 827 | int idx = 0; |
798467a2 DS |
828 | if (argv_find(argv, argc, "cisco", &idx)) { |
829 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
830 | vty_out(vty, "if you are using this please let the developers know!\n"); | |
b7cd3069 | 831 | zlog_info("Deprecated option: `bgp config-type cisco` being used"); |
d62a17ae | 832 | bgp_option_set(BGP_OPT_CONFIG_CISCO); |
798467a2 | 833 | } else |
d62a17ae | 834 | bgp_option_unset(BGP_OPT_CONFIG_CISCO); |
718e3744 | 835 | |
d62a17ae | 836 | return CMD_SUCCESS; |
718e3744 | 837 | } |
838 | ||
798467a2 DS |
839 | DEFUN_HIDDEN (no_bgp_config_type, |
840 | no_bgp_config_type_cmd, | |
841 | "no bgp config-type [<cisco|zebra>]", | |
842 | NO_STR | |
843 | BGP_STR | |
844 | "Display configuration type\n" | |
845 | "cisco\n" | |
846 | "zebra\n") | |
718e3744 | 847 | { |
d62a17ae | 848 | bgp_option_unset(BGP_OPT_CONFIG_CISCO); |
849 | return CMD_SUCCESS; | |
718e3744 | 850 | } |
851 | ||
813d4307 | 852 | |
718e3744 | 853 | DEFUN (no_synchronization, |
854 | no_synchronization_cmd, | |
855 | "no synchronization", | |
856 | NO_STR | |
857 | "Perform IGP synchronization\n") | |
858 | { | |
d62a17ae | 859 | return CMD_SUCCESS; |
718e3744 | 860 | } |
861 | ||
862 | DEFUN (no_auto_summary, | |
863 | no_auto_summary_cmd, | |
864 | "no auto-summary", | |
865 | NO_STR | |
866 | "Enable automatic network number summarization\n") | |
867 | { | |
d62a17ae | 868 | return CMD_SUCCESS; |
718e3744 | 869 | } |
3d515fd9 | 870 | |
718e3744 | 871 | /* "router bgp" commands. */ |
505e5056 | 872 | DEFUN_NOSH (router_bgp, |
f412b39a | 873 | router_bgp_cmd, |
18c57037 | 874 | "router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 875 | ROUTER_STR |
876 | BGP_STR | |
31500417 DW |
877 | AS_STR |
878 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 879 | { |
d62a17ae | 880 | int idx_asn = 2; |
881 | int idx_view_vrf = 3; | |
882 | int idx_vrf = 4; | |
883 | int ret; | |
884 | as_t as; | |
885 | struct bgp *bgp; | |
886 | const char *name = NULL; | |
887 | enum bgp_instance_type inst_type; | |
888 | ||
889 | // "router bgp" without an ASN | |
890 | if (argc == 2) { | |
891 | // Pending: Make VRF option available for ASN less config | |
892 | bgp = bgp_get_default(); | |
893 | ||
894 | if (bgp == NULL) { | |
895 | vty_out(vty, "%% No BGP process is configured\n"); | |
896 | return CMD_WARNING_CONFIG_FAILED; | |
897 | } | |
898 | ||
899 | if (listcount(bm->bgp) > 1) { | |
996c9314 | 900 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 901 | return CMD_WARNING_CONFIG_FAILED; |
902 | } | |
903 | } | |
904 | ||
905 | // "router bgp X" | |
906 | else { | |
907 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
908 | ||
909 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; | |
910 | if (argc > 3) { | |
911 | name = argv[idx_vrf]->arg; | |
912 | ||
913 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) | |
914 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
915 | else if (!strcmp(argv[idx_view_vrf]->text, "view")) | |
916 | inst_type = BGP_INSTANCE_TYPE_VIEW; | |
917 | } | |
918 | ||
919 | ret = bgp_get(&bgp, &as, name, inst_type); | |
920 | switch (ret) { | |
921 | case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET: | |
922 | vty_out(vty, | |
923 | "Please specify 'bgp multiple-instance' first\n"); | |
924 | return CMD_WARNING_CONFIG_FAILED; | |
925 | case BGP_ERR_AS_MISMATCH: | |
926 | vty_out(vty, "BGP is already running; AS is %u\n", as); | |
927 | return CMD_WARNING_CONFIG_FAILED; | |
928 | case BGP_ERR_INSTANCE_MISMATCH: | |
929 | vty_out(vty, | |
930 | "BGP instance name and AS number mismatch\n"); | |
931 | vty_out(vty, | |
932 | "BGP instance is already running; AS is %u\n", | |
933 | as); | |
934 | return CMD_WARNING_CONFIG_FAILED; | |
935 | } | |
936 | ||
3bd70bf8 PZ |
937 | /* |
938 | * If we just instantiated the default instance, complete | |
939 | * any pending VRF-VPN leaking that was configured via | |
940 | * earlier "router bgp X vrf FOO" blocks. | |
941 | */ | |
942 | if (inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
943 | vpn_leak_postchange_all(); | |
944 | ||
d62a17ae | 945 | /* Pending: handle when user tries to change a view to vrf n vv. |
946 | */ | |
947 | } | |
948 | ||
0b5131c9 MK |
949 | /* unset the auto created flag as the user config is now present */ |
950 | UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO); | |
d62a17ae | 951 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); |
952 | ||
953 | return CMD_SUCCESS; | |
718e3744 | 954 | } |
955 | ||
718e3744 | 956 | /* "no router bgp" commands. */ |
957 | DEFUN (no_router_bgp, | |
958 | no_router_bgp_cmd, | |
18c57037 | 959 | "no router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 960 | NO_STR |
961 | ROUTER_STR | |
962 | BGP_STR | |
31500417 DW |
963 | AS_STR |
964 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 965 | { |
d62a17ae | 966 | int idx_asn = 3; |
967 | int idx_vrf = 5; | |
968 | as_t as; | |
969 | struct bgp *bgp; | |
970 | const char *name = NULL; | |
718e3744 | 971 | |
d62a17ae | 972 | // "no router bgp" without an ASN |
973 | if (argc == 3) { | |
974 | // Pending: Make VRF option available for ASN less config | |
975 | bgp = bgp_get_default(); | |
718e3744 | 976 | |
d62a17ae | 977 | if (bgp == NULL) { |
978 | vty_out(vty, "%% No BGP process is configured\n"); | |
979 | return CMD_WARNING_CONFIG_FAILED; | |
980 | } | |
7fb21a9f | 981 | |
d62a17ae | 982 | if (listcount(bm->bgp) > 1) { |
996c9314 | 983 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 984 | return CMD_WARNING_CONFIG_FAILED; |
985 | } | |
0b5131c9 MK |
986 | |
987 | if (bgp->l3vni) { | |
988 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
989 | bgp->l3vni); | |
990 | return CMD_WARNING_CONFIG_FAILED; | |
991 | } | |
d62a17ae | 992 | } else { |
993 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
7fb21a9f | 994 | |
d62a17ae | 995 | if (argc > 4) |
996 | name = argv[idx_vrf]->arg; | |
7fb21a9f | 997 | |
d62a17ae | 998 | /* Lookup bgp structure. */ |
999 | bgp = bgp_lookup(as, name); | |
1000 | if (!bgp) { | |
1001 | vty_out(vty, "%% Can't find BGP instance\n"); | |
1002 | return CMD_WARNING_CONFIG_FAILED; | |
1003 | } | |
0b5131c9 MK |
1004 | |
1005 | if (bgp->l3vni) { | |
1006 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
1007 | bgp->l3vni); | |
1008 | return CMD_WARNING_CONFIG_FAILED; | |
1009 | } | |
d62a17ae | 1010 | } |
718e3744 | 1011 | |
d62a17ae | 1012 | bgp_delete(bgp); |
718e3744 | 1013 | |
d62a17ae | 1014 | return CMD_SUCCESS; |
718e3744 | 1015 | } |
1016 | ||
6b0655a2 | 1017 | |
718e3744 | 1018 | /* BGP router-id. */ |
1019 | ||
f787d7a0 | 1020 | DEFPY (bgp_router_id, |
718e3744 | 1021 | bgp_router_id_cmd, |
1022 | "bgp router-id A.B.C.D", | |
1023 | BGP_STR | |
1024 | "Override configured router identifier\n" | |
1025 | "Manually configured router identifier\n") | |
1026 | { | |
d62a17ae | 1027 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1028 | bgp_router_id_static_set(bgp, router_id); | |
1029 | return CMD_SUCCESS; | |
718e3744 | 1030 | } |
1031 | ||
f787d7a0 | 1032 | DEFPY (no_bgp_router_id, |
718e3744 | 1033 | no_bgp_router_id_cmd, |
31500417 | 1034 | "no bgp router-id [A.B.C.D]", |
718e3744 | 1035 | NO_STR |
1036 | BGP_STR | |
31500417 DW |
1037 | "Override configured router identifier\n" |
1038 | "Manually configured router identifier\n") | |
718e3744 | 1039 | { |
d62a17ae | 1040 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1041 | |
d62a17ae | 1042 | if (router_id_str) { |
1043 | if (!IPV4_ADDR_SAME(&bgp->router_id_static, &router_id)) { | |
1044 | vty_out(vty, "%% BGP router-id doesn't match\n"); | |
1045 | return CMD_WARNING_CONFIG_FAILED; | |
1046 | } | |
e018c7cc | 1047 | } |
718e3744 | 1048 | |
d62a17ae | 1049 | router_id.s_addr = 0; |
1050 | bgp_router_id_static_set(bgp, router_id); | |
718e3744 | 1051 | |
d62a17ae | 1052 | return CMD_SUCCESS; |
718e3744 | 1053 | } |
1054 | ||
6b0655a2 | 1055 | |
718e3744 | 1056 | /* BGP Cluster ID. */ |
718e3744 | 1057 | DEFUN (bgp_cluster_id, |
1058 | bgp_cluster_id_cmd, | |
838758ac | 1059 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", |
718e3744 | 1060 | BGP_STR |
1061 | "Configure Route-Reflector Cluster-id\n" | |
838758ac DW |
1062 | "Route-Reflector Cluster-id in IP address format\n" |
1063 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1064 | { |
d62a17ae | 1065 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1066 | int idx_ipv4 = 2; | |
1067 | int ret; | |
1068 | struct in_addr cluster; | |
718e3744 | 1069 | |
d62a17ae | 1070 | ret = inet_aton(argv[idx_ipv4]->arg, &cluster); |
1071 | if (!ret) { | |
1072 | vty_out(vty, "%% Malformed bgp cluster identifier\n"); | |
1073 | return CMD_WARNING_CONFIG_FAILED; | |
1074 | } | |
718e3744 | 1075 | |
d62a17ae | 1076 | bgp_cluster_id_set(bgp, &cluster); |
1077 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1078 | |
d62a17ae | 1079 | return CMD_SUCCESS; |
718e3744 | 1080 | } |
1081 | ||
718e3744 | 1082 | DEFUN (no_bgp_cluster_id, |
1083 | no_bgp_cluster_id_cmd, | |
c7178fe7 | 1084 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", |
718e3744 | 1085 | NO_STR |
1086 | BGP_STR | |
838758ac DW |
1087 | "Configure Route-Reflector Cluster-id\n" |
1088 | "Route-Reflector Cluster-id in IP address format\n" | |
1089 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1090 | { |
d62a17ae | 1091 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1092 | bgp_cluster_id_unset(bgp); | |
1093 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1094 | |
d62a17ae | 1095 | return CMD_SUCCESS; |
718e3744 | 1096 | } |
1097 | ||
718e3744 | 1098 | DEFUN (bgp_confederation_identifier, |
1099 | bgp_confederation_identifier_cmd, | |
9ccf14f7 | 1100 | "bgp confederation identifier (1-4294967295)", |
718e3744 | 1101 | "BGP specific commands\n" |
1102 | "AS confederation parameters\n" | |
1103 | "AS number\n" | |
1104 | "Set routing domain confederation AS\n") | |
1105 | { | |
d62a17ae | 1106 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1107 | int idx_number = 3; | |
1108 | as_t as; | |
718e3744 | 1109 | |
d62a17ae | 1110 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 1111 | |
d62a17ae | 1112 | bgp_confederation_id_set(bgp, as); |
718e3744 | 1113 | |
d62a17ae | 1114 | return CMD_SUCCESS; |
718e3744 | 1115 | } |
1116 | ||
1117 | DEFUN (no_bgp_confederation_identifier, | |
1118 | no_bgp_confederation_identifier_cmd, | |
838758ac | 1119 | "no bgp confederation identifier [(1-4294967295)]", |
718e3744 | 1120 | NO_STR |
1121 | "BGP specific commands\n" | |
1122 | "AS confederation parameters\n" | |
3a2d747c QY |
1123 | "AS number\n" |
1124 | "Set routing domain confederation AS\n") | |
718e3744 | 1125 | { |
d62a17ae | 1126 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1127 | bgp_confederation_id_unset(bgp); | |
718e3744 | 1128 | |
d62a17ae | 1129 | return CMD_SUCCESS; |
718e3744 | 1130 | } |
1131 | ||
718e3744 | 1132 | DEFUN (bgp_confederation_peers, |
1133 | bgp_confederation_peers_cmd, | |
12dcf78e | 1134 | "bgp confederation peers (1-4294967295)...", |
718e3744 | 1135 | "BGP specific commands\n" |
1136 | "AS confederation parameters\n" | |
1137 | "Peer ASs in BGP confederation\n" | |
1138 | AS_STR) | |
1139 | { | |
d62a17ae | 1140 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1141 | int idx_asn = 3; | |
1142 | as_t as; | |
1143 | int i; | |
718e3744 | 1144 | |
d62a17ae | 1145 | for (i = idx_asn; i < argc; i++) { |
1146 | as = strtoul(argv[i]->arg, NULL, 10); | |
718e3744 | 1147 | |
d62a17ae | 1148 | if (bgp->as == as) { |
1149 | vty_out(vty, | |
1150 | "%% Local member-AS not allowed in confed peer list\n"); | |
1151 | continue; | |
1152 | } | |
718e3744 | 1153 | |
d62a17ae | 1154 | bgp_confederation_peers_add(bgp, as); |
1155 | } | |
1156 | return CMD_SUCCESS; | |
718e3744 | 1157 | } |
1158 | ||
1159 | DEFUN (no_bgp_confederation_peers, | |
1160 | no_bgp_confederation_peers_cmd, | |
e83a9414 | 1161 | "no bgp confederation peers (1-4294967295)...", |
718e3744 | 1162 | NO_STR |
1163 | "BGP specific commands\n" | |
1164 | "AS confederation parameters\n" | |
1165 | "Peer ASs in BGP confederation\n" | |
1166 | AS_STR) | |
1167 | { | |
d62a17ae | 1168 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1169 | int idx_asn = 4; | |
1170 | as_t as; | |
1171 | int i; | |
718e3744 | 1172 | |
d62a17ae | 1173 | for (i = idx_asn; i < argc; i++) { |
1174 | as = strtoul(argv[i]->arg, NULL, 10); | |
0b2aa3a0 | 1175 | |
d62a17ae | 1176 | bgp_confederation_peers_remove(bgp, as); |
1177 | } | |
1178 | return CMD_SUCCESS; | |
718e3744 | 1179 | } |
6b0655a2 | 1180 | |
5e242b0d DS |
1181 | /** |
1182 | * Central routine for maximum-paths configuration. | |
1183 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1184 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1185 | */ | |
d62a17ae | 1186 | static int bgp_maxpaths_config_vty(struct vty *vty, int peer_type, |
d7c0a89a | 1187 | const char *mpaths, uint16_t options, |
d62a17ae | 1188 | int set) |
1189 | { | |
1190 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
d7c0a89a | 1191 | uint16_t maxpaths = 0; |
d62a17ae | 1192 | int ret; |
1193 | afi_t afi; | |
1194 | safi_t safi; | |
1195 | ||
1196 | afi = bgp_node_afi(vty); | |
1197 | safi = bgp_node_safi(vty); | |
1198 | ||
1199 | if (set) { | |
1200 | maxpaths = strtol(mpaths, NULL, 10); | |
1201 | if (maxpaths > multipath_num) { | |
1202 | vty_out(vty, | |
1203 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", | |
1204 | maxpaths, multipath_num); | |
1205 | return CMD_WARNING_CONFIG_FAILED; | |
1206 | } | |
1207 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1208 | options); | |
1209 | } else | |
1210 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1211 | ||
1212 | if (ret < 0) { | |
1213 | vty_out(vty, | |
1214 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", | |
1215 | (set == 1) ? "" : "un", | |
1216 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1217 | maxpaths, afi, safi); | |
1218 | return CMD_WARNING_CONFIG_FAILED; | |
1219 | } | |
1220 | ||
1221 | bgp_recalculate_all_bestpaths(bgp); | |
1222 | ||
1223 | return CMD_SUCCESS; | |
165b5fff JB |
1224 | } |
1225 | ||
abc920f8 DS |
1226 | DEFUN (bgp_maxmed_admin, |
1227 | bgp_maxmed_admin_cmd, | |
1228 | "bgp max-med administrative ", | |
1229 | BGP_STR | |
1230 | "Advertise routes with max-med\n" | |
1231 | "Administratively applied, for an indefinite period\n") | |
1232 | { | |
d62a17ae | 1233 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1234 | |
d62a17ae | 1235 | bgp->v_maxmed_admin = 1; |
1236 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1237 | |
d62a17ae | 1238 | bgp_maxmed_update(bgp); |
abc920f8 | 1239 | |
d62a17ae | 1240 | return CMD_SUCCESS; |
abc920f8 DS |
1241 | } |
1242 | ||
1243 | DEFUN (bgp_maxmed_admin_medv, | |
1244 | bgp_maxmed_admin_medv_cmd, | |
4668a151 | 1245 | "bgp max-med administrative (0-4294967295)", |
abc920f8 DS |
1246 | BGP_STR |
1247 | "Advertise routes with max-med\n" | |
1248 | "Administratively applied, for an indefinite period\n" | |
1249 | "Max MED value to be used\n") | |
1250 | { | |
d62a17ae | 1251 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1252 | int idx_number = 3; | |
abc920f8 | 1253 | |
d62a17ae | 1254 | bgp->v_maxmed_admin = 1; |
1255 | bgp->maxmed_admin_value = strtoul(argv[idx_number]->arg, NULL, 10); | |
abc920f8 | 1256 | |
d62a17ae | 1257 | bgp_maxmed_update(bgp); |
abc920f8 | 1258 | |
d62a17ae | 1259 | return CMD_SUCCESS; |
abc920f8 DS |
1260 | } |
1261 | ||
1262 | DEFUN (no_bgp_maxmed_admin, | |
1263 | no_bgp_maxmed_admin_cmd, | |
4668a151 | 1264 | "no bgp max-med administrative [(0-4294967295)]", |
abc920f8 DS |
1265 | NO_STR |
1266 | BGP_STR | |
1267 | "Advertise routes with max-med\n" | |
838758ac DW |
1268 | "Administratively applied, for an indefinite period\n" |
1269 | "Max MED value to be used\n") | |
abc920f8 | 1270 | { |
d62a17ae | 1271 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1272 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; | |
1273 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1274 | bgp_maxmed_update(bgp); | |
abc920f8 | 1275 | |
d62a17ae | 1276 | return CMD_SUCCESS; |
abc920f8 DS |
1277 | } |
1278 | ||
abc920f8 DS |
1279 | DEFUN (bgp_maxmed_onstartup, |
1280 | bgp_maxmed_onstartup_cmd, | |
4668a151 | 1281 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", |
abc920f8 DS |
1282 | BGP_STR |
1283 | "Advertise routes with max-med\n" | |
1284 | "Effective on a startup\n" | |
1285 | "Time (seconds) period for max-med\n" | |
1286 | "Max MED value to be used\n") | |
1287 | { | |
d62a17ae | 1288 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1289 | int idx = 0; | |
4668a151 | 1290 | |
d62a17ae | 1291 | argv_find(argv, argc, "(5-86400)", &idx); |
1292 | bgp->v_maxmed_onstartup = strtoul(argv[idx]->arg, NULL, 10); | |
1293 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
1294 | bgp->maxmed_onstartup_value = strtoul(argv[idx]->arg, NULL, 10); | |
1295 | else | |
1296 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
4668a151 | 1297 | |
d62a17ae | 1298 | bgp_maxmed_update(bgp); |
abc920f8 | 1299 | |
d62a17ae | 1300 | return CMD_SUCCESS; |
abc920f8 DS |
1301 | } |
1302 | ||
1303 | DEFUN (no_bgp_maxmed_onstartup, | |
1304 | no_bgp_maxmed_onstartup_cmd, | |
4668a151 | 1305 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", |
abc920f8 DS |
1306 | NO_STR |
1307 | BGP_STR | |
1308 | "Advertise routes with max-med\n" | |
838758ac DW |
1309 | "Effective on a startup\n" |
1310 | "Time (seconds) period for max-med\n" | |
1311 | "Max MED value to be used\n") | |
abc920f8 | 1312 | { |
d62a17ae | 1313 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1314 | |
d62a17ae | 1315 | /* Cancel max-med onstartup if its on */ |
1316 | if (bgp->t_maxmed_onstartup) { | |
1317 | THREAD_TIMER_OFF(bgp->t_maxmed_onstartup); | |
1318 | bgp->maxmed_onstartup_over = 1; | |
1319 | } | |
abc920f8 | 1320 | |
d62a17ae | 1321 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; |
1322 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1323 | |
d62a17ae | 1324 | bgp_maxmed_update(bgp); |
abc920f8 | 1325 | |
d62a17ae | 1326 | return CMD_SUCCESS; |
abc920f8 DS |
1327 | } |
1328 | ||
d62a17ae | 1329 | static int bgp_update_delay_config_vty(struct vty *vty, const char *delay, |
1330 | const char *wait) | |
f188f2c4 | 1331 | { |
d62a17ae | 1332 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d7c0a89a QY |
1333 | uint16_t update_delay; |
1334 | uint16_t establish_wait; | |
f188f2c4 | 1335 | |
d62a17ae | 1336 | update_delay = strtoul(delay, NULL, 10); |
f188f2c4 | 1337 | |
d62a17ae | 1338 | if (!wait) /* update-delay <delay> */ |
1339 | { | |
1340 | bgp->v_update_delay = update_delay; | |
1341 | bgp->v_establish_wait = bgp->v_update_delay; | |
1342 | return CMD_SUCCESS; | |
1343 | } | |
f188f2c4 | 1344 | |
d62a17ae | 1345 | /* update-delay <delay> <establish-wait> */ |
1346 | establish_wait = atoi(wait); | |
1347 | if (update_delay < establish_wait) { | |
1348 | vty_out(vty, | |
1349 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1350 | return CMD_WARNING_CONFIG_FAILED; | |
1351 | } | |
f188f2c4 | 1352 | |
d62a17ae | 1353 | bgp->v_update_delay = update_delay; |
1354 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 1355 | |
d62a17ae | 1356 | return CMD_SUCCESS; |
f188f2c4 DS |
1357 | } |
1358 | ||
d62a17ae | 1359 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 1360 | { |
d62a17ae | 1361 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 1362 | |
d62a17ae | 1363 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
1364 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 1365 | |
d62a17ae | 1366 | return CMD_SUCCESS; |
f188f2c4 DS |
1367 | } |
1368 | ||
2b791107 | 1369 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 1370 | { |
d62a17ae | 1371 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
1372 | vty_out(vty, " update-delay %d", bgp->v_update_delay); | |
1373 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1374 | vty_out(vty, " %d", bgp->v_establish_wait); | |
1375 | vty_out(vty, "\n"); | |
1376 | } | |
f188f2c4 DS |
1377 | } |
1378 | ||
1379 | ||
1380 | /* Update-delay configuration */ | |
1381 | DEFUN (bgp_update_delay, | |
1382 | bgp_update_delay_cmd, | |
6147e2c6 | 1383 | "update-delay (0-3600)", |
f188f2c4 DS |
1384 | "Force initial delay for best-path and updates\n" |
1385 | "Seconds\n") | |
1386 | { | |
d62a17ae | 1387 | int idx_number = 1; |
1388 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); | |
f188f2c4 DS |
1389 | } |
1390 | ||
1391 | DEFUN (bgp_update_delay_establish_wait, | |
1392 | bgp_update_delay_establish_wait_cmd, | |
6147e2c6 | 1393 | "update-delay (0-3600) (1-3600)", |
f188f2c4 DS |
1394 | "Force initial delay for best-path and updates\n" |
1395 | "Seconds\n" | |
f188f2c4 DS |
1396 | "Seconds\n") |
1397 | { | |
d62a17ae | 1398 | int idx_number = 1; |
1399 | int idx_number_2 = 2; | |
1400 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, | |
1401 | argv[idx_number_2]->arg); | |
f188f2c4 DS |
1402 | } |
1403 | ||
1404 | /* Update-delay deconfiguration */ | |
1405 | DEFUN (no_bgp_update_delay, | |
1406 | no_bgp_update_delay_cmd, | |
838758ac DW |
1407 | "no update-delay [(0-3600) [(1-3600)]]", |
1408 | NO_STR | |
f188f2c4 | 1409 | "Force initial delay for best-path and updates\n" |
838758ac | 1410 | "Seconds\n" |
7111c1a0 | 1411 | "Seconds\n") |
f188f2c4 | 1412 | { |
d62a17ae | 1413 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
1414 | } |
1415 | ||
5e242b0d | 1416 | |
d62a17ae | 1417 | static int bgp_wpkt_quanta_config_vty(struct vty *vty, const char *num, |
1418 | char set) | |
cb1faec9 | 1419 | { |
d62a17ae | 1420 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
cb1faec9 | 1421 | |
555e09d4 QY |
1422 | if (set) { |
1423 | uint32_t quanta = strtoul(num, NULL, 10); | |
1424 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, | |
1425 | memory_order_relaxed); | |
1426 | } else { | |
1427 | atomic_store_explicit(&bgp->wpkt_quanta, BGP_WRITE_PACKET_MAX, | |
1428 | memory_order_relaxed); | |
1429 | } | |
1430 | ||
1431 | return CMD_SUCCESS; | |
1432 | } | |
1433 | ||
1434 | static int bgp_rpkt_quanta_config_vty(struct vty *vty, const char *num, | |
1435 | char set) | |
1436 | { | |
1437 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1438 | ||
1439 | if (set) { | |
1440 | uint32_t quanta = strtoul(num, NULL, 10); | |
1441 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, | |
1442 | memory_order_relaxed); | |
1443 | } else { | |
1444 | atomic_store_explicit(&bgp->rpkt_quanta, BGP_READ_PACKET_MAX, | |
1445 | memory_order_relaxed); | |
1446 | } | |
cb1faec9 | 1447 | |
d62a17ae | 1448 | return CMD_SUCCESS; |
cb1faec9 DS |
1449 | } |
1450 | ||
2b791107 | 1451 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 1452 | { |
555e09d4 QY |
1453 | uint32_t quanta = |
1454 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
1455 | if (quanta != BGP_WRITE_PACKET_MAX) | |
152456fe | 1456 | vty_out(vty, " write-quanta %d\n", quanta); |
cb1faec9 DS |
1457 | } |
1458 | ||
555e09d4 QY |
1459 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) |
1460 | { | |
1461 | uint32_t quanta = | |
1462 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
1463 | if (quanta != BGP_READ_PACKET_MAX) | |
152456fe | 1464 | vty_out(vty, " read-quanta %d\n", quanta); |
555e09d4 | 1465 | } |
cb1faec9 | 1466 | |
555e09d4 | 1467 | /* Packet quanta configuration */ |
cb1faec9 DS |
1468 | DEFUN (bgp_wpkt_quanta, |
1469 | bgp_wpkt_quanta_cmd, | |
555e09d4 | 1470 | "write-quanta (1-10)", |
cb1faec9 DS |
1471 | "How many packets to write to peer socket per run\n" |
1472 | "Number of packets\n") | |
1473 | { | |
d62a17ae | 1474 | int idx_number = 1; |
1475 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
cb1faec9 DS |
1476 | } |
1477 | ||
cb1faec9 DS |
1478 | DEFUN (no_bgp_wpkt_quanta, |
1479 | no_bgp_wpkt_quanta_cmd, | |
555e09d4 | 1480 | "no write-quanta (1-10)", |
d7fa34c1 | 1481 | NO_STR |
555e09d4 | 1482 | "How many packets to write to peer socket per I/O cycle\n" |
cb1faec9 DS |
1483 | "Number of packets\n") |
1484 | { | |
d62a17ae | 1485 | int idx_number = 2; |
1486 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
cb1faec9 DS |
1487 | } |
1488 | ||
555e09d4 QY |
1489 | DEFUN (bgp_rpkt_quanta, |
1490 | bgp_rpkt_quanta_cmd, | |
1491 | "read-quanta (1-10)", | |
1492 | "How many packets to read from peer socket per I/O cycle\n" | |
1493 | "Number of packets\n") | |
1494 | { | |
1495 | int idx_number = 1; | |
1496 | return bgp_rpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
1497 | } | |
1498 | ||
1499 | DEFUN (no_bgp_rpkt_quanta, | |
1500 | no_bgp_rpkt_quanta_cmd, | |
1501 | "no read-quanta (1-10)", | |
1502 | NO_STR | |
1503 | "How many packets to read from peer socket per I/O cycle\n" | |
1504 | "Number of packets\n") | |
1505 | { | |
1506 | int idx_number = 2; | |
1507 | return bgp_rpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
1508 | } | |
1509 | ||
2b791107 | 1510 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 1511 | { |
37a333fe | 1512 | if (!bgp->heuristic_coalesce) |
d62a17ae | 1513 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); |
3f9c7369 DS |
1514 | } |
1515 | ||
1516 | ||
1517 | DEFUN (bgp_coalesce_time, | |
1518 | bgp_coalesce_time_cmd, | |
6147e2c6 | 1519 | "coalesce-time (0-4294967295)", |
3f9c7369 DS |
1520 | "Subgroup coalesce timer\n" |
1521 | "Subgroup coalesce timer value (in ms)\n") | |
1522 | { | |
d62a17ae | 1523 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1524 | |
d62a17ae | 1525 | int idx = 0; |
1526 | argv_find(argv, argc, "(0-4294967295)", &idx); | |
37a333fe | 1527 | bgp->heuristic_coalesce = false; |
d62a17ae | 1528 | bgp->coalesce_time = strtoul(argv[idx]->arg, NULL, 10); |
1529 | return CMD_SUCCESS; | |
3f9c7369 DS |
1530 | } |
1531 | ||
1532 | DEFUN (no_bgp_coalesce_time, | |
1533 | no_bgp_coalesce_time_cmd, | |
6147e2c6 | 1534 | "no coalesce-time (0-4294967295)", |
3a2d747c | 1535 | NO_STR |
3f9c7369 DS |
1536 | "Subgroup coalesce timer\n" |
1537 | "Subgroup coalesce timer value (in ms)\n") | |
1538 | { | |
d62a17ae | 1539 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1540 | |
37a333fe | 1541 | bgp->heuristic_coalesce = true; |
d62a17ae | 1542 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; |
1543 | return CMD_SUCCESS; | |
3f9c7369 DS |
1544 | } |
1545 | ||
5e242b0d DS |
1546 | /* Maximum-paths configuration */ |
1547 | DEFUN (bgp_maxpaths, | |
1548 | bgp_maxpaths_cmd, | |
6319fd63 | 1549 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), |
5e242b0d DS |
1550 | "Forward packets over multiple paths\n" |
1551 | "Number of paths\n") | |
1552 | { | |
d62a17ae | 1553 | int idx_number = 1; |
1554 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, | |
1555 | argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
1556 | } |
1557 | ||
d62a17ae | 1558 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
1559 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1560 | "Forward packets over multiple paths\n" | |
1561 | "Number of paths\n") | |
596c17ba | 1562 | |
165b5fff JB |
1563 | DEFUN (bgp_maxpaths_ibgp, |
1564 | bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1565 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), |
165b5fff JB |
1566 | "Forward packets over multiple paths\n" |
1567 | "iBGP-multipath\n" | |
1568 | "Number of paths\n") | |
1569 | { | |
d62a17ae | 1570 | int idx_number = 2; |
1571 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, | |
1572 | argv[idx_number]->arg, 0, 1); | |
5e242b0d | 1573 | } |
165b5fff | 1574 | |
d62a17ae | 1575 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
1576 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1577 | "Forward packets over multiple paths\n" | |
1578 | "iBGP-multipath\n" | |
1579 | "Number of paths\n") | |
596c17ba | 1580 | |
5e242b0d DS |
1581 | DEFUN (bgp_maxpaths_ibgp_cluster, |
1582 | bgp_maxpaths_ibgp_cluster_cmd, | |
6319fd63 | 1583 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", |
5e242b0d DS |
1584 | "Forward packets over multiple paths\n" |
1585 | "iBGP-multipath\n" | |
1586 | "Number of paths\n" | |
1587 | "Match the cluster length\n") | |
1588 | { | |
d62a17ae | 1589 | int idx_number = 2; |
1590 | return bgp_maxpaths_config_vty( | |
1591 | vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
1592 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); | |
165b5fff JB |
1593 | } |
1594 | ||
d62a17ae | 1595 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
1596 | "maximum-paths ibgp " CMD_RANGE_STR( | |
1597 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
1598 | "Forward packets over multiple paths\n" | |
1599 | "iBGP-multipath\n" | |
1600 | "Number of paths\n" | |
1601 | "Match the cluster length\n") | |
596c17ba | 1602 | |
165b5fff JB |
1603 | DEFUN (no_bgp_maxpaths, |
1604 | no_bgp_maxpaths_cmd, | |
6319fd63 | 1605 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", |
165b5fff JB |
1606 | NO_STR |
1607 | "Forward packets over multiple paths\n" | |
1608 | "Number of paths\n") | |
1609 | { | |
d62a17ae | 1610 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
1611 | } |
1612 | ||
d62a17ae | 1613 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
996c9314 | 1614 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 1615 | "Forward packets over multiple paths\n" |
1616 | "Number of paths\n") | |
596c17ba | 1617 | |
165b5fff JB |
1618 | DEFUN (no_bgp_maxpaths_ibgp, |
1619 | no_bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1620 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", |
165b5fff JB |
1621 | NO_STR |
1622 | "Forward packets over multiple paths\n" | |
1623 | "iBGP-multipath\n" | |
838758ac DW |
1624 | "Number of paths\n" |
1625 | "Match the cluster length\n") | |
165b5fff | 1626 | { |
d62a17ae | 1627 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1628 | } |
1629 | ||
d62a17ae | 1630 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
1631 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
1632 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
1633 | NO_STR | |
1634 | "Forward packets over multiple paths\n" | |
1635 | "iBGP-multipath\n" | |
1636 | "Number of paths\n" | |
1637 | "Match the cluster length\n") | |
596c17ba | 1638 | |
2b791107 | 1639 | void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, afi_t afi, |
60466a63 | 1640 | safi_t safi) |
165b5fff | 1641 | { |
d62a17ae | 1642 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) { |
d62a17ae | 1643 | vty_out(vty, " maximum-paths %d\n", |
1644 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
1645 | } | |
165b5fff | 1646 | |
d62a17ae | 1647 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) { |
d62a17ae | 1648 | vty_out(vty, " maximum-paths ibgp %d", |
1649 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
1650 | if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, | |
1651 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1652 | vty_out(vty, " equal-cluster-length"); | |
1653 | vty_out(vty, "\n"); | |
1654 | } | |
165b5fff | 1655 | } |
6b0655a2 | 1656 | |
718e3744 | 1657 | /* BGP timers. */ |
1658 | ||
1659 | DEFUN (bgp_timers, | |
1660 | bgp_timers_cmd, | |
6147e2c6 | 1661 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1662 | "Adjust routing timers\n" |
1663 | "BGP timers\n" | |
1664 | "Keepalive interval\n" | |
1665 | "Holdtime\n") | |
1666 | { | |
d62a17ae | 1667 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1668 | int idx_number = 2; | |
1669 | int idx_number_2 = 3; | |
1670 | unsigned long keepalive = 0; | |
1671 | unsigned long holdtime = 0; | |
718e3744 | 1672 | |
d62a17ae | 1673 | keepalive = strtoul(argv[idx_number]->arg, NULL, 10); |
1674 | holdtime = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
718e3744 | 1675 | |
d62a17ae | 1676 | /* Holdtime value check. */ |
1677 | if (holdtime < 3 && holdtime != 0) { | |
1678 | vty_out(vty, | |
1679 | "%% hold time value must be either 0 or greater than 3\n"); | |
1680 | return CMD_WARNING_CONFIG_FAILED; | |
1681 | } | |
718e3744 | 1682 | |
d62a17ae | 1683 | bgp_timers_set(bgp, keepalive, holdtime); |
718e3744 | 1684 | |
d62a17ae | 1685 | return CMD_SUCCESS; |
718e3744 | 1686 | } |
1687 | ||
1688 | DEFUN (no_bgp_timers, | |
1689 | no_bgp_timers_cmd, | |
838758ac | 1690 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1691 | NO_STR |
1692 | "Adjust routing timers\n" | |
838758ac DW |
1693 | "BGP timers\n" |
1694 | "Keepalive interval\n" | |
1695 | "Holdtime\n") | |
718e3744 | 1696 | { |
d62a17ae | 1697 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1698 | bgp_timers_unset(bgp); | |
718e3744 | 1699 | |
d62a17ae | 1700 | return CMD_SUCCESS; |
718e3744 | 1701 | } |
1702 | ||
6b0655a2 | 1703 | |
718e3744 | 1704 | DEFUN (bgp_client_to_client_reflection, |
1705 | bgp_client_to_client_reflection_cmd, | |
1706 | "bgp client-to-client reflection", | |
1707 | "BGP specific commands\n" | |
1708 | "Configure client to client route reflection\n" | |
1709 | "reflection of routes allowed\n") | |
1710 | { | |
d62a17ae | 1711 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1712 | bgp_flag_unset(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1713 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1714 | |
d62a17ae | 1715 | return CMD_SUCCESS; |
718e3744 | 1716 | } |
1717 | ||
1718 | DEFUN (no_bgp_client_to_client_reflection, | |
1719 | no_bgp_client_to_client_reflection_cmd, | |
1720 | "no bgp client-to-client reflection", | |
1721 | NO_STR | |
1722 | "BGP specific commands\n" | |
1723 | "Configure client to client route reflection\n" | |
1724 | "reflection of routes allowed\n") | |
1725 | { | |
d62a17ae | 1726 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1727 | bgp_flag_set(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1728 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1729 | |
d62a17ae | 1730 | return CMD_SUCCESS; |
718e3744 | 1731 | } |
1732 | ||
1733 | /* "bgp always-compare-med" configuration. */ | |
1734 | DEFUN (bgp_always_compare_med, | |
1735 | bgp_always_compare_med_cmd, | |
1736 | "bgp always-compare-med", | |
1737 | "BGP specific commands\n" | |
1738 | "Allow comparing MED from different neighbors\n") | |
1739 | { | |
d62a17ae | 1740 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1741 | bgp_flag_set(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1742 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1743 | |
d62a17ae | 1744 | return CMD_SUCCESS; |
718e3744 | 1745 | } |
1746 | ||
1747 | DEFUN (no_bgp_always_compare_med, | |
1748 | no_bgp_always_compare_med_cmd, | |
1749 | "no bgp always-compare-med", | |
1750 | NO_STR | |
1751 | "BGP specific commands\n" | |
1752 | "Allow comparing MED from different neighbors\n") | |
1753 | { | |
d62a17ae | 1754 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1755 | bgp_flag_unset(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1756 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1757 | |
d62a17ae | 1758 | return CMD_SUCCESS; |
718e3744 | 1759 | } |
6b0655a2 | 1760 | |
718e3744 | 1761 | /* "bgp deterministic-med" configuration. */ |
1762 | DEFUN (bgp_deterministic_med, | |
1763 | bgp_deterministic_med_cmd, | |
1764 | "bgp deterministic-med", | |
1765 | "BGP specific commands\n" | |
1766 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1767 | { | |
d62a17ae | 1768 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1475ac87 | 1769 | |
d62a17ae | 1770 | if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { |
1771 | bgp_flag_set(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1772 | bgp_recalculate_all_bestpaths(bgp); | |
1773 | } | |
7aafcaca | 1774 | |
d62a17ae | 1775 | return CMD_SUCCESS; |
718e3744 | 1776 | } |
1777 | ||
1778 | DEFUN (no_bgp_deterministic_med, | |
1779 | no_bgp_deterministic_med_cmd, | |
1780 | "no bgp deterministic-med", | |
1781 | NO_STR | |
1782 | "BGP specific commands\n" | |
1783 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1784 | { | |
d62a17ae | 1785 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1786 | int bestpath_per_as_used; | |
1787 | afi_t afi; | |
1788 | safi_t safi; | |
1789 | struct peer *peer; | |
1790 | struct listnode *node, *nnode; | |
1791 | ||
1792 | if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { | |
1793 | bestpath_per_as_used = 0; | |
1794 | ||
1795 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
05c7a1cc QY |
1796 | FOREACH_AFI_SAFI (afi, safi) |
1797 | if (CHECK_FLAG( | |
1798 | peer->af_flags[afi][safi], | |
1799 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) { | |
1800 | bestpath_per_as_used = 1; | |
1801 | break; | |
1802 | } | |
d62a17ae | 1803 | |
1804 | if (bestpath_per_as_used) | |
1805 | break; | |
1806 | } | |
1807 | ||
1808 | if (bestpath_per_as_used) { | |
1809 | vty_out(vty, | |
1810 | "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n"); | |
1811 | return CMD_WARNING_CONFIG_FAILED; | |
1812 | } else { | |
1813 | bgp_flag_unset(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1814 | bgp_recalculate_all_bestpaths(bgp); | |
1815 | } | |
1816 | } | |
1817 | ||
1818 | return CMD_SUCCESS; | |
718e3744 | 1819 | } |
538621f2 | 1820 | |
1821 | /* "bgp graceful-restart" configuration. */ | |
1822 | DEFUN (bgp_graceful_restart, | |
1823 | bgp_graceful_restart_cmd, | |
1824 | "bgp graceful-restart", | |
1825 | "BGP specific commands\n" | |
1826 | "Graceful restart capability parameters\n") | |
1827 | { | |
d62a17ae | 1828 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1829 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
1830 | return CMD_SUCCESS; | |
538621f2 | 1831 | } |
1832 | ||
1833 | DEFUN (no_bgp_graceful_restart, | |
1834 | no_bgp_graceful_restart_cmd, | |
1835 | "no bgp graceful-restart", | |
1836 | NO_STR | |
1837 | "BGP specific commands\n" | |
1838 | "Graceful restart capability parameters\n") | |
1839 | { | |
d62a17ae | 1840 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1841 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
1842 | return CMD_SUCCESS; | |
538621f2 | 1843 | } |
1844 | ||
93406d87 | 1845 | DEFUN (bgp_graceful_restart_stalepath_time, |
1846 | bgp_graceful_restart_stalepath_time_cmd, | |
6147e2c6 | 1847 | "bgp graceful-restart stalepath-time (1-3600)", |
93406d87 | 1848 | "BGP specific commands\n" |
1849 | "Graceful restart capability parameters\n" | |
1850 | "Set the max time to hold onto restarting peer's stale paths\n" | |
1851 | "Delay value (seconds)\n") | |
1852 | { | |
d62a17ae | 1853 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1854 | int idx_number = 3; | |
d7c0a89a | 1855 | uint32_t stalepath; |
93406d87 | 1856 | |
d62a17ae | 1857 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
1858 | bgp->stalepath_time = stalepath; | |
1859 | return CMD_SUCCESS; | |
93406d87 | 1860 | } |
1861 | ||
eb6f1b41 PG |
1862 | DEFUN (bgp_graceful_restart_restart_time, |
1863 | bgp_graceful_restart_restart_time_cmd, | |
6147e2c6 | 1864 | "bgp graceful-restart restart-time (1-3600)", |
eb6f1b41 PG |
1865 | "BGP specific commands\n" |
1866 | "Graceful restart capability parameters\n" | |
1867 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
1868 | "Delay value (seconds)\n") | |
1869 | { | |
d62a17ae | 1870 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1871 | int idx_number = 3; | |
d7c0a89a | 1872 | uint32_t restart; |
eb6f1b41 | 1873 | |
d62a17ae | 1874 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
1875 | bgp->restart_time = restart; | |
1876 | return CMD_SUCCESS; | |
eb6f1b41 PG |
1877 | } |
1878 | ||
93406d87 | 1879 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
1880 | no_bgp_graceful_restart_stalepath_time_cmd, | |
838758ac | 1881 | "no bgp graceful-restart stalepath-time [(1-3600)]", |
93406d87 | 1882 | NO_STR |
1883 | "BGP specific commands\n" | |
1884 | "Graceful restart capability parameters\n" | |
838758ac DW |
1885 | "Set the max time to hold onto restarting peer's stale paths\n" |
1886 | "Delay value (seconds)\n") | |
93406d87 | 1887 | { |
d62a17ae | 1888 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 1889 | |
d62a17ae | 1890 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
1891 | return CMD_SUCCESS; | |
93406d87 | 1892 | } |
1893 | ||
eb6f1b41 PG |
1894 | DEFUN (no_bgp_graceful_restart_restart_time, |
1895 | no_bgp_graceful_restart_restart_time_cmd, | |
838758ac | 1896 | "no bgp graceful-restart restart-time [(1-3600)]", |
eb6f1b41 PG |
1897 | NO_STR |
1898 | "BGP specific commands\n" | |
1899 | "Graceful restart capability parameters\n" | |
838758ac DW |
1900 | "Set the time to wait to delete stale routes before a BGP open message is received\n" |
1901 | "Delay value (seconds)\n") | |
eb6f1b41 | 1902 | { |
d62a17ae | 1903 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 1904 | |
d62a17ae | 1905 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
1906 | return CMD_SUCCESS; | |
eb6f1b41 PG |
1907 | } |
1908 | ||
43fc21b3 JC |
1909 | DEFUN (bgp_graceful_restart_preserve_fw, |
1910 | bgp_graceful_restart_preserve_fw_cmd, | |
1911 | "bgp graceful-restart preserve-fw-state", | |
1912 | "BGP specific commands\n" | |
1913 | "Graceful restart capability parameters\n" | |
1914 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1915 | { | |
d62a17ae | 1916 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1917 | bgp_flag_set(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1918 | return CMD_SUCCESS; | |
43fc21b3 JC |
1919 | } |
1920 | ||
1921 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
1922 | no_bgp_graceful_restart_preserve_fw_cmd, | |
1923 | "no bgp graceful-restart preserve-fw-state", | |
1924 | NO_STR | |
1925 | "BGP specific commands\n" | |
1926 | "Graceful restart capability parameters\n" | |
1927 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1928 | { | |
d62a17ae | 1929 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1930 | bgp_flag_unset(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1931 | return CMD_SUCCESS; | |
43fc21b3 JC |
1932 | } |
1933 | ||
7f323236 DW |
1934 | static void bgp_redistribute_redo(struct bgp *bgp) |
1935 | { | |
1936 | afi_t afi; | |
1937 | int i; | |
1938 | struct list *red_list; | |
1939 | struct listnode *node; | |
1940 | struct bgp_redist *red; | |
1941 | ||
a4d82a8a PZ |
1942 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { |
1943 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
7f323236 | 1944 | |
a4d82a8a PZ |
1945 | red_list = bgp->redist[afi][i]; |
1946 | if (!red_list) | |
1947 | continue; | |
7f323236 | 1948 | |
a4d82a8a | 1949 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { |
7f323236 DW |
1950 | bgp_redistribute_resend(bgp, afi, i, |
1951 | red->instance); | |
1952 | } | |
1953 | } | |
1954 | } | |
1955 | } | |
1956 | ||
1957 | /* "bgp graceful-shutdown" configuration */ | |
1958 | DEFUN (bgp_graceful_shutdown, | |
1959 | bgp_graceful_shutdown_cmd, | |
1960 | "bgp graceful-shutdown", | |
1961 | BGP_STR | |
1962 | "Graceful shutdown parameters\n") | |
1963 | { | |
1964 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1965 | ||
1966 | if (!bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
1967 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
1968 | bgp_static_redo_import_check(bgp); | |
1969 | bgp_redistribute_redo(bgp); | |
1970 | bgp_clear_star_soft_out(vty, bgp->name); | |
1971 | bgp_clear_star_soft_in(vty, bgp->name); | |
1972 | } | |
1973 | ||
1974 | return CMD_SUCCESS; | |
1975 | } | |
1976 | ||
1977 | DEFUN (no_bgp_graceful_shutdown, | |
1978 | no_bgp_graceful_shutdown_cmd, | |
1979 | "no bgp graceful-shutdown", | |
1980 | NO_STR | |
1981 | BGP_STR | |
1982 | "Graceful shutdown parameters\n") | |
1983 | { | |
1984 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1985 | ||
1986 | if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
1987 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
1988 | bgp_static_redo_import_check(bgp); | |
1989 | bgp_redistribute_redo(bgp); | |
1990 | bgp_clear_star_soft_out(vty, bgp->name); | |
1991 | bgp_clear_star_soft_in(vty, bgp->name); | |
1992 | } | |
1993 | ||
1994 | return CMD_SUCCESS; | |
1995 | } | |
1996 | ||
718e3744 | 1997 | /* "bgp fast-external-failover" configuration. */ |
1998 | DEFUN (bgp_fast_external_failover, | |
1999 | bgp_fast_external_failover_cmd, | |
2000 | "bgp fast-external-failover", | |
2001 | BGP_STR | |
2002 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2003 | { | |
d62a17ae | 2004 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2005 | bgp_flag_unset(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
2006 | return CMD_SUCCESS; | |
718e3744 | 2007 | } |
2008 | ||
2009 | DEFUN (no_bgp_fast_external_failover, | |
2010 | no_bgp_fast_external_failover_cmd, | |
2011 | "no bgp fast-external-failover", | |
2012 | NO_STR | |
2013 | BGP_STR | |
2014 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2015 | { | |
d62a17ae | 2016 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2017 | bgp_flag_set(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
2018 | return CMD_SUCCESS; | |
718e3744 | 2019 | } |
6b0655a2 | 2020 | |
718e3744 | 2021 | /* "bgp enforce-first-as" configuration. */ |
ec4f0750 | 2022 | #if CONFDATE > 20190517 |
47cbc09b PM |
2023 | CPP_NOTICE("bgpd: remove deprecated '[no] bgp enforce-first-as' commands") |
2024 | #endif | |
2025 | ||
f07e1c4f QY |
2026 | DEFUN_HIDDEN (bgp_enforce_first_as, |
2027 | bgp_enforce_first_as_cmd, | |
2028 | "[no] bgp enforce-first-as", | |
2029 | NO_STR | |
2030 | BGP_STR | |
2031 | "Enforce the first AS for EBGP routes\n") | |
718e3744 | 2032 | { |
d62a17ae | 2033 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2034 | |
f07e1c4f QY |
2035 | if (strmatch(argv[0]->text, "no")) |
2036 | bgp_flag_unset(bgp, BGP_FLAG_ENFORCE_FIRST_AS); | |
2037 | else | |
2038 | bgp_flag_set(bgp, BGP_FLAG_ENFORCE_FIRST_AS); | |
7aafcaca | 2039 | |
d62a17ae | 2040 | return CMD_SUCCESS; |
718e3744 | 2041 | } |
6b0655a2 | 2042 | |
718e3744 | 2043 | /* "bgp bestpath compare-routerid" configuration. */ |
2044 | DEFUN (bgp_bestpath_compare_router_id, | |
2045 | bgp_bestpath_compare_router_id_cmd, | |
2046 | "bgp bestpath compare-routerid", | |
2047 | "BGP specific commands\n" | |
2048 | "Change the default bestpath selection\n" | |
2049 | "Compare router-id for identical EBGP paths\n") | |
2050 | { | |
d62a17ae | 2051 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2052 | bgp_flag_set(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
2053 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2054 | |
d62a17ae | 2055 | return CMD_SUCCESS; |
718e3744 | 2056 | } |
2057 | ||
2058 | DEFUN (no_bgp_bestpath_compare_router_id, | |
2059 | no_bgp_bestpath_compare_router_id_cmd, | |
2060 | "no bgp bestpath compare-routerid", | |
2061 | NO_STR | |
2062 | "BGP specific commands\n" | |
2063 | "Change the default bestpath selection\n" | |
2064 | "Compare router-id for identical EBGP paths\n") | |
2065 | { | |
d62a17ae | 2066 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2067 | bgp_flag_unset(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
2068 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2069 | |
d62a17ae | 2070 | return CMD_SUCCESS; |
718e3744 | 2071 | } |
6b0655a2 | 2072 | |
718e3744 | 2073 | /* "bgp bestpath as-path ignore" configuration. */ |
2074 | DEFUN (bgp_bestpath_aspath_ignore, | |
2075 | bgp_bestpath_aspath_ignore_cmd, | |
2076 | "bgp bestpath as-path ignore", | |
2077 | "BGP specific commands\n" | |
2078 | "Change the default bestpath selection\n" | |
2079 | "AS-path attribute\n" | |
2080 | "Ignore as-path length in selecting a route\n") | |
2081 | { | |
d62a17ae | 2082 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2083 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2084 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2085 | |
d62a17ae | 2086 | return CMD_SUCCESS; |
718e3744 | 2087 | } |
2088 | ||
2089 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
2090 | no_bgp_bestpath_aspath_ignore_cmd, | |
2091 | "no bgp bestpath as-path ignore", | |
2092 | NO_STR | |
2093 | "BGP specific commands\n" | |
2094 | "Change the default bestpath selection\n" | |
2095 | "AS-path attribute\n" | |
2096 | "Ignore as-path length in selecting a route\n") | |
2097 | { | |
d62a17ae | 2098 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2099 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2100 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2101 | |
d62a17ae | 2102 | return CMD_SUCCESS; |
718e3744 | 2103 | } |
6b0655a2 | 2104 | |
6811845b | 2105 | /* "bgp bestpath as-path confed" configuration. */ |
2106 | DEFUN (bgp_bestpath_aspath_confed, | |
2107 | bgp_bestpath_aspath_confed_cmd, | |
2108 | "bgp bestpath as-path confed", | |
2109 | "BGP specific commands\n" | |
2110 | "Change the default bestpath selection\n" | |
2111 | "AS-path attribute\n" | |
2112 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2113 | { | |
d62a17ae | 2114 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2115 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_CONFED); | |
2116 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2117 | |
d62a17ae | 2118 | return CMD_SUCCESS; |
6811845b | 2119 | } |
2120 | ||
2121 | DEFUN (no_bgp_bestpath_aspath_confed, | |
2122 | no_bgp_bestpath_aspath_confed_cmd, | |
2123 | "no bgp bestpath as-path confed", | |
2124 | NO_STR | |
2125 | "BGP specific commands\n" | |
2126 | "Change the default bestpath selection\n" | |
2127 | "AS-path attribute\n" | |
2128 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2129 | { | |
d62a17ae | 2130 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2131 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_CONFED); | |
2132 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2133 | |
d62a17ae | 2134 | return CMD_SUCCESS; |
6811845b | 2135 | } |
6b0655a2 | 2136 | |
2fdd455c PM |
2137 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
2138 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
2139 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2140 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2141 | "BGP specific commands\n" |
2142 | "Change the default bestpath selection\n" | |
2143 | "AS-path attribute\n" | |
2144 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2145 | "Generate an AS_SET\n" |
16fc1eec DS |
2146 | "Do not generate an AS_SET\n") |
2147 | { | |
d62a17ae | 2148 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2149 | int idx = 0; | |
2150 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
219178b6 | 2151 | |
d62a17ae | 2152 | /* no-as-set is now the default behavior so we can silently |
2153 | * ignore it */ | |
2154 | if (argv_find(argv, argc, "as-set", &idx)) | |
2155 | bgp_flag_set(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2156 | else | |
2157 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
219178b6 | 2158 | |
d62a17ae | 2159 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2160 | |
d62a17ae | 2161 | return CMD_SUCCESS; |
16fc1eec DS |
2162 | } |
2163 | ||
219178b6 DW |
2164 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
2165 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2166 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2167 | NO_STR |
2168 | "BGP specific commands\n" | |
2169 | "Change the default bestpath selection\n" | |
2170 | "AS-path attribute\n" | |
2171 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2172 | "Generate an AS_SET\n" |
16fc1eec DS |
2173 | "Do not generate an AS_SET\n") |
2174 | { | |
d62a17ae | 2175 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2176 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
2177 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2178 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2179 | |
d62a17ae | 2180 | return CMD_SUCCESS; |
2fdd455c | 2181 | } |
6b0655a2 | 2182 | |
848973c7 | 2183 | /* "bgp log-neighbor-changes" configuration. */ |
2184 | DEFUN (bgp_log_neighbor_changes, | |
2185 | bgp_log_neighbor_changes_cmd, | |
2186 | "bgp log-neighbor-changes", | |
2187 | "BGP specific commands\n" | |
2188 | "Log neighbor up/down and reset reason\n") | |
2189 | { | |
d62a17ae | 2190 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2191 | bgp_flag_set(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2192 | return CMD_SUCCESS; | |
848973c7 | 2193 | } |
2194 | ||
2195 | DEFUN (no_bgp_log_neighbor_changes, | |
2196 | no_bgp_log_neighbor_changes_cmd, | |
2197 | "no bgp log-neighbor-changes", | |
2198 | NO_STR | |
2199 | "BGP specific commands\n" | |
2200 | "Log neighbor up/down and reset reason\n") | |
2201 | { | |
d62a17ae | 2202 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2203 | bgp_flag_unset(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2204 | return CMD_SUCCESS; | |
848973c7 | 2205 | } |
6b0655a2 | 2206 | |
718e3744 | 2207 | /* "bgp bestpath med" configuration. */ |
2208 | DEFUN (bgp_bestpath_med, | |
2209 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 2210 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2211 | "BGP specific commands\n" |
2212 | "Change the default bestpath selection\n" | |
2213 | "MED attribute\n" | |
2214 | "Compare MED among confederation paths\n" | |
838758ac DW |
2215 | "Treat missing MED as the least preferred one\n" |
2216 | "Treat missing MED as the least preferred one\n" | |
2217 | "Compare MED among confederation paths\n") | |
718e3744 | 2218 | { |
d62a17ae | 2219 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6cbd1915 | 2220 | |
d62a17ae | 2221 | int idx = 0; |
2222 | if (argv_find(argv, argc, "confed", &idx)) | |
2223 | bgp_flag_set(bgp, BGP_FLAG_MED_CONFED); | |
2224 | idx = 0; | |
2225 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2226 | bgp_flag_set(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
e52702f2 | 2227 | |
d62a17ae | 2228 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2229 | |
d62a17ae | 2230 | return CMD_SUCCESS; |
718e3744 | 2231 | } |
2232 | ||
718e3744 | 2233 | DEFUN (no_bgp_bestpath_med, |
2234 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2235 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2236 | NO_STR |
2237 | "BGP specific commands\n" | |
2238 | "Change the default bestpath selection\n" | |
2239 | "MED attribute\n" | |
2240 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2241 | "Treat missing MED as the least preferred one\n" |
2242 | "Treat missing MED as the least preferred one\n" | |
2243 | "Compare MED among confederation paths\n") | |
718e3744 | 2244 | { |
d62a17ae | 2245 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
e52702f2 | 2246 | |
d62a17ae | 2247 | int idx = 0; |
2248 | if (argv_find(argv, argc, "confed", &idx)) | |
2249 | bgp_flag_unset(bgp, BGP_FLAG_MED_CONFED); | |
2250 | idx = 0; | |
2251 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2252 | bgp_flag_unset(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
718e3744 | 2253 | |
d62a17ae | 2254 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2255 | |
d62a17ae | 2256 | return CMD_SUCCESS; |
718e3744 | 2257 | } |
2258 | ||
718e3744 | 2259 | /* "no bgp default ipv4-unicast". */ |
2260 | DEFUN (no_bgp_default_ipv4_unicast, | |
2261 | no_bgp_default_ipv4_unicast_cmd, | |
2262 | "no bgp default ipv4-unicast", | |
2263 | NO_STR | |
2264 | "BGP specific commands\n" | |
2265 | "Configure BGP defaults\n" | |
2266 | "Activate ipv4-unicast for a peer by default\n") | |
2267 | { | |
d62a17ae | 2268 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2269 | bgp_flag_set(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2270 | return CMD_SUCCESS; | |
718e3744 | 2271 | } |
2272 | ||
2273 | DEFUN (bgp_default_ipv4_unicast, | |
2274 | bgp_default_ipv4_unicast_cmd, | |
2275 | "bgp default ipv4-unicast", | |
2276 | "BGP specific commands\n" | |
2277 | "Configure BGP defaults\n" | |
2278 | "Activate ipv4-unicast for a peer by default\n") | |
2279 | { | |
d62a17ae | 2280 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2281 | bgp_flag_unset(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2282 | return CMD_SUCCESS; | |
718e3744 | 2283 | } |
6b0655a2 | 2284 | |
04b6bdc0 DW |
2285 | /* Display hostname in certain command outputs */ |
2286 | DEFUN (bgp_default_show_hostname, | |
2287 | bgp_default_show_hostname_cmd, | |
2288 | "bgp default show-hostname", | |
2289 | "BGP specific commands\n" | |
2290 | "Configure BGP defaults\n" | |
2291 | "Show hostname in certain command ouputs\n") | |
2292 | { | |
d62a17ae | 2293 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2294 | bgp_flag_set(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2295 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2296 | } |
2297 | ||
2298 | DEFUN (no_bgp_default_show_hostname, | |
2299 | no_bgp_default_show_hostname_cmd, | |
2300 | "no bgp default show-hostname", | |
2301 | NO_STR | |
2302 | "BGP specific commands\n" | |
2303 | "Configure BGP defaults\n" | |
2304 | "Show hostname in certain command ouputs\n") | |
2305 | { | |
d62a17ae | 2306 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2307 | bgp_flag_unset(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2308 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2309 | } |
2310 | ||
8233ef81 | 2311 | /* "bgp network import-check" configuration. */ |
718e3744 | 2312 | DEFUN (bgp_network_import_check, |
2313 | bgp_network_import_check_cmd, | |
5623e905 | 2314 | "bgp network import-check", |
718e3744 | 2315 | "BGP specific commands\n" |
2316 | "BGP network command\n" | |
5623e905 | 2317 | "Check BGP network route exists in IGP\n") |
718e3744 | 2318 | { |
d62a17ae | 2319 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2320 | if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2321 | bgp_flag_set(bgp, BGP_FLAG_IMPORT_CHECK); | |
2322 | bgp_static_redo_import_check(bgp); | |
2323 | } | |
078430f6 | 2324 | |
d62a17ae | 2325 | return CMD_SUCCESS; |
718e3744 | 2326 | } |
2327 | ||
d62a17ae | 2328 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
2329 | "bgp network import-check exact", | |
2330 | "BGP specific commands\n" | |
2331 | "BGP network command\n" | |
2332 | "Check BGP network route exists in IGP\n" | |
2333 | "Match route precisely\n") | |
8233ef81 | 2334 | |
718e3744 | 2335 | DEFUN (no_bgp_network_import_check, |
2336 | no_bgp_network_import_check_cmd, | |
5623e905 | 2337 | "no bgp network import-check", |
718e3744 | 2338 | NO_STR |
2339 | "BGP specific commands\n" | |
2340 | "BGP network command\n" | |
2341 | "Check BGP network route exists in IGP\n") | |
2342 | { | |
d62a17ae | 2343 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2344 | if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2345 | bgp_flag_unset(bgp, BGP_FLAG_IMPORT_CHECK); | |
2346 | bgp_static_redo_import_check(bgp); | |
2347 | } | |
5623e905 | 2348 | |
d62a17ae | 2349 | return CMD_SUCCESS; |
718e3744 | 2350 | } |
6b0655a2 | 2351 | |
718e3744 | 2352 | DEFUN (bgp_default_local_preference, |
2353 | bgp_default_local_preference_cmd, | |
6147e2c6 | 2354 | "bgp default local-preference (0-4294967295)", |
718e3744 | 2355 | "BGP specific commands\n" |
2356 | "Configure BGP defaults\n" | |
2357 | "local preference (higher=more preferred)\n" | |
2358 | "Configure default local preference value\n") | |
2359 | { | |
d62a17ae | 2360 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2361 | int idx_number = 3; | |
d7c0a89a | 2362 | uint32_t local_pref; |
718e3744 | 2363 | |
d62a17ae | 2364 | local_pref = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 2365 | |
d62a17ae | 2366 | bgp_default_local_preference_set(bgp, local_pref); |
2367 | bgp_clear_star_soft_in(vty, bgp->name); | |
718e3744 | 2368 | |
d62a17ae | 2369 | return CMD_SUCCESS; |
718e3744 | 2370 | } |
2371 | ||
2372 | DEFUN (no_bgp_default_local_preference, | |
2373 | no_bgp_default_local_preference_cmd, | |
838758ac | 2374 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 2375 | NO_STR |
2376 | "BGP specific commands\n" | |
2377 | "Configure BGP defaults\n" | |
838758ac DW |
2378 | "local preference (higher=more preferred)\n" |
2379 | "Configure default local preference value\n") | |
718e3744 | 2380 | { |
d62a17ae | 2381 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2382 | bgp_default_local_preference_unset(bgp); | |
2383 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2384 | |
d62a17ae | 2385 | return CMD_SUCCESS; |
718e3744 | 2386 | } |
2387 | ||
6b0655a2 | 2388 | |
3f9c7369 DS |
2389 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
2390 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 2391 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
2392 | "BGP specific commands\n" |
2393 | "Configure BGP defaults\n" | |
2394 | "subgroup-pkt-queue-max\n" | |
2395 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 2396 | { |
d62a17ae | 2397 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2398 | int idx_number = 3; | |
d7c0a89a | 2399 | uint32_t max_size; |
8bd9d948 | 2400 | |
d62a17ae | 2401 | max_size = strtoul(argv[idx_number]->arg, NULL, 10); |
3f9c7369 | 2402 | |
d62a17ae | 2403 | bgp_default_subgroup_pkt_queue_max_set(bgp, max_size); |
3f9c7369 | 2404 | |
d62a17ae | 2405 | return CMD_SUCCESS; |
3f9c7369 DS |
2406 | } |
2407 | ||
2408 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
2409 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 2410 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
2411 | NO_STR |
2412 | "BGP specific commands\n" | |
2413 | "Configure BGP defaults\n" | |
838758ac DW |
2414 | "subgroup-pkt-queue-max\n" |
2415 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 2416 | { |
d62a17ae | 2417 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2418 | bgp_default_subgroup_pkt_queue_max_unset(bgp); | |
2419 | return CMD_SUCCESS; | |
8bd9d948 DS |
2420 | } |
2421 | ||
813d4307 | 2422 | |
8bd9d948 DS |
2423 | DEFUN (bgp_rr_allow_outbound_policy, |
2424 | bgp_rr_allow_outbound_policy_cmd, | |
2425 | "bgp route-reflector allow-outbound-policy", | |
2426 | "BGP specific commands\n" | |
2427 | "Allow modifications made by out route-map\n" | |
2428 | "on ibgp neighbors\n") | |
2429 | { | |
d62a17ae | 2430 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2431 | |
d62a17ae | 2432 | if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2433 | bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2434 | update_group_announce_rrclients(bgp); | |
2435 | bgp_clear_star_soft_out(vty, bgp->name); | |
2436 | } | |
8bd9d948 | 2437 | |
d62a17ae | 2438 | return CMD_SUCCESS; |
8bd9d948 DS |
2439 | } |
2440 | ||
2441 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
2442 | no_bgp_rr_allow_outbound_policy_cmd, | |
2443 | "no bgp route-reflector allow-outbound-policy", | |
2444 | NO_STR | |
2445 | "BGP specific commands\n" | |
2446 | "Allow modifications made by out route-map\n" | |
2447 | "on ibgp neighbors\n") | |
2448 | { | |
d62a17ae | 2449 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2450 | |
d62a17ae | 2451 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2452 | bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2453 | update_group_announce_rrclients(bgp); | |
2454 | bgp_clear_star_soft_out(vty, bgp->name); | |
2455 | } | |
8bd9d948 | 2456 | |
d62a17ae | 2457 | return CMD_SUCCESS; |
8bd9d948 DS |
2458 | } |
2459 | ||
f14e6fdb DS |
2460 | DEFUN (bgp_listen_limit, |
2461 | bgp_listen_limit_cmd, | |
9ccf14f7 | 2462 | "bgp listen limit (1-5000)", |
f14e6fdb DS |
2463 | "BGP specific commands\n" |
2464 | "Configure BGP defaults\n" | |
2465 | "maximum number of BGP Dynamic Neighbors that can be created\n" | |
2466 | "Configure Dynamic Neighbors listen limit value\n") | |
2467 | { | |
d62a17ae | 2468 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2469 | int idx_number = 3; | |
2470 | int listen_limit; | |
f14e6fdb | 2471 | |
d62a17ae | 2472 | listen_limit = strtoul(argv[idx_number]->arg, NULL, 10); |
f14e6fdb | 2473 | |
d62a17ae | 2474 | bgp_listen_limit_set(bgp, listen_limit); |
f14e6fdb | 2475 | |
d62a17ae | 2476 | return CMD_SUCCESS; |
f14e6fdb DS |
2477 | } |
2478 | ||
2479 | DEFUN (no_bgp_listen_limit, | |
2480 | no_bgp_listen_limit_cmd, | |
838758ac | 2481 | "no bgp listen limit [(1-5000)]", |
f14e6fdb DS |
2482 | "BGP specific commands\n" |
2483 | "Configure BGP defaults\n" | |
2484 | "unset maximum number of BGP Dynamic Neighbors that can be created\n" | |
838758ac DW |
2485 | "Configure Dynamic Neighbors listen limit value to default\n" |
2486 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 2487 | { |
d62a17ae | 2488 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2489 | bgp_listen_limit_unset(bgp); | |
2490 | return CMD_SUCCESS; | |
f14e6fdb DS |
2491 | } |
2492 | ||
2493 | ||
20eb8864 | 2494 | /* |
2495 | * Check if this listen range is already configured. Check for exact | |
2496 | * match or overlap based on input. | |
2497 | */ | |
d62a17ae | 2498 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
2499 | struct prefix *range, int exact) | |
2500 | { | |
2501 | struct listnode *node, *nnode; | |
2502 | struct listnode *node1, *nnode1; | |
2503 | struct peer_group *group; | |
2504 | struct prefix *lr; | |
2505 | afi_t afi; | |
2506 | int match; | |
2507 | ||
2508 | afi = family2afi(range->family); | |
2509 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2510 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
2511 | lr)) { | |
2512 | if (exact) | |
2513 | match = prefix_same(range, lr); | |
2514 | else | |
2515 | match = (prefix_match(range, lr) | |
2516 | || prefix_match(lr, range)); | |
2517 | if (match) | |
2518 | return group; | |
2519 | } | |
2520 | } | |
2521 | ||
2522 | return NULL; | |
20eb8864 | 2523 | } |
2524 | ||
f14e6fdb DS |
2525 | DEFUN (bgp_listen_range, |
2526 | bgp_listen_range_cmd, | |
9ccf14f7 | 2527 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
f14e6fdb | 2528 | "BGP specific commands\n" |
d7fa34c1 QY |
2529 | "Configure BGP dynamic neighbors listen range\n" |
2530 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
2531 | NEIGHBOR_ADDR_STR |
2532 | "Member of the peer-group\n" | |
2533 | "Peer-group name\n") | |
f14e6fdb | 2534 | { |
d62a17ae | 2535 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2536 | struct prefix range; | |
2537 | struct peer_group *group, *existing_group; | |
2538 | afi_t afi; | |
2539 | int ret; | |
2540 | int idx = 0; | |
2541 | ||
2542 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2543 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2544 | char *prefix = argv[idx]->arg; | |
2545 | argv_find(argv, argc, "WORD", &idx); | |
2546 | char *peergroup = argv[idx]->arg; | |
2547 | ||
2548 | /* Convert IP prefix string to struct prefix. */ | |
2549 | ret = str2prefix(prefix, &range); | |
2550 | if (!ret) { | |
2551 | vty_out(vty, "%% Malformed listen range\n"); | |
2552 | return CMD_WARNING_CONFIG_FAILED; | |
2553 | } | |
2554 | ||
2555 | afi = family2afi(range.family); | |
2556 | ||
2557 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2558 | vty_out(vty, | |
2559 | "%% Malformed listen range (link-local address)\n"); | |
2560 | return CMD_WARNING_CONFIG_FAILED; | |
2561 | } | |
2562 | ||
2563 | apply_mask(&range); | |
2564 | ||
2565 | /* Check if same listen range is already configured. */ | |
2566 | existing_group = listen_range_exists(bgp, &range, 1); | |
2567 | if (existing_group) { | |
2568 | if (strcmp(existing_group->name, peergroup) == 0) | |
2569 | return CMD_SUCCESS; | |
2570 | else { | |
2571 | vty_out(vty, | |
2572 | "%% Same listen range is attached to peer-group %s\n", | |
2573 | existing_group->name); | |
2574 | return CMD_WARNING_CONFIG_FAILED; | |
2575 | } | |
2576 | } | |
2577 | ||
2578 | /* Check if an overlapping listen range exists. */ | |
2579 | if (listen_range_exists(bgp, &range, 0)) { | |
2580 | vty_out(vty, | |
2581 | "%% Listen range overlaps with existing listen range\n"); | |
2582 | return CMD_WARNING_CONFIG_FAILED; | |
2583 | } | |
2584 | ||
2585 | group = peer_group_lookup(bgp, peergroup); | |
2586 | if (!group) { | |
2587 | vty_out(vty, "%% Configure the peer-group first\n"); | |
2588 | return CMD_WARNING_CONFIG_FAILED; | |
2589 | } | |
2590 | ||
2591 | ret = peer_group_listen_range_add(group, &range); | |
2592 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
2593 | } |
2594 | ||
2595 | DEFUN (no_bgp_listen_range, | |
2596 | no_bgp_listen_range_cmd, | |
d7fa34c1 QY |
2597 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
2598 | NO_STR | |
f14e6fdb | 2599 | "BGP specific commands\n" |
d7fa34c1 QY |
2600 | "Unconfigure BGP dynamic neighbors listen range\n" |
2601 | "Unconfigure BGP dynamic neighbors listen range\n" | |
2602 | NEIGHBOR_ADDR_STR | |
2603 | "Member of the peer-group\n" | |
2604 | "Peer-group name\n") | |
f14e6fdb | 2605 | { |
d62a17ae | 2606 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2607 | struct prefix range; | |
2608 | struct peer_group *group; | |
2609 | afi_t afi; | |
2610 | int ret; | |
2611 | int idx = 0; | |
2612 | ||
2613 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2614 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2615 | char *prefix = argv[idx]->arg; | |
2616 | argv_find(argv, argc, "WORD", &idx); | |
2617 | char *peergroup = argv[idx]->arg; | |
2618 | ||
2619 | /* Convert IP prefix string to struct prefix. */ | |
2620 | ret = str2prefix(prefix, &range); | |
2621 | if (!ret) { | |
2622 | vty_out(vty, "%% Malformed listen range\n"); | |
2623 | return CMD_WARNING_CONFIG_FAILED; | |
2624 | } | |
2625 | ||
2626 | afi = family2afi(range.family); | |
2627 | ||
2628 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2629 | vty_out(vty, | |
2630 | "%% Malformed listen range (link-local address)\n"); | |
2631 | return CMD_WARNING_CONFIG_FAILED; | |
2632 | } | |
2633 | ||
2634 | apply_mask(&range); | |
2635 | ||
2636 | group = peer_group_lookup(bgp, peergroup); | |
2637 | if (!group) { | |
2638 | vty_out(vty, "%% Peer-group does not exist\n"); | |
2639 | return CMD_WARNING_CONFIG_FAILED; | |
2640 | } | |
2641 | ||
2642 | ret = peer_group_listen_range_del(group, &range); | |
2643 | return bgp_vty_return(vty, ret); | |
2644 | } | |
2645 | ||
2b791107 | 2646 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 2647 | { |
2648 | struct peer_group *group; | |
2649 | struct listnode *node, *nnode, *rnode, *nrnode; | |
2650 | struct prefix *range; | |
2651 | afi_t afi; | |
2652 | char buf[PREFIX2STR_BUFFER]; | |
2653 | ||
2654 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
2655 | vty_out(vty, " bgp listen limit %d\n", | |
2656 | bgp->dynamic_neighbors_limit); | |
2657 | ||
2658 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2659 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
2660 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
2661 | nrnode, range)) { | |
2662 | prefix2str(range, buf, sizeof(buf)); | |
2663 | vty_out(vty, | |
2664 | " bgp listen range %s peer-group %s\n", | |
2665 | buf, group->name); | |
2666 | } | |
2667 | } | |
2668 | } | |
f14e6fdb DS |
2669 | } |
2670 | ||
2671 | ||
907f92c8 DS |
2672 | DEFUN (bgp_disable_connected_route_check, |
2673 | bgp_disable_connected_route_check_cmd, | |
2674 | "bgp disable-ebgp-connected-route-check", | |
2675 | "BGP specific commands\n" | |
2676 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2677 | { | |
d62a17ae | 2678 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2679 | bgp_flag_set(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2680 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2681 | |
d62a17ae | 2682 | return CMD_SUCCESS; |
907f92c8 DS |
2683 | } |
2684 | ||
2685 | DEFUN (no_bgp_disable_connected_route_check, | |
2686 | no_bgp_disable_connected_route_check_cmd, | |
2687 | "no bgp disable-ebgp-connected-route-check", | |
2688 | NO_STR | |
2689 | "BGP specific commands\n" | |
2690 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2691 | { | |
d62a17ae | 2692 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2693 | bgp_flag_unset(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2694 | bgp_clear_star_soft_in(vty, bgp->name); | |
2695 | ||
2696 | return CMD_SUCCESS; | |
2697 | } | |
2698 | ||
2699 | ||
2700 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, | |
2701 | const char *as_str, afi_t afi, safi_t safi) | |
2702 | { | |
2703 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2704 | int ret; | |
2705 | as_t as; | |
2706 | int as_type = AS_SPECIFIED; | |
2707 | union sockunion su; | |
2708 | ||
2709 | if (as_str[0] == 'i') { | |
2710 | as = 0; | |
2711 | as_type = AS_INTERNAL; | |
2712 | } else if (as_str[0] == 'e') { | |
2713 | as = 0; | |
2714 | as_type = AS_EXTERNAL; | |
2715 | } else { | |
2716 | /* Get AS number. */ | |
2717 | as = strtoul(as_str, NULL, 10); | |
2718 | } | |
2719 | ||
2720 | /* If peer is peer group, call proper function. */ | |
2721 | ret = str2sockunion(peer_str, &su); | |
2722 | if (ret < 0) { | |
2723 | /* Check for peer by interface */ | |
2724 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type, afi, | |
2725 | safi); | |
2726 | if (ret < 0) { | |
2727 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); | |
2728 | if (ret < 0) { | |
2729 | vty_out(vty, | |
2730 | "%% Create the peer-group or interface first\n"); | |
2731 | return CMD_WARNING_CONFIG_FAILED; | |
2732 | } | |
2733 | return CMD_SUCCESS; | |
2734 | } | |
2735 | } else { | |
2736 | if (peer_address_self_check(bgp, &su)) { | |
2737 | vty_out(vty, | |
2738 | "%% Can not configure the local system as neighbor\n"); | |
2739 | return CMD_WARNING_CONFIG_FAILED; | |
2740 | } | |
2741 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type, afi, safi); | |
2742 | } | |
2743 | ||
2744 | /* This peer belongs to peer group. */ | |
2745 | switch (ret) { | |
2746 | case BGP_ERR_PEER_GROUP_MEMBER: | |
2747 | vty_out(vty, | |
2748 | "%% Peer-group AS %u. Cannot configure remote-as for member\n", | |
2749 | as); | |
2750 | return CMD_WARNING_CONFIG_FAILED; | |
2751 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
2752 | vty_out(vty, | |
2753 | "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external\n", | |
2754 | as, as_str); | |
2755 | return CMD_WARNING_CONFIG_FAILED; | |
2756 | } | |
2757 | return bgp_vty_return(vty, ret); | |
718e3744 | 2758 | } |
2759 | ||
f26845f9 QY |
2760 | DEFUN (bgp_default_shutdown, |
2761 | bgp_default_shutdown_cmd, | |
2762 | "[no] bgp default shutdown", | |
2763 | NO_STR | |
2764 | BGP_STR | |
2765 | "Configure BGP defaults\n" | |
b012cbe2 | 2766 | "Apply administrative shutdown to newly configured peers\n") |
f26845f9 QY |
2767 | { |
2768 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2769 | bgp->autoshutdown = !strmatch(argv[0]->text, "no"); | |
2770 | return CMD_SUCCESS; | |
2771 | } | |
2772 | ||
718e3744 | 2773 | DEFUN (neighbor_remote_as, |
2774 | neighbor_remote_as_cmd, | |
3a2d747c | 2775 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2776 | NEIGHBOR_STR |
2777 | NEIGHBOR_ADDR_STR2 | |
2778 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 2779 | AS_STR |
3a2d747c QY |
2780 | "Internal BGP peer\n" |
2781 | "External BGP peer\n") | |
718e3744 | 2782 | { |
d62a17ae | 2783 | int idx_peer = 1; |
2784 | int idx_remote_as = 3; | |
2785 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, | |
2786 | argv[idx_remote_as]->arg, AFI_IP, | |
2787 | SAFI_UNICAST); | |
2788 | } | |
2789 | ||
2790 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, | |
2791 | afi_t afi, safi_t safi, int v6only, | |
2792 | const char *peer_group_name, | |
2793 | const char *as_str) | |
2794 | { | |
2795 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2796 | as_t as = 0; | |
2797 | int as_type = AS_UNSPECIFIED; | |
2798 | struct peer *peer; | |
2799 | struct peer_group *group; | |
2800 | int ret = 0; | |
2801 | union sockunion su; | |
2802 | ||
2803 | group = peer_group_lookup(bgp, conf_if); | |
2804 | ||
2805 | if (group) { | |
2806 | vty_out(vty, "%% Name conflict with peer-group \n"); | |
2807 | return CMD_WARNING_CONFIG_FAILED; | |
2808 | } | |
2809 | ||
2810 | if (as_str) { | |
2811 | if (as_str[0] == 'i') { | |
2812 | as_type = AS_INTERNAL; | |
2813 | } else if (as_str[0] == 'e') { | |
2814 | as_type = AS_EXTERNAL; | |
2815 | } else { | |
2816 | /* Get AS number. */ | |
2817 | as = strtoul(as_str, NULL, 10); | |
2818 | as_type = AS_SPECIFIED; | |
2819 | } | |
2820 | } | |
2821 | ||
2822 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
2823 | if (peer) { | |
2824 | if (as_str) | |
2825 | ret = peer_remote_as(bgp, &su, conf_if, &as, as_type, | |
2826 | afi, safi); | |
2827 | } else { | |
2828 | if (bgp_flag_check(bgp, BGP_FLAG_NO_DEFAULT_IPV4) | |
2829 | && afi == AFI_IP && safi == SAFI_UNICAST) | |
2830 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
2831 | as_type, 0, 0, NULL); | |
2832 | else | |
2833 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
2834 | as_type, afi, safi, NULL); | |
2835 | ||
2836 | if (!peer) { | |
2837 | vty_out(vty, "%% BGP failed to create peer\n"); | |
2838 | return CMD_WARNING_CONFIG_FAILED; | |
2839 | } | |
2840 | ||
2841 | if (v6only) | |
527de3dc | 2842 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 2843 | |
2844 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
2845 | * this | |
2846 | * any unnumbered peer in order to not worry about run-time | |
2847 | * transitions | |
2848 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
2849 | * address | |
2850 | * gets deleted later etc.) | |
2851 | */ | |
2852 | if (peer->ifp) | |
2853 | bgp_zebra_initiate_radv(bgp, peer); | |
2854 | } | |
2855 | ||
2856 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
2857 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
2858 | if (v6only) | |
527de3dc | 2859 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 2860 | else |
527de3dc | 2861 | peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 2862 | |
2863 | /* v6only flag changed. Reset bgp seesion */ | |
2864 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2865 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
2866 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2867 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2868 | } else | |
2869 | bgp_session_reset(peer); | |
2870 | } | |
2871 | ||
9fb964de PM |
2872 | if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) { |
2873 | SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE); | |
2874 | SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE); | |
2875 | UNSET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE); | |
2876 | } | |
d62a17ae | 2877 | |
2878 | if (peer_group_name) { | |
2879 | group = peer_group_lookup(bgp, peer_group_name); | |
2880 | if (!group) { | |
2881 | vty_out(vty, "%% Configure the peer-group first\n"); | |
2882 | return CMD_WARNING_CONFIG_FAILED; | |
2883 | } | |
2884 | ||
2885 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
2886 | } | |
2887 | ||
2888 | return bgp_vty_return(vty, ret); | |
a80beece DS |
2889 | } |
2890 | ||
4c48cf63 DW |
2891 | DEFUN (neighbor_interface_config, |
2892 | neighbor_interface_config_cmd, | |
31500417 | 2893 | "neighbor WORD interface [peer-group WORD]", |
4c48cf63 DW |
2894 | NEIGHBOR_STR |
2895 | "Interface name or neighbor tag\n" | |
31500417 DW |
2896 | "Enable BGP on interface\n" |
2897 | "Member of the peer-group\n" | |
16cedbb0 | 2898 | "Peer-group name\n") |
4c48cf63 | 2899 | { |
d62a17ae | 2900 | int idx_word = 1; |
2901 | int idx_peer_group_word = 4; | |
31500417 | 2902 | |
d62a17ae | 2903 | if (argc > idx_peer_group_word) |
2904 | return peer_conf_interface_get( | |
2905 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
2906 | argv[idx_peer_group_word]->arg, NULL); | |
2907 | else | |
2908 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
2909 | SAFI_UNICAST, 0, NULL, NULL); | |
4c48cf63 DW |
2910 | } |
2911 | ||
4c48cf63 DW |
2912 | DEFUN (neighbor_interface_config_v6only, |
2913 | neighbor_interface_config_v6only_cmd, | |
31500417 | 2914 | "neighbor WORD interface v6only [peer-group WORD]", |
4c48cf63 DW |
2915 | NEIGHBOR_STR |
2916 | "Interface name or neighbor tag\n" | |
2917 | "Enable BGP on interface\n" | |
31500417 DW |
2918 | "Enable BGP with v6 link-local only\n" |
2919 | "Member of the peer-group\n" | |
16cedbb0 | 2920 | "Peer-group name\n") |
4c48cf63 | 2921 | { |
d62a17ae | 2922 | int idx_word = 1; |
2923 | int idx_peer_group_word = 5; | |
31500417 | 2924 | |
d62a17ae | 2925 | if (argc > idx_peer_group_word) |
2926 | return peer_conf_interface_get( | |
2927 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
2928 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 2929 | |
d62a17ae | 2930 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, |
2931 | SAFI_UNICAST, 1, NULL, NULL); | |
4c48cf63 DW |
2932 | } |
2933 | ||
a80beece | 2934 | |
b3a39dc5 DD |
2935 | DEFUN (neighbor_interface_config_remote_as, |
2936 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 2937 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2938 | NEIGHBOR_STR |
2939 | "Interface name or neighbor tag\n" | |
2940 | "Enable BGP on interface\n" | |
3a2d747c | 2941 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2942 | AS_STR |
3a2d747c QY |
2943 | "Internal BGP peer\n" |
2944 | "External BGP peer\n") | |
b3a39dc5 | 2945 | { |
d62a17ae | 2946 | int idx_word = 1; |
2947 | int idx_remote_as = 4; | |
2948 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
2949 | SAFI_UNICAST, 0, NULL, | |
2950 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2951 | } |
2952 | ||
2953 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
2954 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 2955 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2956 | NEIGHBOR_STR |
2957 | "Interface name or neighbor tag\n" | |
3a2d747c | 2958 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 2959 | "Enable BGP on interface\n" |
3a2d747c | 2960 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2961 | AS_STR |
3a2d747c QY |
2962 | "Internal BGP peer\n" |
2963 | "External BGP peer\n") | |
b3a39dc5 | 2964 | { |
d62a17ae | 2965 | int idx_word = 1; |
2966 | int idx_remote_as = 5; | |
2967 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
2968 | SAFI_UNICAST, 1, NULL, | |
2969 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2970 | } |
2971 | ||
718e3744 | 2972 | DEFUN (neighbor_peer_group, |
2973 | neighbor_peer_group_cmd, | |
2974 | "neighbor WORD peer-group", | |
2975 | NEIGHBOR_STR | |
a80beece | 2976 | "Interface name or neighbor tag\n" |
718e3744 | 2977 | "Configure peer-group\n") |
2978 | { | |
d62a17ae | 2979 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2980 | int idx_word = 1; | |
2981 | struct peer *peer; | |
2982 | struct peer_group *group; | |
718e3744 | 2983 | |
d62a17ae | 2984 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
2985 | if (peer) { | |
2986 | vty_out(vty, "%% Name conflict with interface: \n"); | |
2987 | return CMD_WARNING_CONFIG_FAILED; | |
2988 | } | |
718e3744 | 2989 | |
d62a17ae | 2990 | group = peer_group_get(bgp, argv[idx_word]->arg); |
2991 | if (!group) { | |
2992 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
2993 | return CMD_WARNING_CONFIG_FAILED; | |
2994 | } | |
718e3744 | 2995 | |
d62a17ae | 2996 | return CMD_SUCCESS; |
718e3744 | 2997 | } |
2998 | ||
2999 | DEFUN (no_neighbor, | |
3000 | no_neighbor_cmd, | |
dab8cd00 | 3001 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 3002 | NO_STR |
3003 | NEIGHBOR_STR | |
3a2d747c QY |
3004 | NEIGHBOR_ADDR_STR2 |
3005 | "Specify a BGP neighbor\n" | |
3006 | AS_STR | |
3007 | "Internal BGP peer\n" | |
3008 | "External BGP peer\n") | |
718e3744 | 3009 | { |
d62a17ae | 3010 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3011 | int idx_peer = 2; | |
3012 | int ret; | |
3013 | union sockunion su; | |
3014 | struct peer_group *group; | |
3015 | struct peer *peer; | |
3016 | struct peer *other; | |
3017 | ||
3018 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
3019 | if (ret < 0) { | |
3020 | /* look up for neighbor by interface name config. */ | |
3021 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3022 | if (peer) { | |
3023 | /* Request zebra to terminate IPv6 RAs on this | |
3024 | * interface. */ | |
3025 | if (peer->ifp) | |
3026 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
3027 | peer_delete(peer); | |
3028 | return CMD_SUCCESS; | |
3029 | } | |
f14e6fdb | 3030 | |
d62a17ae | 3031 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); |
3032 | if (group) | |
3033 | peer_group_delete(group); | |
3034 | else { | |
3035 | vty_out(vty, "%% Create the peer-group first\n"); | |
3036 | return CMD_WARNING_CONFIG_FAILED; | |
3037 | } | |
3038 | } else { | |
3039 | peer = peer_lookup(bgp, &su); | |
3040 | if (peer) { | |
3041 | if (peer_dynamic_neighbor(peer)) { | |
3042 | vty_out(vty, | |
3043 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3044 | return CMD_WARNING_CONFIG_FAILED; | |
3045 | } | |
3046 | ||
3047 | other = peer->doppelganger; | |
3048 | peer_delete(peer); | |
3049 | if (other && other->status != Deleted) | |
3050 | peer_delete(other); | |
3051 | } | |
1ff9a340 | 3052 | } |
718e3744 | 3053 | |
d62a17ae | 3054 | return CMD_SUCCESS; |
718e3744 | 3055 | } |
3056 | ||
a80beece DS |
3057 | DEFUN (no_neighbor_interface_config, |
3058 | no_neighbor_interface_config_cmd, | |
31500417 | 3059 | "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
3060 | NO_STR |
3061 | NEIGHBOR_STR | |
3062 | "Interface name\n" | |
31500417 DW |
3063 | "Configure BGP on interface\n" |
3064 | "Enable BGP with v6 link-local only\n" | |
3065 | "Member of the peer-group\n" | |
16cedbb0 | 3066 | "Peer-group name\n" |
3a2d747c QY |
3067 | "Specify a BGP neighbor\n" |
3068 | AS_STR | |
3069 | "Internal BGP peer\n" | |
3070 | "External BGP peer\n") | |
a80beece | 3071 | { |
d62a17ae | 3072 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3073 | int idx_word = 2; | |
3074 | struct peer *peer; | |
3075 | ||
3076 | /* look up for neighbor by interface name config. */ | |
3077 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3078 | if (peer) { | |
3079 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
3080 | if (peer->ifp) | |
3081 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
3082 | peer_delete(peer); | |
3083 | } else { | |
3084 | vty_out(vty, "%% Create the bgp interface first\n"); | |
3085 | return CMD_WARNING_CONFIG_FAILED; | |
3086 | } | |
3087 | return CMD_SUCCESS; | |
a80beece DS |
3088 | } |
3089 | ||
718e3744 | 3090 | DEFUN (no_neighbor_peer_group, |
3091 | no_neighbor_peer_group_cmd, | |
3092 | "no neighbor WORD peer-group", | |
3093 | NO_STR | |
3094 | NEIGHBOR_STR | |
3095 | "Neighbor tag\n" | |
3096 | "Configure peer-group\n") | |
3097 | { | |
d62a17ae | 3098 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3099 | int idx_word = 2; | |
3100 | struct peer_group *group; | |
718e3744 | 3101 | |
d62a17ae | 3102 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
3103 | if (group) | |
3104 | peer_group_delete(group); | |
3105 | else { | |
3106 | vty_out(vty, "%% Create the peer-group first\n"); | |
3107 | return CMD_WARNING_CONFIG_FAILED; | |
3108 | } | |
3109 | return CMD_SUCCESS; | |
718e3744 | 3110 | } |
3111 | ||
a80beece DS |
3112 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
3113 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 3114 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3115 | NO_STR |
3116 | NEIGHBOR_STR | |
a80beece | 3117 | "Interface name or neighbor tag\n" |
718e3744 | 3118 | "Specify a BGP neighbor\n" |
3a2d747c QY |
3119 | AS_STR |
3120 | "Internal BGP peer\n" | |
3121 | "External BGP peer\n") | |
718e3744 | 3122 | { |
d62a17ae | 3123 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3124 | int idx_word = 2; | |
3125 | struct peer_group *group; | |
3126 | struct peer *peer; | |
3127 | ||
3128 | /* look up for neighbor by interface name config. */ | |
3129 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3130 | if (peer) { | |
3131 | peer_as_change(peer, 0, AS_SPECIFIED); | |
3132 | return CMD_SUCCESS; | |
3133 | } | |
3134 | ||
3135 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3136 | if (group) | |
3137 | peer_group_remote_as_delete(group); | |
3138 | else { | |
3139 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
3140 | return CMD_WARNING_CONFIG_FAILED; | |
3141 | } | |
3142 | return CMD_SUCCESS; | |
718e3744 | 3143 | } |
6b0655a2 | 3144 | |
718e3744 | 3145 | DEFUN (neighbor_local_as, |
3146 | neighbor_local_as_cmd, | |
9ccf14f7 | 3147 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 3148 | NEIGHBOR_STR |
3149 | NEIGHBOR_ADDR_STR2 | |
3150 | "Specify a local-as number\n" | |
3151 | "AS number used as local AS\n") | |
3152 | { | |
d62a17ae | 3153 | int idx_peer = 1; |
3154 | int idx_number = 3; | |
3155 | struct peer *peer; | |
3156 | int ret; | |
3157 | as_t as; | |
718e3744 | 3158 | |
d62a17ae | 3159 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3160 | if (!peer) | |
3161 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3162 | |
d62a17ae | 3163 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3164 | ret = peer_local_as_set(peer, as, 0, 0); | |
3165 | return bgp_vty_return(vty, ret); | |
718e3744 | 3166 | } |
3167 | ||
3168 | DEFUN (neighbor_local_as_no_prepend, | |
3169 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 3170 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 3171 | NEIGHBOR_STR |
3172 | NEIGHBOR_ADDR_STR2 | |
3173 | "Specify a local-as number\n" | |
3174 | "AS number used as local AS\n" | |
3175 | "Do not prepend local-as to updates from ebgp peers\n") | |
3176 | { | |
d62a17ae | 3177 | int idx_peer = 1; |
3178 | int idx_number = 3; | |
3179 | struct peer *peer; | |
3180 | int ret; | |
3181 | as_t as; | |
718e3744 | 3182 | |
d62a17ae | 3183 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3184 | if (!peer) | |
3185 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3186 | |
d62a17ae | 3187 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3188 | ret = peer_local_as_set(peer, as, 1, 0); | |
3189 | return bgp_vty_return(vty, ret); | |
718e3744 | 3190 | } |
3191 | ||
9d3f9705 AC |
3192 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
3193 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 3194 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
3195 | NEIGHBOR_STR |
3196 | NEIGHBOR_ADDR_STR2 | |
3197 | "Specify a local-as number\n" | |
3198 | "AS number used as local AS\n" | |
3199 | "Do not prepend local-as to updates from ebgp peers\n" | |
3200 | "Do not prepend local-as to updates from ibgp peers\n") | |
3201 | { | |
d62a17ae | 3202 | int idx_peer = 1; |
3203 | int idx_number = 3; | |
3204 | struct peer *peer; | |
3205 | int ret; | |
3206 | as_t as; | |
9d3f9705 | 3207 | |
d62a17ae | 3208 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3209 | if (!peer) | |
3210 | return CMD_WARNING_CONFIG_FAILED; | |
9d3f9705 | 3211 | |
d62a17ae | 3212 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3213 | ret = peer_local_as_set(peer, as, 1, 1); | |
3214 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
3215 | } |
3216 | ||
718e3744 | 3217 | DEFUN (no_neighbor_local_as, |
3218 | no_neighbor_local_as_cmd, | |
a636c635 | 3219 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 3220 | NO_STR |
3221 | NEIGHBOR_STR | |
3222 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
3223 | "Specify a local-as number\n" |
3224 | "AS number used as local AS\n" | |
3225 | "Do not prepend local-as to updates from ebgp peers\n" | |
3226 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 3227 | { |
d62a17ae | 3228 | int idx_peer = 2; |
3229 | struct peer *peer; | |
3230 | int ret; | |
718e3744 | 3231 | |
d62a17ae | 3232 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3233 | if (!peer) | |
3234 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3235 | |
d62a17ae | 3236 | ret = peer_local_as_unset(peer); |
3237 | return bgp_vty_return(vty, ret); | |
718e3744 | 3238 | } |
3239 | ||
718e3744 | 3240 | |
3f9c7369 DS |
3241 | DEFUN (neighbor_solo, |
3242 | neighbor_solo_cmd, | |
9ccf14f7 | 3243 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3244 | NEIGHBOR_STR |
3245 | NEIGHBOR_ADDR_STR2 | |
3246 | "Solo peer - part of its own update group\n") | |
3247 | { | |
d62a17ae | 3248 | int idx_peer = 1; |
3249 | struct peer *peer; | |
3250 | int ret; | |
3f9c7369 | 3251 | |
d62a17ae | 3252 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3253 | if (!peer) | |
3254 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3255 | |
d62a17ae | 3256 | ret = update_group_adjust_soloness(peer, 1); |
3257 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3258 | } |
3259 | ||
3260 | DEFUN (no_neighbor_solo, | |
3261 | no_neighbor_solo_cmd, | |
9ccf14f7 | 3262 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3263 | NO_STR |
3264 | NEIGHBOR_STR | |
3265 | NEIGHBOR_ADDR_STR2 | |
3266 | "Solo peer - part of its own update group\n") | |
3267 | { | |
d62a17ae | 3268 | int idx_peer = 2; |
3269 | struct peer *peer; | |
3270 | int ret; | |
3f9c7369 | 3271 | |
d62a17ae | 3272 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3273 | if (!peer) | |
3274 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3275 | |
d62a17ae | 3276 | ret = update_group_adjust_soloness(peer, 0); |
3277 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3278 | } |
3279 | ||
0df7c91f PJ |
3280 | DEFUN (neighbor_password, |
3281 | neighbor_password_cmd, | |
9ccf14f7 | 3282 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
3283 | NEIGHBOR_STR |
3284 | NEIGHBOR_ADDR_STR2 | |
3285 | "Set a password\n" | |
3286 | "The password\n") | |
3287 | { | |
d62a17ae | 3288 | int idx_peer = 1; |
3289 | int idx_line = 3; | |
3290 | struct peer *peer; | |
3291 | int ret; | |
0df7c91f | 3292 | |
d62a17ae | 3293 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3294 | if (!peer) | |
3295 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3296 | |
d62a17ae | 3297 | ret = peer_password_set(peer, argv[idx_line]->arg); |
3298 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
3299 | } |
3300 | ||
3301 | DEFUN (no_neighbor_password, | |
3302 | no_neighbor_password_cmd, | |
a636c635 | 3303 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
3304 | NO_STR |
3305 | NEIGHBOR_STR | |
3306 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
3307 | "Set a password\n" |
3308 | "The password\n") | |
0df7c91f | 3309 | { |
d62a17ae | 3310 | int idx_peer = 2; |
3311 | struct peer *peer; | |
3312 | int ret; | |
0df7c91f | 3313 | |
d62a17ae | 3314 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3315 | if (!peer) | |
3316 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3317 | |
d62a17ae | 3318 | ret = peer_password_unset(peer); |
3319 | return bgp_vty_return(vty, ret); | |
0df7c91f | 3320 | } |
6b0655a2 | 3321 | |
718e3744 | 3322 | DEFUN (neighbor_activate, |
3323 | neighbor_activate_cmd, | |
9ccf14f7 | 3324 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3325 | NEIGHBOR_STR |
3326 | NEIGHBOR_ADDR_STR2 | |
3327 | "Enable the Address Family for this Neighbor\n") | |
3328 | { | |
d62a17ae | 3329 | int idx_peer = 1; |
3330 | int ret; | |
3331 | struct peer *peer; | |
718e3744 | 3332 | |
d62a17ae | 3333 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3334 | if (!peer) | |
3335 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3336 | |
d62a17ae | 3337 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3338 | return bgp_vty_return(vty, ret); | |
718e3744 | 3339 | } |
3340 | ||
d62a17ae | 3341 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
3342 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3343 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3344 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3345 | |
718e3744 | 3346 | DEFUN (no_neighbor_activate, |
3347 | no_neighbor_activate_cmd, | |
9ccf14f7 | 3348 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3349 | NO_STR |
3350 | NEIGHBOR_STR | |
3351 | NEIGHBOR_ADDR_STR2 | |
3352 | "Enable the Address Family for this Neighbor\n") | |
3353 | { | |
d62a17ae | 3354 | int idx_peer = 2; |
3355 | int ret; | |
3356 | struct peer *peer; | |
718e3744 | 3357 | |
d62a17ae | 3358 | /* Lookup peer. */ |
3359 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3360 | if (!peer) | |
3361 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3362 | |
d62a17ae | 3363 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3364 | return bgp_vty_return(vty, ret); | |
718e3744 | 3365 | } |
6b0655a2 | 3366 | |
d62a17ae | 3367 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
3368 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3369 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3370 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3371 | |
718e3744 | 3372 | DEFUN (neighbor_set_peer_group, |
3373 | neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3374 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3375 | NEIGHBOR_STR |
a80beece | 3376 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3377 | "Member of the peer-group\n" |
16cedbb0 | 3378 | "Peer-group name\n") |
718e3744 | 3379 | { |
d62a17ae | 3380 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3381 | int idx_peer = 1; | |
3382 | int idx_word = 3; | |
3383 | int ret; | |
3384 | as_t as; | |
3385 | union sockunion su; | |
3386 | struct peer *peer; | |
3387 | struct peer_group *group; | |
3388 | ||
d62a17ae | 3389 | ret = str2sockunion(argv[idx_peer]->arg, &su); |
3390 | if (ret < 0) { | |
3391 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3392 | if (!peer) { | |
3393 | vty_out(vty, "%% Malformed address or name: %s\n", | |
3394 | argv[idx_peer]->arg); | |
3395 | return CMD_WARNING_CONFIG_FAILED; | |
3396 | } | |
3397 | } else { | |
3398 | if (peer_address_self_check(bgp, &su)) { | |
3399 | vty_out(vty, | |
3400 | "%% Can not configure the local system as neighbor\n"); | |
3401 | return CMD_WARNING_CONFIG_FAILED; | |
3402 | } | |
3403 | ||
3404 | /* Disallow for dynamic neighbor. */ | |
3405 | peer = peer_lookup(bgp, &su); | |
3406 | if (peer && peer_dynamic_neighbor(peer)) { | |
3407 | vty_out(vty, | |
3408 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3409 | return CMD_WARNING_CONFIG_FAILED; | |
3410 | } | |
3411 | } | |
3412 | ||
3413 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3414 | if (!group) { | |
3415 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3416 | return CMD_WARNING_CONFIG_FAILED; | |
3417 | } | |
3418 | ||
3419 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
3420 | ||
3421 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { | |
3422 | vty_out(vty, | |
3423 | "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", | |
3424 | as); | |
3425 | return CMD_WARNING_CONFIG_FAILED; | |
3426 | } | |
3427 | ||
3428 | return bgp_vty_return(vty, ret); | |
3429 | } | |
3430 | ||
3431 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
3432 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", | |
3433 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3434 | "Member of the peer-group\n" | |
3435 | "Peer-group name\n") | |
596c17ba | 3436 | |
718e3744 | 3437 | DEFUN (no_neighbor_set_peer_group, |
3438 | no_neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3439 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3440 | NO_STR |
3441 | NEIGHBOR_STR | |
a80beece | 3442 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3443 | "Member of the peer-group\n" |
16cedbb0 | 3444 | "Peer-group name\n") |
718e3744 | 3445 | { |
d62a17ae | 3446 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3447 | int idx_peer = 2; | |
3448 | int idx_word = 4; | |
3449 | int ret; | |
3450 | struct peer *peer; | |
3451 | struct peer_group *group; | |
3452 | ||
3453 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); | |
3454 | if (!peer) | |
3455 | return CMD_WARNING_CONFIG_FAILED; | |
3456 | ||
3457 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3458 | if (!group) { | |
3459 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3460 | return CMD_WARNING_CONFIG_FAILED; | |
3461 | } | |
718e3744 | 3462 | |
827ed707 | 3463 | ret = peer_delete(peer); |
718e3744 | 3464 | |
d62a17ae | 3465 | return bgp_vty_return(vty, ret); |
718e3744 | 3466 | } |
6b0655a2 | 3467 | |
d62a17ae | 3468 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
3469 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", | |
3470 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3471 | "Member of the peer-group\n" | |
3472 | "Peer-group name\n") | |
596c17ba | 3473 | |
d62a17ae | 3474 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 3475 | uint32_t flag, int set) |
718e3744 | 3476 | { |
d62a17ae | 3477 | int ret; |
3478 | struct peer *peer; | |
718e3744 | 3479 | |
d62a17ae | 3480 | peer = peer_and_group_lookup_vty(vty, ip_str); |
3481 | if (!peer) | |
3482 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3483 | |
7ebe625c QY |
3484 | /* |
3485 | * If 'neighbor <interface>', then this is for directly connected peers, | |
3486 | * we should not accept disable-connected-check. | |
3487 | */ | |
3488 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
3489 | vty_out(vty, | |
3490 | "%s is directly connected peer, cannot accept disable-" | |
3491 | "connected-check\n", | |
3492 | ip_str); | |
3493 | return CMD_WARNING_CONFIG_FAILED; | |
3494 | } | |
3495 | ||
d62a17ae | 3496 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
3497 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 3498 | |
d62a17ae | 3499 | if (set) |
3500 | ret = peer_flag_set(peer, flag); | |
3501 | else | |
3502 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 3503 | |
d62a17ae | 3504 | return bgp_vty_return(vty, ret); |
718e3744 | 3505 | } |
3506 | ||
47cbc09b | 3507 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint32_t flag) |
718e3744 | 3508 | { |
d62a17ae | 3509 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 3510 | } |
3511 | ||
d62a17ae | 3512 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 3513 | uint32_t flag) |
718e3744 | 3514 | { |
d62a17ae | 3515 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 3516 | } |
3517 | ||
3518 | /* neighbor passive. */ | |
3519 | DEFUN (neighbor_passive, | |
3520 | neighbor_passive_cmd, | |
9ccf14f7 | 3521 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3522 | NEIGHBOR_STR |
3523 | NEIGHBOR_ADDR_STR2 | |
3524 | "Don't send open messages to this neighbor\n") | |
3525 | { | |
d62a17ae | 3526 | int idx_peer = 1; |
3527 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3528 | } |
3529 | ||
3530 | DEFUN (no_neighbor_passive, | |
3531 | no_neighbor_passive_cmd, | |
9ccf14f7 | 3532 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3533 | NO_STR |
3534 | NEIGHBOR_STR | |
3535 | NEIGHBOR_ADDR_STR2 | |
3536 | "Don't send open messages to this neighbor\n") | |
3537 | { | |
d62a17ae | 3538 | int idx_peer = 2; |
3539 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3540 | } |
6b0655a2 | 3541 | |
718e3744 | 3542 | /* neighbor shutdown. */ |
73d70fa6 DL |
3543 | DEFUN (neighbor_shutdown_msg, |
3544 | neighbor_shutdown_msg_cmd, | |
3545 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
718e3744 | 3546 | NEIGHBOR_STR |
3547 | NEIGHBOR_ADDR_STR2 | |
73d70fa6 DL |
3548 | "Administratively shut down this neighbor\n" |
3549 | "Add a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3550 | "Shutdown message\n") | |
718e3744 | 3551 | { |
d62a17ae | 3552 | int idx_peer = 1; |
73d70fa6 | 3553 | |
d62a17ae | 3554 | if (argc >= 5) { |
3555 | struct peer *peer = | |
3556 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3557 | char *message; | |
73d70fa6 | 3558 | |
d62a17ae | 3559 | if (!peer) |
3560 | return CMD_WARNING_CONFIG_FAILED; | |
3561 | message = argv_concat(argv, argc, 4); | |
3562 | peer_tx_shutdown_message_set(peer, message); | |
3563 | XFREE(MTYPE_TMP, message); | |
3564 | } | |
73d70fa6 | 3565 | |
d62a17ae | 3566 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 3567 | } |
3568 | ||
d62a17ae | 3569 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
3570 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3571 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3572 | "Administratively shut down this neighbor\n") | |
73d70fa6 DL |
3573 | |
3574 | DEFUN (no_neighbor_shutdown_msg, | |
3575 | no_neighbor_shutdown_msg_cmd, | |
3576 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
3577 | NO_STR | |
3578 | NEIGHBOR_STR | |
3579 | NEIGHBOR_ADDR_STR2 | |
3580 | "Administratively shut down this neighbor\n" | |
3581 | "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3582 | "Shutdown message\n") | |
718e3744 | 3583 | { |
d62a17ae | 3584 | int idx_peer = 2; |
73d70fa6 | 3585 | |
d62a17ae | 3586 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
3587 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 3588 | } |
6b0655a2 | 3589 | |
d62a17ae | 3590 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
3591 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3592 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3593 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 3594 | |
718e3744 | 3595 | /* neighbor capability dynamic. */ |
3596 | DEFUN (neighbor_capability_dynamic, | |
3597 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3598 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3599 | NEIGHBOR_STR |
3600 | NEIGHBOR_ADDR_STR2 | |
3601 | "Advertise capability to the peer\n" | |
3602 | "Advertise dynamic capability to this neighbor\n") | |
3603 | { | |
d62a17ae | 3604 | int idx_peer = 1; |
3605 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3606 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3607 | } |
3608 | ||
3609 | DEFUN (no_neighbor_capability_dynamic, | |
3610 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3611 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3612 | NO_STR |
3613 | NEIGHBOR_STR | |
3614 | NEIGHBOR_ADDR_STR2 | |
3615 | "Advertise capability to the peer\n" | |
3616 | "Advertise dynamic capability to this neighbor\n") | |
3617 | { | |
d62a17ae | 3618 | int idx_peer = 2; |
3619 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3620 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3621 | } |
6b0655a2 | 3622 | |
718e3744 | 3623 | /* neighbor dont-capability-negotiate */ |
3624 | DEFUN (neighbor_dont_capability_negotiate, | |
3625 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3626 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3627 | NEIGHBOR_STR |
3628 | NEIGHBOR_ADDR_STR2 | |
3629 | "Do not perform capability negotiation\n") | |
3630 | { | |
d62a17ae | 3631 | int idx_peer = 1; |
3632 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3633 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3634 | } |
3635 | ||
3636 | DEFUN (no_neighbor_dont_capability_negotiate, | |
3637 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3638 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3639 | NO_STR |
3640 | NEIGHBOR_STR | |
3641 | NEIGHBOR_ADDR_STR2 | |
3642 | "Do not perform capability negotiation\n") | |
3643 | { | |
d62a17ae | 3644 | int idx_peer = 2; |
3645 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3646 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3647 | } |
6b0655a2 | 3648 | |
8a92a8a0 DS |
3649 | /* neighbor capability extended next hop encoding */ |
3650 | DEFUN (neighbor_capability_enhe, | |
3651 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3652 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3653 | NEIGHBOR_STR |
3654 | NEIGHBOR_ADDR_STR2 | |
3655 | "Advertise capability to the peer\n" | |
3656 | "Advertise extended next-hop capability to the peer\n") | |
3657 | { | |
d62a17ae | 3658 | int idx_peer = 1; |
3659 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3660 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3661 | } |
3662 | ||
3663 | DEFUN (no_neighbor_capability_enhe, | |
3664 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3665 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3666 | NO_STR |
3667 | NEIGHBOR_STR | |
3668 | NEIGHBOR_ADDR_STR2 | |
3669 | "Advertise capability to the peer\n" | |
3670 | "Advertise extended next-hop capability to the peer\n") | |
3671 | { | |
d62a17ae | 3672 | int idx_peer = 2; |
3673 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3674 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3675 | } |
3676 | ||
d62a17ae | 3677 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3678 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 3679 | int set) |
718e3744 | 3680 | { |
d62a17ae | 3681 | int ret; |
3682 | struct peer *peer; | |
718e3744 | 3683 | |
d62a17ae | 3684 | peer = peer_and_group_lookup_vty(vty, peer_str); |
3685 | if (!peer) | |
3686 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3687 | |
d62a17ae | 3688 | if (set) |
3689 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
3690 | else | |
3691 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 3692 | |
d62a17ae | 3693 | return bgp_vty_return(vty, ret); |
718e3744 | 3694 | } |
3695 | ||
d62a17ae | 3696 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3697 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 3698 | { |
d62a17ae | 3699 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 3700 | } |
3701 | ||
d62a17ae | 3702 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3703 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 3704 | { |
d62a17ae | 3705 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 3706 | } |
6b0655a2 | 3707 | |
718e3744 | 3708 | /* neighbor capability orf prefix-list. */ |
3709 | DEFUN (neighbor_capability_orf_prefix, | |
3710 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3711 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3712 | NEIGHBOR_STR |
3713 | NEIGHBOR_ADDR_STR2 | |
3714 | "Advertise capability to the peer\n" | |
3715 | "Advertise ORF capability to the peer\n" | |
3716 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3717 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3718 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3719 | "Capability to SEND the ORF to this neighbor\n") | |
3720 | { | |
d62a17ae | 3721 | int idx_peer = 1; |
3722 | int idx_send_recv = 5; | |
d7c0a89a | 3723 | uint16_t flag = 0; |
d62a17ae | 3724 | |
3725 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3726 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3727 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3728 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3729 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3730 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3731 | else { | |
3732 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3733 | return CMD_WARNING_CONFIG_FAILED; | |
3734 | } | |
3735 | ||
3736 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3737 | bgp_node_safi(vty), flag); | |
3738 | } | |
3739 | ||
3740 | ALIAS_HIDDEN( | |
3741 | neighbor_capability_orf_prefix, | |
3742 | neighbor_capability_orf_prefix_hidden_cmd, | |
3743 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3744 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3745 | "Advertise capability to the peer\n" | |
3746 | "Advertise ORF capability to the peer\n" | |
3747 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3748 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3749 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3750 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 3751 | |
718e3744 | 3752 | DEFUN (no_neighbor_capability_orf_prefix, |
3753 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3754 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3755 | NO_STR |
3756 | NEIGHBOR_STR | |
3757 | NEIGHBOR_ADDR_STR2 | |
3758 | "Advertise capability to the peer\n" | |
3759 | "Advertise ORF capability to the peer\n" | |
3760 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3761 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3762 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3763 | "Capability to SEND the ORF to this neighbor\n") | |
3764 | { | |
d62a17ae | 3765 | int idx_peer = 2; |
3766 | int idx_send_recv = 6; | |
d7c0a89a | 3767 | uint16_t flag = 0; |
d62a17ae | 3768 | |
3769 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3770 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3771 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3772 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3773 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3774 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3775 | else { | |
3776 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3777 | return CMD_WARNING_CONFIG_FAILED; | |
3778 | } | |
3779 | ||
3780 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3781 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3782 | flag); | |
3783 | } | |
3784 | ||
3785 | ALIAS_HIDDEN( | |
3786 | no_neighbor_capability_orf_prefix, | |
3787 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
3788 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3789 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3790 | "Advertise capability to the peer\n" | |
3791 | "Advertise ORF capability to the peer\n" | |
3792 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3793 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3794 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3795 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 3796 | |
718e3744 | 3797 | /* neighbor next-hop-self. */ |
3798 | DEFUN (neighbor_nexthop_self, | |
3799 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3800 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3801 | NEIGHBOR_STR |
3802 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3803 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3804 | { |
d62a17ae | 3805 | int idx_peer = 1; |
3806 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3807 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 3808 | } |
9e7a53c1 | 3809 | |
d62a17ae | 3810 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
3811 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3812 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3813 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 3814 | |
a538debe DS |
3815 | /* neighbor next-hop-self. */ |
3816 | DEFUN (neighbor_nexthop_self_force, | |
3817 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 3818 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3819 | NEIGHBOR_STR |
3820 | NEIGHBOR_ADDR_STR2 | |
3821 | "Disable the next hop calculation for this neighbor\n" | |
3822 | "Set the next hop to self for reflected routes\n") | |
3823 | { | |
d62a17ae | 3824 | int idx_peer = 1; |
3825 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3826 | bgp_node_safi(vty), | |
3827 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 3828 | } |
3829 | ||
d62a17ae | 3830 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
3831 | neighbor_nexthop_self_force_hidden_cmd, | |
3832 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3833 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3834 | "Disable the next hop calculation for this neighbor\n" | |
3835 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 3836 | |
718e3744 | 3837 | DEFUN (no_neighbor_nexthop_self, |
3838 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3839 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3840 | NO_STR |
3841 | NEIGHBOR_STR | |
3842 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3843 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3844 | { |
d62a17ae | 3845 | int idx_peer = 2; |
3846 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3847 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3848 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 3849 | } |
6b0655a2 | 3850 | |
d62a17ae | 3851 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
3852 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3853 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3854 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 3855 | |
88b8ed8d | 3856 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 3857 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 3858 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3859 | NO_STR |
3860 | NEIGHBOR_STR | |
3861 | NEIGHBOR_ADDR_STR2 | |
3862 | "Disable the next hop calculation for this neighbor\n" | |
3863 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 3864 | { |
d62a17ae | 3865 | int idx_peer = 2; |
3866 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3867 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3868 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 3869 | } |
a538debe | 3870 | |
d62a17ae | 3871 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
3872 | no_neighbor_nexthop_self_force_hidden_cmd, | |
3873 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3874 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3875 | "Disable the next hop calculation for this neighbor\n" | |
3876 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 3877 | |
c7122e14 DS |
3878 | /* neighbor as-override */ |
3879 | DEFUN (neighbor_as_override, | |
3880 | neighbor_as_override_cmd, | |
9ccf14f7 | 3881 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3882 | NEIGHBOR_STR |
3883 | NEIGHBOR_ADDR_STR2 | |
3884 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3885 | { | |
d62a17ae | 3886 | int idx_peer = 1; |
3887 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3888 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
3889 | } |
3890 | ||
d62a17ae | 3891 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
3892 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
3893 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3894 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 3895 | |
c7122e14 DS |
3896 | DEFUN (no_neighbor_as_override, |
3897 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 3898 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3899 | NO_STR |
3900 | NEIGHBOR_STR | |
3901 | NEIGHBOR_ADDR_STR2 | |
3902 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3903 | { | |
d62a17ae | 3904 | int idx_peer = 2; |
3905 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3906 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3907 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
3908 | } |
3909 | ||
d62a17ae | 3910 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
3911 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
3912 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3913 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 3914 | |
718e3744 | 3915 | /* neighbor remove-private-AS. */ |
3916 | DEFUN (neighbor_remove_private_as, | |
3917 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3918 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3919 | NEIGHBOR_STR |
3920 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3921 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3922 | { |
d62a17ae | 3923 | int idx_peer = 1; |
3924 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3925 | bgp_node_safi(vty), | |
3926 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 3927 | } |
3928 | ||
d62a17ae | 3929 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
3930 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
3931 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3932 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 3933 | |
5000f21c DS |
3934 | DEFUN (neighbor_remove_private_as_all, |
3935 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 3936 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
3937 | NEIGHBOR_STR |
3938 | NEIGHBOR_ADDR_STR2 | |
3939 | "Remove private ASNs in outbound updates\n" | |
efd7904e | 3940 | "Apply to all AS numbers\n") |
5000f21c | 3941 | { |
d62a17ae | 3942 | int idx_peer = 1; |
3943 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3944 | bgp_node_safi(vty), | |
3945 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
3946 | } |
3947 | ||
d62a17ae | 3948 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
3949 | neighbor_remove_private_as_all_hidden_cmd, | |
3950 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
3951 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3952 | "Remove private ASNs in outbound updates\n" | |
3953 | "Apply to all AS numbers") | |
596c17ba | 3954 | |
5000f21c DS |
3955 | DEFUN (neighbor_remove_private_as_replace_as, |
3956 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 3957 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
3958 | NEIGHBOR_STR |
3959 | NEIGHBOR_ADDR_STR2 | |
3960 | "Remove private ASNs in outbound updates\n" | |
3961 | "Replace private ASNs with our ASN in outbound updates\n") | |
3962 | { | |
d62a17ae | 3963 | int idx_peer = 1; |
3964 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3965 | bgp_node_safi(vty), | |
3966 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
3967 | } |
3968 | ||
d62a17ae | 3969 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
3970 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
3971 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
3972 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3973 | "Remove private ASNs in outbound updates\n" | |
3974 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 3975 | |
5000f21c DS |
3976 | DEFUN (neighbor_remove_private_as_all_replace_as, |
3977 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 3978 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
3979 | NEIGHBOR_STR |
3980 | NEIGHBOR_ADDR_STR2 | |
3981 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3982 | "Apply to all AS numbers\n" |
5000f21c DS |
3983 | "Replace private ASNs with our ASN in outbound updates\n") |
3984 | { | |
d62a17ae | 3985 | int idx_peer = 1; |
3986 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3987 | bgp_node_safi(vty), | |
3988 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
3989 | } |
3990 | ||
d62a17ae | 3991 | ALIAS_HIDDEN( |
3992 | neighbor_remove_private_as_all_replace_as, | |
3993 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
3994 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
3995 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3996 | "Remove private ASNs in outbound updates\n" | |
3997 | "Apply to all AS numbers\n" | |
3998 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 3999 | |
718e3744 | 4000 | DEFUN (no_neighbor_remove_private_as, |
4001 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4002 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4003 | NO_STR |
4004 | NEIGHBOR_STR | |
4005 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4006 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4007 | { |
d62a17ae | 4008 | int idx_peer = 2; |
4009 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4010 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4011 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4012 | } |
6b0655a2 | 4013 | |
d62a17ae | 4014 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
4015 | no_neighbor_remove_private_as_hidden_cmd, | |
4016 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4017 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4018 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4019 | |
88b8ed8d | 4020 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 4021 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 4022 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4023 | NO_STR |
4024 | NEIGHBOR_STR | |
4025 | NEIGHBOR_ADDR_STR2 | |
4026 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4027 | "Apply to all AS numbers\n") |
88b8ed8d | 4028 | { |
d62a17ae | 4029 | int idx_peer = 2; |
4030 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4031 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4032 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 4033 | } |
5000f21c | 4034 | |
d62a17ae | 4035 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
4036 | no_neighbor_remove_private_as_all_hidden_cmd, | |
4037 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4038 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4039 | "Remove private ASNs in outbound updates\n" | |
4040 | "Apply to all AS numbers\n") | |
596c17ba | 4041 | |
88b8ed8d | 4042 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 4043 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 4044 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4045 | NO_STR |
4046 | NEIGHBOR_STR | |
4047 | NEIGHBOR_ADDR_STR2 | |
4048 | "Remove private ASNs in outbound updates\n" | |
4049 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 4050 | { |
d62a17ae | 4051 | int idx_peer = 2; |
4052 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4053 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4054 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 4055 | } |
5000f21c | 4056 | |
d62a17ae | 4057 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
4058 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
4059 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4060 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4061 | "Remove private ASNs in outbound updates\n" | |
4062 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4063 | |
88b8ed8d | 4064 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 4065 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 4066 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4067 | NO_STR |
4068 | NEIGHBOR_STR | |
4069 | NEIGHBOR_ADDR_STR2 | |
4070 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4071 | "Apply to all AS numbers\n" |
5000f21c | 4072 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 4073 | { |
d62a17ae | 4074 | int idx_peer = 2; |
4075 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4076 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4077 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 4078 | } |
5000f21c | 4079 | |
d62a17ae | 4080 | ALIAS_HIDDEN( |
4081 | no_neighbor_remove_private_as_all_replace_as, | |
4082 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4083 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4084 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4085 | "Remove private ASNs in outbound updates\n" | |
4086 | "Apply to all AS numbers\n" | |
4087 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4088 | |
5000f21c | 4089 | |
718e3744 | 4090 | /* neighbor send-community. */ |
4091 | DEFUN (neighbor_send_community, | |
4092 | neighbor_send_community_cmd, | |
9ccf14f7 | 4093 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4094 | NEIGHBOR_STR |
4095 | NEIGHBOR_ADDR_STR2 | |
4096 | "Send Community attribute to this neighbor\n") | |
4097 | { | |
d62a17ae | 4098 | int idx_peer = 1; |
27c05d4d | 4099 | |
d62a17ae | 4100 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4101 | bgp_node_safi(vty), | |
4102 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4103 | } |
4104 | ||
d62a17ae | 4105 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
4106 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4107 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4108 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4109 | |
718e3744 | 4110 | DEFUN (no_neighbor_send_community, |
4111 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 4112 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4113 | NO_STR |
4114 | NEIGHBOR_STR | |
4115 | NEIGHBOR_ADDR_STR2 | |
4116 | "Send Community attribute to this neighbor\n") | |
4117 | { | |
d62a17ae | 4118 | int idx_peer = 2; |
27c05d4d | 4119 | |
d62a17ae | 4120 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
4121 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4122 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4123 | } |
6b0655a2 | 4124 | |
d62a17ae | 4125 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
4126 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4127 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4128 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4129 | |
718e3744 | 4130 | /* neighbor send-community extended. */ |
4131 | DEFUN (neighbor_send_community_type, | |
4132 | neighbor_send_community_type_cmd, | |
57d187bc | 4133 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4134 | NEIGHBOR_STR |
4135 | NEIGHBOR_ADDR_STR2 | |
4136 | "Send Community attribute to this neighbor\n" | |
4137 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4138 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4139 | "Send Extended Community attributes\n" |
57d187bc JS |
4140 | "Send Standard Community attributes\n" |
4141 | "Send Large Community attributes\n") | |
718e3744 | 4142 | { |
27c05d4d | 4143 | int idx_peer = 1; |
d7c0a89a | 4144 | uint32_t flag = 0; |
27c05d4d | 4145 | const char *type = argv[argc - 1]->text; |
d62a17ae | 4146 | |
27c05d4d | 4147 | if (strmatch(type, "standard")) { |
d62a17ae | 4148 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
27c05d4d | 4149 | } else if (strmatch(type, "extended")) { |
d62a17ae | 4150 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); |
27c05d4d | 4151 | } else if (strmatch(type, "large")) { |
d62a17ae | 4152 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); |
27c05d4d | 4153 | } else if (strmatch(type, "both")) { |
d62a17ae | 4154 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4155 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
27c05d4d | 4156 | } else { /* if (strmatch(type, "all")) */ |
d62a17ae | 4157 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4158 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4159 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4160 | } | |
4161 | ||
27c05d4d | 4162 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
d62a17ae | 4163 | bgp_node_safi(vty), flag); |
4164 | } | |
4165 | ||
4166 | ALIAS_HIDDEN( | |
4167 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
4168 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4169 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4170 | "Send Community attribute to this neighbor\n" | |
4171 | "Send Standard and Extended Community attributes\n" | |
4172 | "Send Standard, Large and Extended Community attributes\n" | |
4173 | "Send Extended Community attributes\n" | |
4174 | "Send Standard Community attributes\n" | |
4175 | "Send Large Community attributes\n") | |
596c17ba | 4176 | |
718e3744 | 4177 | DEFUN (no_neighbor_send_community_type, |
4178 | no_neighbor_send_community_type_cmd, | |
57d187bc | 4179 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4180 | NO_STR |
4181 | NEIGHBOR_STR | |
4182 | NEIGHBOR_ADDR_STR2 | |
4183 | "Send Community attribute to this neighbor\n" | |
4184 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4185 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4186 | "Send Extended Community attributes\n" |
57d187bc JS |
4187 | "Send Standard Community attributes\n" |
4188 | "Send Large Community attributes\n") | |
718e3744 | 4189 | { |
d62a17ae | 4190 | int idx_peer = 2; |
27c05d4d | 4191 | uint32_t flag = 0; |
d62a17ae | 4192 | const char *type = argv[argc - 1]->text; |
4193 | ||
27c05d4d PM |
4194 | if (strmatch(type, "standard")) { |
4195 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4196 | } else if (strmatch(type, "extended")) { | |
4197 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4198 | } else if (strmatch(type, "large")) { | |
4199 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4200 | } else if (strmatch(type, "both")) { | |
4201 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4202 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4203 | } else { /* if (strmatch(type, "all")) */ | |
4204 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4205 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4206 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4207 | } | |
4208 | ||
4209 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4210 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4211 | flag); | |
d62a17ae | 4212 | } |
4213 | ||
4214 | ALIAS_HIDDEN( | |
4215 | no_neighbor_send_community_type, | |
4216 | no_neighbor_send_community_type_hidden_cmd, | |
4217 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4218 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4219 | "Send Community attribute to this neighbor\n" | |
4220 | "Send Standard and Extended Community attributes\n" | |
4221 | "Send Standard, Large and Extended Community attributes\n" | |
4222 | "Send Extended Community attributes\n" | |
4223 | "Send Standard Community attributes\n" | |
4224 | "Send Large Community attributes\n") | |
596c17ba | 4225 | |
718e3744 | 4226 | /* neighbor soft-reconfig. */ |
4227 | DEFUN (neighbor_soft_reconfiguration, | |
4228 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4229 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4230 | NEIGHBOR_STR |
4231 | NEIGHBOR_ADDR_STR2 | |
4232 | "Per neighbor soft reconfiguration\n" | |
4233 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4234 | { | |
d62a17ae | 4235 | int idx_peer = 1; |
4236 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4237 | bgp_node_safi(vty), | |
4238 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4239 | } |
4240 | ||
d62a17ae | 4241 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
4242 | neighbor_soft_reconfiguration_hidden_cmd, | |
4243 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4244 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4245 | "Per neighbor soft reconfiguration\n" | |
4246 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4247 | |
718e3744 | 4248 | DEFUN (no_neighbor_soft_reconfiguration, |
4249 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4250 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4251 | NO_STR |
4252 | NEIGHBOR_STR | |
4253 | NEIGHBOR_ADDR_STR2 | |
4254 | "Per neighbor soft reconfiguration\n" | |
4255 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4256 | { | |
d62a17ae | 4257 | int idx_peer = 2; |
4258 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4259 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4260 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4261 | } |
6b0655a2 | 4262 | |
d62a17ae | 4263 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
4264 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
4265 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4266 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4267 | "Per neighbor soft reconfiguration\n" | |
4268 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4269 | |
718e3744 | 4270 | DEFUN (neighbor_route_reflector_client, |
4271 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4272 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4273 | NEIGHBOR_STR |
4274 | NEIGHBOR_ADDR_STR2 | |
4275 | "Configure a neighbor as Route Reflector client\n") | |
4276 | { | |
d62a17ae | 4277 | int idx_peer = 1; |
4278 | struct peer *peer; | |
718e3744 | 4279 | |
4280 | ||
d62a17ae | 4281 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4282 | if (!peer) | |
4283 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4284 | |
d62a17ae | 4285 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4286 | bgp_node_safi(vty), | |
4287 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4288 | } |
4289 | ||
d62a17ae | 4290 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
4291 | neighbor_route_reflector_client_hidden_cmd, | |
4292 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4293 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4294 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4295 | |
718e3744 | 4296 | DEFUN (no_neighbor_route_reflector_client, |
4297 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4298 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4299 | NO_STR |
4300 | NEIGHBOR_STR | |
4301 | NEIGHBOR_ADDR_STR2 | |
4302 | "Configure a neighbor as Route Reflector client\n") | |
4303 | { | |
d62a17ae | 4304 | int idx_peer = 2; |
4305 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4306 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4307 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4308 | } |
6b0655a2 | 4309 | |
d62a17ae | 4310 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
4311 | no_neighbor_route_reflector_client_hidden_cmd, | |
4312 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4313 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4314 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4315 | |
718e3744 | 4316 | /* neighbor route-server-client. */ |
4317 | DEFUN (neighbor_route_server_client, | |
4318 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 4319 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4320 | NEIGHBOR_STR |
4321 | NEIGHBOR_ADDR_STR2 | |
4322 | "Configure a neighbor as Route Server client\n") | |
4323 | { | |
d62a17ae | 4324 | int idx_peer = 1; |
4325 | struct peer *peer; | |
2a3d5731 | 4326 | |
d62a17ae | 4327 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4328 | if (!peer) | |
4329 | return CMD_WARNING_CONFIG_FAILED; | |
4330 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4331 | bgp_node_safi(vty), | |
4332 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 4333 | } |
4334 | ||
d62a17ae | 4335 | ALIAS_HIDDEN(neighbor_route_server_client, |
4336 | neighbor_route_server_client_hidden_cmd, | |
4337 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4338 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4339 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4340 | |
718e3744 | 4341 | DEFUN (no_neighbor_route_server_client, |
4342 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 4343 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4344 | NO_STR |
4345 | NEIGHBOR_STR | |
4346 | NEIGHBOR_ADDR_STR2 | |
4347 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 4348 | { |
d62a17ae | 4349 | int idx_peer = 2; |
4350 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4351 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4352 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 4353 | } |
6b0655a2 | 4354 | |
d62a17ae | 4355 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
4356 | no_neighbor_route_server_client_hidden_cmd, | |
4357 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4358 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4359 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4360 | |
fee0f4c6 | 4361 | DEFUN (neighbor_nexthop_local_unchanged, |
4362 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4363 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4364 | NEIGHBOR_STR |
4365 | NEIGHBOR_ADDR_STR2 | |
4366 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
4367 | "Leave link-local nexthop unchanged for this peer\n") | |
4368 | { | |
d62a17ae | 4369 | int idx_peer = 1; |
4370 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4371 | bgp_node_safi(vty), | |
4372 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 4373 | } |
6b0655a2 | 4374 | |
fee0f4c6 | 4375 | DEFUN (no_neighbor_nexthop_local_unchanged, |
4376 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4377 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4378 | NO_STR |
4379 | NEIGHBOR_STR | |
4380 | NEIGHBOR_ADDR_STR2 | |
4381 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
4382 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 4383 | { |
d62a17ae | 4384 | int idx_peer = 2; |
4385 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4386 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4387 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 4388 | } |
6b0655a2 | 4389 | |
718e3744 | 4390 | DEFUN (neighbor_attr_unchanged, |
4391 | neighbor_attr_unchanged_cmd, | |
a8206004 | 4392 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
718e3744 | 4393 | NEIGHBOR_STR |
4394 | NEIGHBOR_ADDR_STR2 | |
4395 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4396 | "As-path attribute\n" | |
4397 | "Nexthop attribute\n" | |
a8206004 | 4398 | "Med attribute\n") |
718e3744 | 4399 | { |
d62a17ae | 4400 | int idx = 0; |
8eeb0335 DW |
4401 | char *peer_str = argv[1]->arg; |
4402 | struct peer *peer; | |
d7c0a89a | 4403 | uint16_t flags = 0; |
8eeb0335 DW |
4404 | afi_t afi = bgp_node_afi(vty); |
4405 | safi_t safi = bgp_node_safi(vty); | |
4406 | ||
4407 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
4408 | if (!peer) | |
4409 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4410 | |
4411 | if (argv_find(argv, argc, "as-path", &idx)) | |
4412 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4413 | idx = 0; | |
4414 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4415 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4416 | idx = 0; | |
4417 | if (argv_find(argv, argc, "med", &idx)) | |
4418 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4419 | ||
8eeb0335 DW |
4420 | /* no flags means all of them! */ |
4421 | if (!flags) { | |
d62a17ae | 4422 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); |
4423 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4424 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 | 4425 | } else { |
a4d82a8a PZ |
4426 | if (!CHECK_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED) |
4427 | && peer_af_flag_check(peer, afi, safi, | |
4428 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
8eeb0335 DW |
4429 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4430 | PEER_FLAG_AS_PATH_UNCHANGED); | |
4431 | } | |
4432 | ||
a4d82a8a PZ |
4433 | if (!CHECK_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED) |
4434 | && peer_af_flag_check(peer, afi, safi, | |
4435 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
8eeb0335 DW |
4436 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4437 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
4438 | } | |
4439 | ||
a4d82a8a PZ |
4440 | if (!CHECK_FLAG(flags, PEER_FLAG_MED_UNCHANGED) |
4441 | && peer_af_flag_check(peer, afi, safi, | |
4442 | PEER_FLAG_MED_UNCHANGED)) { | |
8eeb0335 DW |
4443 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4444 | PEER_FLAG_MED_UNCHANGED); | |
4445 | } | |
d62a17ae | 4446 | } |
4447 | ||
8eeb0335 | 4448 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, flags); |
d62a17ae | 4449 | } |
4450 | ||
4451 | ALIAS_HIDDEN( | |
4452 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
4453 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4454 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4455 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4456 | "As-path attribute\n" | |
4457 | "Nexthop attribute\n" | |
4458 | "Med attribute\n") | |
596c17ba | 4459 | |
718e3744 | 4460 | DEFUN (no_neighbor_attr_unchanged, |
4461 | no_neighbor_attr_unchanged_cmd, | |
a8206004 | 4462 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
e52702f2 | 4463 | NO_STR |
718e3744 | 4464 | NEIGHBOR_STR |
4465 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
4466 | "BGP attribute is propagated unchanged to this neighbor\n" |
4467 | "As-path attribute\n" | |
40e718b5 | 4468 | "Nexthop attribute\n" |
a8206004 | 4469 | "Med attribute\n") |
718e3744 | 4470 | { |
d62a17ae | 4471 | int idx = 0; |
4472 | char *peer = argv[2]->arg; | |
d7c0a89a | 4473 | uint16_t flags = 0; |
d62a17ae | 4474 | |
4475 | if (argv_find(argv, argc, "as-path", &idx)) | |
4476 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4477 | idx = 0; | |
4478 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4479 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4480 | idx = 0; | |
4481 | if (argv_find(argv, argc, "med", &idx)) | |
4482 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4483 | ||
4484 | if (!flags) // no flags means all of them! | |
4485 | { | |
4486 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4487 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4488 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4489 | } | |
4490 | ||
4491 | return peer_af_flag_unset_vty(vty, peer, bgp_node_afi(vty), | |
4492 | bgp_node_safi(vty), flags); | |
4493 | } | |
4494 | ||
4495 | ALIAS_HIDDEN( | |
4496 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
4497 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4498 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4499 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4500 | "As-path attribute\n" | |
4501 | "Nexthop attribute\n" | |
4502 | "Med attribute\n") | |
718e3744 | 4503 | |
718e3744 | 4504 | /* EBGP multihop configuration. */ |
d62a17ae | 4505 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, |
4506 | const char *ttl_str) | |
718e3744 | 4507 | { |
d62a17ae | 4508 | struct peer *peer; |
4509 | unsigned int ttl; | |
718e3744 | 4510 | |
d62a17ae | 4511 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4512 | if (!peer) | |
4513 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4514 | |
d62a17ae | 4515 | if (peer->conf_if) |
4516 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
63fa10b5 | 4517 | |
d62a17ae | 4518 | if (!ttl_str) |
4519 | ttl = MAXTTL; | |
4520 | else | |
4521 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 4522 | |
d62a17ae | 4523 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 4524 | } |
4525 | ||
d62a17ae | 4526 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 4527 | { |
d62a17ae | 4528 | struct peer *peer; |
718e3744 | 4529 | |
d62a17ae | 4530 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4531 | if (!peer) | |
4532 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4533 | |
d62a17ae | 4534 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 4535 | } |
4536 | ||
4537 | /* neighbor ebgp-multihop. */ | |
4538 | DEFUN (neighbor_ebgp_multihop, | |
4539 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 4540 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 4541 | NEIGHBOR_STR |
4542 | NEIGHBOR_ADDR_STR2 | |
4543 | "Allow EBGP neighbors not on directly connected networks\n") | |
4544 | { | |
d62a17ae | 4545 | int idx_peer = 1; |
4546 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4547 | } |
4548 | ||
4549 | DEFUN (neighbor_ebgp_multihop_ttl, | |
4550 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 4551 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 4552 | NEIGHBOR_STR |
4553 | NEIGHBOR_ADDR_STR2 | |
4554 | "Allow EBGP neighbors not on directly connected networks\n" | |
4555 | "maximum hop count\n") | |
4556 | { | |
d62a17ae | 4557 | int idx_peer = 1; |
4558 | int idx_number = 3; | |
4559 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
4560 | argv[idx_number]->arg); | |
718e3744 | 4561 | } |
4562 | ||
4563 | DEFUN (no_neighbor_ebgp_multihop, | |
4564 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 4565 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 4566 | NO_STR |
4567 | NEIGHBOR_STR | |
4568 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4569 | "Allow EBGP neighbors not on directly connected networks\n" |
4570 | "maximum hop count\n") | |
718e3744 | 4571 | { |
d62a17ae | 4572 | int idx_peer = 2; |
4573 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 4574 | } |
4575 | ||
6b0655a2 | 4576 | |
6ffd2079 | 4577 | /* disable-connected-check */ |
4578 | DEFUN (neighbor_disable_connected_check, | |
4579 | neighbor_disable_connected_check_cmd, | |
7ebe625c | 4580 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4581 | NEIGHBOR_STR |
7ebe625c | 4582 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
4583 | "one-hop away EBGP peer using loopback address\n" |
4584 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4585 | { |
d62a17ae | 4586 | int idx_peer = 1; |
4587 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4588 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4589 | } |
4590 | ||
4591 | DEFUN (no_neighbor_disable_connected_check, | |
4592 | no_neighbor_disable_connected_check_cmd, | |
7ebe625c | 4593 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4594 | NO_STR |
4595 | NEIGHBOR_STR | |
7ebe625c | 4596 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
4597 | "one-hop away EBGP peer using loopback address\n" |
4598 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4599 | { |
d62a17ae | 4600 | int idx_peer = 2; |
4601 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4602 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4603 | } |
4604 | ||
47cbc09b PM |
4605 | |
4606 | /* enforce-first-as */ | |
4607 | DEFUN (neighbor_enforce_first_as, | |
4608 | neighbor_enforce_first_as_cmd, | |
4609 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
4610 | NEIGHBOR_STR | |
4611 | NEIGHBOR_ADDR_STR2 | |
4612 | "Enforce the first AS for EBGP routes\n") | |
4613 | { | |
4614 | int idx_peer = 1; | |
4615 | ||
4616 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4617 | PEER_FLAG_ENFORCE_FIRST_AS); | |
4618 | } | |
4619 | ||
4620 | DEFUN (no_neighbor_enforce_first_as, | |
4621 | no_neighbor_enforce_first_as_cmd, | |
4622 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
4623 | NO_STR | |
4624 | NEIGHBOR_STR | |
4625 | NEIGHBOR_ADDR_STR2 | |
4626 | "Enforce the first AS for EBGP routes\n") | |
4627 | { | |
4628 | int idx_peer = 2; | |
4629 | ||
4630 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4631 | PEER_FLAG_ENFORCE_FIRST_AS); | |
4632 | } | |
4633 | ||
4634 | ||
718e3744 | 4635 | DEFUN (neighbor_description, |
4636 | neighbor_description_cmd, | |
e961923c | 4637 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 4638 | NEIGHBOR_STR |
4639 | NEIGHBOR_ADDR_STR2 | |
4640 | "Neighbor specific description\n" | |
4641 | "Up to 80 characters describing this neighbor\n") | |
4642 | { | |
d62a17ae | 4643 | int idx_peer = 1; |
4644 | int idx_line = 3; | |
4645 | struct peer *peer; | |
4646 | char *str; | |
718e3744 | 4647 | |
d62a17ae | 4648 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4649 | if (!peer) | |
4650 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4651 | |
d62a17ae | 4652 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 4653 | |
d62a17ae | 4654 | peer_description_set(peer, str); |
718e3744 | 4655 | |
d62a17ae | 4656 | XFREE(MTYPE_TMP, str); |
718e3744 | 4657 | |
d62a17ae | 4658 | return CMD_SUCCESS; |
718e3744 | 4659 | } |
4660 | ||
4661 | DEFUN (no_neighbor_description, | |
4662 | no_neighbor_description_cmd, | |
a14810f4 | 4663 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", |
718e3744 | 4664 | NO_STR |
4665 | NEIGHBOR_STR | |
4666 | NEIGHBOR_ADDR_STR2 | |
a14810f4 | 4667 | "Neighbor specific description\n") |
718e3744 | 4668 | { |
d62a17ae | 4669 | int idx_peer = 2; |
4670 | struct peer *peer; | |
718e3744 | 4671 | |
d62a17ae | 4672 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4673 | if (!peer) | |
4674 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4675 | |
d62a17ae | 4676 | peer_description_unset(peer); |
718e3744 | 4677 | |
d62a17ae | 4678 | return CMD_SUCCESS; |
718e3744 | 4679 | } |
4680 | ||
a14810f4 PM |
4681 | ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd, |
4682 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
4683 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4684 | "Neighbor specific description\n" | |
4685 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 4686 | |
718e3744 | 4687 | /* Neighbor update-source. */ |
d62a17ae | 4688 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, |
4689 | const char *source_str) | |
4690 | { | |
4691 | struct peer *peer; | |
4692 | struct prefix p; | |
a14810f4 | 4693 | union sockunion su; |
d62a17ae | 4694 | |
4695 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
4696 | if (!peer) | |
4697 | return CMD_WARNING_CONFIG_FAILED; | |
4698 | ||
4699 | if (peer->conf_if) | |
4700 | return CMD_WARNING; | |
4701 | ||
4702 | if (source_str) { | |
a14810f4 | 4703 | if (str2sockunion(source_str, &su) == 0) |
d62a17ae | 4704 | peer_update_source_addr_set(peer, &su); |
4705 | else { | |
4706 | if (str2prefix(source_str, &p)) { | |
4707 | vty_out(vty, | |
4708 | "%% Invalid update-source, remove prefix length \n"); | |
4709 | return CMD_WARNING_CONFIG_FAILED; | |
4710 | } else | |
4711 | peer_update_source_if_set(peer, source_str); | |
4712 | } | |
4713 | } else | |
4714 | peer_update_source_unset(peer); | |
4715 | ||
4716 | return CMD_SUCCESS; | |
4717 | } | |
4718 | ||
4719 | #define BGP_UPDATE_SOURCE_HELP_STR \ | |
4720 | "IPv4 address\n" \ | |
4721 | "IPv6 address\n" \ | |
4722 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 4723 | |
718e3744 | 4724 | DEFUN (neighbor_update_source, |
4725 | neighbor_update_source_cmd, | |
9ccf14f7 | 4726 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 4727 | NEIGHBOR_STR |
4728 | NEIGHBOR_ADDR_STR2 | |
4729 | "Source of routing updates\n" | |
369688c0 | 4730 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 4731 | { |
d62a17ae | 4732 | int idx_peer = 1; |
4733 | int idx_peer_2 = 3; | |
4734 | return peer_update_source_vty(vty, argv[idx_peer]->arg, | |
4735 | argv[idx_peer_2]->arg); | |
718e3744 | 4736 | } |
4737 | ||
4738 | DEFUN (no_neighbor_update_source, | |
4739 | no_neighbor_update_source_cmd, | |
c7178fe7 | 4740 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 4741 | NO_STR |
4742 | NEIGHBOR_STR | |
4743 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
4744 | "Source of routing updates\n" |
4745 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 4746 | { |
d62a17ae | 4747 | int idx_peer = 2; |
4748 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4749 | } |
6b0655a2 | 4750 | |
d62a17ae | 4751 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
4752 | afi_t afi, safi_t safi, | |
4753 | const char *rmap, int set) | |
718e3744 | 4754 | { |
d62a17ae | 4755 | int ret; |
4756 | struct peer *peer; | |
718e3744 | 4757 | |
d62a17ae | 4758 | peer = peer_and_group_lookup_vty(vty, peer_str); |
4759 | if (!peer) | |
4760 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4761 | |
d62a17ae | 4762 | if (set) |
4763 | ret = peer_default_originate_set(peer, afi, safi, rmap); | |
4764 | else | |
4765 | ret = peer_default_originate_unset(peer, afi, safi); | |
718e3744 | 4766 | |
d62a17ae | 4767 | return bgp_vty_return(vty, ret); |
718e3744 | 4768 | } |
4769 | ||
4770 | /* neighbor default-originate. */ | |
4771 | DEFUN (neighbor_default_originate, | |
4772 | neighbor_default_originate_cmd, | |
9ccf14f7 | 4773 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 4774 | NEIGHBOR_STR |
4775 | NEIGHBOR_ADDR_STR2 | |
4776 | "Originate default route to this neighbor\n") | |
4777 | { | |
d62a17ae | 4778 | int idx_peer = 1; |
4779 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
4780 | bgp_node_afi(vty), | |
4781 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 4782 | } |
4783 | ||
d62a17ae | 4784 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
4785 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
4786 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4787 | "Originate default route to this neighbor\n") | |
596c17ba | 4788 | |
718e3744 | 4789 | DEFUN (neighbor_default_originate_rmap, |
4790 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 4791 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 4792 | NEIGHBOR_STR |
4793 | NEIGHBOR_ADDR_STR2 | |
4794 | "Originate default route to this neighbor\n" | |
4795 | "Route-map to specify criteria to originate default\n" | |
4796 | "route-map name\n") | |
4797 | { | |
d62a17ae | 4798 | int idx_peer = 1; |
4799 | int idx_word = 4; | |
4800 | return peer_default_originate_set_vty( | |
4801 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
4802 | argv[idx_word]->arg, 1); | |
718e3744 | 4803 | } |
4804 | ||
d62a17ae | 4805 | ALIAS_HIDDEN( |
4806 | neighbor_default_originate_rmap, | |
4807 | neighbor_default_originate_rmap_hidden_cmd, | |
4808 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
4809 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4810 | "Originate default route to this neighbor\n" | |
4811 | "Route-map to specify criteria to originate default\n" | |
4812 | "route-map name\n") | |
596c17ba | 4813 | |
718e3744 | 4814 | DEFUN (no_neighbor_default_originate, |
4815 | no_neighbor_default_originate_cmd, | |
a636c635 | 4816 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 4817 | NO_STR |
4818 | NEIGHBOR_STR | |
4819 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4820 | "Originate default route to this neighbor\n" |
4821 | "Route-map to specify criteria to originate default\n" | |
4822 | "route-map name\n") | |
718e3744 | 4823 | { |
d62a17ae | 4824 | int idx_peer = 2; |
4825 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
4826 | bgp_node_afi(vty), | |
4827 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 4828 | } |
4829 | ||
d62a17ae | 4830 | ALIAS_HIDDEN( |
4831 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
4832 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
4833 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4834 | "Originate default route to this neighbor\n" | |
4835 | "Route-map to specify criteria to originate default\n" | |
4836 | "route-map name\n") | |
596c17ba | 4837 | |
6b0655a2 | 4838 | |
718e3744 | 4839 | /* Set neighbor's BGP port. */ |
d62a17ae | 4840 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, |
4841 | const char *port_str) | |
4842 | { | |
4843 | struct peer *peer; | |
d7c0a89a | 4844 | uint16_t port; |
d62a17ae | 4845 | struct servent *sp; |
4846 | ||
4847 | peer = peer_lookup_vty(vty, ip_str); | |
4848 | if (!peer) | |
4849 | return CMD_WARNING_CONFIG_FAILED; | |
4850 | ||
4851 | if (!port_str) { | |
4852 | sp = getservbyname("bgp", "tcp"); | |
4853 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
4854 | } else { | |
4855 | port = strtoul(port_str, NULL, 10); | |
4856 | } | |
718e3744 | 4857 | |
d62a17ae | 4858 | peer_port_set(peer, port); |
718e3744 | 4859 | |
d62a17ae | 4860 | return CMD_SUCCESS; |
718e3744 | 4861 | } |
4862 | ||
f418446b | 4863 | /* Set specified peer's BGP port. */ |
718e3744 | 4864 | DEFUN (neighbor_port, |
4865 | neighbor_port_cmd, | |
9ccf14f7 | 4866 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 4867 | NEIGHBOR_STR |
4868 | NEIGHBOR_ADDR_STR | |
4869 | "Neighbor's BGP port\n" | |
4870 | "TCP port number\n") | |
4871 | { | |
d62a17ae | 4872 | int idx_ip = 1; |
4873 | int idx_number = 3; | |
4874 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
4875 | argv[idx_number]->arg); | |
718e3744 | 4876 | } |
4877 | ||
4878 | DEFUN (no_neighbor_port, | |
4879 | no_neighbor_port_cmd, | |
9ccf14f7 | 4880 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 4881 | NO_STR |
4882 | NEIGHBOR_STR | |
4883 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
4884 | "Neighbor's BGP port\n" |
4885 | "TCP port number\n") | |
718e3744 | 4886 | { |
d62a17ae | 4887 | int idx_ip = 2; |
4888 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 4889 | } |
4890 | ||
6b0655a2 | 4891 | |
718e3744 | 4892 | /* neighbor weight. */ |
d62a17ae | 4893 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
4894 | safi_t safi, const char *weight_str) | |
718e3744 | 4895 | { |
d62a17ae | 4896 | int ret; |
4897 | struct peer *peer; | |
4898 | unsigned long weight; | |
718e3744 | 4899 | |
d62a17ae | 4900 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4901 | if (!peer) | |
4902 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4903 | |
d62a17ae | 4904 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 4905 | |
d62a17ae | 4906 | ret = peer_weight_set(peer, afi, safi, weight); |
4907 | return bgp_vty_return(vty, ret); | |
718e3744 | 4908 | } |
4909 | ||
d62a17ae | 4910 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
4911 | safi_t safi) | |
718e3744 | 4912 | { |
d62a17ae | 4913 | int ret; |
4914 | struct peer *peer; | |
718e3744 | 4915 | |
d62a17ae | 4916 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4917 | if (!peer) | |
4918 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4919 | |
d62a17ae | 4920 | ret = peer_weight_unset(peer, afi, safi); |
4921 | return bgp_vty_return(vty, ret); | |
718e3744 | 4922 | } |
4923 | ||
4924 | DEFUN (neighbor_weight, | |
4925 | neighbor_weight_cmd, | |
9ccf14f7 | 4926 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 4927 | NEIGHBOR_STR |
4928 | NEIGHBOR_ADDR_STR2 | |
4929 | "Set default weight for routes from this neighbor\n" | |
4930 | "default weight\n") | |
4931 | { | |
d62a17ae | 4932 | int idx_peer = 1; |
4933 | int idx_number = 3; | |
4934 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4935 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 4936 | } |
4937 | ||
d62a17ae | 4938 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
4939 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
4940 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4941 | "Set default weight for routes from this neighbor\n" | |
4942 | "default weight\n") | |
596c17ba | 4943 | |
718e3744 | 4944 | DEFUN (no_neighbor_weight, |
4945 | no_neighbor_weight_cmd, | |
9ccf14f7 | 4946 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 4947 | NO_STR |
4948 | NEIGHBOR_STR | |
4949 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
4950 | "Set default weight for routes from this neighbor\n" |
4951 | "default weight\n") | |
718e3744 | 4952 | { |
d62a17ae | 4953 | int idx_peer = 2; |
4954 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, | |
4955 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 4956 | } |
4957 | ||
d62a17ae | 4958 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
4959 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
4960 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4961 | "Set default weight for routes from this neighbor\n" | |
4962 | "default weight\n") | |
596c17ba | 4963 | |
6b0655a2 | 4964 | |
718e3744 | 4965 | /* Override capability negotiation. */ |
4966 | DEFUN (neighbor_override_capability, | |
4967 | neighbor_override_capability_cmd, | |
9ccf14f7 | 4968 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 4969 | NEIGHBOR_STR |
4970 | NEIGHBOR_ADDR_STR2 | |
4971 | "Override capability negotiation result\n") | |
4972 | { | |
d62a17ae | 4973 | int idx_peer = 1; |
4974 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4975 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 4976 | } |
4977 | ||
4978 | DEFUN (no_neighbor_override_capability, | |
4979 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 4980 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 4981 | NO_STR |
4982 | NEIGHBOR_STR | |
4983 | NEIGHBOR_ADDR_STR2 | |
4984 | "Override capability negotiation result\n") | |
4985 | { | |
d62a17ae | 4986 | int idx_peer = 2; |
4987 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4988 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 4989 | } |
6b0655a2 | 4990 | |
718e3744 | 4991 | DEFUN (neighbor_strict_capability, |
4992 | neighbor_strict_capability_cmd, | |
9fb964de | 4993 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 4994 | NEIGHBOR_STR |
9fb964de | 4995 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4996 | "Strict capability negotiation match\n") |
4997 | { | |
9fb964de PM |
4998 | int idx_peer = 1; |
4999 | ||
5000 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5001 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5002 | } |
5003 | ||
5004 | DEFUN (no_neighbor_strict_capability, | |
5005 | no_neighbor_strict_capability_cmd, | |
9fb964de | 5006 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5007 | NO_STR |
5008 | NEIGHBOR_STR | |
9fb964de | 5009 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5010 | "Strict capability negotiation match\n") |
5011 | { | |
9fb964de PM |
5012 | int idx_peer = 2; |
5013 | ||
5014 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5015 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5016 | } |
6b0655a2 | 5017 | |
d62a17ae | 5018 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
5019 | const char *keep_str, const char *hold_str) | |
718e3744 | 5020 | { |
d62a17ae | 5021 | int ret; |
5022 | struct peer *peer; | |
d7c0a89a QY |
5023 | uint32_t keepalive; |
5024 | uint32_t holdtime; | |
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 | keepalive = strtoul(keep_str, NULL, 10); |
5031 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 5032 | |
d62a17ae | 5033 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 5034 | |
d62a17ae | 5035 | return bgp_vty_return(vty, ret); |
718e3744 | 5036 | } |
6b0655a2 | 5037 | |
d62a17ae | 5038 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5039 | { |
d62a17ae | 5040 | int ret; |
5041 | struct peer *peer; | |
718e3744 | 5042 | |
d62a17ae | 5043 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5044 | if (!peer) | |
5045 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5046 | |
d62a17ae | 5047 | ret = peer_timers_unset(peer); |
718e3744 | 5048 | |
d62a17ae | 5049 | return bgp_vty_return(vty, ret); |
718e3744 | 5050 | } |
5051 | ||
5052 | DEFUN (neighbor_timers, | |
5053 | neighbor_timers_cmd, | |
9ccf14f7 | 5054 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 5055 | NEIGHBOR_STR |
5056 | NEIGHBOR_ADDR_STR2 | |
5057 | "BGP per neighbor timers\n" | |
5058 | "Keepalive interval\n" | |
5059 | "Holdtime\n") | |
5060 | { | |
d62a17ae | 5061 | int idx_peer = 1; |
5062 | int idx_number = 3; | |
5063 | int idx_number_2 = 4; | |
5064 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
5065 | argv[idx_number]->arg, | |
5066 | argv[idx_number_2]->arg); | |
718e3744 | 5067 | } |
5068 | ||
5069 | DEFUN (no_neighbor_timers, | |
5070 | no_neighbor_timers_cmd, | |
9ccf14f7 | 5071 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 5072 | NO_STR |
5073 | NEIGHBOR_STR | |
5074 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5075 | "BGP per neighbor timers\n" |
5076 | "Keepalive interval\n" | |
5077 | "Holdtime\n") | |
718e3744 | 5078 | { |
d62a17ae | 5079 | int idx_peer = 2; |
5080 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5081 | } |
6b0655a2 | 5082 | |
813d4307 | 5083 | |
d62a17ae | 5084 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, |
5085 | const char *time_str) | |
718e3744 | 5086 | { |
d62a17ae | 5087 | int ret; |
5088 | struct peer *peer; | |
d7c0a89a | 5089 | uint32_t connect; |
718e3744 | 5090 | |
d62a17ae | 5091 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5092 | if (!peer) | |
5093 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5094 | |
d62a17ae | 5095 | connect = strtoul(time_str, NULL, 10); |
718e3744 | 5096 | |
d62a17ae | 5097 | ret = peer_timers_connect_set(peer, connect); |
718e3744 | 5098 | |
d62a17ae | 5099 | return bgp_vty_return(vty, ret); |
718e3744 | 5100 | } |
5101 | ||
d62a17ae | 5102 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5103 | { |
d62a17ae | 5104 | int ret; |
5105 | struct peer *peer; | |
718e3744 | 5106 | |
d62a17ae | 5107 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5108 | if (!peer) | |
5109 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5110 | |
d62a17ae | 5111 | ret = peer_timers_connect_unset(peer); |
718e3744 | 5112 | |
d62a17ae | 5113 | return bgp_vty_return(vty, ret); |
718e3744 | 5114 | } |
5115 | ||
5116 | DEFUN (neighbor_timers_connect, | |
5117 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 5118 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 5119 | NEIGHBOR_STR |
966f821c | 5120 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5121 | "BGP per neighbor timers\n" |
5122 | "BGP connect timer\n" | |
5123 | "Connect timer\n") | |
5124 | { | |
d62a17ae | 5125 | int idx_peer = 1; |
5126 | int idx_number = 4; | |
5127 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
5128 | argv[idx_number]->arg); | |
718e3744 | 5129 | } |
5130 | ||
5131 | DEFUN (no_neighbor_timers_connect, | |
5132 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 5133 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 5134 | NO_STR |
5135 | NEIGHBOR_STR | |
966f821c | 5136 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5137 | "BGP per neighbor timers\n" |
8334fd5a DW |
5138 | "BGP connect timer\n" |
5139 | "Connect timer\n") | |
718e3744 | 5140 | { |
d62a17ae | 5141 | int idx_peer = 2; |
5142 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5143 | } |
5144 | ||
6b0655a2 | 5145 | |
d62a17ae | 5146 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
5147 | const char *time_str, int set) | |
718e3744 | 5148 | { |
d62a17ae | 5149 | int ret; |
5150 | struct peer *peer; | |
d7c0a89a | 5151 | uint32_t routeadv = 0; |
718e3744 | 5152 | |
d62a17ae | 5153 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5154 | if (!peer) | |
5155 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5156 | |
d62a17ae | 5157 | if (time_str) |
5158 | routeadv = strtoul(time_str, NULL, 10); | |
718e3744 | 5159 | |
d62a17ae | 5160 | if (set) |
5161 | ret = peer_advertise_interval_set(peer, routeadv); | |
5162 | else | |
5163 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 5164 | |
d62a17ae | 5165 | return bgp_vty_return(vty, ret); |
718e3744 | 5166 | } |
5167 | ||
5168 | DEFUN (neighbor_advertise_interval, | |
5169 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5170 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 5171 | NEIGHBOR_STR |
966f821c | 5172 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5173 | "Minimum interval between sending BGP routing updates\n" |
5174 | "time in seconds\n") | |
5175 | { | |
d62a17ae | 5176 | int idx_peer = 1; |
5177 | int idx_number = 3; | |
5178 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
5179 | argv[idx_number]->arg, 1); | |
718e3744 | 5180 | } |
5181 | ||
5182 | DEFUN (no_neighbor_advertise_interval, | |
5183 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5184 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 5185 | NO_STR |
5186 | NEIGHBOR_STR | |
966f821c | 5187 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
5188 | "Minimum interval between sending BGP routing updates\n" |
5189 | "time in seconds\n") | |
718e3744 | 5190 | { |
d62a17ae | 5191 | int idx_peer = 2; |
5192 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 5193 | } |
5194 | ||
6b0655a2 | 5195 | |
518f0eb1 DS |
5196 | /* Time to wait before processing route-map updates */ |
5197 | DEFUN (bgp_set_route_map_delay_timer, | |
5198 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 5199 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
5200 | SET_STR |
5201 | "BGP route-map delay timer\n" | |
5202 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 5203 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 5204 | { |
d62a17ae | 5205 | int idx_number = 3; |
d7c0a89a | 5206 | uint32_t rmap_delay_timer; |
d62a17ae | 5207 | |
5208 | if (argv[idx_number]->arg) { | |
5209 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
5210 | bm->rmap_update_timer = rmap_delay_timer; | |
5211 | ||
5212 | /* if the dynamic update handling is being disabled, and a timer | |
5213 | * is | |
5214 | * running, stop the timer and act as if the timer has already | |
5215 | * fired. | |
5216 | */ | |
5217 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
5218 | BGP_TIMER_OFF(bm->t_rmap_update); | |
5219 | thread_execute(bm->master, bgp_route_map_update_timer, | |
5220 | NULL, 0); | |
5221 | } | |
5222 | return CMD_SUCCESS; | |
5223 | } else { | |
5224 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
5225 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 5226 | } |
518f0eb1 DS |
5227 | } |
5228 | ||
5229 | DEFUN (no_bgp_set_route_map_delay_timer, | |
5230 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 5231 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 5232 | NO_STR |
3a2d747c | 5233 | BGP_STR |
518f0eb1 | 5234 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
5235 | "Reset to default time to wait for processing route-map changes\n" |
5236 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 5237 | { |
518f0eb1 | 5238 | |
d62a17ae | 5239 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 5240 | |
d62a17ae | 5241 | return CMD_SUCCESS; |
518f0eb1 DS |
5242 | } |
5243 | ||
f414725f | 5244 | |
718e3744 | 5245 | /* neighbor interface */ |
d62a17ae | 5246 | static int peer_interface_vty(struct vty *vty, const char *ip_str, |
5247 | const char *str) | |
718e3744 | 5248 | { |
d62a17ae | 5249 | struct peer *peer; |
718e3744 | 5250 | |
d62a17ae | 5251 | peer = peer_lookup_vty(vty, ip_str); |
5252 | if (!peer || peer->conf_if) { | |
5253 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
5254 | return CMD_WARNING_CONFIG_FAILED; | |
5255 | } | |
718e3744 | 5256 | |
d62a17ae | 5257 | if (str) |
5258 | peer_interface_set(peer, str); | |
5259 | else | |
5260 | peer_interface_unset(peer); | |
718e3744 | 5261 | |
d62a17ae | 5262 | return CMD_SUCCESS; |
718e3744 | 5263 | } |
5264 | ||
5265 | DEFUN (neighbor_interface, | |
5266 | neighbor_interface_cmd, | |
9ccf14f7 | 5267 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 5268 | NEIGHBOR_STR |
5269 | NEIGHBOR_ADDR_STR | |
5270 | "Interface\n" | |
5271 | "Interface name\n") | |
5272 | { | |
d62a17ae | 5273 | int idx_ip = 1; |
5274 | int idx_word = 3; | |
5275 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); | |
718e3744 | 5276 | } |
5277 | ||
5278 | DEFUN (no_neighbor_interface, | |
5279 | no_neighbor_interface_cmd, | |
9ccf14f7 | 5280 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 5281 | NO_STR |
5282 | NEIGHBOR_STR | |
16cedbb0 | 5283 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5284 | "Interface\n" |
5285 | "Interface name\n") | |
5286 | { | |
d62a17ae | 5287 | int idx_peer = 2; |
5288 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5289 | } |
6b0655a2 | 5290 | |
718e3744 | 5291 | DEFUN (neighbor_distribute_list, |
5292 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 5293 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5294 | NEIGHBOR_STR |
5295 | NEIGHBOR_ADDR_STR2 | |
5296 | "Filter updates to/from this neighbor\n" | |
5297 | "IP access-list number\n" | |
5298 | "IP access-list number (expanded range)\n" | |
5299 | "IP Access-list name\n" | |
5300 | "Filter incoming updates\n" | |
5301 | "Filter outgoing updates\n") | |
5302 | { | |
d62a17ae | 5303 | int idx_peer = 1; |
5304 | int idx_acl = 3; | |
5305 | int direct, ret; | |
5306 | struct peer *peer; | |
a8206004 | 5307 | |
d62a17ae | 5308 | const char *pstr = argv[idx_peer]->arg; |
5309 | const char *acl = argv[idx_acl]->arg; | |
5310 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5311 | |
d62a17ae | 5312 | peer = peer_and_group_lookup_vty(vty, pstr); |
5313 | if (!peer) | |
5314 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5315 | |
d62a17ae | 5316 | /* Check filter direction. */ |
5317 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5318 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5319 | direct, acl); | |
a8206004 | 5320 | |
d62a17ae | 5321 | return bgp_vty_return(vty, ret); |
718e3744 | 5322 | } |
5323 | ||
d62a17ae | 5324 | ALIAS_HIDDEN( |
5325 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
5326 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5327 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5328 | "Filter updates to/from this neighbor\n" | |
5329 | "IP access-list number\n" | |
5330 | "IP access-list number (expanded range)\n" | |
5331 | "IP Access-list name\n" | |
5332 | "Filter incoming updates\n" | |
5333 | "Filter outgoing updates\n") | |
596c17ba | 5334 | |
718e3744 | 5335 | DEFUN (no_neighbor_distribute_list, |
5336 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 5337 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5338 | NO_STR |
5339 | NEIGHBOR_STR | |
5340 | NEIGHBOR_ADDR_STR2 | |
5341 | "Filter updates to/from this neighbor\n" | |
5342 | "IP access-list number\n" | |
5343 | "IP access-list number (expanded range)\n" | |
5344 | "IP Access-list name\n" | |
5345 | "Filter incoming updates\n" | |
5346 | "Filter outgoing updates\n") | |
5347 | { | |
d62a17ae | 5348 | int idx_peer = 2; |
5349 | int direct, ret; | |
5350 | struct peer *peer; | |
a8206004 | 5351 | |
d62a17ae | 5352 | const char *pstr = argv[idx_peer]->arg; |
5353 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5354 | |
d62a17ae | 5355 | peer = peer_and_group_lookup_vty(vty, pstr); |
5356 | if (!peer) | |
5357 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5358 | |
d62a17ae | 5359 | /* Check filter direction. */ |
5360 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5361 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5362 | direct); | |
a8206004 | 5363 | |
d62a17ae | 5364 | return bgp_vty_return(vty, ret); |
718e3744 | 5365 | } |
6b0655a2 | 5366 | |
d62a17ae | 5367 | ALIAS_HIDDEN( |
5368 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
5369 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5370 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5371 | "Filter updates to/from this neighbor\n" | |
5372 | "IP access-list number\n" | |
5373 | "IP access-list number (expanded range)\n" | |
5374 | "IP Access-list name\n" | |
5375 | "Filter incoming updates\n" | |
5376 | "Filter outgoing updates\n") | |
596c17ba | 5377 | |
718e3744 | 5378 | /* Set prefix list to the peer. */ |
d62a17ae | 5379 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
5380 | afi_t afi, safi_t safi, | |
5381 | const char *name_str, | |
5382 | const char *direct_str) | |
718e3744 | 5383 | { |
d62a17ae | 5384 | int ret; |
d62a17ae | 5385 | int direct = FILTER_IN; |
cf9ac8bf | 5386 | struct peer *peer; |
718e3744 | 5387 | |
d62a17ae | 5388 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5389 | if (!peer) | |
5390 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5391 | |
d62a17ae | 5392 | /* Check filter direction. */ |
5393 | if (strncmp(direct_str, "i", 1) == 0) | |
5394 | direct = FILTER_IN; | |
5395 | else if (strncmp(direct_str, "o", 1) == 0) | |
5396 | direct = FILTER_OUT; | |
718e3744 | 5397 | |
d62a17ae | 5398 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 5399 | |
d62a17ae | 5400 | return bgp_vty_return(vty, ret); |
718e3744 | 5401 | } |
5402 | ||
d62a17ae | 5403 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, |
5404 | afi_t afi, safi_t safi, | |
5405 | const char *direct_str) | |
718e3744 | 5406 | { |
d62a17ae | 5407 | int ret; |
5408 | struct peer *peer; | |
5409 | int direct = FILTER_IN; | |
718e3744 | 5410 | |
d62a17ae | 5411 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5412 | if (!peer) | |
5413 | return CMD_WARNING_CONFIG_FAILED; | |
e52702f2 | 5414 | |
d62a17ae | 5415 | /* Check filter direction. */ |
5416 | if (strncmp(direct_str, "i", 1) == 0) | |
5417 | direct = FILTER_IN; | |
5418 | else if (strncmp(direct_str, "o", 1) == 0) | |
5419 | direct = FILTER_OUT; | |
718e3744 | 5420 | |
d62a17ae | 5421 | ret = peer_prefix_list_unset(peer, afi, safi, direct); |
718e3744 | 5422 | |
d62a17ae | 5423 | return bgp_vty_return(vty, ret); |
718e3744 | 5424 | } |
5425 | ||
5426 | DEFUN (neighbor_prefix_list, | |
5427 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 5428 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5429 | NEIGHBOR_STR |
5430 | NEIGHBOR_ADDR_STR2 | |
5431 | "Filter updates to/from this neighbor\n" | |
5432 | "Name of a prefix list\n" | |
5433 | "Filter incoming updates\n" | |
5434 | "Filter outgoing updates\n") | |
5435 | { | |
d62a17ae | 5436 | int idx_peer = 1; |
5437 | int idx_word = 3; | |
5438 | int idx_in_out = 4; | |
5439 | return peer_prefix_list_set_vty( | |
5440 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5441 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5442 | } |
5443 | ||
d62a17ae | 5444 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
5445 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5446 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5447 | "Filter updates to/from this neighbor\n" | |
5448 | "Name of a prefix list\n" | |
5449 | "Filter incoming updates\n" | |
5450 | "Filter outgoing updates\n") | |
596c17ba | 5451 | |
718e3744 | 5452 | DEFUN (no_neighbor_prefix_list, |
5453 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 5454 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5455 | NO_STR |
5456 | NEIGHBOR_STR | |
5457 | NEIGHBOR_ADDR_STR2 | |
5458 | "Filter updates to/from this neighbor\n" | |
5459 | "Name of a prefix list\n" | |
5460 | "Filter incoming updates\n" | |
5461 | "Filter outgoing updates\n") | |
5462 | { | |
d62a17ae | 5463 | int idx_peer = 2; |
5464 | int idx_in_out = 5; | |
5465 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
5466 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5467 | argv[idx_in_out]->arg); | |
718e3744 | 5468 | } |
6b0655a2 | 5469 | |
d62a17ae | 5470 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, |
5471 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5472 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5473 | "Filter updates to/from this neighbor\n" | |
5474 | "Name of a prefix list\n" | |
5475 | "Filter incoming updates\n" | |
5476 | "Filter outgoing updates\n") | |
596c17ba | 5477 | |
d62a17ae | 5478 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5479 | safi_t safi, const char *name_str, | |
5480 | const char *direct_str) | |
718e3744 | 5481 | { |
d62a17ae | 5482 | int ret; |
5483 | struct peer *peer; | |
5484 | int direct = FILTER_IN; | |
718e3744 | 5485 | |
d62a17ae | 5486 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5487 | if (!peer) | |
5488 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5489 | |
d62a17ae | 5490 | /* Check filter direction. */ |
5491 | if (strncmp(direct_str, "i", 1) == 0) | |
5492 | direct = FILTER_IN; | |
5493 | else if (strncmp(direct_str, "o", 1) == 0) | |
5494 | direct = FILTER_OUT; | |
718e3744 | 5495 | |
d62a17ae | 5496 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 5497 | |
d62a17ae | 5498 | return bgp_vty_return(vty, ret); |
718e3744 | 5499 | } |
5500 | ||
d62a17ae | 5501 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5502 | safi_t safi, const char *direct_str) | |
718e3744 | 5503 | { |
d62a17ae | 5504 | int ret; |
5505 | struct peer *peer; | |
5506 | int direct = FILTER_IN; | |
718e3744 | 5507 | |
d62a17ae | 5508 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5509 | if (!peer) | |
5510 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5511 | |
d62a17ae | 5512 | /* Check filter direction. */ |
5513 | if (strncmp(direct_str, "i", 1) == 0) | |
5514 | direct = FILTER_IN; | |
5515 | else if (strncmp(direct_str, "o", 1) == 0) | |
5516 | direct = FILTER_OUT; | |
718e3744 | 5517 | |
d62a17ae | 5518 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 5519 | |
d62a17ae | 5520 | return bgp_vty_return(vty, ret); |
718e3744 | 5521 | } |
5522 | ||
5523 | DEFUN (neighbor_filter_list, | |
5524 | neighbor_filter_list_cmd, | |
9ccf14f7 | 5525 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5526 | NEIGHBOR_STR |
5527 | NEIGHBOR_ADDR_STR2 | |
5528 | "Establish BGP filters\n" | |
5529 | "AS path access-list name\n" | |
5530 | "Filter incoming routes\n" | |
5531 | "Filter outgoing routes\n") | |
5532 | { | |
d62a17ae | 5533 | int idx_peer = 1; |
5534 | int idx_word = 3; | |
5535 | int idx_in_out = 4; | |
5536 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5537 | bgp_node_safi(vty), argv[idx_word]->arg, | |
5538 | argv[idx_in_out]->arg); | |
718e3744 | 5539 | } |
5540 | ||
d62a17ae | 5541 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
5542 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5543 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5544 | "Establish BGP filters\n" | |
5545 | "AS path access-list name\n" | |
5546 | "Filter incoming routes\n" | |
5547 | "Filter outgoing routes\n") | |
596c17ba | 5548 | |
718e3744 | 5549 | DEFUN (no_neighbor_filter_list, |
5550 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 5551 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5552 | NO_STR |
5553 | NEIGHBOR_STR | |
5554 | NEIGHBOR_ADDR_STR2 | |
5555 | "Establish BGP filters\n" | |
5556 | "AS path access-list name\n" | |
5557 | "Filter incoming routes\n" | |
5558 | "Filter outgoing routes\n") | |
5559 | { | |
d62a17ae | 5560 | int idx_peer = 2; |
5561 | int idx_in_out = 5; | |
5562 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
5563 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5564 | argv[idx_in_out]->arg); | |
718e3744 | 5565 | } |
6b0655a2 | 5566 | |
d62a17ae | 5567 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
5568 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5569 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5570 | "Establish BGP filters\n" | |
5571 | "AS path access-list name\n" | |
5572 | "Filter incoming routes\n" | |
5573 | "Filter outgoing routes\n") | |
596c17ba | 5574 | |
718e3744 | 5575 | /* Set route-map to the peer. */ |
d62a17ae | 5576 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
5577 | afi_t afi, safi_t safi, const char *name_str, | |
5578 | const char *direct_str) | |
718e3744 | 5579 | { |
d62a17ae | 5580 | int ret; |
5581 | struct peer *peer; | |
5582 | int direct = RMAP_IN; | |
718e3744 | 5583 | |
d62a17ae | 5584 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5585 | if (!peer) | |
5586 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5587 | |
d62a17ae | 5588 | /* Check filter direction. */ |
5589 | if (strncmp(direct_str, "in", 2) == 0) | |
5590 | direct = RMAP_IN; | |
5591 | else if (strncmp(direct_str, "o", 1) == 0) | |
5592 | direct = RMAP_OUT; | |
718e3744 | 5593 | |
d62a17ae | 5594 | ret = peer_route_map_set(peer, afi, safi, direct, name_str); |
718e3744 | 5595 | |
d62a17ae | 5596 | return bgp_vty_return(vty, ret); |
718e3744 | 5597 | } |
5598 | ||
d62a17ae | 5599 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, |
5600 | afi_t afi, safi_t safi, | |
5601 | const char *direct_str) | |
718e3744 | 5602 | { |
d62a17ae | 5603 | int ret; |
5604 | struct peer *peer; | |
5605 | int direct = RMAP_IN; | |
718e3744 | 5606 | |
d62a17ae | 5607 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5608 | if (!peer) | |
5609 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5610 | |
d62a17ae | 5611 | /* Check filter direction. */ |
5612 | if (strncmp(direct_str, "in", 2) == 0) | |
5613 | direct = RMAP_IN; | |
5614 | else if (strncmp(direct_str, "o", 1) == 0) | |
5615 | direct = RMAP_OUT; | |
718e3744 | 5616 | |
d62a17ae | 5617 | ret = peer_route_map_unset(peer, afi, safi, direct); |
718e3744 | 5618 | |
d62a17ae | 5619 | return bgp_vty_return(vty, ret); |
718e3744 | 5620 | } |
5621 | ||
5622 | DEFUN (neighbor_route_map, | |
5623 | neighbor_route_map_cmd, | |
9ccf14f7 | 5624 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5625 | NEIGHBOR_STR |
5626 | NEIGHBOR_ADDR_STR2 | |
5627 | "Apply route map to neighbor\n" | |
5628 | "Name of route map\n" | |
5629 | "Apply map to incoming routes\n" | |
2a3d5731 | 5630 | "Apply map to outbound routes\n") |
718e3744 | 5631 | { |
d62a17ae | 5632 | int idx_peer = 1; |
5633 | int idx_word = 3; | |
5634 | int idx_in_out = 4; | |
5635 | return peer_route_map_set_vty( | |
5636 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5637 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5638 | } |
5639 | ||
d62a17ae | 5640 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
5641 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5642 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5643 | "Apply route map to neighbor\n" | |
5644 | "Name of route map\n" | |
5645 | "Apply map to incoming routes\n" | |
5646 | "Apply map to outbound routes\n") | |
596c17ba | 5647 | |
718e3744 | 5648 | DEFUN (no_neighbor_route_map, |
5649 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 5650 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5651 | NO_STR |
5652 | NEIGHBOR_STR | |
5653 | NEIGHBOR_ADDR_STR2 | |
5654 | "Apply route map to neighbor\n" | |
5655 | "Name of route map\n" | |
5656 | "Apply map to incoming routes\n" | |
2a3d5731 | 5657 | "Apply map to outbound routes\n") |
718e3744 | 5658 | { |
d62a17ae | 5659 | int idx_peer = 2; |
5660 | int idx_in_out = 5; | |
5661 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
5662 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5663 | argv[idx_in_out]->arg); | |
718e3744 | 5664 | } |
6b0655a2 | 5665 | |
d62a17ae | 5666 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, |
5667 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5668 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5669 | "Apply route map to neighbor\n" | |
5670 | "Name of route map\n" | |
5671 | "Apply map to incoming routes\n" | |
5672 | "Apply map to outbound routes\n") | |
596c17ba | 5673 | |
718e3744 | 5674 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 5675 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
5676 | afi_t afi, safi_t safi, | |
5677 | const char *name_str) | |
718e3744 | 5678 | { |
d62a17ae | 5679 | int ret; |
5680 | struct peer *peer; | |
718e3744 | 5681 | |
d62a17ae | 5682 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5683 | if (!peer) | |
5684 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5685 | |
d62a17ae | 5686 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str); |
718e3744 | 5687 | |
d62a17ae | 5688 | return bgp_vty_return(vty, ret); |
718e3744 | 5689 | } |
5690 | ||
5691 | /* Unset route-map from the peer. */ | |
d62a17ae | 5692 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
5693 | afi_t afi, safi_t safi) | |
718e3744 | 5694 | { |
d62a17ae | 5695 | int ret; |
5696 | struct peer *peer; | |
718e3744 | 5697 | |
d62a17ae | 5698 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5699 | if (!peer) | |
5700 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5701 | |
d62a17ae | 5702 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 5703 | |
d62a17ae | 5704 | return bgp_vty_return(vty, ret); |
718e3744 | 5705 | } |
5706 | ||
5707 | DEFUN (neighbor_unsuppress_map, | |
5708 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5709 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5710 | NEIGHBOR_STR |
5711 | NEIGHBOR_ADDR_STR2 | |
5712 | "Route-map to selectively unsuppress suppressed routes\n" | |
5713 | "Name of route map\n") | |
5714 | { | |
d62a17ae | 5715 | int idx_peer = 1; |
5716 | int idx_word = 3; | |
5717 | return peer_unsuppress_map_set_vty( | |
5718 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5719 | argv[idx_word]->arg); | |
718e3744 | 5720 | } |
5721 | ||
d62a17ae | 5722 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
5723 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5724 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5725 | "Route-map to selectively unsuppress suppressed routes\n" | |
5726 | "Name of route map\n") | |
596c17ba | 5727 | |
718e3744 | 5728 | DEFUN (no_neighbor_unsuppress_map, |
5729 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5730 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5731 | NO_STR |
5732 | NEIGHBOR_STR | |
5733 | NEIGHBOR_ADDR_STR2 | |
5734 | "Route-map to selectively unsuppress suppressed routes\n" | |
5735 | "Name of route map\n") | |
5736 | { | |
d62a17ae | 5737 | int idx_peer = 2; |
5738 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
5739 | bgp_node_afi(vty), | |
5740 | bgp_node_safi(vty)); | |
718e3744 | 5741 | } |
6b0655a2 | 5742 | |
d62a17ae | 5743 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
5744 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5745 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5746 | "Route-map to selectively unsuppress suppressed routes\n" | |
5747 | "Name of route map\n") | |
596c17ba | 5748 | |
d62a17ae | 5749 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
5750 | afi_t afi, safi_t safi, | |
5751 | const char *num_str, | |
5752 | const char *threshold_str, int warning, | |
5753 | const char *restart_str) | |
718e3744 | 5754 | { |
d62a17ae | 5755 | int ret; |
5756 | struct peer *peer; | |
d7c0a89a QY |
5757 | uint32_t max; |
5758 | uint8_t threshold; | |
5759 | uint16_t restart; | |
718e3744 | 5760 | |
d62a17ae | 5761 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5762 | if (!peer) | |
5763 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5764 | |
d62a17ae | 5765 | max = strtoul(num_str, NULL, 10); |
5766 | if (threshold_str) | |
5767 | threshold = atoi(threshold_str); | |
5768 | else | |
5769 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 5770 | |
d62a17ae | 5771 | if (restart_str) |
5772 | restart = atoi(restart_str); | |
5773 | else | |
5774 | restart = 0; | |
0a486e5f | 5775 | |
d62a17ae | 5776 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, |
5777 | restart); | |
718e3744 | 5778 | |
d62a17ae | 5779 | return bgp_vty_return(vty, ret); |
718e3744 | 5780 | } |
5781 | ||
d62a17ae | 5782 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, |
5783 | afi_t afi, safi_t safi) | |
718e3744 | 5784 | { |
d62a17ae | 5785 | int ret; |
5786 | struct peer *peer; | |
718e3744 | 5787 | |
d62a17ae | 5788 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5789 | if (!peer) | |
5790 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5791 | |
d62a17ae | 5792 | ret = peer_maximum_prefix_unset(peer, afi, safi); |
718e3744 | 5793 | |
d62a17ae | 5794 | return bgp_vty_return(vty, ret); |
718e3744 | 5795 | } |
5796 | ||
5797 | /* Maximum number of prefix configuration. prefix count is different | |
5798 | for each peer configuration. So this configuration can be set for | |
5799 | each peer configuration. */ | |
5800 | DEFUN (neighbor_maximum_prefix, | |
5801 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 5802 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 5803 | NEIGHBOR_STR |
5804 | NEIGHBOR_ADDR_STR2 | |
5805 | "Maximum number of prefix accept from this peer\n" | |
5806 | "maximum no. of prefix limit\n") | |
5807 | { | |
d62a17ae | 5808 | int idx_peer = 1; |
5809 | int idx_number = 3; | |
5810 | return peer_maximum_prefix_set_vty( | |
5811 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5812 | argv[idx_number]->arg, NULL, 0, NULL); | |
718e3744 | 5813 | } |
5814 | ||
d62a17ae | 5815 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
5816 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", | |
5817 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5818 | "Maximum number of prefix accept from this peer\n" | |
5819 | "maximum no. of prefix limit\n") | |
596c17ba | 5820 | |
e0701b79 | 5821 | DEFUN (neighbor_maximum_prefix_threshold, |
5822 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 5823 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 5824 | NEIGHBOR_STR |
5825 | NEIGHBOR_ADDR_STR2 | |
5826 | "Maximum number of prefix accept from this peer\n" | |
5827 | "maximum no. of prefix limit\n" | |
5828 | "Threshold value (%) at which to generate a warning msg\n") | |
5829 | { | |
d62a17ae | 5830 | int idx_peer = 1; |
5831 | int idx_number = 3; | |
5832 | int idx_number_2 = 4; | |
5833 | return peer_maximum_prefix_set_vty( | |
5834 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5835 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL); | |
0a486e5f | 5836 | } |
e0701b79 | 5837 | |
d62a17ae | 5838 | ALIAS_HIDDEN( |
5839 | neighbor_maximum_prefix_threshold, | |
5840 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
5841 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", | |
5842 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5843 | "Maximum number of prefix accept from this peer\n" | |
5844 | "maximum no. of prefix limit\n" | |
5845 | "Threshold value (%) at which to generate a warning msg\n") | |
596c17ba | 5846 | |
718e3744 | 5847 | DEFUN (neighbor_maximum_prefix_warning, |
5848 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 5849 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 5850 | NEIGHBOR_STR |
5851 | NEIGHBOR_ADDR_STR2 | |
5852 | "Maximum number of prefix accept from this peer\n" | |
5853 | "maximum no. of prefix limit\n" | |
5854 | "Only give warning message when limit is exceeded\n") | |
5855 | { | |
d62a17ae | 5856 | int idx_peer = 1; |
5857 | int idx_number = 3; | |
5858 | return peer_maximum_prefix_set_vty( | |
5859 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5860 | argv[idx_number]->arg, NULL, 1, NULL); | |
718e3744 | 5861 | } |
5862 | ||
d62a17ae | 5863 | ALIAS_HIDDEN( |
5864 | neighbor_maximum_prefix_warning, | |
5865 | neighbor_maximum_prefix_warning_hidden_cmd, | |
5866 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", | |
5867 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5868 | "Maximum number of prefix accept from this peer\n" | |
5869 | "maximum no. of prefix limit\n" | |
5870 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 5871 | |
e0701b79 | 5872 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
5873 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 5874 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 5875 | NEIGHBOR_STR |
5876 | NEIGHBOR_ADDR_STR2 | |
5877 | "Maximum number of prefix accept from this peer\n" | |
5878 | "maximum no. of prefix limit\n" | |
5879 | "Threshold value (%) at which to generate a warning msg\n" | |
5880 | "Only give warning message when limit is exceeded\n") | |
5881 | { | |
d62a17ae | 5882 | int idx_peer = 1; |
5883 | int idx_number = 3; | |
5884 | int idx_number_2 = 4; | |
5885 | return peer_maximum_prefix_set_vty( | |
5886 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5887 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 5888 | } |
5889 | ||
d62a17ae | 5890 | ALIAS_HIDDEN( |
5891 | neighbor_maximum_prefix_threshold_warning, | |
5892 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
5893 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", | |
5894 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5895 | "Maximum number of prefix accept from this peer\n" | |
5896 | "maximum no. of prefix limit\n" | |
5897 | "Threshold value (%) at which to generate a warning msg\n" | |
5898 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 5899 | |
0a486e5f | 5900 | DEFUN (neighbor_maximum_prefix_restart, |
5901 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 5902 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 5903 | NEIGHBOR_STR |
5904 | NEIGHBOR_ADDR_STR2 | |
5905 | "Maximum number of prefix accept from this peer\n" | |
5906 | "maximum no. of prefix limit\n" | |
5907 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 5908 | "Restart interval in minutes\n") |
0a486e5f | 5909 | { |
d62a17ae | 5910 | int idx_peer = 1; |
5911 | int idx_number = 3; | |
5912 | int idx_number_2 = 5; | |
5913 | return peer_maximum_prefix_set_vty( | |
5914 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5915 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 5916 | } |
5917 | ||
d62a17ae | 5918 | ALIAS_HIDDEN( |
5919 | neighbor_maximum_prefix_restart, | |
5920 | neighbor_maximum_prefix_restart_hidden_cmd, | |
5921 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", | |
5922 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5923 | "Maximum number of prefix accept from this peer\n" | |
5924 | "maximum no. of prefix limit\n" | |
5925 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 5926 | "Restart interval in minutes\n") |
596c17ba | 5927 | |
0a486e5f | 5928 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
5929 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 5930 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 5931 | NEIGHBOR_STR |
5932 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5933 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 5934 | "maximum no. of prefix limit\n" |
5935 | "Threshold value (%) at which to generate a warning msg\n" | |
5936 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 5937 | "Restart interval in minutes\n") |
0a486e5f | 5938 | { |
d62a17ae | 5939 | int idx_peer = 1; |
5940 | int idx_number = 3; | |
5941 | int idx_number_2 = 4; | |
5942 | int idx_number_3 = 6; | |
5943 | return peer_maximum_prefix_set_vty( | |
5944 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5945 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
5946 | argv[idx_number_3]->arg); | |
5947 | } | |
5948 | ||
5949 | ALIAS_HIDDEN( | |
5950 | neighbor_maximum_prefix_threshold_restart, | |
5951 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
5952 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", | |
5953 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5954 | "Maximum number of prefixes to accept from this peer\n" | |
5955 | "maximum no. of prefix limit\n" | |
5956 | "Threshold value (%) at which to generate a warning msg\n" | |
5957 | "Restart bgp connection after limit is exceeded\n" | |
5958 | "Restart interval in minutes\n") | |
596c17ba | 5959 | |
718e3744 | 5960 | DEFUN (no_neighbor_maximum_prefix, |
5961 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 5962 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 5963 | NO_STR |
5964 | NEIGHBOR_STR | |
5965 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5966 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
5967 | "maximum no. of prefix limit\n" |
5968 | "Threshold value (%) at which to generate a warning msg\n" | |
5969 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 5970 | "Restart interval in minutes\n" |
31500417 | 5971 | "Only give warning message when limit is exceeded\n") |
718e3744 | 5972 | { |
d62a17ae | 5973 | int idx_peer = 2; |
5974 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, | |
5975 | bgp_node_afi(vty), | |
5976 | bgp_node_safi(vty)); | |
718e3744 | 5977 | } |
e52702f2 | 5978 | |
d62a17ae | 5979 | ALIAS_HIDDEN( |
5980 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
5981 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", | |
5982 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5983 | "Maximum number of prefixes to accept from this peer\n" | |
5984 | "maximum no. of prefix limit\n" | |
5985 | "Threshold value (%) at which to generate a warning msg\n" | |
5986 | "Restart bgp connection after limit is exceeded\n" | |
5987 | "Restart interval in minutes\n" | |
5988 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 5989 | |
718e3744 | 5990 | |
718e3744 | 5991 | /* "neighbor allowas-in" */ |
5992 | DEFUN (neighbor_allowas_in, | |
5993 | neighbor_allowas_in_cmd, | |
fd8503f5 | 5994 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 5995 | NEIGHBOR_STR |
5996 | NEIGHBOR_ADDR_STR2 | |
31500417 | 5997 | "Accept as-path with my AS present in it\n" |
fd8503f5 QY |
5998 | "Number of occurances of AS number\n" |
5999 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 6000 | { |
d62a17ae | 6001 | int idx_peer = 1; |
6002 | int idx_number_origin = 3; | |
6003 | int ret; | |
6004 | int origin = 0; | |
6005 | struct peer *peer; | |
6006 | int allow_num = 0; | |
6007 | ||
6008 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6009 | if (!peer) | |
6010 | return CMD_WARNING_CONFIG_FAILED; | |
6011 | ||
6012 | if (argc <= idx_number_origin) | |
6013 | allow_num = 3; | |
6014 | else { | |
6015 | if (argv[idx_number_origin]->type == WORD_TKN) | |
6016 | origin = 1; | |
6017 | else | |
6018 | allow_num = atoi(argv[idx_number_origin]->arg); | |
6019 | } | |
6020 | ||
6021 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6022 | allow_num, origin); | |
6023 | ||
6024 | return bgp_vty_return(vty, ret); | |
6025 | } | |
6026 | ||
6027 | ALIAS_HIDDEN( | |
6028 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
6029 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6030 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6031 | "Accept as-path with my AS present in it\n" | |
6032 | "Number of occurances of AS number\n" | |
6033 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
596c17ba | 6034 | |
718e3744 | 6035 | DEFUN (no_neighbor_allowas_in, |
6036 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 6037 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6038 | NO_STR |
6039 | NEIGHBOR_STR | |
6040 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 6041 | "allow local ASN appears in aspath attribute\n" |
fd8503f5 QY |
6042 | "Number of occurances of AS number\n" |
6043 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 6044 | { |
d62a17ae | 6045 | int idx_peer = 2; |
6046 | int ret; | |
6047 | struct peer *peer; | |
718e3744 | 6048 | |
d62a17ae | 6049 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6050 | if (!peer) | |
6051 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6052 | |
d62a17ae | 6053 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
6054 | bgp_node_safi(vty)); | |
718e3744 | 6055 | |
d62a17ae | 6056 | return bgp_vty_return(vty, ret); |
718e3744 | 6057 | } |
6b0655a2 | 6058 | |
d62a17ae | 6059 | ALIAS_HIDDEN( |
6060 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
6061 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6062 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6063 | "allow local ASN appears in aspath attribute\n" | |
6064 | "Number of occurances of AS number\n" | |
6065 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
596c17ba | 6066 | |
fa411a21 NH |
6067 | DEFUN (neighbor_ttl_security, |
6068 | neighbor_ttl_security_cmd, | |
7ebe625c | 6069 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 | 6070 | NEIGHBOR_STR |
7ebe625c | 6071 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6072 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
6073 | "Specify the maximum number of hops to the BGP peer\n" |
6074 | "Number of hops to BGP peer\n") | |
fa411a21 | 6075 | { |
d62a17ae | 6076 | int idx_peer = 1; |
6077 | int idx_number = 4; | |
6078 | struct peer *peer; | |
6079 | int gtsm_hops; | |
6080 | ||
6081 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6082 | if (!peer) | |
6083 | return CMD_WARNING_CONFIG_FAILED; | |
6084 | ||
6085 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); | |
6086 | ||
7ebe625c QY |
6087 | /* |
6088 | * If 'neighbor swpX', then this is for directly connected peers, | |
6089 | * we should not accept a ttl-security hops value greater than 1. | |
6090 | */ | |
6091 | if (peer->conf_if && (gtsm_hops > 1)) { | |
6092 | vty_out(vty, | |
6093 | "%s is directly connected peer, hops cannot exceed 1\n", | |
6094 | argv[idx_peer]->arg); | |
6095 | return CMD_WARNING_CONFIG_FAILED; | |
6096 | } | |
6097 | ||
d62a17ae | 6098 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
6099 | } |
6100 | ||
6101 | DEFUN (no_neighbor_ttl_security, | |
6102 | no_neighbor_ttl_security_cmd, | |
7ebe625c | 6103 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
6104 | NO_STR |
6105 | NEIGHBOR_STR | |
7ebe625c | 6106 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6107 | "BGP ttl-security parameters\n" |
3a2d747c QY |
6108 | "Specify the maximum number of hops to the BGP peer\n" |
6109 | "Number of hops to BGP peer\n") | |
fa411a21 | 6110 | { |
d62a17ae | 6111 | int idx_peer = 2; |
6112 | struct peer *peer; | |
fa411a21 | 6113 | |
d62a17ae | 6114 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6115 | if (!peer) | |
6116 | return CMD_WARNING_CONFIG_FAILED; | |
fa411a21 | 6117 | |
d62a17ae | 6118 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 6119 | } |
6b0655a2 | 6120 | |
adbac85e DW |
6121 | DEFUN (neighbor_addpath_tx_all_paths, |
6122 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6123 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6124 | NEIGHBOR_STR |
6125 | NEIGHBOR_ADDR_STR2 | |
6126 | "Use addpath to advertise all paths to a neighbor\n") | |
6127 | { | |
d62a17ae | 6128 | int idx_peer = 1; |
6129 | struct peer *peer; | |
adbac85e | 6130 | |
d62a17ae | 6131 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6132 | if (!peer) | |
6133 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 6134 | |
d62a17ae | 6135 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
6136 | bgp_node_safi(vty), | |
6137 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
adbac85e DW |
6138 | } |
6139 | ||
d62a17ae | 6140 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
6141 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
6142 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6143 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6144 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6145 | |
adbac85e DW |
6146 | DEFUN (no_neighbor_addpath_tx_all_paths, |
6147 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6148 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6149 | NO_STR |
6150 | NEIGHBOR_STR | |
6151 | NEIGHBOR_ADDR_STR2 | |
6152 | "Use addpath to advertise all paths to a neighbor\n") | |
6153 | { | |
d62a17ae | 6154 | int idx_peer = 2; |
6155 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6156 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6157 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
adbac85e DW |
6158 | } |
6159 | ||
d62a17ae | 6160 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
6161 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
6162 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6163 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6164 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6165 | |
06370dac DW |
6166 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
6167 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6168 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6169 | NEIGHBOR_STR |
6170 | NEIGHBOR_ADDR_STR2 | |
6171 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6172 | { | |
d62a17ae | 6173 | int idx_peer = 1; |
6174 | struct peer *peer; | |
06370dac | 6175 | |
d62a17ae | 6176 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6177 | if (!peer) | |
6178 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 6179 | |
d62a17ae | 6180 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
6181 | bgp_node_safi(vty), | |
6182 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
06370dac DW |
6183 | } |
6184 | ||
d62a17ae | 6185 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
6186 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6187 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6188 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6189 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 6190 | |
06370dac DW |
6191 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
6192 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6193 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6194 | NO_STR |
6195 | NEIGHBOR_STR | |
6196 | NEIGHBOR_ADDR_STR2 | |
6197 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6198 | { | |
d62a17ae | 6199 | int idx_peer = 2; |
6200 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6201 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6202 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
06370dac DW |
6203 | } |
6204 | ||
d62a17ae | 6205 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
6206 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6207 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6208 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6209 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 6210 | |
b9c7bc5a PZ |
6211 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
6212 | struct ecommunity **list) | |
ddb5b488 | 6213 | { |
b9c7bc5a PZ |
6214 | struct ecommunity *ecom = NULL; |
6215 | struct ecommunity *ecomadd; | |
ddb5b488 | 6216 | |
b9c7bc5a | 6217 | for (; argc; --argc, ++argv) { |
ddb5b488 | 6218 | |
b9c7bc5a PZ |
6219 | ecomadd = ecommunity_str2com(argv[0]->arg, |
6220 | ECOMMUNITY_ROUTE_TARGET, 0); | |
6221 | if (!ecomadd) { | |
6222 | vty_out(vty, "Malformed community-list value\n"); | |
6223 | if (ecom) | |
6224 | ecommunity_free(&ecom); | |
6225 | return CMD_WARNING_CONFIG_FAILED; | |
6226 | } | |
ddb5b488 | 6227 | |
b9c7bc5a PZ |
6228 | if (ecom) { |
6229 | ecommunity_merge(ecom, ecomadd); | |
6230 | ecommunity_free(&ecomadd); | |
6231 | } else { | |
6232 | ecom = ecomadd; | |
6233 | } | |
6234 | } | |
6235 | ||
6236 | if (*list) { | |
6237 | ecommunity_free(&*list); | |
ddb5b488 | 6238 | } |
b9c7bc5a PZ |
6239 | *list = ecom; |
6240 | ||
6241 | return CMD_SUCCESS; | |
ddb5b488 PZ |
6242 | } |
6243 | ||
0ca70ba5 DS |
6244 | /* |
6245 | * v2vimport is true if we are handling a `import vrf ...` command | |
6246 | */ | |
6247 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 6248 | { |
0ca70ba5 DS |
6249 | afi_t afi; |
6250 | ||
ddb5b488 | 6251 | switch (vty->node) { |
b9c7bc5a | 6252 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
6253 | afi = AFI_IP; |
6254 | break; | |
b9c7bc5a | 6255 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
6256 | afi = AFI_IP6; |
6257 | break; | |
ddb5b488 PZ |
6258 | default: |
6259 | vty_out(vty, | |
b9c7bc5a | 6260 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 6261 | return AFI_MAX; |
ddb5b488 | 6262 | } |
69b07479 | 6263 | |
0ca70ba5 DS |
6264 | if (!v2vimport) { |
6265 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6266 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
6267 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6268 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
6269 | vty_out(vty, | |
6270 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
6271 | return AFI_MAX; | |
6272 | } | |
6273 | } else { | |
6274 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6275 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
6276 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6277 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
6278 | vty_out(vty, | |
6279 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
6280 | return AFI_MAX; | |
6281 | } | |
6282 | } | |
6283 | return afi; | |
ddb5b488 PZ |
6284 | } |
6285 | ||
b9c7bc5a PZ |
6286 | DEFPY (af_rd_vpn_export, |
6287 | af_rd_vpn_export_cmd, | |
6288 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
6289 | NO_STR | |
ddb5b488 | 6290 | "Specify route distinguisher\n" |
b9c7bc5a PZ |
6291 | "Between current address-family and vpn\n" |
6292 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6293 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") |
6294 | { | |
6295 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6296 | struct prefix_rd prd; | |
6297 | int ret; | |
ddb5b488 | 6298 | afi_t afi; |
b9c7bc5a PZ |
6299 | int idx = 0; |
6300 | int yes = 1; | |
ddb5b488 | 6301 | |
b9c7bc5a | 6302 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6303 | yes = 0; |
b9c7bc5a PZ |
6304 | |
6305 | if (yes) { | |
6306 | ret = str2prefix_rd(rd_str, &prd); | |
6307 | if (!ret) { | |
6308 | vty_out(vty, "%% Malformed rd\n"); | |
6309 | return CMD_WARNING_CONFIG_FAILED; | |
6310 | } | |
ddb5b488 PZ |
6311 | } |
6312 | ||
0ca70ba5 | 6313 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6314 | if (afi == AFI_MAX) |
6315 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6316 | |
69b07479 DS |
6317 | /* |
6318 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6319 | */ | |
6320 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6321 | bgp_get_default(), bgp); | |
ddb5b488 | 6322 | |
69b07479 DS |
6323 | if (yes) { |
6324 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
6325 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6326 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
6327 | } else { | |
6328 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
6329 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
ddb5b488 PZ |
6330 | } |
6331 | ||
69b07479 DS |
6332 | /* post-change: re-export vpn routes */ |
6333 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6334 | bgp_get_default(), bgp); | |
6335 | ||
ddb5b488 PZ |
6336 | return CMD_SUCCESS; |
6337 | } | |
6338 | ||
b9c7bc5a PZ |
6339 | ALIAS (af_rd_vpn_export, |
6340 | af_no_rd_vpn_export_cmd, | |
6341 | "no rd vpn export", | |
ddb5b488 | 6342 | NO_STR |
b9c7bc5a PZ |
6343 | "Specify route distinguisher\n" |
6344 | "Between current address-family and vpn\n" | |
6345 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6346 | |
b9c7bc5a PZ |
6347 | DEFPY (af_label_vpn_export, |
6348 | af_label_vpn_export_cmd, | |
e70e9f8e | 6349 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 6350 | NO_STR |
ddb5b488 | 6351 | "label value for VRF\n" |
b9c7bc5a PZ |
6352 | "Between current address-family and vpn\n" |
6353 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
6354 | "Label Value <0-1048575>\n" |
6355 | "Automatically assign a label\n") | |
ddb5b488 PZ |
6356 | { |
6357 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 6358 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 6359 | afi_t afi; |
b9c7bc5a PZ |
6360 | int idx = 0; |
6361 | int yes = 1; | |
6362 | ||
6363 | if (argv_find(argv, argc, "no", &idx)) | |
d555f3e9 | 6364 | yes = 0; |
ddb5b488 | 6365 | |
21a16cc2 PZ |
6366 | /* If "no ...", squash trailing parameter */ |
6367 | if (!yes) | |
6368 | label_auto = NULL; | |
6369 | ||
e70e9f8e PZ |
6370 | if (yes) { |
6371 | if (!label_auto) | |
6372 | label = label_val; /* parser should force unsigned */ | |
6373 | } | |
ddb5b488 | 6374 | |
0ca70ba5 | 6375 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6376 | if (afi == AFI_MAX) |
6377 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 6378 | |
e70e9f8e | 6379 | |
69b07479 DS |
6380 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
6381 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
6382 | /* no change */ | |
6383 | return CMD_SUCCESS; | |
e70e9f8e | 6384 | |
69b07479 DS |
6385 | /* |
6386 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6387 | */ | |
6388 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6389 | bgp_get_default(), bgp); | |
6390 | ||
6391 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
6392 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
6393 | ||
6394 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
6395 | ||
6396 | /* | |
6397 | * label has previously been automatically | |
6398 | * assigned by labelpool: release it | |
6399 | * | |
6400 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
6401 | * means the automatic assignment is in flight | |
6402 | * and therefore the labelpool callback must | |
6403 | * detect that the auto label is not needed. | |
6404 | */ | |
6405 | ||
6406 | bgp_lp_release(LP_TYPE_VRF, | |
6407 | &bgp->vpn_policy[afi], | |
6408 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 6409 | } |
69b07479 DS |
6410 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
6411 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
6412 | } | |
ddb5b488 | 6413 | |
69b07479 DS |
6414 | bgp->vpn_policy[afi].tovpn_label = label; |
6415 | if (label_auto) { | |
6416 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6417 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
6418 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
6419 | vpn_leak_label_callback); | |
ddb5b488 PZ |
6420 | } |
6421 | ||
69b07479 DS |
6422 | /* post-change: re-export vpn routes */ |
6423 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6424 | bgp_get_default(), bgp); | |
6425 | ||
ddb5b488 PZ |
6426 | return CMD_SUCCESS; |
6427 | } | |
6428 | ||
b9c7bc5a PZ |
6429 | ALIAS (af_label_vpn_export, |
6430 | af_no_label_vpn_export_cmd, | |
6431 | "no label vpn export", | |
6432 | NO_STR | |
6433 | "label value for VRF\n" | |
6434 | "Between current address-family and vpn\n" | |
6435 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6436 | |
b9c7bc5a PZ |
6437 | DEFPY (af_nexthop_vpn_export, |
6438 | af_nexthop_vpn_export_cmd, | |
6439 | "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str", | |
6440 | NO_STR | |
ddb5b488 | 6441 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
6442 | "Between current address-family and vpn\n" |
6443 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6444 | "IPv4 prefix\n" |
6445 | "IPv6 prefix\n") | |
6446 | { | |
6447 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
ddb5b488 | 6448 | afi_t afi; |
ddb5b488 | 6449 | struct prefix p; |
b9c7bc5a PZ |
6450 | int idx = 0; |
6451 | int yes = 1; | |
ddb5b488 | 6452 | |
b9c7bc5a | 6453 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6454 | yes = 0; |
b9c7bc5a PZ |
6455 | |
6456 | if (yes) { | |
6457 | if (!sockunion2hostprefix(nexthop_str, &p)) | |
6458 | return CMD_WARNING_CONFIG_FAILED; | |
6459 | } | |
ddb5b488 | 6460 | |
0ca70ba5 | 6461 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6462 | if (afi == AFI_MAX) |
6463 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6464 | |
69b07479 DS |
6465 | /* |
6466 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6467 | */ | |
6468 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6469 | bgp_get_default(), bgp); | |
ddb5b488 | 6470 | |
69b07479 DS |
6471 | if (yes) { |
6472 | bgp->vpn_policy[afi].tovpn_nexthop = p; | |
6473 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6474 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
6475 | } else { | |
6476 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
6477 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
ddb5b488 PZ |
6478 | } |
6479 | ||
69b07479 DS |
6480 | /* post-change: re-export vpn routes */ |
6481 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6482 | bgp_get_default(), bgp); | |
6483 | ||
ddb5b488 PZ |
6484 | return CMD_SUCCESS; |
6485 | } | |
6486 | ||
b9c7bc5a PZ |
6487 | ALIAS (af_nexthop_vpn_export, |
6488 | af_no_nexthop_vpn_export_cmd, | |
6489 | "no nexthop vpn export", | |
ddb5b488 | 6490 | NO_STR |
b9c7bc5a PZ |
6491 | "Specify next hop to use for VRF advertised prefixes\n" |
6492 | "Between current address-family and vpn\n" | |
6493 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6494 | |
b9c7bc5a | 6495 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 6496 | { |
b9c7bc5a PZ |
6497 | if (!strcmp(dstr, "import")) { |
6498 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
6499 | } else if (!strcmp(dstr, "export")) { | |
6500 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
6501 | } else if (!strcmp(dstr, "both")) { | |
6502 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
6503 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
6504 | } else { | |
6505 | vty_out(vty, "%% direction parse error\n"); | |
6506 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6507 | } |
ddb5b488 PZ |
6508 | return CMD_SUCCESS; |
6509 | } | |
6510 | ||
b9c7bc5a PZ |
6511 | DEFPY (af_rt_vpn_imexport, |
6512 | af_rt_vpn_imexport_cmd, | |
6513 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
6514 | NO_STR | |
6515 | "Specify route target list\n" | |
ddb5b488 | 6516 | "Specify route target list\n" |
b9c7bc5a PZ |
6517 | "Between current address-family and vpn\n" |
6518 | "For routes leaked from vpn to current address-family: match any\n" | |
6519 | "For routes leaked from current address-family to vpn: set\n" | |
6520 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
6521 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
6522 | { | |
6523 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6524 | int ret; | |
6525 | struct ecommunity *ecom = NULL; | |
6526 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
6527 | vpn_policy_direction_t dir; |
6528 | afi_t afi; | |
6529 | int idx = 0; | |
b9c7bc5a | 6530 | int yes = 1; |
ddb5b488 | 6531 | |
b9c7bc5a | 6532 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6533 | yes = 0; |
b9c7bc5a | 6534 | |
0ca70ba5 | 6535 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6536 | if (afi == AFI_MAX) |
6537 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6538 | |
b9c7bc5a | 6539 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
6540 | if (ret != CMD_SUCCESS) |
6541 | return ret; | |
6542 | ||
b9c7bc5a PZ |
6543 | if (yes) { |
6544 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
6545 | vty_out(vty, "%% Missing RTLIST\n"); | |
6546 | return CMD_WARNING_CONFIG_FAILED; | |
6547 | } | |
6548 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
6549 | if (ret != CMD_SUCCESS) { | |
6550 | return ret; | |
6551 | } | |
ddb5b488 PZ |
6552 | } |
6553 | ||
69b07479 DS |
6554 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
6555 | if (!dodir[dir]) | |
ddb5b488 | 6556 | continue; |
ddb5b488 | 6557 | |
69b07479 | 6558 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 6559 | |
69b07479 DS |
6560 | if (yes) { |
6561 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
6562 | ecommunity_free( | |
6563 | &bgp->vpn_policy[afi].rtlist[dir]); | |
6564 | bgp->vpn_policy[afi].rtlist[dir] = | |
6565 | ecommunity_dup(ecom); | |
6566 | } else { | |
6567 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
6568 | ecommunity_free( | |
6569 | &bgp->vpn_policy[afi].rtlist[dir]); | |
6570 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 6571 | } |
69b07479 DS |
6572 | |
6573 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 6574 | } |
69b07479 | 6575 | |
d555f3e9 PZ |
6576 | if (ecom) |
6577 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
6578 | |
6579 | return CMD_SUCCESS; | |
6580 | } | |
6581 | ||
b9c7bc5a PZ |
6582 | ALIAS (af_rt_vpn_imexport, |
6583 | af_no_rt_vpn_imexport_cmd, | |
6584 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
6585 | NO_STR |
6586 | "Specify route target list\n" | |
b9c7bc5a PZ |
6587 | "Specify route target list\n" |
6588 | "Between current address-family and vpn\n" | |
6589 | "For routes leaked from vpn to current address-family\n" | |
6590 | "For routes leaked from current address-family to vpn\n" | |
6591 | "both import and export\n") | |
6592 | ||
6593 | DEFPY (af_route_map_vpn_imexport, | |
6594 | af_route_map_vpn_imexport_cmd, | |
6595 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
6596 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
6597 | NO_STR | |
ddb5b488 | 6598 | "Specify route map\n" |
b9c7bc5a PZ |
6599 | "Between current address-family and vpn\n" |
6600 | "For routes leaked from vpn to current address-family\n" | |
6601 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6602 | "name of route-map\n") |
6603 | { | |
6604 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6605 | int ret; | |
6606 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
6607 | vpn_policy_direction_t dir; |
6608 | afi_t afi; | |
ddb5b488 | 6609 | int idx = 0; |
b9c7bc5a | 6610 | int yes = 1; |
ddb5b488 | 6611 | |
b9c7bc5a | 6612 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6613 | yes = 0; |
b9c7bc5a | 6614 | |
0ca70ba5 | 6615 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6616 | if (afi == AFI_MAX) |
6617 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6618 | |
b9c7bc5a | 6619 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
6620 | if (ret != CMD_SUCCESS) |
6621 | return ret; | |
6622 | ||
69b07479 DS |
6623 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
6624 | if (!dodir[dir]) | |
ddb5b488 | 6625 | continue; |
ddb5b488 | 6626 | |
69b07479 | 6627 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 6628 | |
69b07479 DS |
6629 | if (yes) { |
6630 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6631 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6632 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6633 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
6634 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
6635 | bgp->vpn_policy[afi].rmap[dir] = | |
6636 | route_map_lookup_by_name(rmap_str); | |
6637 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
6638 | return CMD_SUCCESS; | |
6639 | } else { | |
6640 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6641 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6642 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6643 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
6644 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
ddb5b488 | 6645 | } |
69b07479 DS |
6646 | |
6647 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 PZ |
6648 | } |
6649 | ||
6650 | return CMD_SUCCESS; | |
6651 | } | |
6652 | ||
b9c7bc5a PZ |
6653 | ALIAS (af_route_map_vpn_imexport, |
6654 | af_no_route_map_vpn_imexport_cmd, | |
6655 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
6656 | NO_STR |
6657 | "Specify route map\n" | |
b9c7bc5a PZ |
6658 | "Between current address-family and vpn\n" |
6659 | "For routes leaked from vpn to current address-family\n" | |
6660 | "For routes leaked from current address-family to vpn\n") | |
6661 | ||
bb4f6190 DS |
6662 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
6663 | "[no] import vrf route-map RMAP$rmap_str", | |
6664 | NO_STR | |
6665 | "Import routes from another VRF\n" | |
6666 | "Vrf routes being filtered\n" | |
6667 | "Specify route map\n" | |
6668 | "name of route-map\n") | |
6669 | { | |
6670 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
bb4f6190 DS |
6671 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; |
6672 | afi_t afi; | |
6673 | int idx = 0; | |
6674 | int yes = 1; | |
6675 | struct bgp *bgp_default; | |
6676 | ||
6677 | if (argv_find(argv, argc, "no", &idx)) | |
6678 | yes = 0; | |
6679 | ||
0ca70ba5 | 6680 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
6681 | if (afi == AFI_MAX) |
6682 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
6683 | |
6684 | bgp_default = bgp_get_default(); | |
6685 | if (!bgp_default) { | |
6686 | int32_t ret; | |
6687 | as_t as = bgp->as; | |
6688 | ||
6689 | /* Auto-create assuming the same AS */ | |
6690 | ret = bgp_get(&bgp_default, &as, NULL, | |
6691 | BGP_INSTANCE_TYPE_DEFAULT); | |
6692 | ||
6693 | if (ret) { | |
6694 | vty_out(vty, | |
6695 | "VRF default is not configured as a bgp instance\n"); | |
6696 | return CMD_WARNING; | |
6697 | } | |
6698 | } | |
6699 | ||
69b07479 | 6700 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 6701 | |
69b07479 DS |
6702 | if (yes) { |
6703 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6704 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6705 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6706 | bgp->vpn_policy[afi].rmap_name[dir] = | |
6707 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
6708 | bgp->vpn_policy[afi].rmap[dir] = | |
6709 | route_map_lookup_by_name(rmap_str); | |
6710 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
6711 | return CMD_SUCCESS; | |
6712 | } else { | |
6713 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6714 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6715 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6716 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
6717 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
bb4f6190 DS |
6718 | } |
6719 | ||
69b07479 DS |
6720 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
6721 | ||
bb4f6190 DS |
6722 | return CMD_SUCCESS; |
6723 | } | |
6724 | ||
6725 | ALIAS(af_import_vrf_route_map, af_no_import_vrf_route_map_cmd, | |
6726 | "no import vrf route-map", | |
6727 | NO_STR | |
6728 | "Import routes from another VRF\n" | |
6729 | "Vrf routes being filtered\n" | |
6730 | "Specify route map\n") | |
6731 | ||
12a844a5 DS |
6732 | DEFPY (bgp_imexport_vrf, |
6733 | bgp_imexport_vrf_cmd, | |
6734 | "[no] import vrf NAME$import_name", | |
6735 | NO_STR | |
6736 | "Import routes from another VRF\n" | |
6737 | "VRF to import from\n" | |
6738 | "The name of the VRF\n") | |
6739 | { | |
6740 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6741 | struct listnode *node; | |
79ef8664 DS |
6742 | struct bgp *vrf_bgp, *bgp_default; |
6743 | int32_t ret = 0; | |
6744 | as_t as = bgp->as; | |
12a844a5 DS |
6745 | bool remove = false; |
6746 | int32_t idx = 0; | |
6747 | char *vname; | |
a8dadcf6 | 6748 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; |
12a844a5 DS |
6749 | safi_t safi; |
6750 | afi_t afi; | |
6751 | ||
867f0cca | 6752 | if (import_name == NULL) { |
6753 | vty_out(vty, "%% Missing import name\n"); | |
6754 | return CMD_WARNING; | |
6755 | } | |
6756 | ||
12a844a5 DS |
6757 | if (argv_find(argv, argc, "no", &idx)) |
6758 | remove = true; | |
6759 | ||
0ca70ba5 DS |
6760 | afi = vpn_policy_getafi(vty, bgp, true); |
6761 | if (afi == AFI_MAX) | |
6762 | return CMD_WARNING_CONFIG_FAILED; | |
6763 | ||
12a844a5 DS |
6764 | safi = bgp_node_safi(vty); |
6765 | ||
25679caa DS |
6766 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) |
6767 | && (strcmp(import_name, BGP_DEFAULT_NAME) == 0)) | |
6768 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { | |
6769 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
6770 | remove ? "unimport" : "import", import_name); | |
6771 | return CMD_WARNING; | |
6772 | } | |
6773 | ||
79ef8664 DS |
6774 | bgp_default = bgp_get_default(); |
6775 | if (!bgp_default) { | |
6776 | /* Auto-create assuming the same AS */ | |
6777 | ret = bgp_get(&bgp_default, &as, NULL, | |
6778 | BGP_INSTANCE_TYPE_DEFAULT); | |
6779 | ||
6780 | if (ret) { | |
6781 | vty_out(vty, | |
6782 | "VRF default is not configured as a bgp instance\n"); | |
6783 | return CMD_WARNING; | |
6784 | } | |
6785 | } | |
6786 | ||
12a844a5 DS |
6787 | vrf_bgp = bgp_lookup_by_name(import_name); |
6788 | if (!vrf_bgp) { | |
79ef8664 DS |
6789 | if (strcmp(import_name, BGP_DEFAULT_NAME) == 0) |
6790 | vrf_bgp = bgp_default; | |
6791 | else | |
0fb8d6e6 DS |
6792 | /* Auto-create assuming the same AS */ |
6793 | ret = bgp_get(&vrf_bgp, &as, import_name, bgp_type); | |
a8dadcf6 | 6794 | |
6e2c7fe6 | 6795 | if (ret) { |
020a3f60 DS |
6796 | vty_out(vty, |
6797 | "VRF %s is not configured as a bgp instance\n", | |
6e2c7fe6 DS |
6798 | import_name); |
6799 | return CMD_WARNING; | |
6800 | } | |
12a844a5 DS |
6801 | } |
6802 | ||
12a844a5 | 6803 | if (remove) { |
44338987 | 6804 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 | 6805 | } else { |
44338987 | 6806 | /* Already importing from "import_vrf"? */ |
12a844a5 DS |
6807 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, |
6808 | vname)) { | |
6809 | if (strcmp(vname, import_name) == 0) | |
6810 | return CMD_WARNING; | |
6811 | } | |
6812 | ||
44338987 | 6813 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 DS |
6814 | } |
6815 | ||
6816 | return CMD_SUCCESS; | |
6817 | } | |
6818 | ||
b9c7bc5a PZ |
6819 | /* This command is valid only in a bgp vrf instance or the default instance */ |
6820 | DEFPY (bgp_imexport_vpn, | |
6821 | bgp_imexport_vpn_cmd, | |
6822 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
6823 | NO_STR |
6824 | "Import routes to this address-family\n" | |
6825 | "Export routes from this address-family\n" | |
6826 | "to/from default instance VPN RIB\n") | |
ddb5b488 PZ |
6827 | { |
6828 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 6829 | int previous_state; |
ddb5b488 | 6830 | afi_t afi; |
b9c7bc5a | 6831 | safi_t safi; |
ddb5b488 | 6832 | int idx = 0; |
b9c7bc5a PZ |
6833 | int yes = 1; |
6834 | int flag; | |
6835 | vpn_policy_direction_t dir; | |
ddb5b488 | 6836 | |
b9c7bc5a | 6837 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6838 | yes = 0; |
ddb5b488 | 6839 | |
b9c7bc5a PZ |
6840 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && |
6841 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
ddb5b488 | 6842 | |
b9c7bc5a PZ |
6843 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); |
6844 | return CMD_WARNING_CONFIG_FAILED; | |
6845 | } | |
ddb5b488 | 6846 | |
b9c7bc5a PZ |
6847 | afi = bgp_node_afi(vty); |
6848 | safi = bgp_node_safi(vty); | |
6849 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { | |
6850 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
6851 | return CMD_WARNING_CONFIG_FAILED; | |
6852 | } | |
ddb5b488 | 6853 | |
b9c7bc5a PZ |
6854 | if (!strcmp(direction_str, "import")) { |
6855 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; | |
6856 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
6857 | } else if (!strcmp(direction_str, "export")) { | |
6858 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; | |
6859 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
6860 | } else { | |
6861 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
6862 | return CMD_WARNING_CONFIG_FAILED; | |
6863 | } | |
6864 | ||
6865 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 | 6866 | |
b9c7bc5a PZ |
6867 | if (yes) { |
6868 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
6869 | if (!previous_state) { | |
6870 | /* trigger export current vrf */ | |
ddb5b488 PZ |
6871 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
6872 | } | |
b9c7bc5a PZ |
6873 | } else { |
6874 | if (previous_state) { | |
6875 | /* trigger un-export current vrf */ | |
6876 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
6877 | } | |
6878 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 PZ |
6879 | } |
6880 | ||
6881 | return CMD_SUCCESS; | |
6882 | } | |
6883 | ||
301ad80a PG |
6884 | DEFPY (af_routetarget_import, |
6885 | af_routetarget_import_cmd, | |
6886 | "[no] <rt|route-target> redirect import RTLIST...", | |
6887 | NO_STR | |
6888 | "Specify route target list\n" | |
6889 | "Specify route target list\n" | |
6890 | "Flow-spec redirect type route target\n" | |
6891 | "Import routes to this address-family\n" | |
6892 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") | |
6893 | { | |
6894 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6895 | int ret; | |
6896 | struct ecommunity *ecom = NULL; | |
301ad80a PG |
6897 | afi_t afi; |
6898 | int idx = 0; | |
6899 | int yes = 1; | |
6900 | ||
6901 | if (argv_find(argv, argc, "no", &idx)) | |
6902 | yes = 0; | |
6903 | ||
0ca70ba5 | 6904 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6905 | if (afi == AFI_MAX) |
6906 | return CMD_WARNING_CONFIG_FAILED; | |
6907 | ||
301ad80a PG |
6908 | if (yes) { |
6909 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
6910 | vty_out(vty, "%% Missing RTLIST\n"); | |
6911 | return CMD_WARNING_CONFIG_FAILED; | |
6912 | } | |
6913 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
6914 | if (ret != CMD_SUCCESS) | |
6915 | return ret; | |
6916 | } | |
69b07479 DS |
6917 | |
6918 | if (yes) { | |
6919 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
6920 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 6921 | .import_redirect_rtlist); |
69b07479 DS |
6922 | bgp->vpn_policy[afi].import_redirect_rtlist = |
6923 | ecommunity_dup(ecom); | |
6924 | } else { | |
6925 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
6926 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 6927 | .import_redirect_rtlist); |
69b07479 | 6928 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 6929 | } |
69b07479 | 6930 | |
301ad80a PG |
6931 | if (ecom) |
6932 | ecommunity_free(&ecom); | |
6933 | ||
6934 | return CMD_SUCCESS; | |
6935 | } | |
6936 | ||
505e5056 | 6937 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 6938 | address_family_ipv4_safi_cmd, |
6939 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
6940 | "Enter Address Family command mode\n" | |
6941 | "Address Family\n" | |
6942 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
718e3744 | 6943 | { |
f51bae9c | 6944 | |
d62a17ae | 6945 | if (argc == 3) { |
2131d5cf | 6946 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 6947 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
6948 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
6949 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 6950 | && safi != SAFI_EVPN) { |
31947174 MK |
6951 | vty_out(vty, |
6952 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
6953 | return CMD_WARNING_CONFIG_FAILED; |
6954 | } | |
d62a17ae | 6955 | vty->node = bgp_node_type(AFI_IP, safi); |
6956 | } else | |
6957 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 6958 | |
d62a17ae | 6959 | return CMD_SUCCESS; |
718e3744 | 6960 | } |
6961 | ||
505e5056 | 6962 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 6963 | address_family_ipv6_safi_cmd, |
6964 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
6965 | "Enter Address Family command mode\n" | |
6966 | "Address Family\n" | |
6967 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
25ffbdc1 | 6968 | { |
d62a17ae | 6969 | if (argc == 3) { |
2131d5cf | 6970 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 6971 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
6972 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
6973 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 6974 | && safi != SAFI_EVPN) { |
31947174 MK |
6975 | vty_out(vty, |
6976 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
6977 | return CMD_WARNING_CONFIG_FAILED; |
6978 | } | |
d62a17ae | 6979 | vty->node = bgp_node_type(AFI_IP6, safi); |
6980 | } else | |
6981 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 6982 | |
d62a17ae | 6983 | return CMD_SUCCESS; |
25ffbdc1 | 6984 | } |
718e3744 | 6985 | |
d6902373 | 6986 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 6987 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 6988 | address_family_vpnv4_cmd, |
8334fd5a | 6989 | "address-family vpnv4 [unicast]", |
718e3744 | 6990 | "Enter Address Family command mode\n" |
8c3deaae | 6991 | "Address Family\n" |
3a2d747c | 6992 | "Address Family modifier\n") |
718e3744 | 6993 | { |
d62a17ae | 6994 | vty->node = BGP_VPNV4_NODE; |
6995 | return CMD_SUCCESS; | |
718e3744 | 6996 | } |
6997 | ||
505e5056 | 6998 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 6999 | address_family_vpnv6_cmd, |
8334fd5a | 7000 | "address-family vpnv6 [unicast]", |
8ecd3266 | 7001 | "Enter Address Family command mode\n" |
8c3deaae | 7002 | "Address Family\n" |
3a2d747c | 7003 | "Address Family modifier\n") |
8ecd3266 | 7004 | { |
d62a17ae | 7005 | vty->node = BGP_VPNV6_NODE; |
7006 | return CMD_SUCCESS; | |
8ecd3266 | 7007 | } |
c016b6c7 | 7008 | #endif |
d6902373 | 7009 | |
505e5056 | 7010 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 7011 | address_family_evpn_cmd, |
7111c1a0 | 7012 | "address-family l2vpn evpn", |
4e0b7b6d | 7013 | "Enter Address Family command mode\n" |
7111c1a0 QY |
7014 | "Address Family\n" |
7015 | "Address Family modifier\n") | |
4e0b7b6d | 7016 | { |
2131d5cf | 7017 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7018 | vty->node = BGP_EVPN_NODE; |
7019 | return CMD_SUCCESS; | |
4e0b7b6d PG |
7020 | } |
7021 | ||
505e5056 | 7022 | DEFUN_NOSH (exit_address_family, |
718e3744 | 7023 | exit_address_family_cmd, |
7024 | "exit-address-family", | |
7025 | "Exit from Address Family configuration mode\n") | |
7026 | { | |
d62a17ae | 7027 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
7028 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
7029 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
7030 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
7031 | || vty->node == BGP_EVPN_NODE |
7032 | || vty->node == BGP_FLOWSPECV4_NODE | |
7033 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 7034 | vty->node = BGP_NODE; |
7035 | return CMD_SUCCESS; | |
718e3744 | 7036 | } |
6b0655a2 | 7037 | |
8ad7271d | 7038 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 7039 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
7040 | const char *ip_str, afi_t afi, safi_t safi, | |
7041 | struct prefix_rd *prd) | |
7042 | { | |
7043 | int ret; | |
7044 | struct prefix match; | |
7045 | struct bgp_node *rn; | |
7046 | struct bgp_node *rm; | |
7047 | struct bgp *bgp; | |
7048 | struct bgp_table *table; | |
7049 | struct bgp_table *rib; | |
7050 | ||
7051 | /* BGP structure lookup. */ | |
7052 | if (view_name) { | |
7053 | bgp = bgp_lookup_by_name(view_name); | |
7054 | if (bgp == NULL) { | |
7055 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
7056 | view_name); | |
7057 | return CMD_WARNING; | |
7058 | } | |
7059 | } else { | |
7060 | bgp = bgp_get_default(); | |
7061 | if (bgp == NULL) { | |
7062 | vty_out(vty, "%% No BGP process is configured\n"); | |
7063 | return CMD_WARNING; | |
7064 | } | |
7065 | } | |
7066 | ||
7067 | /* Check IP address argument. */ | |
7068 | ret = str2prefix(ip_str, &match); | |
7069 | if (!ret) { | |
7070 | vty_out(vty, "%% address is malformed\n"); | |
7071 | return CMD_WARNING; | |
7072 | } | |
7073 | ||
7074 | match.family = afi2family(afi); | |
7075 | rib = bgp->rib[afi][safi]; | |
7076 | ||
7077 | if (safi == SAFI_MPLS_VPN) { | |
7078 | for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) { | |
7079 | if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0) | |
7080 | continue; | |
7081 | ||
7082 | if ((table = rn->info) != NULL) { | |
7083 | if ((rm = bgp_node_match(table, &match)) | |
7084 | != NULL) { | |
7085 | if (rm->p.prefixlen | |
7086 | == match.prefixlen) { | |
343cdb61 | 7087 | SET_FLAG(rm->flags, |
d62a17ae | 7088 | BGP_NODE_USER_CLEAR); |
7089 | bgp_process(bgp, rm, afi, safi); | |
7090 | } | |
7091 | bgp_unlock_node(rm); | |
7092 | } | |
7093 | } | |
7094 | } | |
7095 | } else { | |
7096 | if ((rn = bgp_node_match(rib, &match)) != NULL) { | |
7097 | if (rn->p.prefixlen == match.prefixlen) { | |
7098 | SET_FLAG(rn->flags, BGP_NODE_USER_CLEAR); | |
7099 | bgp_process(bgp, rn, afi, safi); | |
7100 | } | |
7101 | bgp_unlock_node(rn); | |
7102 | } | |
7103 | } | |
7104 | ||
7105 | return CMD_SUCCESS; | |
8ad7271d DS |
7106 | } |
7107 | ||
b09b5ae0 | 7108 | /* one clear bgp command to rule them all */ |
718e3744 | 7109 | DEFUN (clear_ip_bgp_all, |
7110 | clear_ip_bgp_all_cmd, | |
c1a44e43 | 7111 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> [<soft [<in|out>]|in [prefix-filter]|out>]", |
718e3744 | 7112 | CLEAR_STR |
7113 | IP_STR | |
7114 | BGP_STR | |
838758ac | 7115 | BGP_INSTANCE_HELP_STR |
510afcd6 DS |
7116 | BGP_AFI_HELP_STR |
7117 | BGP_SAFI_WITH_LABEL_HELP_STR | |
b09b5ae0 DW |
7118 | "Clear all peers\n" |
7119 | "BGP neighbor address to clear\n" | |
a80beece | 7120 | "BGP IPv6 neighbor to clear\n" |
838758ac | 7121 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
7122 | "Clear peers with the AS number\n" |
7123 | "Clear all external peers\n" | |
718e3744 | 7124 | "Clear all members of peer-group\n" |
b09b5ae0 | 7125 | "BGP peer-group name\n" |
b09b5ae0 DW |
7126 | BGP_SOFT_STR |
7127 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
7128 | BGP_SOFT_OUT_STR |
7129 | BGP_SOFT_IN_STR | |
7130 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 7131 | BGP_SOFT_OUT_STR) |
718e3744 | 7132 | { |
d62a17ae | 7133 | char *vrf = NULL; |
7134 | ||
7135 | afi_t afi = AFI_IP6; | |
7136 | safi_t safi = SAFI_UNICAST; | |
7137 | enum clear_sort clr_sort = clear_peer; | |
7138 | enum bgp_clear_type clr_type; | |
7139 | char *clr_arg = NULL; | |
7140 | ||
7141 | int idx = 0; | |
7142 | ||
7143 | /* clear [ip] bgp */ | |
7144 | if (argv_find(argv, argc, "ip", &idx)) | |
7145 | afi = AFI_IP; | |
7146 | ||
7147 | /* [<view|vrf> VIEWVRFNAME] */ | |
7148 | if (argv_find(argv, argc, "view", &idx) | |
7149 | || argv_find(argv, argc, "vrf", &idx)) { | |
7150 | vrf = argv[idx + 1]->arg; | |
7151 | idx += 2; | |
7152 | } | |
7153 | ||
7154 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
7155 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
7156 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
7157 | ||
7158 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */ | |
7159 | if (argv_find(argv, argc, "*", &idx)) { | |
7160 | clr_sort = clear_all; | |
7161 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
7162 | clr_sort = clear_peer; | |
7163 | clr_arg = argv[idx]->arg; | |
7164 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
7165 | clr_sort = clear_peer; | |
7166 | clr_arg = argv[idx]->arg; | |
7167 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
7168 | clr_sort = clear_group; | |
7169 | idx++; | |
7170 | clr_arg = argv[idx]->arg; | |
7171 | } else if (argv_find(argv, argc, "WORD", &idx)) { | |
7172 | clr_sort = clear_peer; | |
7173 | clr_arg = argv[idx]->arg; | |
7174 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { | |
7175 | clr_sort = clear_as; | |
7176 | clr_arg = argv[idx]->arg; | |
7177 | } else if (argv_find(argv, argc, "external", &idx)) { | |
7178 | clr_sort = clear_external; | |
7179 | } | |
7180 | ||
7181 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
7182 | if (argv_find(argv, argc, "soft", &idx)) { | |
7183 | if (argv_find(argv, argc, "in", &idx) | |
7184 | || argv_find(argv, argc, "out", &idx)) | |
7185 | clr_type = strmatch(argv[idx]->text, "in") | |
7186 | ? BGP_CLEAR_SOFT_IN | |
7187 | : BGP_CLEAR_SOFT_OUT; | |
7188 | else | |
7189 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
7190 | } else if (argv_find(argv, argc, "in", &idx)) { | |
7191 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
7192 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
7193 | : BGP_CLEAR_SOFT_IN; | |
7194 | } else if (argv_find(argv, argc, "out", &idx)) { | |
7195 | clr_type = BGP_CLEAR_SOFT_OUT; | |
7196 | } else | |
7197 | clr_type = BGP_CLEAR_SOFT_NONE; | |
7198 | ||
7199 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); | |
838758ac | 7200 | } |
01080f7c | 7201 | |
8ad7271d DS |
7202 | DEFUN (clear_ip_bgp_prefix, |
7203 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 7204 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
7205 | CLEAR_STR |
7206 | IP_STR | |
7207 | BGP_STR | |
838758ac | 7208 | BGP_INSTANCE_HELP_STR |
8ad7271d | 7209 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7210 | "IPv4 prefix\n") |
8ad7271d | 7211 | { |
d62a17ae | 7212 | char *vrf = NULL; |
7213 | char *prefix = NULL; | |
8ad7271d | 7214 | |
d62a17ae | 7215 | int idx = 0; |
01080f7c | 7216 | |
d62a17ae | 7217 | /* [<view|vrf> VIEWVRFNAME] */ |
1d35f218 | 7218 | if (argv_find(argv, argc, "VIEWVRFNAME", &idx)) |
d62a17ae | 7219 | vrf = argv[idx]->arg; |
0c7b1b01 | 7220 | |
d62a17ae | 7221 | prefix = argv[argc - 1]->arg; |
8ad7271d | 7222 | |
d62a17ae | 7223 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 7224 | } |
8ad7271d | 7225 | |
b09b5ae0 DW |
7226 | DEFUN (clear_bgp_ipv6_safi_prefix, |
7227 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 7228 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 7229 | CLEAR_STR |
3a2d747c | 7230 | IP_STR |
718e3744 | 7231 | BGP_STR |
8c3deaae | 7232 | "Address Family\n" |
46f296b4 | 7233 | BGP_SAFI_HELP_STR |
b09b5ae0 | 7234 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7235 | "IPv6 prefix\n") |
718e3744 | 7236 | { |
9b475e76 PG |
7237 | int idx_safi = 0; |
7238 | int idx_ipv6_prefix = 0; | |
7239 | safi_t safi = SAFI_UNICAST; | |
7240 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
7241 | argv[idx_ipv6_prefix]->arg : NULL; | |
7242 | ||
7243 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 7244 | return bgp_clear_prefix( |
9b475e76 PG |
7245 | vty, NULL, prefix, AFI_IP6, |
7246 | safi, NULL); | |
838758ac | 7247 | } |
01080f7c | 7248 | |
b09b5ae0 DW |
7249 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
7250 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 7251 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 7252 | CLEAR_STR |
3a2d747c | 7253 | IP_STR |
718e3744 | 7254 | BGP_STR |
838758ac | 7255 | BGP_INSTANCE_HELP_STR |
8c3deaae | 7256 | "Address Family\n" |
46f296b4 | 7257 | BGP_SAFI_HELP_STR |
b09b5ae0 | 7258 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7259 | "IPv6 prefix\n") |
718e3744 | 7260 | { |
d62a17ae | 7261 | int idx_word = 3; |
9b475e76 PG |
7262 | int idx_safi = 0; |
7263 | int idx_ipv6_prefix = 0; | |
7264 | safi_t safi = SAFI_UNICAST; | |
7265 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
7266 | argv[idx_ipv6_prefix]->arg : NULL; | |
7267 | /* [<view|vrf> VIEWVRFNAME] */ | |
7268 | char *vrfview = argv_find(argv, argc, "VIEWVRFNAME", &idx_word) ? | |
7269 | argv[idx_word]->arg : NULL; | |
7270 | ||
7271 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
7272 | ||
d62a17ae | 7273 | return bgp_clear_prefix( |
9b475e76 PG |
7274 | vty, vrfview, prefix, |
7275 | AFI_IP6, safi, NULL); | |
718e3744 | 7276 | } |
7277 | ||
b09b5ae0 DW |
7278 | DEFUN (show_bgp_views, |
7279 | show_bgp_views_cmd, | |
d6e3c605 | 7280 | "show [ip] bgp views", |
b09b5ae0 | 7281 | SHOW_STR |
d6e3c605 | 7282 | IP_STR |
01080f7c | 7283 | BGP_STR |
b09b5ae0 | 7284 | "Show the defined BGP views\n") |
01080f7c | 7285 | { |
d62a17ae | 7286 | struct list *inst = bm->bgp; |
7287 | struct listnode *node; | |
7288 | struct bgp *bgp; | |
01080f7c | 7289 | |
d62a17ae | 7290 | if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE)) { |
7291 | vty_out(vty, "BGP Multiple Instance is not enabled\n"); | |
7292 | return CMD_WARNING; | |
7293 | } | |
e52702f2 | 7294 | |
d62a17ae | 7295 | vty_out(vty, "Defined BGP views:\n"); |
7296 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
7297 | /* Skip VRFs. */ | |
7298 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
7299 | continue; | |
7300 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
7301 | bgp->as); | |
7302 | } | |
e52702f2 | 7303 | |
d62a17ae | 7304 | return CMD_SUCCESS; |
e0081f70 ML |
7305 | } |
7306 | ||
8386ac43 | 7307 | DEFUN (show_bgp_vrfs, |
7308 | show_bgp_vrfs_cmd, | |
d6e3c605 | 7309 | "show [ip] bgp vrfs [json]", |
8386ac43 | 7310 | SHOW_STR |
d6e3c605 | 7311 | IP_STR |
8386ac43 | 7312 | BGP_STR |
7313 | "Show BGP VRFs\n" | |
9973d184 | 7314 | JSON_STR) |
8386ac43 | 7315 | { |
fe1dc5a3 | 7316 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 7317 | struct list *inst = bm->bgp; |
7318 | struct listnode *node; | |
7319 | struct bgp *bgp; | |
d7c0a89a | 7320 | uint8_t uj = use_json(argc, argv); |
d62a17ae | 7321 | json_object *json = NULL; |
7322 | json_object *json_vrfs = NULL; | |
7323 | int count = 0; | |
d62a17ae | 7324 | |
7325 | if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE)) { | |
7326 | vty_out(vty, "BGP Multiple Instance is not enabled\n"); | |
7327 | return CMD_WARNING; | |
7328 | } | |
7329 | ||
7330 | if (uj) { | |
7331 | json = json_object_new_object(); | |
7332 | json_vrfs = json_object_new_object(); | |
7333 | } | |
7334 | ||
7335 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
7336 | const char *name, *type; | |
7337 | struct peer *peer; | |
7338 | struct listnode *node, *nnode; | |
7339 | int peers_cfg, peers_estb; | |
7340 | json_object *json_vrf = NULL; | |
d62a17ae | 7341 | |
7342 | /* Skip Views. */ | |
7343 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
7344 | continue; | |
7345 | ||
7346 | count++; | |
7347 | if (!uj && count == 1) | |
fe1dc5a3 MK |
7348 | vty_out(vty, |
7349 | "%4s %-5s %-16s %9s %10s %-37s %-10s %-15s\n", | |
a4d82a8a PZ |
7350 | "Type", "Id", "routerId", "#PeersVfg", |
7351 | "#PeersEstb", "Name", "L3-VNI", "Rmac"); | |
d62a17ae | 7352 | |
7353 | peers_cfg = peers_estb = 0; | |
7354 | if (uj) | |
7355 | json_vrf = json_object_new_object(); | |
7356 | ||
7357 | ||
7358 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
7359 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
7360 | continue; | |
7361 | peers_cfg++; | |
7362 | if (peer->status == Established) | |
7363 | peers_estb++; | |
7364 | } | |
7365 | ||
7366 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
7367 | name = "Default"; | |
7368 | type = "DFLT"; | |
7369 | } else { | |
7370 | name = bgp->name; | |
7371 | type = "VRF"; | |
7372 | } | |
7373 | ||
a8bf7d9c | 7374 | |
d62a17ae | 7375 | if (uj) { |
a4d82a8a PZ |
7376 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
7377 | ? -1 | |
7378 | : (int64_t)bgp->vrf_id; | |
d62a17ae | 7379 | json_object_string_add(json_vrf, "type", type); |
7380 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
7381 | json_object_string_add(json_vrf, "routerId", | |
7382 | inet_ntoa(bgp->router_id)); | |
7383 | json_object_int_add(json_vrf, "numConfiguredPeers", | |
7384 | peers_cfg); | |
7385 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
7386 | peers_estb); | |
7387 | ||
fe1dc5a3 | 7388 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
7389 | json_object_string_add( |
7390 | json_vrf, "rmac", | |
7391 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
d62a17ae | 7392 | json_object_object_add(json_vrfs, name, json_vrf); |
7393 | } else | |
fe1dc5a3 MK |
7394 | vty_out(vty, |
7395 | "%4s %-5d %-16s %9u %10u %-37s %-10u %-15s\n", | |
a4d82a8a PZ |
7396 | type, |
7397 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
7398 | : (int)bgp->vrf_id, | |
7399 | inet_ntoa(bgp->router_id), peers_cfg, | |
7400 | peers_estb, name, bgp->l3vni, | |
fe1dc5a3 | 7401 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); |
d62a17ae | 7402 | } |
7403 | ||
7404 | if (uj) { | |
7405 | json_object_object_add(json, "vrfs", json_vrfs); | |
7406 | ||
7407 | json_object_int_add(json, "totalVrfs", count); | |
7408 | ||
996c9314 LB |
7409 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
7410 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 7411 | json_object_free(json); |
7412 | } else { | |
7413 | if (count) | |
7414 | vty_out(vty, | |
7415 | "\nTotal number of VRFs (including default): %d\n", | |
7416 | count); | |
7417 | } | |
7418 | ||
7419 | return CMD_SUCCESS; | |
8386ac43 | 7420 | } |
7421 | ||
acf71666 MK |
7422 | static void show_address_entry(struct hash_backet *backet, void *args) |
7423 | { | |
60466a63 QY |
7424 | struct vty *vty = (struct vty *)args; |
7425 | struct bgp_addr *addr = (struct bgp_addr *)backet->data; | |
acf71666 | 7426 | |
60466a63 | 7427 | vty_out(vty, "addr: %s, count: %d\n", inet_ntoa(addr->addr), |
acf71666 MK |
7428 | addr->refcnt); |
7429 | } | |
7430 | ||
7431 | static void show_tip_entry(struct hash_backet *backet, void *args) | |
7432 | { | |
0291c246 | 7433 | struct vty *vty = (struct vty *)args; |
60466a63 | 7434 | struct tip_addr *tip = (struct tip_addr *)backet->data; |
acf71666 | 7435 | |
60466a63 | 7436 | vty_out(vty, "addr: %s, count: %d\n", inet_ntoa(tip->addr), |
acf71666 MK |
7437 | tip->refcnt); |
7438 | } | |
7439 | ||
7440 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
7441 | { | |
7442 | vty_out(vty, "self nexthop database:\n"); | |
7443 | hash_iterate(bgp->address_hash, | |
7444 | (void (*)(struct hash_backet *, void *))show_address_entry, | |
7445 | vty); | |
7446 | ||
7447 | vty_out(vty, "Tunnel-ip database:\n"); | |
7448 | hash_iterate(bgp->tip_hash, | |
7449 | (void (*)(struct hash_backet *, void *))show_tip_entry, | |
7450 | vty); | |
7451 | } | |
7452 | ||
15c81ca4 DS |
7453 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
7454 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
7455 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
7456 | "martian next-hops\n" |
7457 | "martian next-hop database\n") | |
acf71666 | 7458 | { |
0291c246 | 7459 | struct bgp *bgp = NULL; |
15c81ca4 DS |
7460 | int idx = 0; |
7461 | ||
7462 | if (argv_find(argv, argc, "view", &idx) | |
7463 | || argv_find(argv, argc, "vrf", &idx)) | |
7464 | bgp = bgp_lookup_by_name(argv[idx + 1]->arg); | |
7465 | else | |
7466 | bgp = bgp_get_default(); | |
acf71666 | 7467 | |
acf71666 MK |
7468 | if (!bgp) { |
7469 | vty_out(vty, "%% No BGP process is configured\n"); | |
7470 | return CMD_WARNING; | |
7471 | } | |
7472 | bgp_show_martian_nexthops(vty, bgp); | |
7473 | ||
7474 | return CMD_SUCCESS; | |
7475 | } | |
7476 | ||
f412b39a | 7477 | DEFUN (show_bgp_memory, |
4bf6a362 | 7478 | show_bgp_memory_cmd, |
7fa12b13 | 7479 | "show [ip] bgp memory", |
4bf6a362 | 7480 | SHOW_STR |
3a2d747c | 7481 | IP_STR |
4bf6a362 PJ |
7482 | BGP_STR |
7483 | "Global BGP memory statistics\n") | |
7484 | { | |
d62a17ae | 7485 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
7486 | unsigned long count; | |
7487 | ||
7488 | /* RIB related usage stats */ | |
7489 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
7490 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
7491 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7492 | count * sizeof(struct bgp_node))); | |
7493 | ||
7494 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
7495 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
7496 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7497 | count * sizeof(struct bgp_info))); | |
7498 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) | |
7499 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
7500 | count, | |
7501 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7502 | count * sizeof(struct bgp_info_extra))); | |
7503 | ||
7504 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
7505 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
7506 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7507 | count * sizeof(struct bgp_static))); | |
7508 | ||
7509 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
7510 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
7511 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7512 | count * sizeof(struct bpacket))); | |
7513 | ||
7514 | /* Adj-In/Out */ | |
7515 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
7516 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
7517 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7518 | count * sizeof(struct bgp_adj_in))); | |
7519 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
7520 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
7521 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7522 | count * sizeof(struct bgp_adj_out))); | |
7523 | ||
7524 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
7525 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
7526 | count, | |
7527 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7528 | count * sizeof(struct bgp_nexthop_cache))); | |
7529 | ||
7530 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
7531 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
7532 | count, | |
7533 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7534 | count * sizeof(struct bgp_damp_info))); | |
7535 | ||
7536 | /* Attributes */ | |
7537 | count = attr_count(); | |
7538 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
7539 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7540 | count * sizeof(struct attr))); | |
7541 | ||
7542 | if ((count = attr_unknown_count())) | |
7543 | vty_out(vty, "%ld unknown attributes\n", count); | |
7544 | ||
7545 | /* AS_PATH attributes */ | |
7546 | count = aspath_count(); | |
7547 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
7548 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7549 | count * sizeof(struct aspath))); | |
7550 | ||
7551 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
7552 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
7553 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7554 | count * sizeof(struct assegment))); | |
7555 | ||
7556 | /* Other attributes */ | |
7557 | if ((count = community_count())) | |
7558 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
7559 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7560 | count * sizeof(struct community))); | |
d62a17ae | 7561 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
7562 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
7563 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7564 | count * sizeof(struct ecommunity))); | |
d62a17ae | 7565 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
7566 | vty_out(vty, | |
7567 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
7568 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7569 | count * sizeof(struct lcommunity))); | |
d62a17ae | 7570 | |
7571 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
7572 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
7573 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7574 | count * sizeof(struct cluster_list))); | |
7575 | ||
7576 | /* Peer related usage */ | |
7577 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
7578 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
7579 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7580 | count * sizeof(struct peer))); | |
7581 | ||
7582 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
7583 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
7584 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7585 | count * sizeof(struct peer_group))); | |
7586 | ||
7587 | /* Other */ | |
7588 | if ((count = mtype_stats_alloc(MTYPE_HASH))) | |
7589 | vty_out(vty, "%ld hash tables, using %s of memory\n", count, | |
7590 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7591 | count * sizeof(struct hash))); | |
7592 | if ((count = mtype_stats_alloc(MTYPE_HASH_BACKET))) | |
7593 | vty_out(vty, "%ld hash buckets, using %s of memory\n", count, | |
7594 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7595 | count * sizeof(struct hash_backet))); | |
7596 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) | |
7597 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
7598 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7599 | count * sizeof(regex_t))); | |
d62a17ae | 7600 | return CMD_SUCCESS; |
4bf6a362 | 7601 | } |
fee0f4c6 | 7602 | |
57a9c8a8 DS |
7603 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
7604 | { | |
7605 | json_object *bestpath = json_object_new_object(); | |
7606 | ||
7607 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_IGNORE)) | |
7608 | json_object_string_add(bestpath, "asPath", "ignore"); | |
7609 | ||
7610 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_CONFED)) | |
7611 | json_object_string_add(bestpath, "asPath", "confed"); | |
7612 | ||
7613 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { | |
a4d82a8a PZ |
7614 | if (bgp_flag_check(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) |
7615 | json_object_string_add(bestpath, "multiPathRelax", | |
57a9c8a8 DS |
7616 | "as-set"); |
7617 | else | |
a4d82a8a | 7618 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
7619 | "true"); |
7620 | } else | |
a4d82a8a | 7621 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 DS |
7622 | |
7623 | if (bgp_flag_check(bgp, BGP_FLAG_COMPARE_ROUTER_ID)) | |
7624 | json_object_string_add(bestpath, "compareRouterId", "true"); | |
7625 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED) | |
7626 | || bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
7627 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 7628 | json_object_string_add(bestpath, "med", "confed"); |
57a9c8a8 DS |
7629 | if (bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) |
7630 | json_object_string_add(bestpath, "med", | |
7631 | "missing-as-worst"); | |
7632 | else | |
7633 | json_object_string_add(bestpath, "med", "true"); | |
7634 | } | |
7635 | ||
7636 | json_object_object_add(json, "bestPath", bestpath); | |
7637 | } | |
7638 | ||
718e3744 | 7639 | /* Show BGP peer's summary information. */ |
d62a17ae | 7640 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
d7c0a89a | 7641 | uint8_t use_json, json_object *json) |
d62a17ae | 7642 | { |
7643 | struct peer *peer; | |
7644 | struct listnode *node, *nnode; | |
7645 | unsigned int count = 0, dn_count = 0; | |
7646 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
7647 | char neighbor_buf[VTY_BUFSIZ]; | |
7648 | int neighbor_col_default_width = 16; | |
7649 | int len; | |
7650 | int max_neighbor_width = 0; | |
7651 | int pfx_rcd_safi; | |
7652 | json_object *json_peer = NULL; | |
7653 | json_object *json_peers = NULL; | |
7654 | ||
7655 | /* labeled-unicast routes are installed in the unicast table so in order | |
7656 | * to | |
7657 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
7658 | */ | |
7659 | if (safi == SAFI_LABELED_UNICAST) | |
7660 | pfx_rcd_safi = SAFI_UNICAST; | |
7661 | else | |
7662 | pfx_rcd_safi = safi; | |
7663 | ||
7664 | if (use_json) { | |
7665 | if (json == NULL) | |
7666 | json = json_object_new_object(); | |
7667 | ||
7668 | json_peers = json_object_new_object(); | |
7669 | } else { | |
7670 | /* Loop over all neighbors that will be displayed to determine | |
7671 | * how many | |
7672 | * characters are needed for the Neighbor column | |
7673 | */ | |
7674 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
7675 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
7676 | continue; | |
7677 | ||
7678 | if (peer->afc[afi][safi]) { | |
7679 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
7680 | if (peer_dynamic_neighbor(peer)) | |
7681 | dn_flag[0] = '*'; | |
7682 | ||
7683 | if (peer->hostname | |
7684 | && bgp_flag_check(bgp, | |
7685 | BGP_FLAG_SHOW_HOSTNAME)) | |
7686 | sprintf(neighbor_buf, "%s%s(%s) ", | |
7687 | dn_flag, peer->hostname, | |
7688 | peer->host); | |
7689 | else | |
7690 | sprintf(neighbor_buf, "%s%s ", dn_flag, | |
7691 | peer->host); | |
7692 | ||
7693 | len = strlen(neighbor_buf); | |
7694 | ||
7695 | if (len > max_neighbor_width) | |
7696 | max_neighbor_width = len; | |
7697 | } | |
7698 | } | |
f933309e | 7699 | |
d62a17ae | 7700 | /* Originally we displayed the Neighbor column as 16 |
7701 | * characters wide so make that the default | |
7702 | */ | |
7703 | if (max_neighbor_width < neighbor_col_default_width) | |
7704 | max_neighbor_width = neighbor_col_default_width; | |
7705 | } | |
f933309e | 7706 | |
d62a17ae | 7707 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
7708 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
7709 | continue; | |
7710 | ||
ea47320b DL |
7711 | if (!peer->afc[afi][safi]) |
7712 | continue; | |
d62a17ae | 7713 | |
ea47320b DL |
7714 | if (!count) { |
7715 | unsigned long ents; | |
7716 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 7717 | int64_t vrf_id_ui; |
d62a17ae | 7718 | |
a4d82a8a PZ |
7719 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
7720 | ? -1 | |
7721 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
7722 | |
7723 | /* Usage summary and header */ | |
7724 | if (use_json) { | |
7725 | json_object_string_add( | |
7726 | json, "routerId", | |
7727 | inet_ntoa(bgp->router_id)); | |
60466a63 QY |
7728 | json_object_int_add(json, "as", bgp->as); |
7729 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
7730 | json_object_string_add( |
7731 | json, "vrfName", | |
7732 | (bgp->inst_type | |
7733 | == BGP_INSTANCE_TYPE_DEFAULT) | |
7734 | ? "Default" | |
7735 | : bgp->name); | |
7736 | } else { | |
7737 | vty_out(vty, | |
7738 | "BGP router identifier %s, local AS number %u vrf-id %d", | |
60466a63 | 7739 | inet_ntoa(bgp->router_id), bgp->as, |
a4d82a8a PZ |
7740 | bgp->vrf_id == VRF_UNKNOWN |
7741 | ? -1 | |
7742 | : (int)bgp->vrf_id); | |
ea47320b DL |
7743 | vty_out(vty, "\n"); |
7744 | } | |
d62a17ae | 7745 | |
ea47320b | 7746 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 7747 | if (use_json) { |
ea47320b | 7748 | json_object_int_add( |
60466a63 | 7749 | json, "updateDelayLimit", |
ea47320b | 7750 | bgp->v_update_delay); |
d62a17ae | 7751 | |
ea47320b DL |
7752 | if (bgp->v_update_delay |
7753 | != bgp->v_establish_wait) | |
d62a17ae | 7754 | json_object_int_add( |
7755 | json, | |
ea47320b DL |
7756 | "updateDelayEstablishWait", |
7757 | bgp->v_establish_wait); | |
d62a17ae | 7758 | |
60466a63 | 7759 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
7760 | json_object_string_add( |
7761 | json, | |
7762 | "updateDelayFirstNeighbor", | |
7763 | bgp->update_delay_begin_time); | |
7764 | json_object_boolean_true_add( | |
7765 | json, | |
7766 | "updateDelayInProgress"); | |
7767 | } else { | |
7768 | if (bgp->update_delay_over) { | |
d62a17ae | 7769 | json_object_string_add( |
7770 | json, | |
7771 | "updateDelayFirstNeighbor", | |
7772 | bgp->update_delay_begin_time); | |
ea47320b | 7773 | json_object_string_add( |
d62a17ae | 7774 | json, |
ea47320b DL |
7775 | "updateDelayBestpathResumed", |
7776 | bgp->update_delay_end_time); | |
7777 | json_object_string_add( | |
d62a17ae | 7778 | json, |
ea47320b DL |
7779 | "updateDelayZebraUpdateResume", |
7780 | bgp->update_delay_zebra_resume_time); | |
7781 | json_object_string_add( | |
7782 | json, | |
7783 | "updateDelayPeerUpdateResume", | |
7784 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 7785 | } |
ea47320b DL |
7786 | } |
7787 | } else { | |
7788 | vty_out(vty, | |
7789 | "Read-only mode update-delay limit: %d seconds\n", | |
7790 | bgp->v_update_delay); | |
7791 | if (bgp->v_update_delay | |
7792 | != bgp->v_establish_wait) | |
d62a17ae | 7793 | vty_out(vty, |
ea47320b DL |
7794 | " Establish wait: %d seconds\n", |
7795 | bgp->v_establish_wait); | |
d62a17ae | 7796 | |
60466a63 | 7797 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
7798 | vty_out(vty, |
7799 | " First neighbor established: %s\n", | |
7800 | bgp->update_delay_begin_time); | |
7801 | vty_out(vty, | |
7802 | " Delay in progress\n"); | |
7803 | } else { | |
7804 | if (bgp->update_delay_over) { | |
d62a17ae | 7805 | vty_out(vty, |
7806 | " First neighbor established: %s\n", | |
7807 | bgp->update_delay_begin_time); | |
7808 | vty_out(vty, | |
ea47320b DL |
7809 | " Best-paths resumed: %s\n", |
7810 | bgp->update_delay_end_time); | |
7811 | vty_out(vty, | |
7812 | " zebra update resumed: %s\n", | |
7813 | bgp->update_delay_zebra_resume_time); | |
7814 | vty_out(vty, | |
7815 | " peers update resumed: %s\n", | |
7816 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 7817 | } |
7818 | } | |
7819 | } | |
ea47320b | 7820 | } |
d62a17ae | 7821 | |
ea47320b DL |
7822 | if (use_json) { |
7823 | if (bgp_maxmed_onstartup_configured(bgp) | |
7824 | && bgp->maxmed_active) | |
7825 | json_object_boolean_true_add( | |
60466a63 | 7826 | json, "maxMedOnStartup"); |
ea47320b DL |
7827 | if (bgp->v_maxmed_admin) |
7828 | json_object_boolean_true_add( | |
60466a63 | 7829 | json, "maxMedAdministrative"); |
d62a17ae | 7830 | |
ea47320b DL |
7831 | json_object_int_add( |
7832 | json, "tableVersion", | |
60466a63 | 7833 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 7834 | |
60466a63 QY |
7835 | ents = bgp_table_count(bgp->rib[afi][safi]); |
7836 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
7837 | json_object_int_add( |
7838 | json, "ribMemory", | |
7839 | ents * sizeof(struct bgp_node)); | |
d62a17ae | 7840 | |
ea47320b | 7841 | ents = listcount(bgp->peer); |
60466a63 QY |
7842 | json_object_int_add(json, "peerCount", ents); |
7843 | json_object_int_add(json, "peerMemory", | |
7844 | ents * sizeof(struct peer)); | |
d62a17ae | 7845 | |
ea47320b DL |
7846 | if ((ents = listcount(bgp->group))) { |
7847 | json_object_int_add( | |
60466a63 | 7848 | json, "peerGroupCount", ents); |
ea47320b DL |
7849 | json_object_int_add( |
7850 | json, "peerGroupMemory", | |
996c9314 LB |
7851 | ents * sizeof(struct |
7852 | peer_group)); | |
ea47320b | 7853 | } |
d62a17ae | 7854 | |
ea47320b DL |
7855 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
7856 | BGP_CONFIG_DAMPENING)) | |
7857 | json_object_boolean_true_add( | |
60466a63 | 7858 | json, "dampeningEnabled"); |
ea47320b DL |
7859 | } else { |
7860 | if (bgp_maxmed_onstartup_configured(bgp) | |
7861 | && bgp->maxmed_active) | |
d62a17ae | 7862 | vty_out(vty, |
ea47320b DL |
7863 | "Max-med on-startup active\n"); |
7864 | if (bgp->v_maxmed_admin) | |
d62a17ae | 7865 | vty_out(vty, |
ea47320b | 7866 | "Max-med administrative active\n"); |
d62a17ae | 7867 | |
60466a63 QY |
7868 | vty_out(vty, "BGP table version %" PRIu64 "\n", |
7869 | bgp_table_version(bgp->rib[afi][safi])); | |
d62a17ae | 7870 | |
60466a63 | 7871 | ents = bgp_table_count(bgp->rib[afi][safi]); |
ea47320b DL |
7872 | vty_out(vty, |
7873 | "RIB entries %ld, using %s of memory\n", | |
7874 | ents, | |
996c9314 LB |
7875 | mtype_memstr(memstrbuf, |
7876 | sizeof(memstrbuf), | |
7877 | ents * sizeof(struct | |
7878 | bgp_node))); | |
ea47320b DL |
7879 | |
7880 | /* Peer related usage */ | |
7881 | ents = listcount(bgp->peer); | |
60466a63 | 7882 | vty_out(vty, "Peers %ld, using %s of memory\n", |
ea47320b DL |
7883 | ents, |
7884 | mtype_memstr( | |
60466a63 QY |
7885 | memstrbuf, sizeof(memstrbuf), |
7886 | ents * sizeof(struct peer))); | |
ea47320b DL |
7887 | |
7888 | if ((ents = listcount(bgp->group))) | |
d62a17ae | 7889 | vty_out(vty, |
ea47320b | 7890 | "Peer groups %ld, using %s of memory\n", |
d62a17ae | 7891 | ents, |
7892 | mtype_memstr( | |
7893 | memstrbuf, | |
7894 | sizeof(memstrbuf), | |
996c9314 LB |
7895 | ents * sizeof(struct |
7896 | peer_group))); | |
d62a17ae | 7897 | |
ea47320b DL |
7898 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
7899 | BGP_CONFIG_DAMPENING)) | |
60466a63 | 7900 | vty_out(vty, "Dampening enabled.\n"); |
ea47320b | 7901 | vty_out(vty, "\n"); |
d62a17ae | 7902 | |
ea47320b DL |
7903 | /* Subtract 8 here because 'Neighbor' is |
7904 | * 8 characters */ | |
7905 | vty_out(vty, "Neighbor"); | |
60466a63 QY |
7906 | vty_out(vty, "%*s", max_neighbor_width - 8, |
7907 | " "); | |
ea47320b DL |
7908 | vty_out(vty, |
7909 | "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n"); | |
d62a17ae | 7910 | } |
ea47320b | 7911 | } |
d62a17ae | 7912 | |
ea47320b | 7913 | count++; |
d62a17ae | 7914 | |
ea47320b DL |
7915 | if (use_json) { |
7916 | json_peer = json_object_new_object(); | |
d62a17ae | 7917 | |
b4e9dcba DD |
7918 | if (peer_dynamic_neighbor(peer)) { |
7919 | dn_count++; | |
60466a63 QY |
7920 | json_object_boolean_true_add(json_peer, |
7921 | "dynamicPeer"); | |
b4e9dcba | 7922 | } |
d62a17ae | 7923 | |
ea47320b | 7924 | if (peer->hostname) |
60466a63 | 7925 | json_object_string_add(json_peer, "hostname", |
ea47320b | 7926 | peer->hostname); |
d62a17ae | 7927 | |
ea47320b | 7928 | if (peer->domainname) |
60466a63 QY |
7929 | json_object_string_add(json_peer, "domainname", |
7930 | peer->domainname); | |
d62a17ae | 7931 | |
60466a63 | 7932 | json_object_int_add(json_peer, "remoteAs", peer->as); |
ea47320b | 7933 | json_object_int_add(json_peer, "version", 4); |
60466a63 | 7934 | json_object_int_add(json_peer, "msgRcvd", |
0112e9e0 | 7935 | PEER_TOTAL_RX(peer)); |
60466a63 | 7936 | json_object_int_add(json_peer, "msgSent", |
0112e9e0 | 7937 | PEER_TOTAL_TX(peer)); |
ea47320b DL |
7938 | |
7939 | json_object_int_add(json_peer, "tableVersion", | |
7940 | peer->version[afi][safi]); | |
7941 | json_object_int_add(json_peer, "outq", | |
7942 | peer->obuf->count); | |
7943 | json_object_int_add(json_peer, "inq", 0); | |
60466a63 QY |
7944 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, |
7945 | use_json, json_peer); | |
7946 | json_object_int_add(json_peer, "prefixReceivedCount", | |
7947 | peer->pcount[afi][pfx_rcd_safi]); | |
d62a17ae | 7948 | |
ea47320b | 7949 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) |
60466a63 | 7950 | json_object_string_add(json_peer, "state", |
ea47320b | 7951 | "Idle (Admin)"); |
9199a725 TM |
7952 | else if (peer->afc_recv[afi][safi]) |
7953 | json_object_string_add( | |
7954 | json_peer, "state", | |
7955 | lookup_msg(bgp_status_msg, peer->status, | |
7956 | NULL)); | |
60466a63 QY |
7957 | else if (CHECK_FLAG(peer->sflags, |
7958 | PEER_STATUS_PREFIX_OVERFLOW)) | |
7959 | json_object_string_add(json_peer, "state", | |
ea47320b DL |
7960 | "Idle (PfxCt)"); |
7961 | else | |
7962 | json_object_string_add( | |
7963 | json_peer, "state", | |
60466a63 QY |
7964 | lookup_msg(bgp_status_msg, peer->status, |
7965 | NULL)); | |
ea47320b DL |
7966 | |
7967 | if (peer->conf_if) | |
60466a63 | 7968 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
7969 | "interface"); |
7970 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
7971 | json_object_string_add(json_peer, "idType", |
7972 | "ipv4"); | |
ea47320b | 7973 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
7974 | json_object_string_add(json_peer, "idType", |
7975 | "ipv6"); | |
d62a17ae | 7976 | |
ea47320b DL |
7977 | json_object_object_add(json_peers, peer->host, |
7978 | json_peer); | |
7979 | } else { | |
7980 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
7981 | if (peer_dynamic_neighbor(peer)) { | |
7982 | dn_count++; | |
7983 | dn_flag[0] = '*'; | |
7984 | } | |
d62a17ae | 7985 | |
ea47320b | 7986 | if (peer->hostname |
60466a63 | 7987 | && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) |
ea47320b | 7988 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
60466a63 | 7989 | peer->hostname, peer->host); |
ea47320b | 7990 | else |
60466a63 | 7991 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
ea47320b DL |
7992 | |
7993 | /* pad the neighbor column with spaces */ | |
7994 | if (len < max_neighbor_width) | |
60466a63 QY |
7995 | vty_out(vty, "%*s", max_neighbor_width - len, |
7996 | " "); | |
ea47320b | 7997 | |
86a55b99 | 7998 | vty_out(vty, "4 %10u %7u %7u %8" PRIu64 " %4d %4zd %8s", |
0112e9e0 QY |
7999 | peer->as, PEER_TOTAL_RX(peer), |
8000 | PEER_TOTAL_TX(peer), peer->version[afi][safi], | |
8001 | 0, peer->obuf->count, | |
d62a17ae | 8002 | peer_uptime(peer->uptime, timebuf, |
ea47320b | 8003 | BGP_UPTIME_LEN, 0, NULL)); |
d62a17ae | 8004 | |
ea47320b | 8005 | if (peer->status == Established) |
2f8f4f10 | 8006 | if (peer->afc_recv[afi][safi]) |
95077abf | 8007 | vty_out(vty, " %12ld", |
a4d82a8a PZ |
8008 | peer->pcount[afi] |
8009 | [pfx_rcd_safi]); | |
95077abf DW |
8010 | else |
8011 | vty_out(vty, " NoNeg"); | |
ea47320b | 8012 | else { |
60466a63 | 8013 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) |
ea47320b | 8014 | vty_out(vty, " Idle (Admin)"); |
60466a63 QY |
8015 | else if (CHECK_FLAG( |
8016 | peer->sflags, | |
8017 | PEER_STATUS_PREFIX_OVERFLOW)) | |
ea47320b | 8018 | vty_out(vty, " Idle (PfxCt)"); |
d62a17ae | 8019 | else |
ea47320b | 8020 | vty_out(vty, " %12s", |
60466a63 QY |
8021 | lookup_msg(bgp_status_msg, |
8022 | peer->status, NULL)); | |
d62a17ae | 8023 | } |
ea47320b | 8024 | vty_out(vty, "\n"); |
d62a17ae | 8025 | } |
8026 | } | |
f933309e | 8027 | |
d62a17ae | 8028 | if (use_json) { |
8029 | json_object_object_add(json, "peers", json_peers); | |
8030 | ||
8031 | json_object_int_add(json, "totalPeers", count); | |
8032 | json_object_int_add(json, "dynamicPeers", dn_count); | |
8033 | ||
57a9c8a8 DS |
8034 | bgp_show_bestpath_json(bgp, json); |
8035 | ||
996c9314 LB |
8036 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
8037 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 8038 | json_object_free(json); |
8039 | } else { | |
8040 | if (count) | |
8041 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
8042 | else { | |
d6ceaca3 | 8043 | vty_out(vty, "No %s neighbor is configured\n", |
8044 | afi_safi_print(afi, safi)); | |
d62a17ae | 8045 | } |
b05a1c8b | 8046 | |
d6ceaca3 | 8047 | if (dn_count) { |
d62a17ae | 8048 | vty_out(vty, "* - dynamic neighbor\n"); |
8049 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
8050 | dn_count, bgp->dynamic_neighbors_limit); | |
8051 | } | |
8052 | } | |
1ff9a340 | 8053 | |
d62a17ae | 8054 | return CMD_SUCCESS; |
718e3744 | 8055 | } |
8056 | ||
d62a17ae | 8057 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
d7c0a89a | 8058 | int safi, uint8_t use_json, |
d62a17ae | 8059 | json_object *json) |
8060 | { | |
8061 | int is_first = 1; | |
8062 | int afi_wildcard = (afi == AFI_MAX); | |
8063 | int safi_wildcard = (safi == SAFI_MAX); | |
8064 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
8065 | bool json_output = false; | |
8066 | ||
8067 | if (use_json && is_wildcard) | |
8068 | vty_out(vty, "{\n"); | |
8069 | if (afi_wildcard) | |
8070 | afi = 1; /* AFI_IP */ | |
8071 | while (afi < AFI_MAX) { | |
8072 | if (safi_wildcard) | |
8073 | safi = 1; /* SAFI_UNICAST */ | |
8074 | while (safi < SAFI_MAX) { | |
318cac96 | 8075 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
d62a17ae | 8076 | json_output = true; |
8077 | if (is_wildcard) { | |
8078 | /* | |
8079 | * So limit output to those afi/safi | |
8080 | * pairs that | |
8081 | * actualy have something interesting in | |
8082 | * them | |
8083 | */ | |
8084 | if (use_json) { | |
8085 | json = json_object_new_object(); | |
8086 | ||
8087 | if (!is_first) | |
8088 | vty_out(vty, ",\n"); | |
8089 | else | |
8090 | is_first = 0; | |
8091 | ||
8092 | vty_out(vty, "\"%s\":", | |
8093 | afi_safi_json(afi, | |
8094 | safi)); | |
8095 | } else { | |
8096 | vty_out(vty, "\n%s Summary:\n", | |
8097 | afi_safi_print(afi, | |
8098 | safi)); | |
8099 | } | |
8100 | } | |
8101 | bgp_show_summary(vty, bgp, afi, safi, use_json, | |
8102 | json); | |
8103 | } | |
8104 | safi++; | |
d62a17ae | 8105 | if (!safi_wildcard) |
8106 | safi = SAFI_MAX; | |
8107 | } | |
8108 | afi++; | |
ee851c8c | 8109 | if (!afi_wildcard) |
d62a17ae | 8110 | afi = AFI_MAX; |
8111 | } | |
8112 | ||
8113 | if (use_json && is_wildcard) | |
8114 | vty_out(vty, "}\n"); | |
8115 | else if (use_json && !json_output) | |
8116 | vty_out(vty, "{}\n"); | |
8117 | } | |
8118 | ||
8119 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
d7c0a89a | 8120 | safi_t safi, uint8_t use_json) |
d62a17ae | 8121 | { |
8122 | struct listnode *node, *nnode; | |
8123 | struct bgp *bgp; | |
8124 | json_object *json = NULL; | |
8125 | int is_first = 1; | |
8126 | ||
8127 | if (use_json) | |
8128 | vty_out(vty, "{\n"); | |
8129 | ||
8130 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
8131 | if (use_json) { | |
8132 | json = json_object_new_object(); | |
8133 | ||
8134 | if (!is_first) | |
8135 | vty_out(vty, ",\n"); | |
8136 | else | |
8137 | is_first = 0; | |
8138 | ||
8139 | vty_out(vty, "\"%s\":", | |
8140 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
8141 | ? "Default" | |
8142 | : bgp->name); | |
8143 | } else { | |
8144 | vty_out(vty, "\nInstance %s:\n", | |
8145 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
8146 | ? "Default" | |
8147 | : bgp->name); | |
8148 | } | |
8149 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, json); | |
8150 | } | |
8151 | ||
8152 | if (use_json) | |
8153 | vty_out(vty, "}\n"); | |
8154 | } | |
8155 | ||
8156 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
d7c0a89a | 8157 | safi_t safi, uint8_t use_json) |
d62a17ae | 8158 | { |
8159 | struct bgp *bgp; | |
8160 | ||
8161 | if (name) { | |
8162 | if (strmatch(name, "all")) { | |
8163 | bgp_show_all_instances_summary_vty(vty, afi, safi, | |
8164 | use_json); | |
8165 | return CMD_SUCCESS; | |
8166 | } else { | |
8167 | bgp = bgp_lookup_by_name(name); | |
8168 | ||
8169 | if (!bgp) { | |
8170 | if (use_json) | |
8171 | vty_out(vty, "{}\n"); | |
8172 | else | |
8173 | vty_out(vty, | |
8174 | "%% No such BGP instance exist\n"); | |
8175 | return CMD_WARNING; | |
8176 | } | |
8177 | ||
8178 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, | |
8179 | NULL); | |
8180 | return CMD_SUCCESS; | |
8181 | } | |
8182 | } | |
8183 | ||
8184 | bgp = bgp_get_default(); | |
8185 | ||
8186 | if (bgp) | |
8187 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, NULL); | |
8188 | ||
8189 | return CMD_SUCCESS; | |
4fb25c53 DW |
8190 | } |
8191 | ||
716b2d8a | 8192 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 8193 | DEFUN (show_ip_bgp_summary, |
718e3744 | 8194 | show_ip_bgp_summary_cmd, |
dd6bd0f1 | 8195 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] summary [json]", |
718e3744 | 8196 | SHOW_STR |
8197 | IP_STR | |
8198 | BGP_STR | |
8386ac43 | 8199 | BGP_INSTANCE_HELP_STR |
46f296b4 | 8200 | BGP_AFI_HELP_STR |
dd6bd0f1 | 8201 | BGP_SAFI_WITH_LABEL_HELP_STR |
b05a1c8b | 8202 | "Summary of BGP neighbor status\n" |
9973d184 | 8203 | JSON_STR) |
718e3744 | 8204 | { |
d62a17ae | 8205 | char *vrf = NULL; |
8206 | afi_t afi = AFI_MAX; | |
8207 | safi_t safi = SAFI_MAX; | |
8208 | ||
8209 | int idx = 0; | |
8210 | ||
8211 | /* show [ip] bgp */ | |
8212 | if (argv_find(argv, argc, "ip", &idx)) | |
8213 | afi = AFI_IP; | |
8214 | /* [<view|vrf> VIEWVRFNAME] */ | |
8215 | if (argv_find(argv, argc, "view", &idx) | |
8216 | || argv_find(argv, argc, "vrf", &idx)) | |
8217 | vrf = argv[++idx]->arg; | |
8218 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
8219 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
8220 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
8221 | } | |
8222 | ||
8223 | int uj = use_json(argc, argv); | |
8224 | ||
8225 | return bgp_show_summary_vty(vty, vrf, afi, safi, uj); | |
8226 | } | |
8227 | ||
8228 | const char *afi_safi_print(afi_t afi, safi_t safi) | |
8229 | { | |
8230 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
8231 | return "IPv4 Unicast"; | |
8232 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
8233 | return "IPv4 Multicast"; | |
8234 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
8235 | return "IPv4 Labeled Unicast"; | |
8236 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
8237 | return "IPv4 VPN"; | |
8238 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
8239 | return "IPv4 Encap"; | |
7c40bf39 | 8240 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) |
8241 | return "IPv4 Flowspec"; | |
d62a17ae | 8242 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
8243 | return "IPv6 Unicast"; | |
8244 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
8245 | return "IPv6 Multicast"; | |
8246 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
8247 | return "IPv6 Labeled Unicast"; | |
8248 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
8249 | return "IPv6 VPN"; | |
8250 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
8251 | return "IPv6 Encap"; | |
7c40bf39 | 8252 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) |
8253 | return "IPv6 Flowspec"; | |
d62a17ae | 8254 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) |
8255 | return "L2VPN EVPN"; | |
8256 | else | |
8257 | return "Unknown"; | |
538621f2 | 8258 | } |
8259 | ||
b9f77ec8 DS |
8260 | /* |
8261 | * Please note that we have intentionally camelCased | |
8262 | * the return strings here. So if you want | |
8263 | * to use this function, please ensure you | |
8264 | * are doing this within json output | |
8265 | */ | |
d62a17ae | 8266 | const char *afi_safi_json(afi_t afi, safi_t safi) |
8267 | { | |
8268 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
8269 | return "ipv4Unicast"; | |
8270 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
8271 | return "ipv4Multicast"; | |
8272 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
8273 | return "ipv4LabeledUnicast"; | |
8274 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
8275 | return "ipv4Vpn"; | |
8276 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
8277 | return "ipv4Encap"; | |
7c40bf39 | 8278 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) |
8279 | return "ipv4Flowspec"; | |
d62a17ae | 8280 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
8281 | return "ipv6Unicast"; | |
8282 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
8283 | return "ipv6Multicast"; | |
8284 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
8285 | return "ipv6LabeledUnicast"; | |
8286 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
8287 | return "ipv6Vpn"; | |
8288 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
8289 | return "ipv6Encap"; | |
7c40bf39 | 8290 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) |
8291 | return "ipv6Flowspec"; | |
d62a17ae | 8292 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) |
8293 | return "l2VpnEvpn"; | |
8294 | else | |
8295 | return "Unknown"; | |
27162734 LB |
8296 | } |
8297 | ||
718e3744 | 8298 | /* Show BGP peer's information. */ |
d62a17ae | 8299 | enum show_type { show_all, show_peer }; |
8300 | ||
8301 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
8302 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
8303 | uint16_t adv_smcap, uint16_t adv_rmcap, |
8304 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
8305 | uint8_t use_json, json_object *json_pref) | |
d62a17ae | 8306 | { |
8307 | /* Send-Mode */ | |
8308 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
8309 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
8310 | if (use_json) { | |
8311 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
8312 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8313 | json_object_string_add(json_pref, "sendMode", | |
8314 | "advertisedAndReceived"); | |
8315 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
8316 | json_object_string_add(json_pref, "sendMode", | |
8317 | "advertised"); | |
8318 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8319 | json_object_string_add(json_pref, "sendMode", | |
8320 | "received"); | |
8321 | } else { | |
8322 | vty_out(vty, " Send-mode: "); | |
8323 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
8324 | vty_out(vty, "advertised"); | |
8325 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8326 | vty_out(vty, "%sreceived", | |
8327 | CHECK_FLAG(p->af_cap[afi][safi], | |
8328 | adv_smcap) | |
8329 | ? ", " | |
8330 | : ""); | |
8331 | vty_out(vty, "\n"); | |
8332 | } | |
8333 | } | |
8334 | ||
8335 | /* Receive-Mode */ | |
8336 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
8337 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
8338 | if (use_json) { | |
8339 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
8340 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8341 | json_object_string_add(json_pref, "recvMode", | |
8342 | "advertisedAndReceived"); | |
8343 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
8344 | json_object_string_add(json_pref, "recvMode", | |
8345 | "advertised"); | |
8346 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8347 | json_object_string_add(json_pref, "recvMode", | |
8348 | "received"); | |
8349 | } else { | |
8350 | vty_out(vty, " Receive-mode: "); | |
8351 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
8352 | vty_out(vty, "advertised"); | |
8353 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8354 | vty_out(vty, "%sreceived", | |
8355 | CHECK_FLAG(p->af_cap[afi][safi], | |
8356 | adv_rmcap) | |
8357 | ? ", " | |
8358 | : ""); | |
8359 | vty_out(vty, "\n"); | |
8360 | } | |
8361 | } | |
8362 | } | |
8363 | ||
8364 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, | |
d7c0a89a | 8365 | safi_t safi, uint8_t use_json, |
d62a17ae | 8366 | json_object *json_neigh) |
8367 | { | |
0291c246 MK |
8368 | struct bgp_filter *filter; |
8369 | struct peer_af *paf; | |
8370 | char orf_pfx_name[BUFSIZ]; | |
8371 | int orf_pfx_count; | |
8372 | json_object *json_af = NULL; | |
8373 | json_object *json_prefA = NULL; | |
8374 | json_object *json_prefB = NULL; | |
8375 | json_object *json_addr = NULL; | |
d62a17ae | 8376 | |
8377 | if (use_json) { | |
8378 | json_addr = json_object_new_object(); | |
8379 | json_af = json_object_new_object(); | |
8380 | filter = &p->filter[afi][safi]; | |
8381 | ||
8382 | if (peer_group_active(p)) | |
8383 | json_object_string_add(json_addr, "peerGroupMember", | |
8384 | p->group->name); | |
8385 | ||
8386 | paf = peer_af_find(p, afi, safi); | |
8387 | if (paf && PAF_SUBGRP(paf)) { | |
8388 | json_object_int_add(json_addr, "updateGroupId", | |
8389 | PAF_UPDGRP(paf)->id); | |
8390 | json_object_int_add(json_addr, "subGroupId", | |
8391 | PAF_SUBGRP(paf)->id); | |
8392 | json_object_int_add(json_addr, "packetQueueLength", | |
8393 | bpacket_queue_virtual_length(paf)); | |
8394 | } | |
8395 | ||
8396 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8397 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8398 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8399 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8400 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8401 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8402 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
8403 | json_object_int_add(json_af, "orfType", | |
8404 | ORF_TYPE_PREFIX); | |
8405 | json_prefA = json_object_new_object(); | |
8406 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
8407 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
8408 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8409 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
8410 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
8411 | use_json, json_prefA); | |
8412 | json_object_object_add(json_af, "orfPrefixList", | |
8413 | json_prefA); | |
8414 | } | |
8415 | ||
8416 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8417 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8418 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8419 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8420 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8421 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8422 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
8423 | json_object_int_add(json_af, "orfOldType", | |
8424 | ORF_TYPE_PREFIX_OLD); | |
8425 | json_prefB = json_object_new_object(); | |
8426 | bgp_show_peer_afi_orf_cap( | |
8427 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
8428 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8429 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
8430 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
8431 | json_prefB); | |
8432 | json_object_object_add(json_af, "orfOldPrefixList", | |
8433 | json_prefB); | |
8434 | } | |
8435 | ||
8436 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8437 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8438 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8439 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8440 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8441 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8442 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8443 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8444 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
8445 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8446 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
8447 | json_object_object_add(json_addr, "afDependentCap", | |
8448 | json_af); | |
8449 | else | |
8450 | json_object_free(json_af); | |
8451 | ||
8452 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
8453 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
8454 | NULL, afi, orf_pfx_name, use_json); | |
8455 | ||
8456 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8457 | PEER_STATUS_ORF_PREFIX_SEND) | |
8458 | || orf_pfx_count) { | |
8459 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8460 | PEER_STATUS_ORF_PREFIX_SEND)) | |
8461 | json_object_boolean_true_add(json_neigh, | |
8462 | "orfSent"); | |
8463 | if (orf_pfx_count) | |
8464 | json_object_int_add(json_addr, "orfRecvCounter", | |
8465 | orf_pfx_count); | |
8466 | } | |
8467 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8468 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
8469 | json_object_string_add( | |
8470 | json_addr, "orfFirstUpdate", | |
8471 | "deferredUntilORFOrRouteRefreshRecvd"); | |
8472 | ||
8473 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8474 | PEER_FLAG_REFLECTOR_CLIENT)) | |
8475 | json_object_boolean_true_add(json_addr, | |
8476 | "routeReflectorClient"); | |
8477 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8478 | PEER_FLAG_RSERVER_CLIENT)) | |
8479 | json_object_boolean_true_add(json_addr, | |
8480 | "routeServerClient"); | |
8481 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
8482 | json_object_boolean_true_add(json_addr, | |
8483 | "inboundSoftConfigPermit"); | |
8484 | ||
8485 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8486 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
8487 | json_object_boolean_true_add( | |
8488 | json_addr, | |
8489 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
8490 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8491 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
8492 | json_object_boolean_true_add( | |
8493 | json_addr, | |
8494 | "privateAsNumsReplacedInUpdatesToNbr"); | |
8495 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8496 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
8497 | json_object_boolean_true_add( | |
8498 | json_addr, | |
8499 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
8500 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8501 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
8502 | json_object_boolean_true_add( | |
8503 | json_addr, | |
8504 | "privateAsNumsRemovedInUpdatesToNbr"); | |
8505 | ||
8506 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8507 | PEER_FLAG_ADDPATH_TX_ALL_PATHS)) | |
8508 | json_object_boolean_true_add(json_addr, | |
8509 | "addpathTxAllPaths"); | |
8510 | ||
8511 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8512 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) | |
8513 | json_object_boolean_true_add(json_addr, | |
8514 | "addpathTxBestpathPerAS"); | |
8515 | ||
8516 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
8517 | json_object_string_add(json_addr, | |
8518 | "overrideASNsInOutboundUpdates", | |
8519 | "ifAspathEqualRemoteAs"); | |
8520 | ||
8521 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
8522 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8523 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
8524 | json_object_boolean_true_add(json_addr, | |
8525 | "routerAlwaysNextHop"); | |
8526 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8527 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
8528 | json_object_boolean_true_add( | |
8529 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
8530 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8531 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
8532 | json_object_boolean_true_add( | |
8533 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
8534 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
8535 | json_object_boolean_true_add( | |
8536 | json_addr, "unchangedMedPropogatedToNbr"); | |
8537 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
8538 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8539 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
8540 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8541 | PEER_FLAG_SEND_COMMUNITY) | |
8542 | && CHECK_FLAG(p->af_flags[afi][safi], | |
8543 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
8544 | json_object_string_add(json_addr, | |
8545 | "commAttriSentToNbr", | |
8546 | "extendedAndStandard"); | |
8547 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8548 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
8549 | json_object_string_add(json_addr, | |
8550 | "commAttriSentToNbr", | |
8551 | "extended"); | |
8552 | else | |
8553 | json_object_string_add(json_addr, | |
8554 | "commAttriSentToNbr", | |
8555 | "standard"); | |
8556 | } | |
8557 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8558 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
8559 | if (p->default_rmap[afi][safi].name) | |
8560 | json_object_string_add( | |
8561 | json_addr, "defaultRouteMap", | |
8562 | p->default_rmap[afi][safi].name); | |
8563 | ||
8564 | if (paf && PAF_SUBGRP(paf) | |
8565 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
8566 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
8567 | json_object_boolean_true_add(json_addr, | |
8568 | "defaultSent"); | |
8569 | else | |
8570 | json_object_boolean_true_add(json_addr, | |
8571 | "defaultNotSent"); | |
8572 | } | |
8573 | ||
dff8f48d | 8574 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 8575 | if (is_evpn_enabled()) |
60466a63 QY |
8576 | json_object_boolean_true_add( |
8577 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
8578 | } |
8579 | ||
d62a17ae | 8580 | if (filter->plist[FILTER_IN].name |
8581 | || filter->dlist[FILTER_IN].name | |
8582 | || filter->aslist[FILTER_IN].name | |
8583 | || filter->map[RMAP_IN].name) | |
8584 | json_object_boolean_true_add(json_addr, | |
8585 | "inboundPathPolicyConfig"); | |
8586 | if (filter->plist[FILTER_OUT].name | |
8587 | || filter->dlist[FILTER_OUT].name | |
8588 | || filter->aslist[FILTER_OUT].name | |
8589 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
8590 | json_object_boolean_true_add( | |
8591 | json_addr, "outboundPathPolicyConfig"); | |
8592 | ||
8593 | /* prefix-list */ | |
8594 | if (filter->plist[FILTER_IN].name) | |
8595 | json_object_string_add(json_addr, | |
8596 | "incomingUpdatePrefixFilterList", | |
8597 | filter->plist[FILTER_IN].name); | |
8598 | if (filter->plist[FILTER_OUT].name) | |
8599 | json_object_string_add(json_addr, | |
8600 | "outgoingUpdatePrefixFilterList", | |
8601 | filter->plist[FILTER_OUT].name); | |
8602 | ||
8603 | /* distribute-list */ | |
8604 | if (filter->dlist[FILTER_IN].name) | |
8605 | json_object_string_add( | |
8606 | json_addr, "incomingUpdateNetworkFilterList", | |
8607 | filter->dlist[FILTER_IN].name); | |
8608 | if (filter->dlist[FILTER_OUT].name) | |
8609 | json_object_string_add( | |
8610 | json_addr, "outgoingUpdateNetworkFilterList", | |
8611 | filter->dlist[FILTER_OUT].name); | |
8612 | ||
8613 | /* filter-list. */ | |
8614 | if (filter->aslist[FILTER_IN].name) | |
8615 | json_object_string_add(json_addr, | |
8616 | "incomingUpdateAsPathFilterList", | |
8617 | filter->aslist[FILTER_IN].name); | |
8618 | if (filter->aslist[FILTER_OUT].name) | |
8619 | json_object_string_add(json_addr, | |
8620 | "outgoingUpdateAsPathFilterList", | |
8621 | filter->aslist[FILTER_OUT].name); | |
8622 | ||
8623 | /* route-map. */ | |
8624 | if (filter->map[RMAP_IN].name) | |
8625 | json_object_string_add( | |
8626 | json_addr, "routeMapForIncomingAdvertisements", | |
8627 | filter->map[RMAP_IN].name); | |
8628 | if (filter->map[RMAP_OUT].name) | |
8629 | json_object_string_add( | |
8630 | json_addr, "routeMapForOutgoingAdvertisements", | |
8631 | filter->map[RMAP_OUT].name); | |
8632 | ||
8633 | /* unsuppress-map */ | |
8634 | if (filter->usmap.name) | |
8635 | json_object_string_add(json_addr, | |
8636 | "selectiveUnsuppressRouteMap", | |
8637 | filter->usmap.name); | |
8638 | ||
8639 | /* Receive prefix count */ | |
8640 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
8641 | p->pcount[afi][safi]); | |
8642 | ||
8643 | /* Maximum prefix */ | |
8644 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
8645 | json_object_int_add(json_addr, "prefixAllowedMax", | |
8646 | p->pmax[afi][safi]); | |
8647 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8648 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
8649 | json_object_boolean_true_add( | |
8650 | json_addr, "prefixAllowedMaxWarning"); | |
8651 | json_object_int_add(json_addr, | |
8652 | "prefixAllowedWarningThresh", | |
8653 | p->pmax_threshold[afi][safi]); | |
8654 | if (p->pmax_restart[afi][safi]) | |
8655 | json_object_int_add( | |
8656 | json_addr, | |
8657 | "prefixAllowedRestartIntervalMsecs", | |
8658 | p->pmax_restart[afi][safi] * 60000); | |
8659 | } | |
8660 | json_object_object_add(json_neigh, afi_safi_print(afi, safi), | |
8661 | json_addr); | |
8662 | ||
8663 | } else { | |
8664 | filter = &p->filter[afi][safi]; | |
8665 | ||
8666 | vty_out(vty, " For address family: %s\n", | |
8667 | afi_safi_print(afi, safi)); | |
8668 | ||
8669 | if (peer_group_active(p)) | |
8670 | vty_out(vty, " %s peer-group member\n", | |
8671 | p->group->name); | |
8672 | ||
8673 | paf = peer_af_find(p, afi, safi); | |
8674 | if (paf && PAF_SUBGRP(paf)) { | |
996c9314 LB |
8675 | vty_out(vty, " Update group %" PRIu64 |
8676 | ", subgroup %" PRIu64 "\n", | |
d62a17ae | 8677 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
8678 | vty_out(vty, " Packet Queue length %d\n", | |
8679 | bpacket_queue_virtual_length(paf)); | |
8680 | } else { | |
8681 | vty_out(vty, " Not part of any update group\n"); | |
8682 | } | |
8683 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8684 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8685 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8686 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8687 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8688 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8689 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8690 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8691 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
8692 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8693 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
8694 | vty_out(vty, " AF-dependant capabilities:\n"); | |
8695 | ||
8696 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8697 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8698 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8699 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8700 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8701 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8702 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
8703 | vty_out(vty, | |
8704 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
8705 | ORF_TYPE_PREFIX); | |
8706 | bgp_show_peer_afi_orf_cap( | |
8707 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
8708 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8709 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
8710 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
8711 | } | |
8712 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8713 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8714 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8715 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8716 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8717 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8718 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
8719 | vty_out(vty, | |
8720 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
8721 | ORF_TYPE_PREFIX_OLD); | |
8722 | bgp_show_peer_afi_orf_cap( | |
8723 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
8724 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8725 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
8726 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
8727 | } | |
8728 | ||
8729 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
8730 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
8731 | NULL, afi, orf_pfx_name, use_json); | |
8732 | ||
8733 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8734 | PEER_STATUS_ORF_PREFIX_SEND) | |
8735 | || orf_pfx_count) { | |
8736 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
8737 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8738 | PEER_STATUS_ORF_PREFIX_SEND)) | |
8739 | vty_out(vty, " sent;"); | |
8740 | if (orf_pfx_count) | |
8741 | vty_out(vty, " received (%d entries)", | |
8742 | orf_pfx_count); | |
8743 | vty_out(vty, "\n"); | |
8744 | } | |
8745 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8746 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
8747 | vty_out(vty, | |
8748 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
8749 | ||
8750 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8751 | PEER_FLAG_REFLECTOR_CLIENT)) | |
8752 | vty_out(vty, " Route-Reflector Client\n"); | |
8753 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8754 | PEER_FLAG_RSERVER_CLIENT)) | |
8755 | vty_out(vty, " Route-Server Client\n"); | |
8756 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
8757 | vty_out(vty, | |
8758 | " Inbound soft reconfiguration allowed\n"); | |
8759 | ||
8760 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8761 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
8762 | vty_out(vty, | |
8763 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
8764 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8765 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
8766 | vty_out(vty, | |
8767 | " Private AS numbers replaced in updates to this neighbor\n"); | |
8768 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8769 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
8770 | vty_out(vty, | |
8771 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
8772 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8773 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
8774 | vty_out(vty, | |
8775 | " Private AS numbers removed in updates to this neighbor\n"); | |
8776 | ||
8777 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8778 | PEER_FLAG_ADDPATH_TX_ALL_PATHS)) | |
8779 | vty_out(vty, " Advertise all paths via addpath\n"); | |
8780 | ||
8781 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8782 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) | |
8783 | vty_out(vty, | |
8784 | " Advertise bestpath per AS via addpath\n"); | |
8785 | ||
8786 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
8787 | vty_out(vty, | |
8788 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
8789 | ||
8790 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
8791 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8792 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
8793 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
8794 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8795 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
8796 | vty_out(vty, | |
8797 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
8798 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8799 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
8800 | vty_out(vty, | |
8801 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
8802 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
8803 | vty_out(vty, | |
8804 | " MED is propagated unchanged to this neighbor\n"); | |
8805 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
8806 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8807 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
8808 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8809 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
8810 | vty_out(vty, | |
8811 | " Community attribute sent to this neighbor"); | |
8812 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8813 | PEER_FLAG_SEND_COMMUNITY) | |
8814 | && CHECK_FLAG(p->af_flags[afi][safi], | |
8815 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
8816 | && CHECK_FLAG(p->af_flags[afi][safi], | |
8817 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
8818 | vty_out(vty, "(all)\n"); | |
8819 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8820 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
8821 | vty_out(vty, "(large)\n"); | |
8822 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8823 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
8824 | vty_out(vty, "(extended)\n"); | |
8825 | else | |
8826 | vty_out(vty, "(standard)\n"); | |
8827 | } | |
8828 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8829 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
8830 | vty_out(vty, " Default information originate,"); | |
8831 | ||
8832 | if (p->default_rmap[afi][safi].name) | |
8833 | vty_out(vty, " default route-map %s%s,", | |
8834 | p->default_rmap[afi][safi].map ? "*" | |
8835 | : "", | |
8836 | p->default_rmap[afi][safi].name); | |
8837 | if (paf && PAF_SUBGRP(paf) | |
8838 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
8839 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
8840 | vty_out(vty, " default sent\n"); | |
8841 | else | |
8842 | vty_out(vty, " default not sent\n"); | |
8843 | } | |
8844 | ||
dff8f48d MK |
8845 | /* advertise-vni-all */ |
8846 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 8847 | if (is_evpn_enabled()) |
dff8f48d MK |
8848 | vty_out(vty, " advertise-all-vni\n"); |
8849 | } | |
8850 | ||
d62a17ae | 8851 | if (filter->plist[FILTER_IN].name |
8852 | || filter->dlist[FILTER_IN].name | |
8853 | || filter->aslist[FILTER_IN].name | |
8854 | || filter->map[RMAP_IN].name) | |
8855 | vty_out(vty, " Inbound path policy configured\n"); | |
8856 | if (filter->plist[FILTER_OUT].name | |
8857 | || filter->dlist[FILTER_OUT].name | |
8858 | || filter->aslist[FILTER_OUT].name | |
8859 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
8860 | vty_out(vty, " Outbound path policy configured\n"); | |
8861 | ||
8862 | /* prefix-list */ | |
8863 | if (filter->plist[FILTER_IN].name) | |
8864 | vty_out(vty, | |
8865 | " Incoming update prefix filter list is %s%s\n", | |
8866 | filter->plist[FILTER_IN].plist ? "*" : "", | |
8867 | filter->plist[FILTER_IN].name); | |
8868 | if (filter->plist[FILTER_OUT].name) | |
8869 | vty_out(vty, | |
8870 | " Outgoing update prefix filter list is %s%s\n", | |
8871 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
8872 | filter->plist[FILTER_OUT].name); | |
8873 | ||
8874 | /* distribute-list */ | |
8875 | if (filter->dlist[FILTER_IN].name) | |
8876 | vty_out(vty, | |
8877 | " Incoming update network filter list is %s%s\n", | |
8878 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
8879 | filter->dlist[FILTER_IN].name); | |
8880 | if (filter->dlist[FILTER_OUT].name) | |
8881 | vty_out(vty, | |
8882 | " Outgoing update network filter list is %s%s\n", | |
8883 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
8884 | filter->dlist[FILTER_OUT].name); | |
8885 | ||
8886 | /* filter-list. */ | |
8887 | if (filter->aslist[FILTER_IN].name) | |
8888 | vty_out(vty, | |
8889 | " Incoming update AS path filter list is %s%s\n", | |
8890 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
8891 | filter->aslist[FILTER_IN].name); | |
8892 | if (filter->aslist[FILTER_OUT].name) | |
8893 | vty_out(vty, | |
8894 | " Outgoing update AS path filter list is %s%s\n", | |
8895 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
8896 | filter->aslist[FILTER_OUT].name); | |
8897 | ||
8898 | /* route-map. */ | |
8899 | if (filter->map[RMAP_IN].name) | |
8900 | vty_out(vty, | |
8901 | " Route map for incoming advertisements is %s%s\n", | |
8902 | filter->map[RMAP_IN].map ? "*" : "", | |
8903 | filter->map[RMAP_IN].name); | |
8904 | if (filter->map[RMAP_OUT].name) | |
8905 | vty_out(vty, | |
8906 | " Route map for outgoing advertisements is %s%s\n", | |
8907 | filter->map[RMAP_OUT].map ? "*" : "", | |
8908 | filter->map[RMAP_OUT].name); | |
8909 | ||
8910 | /* unsuppress-map */ | |
8911 | if (filter->usmap.name) | |
8912 | vty_out(vty, | |
8913 | " Route map for selective unsuppress is %s%s\n", | |
8914 | filter->usmap.map ? "*" : "", | |
8915 | filter->usmap.name); | |
8916 | ||
8917 | /* Receive prefix count */ | |
8918 | vty_out(vty, " %ld accepted prefixes\n", p->pcount[afi][safi]); | |
8919 | ||
8920 | /* Maximum prefix */ | |
8921 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
8922 | vty_out(vty, " Maximum prefixes allowed %ld%s\n", | |
8923 | p->pmax[afi][safi], | |
8924 | CHECK_FLAG(p->af_flags[afi][safi], | |
8925 | PEER_FLAG_MAX_PREFIX_WARNING) | |
8926 | ? " (warning-only)" | |
8927 | : ""); | |
8928 | vty_out(vty, " Threshold for warning message %d%%", | |
8929 | p->pmax_threshold[afi][safi]); | |
8930 | if (p->pmax_restart[afi][safi]) | |
8931 | vty_out(vty, ", restart interval %d min", | |
8932 | p->pmax_restart[afi][safi]); | |
8933 | vty_out(vty, "\n"); | |
8934 | } | |
8935 | ||
8936 | vty_out(vty, "\n"); | |
8937 | } | |
8938 | } | |
8939 | ||
d7c0a89a | 8940 | static void bgp_show_peer(struct vty *vty, struct peer *p, uint8_t use_json, |
d62a17ae | 8941 | json_object *json) |
718e3744 | 8942 | { |
d62a17ae | 8943 | struct bgp *bgp; |
8944 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
8945 | char timebuf[BGP_UPTIME_LEN]; | |
8946 | char dn_flag[2]; | |
8947 | const char *subcode_str; | |
8948 | const char *code_str; | |
8949 | afi_t afi; | |
8950 | safi_t safi; | |
d7c0a89a QY |
8951 | uint16_t i; |
8952 | uint8_t *msg; | |
d62a17ae | 8953 | json_object *json_neigh = NULL; |
8954 | time_t epoch_tbuf; | |
718e3744 | 8955 | |
d62a17ae | 8956 | bgp = p->bgp; |
8957 | ||
8958 | if (use_json) | |
8959 | json_neigh = json_object_new_object(); | |
8960 | ||
8961 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
8962 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
8963 | dn_flag[0] = '*'; | |
8964 | ||
8965 | if (!use_json) { | |
8966 | if (p->conf_if) /* Configured interface name. */ | |
8967 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
8968 | BGP_PEER_SU_UNSPEC(p) | |
8969 | ? "None" | |
8970 | : sockunion2str(&p->su, buf, | |
8971 | SU_ADDRSTRLEN)); | |
8972 | else /* Configured IP address. */ | |
8973 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
8974 | p->host); | |
8975 | } | |
8976 | ||
8977 | if (use_json) { | |
8978 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
8979 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
8980 | "none"); | |
8981 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
8982 | json_object_string_add( | |
8983 | json_neigh, "bgpNeighborAddr", | |
8984 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
8985 | ||
8986 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
8987 | ||
8988 | if (p->change_local_as) | |
8989 | json_object_int_add(json_neigh, "localAs", | |
8990 | p->change_local_as); | |
8991 | else | |
8992 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
8993 | ||
8994 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
8995 | json_object_boolean_true_add(json_neigh, | |
8996 | "localAsNoPrepend"); | |
8997 | ||
8998 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
8999 | json_object_boolean_true_add(json_neigh, | |
9000 | "localAsReplaceAs"); | |
9001 | } else { | |
9002 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
9003 | || (p->as_type == AS_INTERNAL)) | |
9004 | vty_out(vty, "remote AS %u, ", p->as); | |
9005 | else | |
9006 | vty_out(vty, "remote AS Unspecified, "); | |
9007 | vty_out(vty, "local AS %u%s%s, ", | |
9008 | p->change_local_as ? p->change_local_as : p->local_as, | |
9009 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
9010 | ? " no-prepend" | |
9011 | : "", | |
9012 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
9013 | ? " replace-as" | |
9014 | : ""); | |
9015 | } | |
9016 | /* peer type internal, external, confed-internal or confed-external */ | |
9017 | if (p->as == p->local_as) { | |
9018 | if (use_json) { | |
9019 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9020 | json_object_boolean_true_add( | |
9021 | json_neigh, "nbrConfedInternalLink"); | |
9022 | else | |
9023 | json_object_boolean_true_add(json_neigh, | |
9024 | "nbrInternalLink"); | |
9025 | } else { | |
9026 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9027 | vty_out(vty, "confed-internal link\n"); | |
9028 | else | |
9029 | vty_out(vty, "internal link\n"); | |
9030 | } | |
9031 | } else { | |
9032 | if (use_json) { | |
9033 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9034 | json_object_boolean_true_add( | |
9035 | json_neigh, "nbrConfedExternalLink"); | |
9036 | else | |
9037 | json_object_boolean_true_add(json_neigh, | |
9038 | "nbrExternalLink"); | |
9039 | } else { | |
9040 | if (bgp_confederation_peers_check(bgp, p->as)) | |
9041 | vty_out(vty, "confed-external link\n"); | |
9042 | else | |
9043 | vty_out(vty, "external link\n"); | |
9044 | } | |
9045 | } | |
9046 | ||
9047 | /* Description. */ | |
9048 | if (p->desc) { | |
9049 | if (use_json) | |
9050 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
9051 | else | |
9052 | vty_out(vty, " Description: %s\n", p->desc); | |
9053 | } | |
9054 | ||
9055 | if (p->hostname) { | |
9056 | if (use_json) { | |
9057 | if (p->hostname) | |
9058 | json_object_string_add(json_neigh, "hostname", | |
9059 | p->hostname); | |
9060 | ||
9061 | if (p->domainname) | |
9062 | json_object_string_add(json_neigh, "domainname", | |
9063 | p->domainname); | |
9064 | } else { | |
9065 | if (p->domainname && (p->domainname[0] != '\0')) | |
9066 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
9067 | p->domainname); | |
9068 | else | |
9069 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
9070 | } | |
9071 | } | |
9072 | ||
9073 | /* Peer-group */ | |
9074 | if (p->group) { | |
9075 | if (use_json) { | |
9076 | json_object_string_add(json_neigh, "peerGroup", | |
9077 | p->group->name); | |
9078 | ||
9079 | if (dn_flag[0]) { | |
9080 | struct prefix prefix, *range = NULL; | |
9081 | ||
9082 | sockunion2hostprefix(&(p->su), &prefix); | |
9083 | range = peer_group_lookup_dynamic_neighbor_range( | |
9084 | p->group, &prefix); | |
9085 | ||
9086 | if (range) { | |
9087 | prefix2str(range, buf1, sizeof(buf1)); | |
9088 | json_object_string_add( | |
9089 | json_neigh, | |
9090 | "peerSubnetRangeGroup", buf1); | |
9091 | } | |
9092 | } | |
9093 | } else { | |
9094 | vty_out(vty, | |
9095 | " Member of peer-group %s for session parameters\n", | |
9096 | p->group->name); | |
9097 | ||
9098 | if (dn_flag[0]) { | |
9099 | struct prefix prefix, *range = NULL; | |
9100 | ||
9101 | sockunion2hostprefix(&(p->su), &prefix); | |
9102 | range = peer_group_lookup_dynamic_neighbor_range( | |
9103 | p->group, &prefix); | |
9104 | ||
9105 | if (range) { | |
9106 | prefix2str(range, buf1, sizeof(buf1)); | |
9107 | vty_out(vty, | |
9108 | " Belongs to the subnet range group: %s\n", | |
9109 | buf1); | |
9110 | } | |
9111 | } | |
9112 | } | |
9113 | } | |
9114 | ||
9115 | if (use_json) { | |
9116 | /* Administrative shutdown. */ | |
9117 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
9118 | json_object_boolean_true_add(json_neigh, | |
9119 | "adminShutDown"); | |
9120 | ||
9121 | /* BGP Version. */ | |
9122 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
9123 | json_object_string_add( | |
9124 | json_neigh, "remoteRouterId", | |
9125 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
d0086e8e AD |
9126 | json_object_string_add( |
9127 | json_neigh, "localRouterId", | |
9128 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
9129 | sizeof(buf1))); | |
d62a17ae | 9130 | |
9131 | /* Confederation */ | |
9132 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
9133 | && bgp_confederation_peers_check(bgp, p->as)) | |
9134 | json_object_boolean_true_add(json_neigh, | |
9135 | "nbrCommonAdmin"); | |
9136 | ||
9137 | /* Status. */ | |
9138 | json_object_string_add( | |
9139 | json_neigh, "bgpState", | |
9140 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
9141 | ||
9142 | if (p->status == Established) { | |
9143 | time_t uptime; | |
d62a17ae | 9144 | |
9145 | uptime = bgp_clock(); | |
9146 | uptime -= p->uptime; | |
d62a17ae | 9147 | epoch_tbuf = time(NULL) - uptime; |
9148 | ||
bee57a7a | 9149 | #if CONFDATE > 20200101 |
a4d82a8a PZ |
9150 | CPP_NOTICE( |
9151 | "bgpTimerUp should be deprecated and can be removed now"); | |
d3c7efed DS |
9152 | #endif |
9153 | /* | |
9154 | * bgpTimerUp was miliseconds that was accurate | |
9155 | * up to 1 day, then the value returned | |
9156 | * became garbage. So in order to provide | |
9157 | * some level of backwards compatability, | |
9158 | * we still provde the data, but now | |
9159 | * we are returning the correct value | |
9160 | * and also adding a new bgpTimerUpMsec | |
9161 | * which will allow us to deprecate | |
9162 | * this eventually | |
9163 | */ | |
d62a17ae | 9164 | json_object_int_add(json_neigh, "bgpTimerUp", |
e0330274 | 9165 | uptime * 1000); |
d3c7efed DS |
9166 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
9167 | uptime * 1000); | |
d62a17ae | 9168 | json_object_string_add(json_neigh, "bgpTimerUpString", |
9169 | peer_uptime(p->uptime, timebuf, | |
9170 | BGP_UPTIME_LEN, 0, | |
9171 | NULL)); | |
9172 | json_object_int_add(json_neigh, | |
9173 | "bgpTimerUpEstablishedEpoch", | |
9174 | epoch_tbuf); | |
9175 | } | |
9176 | ||
9177 | else if (p->status == Active) { | |
9178 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
9179 | json_object_string_add(json_neigh, "bgpStateIs", | |
9180 | "passive"); | |
9181 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
9182 | json_object_string_add(json_neigh, "bgpStateIs", | |
9183 | "passiveNSF"); | |
9184 | } | |
9185 | ||
9186 | /* read timer */ | |
9187 | time_t uptime; | |
9188 | struct tm *tm; | |
9189 | ||
9190 | uptime = bgp_clock(); | |
9191 | uptime -= p->readtime; | |
9192 | tm = gmtime(&uptime); | |
9193 | json_object_int_add(json_neigh, "bgpTimerLastRead", | |
9194 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9195 | + (tm->tm_hour * 3600000)); | |
9196 | ||
9197 | uptime = bgp_clock(); | |
9198 | uptime -= p->last_write; | |
9199 | tm = gmtime(&uptime); | |
9200 | json_object_int_add(json_neigh, "bgpTimerLastWrite", | |
9201 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9202 | + (tm->tm_hour * 3600000)); | |
9203 | ||
9204 | uptime = bgp_clock(); | |
9205 | uptime -= p->update_time; | |
9206 | tm = gmtime(&uptime); | |
9207 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", | |
9208 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9209 | + (tm->tm_hour * 3600000)); | |
9210 | ||
9211 | /* Configured timer values. */ | |
9212 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
9213 | p->v_holdtime * 1000); | |
9214 | json_object_int_add(json_neigh, | |
9215 | "bgpTimerKeepAliveIntervalMsecs", | |
9216 | p->v_keepalive * 1000); | |
b90a8e13 | 9217 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 9218 | json_object_int_add(json_neigh, |
9219 | "bgpTimerConfiguredHoldTimeMsecs", | |
9220 | p->holdtime * 1000); | |
9221 | json_object_int_add( | |
9222 | json_neigh, | |
9223 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
9224 | p->keepalive * 1000); | |
d25e4efc | 9225 | } else if ((bgp->default_holdtime != BGP_DEFAULT_HOLDTIME) |
a4d82a8a PZ |
9226 | || (bgp->default_keepalive |
9227 | != BGP_DEFAULT_KEEPALIVE)) { | |
d25e4efc DS |
9228 | json_object_int_add(json_neigh, |
9229 | "bgpTimerConfiguredHoldTimeMsecs", | |
9230 | bgp->default_holdtime); | |
9231 | json_object_int_add( | |
9232 | json_neigh, | |
9233 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
9234 | bgp->default_keepalive); | |
d62a17ae | 9235 | } |
9236 | } else { | |
9237 | /* Administrative shutdown. */ | |
9238 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
9239 | vty_out(vty, " Administratively shut down\n"); | |
9240 | ||
9241 | /* BGP Version. */ | |
9242 | vty_out(vty, " BGP version 4"); | |
0e38aeb4 | 9243 | vty_out(vty, ", remote router ID %s", |
d62a17ae | 9244 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
0e38aeb4 AD |
9245 | vty_out(vty, ", local router ID %s\n", |
9246 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
9247 | sizeof(buf1))); | |
d62a17ae | 9248 | |
9249 | /* Confederation */ | |
9250 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
9251 | && bgp_confederation_peers_check(bgp, p->as)) | |
9252 | vty_out(vty, | |
9253 | " Neighbor under common administration\n"); | |
9254 | ||
9255 | /* Status. */ | |
9256 | vty_out(vty, " BGP state = %s", | |
9257 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
9258 | ||
9259 | if (p->status == Established) | |
9260 | vty_out(vty, ", up for %8s", | |
9261 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
9262 | 0, NULL)); | |
9263 | ||
9264 | else if (p->status == Active) { | |
9265 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
9266 | vty_out(vty, " (passive)"); | |
9267 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
9268 | vty_out(vty, " (NSF passive)"); | |
9269 | } | |
9270 | vty_out(vty, "\n"); | |
9271 | ||
9272 | /* read timer */ | |
9273 | vty_out(vty, " Last read %s", | |
9274 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
9275 | NULL)); | |
9276 | vty_out(vty, ", Last write %s\n", | |
9277 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
9278 | NULL)); | |
9279 | ||
9280 | /* Configured timer values. */ | |
9281 | vty_out(vty, | |
9282 | " Hold time is %d, keepalive interval is %d seconds\n", | |
9283 | p->v_holdtime, p->v_keepalive); | |
b90a8e13 | 9284 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 9285 | vty_out(vty, " Configured hold time is %d", |
9286 | p->holdtime); | |
9287 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
9288 | p->keepalive); | |
d25e4efc | 9289 | } else if ((bgp->default_holdtime != BGP_DEFAULT_HOLDTIME) |
a4d82a8a PZ |
9290 | || (bgp->default_keepalive |
9291 | != BGP_DEFAULT_KEEPALIVE)) { | |
d25e4efc DS |
9292 | vty_out(vty, " Configured hold time is %d", |
9293 | bgp->default_holdtime); | |
9294 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
9295 | bgp->default_keepalive); | |
d62a17ae | 9296 | } |
9297 | } | |
9298 | /* Capability. */ | |
9299 | if (p->status == Established) { | |
9300 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] | |
9301 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
9302 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
9303 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
9304 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
9305 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
9306 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
9307 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
9308 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
9309 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
9310 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
9311 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
7c40bf39 | 9312 | || p->afc_adv[AFI_IP6][SAFI_FLOWSPEC] |
9313 | || p->afc_recv[AFI_IP6][SAFI_FLOWSPEC] | |
d62a17ae | 9314 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
9315 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
7c40bf39 | 9316 | || p->afc_adv[AFI_IP][SAFI_FLOWSPEC] |
9317 | || p->afc_recv[AFI_IP][SAFI_FLOWSPEC] | |
d62a17ae | 9318 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
9319 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
9320 | if (use_json) { | |
9321 | json_object *json_cap = NULL; | |
9322 | ||
9323 | json_cap = json_object_new_object(); | |
9324 | ||
9325 | /* AS4 */ | |
9326 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
9327 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
9328 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
9329 | && CHECK_FLAG(p->cap, | |
9330 | PEER_CAP_AS4_RCV)) | |
9331 | json_object_string_add( | |
9332 | json_cap, "4byteAs", | |
9333 | "advertisedAndReceived"); | |
9334 | else if (CHECK_FLAG(p->cap, | |
9335 | PEER_CAP_AS4_ADV)) | |
9336 | json_object_string_add( | |
9337 | json_cap, "4byteAs", | |
9338 | "advertised"); | |
9339 | else if (CHECK_FLAG(p->cap, | |
9340 | PEER_CAP_AS4_RCV)) | |
9341 | json_object_string_add( | |
9342 | json_cap, "4byteAs", | |
9343 | "received"); | |
9344 | } | |
9345 | ||
9346 | /* AddPath */ | |
9347 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
9348 | || CHECK_FLAG(p->cap, | |
9349 | PEER_CAP_ADDPATH_ADV)) { | |
9350 | json_object *json_add = NULL; | |
9351 | const char *print_store; | |
9352 | ||
9353 | json_add = json_object_new_object(); | |
9354 | ||
05c7a1cc QY |
9355 | FOREACH_AFI_SAFI (afi, safi) { |
9356 | json_object *json_sub = NULL; | |
9357 | json_sub = | |
9358 | json_object_new_object(); | |
9359 | print_store = afi_safi_print( | |
9360 | afi, safi); | |
d62a17ae | 9361 | |
05c7a1cc QY |
9362 | if (CHECK_FLAG( |
9363 | p->af_cap[afi] | |
9364 | [safi], | |
9365 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9366 | || CHECK_FLAG( | |
9367 | p->af_cap[afi] | |
9368 | [safi], | |
9369 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 9370 | if (CHECK_FLAG( |
9371 | p->af_cap | |
9372 | [afi] | |
9373 | [safi], | |
9374 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 9375 | && CHECK_FLAG( |
d62a17ae | 9376 | p->af_cap |
9377 | [afi] | |
9378 | [safi], | |
05c7a1cc QY |
9379 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
9380 | json_object_boolean_true_add( | |
9381 | json_sub, | |
9382 | "txAdvertisedAndReceived"); | |
9383 | else if ( | |
9384 | CHECK_FLAG( | |
9385 | p->af_cap | |
9386 | [afi] | |
9387 | [safi], | |
9388 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
9389 | json_object_boolean_true_add( | |
9390 | json_sub, | |
9391 | "txAdvertised"); | |
9392 | else if ( | |
9393 | CHECK_FLAG( | |
9394 | p->af_cap | |
9395 | [afi] | |
9396 | [safi], | |
9397 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
9398 | json_object_boolean_true_add( | |
9399 | json_sub, | |
9400 | "txReceived"); | |
9401 | } | |
d62a17ae | 9402 | |
05c7a1cc QY |
9403 | if (CHECK_FLAG( |
9404 | p->af_cap[afi] | |
9405 | [safi], | |
9406 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9407 | || CHECK_FLAG( | |
9408 | p->af_cap[afi] | |
9409 | [safi], | |
9410 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 9411 | if (CHECK_FLAG( |
9412 | p->af_cap | |
9413 | [afi] | |
9414 | [safi], | |
9415 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 9416 | && CHECK_FLAG( |
d62a17ae | 9417 | p->af_cap |
9418 | [afi] | |
9419 | [safi], | |
9420 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
9421 | json_object_boolean_true_add( |
9422 | json_sub, | |
9423 | "rxAdvertisedAndReceived"); | |
9424 | else if ( | |
9425 | CHECK_FLAG( | |
9426 | p->af_cap | |
9427 | [afi] | |
9428 | [safi], | |
9429 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
9430 | json_object_boolean_true_add( | |
9431 | json_sub, | |
9432 | "rxAdvertised"); | |
9433 | else if ( | |
9434 | CHECK_FLAG( | |
9435 | p->af_cap | |
9436 | [afi] | |
9437 | [safi], | |
9438 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
9439 | json_object_boolean_true_add( | |
9440 | json_sub, | |
9441 | "rxReceived"); | |
d62a17ae | 9442 | } |
9443 | ||
05c7a1cc QY |
9444 | if (CHECK_FLAG( |
9445 | p->af_cap[afi] | |
9446 | [safi], | |
9447 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9448 | || CHECK_FLAG( | |
9449 | p->af_cap[afi] | |
9450 | [safi], | |
9451 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
9452 | || CHECK_FLAG( | |
9453 | p->af_cap[afi] | |
9454 | [safi], | |
9455 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9456 | || CHECK_FLAG( | |
9457 | p->af_cap[afi] | |
9458 | [safi], | |
9459 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
9460 | json_object_object_add( | |
9461 | json_add, | |
9462 | print_store, | |
9463 | json_sub); | |
9464 | else | |
9465 | json_object_free( | |
9466 | json_sub); | |
9467 | } | |
9468 | ||
d62a17ae | 9469 | json_object_object_add( |
9470 | json_cap, "addPath", json_add); | |
9471 | } | |
9472 | ||
9473 | /* Dynamic */ | |
9474 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
9475 | || CHECK_FLAG(p->cap, | |
9476 | PEER_CAP_DYNAMIC_ADV)) { | |
9477 | if (CHECK_FLAG(p->cap, | |
9478 | PEER_CAP_DYNAMIC_ADV) | |
9479 | && CHECK_FLAG(p->cap, | |
9480 | PEER_CAP_DYNAMIC_RCV)) | |
9481 | json_object_string_add( | |
9482 | json_cap, "dynamic", | |
9483 | "advertisedAndReceived"); | |
9484 | else if (CHECK_FLAG( | |
9485 | p->cap, | |
9486 | PEER_CAP_DYNAMIC_ADV)) | |
9487 | json_object_string_add( | |
9488 | json_cap, "dynamic", | |
9489 | "advertised"); | |
9490 | else if (CHECK_FLAG( | |
9491 | p->cap, | |
9492 | PEER_CAP_DYNAMIC_RCV)) | |
9493 | json_object_string_add( | |
9494 | json_cap, "dynamic", | |
9495 | "received"); | |
9496 | } | |
9497 | ||
9498 | /* Extended nexthop */ | |
9499 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
9500 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
9501 | json_object *json_nxt = NULL; | |
9502 | const char *print_store; | |
9503 | ||
9504 | ||
9505 | if (CHECK_FLAG(p->cap, | |
9506 | PEER_CAP_ENHE_ADV) | |
9507 | && CHECK_FLAG(p->cap, | |
9508 | PEER_CAP_ENHE_RCV)) | |
9509 | json_object_string_add( | |
9510 | json_cap, | |
9511 | "extendedNexthop", | |
9512 | "advertisedAndReceived"); | |
9513 | else if (CHECK_FLAG(p->cap, | |
9514 | PEER_CAP_ENHE_ADV)) | |
9515 | json_object_string_add( | |
9516 | json_cap, | |
9517 | "extendedNexthop", | |
9518 | "advertised"); | |
9519 | else if (CHECK_FLAG(p->cap, | |
9520 | PEER_CAP_ENHE_RCV)) | |
9521 | json_object_string_add( | |
9522 | json_cap, | |
9523 | "extendedNexthop", | |
9524 | "received"); | |
9525 | ||
9526 | if (CHECK_FLAG(p->cap, | |
9527 | PEER_CAP_ENHE_RCV)) { | |
9528 | json_nxt = | |
9529 | json_object_new_object(); | |
9530 | ||
9531 | for (safi = SAFI_UNICAST; | |
9532 | safi < SAFI_MAX; safi++) { | |
9533 | if (CHECK_FLAG( | |
9534 | p->af_cap | |
9535 | [AFI_IP] | |
9536 | [safi], | |
9537 | PEER_CAP_ENHE_AF_RCV)) { | |
9538 | print_store = afi_safi_print( | |
9539 | AFI_IP, | |
9540 | safi); | |
9541 | json_object_string_add( | |
9542 | json_nxt, | |
9543 | print_store, | |
9544 | "recieved"); | |
9545 | } | |
9546 | } | |
9547 | json_object_object_add( | |
9548 | json_cap, | |
9549 | "extendedNexthopFamililesByPeer", | |
9550 | json_nxt); | |
9551 | } | |
9552 | } | |
9553 | ||
9554 | /* Route Refresh */ | |
9555 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
9556 | || CHECK_FLAG(p->cap, | |
9557 | PEER_CAP_REFRESH_NEW_RCV) | |
9558 | || CHECK_FLAG(p->cap, | |
9559 | PEER_CAP_REFRESH_OLD_RCV)) { | |
9560 | if (CHECK_FLAG(p->cap, | |
9561 | PEER_CAP_REFRESH_ADV) | |
9562 | && (CHECK_FLAG( | |
9563 | p->cap, | |
9564 | PEER_CAP_REFRESH_NEW_RCV) | |
9565 | || CHECK_FLAG( | |
9566 | p->cap, | |
9567 | PEER_CAP_REFRESH_OLD_RCV))) { | |
9568 | if (CHECK_FLAG( | |
9569 | p->cap, | |
9570 | PEER_CAP_REFRESH_OLD_RCV) | |
9571 | && CHECK_FLAG( | |
9572 | p->cap, | |
9573 | PEER_CAP_REFRESH_NEW_RCV)) | |
9574 | json_object_string_add( | |
9575 | json_cap, | |
9576 | "routeRefresh", | |
9577 | "advertisedAndReceivedOldNew"); | |
9578 | else { | |
9579 | if (CHECK_FLAG( | |
9580 | p->cap, | |
9581 | PEER_CAP_REFRESH_OLD_RCV)) | |
9582 | json_object_string_add( | |
9583 | json_cap, | |
9584 | "routeRefresh", | |
9585 | "advertisedAndReceivedOld"); | |
9586 | else | |
9587 | json_object_string_add( | |
9588 | json_cap, | |
9589 | "routeRefresh", | |
9590 | "advertisedAndReceivedNew"); | |
9591 | } | |
9592 | } else if ( | |
9593 | CHECK_FLAG( | |
9594 | p->cap, | |
9595 | PEER_CAP_REFRESH_ADV)) | |
9596 | json_object_string_add( | |
9597 | json_cap, | |
9598 | "routeRefresh", | |
9599 | "advertised"); | |
9600 | else if ( | |
9601 | CHECK_FLAG( | |
9602 | p->cap, | |
9603 | PEER_CAP_REFRESH_NEW_RCV) | |
9604 | || CHECK_FLAG( | |
9605 | p->cap, | |
9606 | PEER_CAP_REFRESH_OLD_RCV)) | |
9607 | json_object_string_add( | |
9608 | json_cap, | |
9609 | "routeRefresh", | |
9610 | "received"); | |
9611 | } | |
9612 | ||
9613 | /* Multiprotocol Extensions */ | |
9614 | json_object *json_multi = NULL; | |
9615 | json_multi = json_object_new_object(); | |
9616 | ||
05c7a1cc QY |
9617 | FOREACH_AFI_SAFI (afi, safi) { |
9618 | if (p->afc_adv[afi][safi] | |
9619 | || p->afc_recv[afi][safi]) { | |
9620 | json_object *json_exten = NULL; | |
9621 | json_exten = | |
9622 | json_object_new_object(); | |
9623 | ||
d62a17ae | 9624 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
9625 | && p->afc_recv[afi][safi]) |
9626 | json_object_boolean_true_add( | |
9627 | json_exten, | |
9628 | "advertisedAndReceived"); | |
9629 | else if (p->afc_adv[afi][safi]) | |
9630 | json_object_boolean_true_add( | |
9631 | json_exten, | |
9632 | "advertised"); | |
9633 | else if (p->afc_recv[afi][safi]) | |
9634 | json_object_boolean_true_add( | |
9635 | json_exten, | |
9636 | "received"); | |
d62a17ae | 9637 | |
05c7a1cc QY |
9638 | json_object_object_add( |
9639 | json_multi, | |
9640 | afi_safi_print(afi, | |
9641 | safi), | |
9642 | json_exten); | |
d62a17ae | 9643 | } |
9644 | } | |
9645 | json_object_object_add( | |
9646 | json_cap, "multiprotocolExtensions", | |
9647 | json_multi); | |
9648 | ||
d77114b7 | 9649 | /* Hostname capabilities */ |
60466a63 | 9650 | json_object *json_hname = NULL; |
d77114b7 MK |
9651 | |
9652 | json_hname = json_object_new_object(); | |
9653 | ||
9654 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
9655 | json_object_string_add( | |
60466a63 QY |
9656 | json_hname, "advHostName", |
9657 | bgp->peer_self->hostname | |
9658 | ? bgp->peer_self | |
9659 | ->hostname | |
d77114b7 MK |
9660 | : "n/a"); |
9661 | json_object_string_add( | |
60466a63 QY |
9662 | json_hname, "advDomainName", |
9663 | bgp->peer_self->domainname | |
9664 | ? bgp->peer_self | |
9665 | ->domainname | |
d77114b7 MK |
9666 | : "n/a"); |
9667 | } | |
9668 | ||
9669 | ||
9670 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
9671 | json_object_string_add( | |
60466a63 QY |
9672 | json_hname, "rcvHostName", |
9673 | p->hostname ? p->hostname | |
9674 | : "n/a"); | |
d77114b7 | 9675 | json_object_string_add( |
60466a63 QY |
9676 | json_hname, "rcvDomainName", |
9677 | p->domainname ? p->domainname | |
9678 | : "n/a"); | |
d77114b7 MK |
9679 | } |
9680 | ||
60466a63 | 9681 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
9682 | json_hname); |
9683 | ||
d62a17ae | 9684 | /* Gracefull Restart */ |
9685 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
9686 | || CHECK_FLAG(p->cap, | |
9687 | PEER_CAP_RESTART_ADV)) { | |
9688 | if (CHECK_FLAG(p->cap, | |
9689 | PEER_CAP_RESTART_ADV) | |
9690 | && CHECK_FLAG(p->cap, | |
9691 | PEER_CAP_RESTART_RCV)) | |
9692 | json_object_string_add( | |
9693 | json_cap, | |
9694 | "gracefulRestart", | |
9695 | "advertisedAndReceived"); | |
9696 | else if (CHECK_FLAG( | |
9697 | p->cap, | |
9698 | PEER_CAP_RESTART_ADV)) | |
9699 | json_object_string_add( | |
9700 | json_cap, | |
9701 | "gracefulRestartCapability", | |
9702 | "advertised"); | |
9703 | else if (CHECK_FLAG( | |
9704 | p->cap, | |
9705 | PEER_CAP_RESTART_RCV)) | |
9706 | json_object_string_add( | |
9707 | json_cap, | |
9708 | "gracefulRestartCapability", | |
9709 | "received"); | |
9710 | ||
9711 | if (CHECK_FLAG(p->cap, | |
9712 | PEER_CAP_RESTART_RCV)) { | |
9713 | int restart_af_count = 0; | |
9714 | json_object *json_restart = | |
9715 | NULL; | |
9716 | json_restart = | |
9717 | json_object_new_object(); | |
9718 | ||
9719 | json_object_int_add( | |
9720 | json_cap, | |
9721 | "gracefulRestartRemoteTimerMsecs", | |
9722 | p->v_gr_restart * 1000); | |
9723 | ||
05c7a1cc QY |
9724 | FOREACH_AFI_SAFI (afi, safi) { |
9725 | if (CHECK_FLAG( | |
9726 | p->af_cap | |
9727 | [afi] | |
9728 | [safi], | |
9729 | PEER_CAP_RESTART_AF_RCV)) { | |
9730 | json_object * | |
9731 | json_sub = | |
9732 | NULL; | |
9733 | json_sub = | |
9734 | json_object_new_object(); | |
9735 | ||
d62a17ae | 9736 | if (CHECK_FLAG( |
9737 | p->af_cap | |
9738 | [afi] | |
9739 | [safi], | |
05c7a1cc QY |
9740 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
9741 | json_object_boolean_true_add( | |
9742 | json_sub, | |
9743 | "preserved"); | |
9744 | restart_af_count++; | |
9745 | json_object_object_add( | |
9746 | json_restart, | |
9747 | afi_safi_print( | |
9748 | afi, | |
9749 | safi), | |
9750 | json_sub); | |
d62a17ae | 9751 | } |
9752 | } | |
9753 | if (!restart_af_count) { | |
9754 | json_object_string_add( | |
9755 | json_cap, | |
9756 | "addressFamiliesByPeer", | |
9757 | "none"); | |
9758 | json_object_free( | |
9759 | json_restart); | |
9760 | } else | |
9761 | json_object_object_add( | |
9762 | json_cap, | |
9763 | "addressFamiliesByPeer", | |
9764 | json_restart); | |
9765 | } | |
9766 | } | |
9767 | json_object_object_add(json_neigh, | |
9768 | "neighborCapabilities", | |
9769 | json_cap); | |
9770 | } else { | |
9771 | vty_out(vty, " Neighbor capabilities:\n"); | |
9772 | ||
9773 | /* AS4 */ | |
9774 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
9775 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
9776 | vty_out(vty, " 4 Byte AS:"); | |
9777 | if (CHECK_FLAG(p->cap, | |
9778 | PEER_CAP_AS4_ADV)) | |
9779 | vty_out(vty, " advertised"); | |
9780 | if (CHECK_FLAG(p->cap, | |
9781 | PEER_CAP_AS4_RCV)) | |
9782 | vty_out(vty, " %sreceived", | |
9783 | CHECK_FLAG( | |
9784 | p->cap, | |
9785 | PEER_CAP_AS4_ADV) | |
9786 | ? "and " | |
9787 | : ""); | |
9788 | vty_out(vty, "\n"); | |
9789 | } | |
9790 | ||
9791 | /* AddPath */ | |
9792 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
9793 | || CHECK_FLAG(p->cap, | |
9794 | PEER_CAP_ADDPATH_ADV)) { | |
9795 | vty_out(vty, " AddPath:\n"); | |
9796 | ||
05c7a1cc QY |
9797 | FOREACH_AFI_SAFI (afi, safi) { |
9798 | if (CHECK_FLAG( | |
9799 | p->af_cap[afi] | |
9800 | [safi], | |
9801 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9802 | || CHECK_FLAG( | |
9803 | p->af_cap[afi] | |
9804 | [safi], | |
9805 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
9806 | vty_out(vty, | |
9807 | " %s: TX ", | |
9808 | afi_safi_print( | |
9809 | afi, | |
9810 | safi)); | |
9811 | ||
d62a17ae | 9812 | if (CHECK_FLAG( |
9813 | p->af_cap | |
9814 | [afi] | |
9815 | [safi], | |
05c7a1cc | 9816 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 9817 | vty_out(vty, |
05c7a1cc | 9818 | "advertised %s", |
d62a17ae | 9819 | afi_safi_print( |
9820 | afi, | |
9821 | safi)); | |
9822 | ||
05c7a1cc QY |
9823 | if (CHECK_FLAG( |
9824 | p->af_cap | |
9825 | [afi] | |
9826 | [safi], | |
9827 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
9828 | vty_out(vty, | |
9829 | "%sreceived", | |
9830 | CHECK_FLAG( | |
9831 | p->af_cap | |
9832 | [afi] | |
9833 | [safi], | |
9834 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9835 | ? " and " | |
9836 | : ""); | |
d62a17ae | 9837 | |
05c7a1cc QY |
9838 | vty_out(vty, "\n"); |
9839 | } | |
d62a17ae | 9840 | |
05c7a1cc QY |
9841 | if (CHECK_FLAG( |
9842 | p->af_cap[afi] | |
9843 | [safi], | |
9844 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9845 | || CHECK_FLAG( | |
9846 | p->af_cap[afi] | |
9847 | [safi], | |
9848 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
9849 | vty_out(vty, | |
9850 | " %s: RX ", | |
9851 | afi_safi_print( | |
9852 | afi, | |
9853 | safi)); | |
d62a17ae | 9854 | |
9855 | if (CHECK_FLAG( | |
9856 | p->af_cap | |
9857 | [afi] | |
9858 | [safi], | |
05c7a1cc | 9859 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 9860 | vty_out(vty, |
05c7a1cc | 9861 | "advertised %s", |
d62a17ae | 9862 | afi_safi_print( |
9863 | afi, | |
9864 | safi)); | |
9865 | ||
05c7a1cc QY |
9866 | if (CHECK_FLAG( |
9867 | p->af_cap | |
9868 | [afi] | |
9869 | [safi], | |
9870 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 9871 | vty_out(vty, |
05c7a1cc QY |
9872 | "%sreceived", |
9873 | CHECK_FLAG( | |
9874 | p->af_cap | |
9875 | [afi] | |
9876 | [safi], | |
9877 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9878 | ? " and " | |
9879 | : ""); | |
9880 | ||
9881 | vty_out(vty, "\n"); | |
d62a17ae | 9882 | } |
05c7a1cc | 9883 | } |
d62a17ae | 9884 | } |
9885 | ||
9886 | /* Dynamic */ | |
9887 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
9888 | || CHECK_FLAG(p->cap, | |
9889 | PEER_CAP_DYNAMIC_ADV)) { | |
9890 | vty_out(vty, " Dynamic:"); | |
9891 | if (CHECK_FLAG(p->cap, | |
9892 | PEER_CAP_DYNAMIC_ADV)) | |
9893 | vty_out(vty, " advertised"); | |
9894 | if (CHECK_FLAG(p->cap, | |
9895 | PEER_CAP_DYNAMIC_RCV)) | |
9896 | vty_out(vty, " %sreceived", | |
9897 | CHECK_FLAG( | |
9898 | p->cap, | |
9899 | PEER_CAP_DYNAMIC_ADV) | |
9900 | ? "and " | |
9901 | : ""); | |
9902 | vty_out(vty, "\n"); | |
9903 | } | |
9904 | ||
9905 | /* Extended nexthop */ | |
9906 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
9907 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
9908 | vty_out(vty, " Extended nexthop:"); | |
9909 | if (CHECK_FLAG(p->cap, | |
9910 | PEER_CAP_ENHE_ADV)) | |
9911 | vty_out(vty, " advertised"); | |
9912 | if (CHECK_FLAG(p->cap, | |
9913 | PEER_CAP_ENHE_RCV)) | |
9914 | vty_out(vty, " %sreceived", | |
9915 | CHECK_FLAG( | |
9916 | p->cap, | |
9917 | PEER_CAP_ENHE_ADV) | |
9918 | ? "and " | |
9919 | : ""); | |
9920 | vty_out(vty, "\n"); | |
9921 | ||
9922 | if (CHECK_FLAG(p->cap, | |
9923 | PEER_CAP_ENHE_RCV)) { | |
9924 | vty_out(vty, | |
9925 | " Address families by peer:\n "); | |
9926 | for (safi = SAFI_UNICAST; | |
9927 | safi < SAFI_MAX; safi++) | |
9928 | if (CHECK_FLAG( | |
9929 | p->af_cap | |
9930 | [AFI_IP] | |
9931 | [safi], | |
9932 | PEER_CAP_ENHE_AF_RCV)) | |
9933 | vty_out(vty, | |
9934 | " %s\n", | |
9935 | afi_safi_print( | |
9936 | AFI_IP, | |
9937 | safi)); | |
9938 | } | |
9939 | } | |
9940 | ||
9941 | /* Route Refresh */ | |
9942 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
9943 | || CHECK_FLAG(p->cap, | |
9944 | PEER_CAP_REFRESH_NEW_RCV) | |
9945 | || CHECK_FLAG(p->cap, | |
9946 | PEER_CAP_REFRESH_OLD_RCV)) { | |
9947 | vty_out(vty, " Route refresh:"); | |
9948 | if (CHECK_FLAG(p->cap, | |
9949 | PEER_CAP_REFRESH_ADV)) | |
9950 | vty_out(vty, " advertised"); | |
9951 | if (CHECK_FLAG(p->cap, | |
9952 | PEER_CAP_REFRESH_NEW_RCV) | |
9953 | || CHECK_FLAG( | |
9954 | p->cap, | |
9955 | PEER_CAP_REFRESH_OLD_RCV)) | |
9956 | vty_out(vty, " %sreceived(%s)", | |
9957 | CHECK_FLAG( | |
9958 | p->cap, | |
9959 | PEER_CAP_REFRESH_ADV) | |
9960 | ? "and " | |
9961 | : "", | |
9962 | (CHECK_FLAG( | |
9963 | p->cap, | |
9964 | PEER_CAP_REFRESH_OLD_RCV) | |
9965 | && CHECK_FLAG( | |
9966 | p->cap, | |
9967 | PEER_CAP_REFRESH_NEW_RCV)) | |
9968 | ? "old & new" | |
9969 | : CHECK_FLAG( | |
9970 | p->cap, | |
9971 | PEER_CAP_REFRESH_OLD_RCV) | |
9972 | ? "old" | |
9973 | : "new"); | |
9974 | ||
9975 | vty_out(vty, "\n"); | |
9976 | } | |
9977 | ||
9978 | /* Multiprotocol Extensions */ | |
05c7a1cc QY |
9979 | FOREACH_AFI_SAFI (afi, safi) |
9980 | if (p->afc_adv[afi][safi] | |
9981 | || p->afc_recv[afi][safi]) { | |
9982 | vty_out(vty, | |
9983 | " Address Family %s:", | |
9984 | afi_safi_print(afi, | |
9985 | safi)); | |
9986 | if (p->afc_adv[afi][safi]) | |
d62a17ae | 9987 | vty_out(vty, |
05c7a1cc QY |
9988 | " advertised"); |
9989 | if (p->afc_recv[afi][safi]) | |
9990 | vty_out(vty, | |
9991 | " %sreceived", | |
9992 | p->afc_adv[afi] | |
9993 | [safi] | |
9994 | ? "and " | |
9995 | : ""); | |
9996 | vty_out(vty, "\n"); | |
9997 | } | |
d62a17ae | 9998 | |
9999 | /* Hostname capability */ | |
60466a63 | 10000 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
10001 | |
10002 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
10003 | vty_out(vty, |
10004 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
10005 | bgp->peer_self->hostname |
10006 | ? bgp->peer_self | |
10007 | ->hostname | |
d77114b7 | 10008 | : "n/a", |
60466a63 QY |
10009 | bgp->peer_self->domainname |
10010 | ? bgp->peer_self | |
10011 | ->domainname | |
d77114b7 MK |
10012 | : "n/a"); |
10013 | } else { | |
10014 | vty_out(vty, " not advertised"); | |
d62a17ae | 10015 | } |
10016 | ||
d77114b7 | 10017 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
10018 | vty_out(vty, |
10019 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
10020 | p->hostname ? p->hostname |
10021 | : "n/a", | |
10022 | p->domainname ? p->domainname | |
10023 | : "n/a"); | |
d77114b7 MK |
10024 | } else { |
10025 | vty_out(vty, " not received"); | |
10026 | } | |
10027 | ||
10028 | vty_out(vty, "\n"); | |
10029 | ||
d62a17ae | 10030 | /* Gracefull Restart */ |
10031 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
10032 | || CHECK_FLAG(p->cap, | |
10033 | PEER_CAP_RESTART_ADV)) { | |
10034 | vty_out(vty, | |
10035 | " Graceful Restart Capabilty:"); | |
10036 | if (CHECK_FLAG(p->cap, | |
10037 | PEER_CAP_RESTART_ADV)) | |
10038 | vty_out(vty, " advertised"); | |
10039 | if (CHECK_FLAG(p->cap, | |
10040 | PEER_CAP_RESTART_RCV)) | |
10041 | vty_out(vty, " %sreceived", | |
10042 | CHECK_FLAG( | |
10043 | p->cap, | |
10044 | PEER_CAP_RESTART_ADV) | |
10045 | ? "and " | |
10046 | : ""); | |
10047 | vty_out(vty, "\n"); | |
10048 | ||
10049 | if (CHECK_FLAG(p->cap, | |
10050 | PEER_CAP_RESTART_RCV)) { | |
10051 | int restart_af_count = 0; | |
10052 | ||
10053 | vty_out(vty, | |
10054 | " Remote Restart timer is %d seconds\n", | |
10055 | p->v_gr_restart); | |
10056 | vty_out(vty, | |
10057 | " Address families by peer:\n "); | |
10058 | ||
05c7a1cc QY |
10059 | FOREACH_AFI_SAFI (afi, safi) |
10060 | if (CHECK_FLAG( | |
10061 | p->af_cap | |
10062 | [afi] | |
10063 | [safi], | |
10064 | PEER_CAP_RESTART_AF_RCV)) { | |
10065 | vty_out(vty, | |
10066 | "%s%s(%s)", | |
10067 | restart_af_count | |
10068 | ? ", " | |
10069 | : "", | |
10070 | afi_safi_print( | |
10071 | afi, | |
10072 | safi), | |
10073 | CHECK_FLAG( | |
10074 | p->af_cap | |
10075 | [afi] | |
10076 | [safi], | |
10077 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
10078 | ? "preserved" | |
10079 | : "not preserved"); | |
10080 | restart_af_count++; | |
10081 | } | |
d62a17ae | 10082 | if (!restart_af_count) |
10083 | vty_out(vty, "none"); | |
10084 | vty_out(vty, "\n"); | |
10085 | } | |
10086 | } | |
10087 | } | |
10088 | } | |
10089 | } | |
10090 | ||
10091 | /* graceful restart information */ | |
10092 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) || p->t_gr_restart | |
10093 | || p->t_gr_stale) { | |
10094 | json_object *json_grace = NULL; | |
10095 | json_object *json_grace_send = NULL; | |
10096 | json_object *json_grace_recv = NULL; | |
10097 | int eor_send_af_count = 0; | |
10098 | int eor_receive_af_count = 0; | |
10099 | ||
10100 | if (use_json) { | |
10101 | json_grace = json_object_new_object(); | |
10102 | json_grace_send = json_object_new_object(); | |
10103 | json_grace_recv = json_object_new_object(); | |
10104 | ||
10105 | if (p->status == Established) { | |
05c7a1cc QY |
10106 | FOREACH_AFI_SAFI (afi, safi) { |
10107 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10108 | PEER_STATUS_EOR_SEND)) { | |
10109 | json_object_boolean_true_add( | |
10110 | json_grace_send, | |
10111 | afi_safi_print(afi, | |
10112 | safi)); | |
10113 | eor_send_af_count++; | |
d62a17ae | 10114 | } |
10115 | } | |
05c7a1cc QY |
10116 | FOREACH_AFI_SAFI (afi, safi) { |
10117 | if (CHECK_FLAG( | |
10118 | p->af_sflags[afi][safi], | |
10119 | PEER_STATUS_EOR_RECEIVED)) { | |
10120 | json_object_boolean_true_add( | |
10121 | json_grace_recv, | |
10122 | afi_safi_print(afi, | |
10123 | safi)); | |
10124 | eor_receive_af_count++; | |
d62a17ae | 10125 | } |
10126 | } | |
10127 | } | |
10128 | ||
10129 | json_object_object_add(json_grace, "endOfRibSend", | |
10130 | json_grace_send); | |
10131 | json_object_object_add(json_grace, "endOfRibRecv", | |
10132 | json_grace_recv); | |
10133 | ||
10134 | if (p->t_gr_restart) | |
10135 | json_object_int_add(json_grace, | |
10136 | "gracefulRestartTimerMsecs", | |
10137 | thread_timer_remain_second( | |
10138 | p->t_gr_restart) | |
10139 | * 1000); | |
10140 | ||
10141 | if (p->t_gr_stale) | |
10142 | json_object_int_add( | |
10143 | json_grace, | |
10144 | "gracefulStalepathTimerMsecs", | |
10145 | thread_timer_remain_second( | |
10146 | p->t_gr_stale) | |
10147 | * 1000); | |
10148 | ||
10149 | json_object_object_add( | |
10150 | json_neigh, "gracefulRestartInfo", json_grace); | |
10151 | } else { | |
10152 | vty_out(vty, " Graceful restart informations:\n"); | |
10153 | if (p->status == Established) { | |
10154 | vty_out(vty, " End-of-RIB send: "); | |
05c7a1cc QY |
10155 | FOREACH_AFI_SAFI (afi, safi) { |
10156 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10157 | PEER_STATUS_EOR_SEND)) { | |
10158 | vty_out(vty, "%s%s", | |
10159 | eor_send_af_count ? ", " | |
10160 | : "", | |
10161 | afi_safi_print(afi, | |
10162 | safi)); | |
10163 | eor_send_af_count++; | |
d62a17ae | 10164 | } |
10165 | } | |
10166 | vty_out(vty, "\n"); | |
10167 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
10168 | FOREACH_AFI_SAFI (afi, safi) { |
10169 | if (CHECK_FLAG( | |
10170 | p->af_sflags[afi][safi], | |
10171 | PEER_STATUS_EOR_RECEIVED)) { | |
10172 | vty_out(vty, "%s%s", | |
10173 | eor_receive_af_count | |
10174 | ? ", " | |
10175 | : "", | |
10176 | afi_safi_print(afi, | |
10177 | safi)); | |
10178 | eor_receive_af_count++; | |
d62a17ae | 10179 | } |
10180 | } | |
10181 | vty_out(vty, "\n"); | |
10182 | } | |
10183 | ||
10184 | if (p->t_gr_restart) | |
10185 | vty_out(vty, | |
10186 | " The remaining time of restart timer is %ld\n", | |
10187 | thread_timer_remain_second( | |
10188 | p->t_gr_restart)); | |
10189 | ||
10190 | if (p->t_gr_stale) | |
10191 | vty_out(vty, | |
10192 | " The remaining time of stalepath timer is %ld\n", | |
10193 | thread_timer_remain_second( | |
10194 | p->t_gr_stale)); | |
10195 | } | |
10196 | } | |
10197 | if (use_json) { | |
10198 | json_object *json_stat = NULL; | |
10199 | json_stat = json_object_new_object(); | |
10200 | /* Packet counts. */ | |
10201 | json_object_int_add(json_stat, "depthInq", 0); | |
10202 | json_object_int_add(json_stat, "depthOutq", | |
10203 | (unsigned long)p->obuf->count); | |
0112e9e0 QY |
10204 | json_object_int_add(json_stat, "opensSent", |
10205 | atomic_load_explicit(&p->open_out, | |
10206 | memory_order_relaxed)); | |
10207 | json_object_int_add(json_stat, "opensRecv", | |
10208 | atomic_load_explicit(&p->open_in, | |
10209 | memory_order_relaxed)); | |
d62a17ae | 10210 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
10211 | atomic_load_explicit(&p->notify_out, |
10212 | memory_order_relaxed)); | |
d62a17ae | 10213 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
10214 | atomic_load_explicit(&p->notify_in, |
10215 | memory_order_relaxed)); | |
10216 | json_object_int_add(json_stat, "updatesSent", | |
10217 | atomic_load_explicit(&p->update_out, | |
10218 | memory_order_relaxed)); | |
10219 | json_object_int_add(json_stat, "updatesRecv", | |
10220 | atomic_load_explicit(&p->update_in, | |
10221 | memory_order_relaxed)); | |
d62a17ae | 10222 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
10223 | atomic_load_explicit(&p->keepalive_out, |
10224 | memory_order_relaxed)); | |
d62a17ae | 10225 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
10226 | atomic_load_explicit(&p->keepalive_in, |
10227 | memory_order_relaxed)); | |
d62a17ae | 10228 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
10229 | atomic_load_explicit(&p->refresh_out, |
10230 | memory_order_relaxed)); | |
d62a17ae | 10231 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
10232 | atomic_load_explicit(&p->refresh_in, |
10233 | memory_order_relaxed)); | |
d62a17ae | 10234 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
10235 | atomic_load_explicit(&p->dynamic_cap_out, |
10236 | memory_order_relaxed)); | |
d62a17ae | 10237 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
10238 | atomic_load_explicit(&p->dynamic_cap_in, |
10239 | memory_order_relaxed)); | |
10240 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
10241 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 10242 | json_object_object_add(json_neigh, "messageStats", json_stat); |
10243 | } else { | |
10244 | /* Packet counts. */ | |
10245 | vty_out(vty, " Message statistics:\n"); | |
10246 | vty_out(vty, " Inq depth is 0\n"); | |
10247 | vty_out(vty, " Outq depth is %lu\n", | |
10248 | (unsigned long)p->obuf->count); | |
10249 | vty_out(vty, " Sent Rcvd\n"); | |
0112e9e0 QY |
10250 | vty_out(vty, " Opens: %10d %10d\n", |
10251 | atomic_load_explicit(&p->open_out, | |
10252 | memory_order_relaxed), | |
10253 | atomic_load_explicit(&p->open_in, | |
10254 | memory_order_relaxed)); | |
10255 | vty_out(vty, " Notifications: %10d %10d\n", | |
10256 | atomic_load_explicit(&p->notify_out, | |
10257 | memory_order_relaxed), | |
10258 | atomic_load_explicit(&p->notify_in, | |
10259 | memory_order_relaxed)); | |
10260 | vty_out(vty, " Updates: %10d %10d\n", | |
10261 | atomic_load_explicit(&p->update_out, | |
10262 | memory_order_relaxed), | |
10263 | atomic_load_explicit(&p->update_in, | |
10264 | memory_order_relaxed)); | |
10265 | vty_out(vty, " Keepalives: %10d %10d\n", | |
10266 | atomic_load_explicit(&p->keepalive_out, | |
10267 | memory_order_relaxed), | |
10268 | atomic_load_explicit(&p->keepalive_in, | |
10269 | memory_order_relaxed)); | |
10270 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
10271 | atomic_load_explicit(&p->refresh_out, | |
10272 | memory_order_relaxed), | |
10273 | atomic_load_explicit(&p->refresh_in, | |
10274 | memory_order_relaxed)); | |
d62a17ae | 10275 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
10276 | atomic_load_explicit(&p->dynamic_cap_out, |
10277 | memory_order_relaxed), | |
10278 | atomic_load_explicit(&p->dynamic_cap_in, | |
10279 | memory_order_relaxed)); | |
10280 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
10281 | PEER_TOTAL_RX(p)); | |
d62a17ae | 10282 | } |
10283 | ||
10284 | if (use_json) { | |
10285 | /* advertisement-interval */ | |
10286 | json_object_int_add(json_neigh, | |
10287 | "minBtwnAdvertisementRunsTimerMsecs", | |
10288 | p->v_routeadv * 1000); | |
10289 | ||
10290 | /* Update-source. */ | |
10291 | if (p->update_if || p->update_source) { | |
10292 | if (p->update_if) | |
10293 | json_object_string_add(json_neigh, | |
10294 | "updateSource", | |
10295 | p->update_if); | |
10296 | else if (p->update_source) | |
10297 | json_object_string_add( | |
10298 | json_neigh, "updateSource", | |
10299 | sockunion2str(p->update_source, buf1, | |
10300 | SU_ADDRSTRLEN)); | |
10301 | } | |
10302 | } else { | |
10303 | /* advertisement-interval */ | |
10304 | vty_out(vty, | |
10305 | " Minimum time between advertisement runs is %d seconds\n", | |
10306 | p->v_routeadv); | |
10307 | ||
10308 | /* Update-source. */ | |
10309 | if (p->update_if || p->update_source) { | |
10310 | vty_out(vty, " Update source is "); | |
10311 | if (p->update_if) | |
10312 | vty_out(vty, "%s", p->update_if); | |
10313 | else if (p->update_source) | |
10314 | vty_out(vty, "%s", | |
10315 | sockunion2str(p->update_source, buf1, | |
10316 | SU_ADDRSTRLEN)); | |
10317 | vty_out(vty, "\n"); | |
10318 | } | |
10319 | ||
10320 | vty_out(vty, "\n"); | |
10321 | } | |
10322 | ||
10323 | /* Address Family Information */ | |
10324 | json_object *json_hold = NULL; | |
10325 | ||
10326 | if (use_json) | |
10327 | json_hold = json_object_new_object(); | |
10328 | ||
05c7a1cc QY |
10329 | FOREACH_AFI_SAFI (afi, safi) |
10330 | if (p->afc[afi][safi]) | |
10331 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
10332 | json_hold); | |
d62a17ae | 10333 | |
10334 | if (use_json) { | |
10335 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
10336 | json_hold); | |
10337 | json_object_int_add(json_neigh, "connectionsEstablished", | |
10338 | p->established); | |
10339 | json_object_int_add(json_neigh, "connectionsDropped", | |
10340 | p->dropped); | |
10341 | } else | |
10342 | vty_out(vty, " Connections established %d; dropped %d\n", | |
10343 | p->established, p->dropped); | |
10344 | ||
10345 | if (!p->last_reset) { | |
10346 | if (use_json) | |
10347 | json_object_string_add(json_neigh, "lastReset", | |
10348 | "never"); | |
10349 | else | |
10350 | vty_out(vty, " Last reset never\n"); | |
10351 | } else { | |
10352 | if (use_json) { | |
10353 | time_t uptime; | |
10354 | struct tm *tm; | |
10355 | ||
10356 | uptime = bgp_clock(); | |
10357 | uptime -= p->resettime; | |
10358 | tm = gmtime(&uptime); | |
10359 | json_object_int_add(json_neigh, "lastResetTimerMsecs", | |
10360 | (tm->tm_sec * 1000) | |
10361 | + (tm->tm_min * 60000) | |
10362 | + (tm->tm_hour * 3600000)); | |
10363 | json_object_string_add( | |
10364 | json_neigh, "lastResetDueTo", | |
10365 | peer_down_str[(int)p->last_reset]); | |
10366 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND | |
10367 | || p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10368 | char errorcodesubcode_hexstr[5]; | |
10369 | char errorcodesubcode_str[256]; | |
10370 | ||
10371 | code_str = bgp_notify_code_str(p->notify.code); | |
10372 | subcode_str = bgp_notify_subcode_str( | |
10373 | p->notify.code, p->notify.subcode); | |
10374 | ||
10375 | sprintf(errorcodesubcode_hexstr, "%02X%02X", | |
10376 | p->notify.code, p->notify.subcode); | |
10377 | json_object_string_add(json_neigh, | |
10378 | "lastErrorCodeSubcode", | |
10379 | errorcodesubcode_hexstr); | |
10380 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
10381 | code_str, subcode_str); | |
10382 | json_object_string_add(json_neigh, | |
10383 | "lastNotificationReason", | |
10384 | errorcodesubcode_str); | |
10385 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
10386 | && p->notify.code == BGP_NOTIFY_CEASE | |
10387 | && (p->notify.subcode | |
10388 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
10389 | || p->notify.subcode | |
10390 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
10391 | && p->notify.length) { | |
10392 | char msgbuf[1024]; | |
10393 | const char *msg_str; | |
10394 | ||
10395 | msg_str = bgp_notify_admin_message( | |
10396 | msgbuf, sizeof(msgbuf), | |
d7c0a89a | 10397 | (uint8_t *)p->notify.data, |
d62a17ae | 10398 | p->notify.length); |
10399 | if (msg_str) | |
10400 | json_object_string_add( | |
10401 | json_neigh, | |
10402 | "lastShutdownDescription", | |
10403 | msg_str); | |
10404 | } | |
10405 | } | |
10406 | } else { | |
10407 | vty_out(vty, " Last reset %s, ", | |
10408 | peer_uptime(p->resettime, timebuf, | |
10409 | BGP_UPTIME_LEN, 0, NULL)); | |
10410 | ||
10411 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND | |
10412 | || p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10413 | code_str = bgp_notify_code_str(p->notify.code); | |
10414 | subcode_str = bgp_notify_subcode_str( | |
10415 | p->notify.code, p->notify.subcode); | |
10416 | vty_out(vty, "due to NOTIFICATION %s (%s%s)\n", | |
10417 | p->last_reset == PEER_DOWN_NOTIFY_SEND | |
10418 | ? "sent" | |
10419 | : "received", | |
10420 | code_str, subcode_str); | |
10421 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
10422 | && p->notify.code == BGP_NOTIFY_CEASE | |
10423 | && (p->notify.subcode | |
10424 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
10425 | || p->notify.subcode | |
10426 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
10427 | && p->notify.length) { | |
10428 | char msgbuf[1024]; | |
10429 | const char *msg_str; | |
10430 | ||
10431 | msg_str = bgp_notify_admin_message( | |
10432 | msgbuf, sizeof(msgbuf), | |
d7c0a89a | 10433 | (uint8_t *)p->notify.data, |
d62a17ae | 10434 | p->notify.length); |
10435 | if (msg_str) | |
10436 | vty_out(vty, | |
10437 | " Message: \"%s\"\n", | |
10438 | msg_str); | |
10439 | } | |
10440 | } else { | |
10441 | vty_out(vty, "due to %s\n", | |
10442 | peer_down_str[(int)p->last_reset]); | |
10443 | } | |
10444 | ||
10445 | if (p->last_reset_cause_size) { | |
10446 | msg = p->last_reset_cause; | |
10447 | vty_out(vty, | |
10448 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
10449 | for (i = 1; i <= p->last_reset_cause_size; | |
10450 | i++) { | |
10451 | vty_out(vty, "%02X", *msg++); | |
10452 | ||
10453 | if (i != p->last_reset_cause_size) { | |
10454 | if (i % 16 == 0) { | |
10455 | vty_out(vty, "\n "); | |
10456 | } else if (i % 4 == 0) { | |
10457 | vty_out(vty, " "); | |
10458 | } | |
10459 | } | |
10460 | } | |
10461 | vty_out(vty, "\n"); | |
10462 | } | |
10463 | } | |
10464 | } | |
10465 | ||
10466 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
10467 | if (use_json) | |
10468 | json_object_boolean_true_add(json_neigh, | |
10469 | "prefixesConfigExceedMax"); | |
10470 | else | |
10471 | vty_out(vty, | |
10472 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
10473 | ||
10474 | if (p->t_pmax_restart) { | |
10475 | if (use_json) { | |
10476 | json_object_boolean_true_add( | |
10477 | json_neigh, "reducePrefixNumFrom"); | |
10478 | json_object_int_add(json_neigh, | |
10479 | "restartInTimerMsec", | |
10480 | thread_timer_remain_second( | |
10481 | p->t_pmax_restart) | |
10482 | * 1000); | |
10483 | } else | |
10484 | vty_out(vty, | |
10485 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
10486 | p->host, thread_timer_remain_second( |
10487 | p->t_pmax_restart)); | |
d62a17ae | 10488 | } else { |
10489 | if (use_json) | |
10490 | json_object_boolean_true_add( | |
10491 | json_neigh, | |
10492 | "reducePrefixNumAndClearIpBgp"); | |
10493 | else | |
10494 | vty_out(vty, | |
10495 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
10496 | p->host); | |
10497 | } | |
10498 | } | |
10499 | ||
10500 | /* EBGP Multihop and GTSM */ | |
10501 | if (p->sort != BGP_PEER_IBGP) { | |
10502 | if (use_json) { | |
10503 | if (p->gtsm_hops > 0) | |
10504 | json_object_int_add(json_neigh, | |
10505 | "externalBgpNbrMaxHopsAway", | |
10506 | p->gtsm_hops); | |
10507 | else if (p->ttl > 1) | |
10508 | json_object_int_add(json_neigh, | |
10509 | "externalBgpNbrMaxHopsAway", | |
10510 | p->ttl); | |
10511 | } else { | |
10512 | if (p->gtsm_hops > 0) | |
10513 | vty_out(vty, | |
10514 | " External BGP neighbor may be up to %d hops away.\n", | |
10515 | p->gtsm_hops); | |
10516 | else if (p->ttl > 1) | |
10517 | vty_out(vty, | |
10518 | " External BGP neighbor may be up to %d hops away.\n", | |
10519 | p->ttl); | |
10520 | } | |
10521 | } else { | |
10522 | if (p->gtsm_hops > 0) { | |
10523 | if (use_json) | |
10524 | json_object_int_add(json_neigh, | |
10525 | "internalBgpNbrMaxHopsAway", | |
10526 | p->gtsm_hops); | |
10527 | else | |
10528 | vty_out(vty, | |
10529 | " Internal BGP neighbor may be up to %d hops away.\n", | |
10530 | p->gtsm_hops); | |
10531 | } | |
10532 | } | |
10533 | ||
10534 | /* Local address. */ | |
10535 | if (p->su_local) { | |
10536 | if (use_json) { | |
10537 | json_object_string_add(json_neigh, "hostLocal", | |
10538 | sockunion2str(p->su_local, buf1, | |
10539 | SU_ADDRSTRLEN)); | |
10540 | json_object_int_add(json_neigh, "portLocal", | |
10541 | ntohs(p->su_local->sin.sin_port)); | |
10542 | } else | |
10543 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
10544 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
10545 | ntohs(p->su_local->sin.sin_port)); | |
10546 | } | |
10547 | ||
10548 | /* Remote address. */ | |
10549 | if (p->su_remote) { | |
10550 | if (use_json) { | |
10551 | json_object_string_add(json_neigh, "hostForeign", | |
10552 | sockunion2str(p->su_remote, buf1, | |
10553 | SU_ADDRSTRLEN)); | |
10554 | json_object_int_add(json_neigh, "portForeign", | |
10555 | ntohs(p->su_remote->sin.sin_port)); | |
10556 | } else | |
10557 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
10558 | sockunion2str(p->su_remote, buf1, | |
10559 | SU_ADDRSTRLEN), | |
10560 | ntohs(p->su_remote->sin.sin_port)); | |
10561 | } | |
10562 | ||
10563 | /* Nexthop display. */ | |
10564 | if (p->su_local) { | |
10565 | if (use_json) { | |
10566 | json_object_string_add(json_neigh, "nexthop", | |
10567 | inet_ntop(AF_INET, | |
10568 | &p->nexthop.v4, buf1, | |
10569 | sizeof(buf1))); | |
10570 | json_object_string_add(json_neigh, "nexthopGlobal", | |
10571 | inet_ntop(AF_INET6, | |
10572 | &p->nexthop.v6_global, | |
10573 | buf1, sizeof(buf1))); | |
10574 | json_object_string_add(json_neigh, "nexthopLocal", | |
10575 | inet_ntop(AF_INET6, | |
10576 | &p->nexthop.v6_local, | |
10577 | buf1, sizeof(buf1))); | |
10578 | if (p->shared_network) | |
10579 | json_object_string_add(json_neigh, | |
10580 | "bgpConnection", | |
10581 | "sharedNetwork"); | |
10582 | else | |
10583 | json_object_string_add(json_neigh, | |
10584 | "bgpConnection", | |
10585 | "nonSharedNetwork"); | |
10586 | } else { | |
10587 | vty_out(vty, "Nexthop: %s\n", | |
10588 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
10589 | sizeof(buf1))); | |
10590 | vty_out(vty, "Nexthop global: %s\n", | |
10591 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
10592 | sizeof(buf1))); | |
10593 | vty_out(vty, "Nexthop local: %s\n", | |
10594 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
10595 | sizeof(buf1))); | |
10596 | vty_out(vty, "BGP connection: %s\n", | |
10597 | p->shared_network ? "shared network" | |
10598 | : "non shared network"); | |
10599 | } | |
10600 | } | |
10601 | ||
10602 | /* Timer information. */ | |
10603 | if (use_json) { | |
10604 | json_object_int_add(json_neigh, "connectRetryTimer", | |
10605 | p->v_connect); | |
10606 | if (p->status == Established && p->rtt) | |
10607 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
10608 | p->rtt); | |
10609 | if (p->t_start) | |
10610 | json_object_int_add( | |
10611 | json_neigh, "nextStartTimerDueInMsecs", | |
10612 | thread_timer_remain_second(p->t_start) * 1000); | |
10613 | if (p->t_connect) | |
10614 | json_object_int_add( | |
10615 | json_neigh, "nextConnectTimerDueInMsecs", | |
10616 | thread_timer_remain_second(p->t_connect) | |
10617 | * 1000); | |
10618 | if (p->t_routeadv) { | |
10619 | json_object_int_add(json_neigh, "mraiInterval", | |
10620 | p->v_routeadv); | |
10621 | json_object_int_add( | |
10622 | json_neigh, "mraiTimerExpireInMsecs", | |
10623 | thread_timer_remain_second(p->t_routeadv) | |
10624 | * 1000); | |
10625 | } | |
10626 | if (p->password) | |
10627 | json_object_int_add(json_neigh, "authenticationEnabled", | |
10628 | 1); | |
10629 | ||
10630 | if (p->t_read) | |
10631 | json_object_string_add(json_neigh, "readThread", "on"); | |
10632 | else | |
10633 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
10634 | |
10635 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 10636 | json_object_string_add(json_neigh, "writeThread", "on"); |
10637 | else | |
10638 | json_object_string_add(json_neigh, "writeThread", | |
10639 | "off"); | |
10640 | } else { | |
10641 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
10642 | p->v_connect); | |
10643 | if (p->status == Established && p->rtt) | |
10644 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
10645 | p->rtt); | |
10646 | if (p->t_start) | |
10647 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
10648 | thread_timer_remain_second(p->t_start)); | |
10649 | if (p->t_connect) | |
10650 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
10651 | thread_timer_remain_second(p->t_connect)); | |
10652 | if (p->t_routeadv) | |
10653 | vty_out(vty, | |
10654 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
10655 | p->v_routeadv, | |
10656 | thread_timer_remain_second(p->t_routeadv)); | |
10657 | if (p->password) | |
10658 | vty_out(vty, "Peer Authentication Enabled\n"); | |
10659 | ||
10660 | vty_out(vty, "Read thread: %s Write thread: %s\n", | |
49507a6f QY |
10661 | p->t_read ? "on" : "off", |
10662 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
10663 | ? "on" | |
10664 | : "off"); | |
d62a17ae | 10665 | } |
10666 | ||
10667 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
10668 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
10669 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
10670 | ||
10671 | if (!use_json) | |
10672 | vty_out(vty, "\n"); | |
10673 | ||
10674 | /* BFD information. */ | |
10675 | bgp_bfd_show_info(vty, p, use_json, json_neigh); | |
10676 | ||
10677 | if (use_json) { | |
10678 | if (p->conf_if) /* Configured interface name. */ | |
10679 | json_object_object_add(json, p->conf_if, json_neigh); | |
10680 | else /* Configured IP address. */ | |
10681 | json_object_object_add(json, p->host, json_neigh); | |
10682 | } | |
10683 | } | |
10684 | ||
10685 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, | |
10686 | enum show_type type, union sockunion *su, | |
d7c0a89a | 10687 | const char *conf_if, uint8_t use_json, |
d62a17ae | 10688 | json_object *json) |
10689 | { | |
10690 | struct listnode *node, *nnode; | |
10691 | struct peer *peer; | |
10692 | int find = 0; | |
10693 | ||
10694 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
10695 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
10696 | continue; | |
10697 | ||
10698 | switch (type) { | |
10699 | case show_all: | |
10700 | bgp_show_peer(vty, peer, use_json, json); | |
10701 | break; | |
10702 | case show_peer: | |
10703 | if (conf_if) { | |
10704 | if ((peer->conf_if | |
10705 | && !strcmp(peer->conf_if, conf_if)) | |
10706 | || (peer->hostname | |
10707 | && !strcmp(peer->hostname, conf_if))) { | |
10708 | find = 1; | |
10709 | bgp_show_peer(vty, peer, use_json, | |
10710 | json); | |
10711 | } | |
10712 | } else { | |
10713 | if (sockunion_same(&peer->su, su)) { | |
10714 | find = 1; | |
10715 | bgp_show_peer(vty, peer, use_json, | |
10716 | json); | |
10717 | } | |
10718 | } | |
10719 | break; | |
10720 | } | |
10721 | } | |
10722 | ||
10723 | if (type == show_peer && !find) { | |
10724 | if (use_json) | |
10725 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
10726 | else | |
88b7d255 | 10727 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 10728 | } |
10729 | ||
10730 | if (use_json) { | |
996c9314 LB |
10731 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
10732 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 10733 | json_object_free(json); |
10734 | } else { | |
10735 | vty_out(vty, "\n"); | |
10736 | } | |
10737 | ||
10738 | return CMD_SUCCESS; | |
10739 | } | |
10740 | ||
10741 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, | |
71aedaa3 DS |
10742 | enum show_type type, |
10743 | const char *ip_str, | |
d7c0a89a | 10744 | uint8_t use_json) |
d62a17ae | 10745 | { |
0291c246 MK |
10746 | struct listnode *node, *nnode; |
10747 | struct bgp *bgp; | |
71aedaa3 | 10748 | union sockunion su; |
0291c246 | 10749 | json_object *json = NULL; |
71aedaa3 | 10750 | int ret, is_first = 1; |
d62a17ae | 10751 | |
10752 | if (use_json) | |
10753 | vty_out(vty, "{\n"); | |
10754 | ||
10755 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
10756 | if (use_json) { | |
10757 | if (!(json = json_object_new_object())) { | |
af4c2728 | 10758 | flog_err( |
14454c9f | 10759 | BGP_ERR_JSON_MEM_ERROR, |
d62a17ae | 10760 | "Unable to allocate memory for JSON object"); |
10761 | vty_out(vty, | |
10762 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
10763 | return; | |
10764 | } | |
10765 | ||
10766 | json_object_int_add(json, "vrfId", | |
10767 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
10768 | ? -1 |
10769 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 10770 | json_object_string_add( |
10771 | json, "vrfName", | |
10772 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
10773 | ? "Default" | |
10774 | : bgp->name); | |
10775 | ||
10776 | if (!is_first) | |
10777 | vty_out(vty, ",\n"); | |
10778 | else | |
10779 | is_first = 0; | |
10780 | ||
10781 | vty_out(vty, "\"%s\":", | |
10782 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
10783 | ? "Default" | |
10784 | : bgp->name); | |
10785 | } else { | |
10786 | vty_out(vty, "\nInstance %s:\n", | |
10787 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
10788 | ? "Default" | |
10789 | : bgp->name); | |
10790 | } | |
71aedaa3 DS |
10791 | |
10792 | if (type == show_peer) { | |
10793 | ret = str2sockunion(ip_str, &su); | |
10794 | if (ret < 0) | |
10795 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
10796 | use_json, json); | |
10797 | else | |
10798 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
10799 | use_json, json); | |
10800 | } else { | |
10801 | bgp_show_neighbor(vty, bgp, show_all, NULL, NULL, | |
10802 | use_json, json); | |
10803 | } | |
d62a17ae | 10804 | } |
10805 | ||
10806 | if (use_json) | |
10807 | vty_out(vty, "}\n"); | |
10808 | } | |
10809 | ||
10810 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
10811 | enum show_type type, const char *ip_str, | |
d7c0a89a | 10812 | uint8_t use_json) |
d62a17ae | 10813 | { |
10814 | int ret; | |
10815 | struct bgp *bgp; | |
10816 | union sockunion su; | |
10817 | json_object *json = NULL; | |
10818 | ||
10819 | if (name) { | |
10820 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
10821 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
10822 | use_json); | |
d62a17ae | 10823 | return CMD_SUCCESS; |
10824 | } else { | |
10825 | bgp = bgp_lookup_by_name(name); | |
10826 | if (!bgp) { | |
10827 | if (use_json) { | |
10828 | json = json_object_new_object(); | |
10829 | json_object_boolean_true_add( | |
10830 | json, "bgpNoSuchInstance"); | |
10831 | vty_out(vty, "%s\n", | |
10832 | json_object_to_json_string_ext( | |
10833 | json, | |
10834 | JSON_C_TO_STRING_PRETTY)); | |
10835 | json_object_free(json); | |
10836 | } else | |
10837 | vty_out(vty, | |
10838 | "%% No such BGP instance exist\n"); | |
10839 | ||
10840 | return CMD_WARNING; | |
10841 | } | |
10842 | } | |
10843 | } else { | |
10844 | bgp = bgp_get_default(); | |
10845 | } | |
10846 | ||
10847 | if (bgp) { | |
10848 | json = json_object_new_object(); | |
10849 | if (ip_str) { | |
10850 | ret = str2sockunion(ip_str, &su); | |
10851 | if (ret < 0) | |
10852 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
10853 | use_json, json); | |
10854 | else | |
10855 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
10856 | use_json, json); | |
10857 | } else { | |
10858 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
10859 | json); | |
10860 | } | |
10861 | json_object_free(json); | |
10862 | } | |
10863 | ||
10864 | return CMD_SUCCESS; | |
4fb25c53 DW |
10865 | } |
10866 | ||
716b2d8a | 10867 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 10868 | DEFUN (show_ip_bgp_neighbors, |
10869 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 10870 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 10871 | SHOW_STR |
10872 | IP_STR | |
10873 | BGP_STR | |
f2a8972b | 10874 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
10875 | "Address Family\n" |
10876 | "Address Family\n" | |
718e3744 | 10877 | "Detailed information on TCP and BGP neighbor connections\n" |
10878 | "Neighbor to display information about\n" | |
a80beece | 10879 | "Neighbor to display information about\n" |
91d37724 | 10880 | "Neighbor on BGP configured interface\n" |
9973d184 | 10881 | JSON_STR) |
718e3744 | 10882 | { |
d62a17ae | 10883 | char *vrf = NULL; |
10884 | char *sh_arg = NULL; | |
10885 | enum show_type sh_type; | |
718e3744 | 10886 | |
d7c0a89a | 10887 | uint8_t uj = use_json(argc, argv); |
718e3744 | 10888 | |
d62a17ae | 10889 | int idx = 0; |
718e3744 | 10890 | |
d62a17ae | 10891 | if (argv_find(argv, argc, "view", &idx) |
10892 | || argv_find(argv, argc, "vrf", &idx)) | |
10893 | vrf = argv[idx + 1]->arg; | |
718e3744 | 10894 | |
d62a17ae | 10895 | idx++; |
10896 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
10897 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
10898 | || argv_find(argv, argc, "WORD", &idx)) { | |
10899 | sh_type = show_peer; | |
10900 | sh_arg = argv[idx]->arg; | |
10901 | } else | |
10902 | sh_type = show_all; | |
856ca177 | 10903 | |
d62a17ae | 10904 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 10905 | } |
10906 | ||
716b2d8a | 10907 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 10908 | paths' and `show ip mbgp paths'. Those functions results are the |
10909 | same.*/ | |
f412b39a | 10910 | DEFUN (show_ip_bgp_paths, |
718e3744 | 10911 | show_ip_bgp_paths_cmd, |
46f296b4 | 10912 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 10913 | SHOW_STR |
10914 | IP_STR | |
10915 | BGP_STR | |
46f296b4 | 10916 | BGP_SAFI_HELP_STR |
718e3744 | 10917 | "Path information\n") |
10918 | { | |
d62a17ae | 10919 | vty_out(vty, "Address Refcnt Path\n"); |
10920 | aspath_print_all_vty(vty); | |
10921 | return CMD_SUCCESS; | |
718e3744 | 10922 | } |
10923 | ||
718e3744 | 10924 | #include "hash.h" |
10925 | ||
d62a17ae | 10926 | static void community_show_all_iterator(struct hash_backet *backet, |
10927 | struct vty *vty) | |
718e3744 | 10928 | { |
d62a17ae | 10929 | struct community *com; |
718e3744 | 10930 | |
d62a17ae | 10931 | com = (struct community *)backet->data; |
3f65c5b1 | 10932 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 10933 | community_str(com, false)); |
718e3744 | 10934 | } |
10935 | ||
10936 | /* Show BGP's community internal data. */ | |
f412b39a | 10937 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 10938 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 10939 | "show [ip] bgp community-info", |
718e3744 | 10940 | SHOW_STR |
10941 | IP_STR | |
10942 | BGP_STR | |
10943 | "List all bgp community information\n") | |
10944 | { | |
d62a17ae | 10945 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 10946 | |
d62a17ae | 10947 | hash_iterate(community_hash(), |
10948 | (void (*)(struct hash_backet *, | |
10949 | void *))community_show_all_iterator, | |
10950 | vty); | |
718e3744 | 10951 | |
d62a17ae | 10952 | return CMD_SUCCESS; |
718e3744 | 10953 | } |
10954 | ||
d62a17ae | 10955 | static void lcommunity_show_all_iterator(struct hash_backet *backet, |
10956 | struct vty *vty) | |
57d187bc | 10957 | { |
d62a17ae | 10958 | struct lcommunity *lcom; |
57d187bc | 10959 | |
d62a17ae | 10960 | lcom = (struct lcommunity *)backet->data; |
3f65c5b1 | 10961 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
8d9b8ed9 | 10962 | lcommunity_str(lcom, false)); |
57d187bc JS |
10963 | } |
10964 | ||
10965 | /* Show BGP's community internal data. */ | |
10966 | DEFUN (show_ip_bgp_lcommunity_info, | |
10967 | show_ip_bgp_lcommunity_info_cmd, | |
10968 | "show ip bgp large-community-info", | |
10969 | SHOW_STR | |
10970 | IP_STR | |
10971 | BGP_STR | |
10972 | "List all bgp large-community information\n") | |
10973 | { | |
d62a17ae | 10974 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 10975 | |
d62a17ae | 10976 | hash_iterate(lcommunity_hash(), |
10977 | (void (*)(struct hash_backet *, | |
10978 | void *))lcommunity_show_all_iterator, | |
10979 | vty); | |
57d187bc | 10980 | |
d62a17ae | 10981 | return CMD_SUCCESS; |
57d187bc JS |
10982 | } |
10983 | ||
10984 | ||
f412b39a | 10985 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 10986 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 10987 | "show [ip] bgp attribute-info", |
718e3744 | 10988 | SHOW_STR |
10989 | IP_STR | |
10990 | BGP_STR | |
10991 | "List all bgp attribute information\n") | |
10992 | { | |
d62a17ae | 10993 | attr_show_all(vty); |
10994 | return CMD_SUCCESS; | |
718e3744 | 10995 | } |
6b0655a2 | 10996 | |
53089bec | 10997 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
b46dfd20 | 10998 | afi_t afi, safi_t safi, uint8_t use_json) |
53089bec | 10999 | { |
11000 | struct bgp *bgp; | |
11001 | struct listnode *node; | |
11002 | char *vname; | |
11003 | char buf1[INET6_ADDRSTRLEN]; | |
11004 | char *ecom_str; | |
11005 | vpn_policy_direction_t dir; | |
11006 | ||
b46dfd20 DS |
11007 | if (use_json) { |
11008 | json_object *json = NULL; | |
11009 | json_object *json_import_vrfs = NULL; | |
11010 | json_object *json_export_vrfs = NULL; | |
11011 | ||
11012 | json = json_object_new_object(); | |
b46dfd20 DS |
11013 | |
11014 | /* Provide context for the block */ | |
11015 | json_object_string_add(json, "vrf", name ? name : "default"); | |
11016 | json_object_string_add(json, "afiSafi", | |
11017 | afi_safi_print(afi, safi)); | |
11018 | ||
11019 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
11020 | ||
53089bec | 11021 | if (!bgp) { |
b46dfd20 DS |
11022 | json_object_boolean_true_add(json, |
11023 | "bgpNoSuchInstance"); | |
11024 | vty_out(vty, "%s\n", | |
11025 | json_object_to_json_string_ext( | |
11026 | json, | |
11027 | JSON_C_TO_STRING_PRETTY)); | |
11028 | json_object_free(json); | |
11029 | ||
53089bec | 11030 | return CMD_WARNING; |
11031 | } | |
b46dfd20 DS |
11032 | |
11033 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
11034 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
11035 | json_object_string_add(json, "importFromVrfs", "none"); | |
11036 | json_object_string_add(json, "importRts", "none"); | |
11037 | } else { | |
6ce24e52 DS |
11038 | json_import_vrfs = json_object_new_array(); |
11039 | ||
b46dfd20 DS |
11040 | for (ALL_LIST_ELEMENTS_RO( |
11041 | bgp->vpn_policy[afi].import_vrf, | |
11042 | node, vname)) | |
11043 | json_object_array_add(json_import_vrfs, | |
11044 | json_object_new_string(vname)); | |
11045 | ||
11046 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
11047 | ecom_str = ecommunity_ecom2str( | |
11048 | bgp->vpn_policy[afi].rtlist[dir], | |
11049 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
11050 | json_object_object_add(json, "importFromVrfs", | |
11051 | json_import_vrfs); | |
11052 | json_object_string_add(json, "importRts", ecom_str); | |
11053 | ||
11054 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
11055 | } | |
11056 | ||
11057 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
11058 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
11059 | json_object_string_add(json, "exportToVrfs", "none"); | |
11060 | json_object_string_add(json, "routeDistinguisher", | |
11061 | "none"); | |
11062 | json_object_string_add(json, "exportRts", "none"); | |
11063 | } else { | |
6ce24e52 DS |
11064 | json_export_vrfs = json_object_new_array(); |
11065 | ||
b46dfd20 DS |
11066 | for (ALL_LIST_ELEMENTS_RO( |
11067 | bgp->vpn_policy[afi].export_vrf, | |
11068 | node, vname)) | |
11069 | json_object_array_add(json_export_vrfs, | |
11070 | json_object_new_string(vname)); | |
11071 | json_object_object_add(json, "exportToVrfs", | |
11072 | json_export_vrfs); | |
11073 | json_object_string_add(json, "routeDistinguisher", | |
11074 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
11075 | buf1, RD_ADDRSTRLEN)); | |
11076 | ||
11077 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
11078 | ecom_str = ecommunity_ecom2str( | |
11079 | bgp->vpn_policy[afi].rtlist[dir], | |
11080 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
11081 | json_object_string_add(json, "exportRts", ecom_str); | |
11082 | ||
11083 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
11084 | } | |
11085 | ||
11086 | vty_out(vty, "%s\n", | |
11087 | json_object_to_json_string_ext(json, | |
11088 | JSON_C_TO_STRING_PRETTY)); | |
11089 | json_object_free(json); | |
11090 | ||
53089bec | 11091 | } else { |
b46dfd20 DS |
11092 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
11093 | ||
53089bec | 11094 | if (!bgp) { |
b46dfd20 | 11095 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 11096 | return CMD_WARNING; |
11097 | } | |
53089bec | 11098 | |
b46dfd20 DS |
11099 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
11100 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
11101 | vty_out(vty, | |
11102 | "This VRF is not importing %s routes from any other VRF\n", | |
11103 | afi_safi_print(afi, safi)); | |
11104 | else { | |
11105 | vty_out(vty, | |
11106 | "This VRF is importing %s routes from the following VRFs:\n", | |
11107 | afi_safi_print(afi, safi)); | |
11108 | ||
11109 | for (ALL_LIST_ELEMENTS_RO( | |
11110 | bgp->vpn_policy[afi].import_vrf, | |
11111 | node, vname)) | |
11112 | vty_out(vty, " %s\n", vname); | |
11113 | ||
11114 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
11115 | ecom_str = ecommunity_ecom2str( | |
11116 | bgp->vpn_policy[afi].rtlist[dir], | |
11117 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
11118 | vty_out(vty, "Import RT(s): %s\n", ecom_str); | |
11119 | ||
11120 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
53089bec | 11121 | } |
53089bec | 11122 | |
b46dfd20 DS |
11123 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
11124 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
11125 | vty_out(vty, | |
11126 | "This VRF is not exporting %s routes to any other VRF\n", | |
53089bec | 11127 | afi_safi_print(afi, safi)); |
b46dfd20 DS |
11128 | else { |
11129 | vty_out(vty, | |
04c9077f | 11130 | "This VRF is exporting %s routes to the following VRFs:\n", |
53089bec | 11131 | afi_safi_print(afi, safi)); |
b46dfd20 DS |
11132 | |
11133 | for (ALL_LIST_ELEMENTS_RO( | |
11134 | bgp->vpn_policy[afi].export_vrf, | |
11135 | node, vname)) | |
11136 | vty_out(vty, " %s\n", vname); | |
11137 | ||
11138 | vty_out(vty, "RD: %s\n", | |
11139 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
11140 | buf1, RD_ADDRSTRLEN)); | |
11141 | ||
11142 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
11143 | ecom_str = ecommunity_ecom2str( | |
11144 | bgp->vpn_policy[afi].rtlist[dir], | |
11145 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
11146 | vty_out(vty, "Export RT: %s\n", ecom_str); | |
04c9077f | 11147 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
53089bec | 11148 | } |
53089bec | 11149 | } |
11150 | ||
11151 | return CMD_SUCCESS; | |
11152 | } | |
11153 | ||
11154 | /* "show [ip] bgp route-leak" command. */ | |
11155 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
11156 | show_ip_bgp_route_leak_cmd, |
11157 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
11158 | SHOW_STR |
11159 | IP_STR | |
11160 | BGP_STR | |
11161 | BGP_INSTANCE_HELP_STR | |
11162 | BGP_AFI_HELP_STR | |
11163 | BGP_SAFI_HELP_STR | |
11164 | "Route leaking information\n" | |
11165 | JSON_STR) | |
53089bec | 11166 | { |
11167 | char *vrf = NULL; | |
11168 | afi_t afi = AFI_MAX; | |
11169 | safi_t safi = SAFI_MAX; | |
11170 | ||
b46dfd20 | 11171 | uint8_t uj = use_json(argc, argv); |
53089bec | 11172 | int idx = 0; |
11173 | ||
11174 | /* show [ip] bgp */ | |
11175 | if (argv_find(argv, argc, "ip", &idx)) { | |
11176 | afi = AFI_IP; | |
11177 | safi = SAFI_UNICAST; | |
11178 | } | |
11179 | /* [vrf VIEWVRFNAME] */ | |
11180 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
11181 | vty_out(vty, |
11182 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 11183 | return CMD_WARNING; |
11184 | } | |
11185 | ||
11186 | if (argv_find(argv, argc, "vrf", &idx)) | |
11187 | vrf = argv[++idx]->arg; | |
11188 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
11189 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11190 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11191 | } | |
11192 | ||
11193 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
11194 | vty_out(vty, |
11195 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 11196 | return CMD_WARNING; |
11197 | } | |
11198 | ||
b46dfd20 | 11199 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj); |
53089bec | 11200 | } |
11201 | ||
d62a17ae | 11202 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
11203 | safi_t safi) | |
f186de26 | 11204 | { |
d62a17ae | 11205 | struct listnode *node, *nnode; |
11206 | struct bgp *bgp; | |
f186de26 | 11207 | |
d62a17ae | 11208 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
11209 | vty_out(vty, "\nInstance %s:\n", | |
11210 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
11211 | ? "Default" | |
11212 | : bgp->name); | |
11213 | update_group_show(bgp, afi, safi, vty, 0); | |
11214 | } | |
f186de26 | 11215 | } |
11216 | ||
d62a17ae | 11217 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
11218 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 11219 | { |
d62a17ae | 11220 | struct bgp *bgp; |
4fb25c53 | 11221 | |
d62a17ae | 11222 | if (name) { |
11223 | if (strmatch(name, "all")) { | |
11224 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
11225 | return CMD_SUCCESS; | |
11226 | } else { | |
11227 | bgp = bgp_lookup_by_name(name); | |
11228 | } | |
11229 | } else { | |
11230 | bgp = bgp_get_default(); | |
11231 | } | |
4fb25c53 | 11232 | |
d62a17ae | 11233 | if (bgp) |
11234 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
11235 | return CMD_SUCCESS; | |
4fb25c53 DW |
11236 | } |
11237 | ||
8fe8a7f6 DS |
11238 | DEFUN (show_ip_bgp_updgrps, |
11239 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 11240 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 11241 | SHOW_STR |
11242 | IP_STR | |
11243 | BGP_STR | |
11244 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 11245 | BGP_AFI_HELP_STR |
9bedbb1e | 11246 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
11247 | "Detailed info about dynamic update groups\n" |
11248 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 11249 | { |
d62a17ae | 11250 | char *vrf = NULL; |
11251 | afi_t afi = AFI_IP6; | |
11252 | safi_t safi = SAFI_UNICAST; | |
11253 | uint64_t subgrp_id = 0; | |
11254 | ||
11255 | int idx = 0; | |
11256 | ||
11257 | /* show [ip] bgp */ | |
11258 | if (argv_find(argv, argc, "ip", &idx)) | |
11259 | afi = AFI_IP; | |
11260 | /* [<view|vrf> VIEWVRFNAME] */ | |
11261 | if (argv_find(argv, argc, "view", &idx) | |
11262 | || argv_find(argv, argc, "vrf", &idx)) | |
11263 | vrf = argv[++idx]->arg; | |
11264 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
11265 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11266 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11267 | } | |
5bf15956 | 11268 | |
d62a17ae | 11269 | /* get subgroup id, if provided */ |
11270 | idx = argc - 1; | |
11271 | if (argv[idx]->type == VARIABLE_TKN) | |
11272 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 11273 | |
d62a17ae | 11274 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
11275 | } |
11276 | ||
f186de26 | 11277 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
11278 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 11279 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 11280 | SHOW_STR |
716b2d8a | 11281 | IP_STR |
f186de26 | 11282 | BGP_STR |
11283 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 11284 | "Detailed info about dynamic update groups\n") |
f186de26 | 11285 | { |
d62a17ae | 11286 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
11287 | return CMD_SUCCESS; | |
f186de26 | 11288 | } |
11289 | ||
5bf15956 DW |
11290 | DEFUN (show_bgp_updgrps_stats, |
11291 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 11292 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 11293 | SHOW_STR |
716b2d8a | 11294 | IP_STR |
3f9c7369 | 11295 | BGP_STR |
0c7b1b01 | 11296 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
11297 | "Statistics\n") |
11298 | { | |
d62a17ae | 11299 | struct bgp *bgp; |
3f9c7369 | 11300 | |
d62a17ae | 11301 | bgp = bgp_get_default(); |
11302 | if (bgp) | |
11303 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 11304 | |
d62a17ae | 11305 | return CMD_SUCCESS; |
3f9c7369 DS |
11306 | } |
11307 | ||
8386ac43 | 11308 | DEFUN (show_bgp_instance_updgrps_stats, |
11309 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 11310 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 11311 | SHOW_STR |
716b2d8a | 11312 | IP_STR |
8386ac43 | 11313 | BGP_STR |
11314 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 11315 | "Detailed info about dynamic update groups\n" |
8386ac43 | 11316 | "Statistics\n") |
11317 | { | |
d62a17ae | 11318 | int idx_word = 3; |
11319 | struct bgp *bgp; | |
8386ac43 | 11320 | |
d62a17ae | 11321 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
11322 | if (bgp) | |
11323 | update_group_show_stats(bgp, vty); | |
8386ac43 | 11324 | |
d62a17ae | 11325 | return CMD_SUCCESS; |
8386ac43 | 11326 | } |
11327 | ||
d62a17ae | 11328 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
11329 | afi_t afi, safi_t safi, | |
11330 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 11331 | { |
d62a17ae | 11332 | struct bgp *bgp; |
8386ac43 | 11333 | |
d62a17ae | 11334 | if (name) |
11335 | bgp = bgp_lookup_by_name(name); | |
11336 | else | |
11337 | bgp = bgp_get_default(); | |
8386ac43 | 11338 | |
d62a17ae | 11339 | if (bgp) { |
11340 | if (!strcmp(what, "advertise-queue")) | |
11341 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
11342 | subgrp_id); | |
11343 | else if (!strcmp(what, "advertised-routes")) | |
11344 | update_group_show_advertised(bgp, afi, safi, vty, | |
11345 | subgrp_id); | |
11346 | else if (!strcmp(what, "packet-queue")) | |
11347 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
11348 | subgrp_id); | |
11349 | } | |
3f9c7369 DS |
11350 | } |
11351 | ||
dc64bdec QY |
11352 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
11353 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
11354 | "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", | |
11355 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
11356 | BGP_SAFI_HELP_STR | |
11357 | "Detailed info about dynamic update groups\n" | |
11358 | "Specific subgroup to display info for\n" | |
11359 | "Advertisement queue\n" | |
11360 | "Announced routes\n" | |
11361 | "Packet queue\n") | |
3f9c7369 | 11362 | { |
dc64bdec QY |
11363 | uint64_t subgrp_id = 0; |
11364 | afi_t afiz; | |
11365 | safi_t safiz; | |
11366 | if (sgid) | |
11367 | subgrp_id = strtoull(sgid, NULL, 10); | |
11368 | ||
11369 | if (!ip && !afi) | |
11370 | afiz = AFI_IP6; | |
11371 | if (!ip && afi) | |
11372 | afiz = bgp_vty_afi_from_str(afi); | |
11373 | if (ip && !afi) | |
11374 | afiz = AFI_IP; | |
11375 | if (ip && afi) { | |
11376 | afiz = bgp_vty_afi_from_str(afi); | |
11377 | if (afiz != AFI_IP) | |
11378 | vty_out(vty, | |
11379 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
11380 | return CMD_WARNING; | |
11381 | } | |
d62a17ae | 11382 | |
dc64bdec | 11383 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 11384 | |
dc64bdec | 11385 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 11386 | return CMD_SUCCESS; |
11387 | } | |
11388 | ||
d62a17ae | 11389 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group) |
11390 | { | |
11391 | struct listnode *node, *nnode; | |
11392 | struct prefix *range; | |
11393 | struct peer *conf; | |
11394 | struct peer *peer; | |
11395 | char buf[PREFIX2STR_BUFFER]; | |
11396 | afi_t afi; | |
11397 | safi_t safi; | |
11398 | const char *peer_status; | |
11399 | const char *af_str; | |
11400 | int lr_count; | |
11401 | int dynamic; | |
11402 | int af_cfgd; | |
11403 | ||
11404 | conf = group->conf; | |
11405 | ||
11406 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
11407 | vty_out(vty, "\nBGP peer-group %s, remote AS %d\n", group->name, | |
11408 | conf->as); | |
11409 | } else if (conf->as_type == AS_INTERNAL) { | |
11410 | vty_out(vty, "\nBGP peer-group %s, remote AS %d\n", group->name, | |
11411 | group->bgp->as); | |
11412 | } else { | |
11413 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
11414 | } | |
f14e6fdb | 11415 | |
d62a17ae | 11416 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
11417 | vty_out(vty, " Peer-group type is internal\n"); | |
11418 | else | |
11419 | vty_out(vty, " Peer-group type is external\n"); | |
11420 | ||
11421 | /* Display AFs configured. */ | |
11422 | vty_out(vty, " Configured address-families:"); | |
05c7a1cc QY |
11423 | FOREACH_AFI_SAFI (afi, safi) { |
11424 | if (conf->afc[afi][safi]) { | |
11425 | af_cfgd = 1; | |
11426 | vty_out(vty, " %s;", afi_safi_print(afi, safi)); | |
d62a17ae | 11427 | } |
05c7a1cc | 11428 | } |
d62a17ae | 11429 | if (!af_cfgd) |
11430 | vty_out(vty, " none\n"); | |
11431 | else | |
11432 | vty_out(vty, "\n"); | |
11433 | ||
11434 | /* Display listen ranges (for dynamic neighbors), if any */ | |
11435 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
11436 | if (afi == AFI_IP) | |
11437 | af_str = "IPv4"; | |
11438 | else if (afi == AFI_IP6) | |
11439 | af_str = "IPv6"; | |
11440 | else | |
11441 | af_str = "???"; | |
11442 | lr_count = listcount(group->listen_range[afi]); | |
11443 | if (lr_count) { | |
11444 | vty_out(vty, " %d %s listen range(s)\n", lr_count, | |
11445 | af_str); | |
11446 | ||
11447 | ||
11448 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
11449 | nnode, range)) { | |
11450 | prefix2str(range, buf, sizeof(buf)); | |
11451 | vty_out(vty, " %s\n", buf); | |
11452 | } | |
11453 | } | |
11454 | } | |
f14e6fdb | 11455 | |
d62a17ae | 11456 | /* Display group members and their status */ |
11457 | if (listcount(group->peer)) { | |
11458 | vty_out(vty, " Peer-group members:\n"); | |
11459 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
11460 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
11461 | peer_status = "Idle (Admin)"; | |
11462 | else if (CHECK_FLAG(peer->sflags, | |
11463 | PEER_STATUS_PREFIX_OVERFLOW)) | |
11464 | peer_status = "Idle (PfxCt)"; | |
11465 | else | |
11466 | peer_status = lookup_msg(bgp_status_msg, | |
11467 | peer->status, NULL); | |
11468 | ||
11469 | dynamic = peer_dynamic_neighbor(peer); | |
11470 | vty_out(vty, " %s %s %s \n", peer->host, | |
11471 | dynamic ? "(dynamic)" : "", peer_status); | |
11472 | } | |
11473 | } | |
f14e6fdb | 11474 | |
d62a17ae | 11475 | return CMD_SUCCESS; |
11476 | } | |
11477 | ||
ff9959b0 QY |
11478 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
11479 | const char *group_name) | |
d62a17ae | 11480 | { |
ff9959b0 | 11481 | struct bgp *bgp; |
d62a17ae | 11482 | struct listnode *node, *nnode; |
11483 | struct peer_group *group; | |
ff9959b0 QY |
11484 | bool found = false; |
11485 | ||
11486 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
11487 | ||
11488 | if (!bgp) { | |
11489 | vty_out(vty, "%% No such BGP instance exists\n"); | |
11490 | return CMD_WARNING; | |
11491 | } | |
d62a17ae | 11492 | |
11493 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
11494 | if (group_name) { |
11495 | if (strmatch(group->name, group_name)) { | |
d62a17ae | 11496 | bgp_show_one_peer_group(vty, group); |
ff9959b0 QY |
11497 | found = true; |
11498 | break; | |
d62a17ae | 11499 | } |
ff9959b0 QY |
11500 | } else { |
11501 | bgp_show_one_peer_group(vty, group); | |
d62a17ae | 11502 | } |
f14e6fdb | 11503 | } |
f14e6fdb | 11504 | |
ff9959b0 | 11505 | if (group_name && !found) |
d62a17ae | 11506 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 11507 | |
d62a17ae | 11508 | return CMD_SUCCESS; |
f14e6fdb DS |
11509 | } |
11510 | ||
f14e6fdb DS |
11511 | DEFUN (show_ip_bgp_peer_groups, |
11512 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 11513 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
11514 | SHOW_STR |
11515 | IP_STR | |
11516 | BGP_STR | |
8386ac43 | 11517 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
11518 | "Detailed information on BGP peer groups\n" |
11519 | "Peer group name\n") | |
f14e6fdb | 11520 | { |
d62a17ae | 11521 | char *vrf, *pg; |
d62a17ae | 11522 | int idx = 0; |
f14e6fdb | 11523 | |
a4d82a8a PZ |
11524 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
11525 | : NULL; | |
d62a17ae | 11526 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 11527 | |
ff9959b0 | 11528 | return bgp_show_peer_group_vty(vty, vrf, pg); |
f14e6fdb | 11529 | } |
3f9c7369 | 11530 | |
d6e3c605 | 11531 | |
718e3744 | 11532 | /* Redistribute VTY commands. */ |
11533 | ||
718e3744 | 11534 | DEFUN (bgp_redistribute_ipv4, |
11535 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 11536 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 11537 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11538 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 11539 | { |
d62a17ae | 11540 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11541 | int idx_protocol = 1; | |
11542 | int type; | |
718e3744 | 11543 | |
d62a17ae | 11544 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
11545 | if (type < 0) { | |
11546 | vty_out(vty, "%% Invalid route type\n"); | |
11547 | return CMD_WARNING_CONFIG_FAILED; | |
11548 | } | |
7f323236 | 11549 | |
d62a17ae | 11550 | bgp_redist_add(bgp, AFI_IP, type, 0); |
e923dd62 | 11551 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, false); |
718e3744 | 11552 | } |
11553 | ||
d62a17ae | 11554 | ALIAS_HIDDEN( |
11555 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
11556 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
11557 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 11558 | |
718e3744 | 11559 | DEFUN (bgp_redistribute_ipv4_rmap, |
11560 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 11561 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 11562 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11563 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 11564 | "Route map reference\n" |
11565 | "Pointer to route-map entries\n") | |
11566 | { | |
d62a17ae | 11567 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11568 | int idx_protocol = 1; | |
11569 | int idx_word = 3; | |
11570 | int type; | |
11571 | struct bgp_redist *red; | |
e923dd62 | 11572 | bool changed; |
718e3744 | 11573 | |
d62a17ae | 11574 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
11575 | if (type < 0) { | |
11576 | vty_out(vty, "%% Invalid route type\n"); | |
11577 | return CMD_WARNING_CONFIG_FAILED; | |
11578 | } | |
718e3744 | 11579 | |
d62a17ae | 11580 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
e923dd62 | 11581 | changed = bgp_redistribute_rmap_set(red, argv[idx_word]->arg); |
11582 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
718e3744 | 11583 | } |
11584 | ||
d62a17ae | 11585 | ALIAS_HIDDEN( |
11586 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
11587 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
11588 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
11589 | "Route map reference\n" | |
11590 | "Pointer to route-map entries\n") | |
596c17ba | 11591 | |
718e3744 | 11592 | DEFUN (bgp_redistribute_ipv4_metric, |
11593 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 11594 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 11595 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11596 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 11597 | "Metric for redistributed routes\n" |
11598 | "Default metric\n") | |
11599 | { | |
d62a17ae | 11600 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11601 | int idx_protocol = 1; | |
11602 | int idx_number = 3; | |
11603 | int type; | |
d7c0a89a | 11604 | uint32_t metric; |
d62a17ae | 11605 | struct bgp_redist *red; |
e923dd62 | 11606 | bool changed; |
d62a17ae | 11607 | |
11608 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
11609 | if (type < 0) { | |
11610 | vty_out(vty, "%% Invalid route type\n"); | |
11611 | return CMD_WARNING_CONFIG_FAILED; | |
11612 | } | |
11613 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
11614 | ||
11615 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 11616 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
11617 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 11618 | } |
11619 | ||
11620 | ALIAS_HIDDEN( | |
11621 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
11622 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
11623 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
11624 | "Metric for redistributed routes\n" | |
11625 | "Default metric\n") | |
596c17ba | 11626 | |
718e3744 | 11627 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
11628 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 11629 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 11630 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11631 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 11632 | "Route map reference\n" |
11633 | "Pointer to route-map entries\n" | |
11634 | "Metric for redistributed routes\n" | |
11635 | "Default metric\n") | |
11636 | { | |
d62a17ae | 11637 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11638 | int idx_protocol = 1; | |
11639 | int idx_word = 3; | |
11640 | int idx_number = 5; | |
11641 | int type; | |
d7c0a89a | 11642 | uint32_t metric; |
d62a17ae | 11643 | struct bgp_redist *red; |
e923dd62 | 11644 | bool changed; |
d62a17ae | 11645 | |
11646 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
11647 | if (type < 0) { | |
11648 | vty_out(vty, "%% Invalid route type\n"); | |
11649 | return CMD_WARNING_CONFIG_FAILED; | |
11650 | } | |
11651 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
11652 | ||
11653 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 11654 | changed = bgp_redistribute_rmap_set(red, argv[idx_word]->arg); |
11655 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
11656 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 11657 | } |
11658 | ||
11659 | ALIAS_HIDDEN( | |
11660 | bgp_redistribute_ipv4_rmap_metric, | |
11661 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
11662 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
11663 | " route-map WORD metric (0-4294967295)", | |
11664 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
11665 | "Route map reference\n" | |
11666 | "Pointer to route-map entries\n" | |
11667 | "Metric for redistributed routes\n" | |
11668 | "Default metric\n") | |
596c17ba | 11669 | |
718e3744 | 11670 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
11671 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 11672 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 11673 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11674 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 11675 | "Metric for redistributed routes\n" |
11676 | "Default metric\n" | |
11677 | "Route map reference\n" | |
11678 | "Pointer to route-map entries\n") | |
11679 | { | |
d62a17ae | 11680 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11681 | int idx_protocol = 1; | |
11682 | int idx_number = 3; | |
11683 | int idx_word = 5; | |
11684 | int type; | |
d7c0a89a | 11685 | uint32_t metric; |
d62a17ae | 11686 | struct bgp_redist *red; |
e923dd62 | 11687 | bool changed; |
d62a17ae | 11688 | |
11689 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
11690 | if (type < 0) { | |
11691 | vty_out(vty, "%% Invalid route type\n"); | |
11692 | return CMD_WARNING_CONFIG_FAILED; | |
11693 | } | |
11694 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
11695 | ||
11696 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 11697 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
11698 | changed |= bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11699 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 11700 | } |
11701 | ||
11702 | ALIAS_HIDDEN( | |
11703 | bgp_redistribute_ipv4_metric_rmap, | |
11704 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
11705 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
11706 | " metric (0-4294967295) route-map WORD", | |
11707 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
11708 | "Metric for redistributed routes\n" | |
11709 | "Default metric\n" | |
11710 | "Route map reference\n" | |
11711 | "Pointer to route-map entries\n") | |
596c17ba | 11712 | |
7c8ff89e DS |
11713 | DEFUN (bgp_redistribute_ipv4_ospf, |
11714 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 11715 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
11716 | "Redistribute information from another routing protocol\n" |
11717 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
11718 | "Non-main Kernel Routing Table\n" |
11719 | "Instance ID/Table ID\n") | |
7c8ff89e | 11720 | { |
d62a17ae | 11721 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11722 | int idx_ospf_table = 1; | |
11723 | int idx_number = 2; | |
d7c0a89a QY |
11724 | unsigned short instance; |
11725 | unsigned short protocol; | |
7c8ff89e | 11726 | |
d62a17ae | 11727 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 11728 | |
d62a17ae | 11729 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
11730 | protocol = ZEBRA_ROUTE_OSPF; | |
11731 | else | |
11732 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 11733 | |
d62a17ae | 11734 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
e923dd62 | 11735 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, false); |
7c8ff89e DS |
11736 | } |
11737 | ||
d62a17ae | 11738 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
11739 | "redistribute <ospf|table> (1-65535)", | |
11740 | "Redistribute information from another routing protocol\n" | |
11741 | "Open Shortest Path First (OSPFv2)\n" | |
11742 | "Non-main Kernel Routing Table\n" | |
11743 | "Instance ID/Table ID\n") | |
596c17ba | 11744 | |
7c8ff89e DS |
11745 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
11746 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 11747 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
11748 | "Redistribute information from another routing protocol\n" |
11749 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
11750 | "Non-main Kernel Routing Table\n" |
11751 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
11752 | "Route map reference\n" |
11753 | "Pointer to route-map entries\n") | |
11754 | { | |
d62a17ae | 11755 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11756 | int idx_ospf_table = 1; | |
11757 | int idx_number = 2; | |
11758 | int idx_word = 4; | |
11759 | struct bgp_redist *red; | |
d7c0a89a | 11760 | unsigned short instance; |
d62a17ae | 11761 | int protocol; |
e923dd62 | 11762 | bool changed; |
d62a17ae | 11763 | |
11764 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
11765 | protocol = ZEBRA_ROUTE_OSPF; | |
11766 | else | |
11767 | protocol = ZEBRA_ROUTE_TABLE; | |
11768 | ||
11769 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
11770 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 11771 | changed = bgp_redistribute_rmap_set(red, argv[idx_word]->arg); |
11772 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 11773 | } |
11774 | ||
11775 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
11776 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
11777 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
11778 | "Redistribute information from another routing protocol\n" | |
11779 | "Open Shortest Path First (OSPFv2)\n" | |
11780 | "Non-main Kernel Routing Table\n" | |
11781 | "Instance ID/Table ID\n" | |
11782 | "Route map reference\n" | |
11783 | "Pointer to route-map entries\n") | |
596c17ba | 11784 | |
7c8ff89e DS |
11785 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
11786 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 11787 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
11788 | "Redistribute information from another routing protocol\n" |
11789 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
11790 | "Non-main Kernel Routing Table\n" |
11791 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
11792 | "Metric for redistributed routes\n" |
11793 | "Default metric\n") | |
11794 | { | |
d62a17ae | 11795 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11796 | int idx_ospf_table = 1; | |
11797 | int idx_number = 2; | |
11798 | int idx_number_2 = 4; | |
d7c0a89a | 11799 | uint32_t metric; |
d62a17ae | 11800 | struct bgp_redist *red; |
d7c0a89a | 11801 | unsigned short instance; |
d62a17ae | 11802 | int protocol; |
e923dd62 | 11803 | bool changed; |
d62a17ae | 11804 | |
11805 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
11806 | protocol = ZEBRA_ROUTE_OSPF; | |
11807 | else | |
11808 | protocol = ZEBRA_ROUTE_TABLE; | |
11809 | ||
11810 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
11811 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
11812 | ||
11813 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 11814 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
11815 | metric); | |
11816 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 11817 | } |
11818 | ||
11819 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
11820 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
11821 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
11822 | "Redistribute information from another routing protocol\n" | |
11823 | "Open Shortest Path First (OSPFv2)\n" | |
11824 | "Non-main Kernel Routing Table\n" | |
11825 | "Instance ID/Table ID\n" | |
11826 | "Metric for redistributed routes\n" | |
11827 | "Default metric\n") | |
596c17ba | 11828 | |
7c8ff89e DS |
11829 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
11830 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 11831 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
11832 | "Redistribute information from another routing protocol\n" |
11833 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
11834 | "Non-main Kernel Routing Table\n" |
11835 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
11836 | "Route map reference\n" |
11837 | "Pointer to route-map entries\n" | |
11838 | "Metric for redistributed routes\n" | |
11839 | "Default metric\n") | |
11840 | { | |
d62a17ae | 11841 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11842 | int idx_ospf_table = 1; | |
11843 | int idx_number = 2; | |
11844 | int idx_word = 4; | |
11845 | int idx_number_2 = 6; | |
d7c0a89a | 11846 | uint32_t metric; |
d62a17ae | 11847 | struct bgp_redist *red; |
d7c0a89a | 11848 | unsigned short instance; |
d62a17ae | 11849 | int protocol; |
e923dd62 | 11850 | bool changed; |
d62a17ae | 11851 | |
11852 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
11853 | protocol = ZEBRA_ROUTE_OSPF; | |
11854 | else | |
11855 | protocol = ZEBRA_ROUTE_TABLE; | |
11856 | ||
11857 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
11858 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
11859 | ||
11860 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 11861 | changed = bgp_redistribute_rmap_set(red, argv[idx_word]->arg); |
11862 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, | |
11863 | metric); | |
11864 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 11865 | } |
11866 | ||
11867 | ALIAS_HIDDEN( | |
11868 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
11869 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
11870 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
11871 | "Redistribute information from another routing protocol\n" | |
11872 | "Open Shortest Path First (OSPFv2)\n" | |
11873 | "Non-main Kernel Routing Table\n" | |
11874 | "Instance ID/Table ID\n" | |
11875 | "Route map reference\n" | |
11876 | "Pointer to route-map entries\n" | |
11877 | "Metric for redistributed routes\n" | |
11878 | "Default metric\n") | |
596c17ba | 11879 | |
7c8ff89e DS |
11880 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
11881 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 11882 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
11883 | "Redistribute information from another routing protocol\n" |
11884 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
11885 | "Non-main Kernel Routing Table\n" |
11886 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
11887 | "Metric for redistributed routes\n" |
11888 | "Default metric\n" | |
11889 | "Route map reference\n" | |
11890 | "Pointer to route-map entries\n") | |
11891 | { | |
d62a17ae | 11892 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11893 | int idx_ospf_table = 1; | |
11894 | int idx_number = 2; | |
11895 | int idx_number_2 = 4; | |
11896 | int idx_word = 6; | |
d7c0a89a | 11897 | uint32_t metric; |
d62a17ae | 11898 | struct bgp_redist *red; |
d7c0a89a | 11899 | unsigned short instance; |
d62a17ae | 11900 | int protocol; |
e923dd62 | 11901 | bool changed; |
d62a17ae | 11902 | |
11903 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
11904 | protocol = ZEBRA_ROUTE_OSPF; | |
11905 | else | |
11906 | protocol = ZEBRA_ROUTE_TABLE; | |
11907 | ||
11908 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
11909 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
11910 | ||
11911 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 11912 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
11913 | metric); | |
11914 | changed |= bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11915 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 11916 | } |
11917 | ||
11918 | ALIAS_HIDDEN( | |
11919 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
11920 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
11921 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
11922 | "Redistribute information from another routing protocol\n" | |
11923 | "Open Shortest Path First (OSPFv2)\n" | |
11924 | "Non-main Kernel Routing Table\n" | |
11925 | "Instance ID/Table ID\n" | |
11926 | "Metric for redistributed routes\n" | |
11927 | "Default metric\n" | |
11928 | "Route map reference\n" | |
11929 | "Pointer to route-map entries\n") | |
596c17ba | 11930 | |
7c8ff89e DS |
11931 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
11932 | no_bgp_redistribute_ipv4_ospf_cmd, | |
d04c479d | 11933 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", |
7c8ff89e DS |
11934 | NO_STR |
11935 | "Redistribute information from another routing protocol\n" | |
11936 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 11937 | "Non-main Kernel Routing Table\n" |
31500417 DW |
11938 | "Instance ID/Table ID\n" |
11939 | "Metric for redistributed routes\n" | |
11940 | "Default metric\n" | |
11941 | "Route map reference\n" | |
11942 | "Pointer to route-map entries\n") | |
7c8ff89e | 11943 | { |
d62a17ae | 11944 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11945 | int idx_ospf_table = 2; | |
11946 | int idx_number = 3; | |
d7c0a89a | 11947 | unsigned short instance; |
d62a17ae | 11948 | int protocol; |
11949 | ||
11950 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
11951 | protocol = ZEBRA_ROUTE_OSPF; | |
11952 | else | |
11953 | protocol = ZEBRA_ROUTE_TABLE; | |
11954 | ||
11955 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
11956 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
11957 | } | |
11958 | ||
11959 | ALIAS_HIDDEN( | |
11960 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
11961 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", | |
11962 | NO_STR | |
11963 | "Redistribute information from another routing protocol\n" | |
11964 | "Open Shortest Path First (OSPFv2)\n" | |
11965 | "Non-main Kernel Routing Table\n" | |
11966 | "Instance ID/Table ID\n" | |
11967 | "Metric for redistributed routes\n" | |
11968 | "Default metric\n" | |
11969 | "Route map reference\n" | |
11970 | "Pointer to route-map entries\n") | |
596c17ba | 11971 | |
718e3744 | 11972 | DEFUN (no_bgp_redistribute_ipv4, |
11973 | no_bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 11974 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 11975 | NO_STR |
11976 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 11977 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
11978 | "Metric for redistributed routes\n" |
11979 | "Default metric\n" | |
11980 | "Route map reference\n" | |
11981 | "Pointer to route-map entries\n") | |
718e3744 | 11982 | { |
d62a17ae | 11983 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11984 | int idx_protocol = 2; | |
11985 | int type; | |
11986 | ||
11987 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
11988 | if (type < 0) { | |
11989 | vty_out(vty, "%% Invalid route type\n"); | |
11990 | return CMD_WARNING_CONFIG_FAILED; | |
11991 | } | |
11992 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
11993 | } | |
11994 | ||
11995 | ALIAS_HIDDEN( | |
11996 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
11997 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
11998 | " [metric (0-4294967295)] [route-map WORD]", | |
11999 | NO_STR | |
12000 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
12001 | "Metric for redistributed routes\n" | |
12002 | "Default metric\n" | |
12003 | "Route map reference\n" | |
12004 | "Pointer to route-map entries\n") | |
596c17ba | 12005 | |
718e3744 | 12006 | DEFUN (bgp_redistribute_ipv6, |
12007 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 12008 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 12009 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12010 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 12011 | { |
d62a17ae | 12012 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12013 | int idx_protocol = 1; | |
12014 | int type; | |
718e3744 | 12015 | |
d62a17ae | 12016 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
12017 | if (type < 0) { | |
12018 | vty_out(vty, "%% Invalid route type\n"); | |
12019 | return CMD_WARNING_CONFIG_FAILED; | |
12020 | } | |
718e3744 | 12021 | |
d62a17ae | 12022 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 12023 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, false); |
718e3744 | 12024 | } |
12025 | ||
12026 | DEFUN (bgp_redistribute_ipv6_rmap, | |
12027 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 12028 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 12029 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12030 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12031 | "Route map reference\n" |
12032 | "Pointer to route-map entries\n") | |
12033 | { | |
d62a17ae | 12034 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12035 | int idx_protocol = 1; | |
12036 | int idx_word = 3; | |
12037 | int type; | |
12038 | struct bgp_redist *red; | |
e923dd62 | 12039 | bool changed; |
718e3744 | 12040 | |
d62a17ae | 12041 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
12042 | if (type < 0) { | |
12043 | vty_out(vty, "%% Invalid route type\n"); | |
12044 | return CMD_WARNING_CONFIG_FAILED; | |
12045 | } | |
718e3744 | 12046 | |
d62a17ae | 12047 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 12048 | changed = bgp_redistribute_rmap_set(red, argv[idx_word]->arg); |
12049 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 12050 | } |
12051 | ||
12052 | DEFUN (bgp_redistribute_ipv6_metric, | |
12053 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 12054 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 12055 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12056 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12057 | "Metric for redistributed routes\n" |
12058 | "Default metric\n") | |
12059 | { | |
d62a17ae | 12060 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12061 | int idx_protocol = 1; | |
12062 | int idx_number = 3; | |
12063 | int type; | |
d7c0a89a | 12064 | uint32_t metric; |
d62a17ae | 12065 | struct bgp_redist *red; |
e923dd62 | 12066 | bool changed; |
d62a17ae | 12067 | |
12068 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
12069 | if (type < 0) { | |
12070 | vty_out(vty, "%% Invalid route type\n"); | |
12071 | return CMD_WARNING_CONFIG_FAILED; | |
12072 | } | |
12073 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 12074 | |
d62a17ae | 12075 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 12076 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); |
12077 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 12078 | } |
12079 | ||
12080 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
12081 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 12082 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 12083 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12084 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12085 | "Route map reference\n" |
12086 | "Pointer to route-map entries\n" | |
12087 | "Metric for redistributed routes\n" | |
12088 | "Default metric\n") | |
12089 | { | |
d62a17ae | 12090 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12091 | int idx_protocol = 1; | |
12092 | int idx_word = 3; | |
12093 | int idx_number = 5; | |
12094 | int type; | |
d7c0a89a | 12095 | uint32_t metric; |
d62a17ae | 12096 | struct bgp_redist *red; |
e923dd62 | 12097 | bool changed; |
d62a17ae | 12098 | |
12099 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
12100 | if (type < 0) { | |
12101 | vty_out(vty, "%% Invalid route type\n"); | |
12102 | return CMD_WARNING_CONFIG_FAILED; | |
12103 | } | |
12104 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 12105 | |
d62a17ae | 12106 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 12107 | changed = bgp_redistribute_rmap_set(red, argv[idx_word]->arg); |
12108 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, | |
12109 | metric); | |
12110 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 12111 | } |
12112 | ||
12113 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
12114 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 12115 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 12116 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12117 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12118 | "Metric for redistributed routes\n" |
12119 | "Default metric\n" | |
12120 | "Route map reference\n" | |
12121 | "Pointer to route-map entries\n") | |
12122 | { | |
d62a17ae | 12123 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12124 | int idx_protocol = 1; | |
12125 | int idx_number = 3; | |
12126 | int idx_word = 5; | |
12127 | int type; | |
d7c0a89a | 12128 | uint32_t metric; |
d62a17ae | 12129 | struct bgp_redist *red; |
e923dd62 | 12130 | bool changed; |
d62a17ae | 12131 | |
12132 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
12133 | if (type < 0) { | |
12134 | vty_out(vty, "%% Invalid route type\n"); | |
12135 | return CMD_WARNING_CONFIG_FAILED; | |
12136 | } | |
12137 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 12138 | |
d62a17ae | 12139 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 12140 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, |
12141 | metric); | |
12142 | changed |= bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
12143 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 12144 | } |
12145 | ||
12146 | DEFUN (no_bgp_redistribute_ipv6, | |
12147 | no_bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 12148 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 12149 | NO_STR |
12150 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 12151 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
12152 | "Metric for redistributed routes\n" |
12153 | "Default metric\n" | |
12154 | "Route map reference\n" | |
12155 | "Pointer to route-map entries\n") | |
718e3744 | 12156 | { |
d62a17ae | 12157 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12158 | int idx_protocol = 2; | |
12159 | int type; | |
718e3744 | 12160 | |
d62a17ae | 12161 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
12162 | if (type < 0) { | |
12163 | vty_out(vty, "%% Invalid route type\n"); | |
12164 | return CMD_WARNING_CONFIG_FAILED; | |
12165 | } | |
718e3744 | 12166 | |
d62a17ae | 12167 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
12168 | } | |
12169 | ||
2b791107 | 12170 | void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, afi_t afi, |
60466a63 | 12171 | safi_t safi) |
d62a17ae | 12172 | { |
12173 | int i; | |
12174 | ||
12175 | /* Unicast redistribution only. */ | |
12176 | if (safi != SAFI_UNICAST) | |
2b791107 | 12177 | return; |
d62a17ae | 12178 | |
12179 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
12180 | /* Redistribute BGP does not make sense. */ | |
12181 | if (i != ZEBRA_ROUTE_BGP) { | |
12182 | struct list *red_list; | |
12183 | struct listnode *node; | |
12184 | struct bgp_redist *red; | |
12185 | ||
12186 | red_list = bgp->redist[afi][i]; | |
12187 | if (!red_list) | |
12188 | continue; | |
12189 | ||
12190 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 12191 | /* "redistribute" configuration. */ |
12192 | vty_out(vty, " redistribute %s", | |
12193 | zebra_route_string(i)); | |
12194 | if (red->instance) | |
12195 | vty_out(vty, " %d", red->instance); | |
12196 | if (red->redist_metric_flag) | |
12197 | vty_out(vty, " metric %u", | |
12198 | red->redist_metric); | |
12199 | if (red->rmap.name) | |
12200 | vty_out(vty, " route-map %s", | |
12201 | red->rmap.name); | |
12202 | vty_out(vty, "\n"); | |
12203 | } | |
12204 | } | |
12205 | } | |
718e3744 | 12206 | } |
6b0655a2 | 12207 | |
b9c7bc5a PZ |
12208 | /* This is part of the address-family block (unicast only) */ |
12209 | void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, | |
ddb5b488 PZ |
12210 | afi_t afi) |
12211 | { | |
b9c7bc5a | 12212 | int indent = 2; |
ddb5b488 | 12213 | |
bb4f6190 DS |
12214 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) |
12215 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", | |
12216 | bgp->vpn_policy[afi] | |
12217 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
12218 | ||
12a844a5 DS |
12219 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
12220 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
12221 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
12222 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
12223 | return; | |
12224 | ||
e70e9f8e PZ |
12225 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
12226 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
12227 | ||
12228 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
12229 | ||
12230 | } else { | |
12231 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
12232 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
12233 | bgp->vpn_policy[afi].tovpn_label); | |
12234 | } | |
ddb5b488 PZ |
12235 | } |
12236 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
12237 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
12238 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 12239 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
12240 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
12241 | sizeof(buf))); | |
12242 | } | |
12243 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
12244 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
12245 | ||
12246 | char buf[PREFIX_STRLEN]; | |
12247 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
12248 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
12249 | sizeof(buf))) { | |
12250 | ||
b9c7bc5a PZ |
12251 | vty_out(vty, "%*snexthop vpn export %s\n", |
12252 | indent, "", buf); | |
ddb5b488 PZ |
12253 | } |
12254 | } | |
12255 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
12256 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
12257 | && ecommunity_cmp( | |
12258 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
12259 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
12260 | ||
12261 | char *b = ecommunity_ecom2str( | |
12262 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
12263 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12264 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
12265 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12266 | } else { | |
12267 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
12268 | char *b = ecommunity_ecom2str( | |
12269 | bgp->vpn_policy[afi] | |
12270 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
12271 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12272 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12273 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
12274 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12275 | } | |
12276 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
12277 | char *b = ecommunity_ecom2str( | |
12278 | bgp->vpn_policy[afi] | |
12279 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
12280 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12281 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12282 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
12283 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12284 | } | |
12285 | } | |
bb4f6190 DS |
12286 | |
12287 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 12288 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
12289 | bgp->vpn_policy[afi] |
12290 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 12291 | |
301ad80a PG |
12292 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
12293 | char *b = ecommunity_ecom2str( | |
12294 | bgp->vpn_policy[afi] | |
12295 | .import_redirect_rtlist, | |
12296 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12297 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 12298 | |
301ad80a PG |
12299 | vty_out(vty, "%*srt redirect import %s\n", indent, "", b); |
12300 | XFREE(MTYPE_ECOMMUNITY_STR, b); | |
12301 | } | |
ddb5b488 PZ |
12302 | } |
12303 | ||
12304 | ||
718e3744 | 12305 | /* BGP node structure. */ |
d62a17ae | 12306 | static struct cmd_node bgp_node = { |
9d303b37 | 12307 | BGP_NODE, "%s(config-router)# ", 1, |
718e3744 | 12308 | }; |
12309 | ||
d62a17ae | 12310 | static struct cmd_node bgp_ipv4_unicast_node = { |
9d303b37 | 12311 | BGP_IPV4_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12312 | }; |
12313 | ||
d62a17ae | 12314 | static struct cmd_node bgp_ipv4_multicast_node = { |
9d303b37 | 12315 | BGP_IPV4M_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12316 | }; |
12317 | ||
d62a17ae | 12318 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
9d303b37 | 12319 | BGP_IPV4L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
12320 | }; |
12321 | ||
d62a17ae | 12322 | static struct cmd_node bgp_ipv6_unicast_node = { |
9d303b37 | 12323 | BGP_IPV6_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12324 | }; |
12325 | ||
d62a17ae | 12326 | static struct cmd_node bgp_ipv6_multicast_node = { |
9d303b37 | 12327 | BGP_IPV6M_NODE, "%s(config-router-af)# ", 1, |
25ffbdc1 | 12328 | }; |
12329 | ||
d62a17ae | 12330 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
9d303b37 | 12331 | BGP_IPV6L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
12332 | }; |
12333 | ||
d62a17ae | 12334 | static struct cmd_node bgp_vpnv4_node = {BGP_VPNV4_NODE, |
12335 | "%s(config-router-af)# ", 1}; | |
6b0655a2 | 12336 | |
d62a17ae | 12337 | static struct cmd_node bgp_vpnv6_node = {BGP_VPNV6_NODE, |
12338 | "%s(config-router-af-vpnv6)# ", 1}; | |
8ecd3266 | 12339 | |
d62a17ae | 12340 | static struct cmd_node bgp_evpn_node = {BGP_EVPN_NODE, |
12341 | "%s(config-router-evpn)# ", 1}; | |
4e0b7b6d | 12342 | |
d62a17ae | 12343 | static struct cmd_node bgp_evpn_vni_node = {BGP_EVPN_VNI_NODE, |
12344 | "%s(config-router-af-vni)# ", 1}; | |
90e60aa7 | 12345 | |
7c40bf39 | 12346 | static struct cmd_node bgp_flowspecv4_node = {BGP_FLOWSPECV4_NODE, |
12347 | "%s(config-router-af)# ", 1}; | |
12348 | ||
12349 | static struct cmd_node bgp_flowspecv6_node = {BGP_FLOWSPECV6_NODE, | |
12350 | "%s(config-router-af-vpnv6)# ", 1}; | |
12351 | ||
d62a17ae | 12352 | static void community_list_vty(void); |
1f8ae70b | 12353 | |
d62a17ae | 12354 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 12355 | { |
d62a17ae | 12356 | struct bgp *bgp; |
12357 | struct peer *peer; | |
d62a17ae | 12358 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 12359 | |
d62a17ae | 12360 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
12361 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
12362 | /* only provide suggestions on the appropriate input | |
12363 | * token type, | |
12364 | * they'll otherwise show up multiple times */ | |
12365 | enum cmd_token_type match_type; | |
12366 | char *name = peer->host; | |
d48ed3e0 | 12367 | |
d62a17ae | 12368 | if (peer->conf_if) { |
12369 | match_type = VARIABLE_TKN; | |
12370 | name = peer->conf_if; | |
12371 | } else if (strchr(peer->host, ':')) | |
12372 | match_type = IPV6_TKN; | |
12373 | else | |
12374 | match_type = IPV4_TKN; | |
d48ed3e0 | 12375 | |
d62a17ae | 12376 | if (token->type != match_type) |
12377 | continue; | |
d48ed3e0 | 12378 | |
d62a17ae | 12379 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
12380 | } | |
d62a17ae | 12381 | } |
b8a815e5 DL |
12382 | } |
12383 | ||
12384 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 12385 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
12386 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 12387 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 12388 | {.completions = NULL}}; |
12389 | ||
47a306a0 DS |
12390 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
12391 | { | |
12392 | struct bgp *bgp; | |
12393 | struct peer_group *group; | |
12394 | struct listnode *lnbgp, *lnpeer; | |
12395 | ||
12396 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
12397 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
12398 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
12399 | group->name)); | |
12400 | } | |
12401 | } | |
12402 | ||
12403 | static const struct cmd_variable_handler bgp_var_peergroup[] = { | |
12404 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
12405 | {.completions = NULL} }; | |
12406 | ||
d62a17ae | 12407 | void bgp_vty_init(void) |
12408 | { | |
12409 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 12410 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 12411 | |
12412 | /* Install bgp top node. */ | |
12413 | install_node(&bgp_node, bgp_config_write); | |
12414 | install_node(&bgp_ipv4_unicast_node, NULL); | |
12415 | install_node(&bgp_ipv4_multicast_node, NULL); | |
12416 | install_node(&bgp_ipv4_labeled_unicast_node, NULL); | |
12417 | install_node(&bgp_ipv6_unicast_node, NULL); | |
12418 | install_node(&bgp_ipv6_multicast_node, NULL); | |
12419 | install_node(&bgp_ipv6_labeled_unicast_node, NULL); | |
12420 | install_node(&bgp_vpnv4_node, NULL); | |
12421 | install_node(&bgp_vpnv6_node, NULL); | |
12422 | install_node(&bgp_evpn_node, NULL); | |
12423 | install_node(&bgp_evpn_vni_node, NULL); | |
7c40bf39 | 12424 | install_node(&bgp_flowspecv4_node, NULL); |
12425 | install_node(&bgp_flowspecv6_node, NULL); | |
d62a17ae | 12426 | |
12427 | /* Install default VTY commands to new nodes. */ | |
12428 | install_default(BGP_NODE); | |
12429 | install_default(BGP_IPV4_NODE); | |
12430 | install_default(BGP_IPV4M_NODE); | |
12431 | install_default(BGP_IPV4L_NODE); | |
12432 | install_default(BGP_IPV6_NODE); | |
12433 | install_default(BGP_IPV6M_NODE); | |
12434 | install_default(BGP_IPV6L_NODE); | |
12435 | install_default(BGP_VPNV4_NODE); | |
12436 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 12437 | install_default(BGP_FLOWSPECV4_NODE); |
12438 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 12439 | install_default(BGP_EVPN_NODE); |
12440 | install_default(BGP_EVPN_VNI_NODE); | |
12441 | ||
12442 | /* "bgp multiple-instance" commands. */ | |
12443 | install_element(CONFIG_NODE, &bgp_multiple_instance_cmd); | |
12444 | install_element(CONFIG_NODE, &no_bgp_multiple_instance_cmd); | |
12445 | ||
12446 | /* "bgp config-type" commands. */ | |
12447 | install_element(CONFIG_NODE, &bgp_config_type_cmd); | |
12448 | install_element(CONFIG_NODE, &no_bgp_config_type_cmd); | |
12449 | ||
12450 | /* bgp route-map delay-timer commands. */ | |
12451 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
12452 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
12453 | ||
12454 | /* Dummy commands (Currently not supported) */ | |
12455 | install_element(BGP_NODE, &no_synchronization_cmd); | |
12456 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
12457 | ||
12458 | /* "router bgp" commands. */ | |
12459 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
12460 | ||
12461 | /* "no router bgp" commands. */ | |
12462 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
12463 | ||
12464 | /* "bgp router-id" commands. */ | |
12465 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
12466 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
12467 | ||
12468 | /* "bgp cluster-id" commands. */ | |
12469 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
12470 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
12471 | ||
12472 | /* "bgp confederation" commands. */ | |
12473 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
12474 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
12475 | ||
12476 | /* "bgp confederation peers" commands. */ | |
12477 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
12478 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
12479 | ||
12480 | /* bgp max-med command */ | |
12481 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
12482 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
12483 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
12484 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
12485 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
12486 | ||
12487 | /* bgp disable-ebgp-connected-nh-check */ | |
12488 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
12489 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
12490 | ||
12491 | /* bgp update-delay command */ | |
12492 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
12493 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
12494 | install_element(BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
12495 | ||
12496 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
12497 | install_element(BGP_NODE, &no_bgp_wpkt_quanta_cmd); | |
555e09d4 QY |
12498 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
12499 | install_element(BGP_NODE, &no_bgp_rpkt_quanta_cmd); | |
d62a17ae | 12500 | |
12501 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
12502 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
12503 | ||
12504 | /* "maximum-paths" commands. */ | |
12505 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
12506 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
12507 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
12508 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
12509 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
12510 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
12511 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
12512 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
12513 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
12514 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
12515 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
12516 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
12517 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
12518 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
12519 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
12520 | ||
12521 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); | |
12522 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
12523 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
12524 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
12525 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
12526 | ||
12527 | /* "timers bgp" commands. */ | |
12528 | install_element(BGP_NODE, &bgp_timers_cmd); | |
12529 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
12530 | ||
12531 | /* route-map delay-timer commands - per instance for backwards compat. | |
12532 | */ | |
12533 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
12534 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
12535 | ||
12536 | /* "bgp client-to-client reflection" commands */ | |
12537 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
12538 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
12539 | ||
12540 | /* "bgp always-compare-med" commands */ | |
12541 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
12542 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
12543 | ||
12544 | /* "bgp deterministic-med" commands */ | |
12545 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
12546 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
12547 | ||
12548 | /* "bgp graceful-restart" commands */ | |
12549 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); | |
12550 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
12551 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); | |
12552 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
12553 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
12554 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
12555 | ||
12556 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); | |
12557 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
12558 | ||
7f323236 DW |
12559 | /* "bgp graceful-shutdown" commands */ |
12560 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
12561 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
12562 | ||
d62a17ae | 12563 | /* "bgp fast-external-failover" commands */ |
12564 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
12565 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
12566 | ||
12567 | /* "bgp enforce-first-as" commands */ | |
12568 | install_element(BGP_NODE, &bgp_enforce_first_as_cmd); | |
d62a17ae | 12569 | |
12570 | /* "bgp bestpath compare-routerid" commands */ | |
12571 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
12572 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
12573 | ||
12574 | /* "bgp bestpath as-path ignore" commands */ | |
12575 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
12576 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
12577 | ||
12578 | /* "bgp bestpath as-path confed" commands */ | |
12579 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
12580 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
12581 | ||
12582 | /* "bgp bestpath as-path multipath-relax" commands */ | |
12583 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
12584 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
12585 | ||
12586 | /* "bgp log-neighbor-changes" commands */ | |
12587 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
12588 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
12589 | ||
12590 | /* "bgp bestpath med" commands */ | |
12591 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
12592 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
12593 | ||
12594 | /* "no bgp default ipv4-unicast" commands. */ | |
12595 | install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
12596 | install_element(BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
12597 | ||
12598 | /* "bgp network import-check" commands. */ | |
12599 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
12600 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
12601 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
12602 | ||
12603 | /* "bgp default local-preference" commands. */ | |
12604 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
12605 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
12606 | ||
12607 | /* bgp default show-hostname */ | |
12608 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
12609 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
12610 | ||
12611 | /* "bgp default subgroup-pkt-queue-max" commands. */ | |
12612 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
12613 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
12614 | ||
12615 | /* bgp ibgp-allow-policy-mods command */ | |
12616 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
12617 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
12618 | ||
12619 | /* "bgp listen limit" commands. */ | |
12620 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
12621 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
12622 | ||
12623 | /* "bgp listen range" commands. */ | |
12624 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
12625 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
12626 | ||
8175f54a | 12627 | /* "bgp default shutdown" command */ |
f26845f9 QY |
12628 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
12629 | ||
d62a17ae | 12630 | /* "neighbor remote-as" commands. */ |
12631 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
12632 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
12633 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
12634 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
12635 | install_element(BGP_NODE, | |
12636 | &neighbor_interface_v6only_config_remote_as_cmd); | |
12637 | install_element(BGP_NODE, &no_neighbor_cmd); | |
12638 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
12639 | ||
12640 | /* "neighbor peer-group" commands. */ | |
12641 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
12642 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
12643 | install_element(BGP_NODE, | |
12644 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
12645 | ||
12646 | /* "neighbor local-as" commands. */ | |
12647 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
12648 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
12649 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
12650 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
12651 | ||
12652 | /* "neighbor solo" commands. */ | |
12653 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
12654 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
12655 | ||
12656 | /* "neighbor password" commands. */ | |
12657 | install_element(BGP_NODE, &neighbor_password_cmd); | |
12658 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
12659 | ||
12660 | /* "neighbor activate" commands. */ | |
12661 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
12662 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
12663 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
12664 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
12665 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
12666 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
12667 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
12668 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
12669 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 12670 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
12671 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 12672 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
12673 | ||
12674 | /* "no neighbor activate" commands. */ | |
12675 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
12676 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
12677 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
12678 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
12679 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
12680 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
12681 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
12682 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
12683 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 12684 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
12685 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 12686 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
12687 | ||
12688 | /* "neighbor peer-group" set commands. */ | |
12689 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
12690 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12691 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12692 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12693 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12694 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12695 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12696 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 12697 | install_element(BGP_FLOWSPECV4_NODE, |
12698 | &neighbor_set_peer_group_hidden_cmd); | |
12699 | install_element(BGP_FLOWSPECV6_NODE, | |
12700 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 12701 | |
12702 | /* "no neighbor peer-group unset" commands. */ | |
12703 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
12704 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12705 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12706 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12707 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12708 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12709 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12710 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 12711 | install_element(BGP_FLOWSPECV4_NODE, |
12712 | &no_neighbor_set_peer_group_hidden_cmd); | |
12713 | install_element(BGP_FLOWSPECV6_NODE, | |
12714 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 12715 | |
12716 | /* "neighbor softreconfiguration inbound" commands.*/ | |
12717 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
12718 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
12719 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
12720 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12721 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
12722 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12723 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
12724 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12725 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
12726 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12727 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
12728 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12729 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
12730 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12731 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
12732 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12733 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
12734 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 12735 | install_element(BGP_FLOWSPECV4_NODE, |
12736 | &neighbor_soft_reconfiguration_cmd); | |
12737 | install_element(BGP_FLOWSPECV4_NODE, | |
12738 | &no_neighbor_soft_reconfiguration_cmd); | |
12739 | install_element(BGP_FLOWSPECV6_NODE, | |
12740 | &neighbor_soft_reconfiguration_cmd); | |
12741 | install_element(BGP_FLOWSPECV6_NODE, | |
12742 | &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 12743 | |
12744 | /* "neighbor attribute-unchanged" commands. */ | |
12745 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
12746 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
12747 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
12748 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
12749 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
12750 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
12751 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
12752 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
12753 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
12754 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
12755 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
12756 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
12757 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
12758 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
12759 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
12760 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
12761 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
12762 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
12763 | ||
12764 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
12765 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
12766 | ||
12767 | /* "nexthop-local unchanged" commands */ | |
12768 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
12769 | install_element(BGP_IPV6_NODE, | |
12770 | &no_neighbor_nexthop_local_unchanged_cmd); | |
12771 | ||
12772 | /* "neighbor next-hop-self" commands. */ | |
12773 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
12774 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
12775 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
12776 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
12777 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
12778 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
12779 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
12780 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
12781 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
12782 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
12783 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
12784 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
12785 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
12786 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
12787 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
12788 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
12789 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
12790 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
12791 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
12792 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 12793 | |
12794 | /* "neighbor next-hop-self force" commands. */ | |
12795 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
12796 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
12797 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); | |
12798 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
12799 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); | |
12800 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
12801 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); | |
12802 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
12803 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); | |
12804 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
12805 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); | |
12806 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
12807 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); | |
12808 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
12809 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); | |
12810 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
12811 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); | |
12812 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
12813 | ||
12814 | /* "neighbor as-override" commands. */ | |
12815 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
12816 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
12817 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
12818 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
12819 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
12820 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
12821 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
12822 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
12823 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
12824 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
12825 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
12826 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
12827 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
12828 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
12829 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
12830 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
12831 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
12832 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
12833 | ||
12834 | /* "neighbor remove-private-AS" commands. */ | |
12835 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
12836 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
12837 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
12838 | install_element(BGP_NODE, | |
12839 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
12840 | install_element(BGP_NODE, | |
12841 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
12842 | install_element(BGP_NODE, | |
12843 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
12844 | install_element(BGP_NODE, | |
12845 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
12846 | install_element( | |
12847 | BGP_NODE, | |
12848 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
12849 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
12850 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
12851 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
12852 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
12853 | install_element(BGP_IPV4_NODE, | |
12854 | &neighbor_remove_private_as_replace_as_cmd); | |
12855 | install_element(BGP_IPV4_NODE, | |
12856 | &no_neighbor_remove_private_as_replace_as_cmd); | |
12857 | install_element(BGP_IPV4_NODE, | |
12858 | &neighbor_remove_private_as_all_replace_as_cmd); | |
12859 | install_element(BGP_IPV4_NODE, | |
12860 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
12861 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
12862 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
12863 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
12864 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
12865 | install_element(BGP_IPV4M_NODE, | |
12866 | &neighbor_remove_private_as_replace_as_cmd); | |
12867 | install_element(BGP_IPV4M_NODE, | |
12868 | &no_neighbor_remove_private_as_replace_as_cmd); | |
12869 | install_element(BGP_IPV4M_NODE, | |
12870 | &neighbor_remove_private_as_all_replace_as_cmd); | |
12871 | install_element(BGP_IPV4M_NODE, | |
12872 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
12873 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
12874 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
12875 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
12876 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
12877 | install_element(BGP_IPV4L_NODE, | |
12878 | &neighbor_remove_private_as_replace_as_cmd); | |
12879 | install_element(BGP_IPV4L_NODE, | |
12880 | &no_neighbor_remove_private_as_replace_as_cmd); | |
12881 | install_element(BGP_IPV4L_NODE, | |
12882 | &neighbor_remove_private_as_all_replace_as_cmd); | |
12883 | install_element(BGP_IPV4L_NODE, | |
12884 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
12885 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
12886 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
12887 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
12888 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
12889 | install_element(BGP_IPV6_NODE, | |
12890 | &neighbor_remove_private_as_replace_as_cmd); | |
12891 | install_element(BGP_IPV6_NODE, | |
12892 | &no_neighbor_remove_private_as_replace_as_cmd); | |
12893 | install_element(BGP_IPV6_NODE, | |
12894 | &neighbor_remove_private_as_all_replace_as_cmd); | |
12895 | install_element(BGP_IPV6_NODE, | |
12896 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
12897 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
12898 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
12899 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
12900 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
12901 | install_element(BGP_IPV6M_NODE, | |
12902 | &neighbor_remove_private_as_replace_as_cmd); | |
12903 | install_element(BGP_IPV6M_NODE, | |
12904 | &no_neighbor_remove_private_as_replace_as_cmd); | |
12905 | install_element(BGP_IPV6M_NODE, | |
12906 | &neighbor_remove_private_as_all_replace_as_cmd); | |
12907 | install_element(BGP_IPV6M_NODE, | |
12908 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
12909 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
12910 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
12911 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
12912 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
12913 | install_element(BGP_IPV6L_NODE, | |
12914 | &neighbor_remove_private_as_replace_as_cmd); | |
12915 | install_element(BGP_IPV6L_NODE, | |
12916 | &no_neighbor_remove_private_as_replace_as_cmd); | |
12917 | install_element(BGP_IPV6L_NODE, | |
12918 | &neighbor_remove_private_as_all_replace_as_cmd); | |
12919 | install_element(BGP_IPV6L_NODE, | |
12920 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
12921 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
12922 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
12923 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
12924 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
12925 | install_element(BGP_VPNV4_NODE, | |
12926 | &neighbor_remove_private_as_replace_as_cmd); | |
12927 | install_element(BGP_VPNV4_NODE, | |
12928 | &no_neighbor_remove_private_as_replace_as_cmd); | |
12929 | install_element(BGP_VPNV4_NODE, | |
12930 | &neighbor_remove_private_as_all_replace_as_cmd); | |
12931 | install_element(BGP_VPNV4_NODE, | |
12932 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
12933 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
12934 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
12935 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
12936 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
12937 | install_element(BGP_VPNV6_NODE, | |
12938 | &neighbor_remove_private_as_replace_as_cmd); | |
12939 | install_element(BGP_VPNV6_NODE, | |
12940 | &no_neighbor_remove_private_as_replace_as_cmd); | |
12941 | install_element(BGP_VPNV6_NODE, | |
12942 | &neighbor_remove_private_as_all_replace_as_cmd); | |
12943 | install_element(BGP_VPNV6_NODE, | |
12944 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
12945 | ||
12946 | /* "neighbor send-community" commands.*/ | |
12947 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
12948 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
12949 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
12950 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
12951 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
12952 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
12953 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
12954 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
12955 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
12956 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
12957 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
12958 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
12959 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
12960 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
12961 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
12962 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
12963 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
12964 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
12965 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
12966 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
12967 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
12968 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
12969 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
12970 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
12971 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
12972 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
12973 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
12974 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
12975 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
12976 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
12977 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
12978 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
12979 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
12980 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
12981 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
12982 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
12983 | ||
12984 | /* "neighbor route-reflector" commands.*/ | |
12985 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
12986 | install_element(BGP_NODE, | |
12987 | &no_neighbor_route_reflector_client_hidden_cmd); | |
12988 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
12989 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
12990 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
12991 | install_element(BGP_IPV4M_NODE, | |
12992 | &no_neighbor_route_reflector_client_cmd); | |
12993 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
12994 | install_element(BGP_IPV4L_NODE, | |
12995 | &no_neighbor_route_reflector_client_cmd); | |
12996 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
12997 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
12998 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
12999 | install_element(BGP_IPV6M_NODE, | |
13000 | &no_neighbor_route_reflector_client_cmd); | |
13001 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
13002 | install_element(BGP_IPV6L_NODE, | |
13003 | &no_neighbor_route_reflector_client_cmd); | |
13004 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
13005 | install_element(BGP_VPNV4_NODE, | |
13006 | &no_neighbor_route_reflector_client_cmd); | |
13007 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
13008 | install_element(BGP_VPNV6_NODE, | |
13009 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 13010 | install_element(BGP_FLOWSPECV4_NODE, |
13011 | &neighbor_route_reflector_client_cmd); | |
13012 | install_element(BGP_FLOWSPECV4_NODE, | |
13013 | &no_neighbor_route_reflector_client_cmd); | |
13014 | install_element(BGP_FLOWSPECV6_NODE, | |
13015 | &neighbor_route_reflector_client_cmd); | |
13016 | install_element(BGP_FLOWSPECV6_NODE, | |
13017 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 13018 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
13019 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
13020 | ||
13021 | /* "neighbor route-server" commands.*/ | |
13022 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
13023 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
13024 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
13025 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
13026 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
13027 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
13028 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
13029 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
13030 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
13031 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
13032 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
13033 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
13034 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
13035 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
13036 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
13037 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
13038 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
13039 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 13040 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
13041 | install_element(BGP_FLOWSPECV4_NODE, | |
13042 | &no_neighbor_route_server_client_cmd); | |
13043 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
13044 | install_element(BGP_FLOWSPECV6_NODE, | |
13045 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 13046 | |
13047 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
13048 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
13049 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
13050 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13051 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13052 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13053 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13054 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13055 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13056 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13057 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13058 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13059 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13060 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13061 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13062 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13063 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13064 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13065 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13066 | ||
13067 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
13068 | install_element(BGP_NODE, | |
13069 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
13070 | install_element(BGP_NODE, | |
13071 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
13072 | install_element(BGP_IPV4_NODE, | |
13073 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13074 | install_element(BGP_IPV4_NODE, | |
13075 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13076 | install_element(BGP_IPV4M_NODE, | |
13077 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13078 | install_element(BGP_IPV4M_NODE, | |
13079 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13080 | install_element(BGP_IPV4L_NODE, | |
13081 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13082 | install_element(BGP_IPV4L_NODE, | |
13083 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13084 | install_element(BGP_IPV6_NODE, | |
13085 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13086 | install_element(BGP_IPV6_NODE, | |
13087 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13088 | install_element(BGP_IPV6M_NODE, | |
13089 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13090 | install_element(BGP_IPV6M_NODE, | |
13091 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13092 | install_element(BGP_IPV6L_NODE, | |
13093 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13094 | install_element(BGP_IPV6L_NODE, | |
13095 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13096 | install_element(BGP_VPNV4_NODE, | |
13097 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13098 | install_element(BGP_VPNV4_NODE, | |
13099 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13100 | install_element(BGP_VPNV6_NODE, | |
13101 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13102 | install_element(BGP_VPNV6_NODE, | |
13103 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13104 | ||
13105 | /* "neighbor passive" commands. */ | |
13106 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
13107 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
13108 | ||
13109 | ||
13110 | /* "neighbor shutdown" commands. */ | |
13111 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
13112 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
13113 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
13114 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
13115 | ||
13116 | /* "neighbor capability extended-nexthop" commands.*/ | |
13117 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
13118 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
13119 | ||
13120 | /* "neighbor capability orf prefix-list" commands.*/ | |
13121 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
13122 | install_element(BGP_NODE, | |
13123 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
13124 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
13125 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13126 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
13127 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13128 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
13129 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13130 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
13131 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13132 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
13133 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13134 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
13135 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13136 | ||
13137 | /* "neighbor capability dynamic" commands.*/ | |
13138 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
13139 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
13140 | ||
13141 | /* "neighbor dont-capability-negotiate" commands. */ | |
13142 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
13143 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
13144 | ||
13145 | /* "neighbor ebgp-multihop" commands. */ | |
13146 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
13147 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
13148 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
13149 | ||
13150 | /* "neighbor disable-connected-check" commands. */ | |
13151 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
13152 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
13153 | ||
47cbc09b PM |
13154 | /* "neighbor enforce-first-as" commands. */ |
13155 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
13156 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
13157 | ||
d62a17ae | 13158 | /* "neighbor description" commands. */ |
13159 | install_element(BGP_NODE, &neighbor_description_cmd); | |
13160 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 13161 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 13162 | |
13163 | /* "neighbor update-source" commands. "*/ | |
13164 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
13165 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
13166 | ||
13167 | /* "neighbor default-originate" commands. */ | |
13168 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
13169 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
13170 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
13171 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
13172 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
13173 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
13174 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
13175 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
13176 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
13177 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
13178 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
13179 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
13180 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
13181 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
13182 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
13183 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
13184 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
13185 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
13186 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
13187 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
13188 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
13189 | ||
13190 | /* "neighbor port" commands. */ | |
13191 | install_element(BGP_NODE, &neighbor_port_cmd); | |
13192 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
13193 | ||
13194 | /* "neighbor weight" commands. */ | |
13195 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
13196 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
13197 | ||
13198 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
13199 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
13200 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
13201 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
13202 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
13203 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
13204 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
13205 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
13206 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
13207 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
13208 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
13209 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
13210 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
13211 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
13212 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
13213 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
13214 | ||
13215 | /* "neighbor override-capability" commands. */ | |
13216 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
13217 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
13218 | ||
13219 | /* "neighbor strict-capability-match" commands. */ | |
13220 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
13221 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
13222 | ||
13223 | /* "neighbor timers" commands. */ | |
13224 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
13225 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
13226 | ||
13227 | /* "neighbor timers connect" commands. */ | |
13228 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
13229 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
13230 | ||
13231 | /* "neighbor advertisement-interval" commands. */ | |
13232 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
13233 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
13234 | ||
13235 | /* "neighbor interface" commands. */ | |
13236 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
13237 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
13238 | ||
13239 | /* "neighbor distribute" commands. */ | |
13240 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
13241 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
13242 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
13243 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
13244 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
13245 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
13246 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
13247 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
13248 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
13249 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
13250 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
13251 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
13252 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
13253 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
13254 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
13255 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
13256 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
13257 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
13258 | ||
13259 | /* "neighbor prefix-list" commands. */ | |
13260 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
13261 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
13262 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
13263 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
13264 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
13265 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
13266 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); | |
13267 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
13268 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
13269 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
13270 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); | |
13271 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
13272 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); | |
13273 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
13274 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); | |
13275 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
13276 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); | |
13277 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
7c40bf39 | 13278 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
13279 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); | |
13280 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); | |
13281 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); | |
d62a17ae | 13282 | |
13283 | /* "neighbor filter-list" commands. */ | |
13284 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
13285 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
13286 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
13287 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
13288 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
13289 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
13290 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
13291 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
13292 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
13293 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
13294 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
13295 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
13296 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
13297 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
13298 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
13299 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
13300 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
13301 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 13302 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
13303 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
13304 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
13305 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 13306 | |
13307 | /* "neighbor route-map" commands. */ | |
13308 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); | |
13309 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
13310 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
13311 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
13312 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
13313 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
13314 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); | |
13315 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
13316 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
13317 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
13318 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); | |
13319 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
13320 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); | |
13321 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
13322 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); | |
13323 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
13324 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); | |
13325 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
7c40bf39 | 13326 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
13327 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); | |
13328 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); | |
13329 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); | |
d37ba549 MK |
13330 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
13331 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); | |
d62a17ae | 13332 | |
13333 | /* "neighbor unsuppress-map" commands. */ | |
13334 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
13335 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
13336 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
13337 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
13338 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
13339 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
13340 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
13341 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
13342 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
13343 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
13344 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
13345 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
13346 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
13347 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
13348 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
13349 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
13350 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
13351 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
13352 | ||
13353 | /* "neighbor maximum-prefix" commands. */ | |
13354 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
13355 | install_element(BGP_NODE, | |
13356 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
13357 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
13358 | install_element(BGP_NODE, | |
13359 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
13360 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
13361 | install_element(BGP_NODE, | |
13362 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
13363 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
13364 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
13365 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13366 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13367 | install_element(BGP_IPV4_NODE, | |
13368 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13369 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13370 | install_element(BGP_IPV4_NODE, | |
13371 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13372 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
13373 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
13374 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13375 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13376 | install_element(BGP_IPV4M_NODE, | |
13377 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13378 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13379 | install_element(BGP_IPV4M_NODE, | |
13380 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13381 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
13382 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
13383 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13384 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13385 | install_element(BGP_IPV4L_NODE, | |
13386 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13387 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13388 | install_element(BGP_IPV4L_NODE, | |
13389 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13390 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
13391 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
13392 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13393 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13394 | install_element(BGP_IPV6_NODE, | |
13395 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13396 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13397 | install_element(BGP_IPV6_NODE, | |
13398 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13399 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
13400 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
13401 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13402 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13403 | install_element(BGP_IPV6M_NODE, | |
13404 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13405 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13406 | install_element(BGP_IPV6M_NODE, | |
13407 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13408 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
13409 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
13410 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13411 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13412 | install_element(BGP_IPV6L_NODE, | |
13413 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13414 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13415 | install_element(BGP_IPV6L_NODE, | |
13416 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13417 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
13418 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
13419 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13420 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13421 | install_element(BGP_VPNV4_NODE, | |
13422 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13423 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13424 | install_element(BGP_VPNV4_NODE, | |
13425 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13426 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
13427 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
13428 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13429 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13430 | install_element(BGP_VPNV6_NODE, | |
13431 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13432 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13433 | install_element(BGP_VPNV6_NODE, | |
13434 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13435 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
13436 | ||
13437 | /* "neighbor allowas-in" */ | |
13438 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
13439 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
13440 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
13441 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
13442 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
13443 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
13444 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
13445 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
13446 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
13447 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
13448 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
13449 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
13450 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
13451 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
13452 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
13453 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
13454 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
13455 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
13456 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
13457 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
13458 | ||
13459 | /* address-family commands. */ | |
13460 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
13461 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 13462 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 13463 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
13464 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 13465 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 13466 | |
d62a17ae | 13467 | install_element(BGP_NODE, &address_family_evpn_cmd); |
13468 | ||
13469 | /* "exit-address-family" command. */ | |
13470 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
13471 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
13472 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
13473 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
13474 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
13475 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
13476 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
13477 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 13478 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
13479 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 13480 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
13481 | ||
13482 | /* "clear ip bgp commands" */ | |
13483 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
13484 | ||
13485 | /* clear ip bgp prefix */ | |
13486 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
13487 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
13488 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
13489 | ||
13490 | /* "show [ip] bgp summary" commands. */ | |
13491 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
d62a17ae | 13492 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 13493 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 13494 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
13495 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 13496 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
13497 | ||
13498 | /* "show [ip] bgp neighbors" commands. */ | |
13499 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
13500 | ||
13501 | /* "show [ip] bgp peer-group" commands. */ | |
13502 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
13503 | ||
13504 | /* "show [ip] bgp paths" commands. */ | |
13505 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
13506 | ||
13507 | /* "show [ip] bgp community" commands. */ | |
13508 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
13509 | ||
13510 | /* "show ip bgp large-community" commands. */ | |
13511 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
13512 | /* "show [ip] bgp attribute-info" commands. */ | |
13513 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 13514 | /* "show [ip] bgp route-leak" command */ |
13515 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 13516 | |
13517 | /* "redistribute" commands. */ | |
13518 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
13519 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
13520 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
13521 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
13522 | install_element(BGP_NODE, | |
13523 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
13524 | install_element(BGP_NODE, | |
13525 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
13526 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
13527 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
13528 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
13529 | install_element(BGP_NODE, | |
13530 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
13531 | install_element(BGP_NODE, | |
13532 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
13533 | install_element(BGP_NODE, | |
13534 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
13535 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
13536 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
13537 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
13538 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
13539 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
13540 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
13541 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
13542 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
13543 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
13544 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
13545 | install_element(BGP_IPV4_NODE, | |
13546 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
13547 | install_element(BGP_IPV4_NODE, | |
13548 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
13549 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
13550 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
13551 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
13552 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
13553 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
13554 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
13555 | ||
b9c7bc5a PZ |
13556 | /* import|export vpn [route-map WORD] */ |
13557 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
13558 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 13559 | |
12a844a5 DS |
13560 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
13561 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
13562 | ||
d62a17ae | 13563 | /* ttl_security commands */ |
13564 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
13565 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
13566 | ||
13567 | /* "show [ip] bgp memory" commands. */ | |
13568 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
13569 | ||
acf71666 MK |
13570 | /* "show bgp martian next-hop" */ |
13571 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
13572 | ||
d62a17ae | 13573 | /* "show [ip] bgp views" commands. */ |
13574 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
13575 | ||
13576 | /* "show [ip] bgp vrfs" commands. */ | |
13577 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
13578 | ||
13579 | /* Community-list. */ | |
13580 | community_list_vty(); | |
ddb5b488 PZ |
13581 | |
13582 | /* vpn-policy commands */ | |
b9c7bc5a PZ |
13583 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
13584 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
13585 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
13586 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
13587 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
13588 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
13589 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
13590 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
13591 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
13592 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
13593 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
13594 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 13595 | |
301ad80a PG |
13596 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
13597 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
13598 | ||
b9c7bc5a PZ |
13599 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
13600 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
13601 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
13602 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
13603 | install_element(BGP_IPV4_NODE, &af_no_nexthop_vpn_export_cmd); | |
13604 | install_element(BGP_IPV6_NODE, &af_no_nexthop_vpn_export_cmd); | |
13605 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); | |
13606 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
13607 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
13608 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
13609 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
13610 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
718e3744 | 13611 | } |
6b0655a2 | 13612 | |
718e3744 | 13613 | #include "memory.h" |
13614 | #include "bgp_regex.h" | |
13615 | #include "bgp_clist.h" | |
13616 | #include "bgp_ecommunity.h" | |
13617 | ||
13618 | /* VTY functions. */ | |
13619 | ||
13620 | /* Direction value to string conversion. */ | |
d62a17ae | 13621 | static const char *community_direct_str(int direct) |
13622 | { | |
13623 | switch (direct) { | |
13624 | case COMMUNITY_DENY: | |
13625 | return "deny"; | |
13626 | case COMMUNITY_PERMIT: | |
13627 | return "permit"; | |
13628 | default: | |
13629 | return "unknown"; | |
13630 | } | |
718e3744 | 13631 | } |
13632 | ||
13633 | /* Display error string. */ | |
d62a17ae | 13634 | static void community_list_perror(struct vty *vty, int ret) |
13635 | { | |
13636 | switch (ret) { | |
13637 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
13638 | vty_out(vty, "%% Can't find community-list\n"); | |
13639 | break; | |
13640 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
13641 | vty_out(vty, "%% Malformed community-list value\n"); | |
13642 | break; | |
13643 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
13644 | vty_out(vty, | |
13645 | "%% Community name conflict, previously defined as standard community\n"); | |
13646 | break; | |
13647 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
13648 | vty_out(vty, | |
13649 | "%% Community name conflict, previously defined as expanded community\n"); | |
13650 | break; | |
13651 | } | |
718e3744 | 13652 | } |
13653 | ||
5bf15956 DW |
13654 | /* "community-list" keyword help string. */ |
13655 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
13656 | ||
5bf15956 | 13657 | /* ip community-list standard */ |
718e3744 | 13658 | DEFUN (ip_community_list_standard, |
13659 | ip_community_list_standard_cmd, | |
e961923c | 13660 | "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 13661 | IP_STR |
13662 | COMMUNITY_LIST_STR | |
13663 | "Community list number (standard)\n" | |
5bf15956 | 13664 | "Add an standard community-list entry\n" |
718e3744 | 13665 | "Community list name\n" |
13666 | "Specify community to reject\n" | |
13667 | "Specify community to accept\n" | |
13668 | COMMUNITY_VAL_STR) | |
13669 | { | |
d62a17ae | 13670 | char *cl_name_or_number = NULL; |
13671 | int direct = 0; | |
13672 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 13673 | |
d62a17ae | 13674 | int idx = 0; |
13675 | argv_find(argv, argc, "(1-99)", &idx); | |
13676 | argv_find(argv, argc, "WORD", &idx); | |
13677 | cl_name_or_number = argv[idx]->arg; | |
13678 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13679 | : COMMUNITY_DENY; | |
13680 | argv_find(argv, argc, "AA:NN", &idx); | |
13681 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 13682 | |
d62a17ae | 13683 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
13684 | style); | |
42f914d4 | 13685 | |
d62a17ae | 13686 | XFREE(MTYPE_TMP, str); |
42f914d4 | 13687 | |
d62a17ae | 13688 | if (ret < 0) { |
13689 | /* Display error string. */ | |
13690 | community_list_perror(vty, ret); | |
13691 | return CMD_WARNING_CONFIG_FAILED; | |
13692 | } | |
42f914d4 | 13693 | |
d62a17ae | 13694 | return CMD_SUCCESS; |
718e3744 | 13695 | } |
13696 | ||
fee6e4e4 | 13697 | DEFUN (no_ip_community_list_standard_all, |
13698 | no_ip_community_list_standard_all_cmd, | |
e961923c | 13699 | "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 13700 | NO_STR |
13701 | IP_STR | |
13702 | COMMUNITY_LIST_STR | |
13703 | "Community list number (standard)\n" | |
5bf15956 DW |
13704 | "Add an standard community-list entry\n" |
13705 | "Community list name\n" | |
718e3744 | 13706 | "Specify community to reject\n" |
13707 | "Specify community to accept\n" | |
13708 | COMMUNITY_VAL_STR) | |
13709 | { | |
d62a17ae | 13710 | char *cl_name_or_number = NULL; |
13711 | int direct = 0; | |
13712 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 13713 | |
d62a17ae | 13714 | int idx = 0; |
13715 | argv_find(argv, argc, "(1-99)", &idx); | |
13716 | argv_find(argv, argc, "WORD", &idx); | |
13717 | cl_name_or_number = argv[idx]->arg; | |
13718 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13719 | : COMMUNITY_DENY; | |
13720 | argv_find(argv, argc, "AA:NN", &idx); | |
13721 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 13722 | |
d62a17ae | 13723 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
7298a8e1 | 13724 | direct, style); |
42f914d4 | 13725 | |
d62a17ae | 13726 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 13727 | |
d62a17ae | 13728 | if (ret < 0) { |
13729 | community_list_perror(vty, ret); | |
13730 | return CMD_WARNING_CONFIG_FAILED; | |
13731 | } | |
42f914d4 | 13732 | |
d62a17ae | 13733 | return CMD_SUCCESS; |
718e3744 | 13734 | } |
13735 | ||
5bf15956 DW |
13736 | /* ip community-list expanded */ |
13737 | DEFUN (ip_community_list_expanded_all, | |
13738 | ip_community_list_expanded_all_cmd, | |
42f914d4 | 13739 | "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 13740 | IP_STR |
13741 | COMMUNITY_LIST_STR | |
13742 | "Community list number (expanded)\n" | |
5bf15956 | 13743 | "Add an expanded community-list entry\n" |
718e3744 | 13744 | "Community list name\n" |
13745 | "Specify community to reject\n" | |
13746 | "Specify community to accept\n" | |
13747 | COMMUNITY_VAL_STR) | |
13748 | { | |
d62a17ae | 13749 | char *cl_name_or_number = NULL; |
13750 | int direct = 0; | |
13751 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 13752 | |
d62a17ae | 13753 | int idx = 0; |
13754 | argv_find(argv, argc, "(100-500)", &idx); | |
13755 | argv_find(argv, argc, "WORD", &idx); | |
13756 | cl_name_or_number = argv[idx]->arg; | |
13757 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13758 | : COMMUNITY_DENY; | |
13759 | argv_find(argv, argc, "AA:NN", &idx); | |
13760 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 13761 | |
d62a17ae | 13762 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
13763 | style); | |
42f914d4 | 13764 | |
d62a17ae | 13765 | XFREE(MTYPE_TMP, str); |
42f914d4 | 13766 | |
d62a17ae | 13767 | if (ret < 0) { |
13768 | /* Display error string. */ | |
13769 | community_list_perror(vty, ret); | |
13770 | return CMD_WARNING_CONFIG_FAILED; | |
13771 | } | |
42f914d4 | 13772 | |
d62a17ae | 13773 | return CMD_SUCCESS; |
718e3744 | 13774 | } |
13775 | ||
5bf15956 DW |
13776 | DEFUN (no_ip_community_list_expanded_all, |
13777 | no_ip_community_list_expanded_all_cmd, | |
42f914d4 | 13778 | "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 13779 | NO_STR |
13780 | IP_STR | |
13781 | COMMUNITY_LIST_STR | |
5bf15956 DW |
13782 | "Community list number (expanded)\n" |
13783 | "Add an expanded community-list entry\n" | |
718e3744 | 13784 | "Community list name\n" |
13785 | "Specify community to reject\n" | |
13786 | "Specify community to accept\n" | |
5bf15956 | 13787 | COMMUNITY_VAL_STR) |
718e3744 | 13788 | { |
d62a17ae | 13789 | char *cl_name_or_number = NULL; |
13790 | int direct = 0; | |
13791 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 13792 | |
d62a17ae | 13793 | int idx = 0; |
13794 | argv_find(argv, argc, "(100-500)", &idx); | |
13795 | argv_find(argv, argc, "WORD", &idx); | |
13796 | cl_name_or_number = argv[idx]->arg; | |
13797 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13798 | : COMMUNITY_DENY; | |
13799 | argv_find(argv, argc, "AA:NN", &idx); | |
13800 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 13801 | |
d62a17ae | 13802 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
7298a8e1 | 13803 | direct, style); |
42f914d4 | 13804 | |
d62a17ae | 13805 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 13806 | |
d62a17ae | 13807 | if (ret < 0) { |
13808 | community_list_perror(vty, ret); | |
13809 | return CMD_WARNING_CONFIG_FAILED; | |
13810 | } | |
42f914d4 | 13811 | |
d62a17ae | 13812 | return CMD_SUCCESS; |
718e3744 | 13813 | } |
13814 | ||
8d9b8ed9 PM |
13815 | /* Return configuration string of community-list entry. */ |
13816 | static const char *community_list_config_str(struct community_entry *entry) | |
13817 | { | |
13818 | const char *str; | |
13819 | ||
13820 | if (entry->any) | |
13821 | str = ""; | |
13822 | else { | |
13823 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
13824 | str = community_str(entry->u.com, false); | |
13825 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
13826 | str = lcommunity_str(entry->u.lcom, false); | |
13827 | else | |
13828 | str = entry->config; | |
13829 | } | |
13830 | return str; | |
13831 | } | |
13832 | ||
d62a17ae | 13833 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 13834 | { |
d62a17ae | 13835 | struct community_entry *entry; |
718e3744 | 13836 | |
d62a17ae | 13837 | for (entry = list->head; entry; entry = entry->next) { |
13838 | if (entry == list->head) { | |
13839 | if (all_digit(list->name)) | |
13840 | vty_out(vty, "Community %s list %s\n", | |
13841 | entry->style == COMMUNITY_LIST_STANDARD | |
13842 | ? "standard" | |
13843 | : "(expanded) access", | |
13844 | list->name); | |
13845 | else | |
13846 | vty_out(vty, "Named Community %s list %s\n", | |
13847 | entry->style == COMMUNITY_LIST_STANDARD | |
13848 | ? "standard" | |
13849 | : "expanded", | |
13850 | list->name); | |
13851 | } | |
13852 | if (entry->any) | |
13853 | vty_out(vty, " %s\n", | |
13854 | community_direct_str(entry->direct)); | |
13855 | else | |
13856 | vty_out(vty, " %s %s\n", | |
13857 | community_direct_str(entry->direct), | |
8d9b8ed9 | 13858 | community_list_config_str(entry)); |
d62a17ae | 13859 | } |
718e3744 | 13860 | } |
13861 | ||
13862 | DEFUN (show_ip_community_list, | |
13863 | show_ip_community_list_cmd, | |
13864 | "show ip community-list", | |
13865 | SHOW_STR | |
13866 | IP_STR | |
13867 | "List community-list\n") | |
13868 | { | |
d62a17ae | 13869 | struct community_list *list; |
13870 | struct community_list_master *cm; | |
718e3744 | 13871 | |
d62a17ae | 13872 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
13873 | if (!cm) | |
13874 | return CMD_SUCCESS; | |
718e3744 | 13875 | |
d62a17ae | 13876 | for (list = cm->num.head; list; list = list->next) |
13877 | community_list_show(vty, list); | |
718e3744 | 13878 | |
d62a17ae | 13879 | for (list = cm->str.head; list; list = list->next) |
13880 | community_list_show(vty, list); | |
718e3744 | 13881 | |
d62a17ae | 13882 | return CMD_SUCCESS; |
718e3744 | 13883 | } |
13884 | ||
13885 | DEFUN (show_ip_community_list_arg, | |
13886 | show_ip_community_list_arg_cmd, | |
6147e2c6 | 13887 | "show ip community-list <(1-500)|WORD>", |
718e3744 | 13888 | SHOW_STR |
13889 | IP_STR | |
13890 | "List community-list\n" | |
13891 | "Community-list number\n" | |
13892 | "Community-list name\n") | |
13893 | { | |
d62a17ae | 13894 | int idx_comm_list = 3; |
13895 | struct community_list *list; | |
718e3744 | 13896 | |
d62a17ae | 13897 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, |
13898 | COMMUNITY_LIST_MASTER); | |
13899 | if (!list) { | |
13900 | vty_out(vty, "%% Can't find community-list\n"); | |
13901 | return CMD_WARNING; | |
13902 | } | |
718e3744 | 13903 | |
d62a17ae | 13904 | community_list_show(vty, list); |
718e3744 | 13905 | |
d62a17ae | 13906 | return CMD_SUCCESS; |
718e3744 | 13907 | } |
6b0655a2 | 13908 | |
57d187bc JS |
13909 | /* |
13910 | * Large Community code. | |
13911 | */ | |
d62a17ae | 13912 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
13913 | struct cmd_token **argv, int style, | |
13914 | int reject_all_digit_name) | |
13915 | { | |
13916 | int ret; | |
13917 | int direct; | |
13918 | char *str; | |
13919 | int idx = 0; | |
13920 | char *cl_name; | |
13921 | ||
13922 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13923 | : COMMUNITY_DENY; | |
13924 | ||
13925 | /* All digit name check. */ | |
13926 | idx = 0; | |
13927 | argv_find(argv, argc, "WORD", &idx); | |
13928 | argv_find(argv, argc, "(1-99)", &idx); | |
13929 | argv_find(argv, argc, "(100-500)", &idx); | |
13930 | cl_name = argv[idx]->arg; | |
13931 | if (reject_all_digit_name && all_digit(cl_name)) { | |
13932 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
13933 | return CMD_WARNING_CONFIG_FAILED; | |
13934 | } | |
13935 | ||
13936 | idx = 0; | |
13937 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
13938 | argv_find(argv, argc, "LINE", &idx); | |
13939 | /* Concat community string argument. */ | |
13940 | if (idx) | |
13941 | str = argv_concat(argv, argc, idx); | |
13942 | else | |
13943 | str = NULL; | |
13944 | ||
13945 | ret = lcommunity_list_set(bgp_clist, cl_name, str, direct, style); | |
13946 | ||
13947 | /* Free temporary community list string allocated by | |
13948 | argv_concat(). */ | |
13949 | if (str) | |
13950 | XFREE(MTYPE_TMP, str); | |
13951 | ||
13952 | if (ret < 0) { | |
13953 | community_list_perror(vty, ret); | |
13954 | return CMD_WARNING_CONFIG_FAILED; | |
13955 | } | |
13956 | return CMD_SUCCESS; | |
13957 | } | |
13958 | ||
13959 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
13960 | struct cmd_token **argv, int style) | |
13961 | { | |
13962 | int ret; | |
13963 | int direct = 0; | |
13964 | char *str = NULL; | |
13965 | int idx = 0; | |
13966 | ||
13967 | argv_find(argv, argc, "permit", &idx); | |
13968 | argv_find(argv, argc, "deny", &idx); | |
13969 | ||
13970 | if (idx) { | |
13971 | /* Check the list direct. */ | |
13972 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
13973 | direct = COMMUNITY_PERMIT; | |
13974 | else | |
13975 | direct = COMMUNITY_DENY; | |
13976 | ||
13977 | idx = 0; | |
13978 | argv_find(argv, argc, "LINE", &idx); | |
13979 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
13980 | /* Concat community string argument. */ | |
13981 | str = argv_concat(argv, argc, idx); | |
13982 | } | |
13983 | ||
13984 | idx = 0; | |
13985 | argv_find(argv, argc, "(1-99)", &idx); | |
13986 | argv_find(argv, argc, "(100-500)", &idx); | |
13987 | argv_find(argv, argc, "WORD", &idx); | |
13988 | ||
13989 | /* Unset community list. */ | |
13990 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, direct, | |
13991 | style); | |
13992 | ||
13993 | /* Free temporary community list string allocated by | |
13994 | argv_concat(). */ | |
13995 | if (str) | |
13996 | XFREE(MTYPE_TMP, str); | |
13997 | ||
13998 | if (ret < 0) { | |
13999 | community_list_perror(vty, ret); | |
14000 | return CMD_WARNING_CONFIG_FAILED; | |
14001 | } | |
14002 | ||
14003 | return CMD_SUCCESS; | |
57d187bc JS |
14004 | } |
14005 | ||
14006 | /* "large-community-list" keyword help string. */ | |
14007 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
14008 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
14009 | ||
14010 | DEFUN (ip_lcommunity_list_standard, | |
14011 | ip_lcommunity_list_standard_cmd, | |
52951b63 DS |
14012 | "ip large-community-list (1-99) <deny|permit>", |
14013 | IP_STR | |
14014 | LCOMMUNITY_LIST_STR | |
14015 | "Large Community list number (standard)\n" | |
14016 | "Specify large community to reject\n" | |
7111c1a0 | 14017 | "Specify large community to accept\n") |
52951b63 | 14018 | { |
d62a17ae | 14019 | return lcommunity_list_set_vty(vty, argc, argv, |
14020 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
14021 | } |
14022 | ||
14023 | DEFUN (ip_lcommunity_list_standard1, | |
14024 | ip_lcommunity_list_standard1_cmd, | |
14025 | "ip large-community-list (1-99) <deny|permit> AA:BB:CC...", | |
57d187bc JS |
14026 | IP_STR |
14027 | LCOMMUNITY_LIST_STR | |
14028 | "Large Community list number (standard)\n" | |
14029 | "Specify large community to reject\n" | |
14030 | "Specify large community to accept\n" | |
14031 | LCOMMUNITY_VAL_STR) | |
14032 | { | |
d62a17ae | 14033 | return lcommunity_list_set_vty(vty, argc, argv, |
14034 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
57d187bc JS |
14035 | } |
14036 | ||
14037 | DEFUN (ip_lcommunity_list_expanded, | |
14038 | ip_lcommunity_list_expanded_cmd, | |
14039 | "ip large-community-list (100-500) <deny|permit> LINE...", | |
14040 | IP_STR | |
14041 | LCOMMUNITY_LIST_STR | |
14042 | "Large Community list number (expanded)\n" | |
14043 | "Specify large community to reject\n" | |
14044 | "Specify large community to accept\n" | |
14045 | "An ordered list as a regular-expression\n") | |
14046 | { | |
d62a17ae | 14047 | return lcommunity_list_set_vty(vty, argc, argv, |
14048 | LARGE_COMMUNITY_LIST_EXPANDED, 0); | |
57d187bc JS |
14049 | } |
14050 | ||
14051 | DEFUN (ip_lcommunity_list_name_standard, | |
14052 | ip_lcommunity_list_name_standard_cmd, | |
52951b63 DS |
14053 | "ip large-community-list standard WORD <deny|permit>", |
14054 | IP_STR | |
14055 | LCOMMUNITY_LIST_STR | |
14056 | "Specify standard large-community-list\n" | |
14057 | "Large Community list name\n" | |
14058 | "Specify large community to reject\n" | |
14059 | "Specify large community to accept\n") | |
14060 | { | |
d62a17ae | 14061 | return lcommunity_list_set_vty(vty, argc, argv, |
14062 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
14063 | } |
14064 | ||
14065 | DEFUN (ip_lcommunity_list_name_standard1, | |
14066 | ip_lcommunity_list_name_standard1_cmd, | |
14067 | "ip large-community-list standard WORD <deny|permit> AA:BB:CC...", | |
57d187bc JS |
14068 | IP_STR |
14069 | LCOMMUNITY_LIST_STR | |
14070 | "Specify standard large-community-list\n" | |
14071 | "Large Community list name\n" | |
14072 | "Specify large community to reject\n" | |
14073 | "Specify large community to accept\n" | |
14074 | LCOMMUNITY_VAL_STR) | |
14075 | { | |
d62a17ae | 14076 | return lcommunity_list_set_vty(vty, argc, argv, |
14077 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
57d187bc JS |
14078 | } |
14079 | ||
14080 | DEFUN (ip_lcommunity_list_name_expanded, | |
14081 | ip_lcommunity_list_name_expanded_cmd, | |
14082 | "ip large-community-list expanded WORD <deny|permit> LINE...", | |
14083 | IP_STR | |
14084 | LCOMMUNITY_LIST_STR | |
14085 | "Specify expanded large-community-list\n" | |
14086 | "Large Community list name\n" | |
14087 | "Specify large community to reject\n" | |
14088 | "Specify large community to accept\n" | |
14089 | "An ordered list as a regular-expression\n") | |
14090 | { | |
d62a17ae | 14091 | return lcommunity_list_set_vty(vty, argc, argv, |
14092 | LARGE_COMMUNITY_LIST_EXPANDED, 1); | |
57d187bc JS |
14093 | } |
14094 | ||
14095 | DEFUN (no_ip_lcommunity_list_standard_all, | |
14096 | no_ip_lcommunity_list_standard_all_cmd, | |
14097 | "no ip large-community-list <(1-99)|(100-500)|WORD>", | |
14098 | NO_STR | |
14099 | IP_STR | |
14100 | LCOMMUNITY_LIST_STR | |
14101 | "Large Community list number (standard)\n" | |
14102 | "Large Community list number (expanded)\n" | |
14103 | "Large Community list name\n") | |
14104 | { | |
d62a17ae | 14105 | return lcommunity_list_unset_vty(vty, argc, argv, |
14106 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
14107 | } |
14108 | ||
14109 | DEFUN (no_ip_lcommunity_list_name_expanded_all, | |
14110 | no_ip_lcommunity_list_name_expanded_all_cmd, | |
14111 | "no ip large-community-list expanded WORD", | |
14112 | NO_STR | |
14113 | IP_STR | |
14114 | LCOMMUNITY_LIST_STR | |
14115 | "Specify expanded large-community-list\n" | |
14116 | "Large Community list name\n") | |
14117 | { | |
d62a17ae | 14118 | return lcommunity_list_unset_vty(vty, argc, argv, |
14119 | LARGE_COMMUNITY_LIST_EXPANDED); | |
57d187bc JS |
14120 | } |
14121 | ||
14122 | DEFUN (no_ip_lcommunity_list_standard, | |
14123 | no_ip_lcommunity_list_standard_cmd, | |
14124 | "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...", | |
14125 | NO_STR | |
14126 | IP_STR | |
14127 | LCOMMUNITY_LIST_STR | |
14128 | "Large Community list number (standard)\n" | |
14129 | "Specify large community to reject\n" | |
14130 | "Specify large community to accept\n" | |
14131 | LCOMMUNITY_VAL_STR) | |
14132 | { | |
d62a17ae | 14133 | return lcommunity_list_unset_vty(vty, argc, argv, |
14134 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
14135 | } |
14136 | ||
14137 | DEFUN (no_ip_lcommunity_list_expanded, | |
14138 | no_ip_lcommunity_list_expanded_cmd, | |
14139 | "no ip large-community-list (100-500) <deny|permit> LINE...", | |
14140 | NO_STR | |
14141 | IP_STR | |
14142 | LCOMMUNITY_LIST_STR | |
14143 | "Large Community list number (expanded)\n" | |
14144 | "Specify large community to reject\n" | |
14145 | "Specify large community to accept\n" | |
14146 | "An ordered list as a regular-expression\n") | |
14147 | { | |
d62a17ae | 14148 | return lcommunity_list_unset_vty(vty, argc, argv, |
14149 | LARGE_COMMUNITY_LIST_EXPANDED); | |
57d187bc JS |
14150 | } |
14151 | ||
14152 | DEFUN (no_ip_lcommunity_list_name_standard, | |
14153 | no_ip_lcommunity_list_name_standard_cmd, | |
14154 | "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...", | |
14155 | NO_STR | |
14156 | IP_STR | |
14157 | LCOMMUNITY_LIST_STR | |
14158 | "Specify standard large-community-list\n" | |
14159 | "Large Community list name\n" | |
14160 | "Specify large community to reject\n" | |
14161 | "Specify large community to accept\n" | |
14162 | LCOMMUNITY_VAL_STR) | |
14163 | { | |
d62a17ae | 14164 | return lcommunity_list_unset_vty(vty, argc, argv, |
14165 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
14166 | } |
14167 | ||
14168 | DEFUN (no_ip_lcommunity_list_name_expanded, | |
14169 | no_ip_lcommunity_list_name_expanded_cmd, | |
14170 | "no ip large-community-list expanded WORD <deny|permit> LINE...", | |
14171 | NO_STR | |
14172 | IP_STR | |
14173 | LCOMMUNITY_LIST_STR | |
14174 | "Specify expanded large-community-list\n" | |
14175 | "Large community list name\n" | |
14176 | "Specify large community to reject\n" | |
14177 | "Specify large community to accept\n" | |
14178 | "An ordered list as a regular-expression\n") | |
14179 | { | |
d62a17ae | 14180 | return lcommunity_list_unset_vty(vty, argc, argv, |
14181 | LARGE_COMMUNITY_LIST_EXPANDED); | |
14182 | } | |
14183 | ||
14184 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) | |
14185 | { | |
14186 | struct community_entry *entry; | |
14187 | ||
14188 | for (entry = list->head; entry; entry = entry->next) { | |
14189 | if (entry == list->head) { | |
14190 | if (all_digit(list->name)) | |
14191 | vty_out(vty, "Large community %s list %s\n", | |
14192 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
14193 | ? "standard" | |
14194 | : "(expanded) access", | |
14195 | list->name); | |
14196 | else | |
14197 | vty_out(vty, | |
14198 | "Named large community %s list %s\n", | |
14199 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
14200 | ? "standard" | |
14201 | : "expanded", | |
14202 | list->name); | |
14203 | } | |
14204 | if (entry->any) | |
14205 | vty_out(vty, " %s\n", | |
14206 | community_direct_str(entry->direct)); | |
14207 | else | |
14208 | vty_out(vty, " %s %s\n", | |
14209 | community_direct_str(entry->direct), | |
8d9b8ed9 | 14210 | community_list_config_str(entry)); |
d62a17ae | 14211 | } |
57d187bc JS |
14212 | } |
14213 | ||
14214 | DEFUN (show_ip_lcommunity_list, | |
14215 | show_ip_lcommunity_list_cmd, | |
14216 | "show ip large-community-list", | |
14217 | SHOW_STR | |
14218 | IP_STR | |
14219 | "List large-community list\n") | |
14220 | { | |
d62a17ae | 14221 | struct community_list *list; |
14222 | struct community_list_master *cm; | |
57d187bc | 14223 | |
d62a17ae | 14224 | cm = community_list_master_lookup(bgp_clist, |
14225 | LARGE_COMMUNITY_LIST_MASTER); | |
14226 | if (!cm) | |
14227 | return CMD_SUCCESS; | |
57d187bc | 14228 | |
d62a17ae | 14229 | for (list = cm->num.head; list; list = list->next) |
14230 | lcommunity_list_show(vty, list); | |
57d187bc | 14231 | |
d62a17ae | 14232 | for (list = cm->str.head; list; list = list->next) |
14233 | lcommunity_list_show(vty, list); | |
57d187bc | 14234 | |
d62a17ae | 14235 | return CMD_SUCCESS; |
57d187bc JS |
14236 | } |
14237 | ||
14238 | DEFUN (show_ip_lcommunity_list_arg, | |
14239 | show_ip_lcommunity_list_arg_cmd, | |
14240 | "show ip large-community-list <(1-500)|WORD>", | |
14241 | SHOW_STR | |
14242 | IP_STR | |
14243 | "List large-community list\n" | |
14244 | "large-community-list number\n" | |
14245 | "large-community-list name\n") | |
14246 | { | |
d62a17ae | 14247 | struct community_list *list; |
57d187bc | 14248 | |
d62a17ae | 14249 | list = community_list_lookup(bgp_clist, argv[3]->arg, |
14250 | LARGE_COMMUNITY_LIST_MASTER); | |
14251 | if (!list) { | |
14252 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
14253 | return CMD_WARNING; | |
14254 | } | |
57d187bc | 14255 | |
d62a17ae | 14256 | lcommunity_list_show(vty, list); |
57d187bc | 14257 | |
d62a17ae | 14258 | return CMD_SUCCESS; |
57d187bc JS |
14259 | } |
14260 | ||
718e3744 | 14261 | /* "extcommunity-list" keyword help string. */ |
14262 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
14263 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
14264 | ||
14265 | DEFUN (ip_extcommunity_list_standard, | |
14266 | ip_extcommunity_list_standard_cmd, | |
e961923c | 14267 | "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 14268 | IP_STR |
14269 | EXTCOMMUNITY_LIST_STR | |
14270 | "Extended Community list number (standard)\n" | |
718e3744 | 14271 | "Specify standard extcommunity-list\n" |
5bf15956 | 14272 | "Community list name\n" |
718e3744 | 14273 | "Specify community to reject\n" |
14274 | "Specify community to accept\n" | |
14275 | EXTCOMMUNITY_VAL_STR) | |
14276 | { | |
d62a17ae | 14277 | int style = EXTCOMMUNITY_LIST_STANDARD; |
14278 | int direct = 0; | |
14279 | char *cl_number_or_name = NULL; | |
42f914d4 | 14280 | |
d62a17ae | 14281 | int idx = 0; |
14282 | argv_find(argv, argc, "(1-99)", &idx); | |
14283 | argv_find(argv, argc, "WORD", &idx); | |
14284 | cl_number_or_name = argv[idx]->arg; | |
14285 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14286 | : COMMUNITY_DENY; | |
14287 | argv_find(argv, argc, "AA:NN", &idx); | |
14288 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14289 | |
d62a17ae | 14290 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
14291 | direct, style); | |
42f914d4 | 14292 | |
d62a17ae | 14293 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14294 | |
d62a17ae | 14295 | if (ret < 0) { |
14296 | community_list_perror(vty, ret); | |
14297 | return CMD_WARNING_CONFIG_FAILED; | |
14298 | } | |
42f914d4 | 14299 | |
d62a17ae | 14300 | return CMD_SUCCESS; |
718e3744 | 14301 | } |
14302 | ||
718e3744 | 14303 | DEFUN (ip_extcommunity_list_name_expanded, |
14304 | ip_extcommunity_list_name_expanded_cmd, | |
e961923c | 14305 | "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 14306 | IP_STR |
14307 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 14308 | "Extended Community list number (expanded)\n" |
718e3744 | 14309 | "Specify expanded extcommunity-list\n" |
14310 | "Extended Community list name\n" | |
14311 | "Specify community to reject\n" | |
14312 | "Specify community to accept\n" | |
14313 | "An ordered list as a regular-expression\n") | |
14314 | { | |
d62a17ae | 14315 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
14316 | int direct = 0; | |
14317 | char *cl_number_or_name = NULL; | |
42f914d4 | 14318 | |
d62a17ae | 14319 | int idx = 0; |
14320 | argv_find(argv, argc, "(100-500)", &idx); | |
14321 | argv_find(argv, argc, "WORD", &idx); | |
14322 | cl_number_or_name = argv[idx]->arg; | |
14323 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14324 | : COMMUNITY_DENY; | |
14325 | argv_find(argv, argc, "LINE", &idx); | |
14326 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14327 | |
d62a17ae | 14328 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
14329 | direct, style); | |
42f914d4 | 14330 | |
d62a17ae | 14331 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14332 | |
d62a17ae | 14333 | if (ret < 0) { |
14334 | community_list_perror(vty, ret); | |
14335 | return CMD_WARNING_CONFIG_FAILED; | |
14336 | } | |
42f914d4 | 14337 | |
d62a17ae | 14338 | return CMD_SUCCESS; |
718e3744 | 14339 | } |
14340 | ||
fee6e4e4 | 14341 | DEFUN (no_ip_extcommunity_list_standard_all, |
14342 | no_ip_extcommunity_list_standard_all_cmd, | |
e961923c | 14343 | "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
813d4307 DW |
14344 | NO_STR |
14345 | IP_STR | |
14346 | EXTCOMMUNITY_LIST_STR | |
14347 | "Extended Community list number (standard)\n" | |
718e3744 | 14348 | "Specify standard extcommunity-list\n" |
5bf15956 | 14349 | "Community list name\n" |
718e3744 | 14350 | "Specify community to reject\n" |
14351 | "Specify community to accept\n" | |
14352 | EXTCOMMUNITY_VAL_STR) | |
14353 | { | |
d62a17ae | 14354 | int style = EXTCOMMUNITY_LIST_STANDARD; |
14355 | int direct = 0; | |
14356 | char *cl_number_or_name = NULL; | |
42f914d4 | 14357 | |
d62a17ae | 14358 | int idx = 0; |
14359 | argv_find(argv, argc, "(1-99)", &idx); | |
14360 | argv_find(argv, argc, "WORD", &idx); | |
14361 | cl_number_or_name = argv[idx]->arg; | |
14362 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14363 | : COMMUNITY_DENY; | |
14364 | argv_find(argv, argc, "AA:NN", &idx); | |
14365 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14366 | |
d62a17ae | 14367 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
7298a8e1 | 14368 | direct, style); |
42f914d4 | 14369 | |
d62a17ae | 14370 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14371 | |
d62a17ae | 14372 | if (ret < 0) { |
14373 | community_list_perror(vty, ret); | |
14374 | return CMD_WARNING_CONFIG_FAILED; | |
14375 | } | |
42f914d4 | 14376 | |
d62a17ae | 14377 | return CMD_SUCCESS; |
718e3744 | 14378 | } |
14379 | ||
5bf15956 DW |
14380 | DEFUN (no_ip_extcommunity_list_expanded_all, |
14381 | no_ip_extcommunity_list_expanded_all_cmd, | |
e961923c | 14382 | "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 14383 | NO_STR |
14384 | IP_STR | |
14385 | EXTCOMMUNITY_LIST_STR | |
14386 | "Extended Community list number (expanded)\n" | |
718e3744 | 14387 | "Specify expanded extcommunity-list\n" |
5bf15956 | 14388 | "Extended Community list name\n" |
718e3744 | 14389 | "Specify community to reject\n" |
14390 | "Specify community to accept\n" | |
14391 | "An ordered list as a regular-expression\n") | |
14392 | { | |
d62a17ae | 14393 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
14394 | int direct = 0; | |
14395 | char *cl_number_or_name = NULL; | |
42f914d4 | 14396 | |
d62a17ae | 14397 | int idx = 0; |
14398 | argv_find(argv, argc, "(100-500)", &idx); | |
14399 | argv_find(argv, argc, "WORD", &idx); | |
14400 | cl_number_or_name = argv[idx]->arg; | |
14401 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14402 | : COMMUNITY_DENY; | |
14403 | argv_find(argv, argc, "LINE", &idx); | |
14404 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14405 | |
d62a17ae | 14406 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
7298a8e1 | 14407 | direct, style); |
42f914d4 | 14408 | |
d62a17ae | 14409 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14410 | |
d62a17ae | 14411 | if (ret < 0) { |
14412 | community_list_perror(vty, ret); | |
14413 | return CMD_WARNING_CONFIG_FAILED; | |
14414 | } | |
42f914d4 | 14415 | |
d62a17ae | 14416 | return CMD_SUCCESS; |
718e3744 | 14417 | } |
14418 | ||
d62a17ae | 14419 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 14420 | { |
d62a17ae | 14421 | struct community_entry *entry; |
718e3744 | 14422 | |
d62a17ae | 14423 | for (entry = list->head; entry; entry = entry->next) { |
14424 | if (entry == list->head) { | |
14425 | if (all_digit(list->name)) | |
14426 | vty_out(vty, "Extended community %s list %s\n", | |
14427 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
14428 | ? "standard" | |
14429 | : "(expanded) access", | |
14430 | list->name); | |
14431 | else | |
14432 | vty_out(vty, | |
14433 | "Named extended community %s list %s\n", | |
14434 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
14435 | ? "standard" | |
14436 | : "expanded", | |
14437 | list->name); | |
14438 | } | |
14439 | if (entry->any) | |
14440 | vty_out(vty, " %s\n", | |
14441 | community_direct_str(entry->direct)); | |
14442 | else | |
14443 | vty_out(vty, " %s %s\n", | |
14444 | community_direct_str(entry->direct), | |
8d9b8ed9 | 14445 | community_list_config_str(entry)); |
d62a17ae | 14446 | } |
718e3744 | 14447 | } |
14448 | ||
14449 | DEFUN (show_ip_extcommunity_list, | |
14450 | show_ip_extcommunity_list_cmd, | |
14451 | "show ip extcommunity-list", | |
14452 | SHOW_STR | |
14453 | IP_STR | |
14454 | "List extended-community list\n") | |
14455 | { | |
d62a17ae | 14456 | struct community_list *list; |
14457 | struct community_list_master *cm; | |
718e3744 | 14458 | |
d62a17ae | 14459 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
14460 | if (!cm) | |
14461 | return CMD_SUCCESS; | |
718e3744 | 14462 | |
d62a17ae | 14463 | for (list = cm->num.head; list; list = list->next) |
14464 | extcommunity_list_show(vty, list); | |
718e3744 | 14465 | |
d62a17ae | 14466 | for (list = cm->str.head; list; list = list->next) |
14467 | extcommunity_list_show(vty, list); | |
718e3744 | 14468 | |
d62a17ae | 14469 | return CMD_SUCCESS; |
718e3744 | 14470 | } |
14471 | ||
14472 | DEFUN (show_ip_extcommunity_list_arg, | |
14473 | show_ip_extcommunity_list_arg_cmd, | |
6147e2c6 | 14474 | "show ip extcommunity-list <(1-500)|WORD>", |
718e3744 | 14475 | SHOW_STR |
14476 | IP_STR | |
14477 | "List extended-community list\n" | |
14478 | "Extcommunity-list number\n" | |
14479 | "Extcommunity-list name\n") | |
14480 | { | |
d62a17ae | 14481 | int idx_comm_list = 3; |
14482 | struct community_list *list; | |
718e3744 | 14483 | |
d62a17ae | 14484 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, |
14485 | EXTCOMMUNITY_LIST_MASTER); | |
14486 | if (!list) { | |
14487 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
14488 | return CMD_WARNING; | |
14489 | } | |
718e3744 | 14490 | |
d62a17ae | 14491 | extcommunity_list_show(vty, list); |
718e3744 | 14492 | |
d62a17ae | 14493 | return CMD_SUCCESS; |
718e3744 | 14494 | } |
6b0655a2 | 14495 | |
718e3744 | 14496 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 14497 | static int community_list_config_write(struct vty *vty) |
14498 | { | |
14499 | struct community_list *list; | |
14500 | struct community_entry *entry; | |
14501 | struct community_list_master *cm; | |
14502 | int write = 0; | |
14503 | ||
14504 | /* Community-list. */ | |
14505 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
14506 | ||
14507 | for (list = cm->num.head; list; list = list->next) | |
14508 | for (entry = list->head; entry; entry = entry->next) { | |
14509 | vty_out(vty, "ip community-list %s %s %s\n", list->name, | |
14510 | community_direct_str(entry->direct), | |
14511 | community_list_config_str(entry)); | |
14512 | write++; | |
14513 | } | |
14514 | for (list = cm->str.head; list; list = list->next) | |
14515 | for (entry = list->head; entry; entry = entry->next) { | |
14516 | vty_out(vty, "ip community-list %s %s %s %s\n", | |
14517 | entry->style == COMMUNITY_LIST_STANDARD | |
14518 | ? "standard" | |
14519 | : "expanded", | |
14520 | list->name, community_direct_str(entry->direct), | |
14521 | community_list_config_str(entry)); | |
14522 | write++; | |
14523 | } | |
14524 | ||
14525 | /* Extcommunity-list. */ | |
14526 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
14527 | ||
14528 | for (list = cm->num.head; list; list = list->next) | |
14529 | for (entry = list->head; entry; entry = entry->next) { | |
14530 | vty_out(vty, "ip extcommunity-list %s %s %s\n", | |
14531 | list->name, community_direct_str(entry->direct), | |
14532 | community_list_config_str(entry)); | |
14533 | write++; | |
14534 | } | |
14535 | for (list = cm->str.head; list; list = list->next) | |
14536 | for (entry = list->head; entry; entry = entry->next) { | |
14537 | vty_out(vty, "ip extcommunity-list %s %s %s %s\n", | |
14538 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
14539 | ? "standard" | |
14540 | : "expanded", | |
14541 | list->name, community_direct_str(entry->direct), | |
14542 | community_list_config_str(entry)); | |
14543 | write++; | |
14544 | } | |
14545 | ||
14546 | ||
14547 | /* lcommunity-list. */ | |
14548 | cm = community_list_master_lookup(bgp_clist, | |
14549 | LARGE_COMMUNITY_LIST_MASTER); | |
14550 | ||
14551 | for (list = cm->num.head; list; list = list->next) | |
14552 | for (entry = list->head; entry; entry = entry->next) { | |
14553 | vty_out(vty, "ip large-community-list %s %s %s\n", | |
14554 | list->name, community_direct_str(entry->direct), | |
14555 | community_list_config_str(entry)); | |
14556 | write++; | |
14557 | } | |
14558 | for (list = cm->str.head; list; list = list->next) | |
14559 | for (entry = list->head; entry; entry = entry->next) { | |
14560 | vty_out(vty, "ip large-community-list %s %s %s %s\n", | |
14561 | entry->style == LARGE_COMMUNITY_LIST_STANDARD | |
14562 | ? "standard" | |
14563 | : "expanded", | |
14564 | list->name, community_direct_str(entry->direct), | |
14565 | community_list_config_str(entry)); | |
14566 | write++; | |
14567 | } | |
14568 | ||
14569 | return write; | |
14570 | } | |
14571 | ||
14572 | static struct cmd_node community_list_node = { | |
14573 | COMMUNITY_LIST_NODE, "", 1 /* Export to vtysh. */ | |
718e3744 | 14574 | }; |
14575 | ||
d62a17ae | 14576 | static void community_list_vty(void) |
14577 | { | |
14578 | install_node(&community_list_node, community_list_config_write); | |
14579 | ||
14580 | /* Community-list. */ | |
14581 | install_element(CONFIG_NODE, &ip_community_list_standard_cmd); | |
14582 | install_element(CONFIG_NODE, &ip_community_list_expanded_all_cmd); | |
14583 | install_element(CONFIG_NODE, &no_ip_community_list_standard_all_cmd); | |
14584 | install_element(CONFIG_NODE, &no_ip_community_list_expanded_all_cmd); | |
14585 | install_element(VIEW_NODE, &show_ip_community_list_cmd); | |
14586 | install_element(VIEW_NODE, &show_ip_community_list_arg_cmd); | |
14587 | ||
14588 | /* Extcommunity-list. */ | |
14589 | install_element(CONFIG_NODE, &ip_extcommunity_list_standard_cmd); | |
14590 | install_element(CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd); | |
14591 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd); | |
14592 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd); | |
14593 | install_element(VIEW_NODE, &show_ip_extcommunity_list_cmd); | |
14594 | install_element(VIEW_NODE, &show_ip_extcommunity_list_arg_cmd); | |
14595 | ||
14596 | /* Large Community List */ | |
14597 | install_element(CONFIG_NODE, &ip_lcommunity_list_standard_cmd); | |
14598 | install_element(CONFIG_NODE, &ip_lcommunity_list_standard1_cmd); | |
14599 | install_element(CONFIG_NODE, &ip_lcommunity_list_expanded_cmd); | |
14600 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_standard_cmd); | |
14601 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_standard1_cmd); | |
14602 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_expanded_cmd); | |
14603 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_standard_all_cmd); | |
14604 | install_element(CONFIG_NODE, | |
14605 | &no_ip_lcommunity_list_name_expanded_all_cmd); | |
14606 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_standard_cmd); | |
14607 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_expanded_cmd); | |
14608 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_name_standard_cmd); | |
14609 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_cmd); | |
14610 | install_element(VIEW_NODE, &show_ip_lcommunity_list_cmd); | |
14611 | install_element(VIEW_NODE, &show_ip_lcommunity_list_arg_cmd); | |
5bf15956 | 14612 | } |