]>
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" |
e0701b79 | 48 | #include "bgpd/bgp_fsm.h" |
4bf6a362 | 49 | #include "bgpd/bgp_nexthop.h" |
718e3744 | 50 | #include "bgpd/bgp_open.h" |
4bf6a362 | 51 | #include "bgpd/bgp_regex.h" |
718e3744 | 52 | #include "bgpd/bgp_route.h" |
c016b6c7 | 53 | #include "bgpd/bgp_mplsvpn.h" |
718e3744 | 54 | #include "bgpd/bgp_zebra.h" |
fee0f4c6 | 55 | #include "bgpd/bgp_table.h" |
94f2b392 | 56 | #include "bgpd/bgp_vty.h" |
165b5fff | 57 | #include "bgpd/bgp_mpath.h" |
cb1faec9 | 58 | #include "bgpd/bgp_packet.h" |
3f9c7369 | 59 | #include "bgpd/bgp_updgrp.h" |
c43ed2e4 | 60 | #include "bgpd/bgp_bfd.h" |
555e09d4 | 61 | #include "bgpd/bgp_io.h" |
94c2f693 | 62 | #include "bgpd/bgp_evpn.h" |
718e3744 | 63 | |
d62a17ae | 64 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
65 | struct prefix *range, int exact); | |
66 | ||
67 | static enum node_type bgp_node_type(afi_t afi, safi_t safi) | |
68 | { | |
69 | switch (afi) { | |
70 | case AFI_IP: | |
71 | switch (safi) { | |
72 | case SAFI_UNICAST: | |
73 | return BGP_IPV4_NODE; | |
74 | break; | |
75 | case SAFI_MULTICAST: | |
76 | return BGP_IPV4M_NODE; | |
77 | break; | |
78 | case SAFI_LABELED_UNICAST: | |
79 | return BGP_IPV4L_NODE; | |
80 | break; | |
81 | case SAFI_MPLS_VPN: | |
82 | return BGP_VPNV4_NODE; | |
83 | break; | |
7c40bf39 | 84 | case SAFI_FLOWSPEC: |
85 | return BGP_FLOWSPECV4_NODE; | |
5c525538 RW |
86 | default: |
87 | /* not expected */ | |
88 | return BGP_IPV4_NODE; | |
89 | break; | |
d62a17ae | 90 | } |
91 | break; | |
92 | case AFI_IP6: | |
93 | switch (safi) { | |
94 | case SAFI_UNICAST: | |
95 | return BGP_IPV6_NODE; | |
96 | break; | |
97 | case SAFI_MULTICAST: | |
98 | return BGP_IPV6M_NODE; | |
99 | break; | |
100 | case SAFI_LABELED_UNICAST: | |
101 | return BGP_IPV6L_NODE; | |
102 | break; | |
103 | case SAFI_MPLS_VPN: | |
104 | return BGP_VPNV6_NODE; | |
105 | break; | |
7c40bf39 | 106 | case SAFI_FLOWSPEC: |
107 | return BGP_FLOWSPECV6_NODE; | |
5c525538 RW |
108 | default: |
109 | /* not expected */ | |
110 | return BGP_IPV4_NODE; | |
111 | break; | |
d62a17ae | 112 | } |
113 | break; | |
114 | case AFI_L2VPN: | |
115 | return BGP_EVPN_NODE; | |
116 | break; | |
117 | case AFI_MAX: | |
118 | // We should never be here but to clarify the switch statement.. | |
119 | return BGP_IPV4_NODE; | |
120 | break; | |
121 | } | |
122 | ||
123 | // Impossible to happen | |
124 | return BGP_IPV4_NODE; | |
f51bae9c | 125 | } |
20eb8864 | 126 | |
718e3744 | 127 | /* Utility function to get address family from current node. */ |
d62a17ae | 128 | afi_t bgp_node_afi(struct vty *vty) |
129 | { | |
130 | afi_t afi; | |
131 | switch (vty->node) { | |
132 | case BGP_IPV6_NODE: | |
133 | case BGP_IPV6M_NODE: | |
134 | case BGP_IPV6L_NODE: | |
135 | case BGP_VPNV6_NODE: | |
7c40bf39 | 136 | case BGP_FLOWSPECV6_NODE: |
d62a17ae | 137 | afi = AFI_IP6; |
138 | break; | |
139 | case BGP_EVPN_NODE: | |
140 | afi = AFI_L2VPN; | |
141 | break; | |
142 | default: | |
143 | afi = AFI_IP; | |
144 | break; | |
145 | } | |
146 | return afi; | |
718e3744 | 147 | } |
148 | ||
149 | /* Utility function to get subsequent address family from current | |
150 | node. */ | |
d62a17ae | 151 | safi_t bgp_node_safi(struct vty *vty) |
152 | { | |
153 | safi_t safi; | |
154 | switch (vty->node) { | |
155 | case BGP_VPNV4_NODE: | |
156 | case BGP_VPNV6_NODE: | |
157 | safi = SAFI_MPLS_VPN; | |
158 | break; | |
159 | case BGP_IPV4M_NODE: | |
160 | case BGP_IPV6M_NODE: | |
161 | safi = SAFI_MULTICAST; | |
162 | break; | |
163 | case BGP_EVPN_NODE: | |
164 | safi = SAFI_EVPN; | |
165 | break; | |
166 | case BGP_IPV4L_NODE: | |
167 | case BGP_IPV6L_NODE: | |
168 | safi = SAFI_LABELED_UNICAST; | |
169 | break; | |
7c40bf39 | 170 | case BGP_FLOWSPECV4_NODE: |
171 | case BGP_FLOWSPECV6_NODE: | |
172 | safi = SAFI_FLOWSPEC; | |
173 | break; | |
d62a17ae | 174 | default: |
175 | safi = SAFI_UNICAST; | |
176 | break; | |
177 | } | |
178 | return safi; | |
718e3744 | 179 | } |
180 | ||
55f91488 QY |
181 | /** |
182 | * Converts an AFI in string form to afi_t | |
183 | * | |
184 | * @param afi string, one of | |
185 | * - "ipv4" | |
186 | * - "ipv6" | |
81cf0de5 | 187 | * - "l2vpn" |
55f91488 QY |
188 | * @return the corresponding afi_t |
189 | */ | |
d62a17ae | 190 | afi_t bgp_vty_afi_from_str(const char *afi_str) |
191 | { | |
192 | afi_t afi = AFI_MAX; /* unknown */ | |
193 | if (strmatch(afi_str, "ipv4")) | |
194 | afi = AFI_IP; | |
195 | else if (strmatch(afi_str, "ipv6")) | |
196 | afi = AFI_IP6; | |
81cf0de5 CS |
197 | else if (strmatch(afi_str, "l2vpn")) |
198 | afi = AFI_L2VPN; | |
d62a17ae | 199 | return afi; |
200 | } | |
201 | ||
202 | int argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, | |
203 | afi_t *afi) | |
204 | { | |
205 | int ret = 0; | |
206 | if (argv_find(argv, argc, "ipv4", index)) { | |
207 | ret = 1; | |
208 | if (afi) | |
209 | *afi = AFI_IP; | |
210 | } else if (argv_find(argv, argc, "ipv6", index)) { | |
211 | ret = 1; | |
212 | if (afi) | |
213 | *afi = AFI_IP6; | |
214 | } | |
215 | return ret; | |
46f296b4 LB |
216 | } |
217 | ||
375a2e67 | 218 | /* supports <unicast|multicast|vpn|labeled-unicast> */ |
d62a17ae | 219 | safi_t bgp_vty_safi_from_str(const char *safi_str) |
220 | { | |
221 | safi_t safi = SAFI_MAX; /* unknown */ | |
222 | if (strmatch(safi_str, "multicast")) | |
223 | safi = SAFI_MULTICAST; | |
224 | else if (strmatch(safi_str, "unicast")) | |
225 | safi = SAFI_UNICAST; | |
226 | else if (strmatch(safi_str, "vpn")) | |
227 | safi = SAFI_MPLS_VPN; | |
81cf0de5 CS |
228 | else if (strmatch(safi_str, "evpn")) |
229 | safi = SAFI_EVPN; | |
d62a17ae | 230 | else if (strmatch(safi_str, "labeled-unicast")) |
231 | safi = SAFI_LABELED_UNICAST; | |
7c40bf39 | 232 | else if (strmatch(safi_str, "flowspec")) |
233 | safi = SAFI_FLOWSPEC; | |
d62a17ae | 234 | return safi; |
235 | } | |
236 | ||
237 | int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, | |
238 | safi_t *safi) | |
239 | { | |
240 | int ret = 0; | |
241 | if (argv_find(argv, argc, "unicast", index)) { | |
242 | ret = 1; | |
243 | if (safi) | |
244 | *safi = SAFI_UNICAST; | |
245 | } else if (argv_find(argv, argc, "multicast", index)) { | |
246 | ret = 1; | |
247 | if (safi) | |
248 | *safi = SAFI_MULTICAST; | |
249 | } else if (argv_find(argv, argc, "labeled-unicast", index)) { | |
250 | ret = 1; | |
251 | if (safi) | |
252 | *safi = SAFI_LABELED_UNICAST; | |
253 | } else if (argv_find(argv, argc, "vpn", index)) { | |
254 | ret = 1; | |
255 | if (safi) | |
256 | *safi = SAFI_MPLS_VPN; | |
7c40bf39 | 257 | } else if (argv_find(argv, argc, "flowspec", index)) { |
258 | ret = 1; | |
259 | if (safi) | |
260 | *safi = SAFI_FLOWSPEC; | |
d62a17ae | 261 | } |
262 | return ret; | |
46f296b4 LB |
263 | } |
264 | ||
7eeee51e | 265 | /* |
f212a857 | 266 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 267 | * |
f212a857 DS |
268 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
269 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
270 | * to appropriate values for the calling function. This is to allow the |
271 | * calling function to make decisions appropriate for the show command | |
272 | * that is being parsed. | |
273 | * | |
274 | * The show commands are generally of the form: | |
d62a17ae | 275 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> |
276 | * [<unicast|multicast|vpn|labeled-unicast>]] ..." | |
7eeee51e DS |
277 | * |
278 | * Since we use argv_find if the show command in particular doesn't have: | |
279 | * [ip] | |
18c57037 | 280 | * [<view|vrf> VIEWVRFNAME] |
375a2e67 | 281 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] |
7eeee51e DS |
282 | * The command parsing should still be ok. |
283 | * | |
284 | * vty -> The vty for the command so we can output some useful data in | |
285 | * the event of a parse error in the vrf. | |
286 | * argv -> The command tokens | |
287 | * argc -> How many command tokens we have | |
d62a17ae | 288 | * idx -> The current place in the command, generally should be 0 for this |
289 | * function | |
7eeee51e DS |
290 | * afi -> The parsed afi if it was included in the show command, returned here |
291 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 292 | * bgp -> Pointer to the bgp data structure we need to fill in. |
7eeee51e DS |
293 | * |
294 | * The function returns the correct location in the parse tree for the | |
295 | * last token found. | |
0e37c258 DS |
296 | * |
297 | * Returns 0 for failure to parse correctly, else the idx position of where | |
298 | * it found the last token. | |
7eeee51e | 299 | */ |
d62a17ae | 300 | int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, |
301 | struct cmd_token **argv, int argc, | |
302 | int *idx, afi_t *afi, safi_t *safi, | |
303 | struct bgp **bgp) | |
304 | { | |
305 | char *vrf_name = NULL; | |
306 | ||
307 | assert(afi); | |
308 | assert(safi); | |
309 | assert(bgp); | |
310 | ||
311 | if (argv_find(argv, argc, "ip", idx)) | |
312 | *afi = AFI_IP; | |
313 | ||
314 | if (argv_find(argv, argc, "view", idx) | |
315 | || argv_find(argv, argc, "vrf", idx)) { | |
316 | vrf_name = argv[*idx + 1]->arg; | |
317 | ||
318 | if (strmatch(vrf_name, "all")) | |
319 | *bgp = NULL; | |
320 | else { | |
321 | *bgp = bgp_lookup_by_name(vrf_name); | |
322 | if (!*bgp) { | |
323 | vty_out(vty, | |
324 | "View/Vrf specified is unknown: %s\n", | |
325 | vrf_name); | |
326 | *idx = 0; | |
327 | return 0; | |
328 | } | |
329 | } | |
330 | } else { | |
331 | *bgp = bgp_get_default(); | |
332 | if (!*bgp) { | |
333 | vty_out(vty, "Unable to find default BGP instance\n"); | |
334 | *idx = 0; | |
335 | return 0; | |
336 | } | |
337 | } | |
338 | ||
339 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
340 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
341 | ||
342 | *idx += 1; | |
343 | return *idx; | |
344 | } | |
345 | ||
346 | static int peer_address_self_check(struct bgp *bgp, union sockunion *su) | |
347 | { | |
348 | struct interface *ifp = NULL; | |
349 | ||
350 | if (su->sa.sa_family == AF_INET) | |
351 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); | |
352 | else if (su->sa.sa_family == AF_INET6) | |
353 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, | |
354 | su->sin6.sin6_scope_id, | |
355 | bgp->vrf_id); | |
356 | ||
357 | if (ifp) | |
358 | return 1; | |
359 | ||
360 | return 0; | |
718e3744 | 361 | } |
362 | ||
363 | /* Utility function for looking up peer from VTY. */ | |
f14e6fdb DS |
364 | /* This is used only for configuration, so disallow if attempted on |
365 | * a dynamic neighbor. | |
366 | */ | |
d62a17ae | 367 | static struct peer *peer_lookup_vty(struct vty *vty, const char *ip_str) |
368 | { | |
369 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
370 | int ret; | |
371 | union sockunion su; | |
372 | struct peer *peer; | |
373 | ||
374 | if (!bgp) { | |
375 | return NULL; | |
376 | } | |
377 | ||
378 | ret = str2sockunion(ip_str, &su); | |
379 | if (ret < 0) { | |
380 | peer = peer_lookup_by_conf_if(bgp, ip_str); | |
381 | if (!peer) { | |
382 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) | |
383 | == NULL) { | |
384 | vty_out(vty, | |
385 | "%% Malformed address or name: %s\n", | |
386 | ip_str); | |
387 | return NULL; | |
388 | } | |
389 | } | |
390 | } else { | |
391 | peer = peer_lookup(bgp, &su); | |
392 | if (!peer) { | |
393 | vty_out(vty, | |
394 | "%% Specify remote-as or peer-group commands first\n"); | |
395 | return NULL; | |
396 | } | |
397 | if (peer_dynamic_neighbor(peer)) { | |
398 | vty_out(vty, | |
399 | "%% Operation not allowed on a dynamic neighbor\n"); | |
400 | return NULL; | |
401 | } | |
402 | } | |
403 | return peer; | |
718e3744 | 404 | } |
405 | ||
406 | /* Utility function for looking up peer or peer group. */ | |
f14e6fdb DS |
407 | /* This is used only for configuration, so disallow if attempted on |
408 | * a dynamic neighbor. | |
409 | */ | |
d62a17ae | 410 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) |
411 | { | |
412 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
413 | int ret; | |
414 | union sockunion su; | |
415 | struct peer *peer = NULL; | |
416 | struct peer_group *group = NULL; | |
417 | ||
418 | if (!bgp) { | |
419 | return NULL; | |
420 | } | |
421 | ||
422 | ret = str2sockunion(peer_str, &su); | |
423 | if (ret == 0) { | |
424 | /* IP address, locate peer. */ | |
425 | peer = peer_lookup(bgp, &su); | |
426 | } else { | |
427 | /* Not IP, could match either peer configured on interface or a | |
428 | * group. */ | |
429 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
430 | if (!peer) | |
431 | group = peer_group_lookup(bgp, peer_str); | |
432 | } | |
433 | ||
434 | if (peer) { | |
435 | if (peer_dynamic_neighbor(peer)) { | |
436 | vty_out(vty, | |
437 | "%% Operation not allowed on a dynamic neighbor\n"); | |
438 | return NULL; | |
439 | } | |
440 | ||
441 | return peer; | |
442 | } | |
443 | ||
444 | if (group) | |
445 | return group->conf; | |
446 | ||
447 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); | |
448 | ||
449 | return NULL; | |
450 | } | |
451 | ||
452 | int bgp_vty_return(struct vty *vty, int ret) | |
453 | { | |
454 | const char *str = NULL; | |
455 | ||
456 | switch (ret) { | |
457 | case BGP_ERR_INVALID_VALUE: | |
458 | str = "Invalid value"; | |
459 | break; | |
460 | case BGP_ERR_INVALID_FLAG: | |
461 | str = "Invalid flag"; | |
462 | break; | |
463 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
464 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
465 | break; | |
466 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
467 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
468 | break; | |
469 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
470 | str = "Specify remote-as or peer-group remote AS first"; | |
471 | break; | |
472 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
473 | str = "Cannot change the peer-group. Deconfigure first"; | |
474 | break; | |
475 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
476 | str = "Peer is not a member of this peer-group"; | |
477 | break; | |
478 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
479 | str = "Prefix/distribute list can not co-exist"; | |
480 | break; | |
481 | case BGP_ERR_NOT_INTERNAL_PEER: | |
482 | str = "Invalid command. Not an internal neighbor"; | |
483 | break; | |
484 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
485 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
486 | break; | |
487 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
488 | str = "Local-AS allowed only for EBGP peers"; | |
489 | break; | |
490 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
491 | str = "Cannot have local-as same as BGP AS number"; | |
492 | break; | |
493 | case BGP_ERR_TCPSIG_FAILED: | |
494 | str = "Error while applying TCP-Sig to session(s)"; | |
495 | break; | |
496 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
497 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
498 | break; | |
499 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
500 | str = "ttl-security only allowed for EBGP peers"; | |
501 | break; | |
502 | case BGP_ERR_AS_OVERRIDE: | |
503 | str = "as-override cannot be configured for IBGP peers"; | |
504 | break; | |
505 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
506 | str = "Invalid limit for number of dynamic neighbors"; | |
507 | break; | |
508 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
509 | str = "Dynamic neighbor listen range already exists"; | |
510 | break; | |
511 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
512 | str = "Operation not allowed on a dynamic neighbor"; | |
513 | break; | |
514 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
515 | str = "Operation not allowed on a directly connected neighbor"; | |
516 | break; | |
517 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
518 | str = "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'"; | |
519 | break; | |
520 | } | |
521 | if (str) { | |
522 | vty_out(vty, "%% %s\n", str); | |
523 | return CMD_WARNING_CONFIG_FAILED; | |
524 | } | |
525 | return CMD_SUCCESS; | |
718e3744 | 526 | } |
527 | ||
7aafcaca | 528 | /* BGP clear sort. */ |
d62a17ae | 529 | enum clear_sort { |
530 | clear_all, | |
531 | clear_peer, | |
532 | clear_group, | |
533 | clear_external, | |
534 | clear_as | |
7aafcaca DS |
535 | }; |
536 | ||
d62a17ae | 537 | static void bgp_clear_vty_error(struct vty *vty, struct peer *peer, afi_t afi, |
538 | safi_t safi, int error) | |
539 | { | |
540 | switch (error) { | |
541 | case BGP_ERR_AF_UNCONFIGURED: | |
542 | vty_out(vty, | |
543 | "%%BGP: Enable %s address family for the neighbor %s\n", | |
544 | afi_safi_print(afi, safi), peer->host); | |
545 | break; | |
546 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
547 | vty_out(vty, | |
548 | "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n", | |
549 | peer->host); | |
550 | break; | |
551 | default: | |
552 | break; | |
553 | } | |
7aafcaca DS |
554 | } |
555 | ||
556 | /* `clear ip bgp' functions. */ | |
d62a17ae | 557 | static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
558 | enum clear_sort sort, enum bgp_clear_type stype, | |
559 | const char *arg) | |
560 | { | |
561 | int ret; | |
3ae8bfa5 | 562 | bool found = false; |
d62a17ae | 563 | struct peer *peer; |
564 | struct listnode *node, *nnode; | |
565 | ||
566 | /* Clear all neighbors. */ | |
567 | /* | |
568 | * Pass along pointer to next node to peer_clear() when walking all | |
3ae8bfa5 PM |
569 | * nodes on the BGP instance as that may get freed if it is a |
570 | * doppelganger | |
d62a17ae | 571 | */ |
572 | if (sort == clear_all) { | |
573 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
3ae8bfa5 PM |
574 | if (!peer->afc[afi][safi]) |
575 | continue; | |
576 | ||
d62a17ae | 577 | if (stype == BGP_CLEAR_SOFT_NONE) |
578 | ret = peer_clear(peer, &nnode); | |
d62a17ae | 579 | else |
3ae8bfa5 | 580 | ret = peer_clear_soft(peer, afi, safi, stype); |
d62a17ae | 581 | |
582 | if (ret < 0) | |
583 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
584 | else |
585 | found = true; | |
04b6bdc0 | 586 | } |
d62a17ae | 587 | |
588 | /* This is to apply read-only mode on this clear. */ | |
589 | if (stype == BGP_CLEAR_SOFT_NONE) | |
590 | bgp->update_delay_over = 0; | |
591 | ||
3ae8bfa5 PM |
592 | if (!found) |
593 | vty_out(vty, "%%BGP: No %s peer configured", | |
594 | afi_safi_print(afi, safi)); | |
595 | ||
d62a17ae | 596 | return CMD_SUCCESS; |
7aafcaca DS |
597 | } |
598 | ||
3ae8bfa5 | 599 | /* Clear specified neighbor. */ |
d62a17ae | 600 | if (sort == clear_peer) { |
601 | union sockunion su; | |
d62a17ae | 602 | |
603 | /* Make sockunion for lookup. */ | |
604 | ret = str2sockunion(arg, &su); | |
605 | if (ret < 0) { | |
606 | peer = peer_lookup_by_conf_if(bgp, arg); | |
607 | if (!peer) { | |
608 | peer = peer_lookup_by_hostname(bgp, arg); | |
609 | if (!peer) { | |
610 | vty_out(vty, | |
611 | "Malformed address or name: %s\n", | |
612 | arg); | |
613 | return CMD_WARNING; | |
614 | } | |
615 | } | |
616 | } else { | |
617 | peer = peer_lookup(bgp, &su); | |
618 | if (!peer) { | |
619 | vty_out(vty, | |
620 | "%%BGP: Unknown neighbor - \"%s\"\n", | |
621 | arg); | |
622 | return CMD_WARNING; | |
623 | } | |
624 | } | |
7aafcaca | 625 | |
3ae8bfa5 PM |
626 | if (!peer->afc[afi][safi]) |
627 | ret = BGP_ERR_AF_UNCONFIGURED; | |
628 | else if (stype == BGP_CLEAR_SOFT_NONE) | |
d62a17ae | 629 | ret = peer_clear(peer, NULL); |
630 | else | |
631 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 632 | |
d62a17ae | 633 | if (ret < 0) |
634 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
7aafcaca | 635 | |
d62a17ae | 636 | return CMD_SUCCESS; |
7aafcaca | 637 | } |
7aafcaca | 638 | |
3ae8bfa5 | 639 | /* Clear all neighbors belonging to a specific peer-group. */ |
d62a17ae | 640 | if (sort == clear_group) { |
641 | struct peer_group *group; | |
7aafcaca | 642 | |
d62a17ae | 643 | group = peer_group_lookup(bgp, arg); |
644 | if (!group) { | |
645 | vty_out(vty, "%%BGP: No such peer-group %s\n", arg); | |
646 | return CMD_WARNING; | |
647 | } | |
648 | ||
649 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
d62a17ae | 650 | if (!peer->afc[afi][safi]) |
651 | continue; | |
652 | ||
3ae8bfa5 PM |
653 | if (stype == BGP_CLEAR_SOFT_NONE) |
654 | ret = peer_clear(peer, NULL); | |
655 | else | |
656 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 657 | |
d62a17ae | 658 | if (ret < 0) |
659 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
660 | else |
661 | found = true; | |
d62a17ae | 662 | } |
3ae8bfa5 PM |
663 | |
664 | if (!found) | |
665 | vty_out(vty, | |
666 | "%%BGP: No %s peer belonging to peer-group %s is configured\n", | |
667 | afi_safi_print(afi, safi), arg); | |
668 | ||
d62a17ae | 669 | return CMD_SUCCESS; |
7aafcaca | 670 | } |
7aafcaca | 671 | |
3ae8bfa5 | 672 | /* Clear all external (eBGP) neighbors. */ |
d62a17ae | 673 | if (sort == clear_external) { |
674 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
675 | if (peer->sort == BGP_PEER_IBGP) | |
676 | continue; | |
7aafcaca | 677 | |
3ae8bfa5 PM |
678 | if (!peer->afc[afi][safi]) |
679 | continue; | |
680 | ||
d62a17ae | 681 | if (stype == BGP_CLEAR_SOFT_NONE) |
682 | ret = peer_clear(peer, &nnode); | |
683 | else | |
684 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 685 | |
d62a17ae | 686 | if (ret < 0) |
687 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
688 | else |
689 | found = true; | |
d62a17ae | 690 | } |
3ae8bfa5 PM |
691 | |
692 | if (!found) | |
693 | vty_out(vty, | |
694 | "%%BGP: No external %s peer is configured\n", | |
695 | afi_safi_print(afi, safi)); | |
696 | ||
d62a17ae | 697 | return CMD_SUCCESS; |
698 | } | |
699 | ||
3ae8bfa5 | 700 | /* Clear all neighbors belonging to a specific AS. */ |
d62a17ae | 701 | if (sort == clear_as) { |
3ae8bfa5 | 702 | as_t as = strtoul(arg, NULL, 10); |
d62a17ae | 703 | |
704 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
705 | if (peer->as != as) | |
706 | continue; | |
707 | ||
3ae8bfa5 PM |
708 | if (!peer->afc[afi][safi]) |
709 | ret = BGP_ERR_AF_UNCONFIGURED; | |
710 | else if (stype == BGP_CLEAR_SOFT_NONE) | |
d62a17ae | 711 | ret = peer_clear(peer, &nnode); |
712 | else | |
713 | ret = peer_clear_soft(peer, afi, safi, stype); | |
714 | ||
715 | if (ret < 0) | |
716 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
717 | else |
718 | found = true; | |
d62a17ae | 719 | } |
3ae8bfa5 PM |
720 | |
721 | if (!found) | |
d62a17ae | 722 | vty_out(vty, |
3ae8bfa5 PM |
723 | "%%BGP: No %s peer is configured with AS %s\n", |
724 | afi_safi_print(afi, safi), arg); | |
725 | ||
d62a17ae | 726 | return CMD_SUCCESS; |
727 | } | |
728 | ||
729 | return CMD_SUCCESS; | |
730 | } | |
731 | ||
732 | static int bgp_clear_vty(struct vty *vty, const char *name, afi_t afi, | |
733 | safi_t safi, enum clear_sort sort, | |
734 | enum bgp_clear_type stype, const char *arg) | |
735 | { | |
736 | struct bgp *bgp; | |
737 | ||
738 | /* BGP structure lookup. */ | |
739 | if (name) { | |
740 | bgp = bgp_lookup_by_name(name); | |
741 | if (bgp == NULL) { | |
742 | vty_out(vty, "Can't find BGP instance %s\n", name); | |
743 | return CMD_WARNING; | |
744 | } | |
745 | } else { | |
746 | bgp = bgp_get_default(); | |
747 | if (bgp == NULL) { | |
748 | vty_out(vty, "No BGP process is configured\n"); | |
749 | return CMD_WARNING; | |
750 | } | |
751 | } | |
752 | ||
753 | return bgp_clear(vty, bgp, afi, safi, sort, stype, arg); | |
7aafcaca DS |
754 | } |
755 | ||
756 | /* clear soft inbound */ | |
d62a17ae | 757 | static void bgp_clear_star_soft_in(struct vty *vty, const char *name) |
7aafcaca | 758 | { |
d62a17ae | 759 | bgp_clear_vty(vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
760 | BGP_CLEAR_SOFT_IN, NULL); | |
761 | bgp_clear_vty(vty, name, AFI_IP6, SAFI_UNICAST, clear_all, | |
762 | BGP_CLEAR_SOFT_IN, NULL); | |
7aafcaca DS |
763 | } |
764 | ||
765 | /* clear soft outbound */ | |
d62a17ae | 766 | static void bgp_clear_star_soft_out(struct vty *vty, const char *name) |
7aafcaca | 767 | { |
d62a17ae | 768 | bgp_clear_vty(vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
769 | BGP_CLEAR_SOFT_OUT, NULL); | |
770 | bgp_clear_vty(vty, name, AFI_IP6, SAFI_UNICAST, clear_all, | |
771 | BGP_CLEAR_SOFT_OUT, NULL); | |
7aafcaca DS |
772 | } |
773 | ||
774 | ||
f787d7a0 | 775 | #ifndef VTYSH_EXTRACT_PL |
2e4c2296 | 776 | #include "bgpd/bgp_vty_clippy.c" |
f787d7a0 DL |
777 | #endif |
778 | ||
718e3744 | 779 | /* BGP global configuration. */ |
bee57a7a | 780 | #if (CONFDATE > 20190601) |
1cc40660 DS |
781 | CPP_NOTICE("bgpd: time to remove deprecated bgp multiple-instance") |
782 | CPP_NOTICE("This includes BGP_OPT_MULTIPLE_INSTANCE") | |
783 | #endif | |
784 | DEFUN_HIDDEN (bgp_multiple_instance_func, | |
785 | bgp_multiple_instance_cmd, | |
786 | "bgp multiple-instance", | |
787 | BGP_STR | |
788 | "Enable bgp multiple instance\n") | |
718e3744 | 789 | { |
d62a17ae | 790 | bgp_option_set(BGP_OPT_MULTIPLE_INSTANCE); |
791 | return CMD_SUCCESS; | |
718e3744 | 792 | } |
793 | ||
1cc40660 | 794 | DEFUN_HIDDEN (no_bgp_multiple_instance, |
718e3744 | 795 | no_bgp_multiple_instance_cmd, |
796 | "no bgp multiple-instance", | |
797 | NO_STR | |
798 | BGP_STR | |
799 | "BGP multiple instance\n") | |
800 | { | |
d62a17ae | 801 | int ret; |
718e3744 | 802 | |
1cc40660 DS |
803 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); |
804 | vty_out(vty, "if you are using this please let the developers know\n"); | |
805 | zlog_warn("Deprecated option: `bgp multiple-instance` being used"); | |
d62a17ae | 806 | ret = bgp_option_unset(BGP_OPT_MULTIPLE_INSTANCE); |
807 | if (ret < 0) { | |
808 | vty_out(vty, "%% There are more than two BGP instances\n"); | |
809 | return CMD_WARNING_CONFIG_FAILED; | |
810 | } | |
811 | return CMD_SUCCESS; | |
718e3744 | 812 | } |
813 | ||
bee57a7a | 814 | #if (CONFDATE > 20190601) |
798467a2 DS |
815 | CPP_NOTICE("bgpd: time to remove deprecated cli bgp config-type cisco") |
816 | CPP_NOTICE("This includes BGP_OPT_CISCO_CONFIG") | |
817 | #endif | |
818 | DEFUN_HIDDEN (bgp_config_type, | |
819 | bgp_config_type_cmd, | |
820 | "bgp config-type <cisco|zebra>", | |
821 | BGP_STR | |
822 | "Configuration type\n" | |
823 | "cisco\n" | |
824 | "zebra\n") | |
718e3744 | 825 | { |
d62a17ae | 826 | int idx = 0; |
798467a2 DS |
827 | if (argv_find(argv, argc, "cisco", &idx)) { |
828 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
829 | vty_out(vty, "if you are using this please let the developers know!\n"); | |
830 | zlog_warn("Deprecated option: `bgp config-type cisco` being used"); | |
d62a17ae | 831 | bgp_option_set(BGP_OPT_CONFIG_CISCO); |
798467a2 | 832 | } else |
d62a17ae | 833 | bgp_option_unset(BGP_OPT_CONFIG_CISCO); |
718e3744 | 834 | |
d62a17ae | 835 | return CMD_SUCCESS; |
718e3744 | 836 | } |
837 | ||
798467a2 DS |
838 | DEFUN_HIDDEN (no_bgp_config_type, |
839 | no_bgp_config_type_cmd, | |
840 | "no bgp config-type [<cisco|zebra>]", | |
841 | NO_STR | |
842 | BGP_STR | |
843 | "Display configuration type\n" | |
844 | "cisco\n" | |
845 | "zebra\n") | |
718e3744 | 846 | { |
d62a17ae | 847 | bgp_option_unset(BGP_OPT_CONFIG_CISCO); |
848 | return CMD_SUCCESS; | |
718e3744 | 849 | } |
850 | ||
813d4307 | 851 | |
718e3744 | 852 | DEFUN (no_synchronization, |
853 | no_synchronization_cmd, | |
854 | "no synchronization", | |
855 | NO_STR | |
856 | "Perform IGP synchronization\n") | |
857 | { | |
d62a17ae | 858 | return CMD_SUCCESS; |
718e3744 | 859 | } |
860 | ||
861 | DEFUN (no_auto_summary, | |
862 | no_auto_summary_cmd, | |
863 | "no auto-summary", | |
864 | NO_STR | |
865 | "Enable automatic network number summarization\n") | |
866 | { | |
d62a17ae | 867 | return CMD_SUCCESS; |
718e3744 | 868 | } |
3d515fd9 | 869 | |
718e3744 | 870 | /* "router bgp" commands. */ |
505e5056 | 871 | DEFUN_NOSH (router_bgp, |
f412b39a | 872 | router_bgp_cmd, |
18c57037 | 873 | "router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 874 | ROUTER_STR |
875 | BGP_STR | |
31500417 DW |
876 | AS_STR |
877 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 878 | { |
d62a17ae | 879 | int idx_asn = 2; |
880 | int idx_view_vrf = 3; | |
881 | int idx_vrf = 4; | |
882 | int ret; | |
883 | as_t as; | |
884 | struct bgp *bgp; | |
885 | const char *name = NULL; | |
886 | enum bgp_instance_type inst_type; | |
887 | ||
888 | // "router bgp" without an ASN | |
889 | if (argc == 2) { | |
890 | // Pending: Make VRF option available for ASN less config | |
891 | bgp = bgp_get_default(); | |
892 | ||
893 | if (bgp == NULL) { | |
894 | vty_out(vty, "%% No BGP process is configured\n"); | |
895 | return CMD_WARNING_CONFIG_FAILED; | |
896 | } | |
897 | ||
898 | if (listcount(bm->bgp) > 1) { | |
996c9314 | 899 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 900 | return CMD_WARNING_CONFIG_FAILED; |
901 | } | |
902 | } | |
903 | ||
904 | // "router bgp X" | |
905 | else { | |
906 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
907 | ||
908 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; | |
909 | if (argc > 3) { | |
910 | name = argv[idx_vrf]->arg; | |
911 | ||
912 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) | |
913 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
914 | else if (!strcmp(argv[idx_view_vrf]->text, "view")) | |
915 | inst_type = BGP_INSTANCE_TYPE_VIEW; | |
916 | } | |
917 | ||
918 | ret = bgp_get(&bgp, &as, name, inst_type); | |
919 | switch (ret) { | |
920 | case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET: | |
921 | vty_out(vty, | |
922 | "Please specify 'bgp multiple-instance' first\n"); | |
923 | return CMD_WARNING_CONFIG_FAILED; | |
924 | case BGP_ERR_AS_MISMATCH: | |
925 | vty_out(vty, "BGP is already running; AS is %u\n", as); | |
926 | return CMD_WARNING_CONFIG_FAILED; | |
927 | case BGP_ERR_INSTANCE_MISMATCH: | |
928 | vty_out(vty, | |
929 | "BGP instance name and AS number mismatch\n"); | |
930 | vty_out(vty, | |
931 | "BGP instance is already running; AS is %u\n", | |
932 | as); | |
933 | return CMD_WARNING_CONFIG_FAILED; | |
934 | } | |
935 | ||
3bd70bf8 PZ |
936 | /* |
937 | * If we just instantiated the default instance, complete | |
938 | * any pending VRF-VPN leaking that was configured via | |
939 | * earlier "router bgp X vrf FOO" blocks. | |
940 | */ | |
941 | if (inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
942 | vpn_leak_postchange_all(); | |
943 | ||
d62a17ae | 944 | /* Pending: handle when user tries to change a view to vrf n vv. |
945 | */ | |
946 | } | |
947 | ||
0b5131c9 MK |
948 | /* unset the auto created flag as the user config is now present */ |
949 | UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO); | |
d62a17ae | 950 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); |
951 | ||
952 | return CMD_SUCCESS; | |
718e3744 | 953 | } |
954 | ||
718e3744 | 955 | /* "no router bgp" commands. */ |
956 | DEFUN (no_router_bgp, | |
957 | no_router_bgp_cmd, | |
18c57037 | 958 | "no router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 959 | NO_STR |
960 | ROUTER_STR | |
961 | BGP_STR | |
31500417 DW |
962 | AS_STR |
963 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 964 | { |
d62a17ae | 965 | int idx_asn = 3; |
966 | int idx_vrf = 5; | |
967 | as_t as; | |
968 | struct bgp *bgp; | |
969 | const char *name = NULL; | |
718e3744 | 970 | |
d62a17ae | 971 | // "no router bgp" without an ASN |
972 | if (argc == 3) { | |
973 | // Pending: Make VRF option available for ASN less config | |
974 | bgp = bgp_get_default(); | |
718e3744 | 975 | |
d62a17ae | 976 | if (bgp == NULL) { |
977 | vty_out(vty, "%% No BGP process is configured\n"); | |
978 | return CMD_WARNING_CONFIG_FAILED; | |
979 | } | |
7fb21a9f | 980 | |
d62a17ae | 981 | if (listcount(bm->bgp) > 1) { |
996c9314 | 982 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 983 | return CMD_WARNING_CONFIG_FAILED; |
984 | } | |
0b5131c9 MK |
985 | |
986 | if (bgp->l3vni) { | |
987 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
988 | bgp->l3vni); | |
989 | return CMD_WARNING_CONFIG_FAILED; | |
990 | } | |
d62a17ae | 991 | } else { |
992 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
7fb21a9f | 993 | |
d62a17ae | 994 | if (argc > 4) |
995 | name = argv[idx_vrf]->arg; | |
7fb21a9f | 996 | |
d62a17ae | 997 | /* Lookup bgp structure. */ |
998 | bgp = bgp_lookup(as, name); | |
999 | if (!bgp) { | |
1000 | vty_out(vty, "%% Can't find BGP instance\n"); | |
1001 | return CMD_WARNING_CONFIG_FAILED; | |
1002 | } | |
0b5131c9 MK |
1003 | |
1004 | if (bgp->l3vni) { | |
1005 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
1006 | bgp->l3vni); | |
1007 | return CMD_WARNING_CONFIG_FAILED; | |
1008 | } | |
d62a17ae | 1009 | } |
718e3744 | 1010 | |
d62a17ae | 1011 | bgp_delete(bgp); |
718e3744 | 1012 | |
d62a17ae | 1013 | return CMD_SUCCESS; |
718e3744 | 1014 | } |
1015 | ||
6b0655a2 | 1016 | |
718e3744 | 1017 | /* BGP router-id. */ |
1018 | ||
f787d7a0 | 1019 | DEFPY (bgp_router_id, |
718e3744 | 1020 | bgp_router_id_cmd, |
1021 | "bgp router-id A.B.C.D", | |
1022 | BGP_STR | |
1023 | "Override configured router identifier\n" | |
1024 | "Manually configured router identifier\n") | |
1025 | { | |
d62a17ae | 1026 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1027 | bgp_router_id_static_set(bgp, router_id); | |
1028 | return CMD_SUCCESS; | |
718e3744 | 1029 | } |
1030 | ||
f787d7a0 | 1031 | DEFPY (no_bgp_router_id, |
718e3744 | 1032 | no_bgp_router_id_cmd, |
31500417 | 1033 | "no bgp router-id [A.B.C.D]", |
718e3744 | 1034 | NO_STR |
1035 | BGP_STR | |
31500417 DW |
1036 | "Override configured router identifier\n" |
1037 | "Manually configured router identifier\n") | |
718e3744 | 1038 | { |
d62a17ae | 1039 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1040 | |
d62a17ae | 1041 | if (router_id_str) { |
1042 | if (!IPV4_ADDR_SAME(&bgp->router_id_static, &router_id)) { | |
1043 | vty_out(vty, "%% BGP router-id doesn't match\n"); | |
1044 | return CMD_WARNING_CONFIG_FAILED; | |
1045 | } | |
e018c7cc | 1046 | } |
718e3744 | 1047 | |
d62a17ae | 1048 | router_id.s_addr = 0; |
1049 | bgp_router_id_static_set(bgp, router_id); | |
718e3744 | 1050 | |
d62a17ae | 1051 | return CMD_SUCCESS; |
718e3744 | 1052 | } |
1053 | ||
6b0655a2 | 1054 | |
718e3744 | 1055 | /* BGP Cluster ID. */ |
718e3744 | 1056 | DEFUN (bgp_cluster_id, |
1057 | bgp_cluster_id_cmd, | |
838758ac | 1058 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", |
718e3744 | 1059 | BGP_STR |
1060 | "Configure Route-Reflector Cluster-id\n" | |
838758ac DW |
1061 | "Route-Reflector Cluster-id in IP address format\n" |
1062 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1063 | { |
d62a17ae | 1064 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1065 | int idx_ipv4 = 2; | |
1066 | int ret; | |
1067 | struct in_addr cluster; | |
718e3744 | 1068 | |
d62a17ae | 1069 | ret = inet_aton(argv[idx_ipv4]->arg, &cluster); |
1070 | if (!ret) { | |
1071 | vty_out(vty, "%% Malformed bgp cluster identifier\n"); | |
1072 | return CMD_WARNING_CONFIG_FAILED; | |
1073 | } | |
718e3744 | 1074 | |
d62a17ae | 1075 | bgp_cluster_id_set(bgp, &cluster); |
1076 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1077 | |
d62a17ae | 1078 | return CMD_SUCCESS; |
718e3744 | 1079 | } |
1080 | ||
718e3744 | 1081 | DEFUN (no_bgp_cluster_id, |
1082 | no_bgp_cluster_id_cmd, | |
c7178fe7 | 1083 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", |
718e3744 | 1084 | NO_STR |
1085 | BGP_STR | |
838758ac DW |
1086 | "Configure Route-Reflector Cluster-id\n" |
1087 | "Route-Reflector Cluster-id in IP address format\n" | |
1088 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1089 | { |
d62a17ae | 1090 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1091 | bgp_cluster_id_unset(bgp); | |
1092 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1093 | |
d62a17ae | 1094 | return CMD_SUCCESS; |
718e3744 | 1095 | } |
1096 | ||
718e3744 | 1097 | DEFUN (bgp_confederation_identifier, |
1098 | bgp_confederation_identifier_cmd, | |
9ccf14f7 | 1099 | "bgp confederation identifier (1-4294967295)", |
718e3744 | 1100 | "BGP specific commands\n" |
1101 | "AS confederation parameters\n" | |
1102 | "AS number\n" | |
1103 | "Set routing domain confederation AS\n") | |
1104 | { | |
d62a17ae | 1105 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1106 | int idx_number = 3; | |
1107 | as_t as; | |
718e3744 | 1108 | |
d62a17ae | 1109 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 1110 | |
d62a17ae | 1111 | bgp_confederation_id_set(bgp, as); |
718e3744 | 1112 | |
d62a17ae | 1113 | return CMD_SUCCESS; |
718e3744 | 1114 | } |
1115 | ||
1116 | DEFUN (no_bgp_confederation_identifier, | |
1117 | no_bgp_confederation_identifier_cmd, | |
838758ac | 1118 | "no bgp confederation identifier [(1-4294967295)]", |
718e3744 | 1119 | NO_STR |
1120 | "BGP specific commands\n" | |
1121 | "AS confederation parameters\n" | |
3a2d747c QY |
1122 | "AS number\n" |
1123 | "Set routing domain confederation AS\n") | |
718e3744 | 1124 | { |
d62a17ae | 1125 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1126 | bgp_confederation_id_unset(bgp); | |
718e3744 | 1127 | |
d62a17ae | 1128 | return CMD_SUCCESS; |
718e3744 | 1129 | } |
1130 | ||
718e3744 | 1131 | DEFUN (bgp_confederation_peers, |
1132 | bgp_confederation_peers_cmd, | |
12dcf78e | 1133 | "bgp confederation peers (1-4294967295)...", |
718e3744 | 1134 | "BGP specific commands\n" |
1135 | "AS confederation parameters\n" | |
1136 | "Peer ASs in BGP confederation\n" | |
1137 | AS_STR) | |
1138 | { | |
d62a17ae | 1139 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1140 | int idx_asn = 3; | |
1141 | as_t as; | |
1142 | int i; | |
718e3744 | 1143 | |
d62a17ae | 1144 | for (i = idx_asn; i < argc; i++) { |
1145 | as = strtoul(argv[i]->arg, NULL, 10); | |
718e3744 | 1146 | |
d62a17ae | 1147 | if (bgp->as == as) { |
1148 | vty_out(vty, | |
1149 | "%% Local member-AS not allowed in confed peer list\n"); | |
1150 | continue; | |
1151 | } | |
718e3744 | 1152 | |
d62a17ae | 1153 | bgp_confederation_peers_add(bgp, as); |
1154 | } | |
1155 | return CMD_SUCCESS; | |
718e3744 | 1156 | } |
1157 | ||
1158 | DEFUN (no_bgp_confederation_peers, | |
1159 | no_bgp_confederation_peers_cmd, | |
e83a9414 | 1160 | "no bgp confederation peers (1-4294967295)...", |
718e3744 | 1161 | NO_STR |
1162 | "BGP specific commands\n" | |
1163 | "AS confederation parameters\n" | |
1164 | "Peer ASs in BGP confederation\n" | |
1165 | AS_STR) | |
1166 | { | |
d62a17ae | 1167 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1168 | int idx_asn = 4; | |
1169 | as_t as; | |
1170 | int i; | |
718e3744 | 1171 | |
d62a17ae | 1172 | for (i = idx_asn; i < argc; i++) { |
1173 | as = strtoul(argv[i]->arg, NULL, 10); | |
0b2aa3a0 | 1174 | |
d62a17ae | 1175 | bgp_confederation_peers_remove(bgp, as); |
1176 | } | |
1177 | return CMD_SUCCESS; | |
718e3744 | 1178 | } |
6b0655a2 | 1179 | |
5e242b0d DS |
1180 | /** |
1181 | * Central routine for maximum-paths configuration. | |
1182 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1183 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1184 | */ | |
d62a17ae | 1185 | static int bgp_maxpaths_config_vty(struct vty *vty, int peer_type, |
d7c0a89a | 1186 | const char *mpaths, uint16_t options, |
d62a17ae | 1187 | int set) |
1188 | { | |
1189 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
d7c0a89a | 1190 | uint16_t maxpaths = 0; |
d62a17ae | 1191 | int ret; |
1192 | afi_t afi; | |
1193 | safi_t safi; | |
1194 | ||
1195 | afi = bgp_node_afi(vty); | |
1196 | safi = bgp_node_safi(vty); | |
1197 | ||
1198 | if (set) { | |
1199 | maxpaths = strtol(mpaths, NULL, 10); | |
1200 | if (maxpaths > multipath_num) { | |
1201 | vty_out(vty, | |
1202 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", | |
1203 | maxpaths, multipath_num); | |
1204 | return CMD_WARNING_CONFIG_FAILED; | |
1205 | } | |
1206 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1207 | options); | |
1208 | } else | |
1209 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1210 | ||
1211 | if (ret < 0) { | |
1212 | vty_out(vty, | |
1213 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", | |
1214 | (set == 1) ? "" : "un", | |
1215 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1216 | maxpaths, afi, safi); | |
1217 | return CMD_WARNING_CONFIG_FAILED; | |
1218 | } | |
1219 | ||
1220 | bgp_recalculate_all_bestpaths(bgp); | |
1221 | ||
1222 | return CMD_SUCCESS; | |
165b5fff JB |
1223 | } |
1224 | ||
abc920f8 DS |
1225 | DEFUN (bgp_maxmed_admin, |
1226 | bgp_maxmed_admin_cmd, | |
1227 | "bgp max-med administrative ", | |
1228 | BGP_STR | |
1229 | "Advertise routes with max-med\n" | |
1230 | "Administratively applied, for an indefinite period\n") | |
1231 | { | |
d62a17ae | 1232 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1233 | |
d62a17ae | 1234 | bgp->v_maxmed_admin = 1; |
1235 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1236 | |
d62a17ae | 1237 | bgp_maxmed_update(bgp); |
abc920f8 | 1238 | |
d62a17ae | 1239 | return CMD_SUCCESS; |
abc920f8 DS |
1240 | } |
1241 | ||
1242 | DEFUN (bgp_maxmed_admin_medv, | |
1243 | bgp_maxmed_admin_medv_cmd, | |
4668a151 | 1244 | "bgp max-med administrative (0-4294967295)", |
abc920f8 DS |
1245 | BGP_STR |
1246 | "Advertise routes with max-med\n" | |
1247 | "Administratively applied, for an indefinite period\n" | |
1248 | "Max MED value to be used\n") | |
1249 | { | |
d62a17ae | 1250 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1251 | int idx_number = 3; | |
abc920f8 | 1252 | |
d62a17ae | 1253 | bgp->v_maxmed_admin = 1; |
1254 | bgp->maxmed_admin_value = strtoul(argv[idx_number]->arg, NULL, 10); | |
abc920f8 | 1255 | |
d62a17ae | 1256 | bgp_maxmed_update(bgp); |
abc920f8 | 1257 | |
d62a17ae | 1258 | return CMD_SUCCESS; |
abc920f8 DS |
1259 | } |
1260 | ||
1261 | DEFUN (no_bgp_maxmed_admin, | |
1262 | no_bgp_maxmed_admin_cmd, | |
4668a151 | 1263 | "no bgp max-med administrative [(0-4294967295)]", |
abc920f8 DS |
1264 | NO_STR |
1265 | BGP_STR | |
1266 | "Advertise routes with max-med\n" | |
838758ac DW |
1267 | "Administratively applied, for an indefinite period\n" |
1268 | "Max MED value to be used\n") | |
abc920f8 | 1269 | { |
d62a17ae | 1270 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1271 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; | |
1272 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1273 | bgp_maxmed_update(bgp); | |
abc920f8 | 1274 | |
d62a17ae | 1275 | return CMD_SUCCESS; |
abc920f8 DS |
1276 | } |
1277 | ||
abc920f8 DS |
1278 | DEFUN (bgp_maxmed_onstartup, |
1279 | bgp_maxmed_onstartup_cmd, | |
4668a151 | 1280 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", |
abc920f8 DS |
1281 | BGP_STR |
1282 | "Advertise routes with max-med\n" | |
1283 | "Effective on a startup\n" | |
1284 | "Time (seconds) period for max-med\n" | |
1285 | "Max MED value to be used\n") | |
1286 | { | |
d62a17ae | 1287 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1288 | int idx = 0; | |
4668a151 | 1289 | |
d62a17ae | 1290 | argv_find(argv, argc, "(5-86400)", &idx); |
1291 | bgp->v_maxmed_onstartup = strtoul(argv[idx]->arg, NULL, 10); | |
1292 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
1293 | bgp->maxmed_onstartup_value = strtoul(argv[idx]->arg, NULL, 10); | |
1294 | else | |
1295 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
4668a151 | 1296 | |
d62a17ae | 1297 | bgp_maxmed_update(bgp); |
abc920f8 | 1298 | |
d62a17ae | 1299 | return CMD_SUCCESS; |
abc920f8 DS |
1300 | } |
1301 | ||
1302 | DEFUN (no_bgp_maxmed_onstartup, | |
1303 | no_bgp_maxmed_onstartup_cmd, | |
4668a151 | 1304 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", |
abc920f8 DS |
1305 | NO_STR |
1306 | BGP_STR | |
1307 | "Advertise routes with max-med\n" | |
838758ac DW |
1308 | "Effective on a startup\n" |
1309 | "Time (seconds) period for max-med\n" | |
1310 | "Max MED value to be used\n") | |
abc920f8 | 1311 | { |
d62a17ae | 1312 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1313 | |
d62a17ae | 1314 | /* Cancel max-med onstartup if its on */ |
1315 | if (bgp->t_maxmed_onstartup) { | |
1316 | THREAD_TIMER_OFF(bgp->t_maxmed_onstartup); | |
1317 | bgp->maxmed_onstartup_over = 1; | |
1318 | } | |
abc920f8 | 1319 | |
d62a17ae | 1320 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; |
1321 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1322 | |
d62a17ae | 1323 | bgp_maxmed_update(bgp); |
abc920f8 | 1324 | |
d62a17ae | 1325 | return CMD_SUCCESS; |
abc920f8 DS |
1326 | } |
1327 | ||
d62a17ae | 1328 | static int bgp_update_delay_config_vty(struct vty *vty, const char *delay, |
1329 | const char *wait) | |
f188f2c4 | 1330 | { |
d62a17ae | 1331 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d7c0a89a QY |
1332 | uint16_t update_delay; |
1333 | uint16_t establish_wait; | |
f188f2c4 | 1334 | |
d62a17ae | 1335 | update_delay = strtoul(delay, NULL, 10); |
f188f2c4 | 1336 | |
d62a17ae | 1337 | if (!wait) /* update-delay <delay> */ |
1338 | { | |
1339 | bgp->v_update_delay = update_delay; | |
1340 | bgp->v_establish_wait = bgp->v_update_delay; | |
1341 | return CMD_SUCCESS; | |
1342 | } | |
f188f2c4 | 1343 | |
d62a17ae | 1344 | /* update-delay <delay> <establish-wait> */ |
1345 | establish_wait = atoi(wait); | |
1346 | if (update_delay < establish_wait) { | |
1347 | vty_out(vty, | |
1348 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1349 | return CMD_WARNING_CONFIG_FAILED; | |
1350 | } | |
f188f2c4 | 1351 | |
d62a17ae | 1352 | bgp->v_update_delay = update_delay; |
1353 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 1354 | |
d62a17ae | 1355 | return CMD_SUCCESS; |
f188f2c4 DS |
1356 | } |
1357 | ||
d62a17ae | 1358 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 1359 | { |
d62a17ae | 1360 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 1361 | |
d62a17ae | 1362 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
1363 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 1364 | |
d62a17ae | 1365 | return CMD_SUCCESS; |
f188f2c4 DS |
1366 | } |
1367 | ||
2b791107 | 1368 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 1369 | { |
d62a17ae | 1370 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
1371 | vty_out(vty, " update-delay %d", bgp->v_update_delay); | |
1372 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1373 | vty_out(vty, " %d", bgp->v_establish_wait); | |
1374 | vty_out(vty, "\n"); | |
1375 | } | |
f188f2c4 DS |
1376 | } |
1377 | ||
1378 | ||
1379 | /* Update-delay configuration */ | |
1380 | DEFUN (bgp_update_delay, | |
1381 | bgp_update_delay_cmd, | |
6147e2c6 | 1382 | "update-delay (0-3600)", |
f188f2c4 DS |
1383 | "Force initial delay for best-path and updates\n" |
1384 | "Seconds\n") | |
1385 | { | |
d62a17ae | 1386 | int idx_number = 1; |
1387 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); | |
f188f2c4 DS |
1388 | } |
1389 | ||
1390 | DEFUN (bgp_update_delay_establish_wait, | |
1391 | bgp_update_delay_establish_wait_cmd, | |
6147e2c6 | 1392 | "update-delay (0-3600) (1-3600)", |
f188f2c4 DS |
1393 | "Force initial delay for best-path and updates\n" |
1394 | "Seconds\n" | |
f188f2c4 DS |
1395 | "Seconds\n") |
1396 | { | |
d62a17ae | 1397 | int idx_number = 1; |
1398 | int idx_number_2 = 2; | |
1399 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, | |
1400 | argv[idx_number_2]->arg); | |
f188f2c4 DS |
1401 | } |
1402 | ||
1403 | /* Update-delay deconfiguration */ | |
1404 | DEFUN (no_bgp_update_delay, | |
1405 | no_bgp_update_delay_cmd, | |
838758ac DW |
1406 | "no update-delay [(0-3600) [(1-3600)]]", |
1407 | NO_STR | |
f188f2c4 | 1408 | "Force initial delay for best-path and updates\n" |
838758ac | 1409 | "Seconds\n" |
7111c1a0 | 1410 | "Seconds\n") |
f188f2c4 | 1411 | { |
d62a17ae | 1412 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
1413 | } |
1414 | ||
5e242b0d | 1415 | |
d62a17ae | 1416 | static int bgp_wpkt_quanta_config_vty(struct vty *vty, const char *num, |
1417 | char set) | |
cb1faec9 | 1418 | { |
d62a17ae | 1419 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
cb1faec9 | 1420 | |
555e09d4 QY |
1421 | if (set) { |
1422 | uint32_t quanta = strtoul(num, NULL, 10); | |
1423 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, | |
1424 | memory_order_relaxed); | |
1425 | } else { | |
1426 | atomic_store_explicit(&bgp->wpkt_quanta, BGP_WRITE_PACKET_MAX, | |
1427 | memory_order_relaxed); | |
1428 | } | |
1429 | ||
1430 | return CMD_SUCCESS; | |
1431 | } | |
1432 | ||
1433 | static int bgp_rpkt_quanta_config_vty(struct vty *vty, const char *num, | |
1434 | char set) | |
1435 | { | |
1436 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1437 | ||
1438 | if (set) { | |
1439 | uint32_t quanta = strtoul(num, NULL, 10); | |
1440 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, | |
1441 | memory_order_relaxed); | |
1442 | } else { | |
1443 | atomic_store_explicit(&bgp->rpkt_quanta, BGP_READ_PACKET_MAX, | |
1444 | memory_order_relaxed); | |
1445 | } | |
cb1faec9 | 1446 | |
d62a17ae | 1447 | return CMD_SUCCESS; |
cb1faec9 DS |
1448 | } |
1449 | ||
2b791107 | 1450 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 1451 | { |
555e09d4 QY |
1452 | uint32_t quanta = |
1453 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
1454 | if (quanta != BGP_WRITE_PACKET_MAX) | |
152456fe | 1455 | vty_out(vty, " write-quanta %d\n", quanta); |
cb1faec9 DS |
1456 | } |
1457 | ||
555e09d4 QY |
1458 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) |
1459 | { | |
1460 | uint32_t quanta = | |
1461 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
1462 | if (quanta != BGP_READ_PACKET_MAX) | |
152456fe | 1463 | vty_out(vty, " read-quanta %d\n", quanta); |
555e09d4 | 1464 | } |
cb1faec9 | 1465 | |
555e09d4 | 1466 | /* Packet quanta configuration */ |
cb1faec9 DS |
1467 | DEFUN (bgp_wpkt_quanta, |
1468 | bgp_wpkt_quanta_cmd, | |
555e09d4 | 1469 | "write-quanta (1-10)", |
cb1faec9 DS |
1470 | "How many packets to write to peer socket per run\n" |
1471 | "Number of packets\n") | |
1472 | { | |
d62a17ae | 1473 | int idx_number = 1; |
1474 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
cb1faec9 DS |
1475 | } |
1476 | ||
cb1faec9 DS |
1477 | DEFUN (no_bgp_wpkt_quanta, |
1478 | no_bgp_wpkt_quanta_cmd, | |
555e09d4 | 1479 | "no write-quanta (1-10)", |
d7fa34c1 | 1480 | NO_STR |
555e09d4 | 1481 | "How many packets to write to peer socket per I/O cycle\n" |
cb1faec9 DS |
1482 | "Number of packets\n") |
1483 | { | |
d62a17ae | 1484 | int idx_number = 2; |
1485 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
cb1faec9 DS |
1486 | } |
1487 | ||
555e09d4 QY |
1488 | DEFUN (bgp_rpkt_quanta, |
1489 | bgp_rpkt_quanta_cmd, | |
1490 | "read-quanta (1-10)", | |
1491 | "How many packets to read from peer socket per I/O cycle\n" | |
1492 | "Number of packets\n") | |
1493 | { | |
1494 | int idx_number = 1; | |
1495 | return bgp_rpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
1496 | } | |
1497 | ||
1498 | DEFUN (no_bgp_rpkt_quanta, | |
1499 | no_bgp_rpkt_quanta_cmd, | |
1500 | "no read-quanta (1-10)", | |
1501 | NO_STR | |
1502 | "How many packets to read from peer socket per I/O cycle\n" | |
1503 | "Number of packets\n") | |
1504 | { | |
1505 | int idx_number = 2; | |
1506 | return bgp_rpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
1507 | } | |
1508 | ||
2b791107 | 1509 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 1510 | { |
37a333fe | 1511 | if (!bgp->heuristic_coalesce) |
d62a17ae | 1512 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); |
3f9c7369 DS |
1513 | } |
1514 | ||
1515 | ||
1516 | DEFUN (bgp_coalesce_time, | |
1517 | bgp_coalesce_time_cmd, | |
6147e2c6 | 1518 | "coalesce-time (0-4294967295)", |
3f9c7369 DS |
1519 | "Subgroup coalesce timer\n" |
1520 | "Subgroup coalesce timer value (in ms)\n") | |
1521 | { | |
d62a17ae | 1522 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1523 | |
d62a17ae | 1524 | int idx = 0; |
1525 | argv_find(argv, argc, "(0-4294967295)", &idx); | |
37a333fe | 1526 | bgp->heuristic_coalesce = false; |
d62a17ae | 1527 | bgp->coalesce_time = strtoul(argv[idx]->arg, NULL, 10); |
1528 | return CMD_SUCCESS; | |
3f9c7369 DS |
1529 | } |
1530 | ||
1531 | DEFUN (no_bgp_coalesce_time, | |
1532 | no_bgp_coalesce_time_cmd, | |
6147e2c6 | 1533 | "no coalesce-time (0-4294967295)", |
3a2d747c | 1534 | NO_STR |
3f9c7369 DS |
1535 | "Subgroup coalesce timer\n" |
1536 | "Subgroup coalesce timer value (in ms)\n") | |
1537 | { | |
d62a17ae | 1538 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1539 | |
37a333fe | 1540 | bgp->heuristic_coalesce = true; |
d62a17ae | 1541 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; |
1542 | return CMD_SUCCESS; | |
3f9c7369 DS |
1543 | } |
1544 | ||
5e242b0d DS |
1545 | /* Maximum-paths configuration */ |
1546 | DEFUN (bgp_maxpaths, | |
1547 | bgp_maxpaths_cmd, | |
6319fd63 | 1548 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), |
5e242b0d DS |
1549 | "Forward packets over multiple paths\n" |
1550 | "Number of paths\n") | |
1551 | { | |
d62a17ae | 1552 | int idx_number = 1; |
1553 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, | |
1554 | argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
1555 | } |
1556 | ||
d62a17ae | 1557 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
1558 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1559 | "Forward packets over multiple paths\n" | |
1560 | "Number of paths\n") | |
596c17ba | 1561 | |
165b5fff JB |
1562 | DEFUN (bgp_maxpaths_ibgp, |
1563 | bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1564 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), |
165b5fff JB |
1565 | "Forward packets over multiple paths\n" |
1566 | "iBGP-multipath\n" | |
1567 | "Number of paths\n") | |
1568 | { | |
d62a17ae | 1569 | int idx_number = 2; |
1570 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, | |
1571 | argv[idx_number]->arg, 0, 1); | |
5e242b0d | 1572 | } |
165b5fff | 1573 | |
d62a17ae | 1574 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
1575 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1576 | "Forward packets over multiple paths\n" | |
1577 | "iBGP-multipath\n" | |
1578 | "Number of paths\n") | |
596c17ba | 1579 | |
5e242b0d DS |
1580 | DEFUN (bgp_maxpaths_ibgp_cluster, |
1581 | bgp_maxpaths_ibgp_cluster_cmd, | |
6319fd63 | 1582 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", |
5e242b0d DS |
1583 | "Forward packets over multiple paths\n" |
1584 | "iBGP-multipath\n" | |
1585 | "Number of paths\n" | |
1586 | "Match the cluster length\n") | |
1587 | { | |
d62a17ae | 1588 | int idx_number = 2; |
1589 | return bgp_maxpaths_config_vty( | |
1590 | vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
1591 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); | |
165b5fff JB |
1592 | } |
1593 | ||
d62a17ae | 1594 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
1595 | "maximum-paths ibgp " CMD_RANGE_STR( | |
1596 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
1597 | "Forward packets over multiple paths\n" | |
1598 | "iBGP-multipath\n" | |
1599 | "Number of paths\n" | |
1600 | "Match the cluster length\n") | |
596c17ba | 1601 | |
165b5fff JB |
1602 | DEFUN (no_bgp_maxpaths, |
1603 | no_bgp_maxpaths_cmd, | |
6319fd63 | 1604 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", |
165b5fff JB |
1605 | NO_STR |
1606 | "Forward packets over multiple paths\n" | |
1607 | "Number of paths\n") | |
1608 | { | |
d62a17ae | 1609 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
1610 | } |
1611 | ||
d62a17ae | 1612 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
996c9314 | 1613 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 1614 | "Forward packets over multiple paths\n" |
1615 | "Number of paths\n") | |
596c17ba | 1616 | |
165b5fff JB |
1617 | DEFUN (no_bgp_maxpaths_ibgp, |
1618 | no_bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1619 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", |
165b5fff JB |
1620 | NO_STR |
1621 | "Forward packets over multiple paths\n" | |
1622 | "iBGP-multipath\n" | |
838758ac DW |
1623 | "Number of paths\n" |
1624 | "Match the cluster length\n") | |
165b5fff | 1625 | { |
d62a17ae | 1626 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1627 | } |
1628 | ||
d62a17ae | 1629 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
1630 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
1631 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
1632 | NO_STR | |
1633 | "Forward packets over multiple paths\n" | |
1634 | "iBGP-multipath\n" | |
1635 | "Number of paths\n" | |
1636 | "Match the cluster length\n") | |
596c17ba | 1637 | |
2b791107 | 1638 | void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, afi_t afi, |
60466a63 | 1639 | safi_t safi) |
165b5fff | 1640 | { |
d62a17ae | 1641 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) { |
d62a17ae | 1642 | vty_out(vty, " maximum-paths %d\n", |
1643 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
1644 | } | |
165b5fff | 1645 | |
d62a17ae | 1646 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) { |
d62a17ae | 1647 | vty_out(vty, " maximum-paths ibgp %d", |
1648 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
1649 | if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, | |
1650 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1651 | vty_out(vty, " equal-cluster-length"); | |
1652 | vty_out(vty, "\n"); | |
1653 | } | |
165b5fff | 1654 | } |
6b0655a2 | 1655 | |
718e3744 | 1656 | /* BGP timers. */ |
1657 | ||
1658 | DEFUN (bgp_timers, | |
1659 | bgp_timers_cmd, | |
6147e2c6 | 1660 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1661 | "Adjust routing timers\n" |
1662 | "BGP timers\n" | |
1663 | "Keepalive interval\n" | |
1664 | "Holdtime\n") | |
1665 | { | |
d62a17ae | 1666 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1667 | int idx_number = 2; | |
1668 | int idx_number_2 = 3; | |
1669 | unsigned long keepalive = 0; | |
1670 | unsigned long holdtime = 0; | |
718e3744 | 1671 | |
d62a17ae | 1672 | keepalive = strtoul(argv[idx_number]->arg, NULL, 10); |
1673 | holdtime = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
718e3744 | 1674 | |
d62a17ae | 1675 | /* Holdtime value check. */ |
1676 | if (holdtime < 3 && holdtime != 0) { | |
1677 | vty_out(vty, | |
1678 | "%% hold time value must be either 0 or greater than 3\n"); | |
1679 | return CMD_WARNING_CONFIG_FAILED; | |
1680 | } | |
718e3744 | 1681 | |
d62a17ae | 1682 | bgp_timers_set(bgp, keepalive, holdtime); |
718e3744 | 1683 | |
d62a17ae | 1684 | return CMD_SUCCESS; |
718e3744 | 1685 | } |
1686 | ||
1687 | DEFUN (no_bgp_timers, | |
1688 | no_bgp_timers_cmd, | |
838758ac | 1689 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1690 | NO_STR |
1691 | "Adjust routing timers\n" | |
838758ac DW |
1692 | "BGP timers\n" |
1693 | "Keepalive interval\n" | |
1694 | "Holdtime\n") | |
718e3744 | 1695 | { |
d62a17ae | 1696 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1697 | bgp_timers_unset(bgp); | |
718e3744 | 1698 | |
d62a17ae | 1699 | return CMD_SUCCESS; |
718e3744 | 1700 | } |
1701 | ||
6b0655a2 | 1702 | |
718e3744 | 1703 | DEFUN (bgp_client_to_client_reflection, |
1704 | bgp_client_to_client_reflection_cmd, | |
1705 | "bgp client-to-client reflection", | |
1706 | "BGP specific commands\n" | |
1707 | "Configure client to client route reflection\n" | |
1708 | "reflection of routes allowed\n") | |
1709 | { | |
d62a17ae | 1710 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1711 | bgp_flag_unset(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1712 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1713 | |
d62a17ae | 1714 | return CMD_SUCCESS; |
718e3744 | 1715 | } |
1716 | ||
1717 | DEFUN (no_bgp_client_to_client_reflection, | |
1718 | no_bgp_client_to_client_reflection_cmd, | |
1719 | "no bgp client-to-client reflection", | |
1720 | NO_STR | |
1721 | "BGP specific commands\n" | |
1722 | "Configure client to client route reflection\n" | |
1723 | "reflection of routes allowed\n") | |
1724 | { | |
d62a17ae | 1725 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1726 | bgp_flag_set(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1727 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1728 | |
d62a17ae | 1729 | return CMD_SUCCESS; |
718e3744 | 1730 | } |
1731 | ||
1732 | /* "bgp always-compare-med" configuration. */ | |
1733 | DEFUN (bgp_always_compare_med, | |
1734 | bgp_always_compare_med_cmd, | |
1735 | "bgp always-compare-med", | |
1736 | "BGP specific commands\n" | |
1737 | "Allow comparing MED from different neighbors\n") | |
1738 | { | |
d62a17ae | 1739 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1740 | bgp_flag_set(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1741 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1742 | |
d62a17ae | 1743 | return CMD_SUCCESS; |
718e3744 | 1744 | } |
1745 | ||
1746 | DEFUN (no_bgp_always_compare_med, | |
1747 | no_bgp_always_compare_med_cmd, | |
1748 | "no bgp always-compare-med", | |
1749 | NO_STR | |
1750 | "BGP specific commands\n" | |
1751 | "Allow comparing MED from different neighbors\n") | |
1752 | { | |
d62a17ae | 1753 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1754 | bgp_flag_unset(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1755 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1756 | |
d62a17ae | 1757 | return CMD_SUCCESS; |
718e3744 | 1758 | } |
6b0655a2 | 1759 | |
718e3744 | 1760 | /* "bgp deterministic-med" configuration. */ |
1761 | DEFUN (bgp_deterministic_med, | |
1762 | bgp_deterministic_med_cmd, | |
1763 | "bgp deterministic-med", | |
1764 | "BGP specific commands\n" | |
1765 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1766 | { | |
d62a17ae | 1767 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1475ac87 | 1768 | |
d62a17ae | 1769 | if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { |
1770 | bgp_flag_set(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1771 | bgp_recalculate_all_bestpaths(bgp); | |
1772 | } | |
7aafcaca | 1773 | |
d62a17ae | 1774 | return CMD_SUCCESS; |
718e3744 | 1775 | } |
1776 | ||
1777 | DEFUN (no_bgp_deterministic_med, | |
1778 | no_bgp_deterministic_med_cmd, | |
1779 | "no bgp deterministic-med", | |
1780 | NO_STR | |
1781 | "BGP specific commands\n" | |
1782 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1783 | { | |
d62a17ae | 1784 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1785 | int bestpath_per_as_used; | |
1786 | afi_t afi; | |
1787 | safi_t safi; | |
1788 | struct peer *peer; | |
1789 | struct listnode *node, *nnode; | |
1790 | ||
1791 | if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { | |
1792 | bestpath_per_as_used = 0; | |
1793 | ||
1794 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
05c7a1cc QY |
1795 | FOREACH_AFI_SAFI (afi, safi) |
1796 | if (CHECK_FLAG( | |
1797 | peer->af_flags[afi][safi], | |
1798 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) { | |
1799 | bestpath_per_as_used = 1; | |
1800 | break; | |
1801 | } | |
d62a17ae | 1802 | |
1803 | if (bestpath_per_as_used) | |
1804 | break; | |
1805 | } | |
1806 | ||
1807 | if (bestpath_per_as_used) { | |
1808 | vty_out(vty, | |
1809 | "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n"); | |
1810 | return CMD_WARNING_CONFIG_FAILED; | |
1811 | } else { | |
1812 | bgp_flag_unset(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1813 | bgp_recalculate_all_bestpaths(bgp); | |
1814 | } | |
1815 | } | |
1816 | ||
1817 | return CMD_SUCCESS; | |
718e3744 | 1818 | } |
538621f2 | 1819 | |
1820 | /* "bgp graceful-restart" configuration. */ | |
1821 | DEFUN (bgp_graceful_restart, | |
1822 | bgp_graceful_restart_cmd, | |
1823 | "bgp graceful-restart", | |
1824 | "BGP specific commands\n" | |
1825 | "Graceful restart capability parameters\n") | |
1826 | { | |
d62a17ae | 1827 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1828 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
1829 | return CMD_SUCCESS; | |
538621f2 | 1830 | } |
1831 | ||
1832 | DEFUN (no_bgp_graceful_restart, | |
1833 | no_bgp_graceful_restart_cmd, | |
1834 | "no bgp graceful-restart", | |
1835 | NO_STR | |
1836 | "BGP specific commands\n" | |
1837 | "Graceful restart capability parameters\n") | |
1838 | { | |
d62a17ae | 1839 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1840 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
1841 | return CMD_SUCCESS; | |
538621f2 | 1842 | } |
1843 | ||
93406d87 | 1844 | DEFUN (bgp_graceful_restart_stalepath_time, |
1845 | bgp_graceful_restart_stalepath_time_cmd, | |
6147e2c6 | 1846 | "bgp graceful-restart stalepath-time (1-3600)", |
93406d87 | 1847 | "BGP specific commands\n" |
1848 | "Graceful restart capability parameters\n" | |
1849 | "Set the max time to hold onto restarting peer's stale paths\n" | |
1850 | "Delay value (seconds)\n") | |
1851 | { | |
d62a17ae | 1852 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1853 | int idx_number = 3; | |
d7c0a89a | 1854 | uint32_t stalepath; |
93406d87 | 1855 | |
d62a17ae | 1856 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
1857 | bgp->stalepath_time = stalepath; | |
1858 | return CMD_SUCCESS; | |
93406d87 | 1859 | } |
1860 | ||
eb6f1b41 PG |
1861 | DEFUN (bgp_graceful_restart_restart_time, |
1862 | bgp_graceful_restart_restart_time_cmd, | |
6147e2c6 | 1863 | "bgp graceful-restart restart-time (1-3600)", |
eb6f1b41 PG |
1864 | "BGP specific commands\n" |
1865 | "Graceful restart capability parameters\n" | |
1866 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
1867 | "Delay value (seconds)\n") | |
1868 | { | |
d62a17ae | 1869 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1870 | int idx_number = 3; | |
d7c0a89a | 1871 | uint32_t restart; |
eb6f1b41 | 1872 | |
d62a17ae | 1873 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
1874 | bgp->restart_time = restart; | |
1875 | return CMD_SUCCESS; | |
eb6f1b41 PG |
1876 | } |
1877 | ||
93406d87 | 1878 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
1879 | no_bgp_graceful_restart_stalepath_time_cmd, | |
838758ac | 1880 | "no bgp graceful-restart stalepath-time [(1-3600)]", |
93406d87 | 1881 | NO_STR |
1882 | "BGP specific commands\n" | |
1883 | "Graceful restart capability parameters\n" | |
838758ac DW |
1884 | "Set the max time to hold onto restarting peer's stale paths\n" |
1885 | "Delay value (seconds)\n") | |
93406d87 | 1886 | { |
d62a17ae | 1887 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 1888 | |
d62a17ae | 1889 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
1890 | return CMD_SUCCESS; | |
93406d87 | 1891 | } |
1892 | ||
eb6f1b41 PG |
1893 | DEFUN (no_bgp_graceful_restart_restart_time, |
1894 | no_bgp_graceful_restart_restart_time_cmd, | |
838758ac | 1895 | "no bgp graceful-restart restart-time [(1-3600)]", |
eb6f1b41 PG |
1896 | NO_STR |
1897 | "BGP specific commands\n" | |
1898 | "Graceful restart capability parameters\n" | |
838758ac DW |
1899 | "Set the time to wait to delete stale routes before a BGP open message is received\n" |
1900 | "Delay value (seconds)\n") | |
eb6f1b41 | 1901 | { |
d62a17ae | 1902 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 1903 | |
d62a17ae | 1904 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
1905 | return CMD_SUCCESS; | |
eb6f1b41 PG |
1906 | } |
1907 | ||
43fc21b3 JC |
1908 | DEFUN (bgp_graceful_restart_preserve_fw, |
1909 | bgp_graceful_restart_preserve_fw_cmd, | |
1910 | "bgp graceful-restart preserve-fw-state", | |
1911 | "BGP specific commands\n" | |
1912 | "Graceful restart capability parameters\n" | |
1913 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1914 | { | |
d62a17ae | 1915 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1916 | bgp_flag_set(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1917 | return CMD_SUCCESS; | |
43fc21b3 JC |
1918 | } |
1919 | ||
1920 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
1921 | no_bgp_graceful_restart_preserve_fw_cmd, | |
1922 | "no bgp graceful-restart preserve-fw-state", | |
1923 | NO_STR | |
1924 | "BGP specific commands\n" | |
1925 | "Graceful restart capability parameters\n" | |
1926 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1927 | { | |
d62a17ae | 1928 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1929 | bgp_flag_unset(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1930 | return CMD_SUCCESS; | |
43fc21b3 JC |
1931 | } |
1932 | ||
7f323236 DW |
1933 | static void bgp_redistribute_redo(struct bgp *bgp) |
1934 | { | |
1935 | afi_t afi; | |
1936 | int i; | |
1937 | struct list *red_list; | |
1938 | struct listnode *node; | |
1939 | struct bgp_redist *red; | |
1940 | ||
a4d82a8a PZ |
1941 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { |
1942 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
7f323236 | 1943 | |
a4d82a8a PZ |
1944 | red_list = bgp->redist[afi][i]; |
1945 | if (!red_list) | |
1946 | continue; | |
7f323236 | 1947 | |
a4d82a8a | 1948 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { |
7f323236 DW |
1949 | bgp_redistribute_resend(bgp, afi, i, |
1950 | red->instance); | |
1951 | } | |
1952 | } | |
1953 | } | |
1954 | } | |
1955 | ||
1956 | /* "bgp graceful-shutdown" configuration */ | |
1957 | DEFUN (bgp_graceful_shutdown, | |
1958 | bgp_graceful_shutdown_cmd, | |
1959 | "bgp graceful-shutdown", | |
1960 | BGP_STR | |
1961 | "Graceful shutdown parameters\n") | |
1962 | { | |
1963 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1964 | ||
1965 | if (!bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
1966 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
1967 | bgp_static_redo_import_check(bgp); | |
1968 | bgp_redistribute_redo(bgp); | |
1969 | bgp_clear_star_soft_out(vty, bgp->name); | |
1970 | bgp_clear_star_soft_in(vty, bgp->name); | |
1971 | } | |
1972 | ||
1973 | return CMD_SUCCESS; | |
1974 | } | |
1975 | ||
1976 | DEFUN (no_bgp_graceful_shutdown, | |
1977 | no_bgp_graceful_shutdown_cmd, | |
1978 | "no bgp graceful-shutdown", | |
1979 | NO_STR | |
1980 | BGP_STR | |
1981 | "Graceful shutdown parameters\n") | |
1982 | { | |
1983 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1984 | ||
1985 | if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
1986 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
1987 | bgp_static_redo_import_check(bgp); | |
1988 | bgp_redistribute_redo(bgp); | |
1989 | bgp_clear_star_soft_out(vty, bgp->name); | |
1990 | bgp_clear_star_soft_in(vty, bgp->name); | |
1991 | } | |
1992 | ||
1993 | return CMD_SUCCESS; | |
1994 | } | |
1995 | ||
718e3744 | 1996 | /* "bgp fast-external-failover" configuration. */ |
1997 | DEFUN (bgp_fast_external_failover, | |
1998 | bgp_fast_external_failover_cmd, | |
1999 | "bgp fast-external-failover", | |
2000 | BGP_STR | |
2001 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2002 | { | |
d62a17ae | 2003 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2004 | bgp_flag_unset(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
2005 | return CMD_SUCCESS; | |
718e3744 | 2006 | } |
2007 | ||
2008 | DEFUN (no_bgp_fast_external_failover, | |
2009 | no_bgp_fast_external_failover_cmd, | |
2010 | "no bgp fast-external-failover", | |
2011 | NO_STR | |
2012 | BGP_STR | |
2013 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2014 | { | |
d62a17ae | 2015 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2016 | bgp_flag_set(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
2017 | return CMD_SUCCESS; | |
718e3744 | 2018 | } |
6b0655a2 | 2019 | |
718e3744 | 2020 | /* "bgp enforce-first-as" configuration. */ |
bee57a7a | 2021 | #if CONFDATE > 20180517 |
47cbc09b PM |
2022 | CPP_NOTICE("bgpd: remove deprecated '[no] bgp enforce-first-as' commands") |
2023 | #endif | |
2024 | ||
f07e1c4f QY |
2025 | DEFUN_HIDDEN (bgp_enforce_first_as, |
2026 | bgp_enforce_first_as_cmd, | |
2027 | "[no] bgp enforce-first-as", | |
2028 | NO_STR | |
2029 | BGP_STR | |
2030 | "Enforce the first AS for EBGP routes\n") | |
718e3744 | 2031 | { |
d62a17ae | 2032 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2033 | |
f07e1c4f QY |
2034 | if (strmatch(argv[0]->text, "no")) |
2035 | bgp_flag_unset(bgp, BGP_FLAG_ENFORCE_FIRST_AS); | |
2036 | else | |
2037 | bgp_flag_set(bgp, BGP_FLAG_ENFORCE_FIRST_AS); | |
7aafcaca | 2038 | |
d62a17ae | 2039 | return CMD_SUCCESS; |
718e3744 | 2040 | } |
6b0655a2 | 2041 | |
718e3744 | 2042 | /* "bgp bestpath compare-routerid" configuration. */ |
2043 | DEFUN (bgp_bestpath_compare_router_id, | |
2044 | bgp_bestpath_compare_router_id_cmd, | |
2045 | "bgp bestpath compare-routerid", | |
2046 | "BGP specific commands\n" | |
2047 | "Change the default bestpath selection\n" | |
2048 | "Compare router-id for identical EBGP paths\n") | |
2049 | { | |
d62a17ae | 2050 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2051 | bgp_flag_set(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
2052 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2053 | |
d62a17ae | 2054 | return CMD_SUCCESS; |
718e3744 | 2055 | } |
2056 | ||
2057 | DEFUN (no_bgp_bestpath_compare_router_id, | |
2058 | no_bgp_bestpath_compare_router_id_cmd, | |
2059 | "no bgp bestpath compare-routerid", | |
2060 | NO_STR | |
2061 | "BGP specific commands\n" | |
2062 | "Change the default bestpath selection\n" | |
2063 | "Compare router-id for identical EBGP paths\n") | |
2064 | { | |
d62a17ae | 2065 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2066 | bgp_flag_unset(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
2067 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2068 | |
d62a17ae | 2069 | return CMD_SUCCESS; |
718e3744 | 2070 | } |
6b0655a2 | 2071 | |
718e3744 | 2072 | /* "bgp bestpath as-path ignore" configuration. */ |
2073 | DEFUN (bgp_bestpath_aspath_ignore, | |
2074 | bgp_bestpath_aspath_ignore_cmd, | |
2075 | "bgp bestpath as-path ignore", | |
2076 | "BGP specific commands\n" | |
2077 | "Change the default bestpath selection\n" | |
2078 | "AS-path attribute\n" | |
2079 | "Ignore as-path length in selecting a route\n") | |
2080 | { | |
d62a17ae | 2081 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2082 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2083 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2084 | |
d62a17ae | 2085 | return CMD_SUCCESS; |
718e3744 | 2086 | } |
2087 | ||
2088 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
2089 | no_bgp_bestpath_aspath_ignore_cmd, | |
2090 | "no bgp bestpath as-path ignore", | |
2091 | NO_STR | |
2092 | "BGP specific commands\n" | |
2093 | "Change the default bestpath selection\n" | |
2094 | "AS-path attribute\n" | |
2095 | "Ignore as-path length in selecting a route\n") | |
2096 | { | |
d62a17ae | 2097 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2098 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2099 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2100 | |
d62a17ae | 2101 | return CMD_SUCCESS; |
718e3744 | 2102 | } |
6b0655a2 | 2103 | |
6811845b | 2104 | /* "bgp bestpath as-path confed" configuration. */ |
2105 | DEFUN (bgp_bestpath_aspath_confed, | |
2106 | bgp_bestpath_aspath_confed_cmd, | |
2107 | "bgp bestpath as-path confed", | |
2108 | "BGP specific commands\n" | |
2109 | "Change the default bestpath selection\n" | |
2110 | "AS-path attribute\n" | |
2111 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2112 | { | |
d62a17ae | 2113 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2114 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_CONFED); | |
2115 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2116 | |
d62a17ae | 2117 | return CMD_SUCCESS; |
6811845b | 2118 | } |
2119 | ||
2120 | DEFUN (no_bgp_bestpath_aspath_confed, | |
2121 | no_bgp_bestpath_aspath_confed_cmd, | |
2122 | "no bgp bestpath as-path confed", | |
2123 | NO_STR | |
2124 | "BGP specific commands\n" | |
2125 | "Change the default bestpath selection\n" | |
2126 | "AS-path attribute\n" | |
2127 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2128 | { | |
d62a17ae | 2129 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2130 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_CONFED); | |
2131 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2132 | |
d62a17ae | 2133 | return CMD_SUCCESS; |
6811845b | 2134 | } |
6b0655a2 | 2135 | |
2fdd455c PM |
2136 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
2137 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
2138 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2139 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2140 | "BGP specific commands\n" |
2141 | "Change the default bestpath selection\n" | |
2142 | "AS-path attribute\n" | |
2143 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2144 | "Generate an AS_SET\n" |
16fc1eec DS |
2145 | "Do not generate an AS_SET\n") |
2146 | { | |
d62a17ae | 2147 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2148 | int idx = 0; | |
2149 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
219178b6 | 2150 | |
d62a17ae | 2151 | /* no-as-set is now the default behavior so we can silently |
2152 | * ignore it */ | |
2153 | if (argv_find(argv, argc, "as-set", &idx)) | |
2154 | bgp_flag_set(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2155 | else | |
2156 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
219178b6 | 2157 | |
d62a17ae | 2158 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2159 | |
d62a17ae | 2160 | return CMD_SUCCESS; |
16fc1eec DS |
2161 | } |
2162 | ||
219178b6 DW |
2163 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
2164 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2165 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2166 | NO_STR |
2167 | "BGP specific commands\n" | |
2168 | "Change the default bestpath selection\n" | |
2169 | "AS-path attribute\n" | |
2170 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2171 | "Generate an AS_SET\n" |
16fc1eec DS |
2172 | "Do not generate an AS_SET\n") |
2173 | { | |
d62a17ae | 2174 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2175 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
2176 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2177 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2178 | |
d62a17ae | 2179 | return CMD_SUCCESS; |
2fdd455c | 2180 | } |
6b0655a2 | 2181 | |
848973c7 | 2182 | /* "bgp log-neighbor-changes" configuration. */ |
2183 | DEFUN (bgp_log_neighbor_changes, | |
2184 | bgp_log_neighbor_changes_cmd, | |
2185 | "bgp log-neighbor-changes", | |
2186 | "BGP specific commands\n" | |
2187 | "Log neighbor up/down and reset reason\n") | |
2188 | { | |
d62a17ae | 2189 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2190 | bgp_flag_set(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2191 | return CMD_SUCCESS; | |
848973c7 | 2192 | } |
2193 | ||
2194 | DEFUN (no_bgp_log_neighbor_changes, | |
2195 | no_bgp_log_neighbor_changes_cmd, | |
2196 | "no bgp log-neighbor-changes", | |
2197 | NO_STR | |
2198 | "BGP specific commands\n" | |
2199 | "Log neighbor up/down and reset reason\n") | |
2200 | { | |
d62a17ae | 2201 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2202 | bgp_flag_unset(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2203 | return CMD_SUCCESS; | |
848973c7 | 2204 | } |
6b0655a2 | 2205 | |
718e3744 | 2206 | /* "bgp bestpath med" configuration. */ |
2207 | DEFUN (bgp_bestpath_med, | |
2208 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 2209 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2210 | "BGP specific commands\n" |
2211 | "Change the default bestpath selection\n" | |
2212 | "MED attribute\n" | |
2213 | "Compare MED among confederation paths\n" | |
838758ac DW |
2214 | "Treat missing MED as the least preferred one\n" |
2215 | "Treat missing MED as the least preferred one\n" | |
2216 | "Compare MED among confederation paths\n") | |
718e3744 | 2217 | { |
d62a17ae | 2218 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6cbd1915 | 2219 | |
d62a17ae | 2220 | int idx = 0; |
2221 | if (argv_find(argv, argc, "confed", &idx)) | |
2222 | bgp_flag_set(bgp, BGP_FLAG_MED_CONFED); | |
2223 | idx = 0; | |
2224 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2225 | bgp_flag_set(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
e52702f2 | 2226 | |
d62a17ae | 2227 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2228 | |
d62a17ae | 2229 | return CMD_SUCCESS; |
718e3744 | 2230 | } |
2231 | ||
718e3744 | 2232 | DEFUN (no_bgp_bestpath_med, |
2233 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2234 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2235 | NO_STR |
2236 | "BGP specific commands\n" | |
2237 | "Change the default bestpath selection\n" | |
2238 | "MED attribute\n" | |
2239 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2240 | "Treat missing MED as the least preferred one\n" |
2241 | "Treat missing MED as the least preferred one\n" | |
2242 | "Compare MED among confederation paths\n") | |
718e3744 | 2243 | { |
d62a17ae | 2244 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
e52702f2 | 2245 | |
d62a17ae | 2246 | int idx = 0; |
2247 | if (argv_find(argv, argc, "confed", &idx)) | |
2248 | bgp_flag_unset(bgp, BGP_FLAG_MED_CONFED); | |
2249 | idx = 0; | |
2250 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2251 | bgp_flag_unset(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
718e3744 | 2252 | |
d62a17ae | 2253 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2254 | |
d62a17ae | 2255 | return CMD_SUCCESS; |
718e3744 | 2256 | } |
2257 | ||
718e3744 | 2258 | /* "no bgp default ipv4-unicast". */ |
2259 | DEFUN (no_bgp_default_ipv4_unicast, | |
2260 | no_bgp_default_ipv4_unicast_cmd, | |
2261 | "no bgp default ipv4-unicast", | |
2262 | NO_STR | |
2263 | "BGP specific commands\n" | |
2264 | "Configure BGP defaults\n" | |
2265 | "Activate ipv4-unicast for a peer by default\n") | |
2266 | { | |
d62a17ae | 2267 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2268 | bgp_flag_set(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2269 | return CMD_SUCCESS; | |
718e3744 | 2270 | } |
2271 | ||
2272 | DEFUN (bgp_default_ipv4_unicast, | |
2273 | bgp_default_ipv4_unicast_cmd, | |
2274 | "bgp default ipv4-unicast", | |
2275 | "BGP specific commands\n" | |
2276 | "Configure BGP defaults\n" | |
2277 | "Activate ipv4-unicast for a peer by default\n") | |
2278 | { | |
d62a17ae | 2279 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2280 | bgp_flag_unset(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2281 | return CMD_SUCCESS; | |
718e3744 | 2282 | } |
6b0655a2 | 2283 | |
04b6bdc0 DW |
2284 | /* Display hostname in certain command outputs */ |
2285 | DEFUN (bgp_default_show_hostname, | |
2286 | bgp_default_show_hostname_cmd, | |
2287 | "bgp default show-hostname", | |
2288 | "BGP specific commands\n" | |
2289 | "Configure BGP defaults\n" | |
2290 | "Show hostname in certain command ouputs\n") | |
2291 | { | |
d62a17ae | 2292 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2293 | bgp_flag_set(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2294 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2295 | } |
2296 | ||
2297 | DEFUN (no_bgp_default_show_hostname, | |
2298 | no_bgp_default_show_hostname_cmd, | |
2299 | "no bgp default show-hostname", | |
2300 | NO_STR | |
2301 | "BGP specific commands\n" | |
2302 | "Configure BGP defaults\n" | |
2303 | "Show hostname in certain command ouputs\n") | |
2304 | { | |
d62a17ae | 2305 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2306 | bgp_flag_unset(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2307 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2308 | } |
2309 | ||
8233ef81 | 2310 | /* "bgp network import-check" configuration. */ |
718e3744 | 2311 | DEFUN (bgp_network_import_check, |
2312 | bgp_network_import_check_cmd, | |
5623e905 | 2313 | "bgp network import-check", |
718e3744 | 2314 | "BGP specific commands\n" |
2315 | "BGP network command\n" | |
5623e905 | 2316 | "Check BGP network route exists in IGP\n") |
718e3744 | 2317 | { |
d62a17ae | 2318 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2319 | if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2320 | bgp_flag_set(bgp, BGP_FLAG_IMPORT_CHECK); | |
2321 | bgp_static_redo_import_check(bgp); | |
2322 | } | |
078430f6 | 2323 | |
d62a17ae | 2324 | return CMD_SUCCESS; |
718e3744 | 2325 | } |
2326 | ||
d62a17ae | 2327 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
2328 | "bgp network import-check exact", | |
2329 | "BGP specific commands\n" | |
2330 | "BGP network command\n" | |
2331 | "Check BGP network route exists in IGP\n" | |
2332 | "Match route precisely\n") | |
8233ef81 | 2333 | |
718e3744 | 2334 | DEFUN (no_bgp_network_import_check, |
2335 | no_bgp_network_import_check_cmd, | |
5623e905 | 2336 | "no bgp network import-check", |
718e3744 | 2337 | NO_STR |
2338 | "BGP specific commands\n" | |
2339 | "BGP network command\n" | |
2340 | "Check BGP network route exists in IGP\n") | |
2341 | { | |
d62a17ae | 2342 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2343 | if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2344 | bgp_flag_unset(bgp, BGP_FLAG_IMPORT_CHECK); | |
2345 | bgp_static_redo_import_check(bgp); | |
2346 | } | |
5623e905 | 2347 | |
d62a17ae | 2348 | return CMD_SUCCESS; |
718e3744 | 2349 | } |
6b0655a2 | 2350 | |
718e3744 | 2351 | DEFUN (bgp_default_local_preference, |
2352 | bgp_default_local_preference_cmd, | |
6147e2c6 | 2353 | "bgp default local-preference (0-4294967295)", |
718e3744 | 2354 | "BGP specific commands\n" |
2355 | "Configure BGP defaults\n" | |
2356 | "local preference (higher=more preferred)\n" | |
2357 | "Configure default local preference value\n") | |
2358 | { | |
d62a17ae | 2359 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2360 | int idx_number = 3; | |
d7c0a89a | 2361 | uint32_t local_pref; |
718e3744 | 2362 | |
d62a17ae | 2363 | local_pref = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 2364 | |
d62a17ae | 2365 | bgp_default_local_preference_set(bgp, local_pref); |
2366 | bgp_clear_star_soft_in(vty, bgp->name); | |
718e3744 | 2367 | |
d62a17ae | 2368 | return CMD_SUCCESS; |
718e3744 | 2369 | } |
2370 | ||
2371 | DEFUN (no_bgp_default_local_preference, | |
2372 | no_bgp_default_local_preference_cmd, | |
838758ac | 2373 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 2374 | NO_STR |
2375 | "BGP specific commands\n" | |
2376 | "Configure BGP defaults\n" | |
838758ac DW |
2377 | "local preference (higher=more preferred)\n" |
2378 | "Configure default local preference value\n") | |
718e3744 | 2379 | { |
d62a17ae | 2380 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2381 | bgp_default_local_preference_unset(bgp); | |
2382 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2383 | |
d62a17ae | 2384 | return CMD_SUCCESS; |
718e3744 | 2385 | } |
2386 | ||
6b0655a2 | 2387 | |
3f9c7369 DS |
2388 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
2389 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 2390 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
2391 | "BGP specific commands\n" |
2392 | "Configure BGP defaults\n" | |
2393 | "subgroup-pkt-queue-max\n" | |
2394 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 2395 | { |
d62a17ae | 2396 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2397 | int idx_number = 3; | |
d7c0a89a | 2398 | uint32_t max_size; |
8bd9d948 | 2399 | |
d62a17ae | 2400 | max_size = strtoul(argv[idx_number]->arg, NULL, 10); |
3f9c7369 | 2401 | |
d62a17ae | 2402 | bgp_default_subgroup_pkt_queue_max_set(bgp, max_size); |
3f9c7369 | 2403 | |
d62a17ae | 2404 | return CMD_SUCCESS; |
3f9c7369 DS |
2405 | } |
2406 | ||
2407 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
2408 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 2409 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
2410 | NO_STR |
2411 | "BGP specific commands\n" | |
2412 | "Configure BGP defaults\n" | |
838758ac DW |
2413 | "subgroup-pkt-queue-max\n" |
2414 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 2415 | { |
d62a17ae | 2416 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2417 | bgp_default_subgroup_pkt_queue_max_unset(bgp); | |
2418 | return CMD_SUCCESS; | |
8bd9d948 DS |
2419 | } |
2420 | ||
813d4307 | 2421 | |
8bd9d948 DS |
2422 | DEFUN (bgp_rr_allow_outbound_policy, |
2423 | bgp_rr_allow_outbound_policy_cmd, | |
2424 | "bgp route-reflector allow-outbound-policy", | |
2425 | "BGP specific commands\n" | |
2426 | "Allow modifications made by out route-map\n" | |
2427 | "on ibgp neighbors\n") | |
2428 | { | |
d62a17ae | 2429 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2430 | |
d62a17ae | 2431 | if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2432 | bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2433 | update_group_announce_rrclients(bgp); | |
2434 | bgp_clear_star_soft_out(vty, bgp->name); | |
2435 | } | |
8bd9d948 | 2436 | |
d62a17ae | 2437 | return CMD_SUCCESS; |
8bd9d948 DS |
2438 | } |
2439 | ||
2440 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
2441 | no_bgp_rr_allow_outbound_policy_cmd, | |
2442 | "no bgp route-reflector allow-outbound-policy", | |
2443 | NO_STR | |
2444 | "BGP specific commands\n" | |
2445 | "Allow modifications made by out route-map\n" | |
2446 | "on ibgp neighbors\n") | |
2447 | { | |
d62a17ae | 2448 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2449 | |
d62a17ae | 2450 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2451 | bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2452 | update_group_announce_rrclients(bgp); | |
2453 | bgp_clear_star_soft_out(vty, bgp->name); | |
2454 | } | |
8bd9d948 | 2455 | |
d62a17ae | 2456 | return CMD_SUCCESS; |
8bd9d948 DS |
2457 | } |
2458 | ||
f14e6fdb DS |
2459 | DEFUN (bgp_listen_limit, |
2460 | bgp_listen_limit_cmd, | |
9ccf14f7 | 2461 | "bgp listen limit (1-5000)", |
f14e6fdb DS |
2462 | "BGP specific commands\n" |
2463 | "Configure BGP defaults\n" | |
2464 | "maximum number of BGP Dynamic Neighbors that can be created\n" | |
2465 | "Configure Dynamic Neighbors listen limit value\n") | |
2466 | { | |
d62a17ae | 2467 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2468 | int idx_number = 3; | |
2469 | int listen_limit; | |
f14e6fdb | 2470 | |
d62a17ae | 2471 | listen_limit = strtoul(argv[idx_number]->arg, NULL, 10); |
f14e6fdb | 2472 | |
d62a17ae | 2473 | bgp_listen_limit_set(bgp, listen_limit); |
f14e6fdb | 2474 | |
d62a17ae | 2475 | return CMD_SUCCESS; |
f14e6fdb DS |
2476 | } |
2477 | ||
2478 | DEFUN (no_bgp_listen_limit, | |
2479 | no_bgp_listen_limit_cmd, | |
838758ac | 2480 | "no bgp listen limit [(1-5000)]", |
f14e6fdb DS |
2481 | "BGP specific commands\n" |
2482 | "Configure BGP defaults\n" | |
2483 | "unset maximum number of BGP Dynamic Neighbors that can be created\n" | |
838758ac DW |
2484 | "Configure Dynamic Neighbors listen limit value to default\n" |
2485 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 2486 | { |
d62a17ae | 2487 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2488 | bgp_listen_limit_unset(bgp); | |
2489 | return CMD_SUCCESS; | |
f14e6fdb DS |
2490 | } |
2491 | ||
2492 | ||
20eb8864 | 2493 | /* |
2494 | * Check if this listen range is already configured. Check for exact | |
2495 | * match or overlap based on input. | |
2496 | */ | |
d62a17ae | 2497 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
2498 | struct prefix *range, int exact) | |
2499 | { | |
2500 | struct listnode *node, *nnode; | |
2501 | struct listnode *node1, *nnode1; | |
2502 | struct peer_group *group; | |
2503 | struct prefix *lr; | |
2504 | afi_t afi; | |
2505 | int match; | |
2506 | ||
2507 | afi = family2afi(range->family); | |
2508 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2509 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
2510 | lr)) { | |
2511 | if (exact) | |
2512 | match = prefix_same(range, lr); | |
2513 | else | |
2514 | match = (prefix_match(range, lr) | |
2515 | || prefix_match(lr, range)); | |
2516 | if (match) | |
2517 | return group; | |
2518 | } | |
2519 | } | |
2520 | ||
2521 | return NULL; | |
20eb8864 | 2522 | } |
2523 | ||
f14e6fdb DS |
2524 | DEFUN (bgp_listen_range, |
2525 | bgp_listen_range_cmd, | |
9ccf14f7 | 2526 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
f14e6fdb | 2527 | "BGP specific commands\n" |
d7fa34c1 QY |
2528 | "Configure BGP dynamic neighbors listen range\n" |
2529 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
2530 | NEIGHBOR_ADDR_STR |
2531 | "Member of the peer-group\n" | |
2532 | "Peer-group name\n") | |
f14e6fdb | 2533 | { |
d62a17ae | 2534 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2535 | struct prefix range; | |
2536 | struct peer_group *group, *existing_group; | |
2537 | afi_t afi; | |
2538 | int ret; | |
2539 | int idx = 0; | |
2540 | ||
2541 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2542 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2543 | char *prefix = argv[idx]->arg; | |
2544 | argv_find(argv, argc, "WORD", &idx); | |
2545 | char *peergroup = argv[idx]->arg; | |
2546 | ||
2547 | /* Convert IP prefix string to struct prefix. */ | |
2548 | ret = str2prefix(prefix, &range); | |
2549 | if (!ret) { | |
2550 | vty_out(vty, "%% Malformed listen range\n"); | |
2551 | return CMD_WARNING_CONFIG_FAILED; | |
2552 | } | |
2553 | ||
2554 | afi = family2afi(range.family); | |
2555 | ||
2556 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2557 | vty_out(vty, | |
2558 | "%% Malformed listen range (link-local address)\n"); | |
2559 | return CMD_WARNING_CONFIG_FAILED; | |
2560 | } | |
2561 | ||
2562 | apply_mask(&range); | |
2563 | ||
2564 | /* Check if same listen range is already configured. */ | |
2565 | existing_group = listen_range_exists(bgp, &range, 1); | |
2566 | if (existing_group) { | |
2567 | if (strcmp(existing_group->name, peergroup) == 0) | |
2568 | return CMD_SUCCESS; | |
2569 | else { | |
2570 | vty_out(vty, | |
2571 | "%% Same listen range is attached to peer-group %s\n", | |
2572 | existing_group->name); | |
2573 | return CMD_WARNING_CONFIG_FAILED; | |
2574 | } | |
2575 | } | |
2576 | ||
2577 | /* Check if an overlapping listen range exists. */ | |
2578 | if (listen_range_exists(bgp, &range, 0)) { | |
2579 | vty_out(vty, | |
2580 | "%% Listen range overlaps with existing listen range\n"); | |
2581 | return CMD_WARNING_CONFIG_FAILED; | |
2582 | } | |
2583 | ||
2584 | group = peer_group_lookup(bgp, peergroup); | |
2585 | if (!group) { | |
2586 | vty_out(vty, "%% Configure the peer-group first\n"); | |
2587 | return CMD_WARNING_CONFIG_FAILED; | |
2588 | } | |
2589 | ||
2590 | ret = peer_group_listen_range_add(group, &range); | |
2591 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
2592 | } |
2593 | ||
2594 | DEFUN (no_bgp_listen_range, | |
2595 | no_bgp_listen_range_cmd, | |
d7fa34c1 QY |
2596 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
2597 | NO_STR | |
f14e6fdb | 2598 | "BGP specific commands\n" |
d7fa34c1 QY |
2599 | "Unconfigure BGP dynamic neighbors listen range\n" |
2600 | "Unconfigure BGP dynamic neighbors listen range\n" | |
2601 | NEIGHBOR_ADDR_STR | |
2602 | "Member of the peer-group\n" | |
2603 | "Peer-group name\n") | |
f14e6fdb | 2604 | { |
d62a17ae | 2605 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2606 | struct prefix range; | |
2607 | struct peer_group *group; | |
2608 | afi_t afi; | |
2609 | int ret; | |
2610 | int idx = 0; | |
2611 | ||
2612 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2613 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2614 | char *prefix = argv[idx]->arg; | |
2615 | argv_find(argv, argc, "WORD", &idx); | |
2616 | char *peergroup = argv[idx]->arg; | |
2617 | ||
2618 | /* Convert IP prefix string to struct prefix. */ | |
2619 | ret = str2prefix(prefix, &range); | |
2620 | if (!ret) { | |
2621 | vty_out(vty, "%% Malformed listen range\n"); | |
2622 | return CMD_WARNING_CONFIG_FAILED; | |
2623 | } | |
2624 | ||
2625 | afi = family2afi(range.family); | |
2626 | ||
2627 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2628 | vty_out(vty, | |
2629 | "%% Malformed listen range (link-local address)\n"); | |
2630 | return CMD_WARNING_CONFIG_FAILED; | |
2631 | } | |
2632 | ||
2633 | apply_mask(&range); | |
2634 | ||
2635 | group = peer_group_lookup(bgp, peergroup); | |
2636 | if (!group) { | |
2637 | vty_out(vty, "%% Peer-group does not exist\n"); | |
2638 | return CMD_WARNING_CONFIG_FAILED; | |
2639 | } | |
2640 | ||
2641 | ret = peer_group_listen_range_del(group, &range); | |
2642 | return bgp_vty_return(vty, ret); | |
2643 | } | |
2644 | ||
2b791107 | 2645 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 2646 | { |
2647 | struct peer_group *group; | |
2648 | struct listnode *node, *nnode, *rnode, *nrnode; | |
2649 | struct prefix *range; | |
2650 | afi_t afi; | |
2651 | char buf[PREFIX2STR_BUFFER]; | |
2652 | ||
2653 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
2654 | vty_out(vty, " bgp listen limit %d\n", | |
2655 | bgp->dynamic_neighbors_limit); | |
2656 | ||
2657 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2658 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
2659 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
2660 | nrnode, range)) { | |
2661 | prefix2str(range, buf, sizeof(buf)); | |
2662 | vty_out(vty, | |
2663 | " bgp listen range %s peer-group %s\n", | |
2664 | buf, group->name); | |
2665 | } | |
2666 | } | |
2667 | } | |
f14e6fdb DS |
2668 | } |
2669 | ||
2670 | ||
907f92c8 DS |
2671 | DEFUN (bgp_disable_connected_route_check, |
2672 | bgp_disable_connected_route_check_cmd, | |
2673 | "bgp disable-ebgp-connected-route-check", | |
2674 | "BGP specific commands\n" | |
2675 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2676 | { | |
d62a17ae | 2677 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2678 | bgp_flag_set(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2679 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2680 | |
d62a17ae | 2681 | return CMD_SUCCESS; |
907f92c8 DS |
2682 | } |
2683 | ||
2684 | DEFUN (no_bgp_disable_connected_route_check, | |
2685 | no_bgp_disable_connected_route_check_cmd, | |
2686 | "no bgp disable-ebgp-connected-route-check", | |
2687 | NO_STR | |
2688 | "BGP specific commands\n" | |
2689 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2690 | { | |
d62a17ae | 2691 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2692 | bgp_flag_unset(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2693 | bgp_clear_star_soft_in(vty, bgp->name); | |
2694 | ||
2695 | return CMD_SUCCESS; | |
2696 | } | |
2697 | ||
2698 | ||
2699 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, | |
2700 | const char *as_str, afi_t afi, safi_t safi) | |
2701 | { | |
2702 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2703 | int ret; | |
2704 | as_t as; | |
2705 | int as_type = AS_SPECIFIED; | |
2706 | union sockunion su; | |
2707 | ||
2708 | if (as_str[0] == 'i') { | |
2709 | as = 0; | |
2710 | as_type = AS_INTERNAL; | |
2711 | } else if (as_str[0] == 'e') { | |
2712 | as = 0; | |
2713 | as_type = AS_EXTERNAL; | |
2714 | } else { | |
2715 | /* Get AS number. */ | |
2716 | as = strtoul(as_str, NULL, 10); | |
2717 | } | |
2718 | ||
2719 | /* If peer is peer group, call proper function. */ | |
2720 | ret = str2sockunion(peer_str, &su); | |
2721 | if (ret < 0) { | |
2722 | /* Check for peer by interface */ | |
2723 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type, afi, | |
2724 | safi); | |
2725 | if (ret < 0) { | |
2726 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); | |
2727 | if (ret < 0) { | |
2728 | vty_out(vty, | |
2729 | "%% Create the peer-group or interface first\n"); | |
2730 | return CMD_WARNING_CONFIG_FAILED; | |
2731 | } | |
2732 | return CMD_SUCCESS; | |
2733 | } | |
2734 | } else { | |
2735 | if (peer_address_self_check(bgp, &su)) { | |
2736 | vty_out(vty, | |
2737 | "%% Can not configure the local system as neighbor\n"); | |
2738 | return CMD_WARNING_CONFIG_FAILED; | |
2739 | } | |
2740 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type, afi, safi); | |
2741 | } | |
2742 | ||
2743 | /* This peer belongs to peer group. */ | |
2744 | switch (ret) { | |
2745 | case BGP_ERR_PEER_GROUP_MEMBER: | |
2746 | vty_out(vty, | |
2747 | "%% Peer-group AS %u. Cannot configure remote-as for member\n", | |
2748 | as); | |
2749 | return CMD_WARNING_CONFIG_FAILED; | |
2750 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
2751 | vty_out(vty, | |
2752 | "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external\n", | |
2753 | as, as_str); | |
2754 | return CMD_WARNING_CONFIG_FAILED; | |
2755 | } | |
2756 | return bgp_vty_return(vty, ret); | |
718e3744 | 2757 | } |
2758 | ||
f26845f9 QY |
2759 | DEFUN (bgp_default_shutdown, |
2760 | bgp_default_shutdown_cmd, | |
2761 | "[no] bgp default shutdown", | |
2762 | NO_STR | |
2763 | BGP_STR | |
2764 | "Configure BGP defaults\n" | |
b012cbe2 | 2765 | "Apply administrative shutdown to newly configured peers\n") |
f26845f9 QY |
2766 | { |
2767 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2768 | bgp->autoshutdown = !strmatch(argv[0]->text, "no"); | |
2769 | return CMD_SUCCESS; | |
2770 | } | |
2771 | ||
718e3744 | 2772 | DEFUN (neighbor_remote_as, |
2773 | neighbor_remote_as_cmd, | |
3a2d747c | 2774 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2775 | NEIGHBOR_STR |
2776 | NEIGHBOR_ADDR_STR2 | |
2777 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 2778 | AS_STR |
3a2d747c QY |
2779 | "Internal BGP peer\n" |
2780 | "External BGP peer\n") | |
718e3744 | 2781 | { |
d62a17ae | 2782 | int idx_peer = 1; |
2783 | int idx_remote_as = 3; | |
2784 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, | |
2785 | argv[idx_remote_as]->arg, AFI_IP, | |
2786 | SAFI_UNICAST); | |
2787 | } | |
2788 | ||
2789 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, | |
2790 | afi_t afi, safi_t safi, int v6only, | |
2791 | const char *peer_group_name, | |
2792 | const char *as_str) | |
2793 | { | |
2794 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2795 | as_t as = 0; | |
2796 | int as_type = AS_UNSPECIFIED; | |
2797 | struct peer *peer; | |
2798 | struct peer_group *group; | |
2799 | int ret = 0; | |
2800 | union sockunion su; | |
2801 | ||
2802 | group = peer_group_lookup(bgp, conf_if); | |
2803 | ||
2804 | if (group) { | |
2805 | vty_out(vty, "%% Name conflict with peer-group \n"); | |
2806 | return CMD_WARNING_CONFIG_FAILED; | |
2807 | } | |
2808 | ||
2809 | if (as_str) { | |
2810 | if (as_str[0] == 'i') { | |
2811 | as_type = AS_INTERNAL; | |
2812 | } else if (as_str[0] == 'e') { | |
2813 | as_type = AS_EXTERNAL; | |
2814 | } else { | |
2815 | /* Get AS number. */ | |
2816 | as = strtoul(as_str, NULL, 10); | |
2817 | as_type = AS_SPECIFIED; | |
2818 | } | |
2819 | } | |
2820 | ||
2821 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
2822 | if (peer) { | |
2823 | if (as_str) | |
2824 | ret = peer_remote_as(bgp, &su, conf_if, &as, as_type, | |
2825 | afi, safi); | |
2826 | } else { | |
2827 | if (bgp_flag_check(bgp, BGP_FLAG_NO_DEFAULT_IPV4) | |
2828 | && afi == AFI_IP && safi == SAFI_UNICAST) | |
2829 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
2830 | as_type, 0, 0, NULL); | |
2831 | else | |
2832 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
2833 | as_type, afi, safi, NULL); | |
2834 | ||
2835 | if (!peer) { | |
2836 | vty_out(vty, "%% BGP failed to create peer\n"); | |
2837 | return CMD_WARNING_CONFIG_FAILED; | |
2838 | } | |
2839 | ||
2840 | if (v6only) | |
527de3dc | 2841 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 2842 | |
2843 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
2844 | * this | |
2845 | * any unnumbered peer in order to not worry about run-time | |
2846 | * transitions | |
2847 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
2848 | * address | |
2849 | * gets deleted later etc.) | |
2850 | */ | |
2851 | if (peer->ifp) | |
2852 | bgp_zebra_initiate_radv(bgp, peer); | |
2853 | } | |
2854 | ||
2855 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
2856 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
2857 | if (v6only) | |
527de3dc | 2858 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 2859 | else |
527de3dc | 2860 | peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 2861 | |
2862 | /* v6only flag changed. Reset bgp seesion */ | |
2863 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2864 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
2865 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2866 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2867 | } else | |
2868 | bgp_session_reset(peer); | |
2869 | } | |
2870 | ||
9fb964de PM |
2871 | if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) { |
2872 | SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE); | |
2873 | SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE); | |
2874 | UNSET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE); | |
2875 | } | |
d62a17ae | 2876 | |
2877 | if (peer_group_name) { | |
2878 | group = peer_group_lookup(bgp, peer_group_name); | |
2879 | if (!group) { | |
2880 | vty_out(vty, "%% Configure the peer-group first\n"); | |
2881 | return CMD_WARNING_CONFIG_FAILED; | |
2882 | } | |
2883 | ||
2884 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
2885 | } | |
2886 | ||
2887 | return bgp_vty_return(vty, ret); | |
a80beece DS |
2888 | } |
2889 | ||
4c48cf63 DW |
2890 | DEFUN (neighbor_interface_config, |
2891 | neighbor_interface_config_cmd, | |
31500417 | 2892 | "neighbor WORD interface [peer-group WORD]", |
4c48cf63 DW |
2893 | NEIGHBOR_STR |
2894 | "Interface name or neighbor tag\n" | |
31500417 DW |
2895 | "Enable BGP on interface\n" |
2896 | "Member of the peer-group\n" | |
16cedbb0 | 2897 | "Peer-group name\n") |
4c48cf63 | 2898 | { |
d62a17ae | 2899 | int idx_word = 1; |
2900 | int idx_peer_group_word = 4; | |
31500417 | 2901 | |
d62a17ae | 2902 | if (argc > idx_peer_group_word) |
2903 | return peer_conf_interface_get( | |
2904 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
2905 | argv[idx_peer_group_word]->arg, NULL); | |
2906 | else | |
2907 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
2908 | SAFI_UNICAST, 0, NULL, NULL); | |
4c48cf63 DW |
2909 | } |
2910 | ||
4c48cf63 DW |
2911 | DEFUN (neighbor_interface_config_v6only, |
2912 | neighbor_interface_config_v6only_cmd, | |
31500417 | 2913 | "neighbor WORD interface v6only [peer-group WORD]", |
4c48cf63 DW |
2914 | NEIGHBOR_STR |
2915 | "Interface name or neighbor tag\n" | |
2916 | "Enable BGP on interface\n" | |
31500417 DW |
2917 | "Enable BGP with v6 link-local only\n" |
2918 | "Member of the peer-group\n" | |
16cedbb0 | 2919 | "Peer-group name\n") |
4c48cf63 | 2920 | { |
d62a17ae | 2921 | int idx_word = 1; |
2922 | int idx_peer_group_word = 5; | |
31500417 | 2923 | |
d62a17ae | 2924 | if (argc > idx_peer_group_word) |
2925 | return peer_conf_interface_get( | |
2926 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
2927 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 2928 | |
d62a17ae | 2929 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, |
2930 | SAFI_UNICAST, 1, NULL, NULL); | |
4c48cf63 DW |
2931 | } |
2932 | ||
a80beece | 2933 | |
b3a39dc5 DD |
2934 | DEFUN (neighbor_interface_config_remote_as, |
2935 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 2936 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2937 | NEIGHBOR_STR |
2938 | "Interface name or neighbor tag\n" | |
2939 | "Enable BGP on interface\n" | |
3a2d747c | 2940 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2941 | AS_STR |
3a2d747c QY |
2942 | "Internal BGP peer\n" |
2943 | "External BGP peer\n") | |
b3a39dc5 | 2944 | { |
d62a17ae | 2945 | int idx_word = 1; |
2946 | int idx_remote_as = 4; | |
2947 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
2948 | SAFI_UNICAST, 0, NULL, | |
2949 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2950 | } |
2951 | ||
2952 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
2953 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 2954 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2955 | NEIGHBOR_STR |
2956 | "Interface name or neighbor tag\n" | |
3a2d747c | 2957 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 2958 | "Enable BGP on interface\n" |
3a2d747c | 2959 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2960 | AS_STR |
3a2d747c QY |
2961 | "Internal BGP peer\n" |
2962 | "External BGP peer\n") | |
b3a39dc5 | 2963 | { |
d62a17ae | 2964 | int idx_word = 1; |
2965 | int idx_remote_as = 5; | |
2966 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
2967 | SAFI_UNICAST, 1, NULL, | |
2968 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2969 | } |
2970 | ||
718e3744 | 2971 | DEFUN (neighbor_peer_group, |
2972 | neighbor_peer_group_cmd, | |
2973 | "neighbor WORD peer-group", | |
2974 | NEIGHBOR_STR | |
a80beece | 2975 | "Interface name or neighbor tag\n" |
718e3744 | 2976 | "Configure peer-group\n") |
2977 | { | |
d62a17ae | 2978 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2979 | int idx_word = 1; | |
2980 | struct peer *peer; | |
2981 | struct peer_group *group; | |
718e3744 | 2982 | |
d62a17ae | 2983 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
2984 | if (peer) { | |
2985 | vty_out(vty, "%% Name conflict with interface: \n"); | |
2986 | return CMD_WARNING_CONFIG_FAILED; | |
2987 | } | |
718e3744 | 2988 | |
d62a17ae | 2989 | group = peer_group_get(bgp, argv[idx_word]->arg); |
2990 | if (!group) { | |
2991 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
2992 | return CMD_WARNING_CONFIG_FAILED; | |
2993 | } | |
718e3744 | 2994 | |
d62a17ae | 2995 | return CMD_SUCCESS; |
718e3744 | 2996 | } |
2997 | ||
2998 | DEFUN (no_neighbor, | |
2999 | no_neighbor_cmd, | |
dab8cd00 | 3000 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 3001 | NO_STR |
3002 | NEIGHBOR_STR | |
3a2d747c QY |
3003 | NEIGHBOR_ADDR_STR2 |
3004 | "Specify a BGP neighbor\n" | |
3005 | AS_STR | |
3006 | "Internal BGP peer\n" | |
3007 | "External BGP peer\n") | |
718e3744 | 3008 | { |
d62a17ae | 3009 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3010 | int idx_peer = 2; | |
3011 | int ret; | |
3012 | union sockunion su; | |
3013 | struct peer_group *group; | |
3014 | struct peer *peer; | |
3015 | struct peer *other; | |
3016 | ||
3017 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
3018 | if (ret < 0) { | |
3019 | /* look up for neighbor by interface name config. */ | |
3020 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3021 | if (peer) { | |
3022 | /* Request zebra to terminate IPv6 RAs on this | |
3023 | * interface. */ | |
3024 | if (peer->ifp) | |
3025 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
3026 | peer_delete(peer); | |
3027 | return CMD_SUCCESS; | |
3028 | } | |
f14e6fdb | 3029 | |
d62a17ae | 3030 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); |
3031 | if (group) | |
3032 | peer_group_delete(group); | |
3033 | else { | |
3034 | vty_out(vty, "%% Create the peer-group first\n"); | |
3035 | return CMD_WARNING_CONFIG_FAILED; | |
3036 | } | |
3037 | } else { | |
3038 | peer = peer_lookup(bgp, &su); | |
3039 | if (peer) { | |
3040 | if (peer_dynamic_neighbor(peer)) { | |
3041 | vty_out(vty, | |
3042 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3043 | return CMD_WARNING_CONFIG_FAILED; | |
3044 | } | |
3045 | ||
3046 | other = peer->doppelganger; | |
3047 | peer_delete(peer); | |
3048 | if (other && other->status != Deleted) | |
3049 | peer_delete(other); | |
3050 | } | |
1ff9a340 | 3051 | } |
718e3744 | 3052 | |
d62a17ae | 3053 | return CMD_SUCCESS; |
718e3744 | 3054 | } |
3055 | ||
a80beece DS |
3056 | DEFUN (no_neighbor_interface_config, |
3057 | no_neighbor_interface_config_cmd, | |
31500417 | 3058 | "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
3059 | NO_STR |
3060 | NEIGHBOR_STR | |
3061 | "Interface name\n" | |
31500417 DW |
3062 | "Configure BGP on interface\n" |
3063 | "Enable BGP with v6 link-local only\n" | |
3064 | "Member of the peer-group\n" | |
16cedbb0 | 3065 | "Peer-group name\n" |
3a2d747c QY |
3066 | "Specify a BGP neighbor\n" |
3067 | AS_STR | |
3068 | "Internal BGP peer\n" | |
3069 | "External BGP peer\n") | |
a80beece | 3070 | { |
d62a17ae | 3071 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3072 | int idx_word = 2; | |
3073 | struct peer *peer; | |
3074 | ||
3075 | /* look up for neighbor by interface name config. */ | |
3076 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3077 | if (peer) { | |
3078 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
3079 | if (peer->ifp) | |
3080 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
3081 | peer_delete(peer); | |
3082 | } else { | |
3083 | vty_out(vty, "%% Create the bgp interface first\n"); | |
3084 | return CMD_WARNING_CONFIG_FAILED; | |
3085 | } | |
3086 | return CMD_SUCCESS; | |
a80beece DS |
3087 | } |
3088 | ||
718e3744 | 3089 | DEFUN (no_neighbor_peer_group, |
3090 | no_neighbor_peer_group_cmd, | |
3091 | "no neighbor WORD peer-group", | |
3092 | NO_STR | |
3093 | NEIGHBOR_STR | |
3094 | "Neighbor tag\n" | |
3095 | "Configure peer-group\n") | |
3096 | { | |
d62a17ae | 3097 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3098 | int idx_word = 2; | |
3099 | struct peer_group *group; | |
718e3744 | 3100 | |
d62a17ae | 3101 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
3102 | if (group) | |
3103 | peer_group_delete(group); | |
3104 | else { | |
3105 | vty_out(vty, "%% Create the peer-group first\n"); | |
3106 | return CMD_WARNING_CONFIG_FAILED; | |
3107 | } | |
3108 | return CMD_SUCCESS; | |
718e3744 | 3109 | } |
3110 | ||
a80beece DS |
3111 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
3112 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 3113 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3114 | NO_STR |
3115 | NEIGHBOR_STR | |
a80beece | 3116 | "Interface name or neighbor tag\n" |
718e3744 | 3117 | "Specify a BGP neighbor\n" |
3a2d747c QY |
3118 | AS_STR |
3119 | "Internal BGP peer\n" | |
3120 | "External BGP peer\n") | |
718e3744 | 3121 | { |
d62a17ae | 3122 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3123 | int idx_word = 2; | |
3124 | struct peer_group *group; | |
3125 | struct peer *peer; | |
3126 | ||
3127 | /* look up for neighbor by interface name config. */ | |
3128 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3129 | if (peer) { | |
3130 | peer_as_change(peer, 0, AS_SPECIFIED); | |
3131 | return CMD_SUCCESS; | |
3132 | } | |
3133 | ||
3134 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3135 | if (group) | |
3136 | peer_group_remote_as_delete(group); | |
3137 | else { | |
3138 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
3139 | return CMD_WARNING_CONFIG_FAILED; | |
3140 | } | |
3141 | return CMD_SUCCESS; | |
718e3744 | 3142 | } |
6b0655a2 | 3143 | |
718e3744 | 3144 | DEFUN (neighbor_local_as, |
3145 | neighbor_local_as_cmd, | |
9ccf14f7 | 3146 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 3147 | NEIGHBOR_STR |
3148 | NEIGHBOR_ADDR_STR2 | |
3149 | "Specify a local-as number\n" | |
3150 | "AS number used as local AS\n") | |
3151 | { | |
d62a17ae | 3152 | int idx_peer = 1; |
3153 | int idx_number = 3; | |
3154 | struct peer *peer; | |
3155 | int ret; | |
3156 | as_t as; | |
718e3744 | 3157 | |
d62a17ae | 3158 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3159 | if (!peer) | |
3160 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3161 | |
d62a17ae | 3162 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3163 | ret = peer_local_as_set(peer, as, 0, 0); | |
3164 | return bgp_vty_return(vty, ret); | |
718e3744 | 3165 | } |
3166 | ||
3167 | DEFUN (neighbor_local_as_no_prepend, | |
3168 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 3169 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 3170 | NEIGHBOR_STR |
3171 | NEIGHBOR_ADDR_STR2 | |
3172 | "Specify a local-as number\n" | |
3173 | "AS number used as local AS\n" | |
3174 | "Do not prepend local-as to updates from ebgp peers\n") | |
3175 | { | |
d62a17ae | 3176 | int idx_peer = 1; |
3177 | int idx_number = 3; | |
3178 | struct peer *peer; | |
3179 | int ret; | |
3180 | as_t as; | |
718e3744 | 3181 | |
d62a17ae | 3182 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3183 | if (!peer) | |
3184 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3185 | |
d62a17ae | 3186 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3187 | ret = peer_local_as_set(peer, as, 1, 0); | |
3188 | return bgp_vty_return(vty, ret); | |
718e3744 | 3189 | } |
3190 | ||
9d3f9705 AC |
3191 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
3192 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 3193 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
3194 | NEIGHBOR_STR |
3195 | NEIGHBOR_ADDR_STR2 | |
3196 | "Specify a local-as number\n" | |
3197 | "AS number used as local AS\n" | |
3198 | "Do not prepend local-as to updates from ebgp peers\n" | |
3199 | "Do not prepend local-as to updates from ibgp peers\n") | |
3200 | { | |
d62a17ae | 3201 | int idx_peer = 1; |
3202 | int idx_number = 3; | |
3203 | struct peer *peer; | |
3204 | int ret; | |
3205 | as_t as; | |
9d3f9705 | 3206 | |
d62a17ae | 3207 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3208 | if (!peer) | |
3209 | return CMD_WARNING_CONFIG_FAILED; | |
9d3f9705 | 3210 | |
d62a17ae | 3211 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3212 | ret = peer_local_as_set(peer, as, 1, 1); | |
3213 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
3214 | } |
3215 | ||
718e3744 | 3216 | DEFUN (no_neighbor_local_as, |
3217 | no_neighbor_local_as_cmd, | |
a636c635 | 3218 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 3219 | NO_STR |
3220 | NEIGHBOR_STR | |
3221 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
3222 | "Specify a local-as number\n" |
3223 | "AS number used as local AS\n" | |
3224 | "Do not prepend local-as to updates from ebgp peers\n" | |
3225 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 3226 | { |
d62a17ae | 3227 | int idx_peer = 2; |
3228 | struct peer *peer; | |
3229 | int ret; | |
718e3744 | 3230 | |
d62a17ae | 3231 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3232 | if (!peer) | |
3233 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3234 | |
d62a17ae | 3235 | ret = peer_local_as_unset(peer); |
3236 | return bgp_vty_return(vty, ret); | |
718e3744 | 3237 | } |
3238 | ||
718e3744 | 3239 | |
3f9c7369 DS |
3240 | DEFUN (neighbor_solo, |
3241 | neighbor_solo_cmd, | |
9ccf14f7 | 3242 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3243 | NEIGHBOR_STR |
3244 | NEIGHBOR_ADDR_STR2 | |
3245 | "Solo peer - part of its own update group\n") | |
3246 | { | |
d62a17ae | 3247 | int idx_peer = 1; |
3248 | struct peer *peer; | |
3249 | int ret; | |
3f9c7369 | 3250 | |
d62a17ae | 3251 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3252 | if (!peer) | |
3253 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3254 | |
d62a17ae | 3255 | ret = update_group_adjust_soloness(peer, 1); |
3256 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3257 | } |
3258 | ||
3259 | DEFUN (no_neighbor_solo, | |
3260 | no_neighbor_solo_cmd, | |
9ccf14f7 | 3261 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3262 | NO_STR |
3263 | NEIGHBOR_STR | |
3264 | NEIGHBOR_ADDR_STR2 | |
3265 | "Solo peer - part of its own update group\n") | |
3266 | { | |
d62a17ae | 3267 | int idx_peer = 2; |
3268 | struct peer *peer; | |
3269 | int ret; | |
3f9c7369 | 3270 | |
d62a17ae | 3271 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3272 | if (!peer) | |
3273 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3274 | |
d62a17ae | 3275 | ret = update_group_adjust_soloness(peer, 0); |
3276 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3277 | } |
3278 | ||
0df7c91f PJ |
3279 | DEFUN (neighbor_password, |
3280 | neighbor_password_cmd, | |
9ccf14f7 | 3281 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
3282 | NEIGHBOR_STR |
3283 | NEIGHBOR_ADDR_STR2 | |
3284 | "Set a password\n" | |
3285 | "The password\n") | |
3286 | { | |
d62a17ae | 3287 | int idx_peer = 1; |
3288 | int idx_line = 3; | |
3289 | struct peer *peer; | |
3290 | int ret; | |
0df7c91f | 3291 | |
d62a17ae | 3292 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3293 | if (!peer) | |
3294 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3295 | |
d62a17ae | 3296 | ret = peer_password_set(peer, argv[idx_line]->arg); |
3297 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
3298 | } |
3299 | ||
3300 | DEFUN (no_neighbor_password, | |
3301 | no_neighbor_password_cmd, | |
a636c635 | 3302 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
3303 | NO_STR |
3304 | NEIGHBOR_STR | |
3305 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
3306 | "Set a password\n" |
3307 | "The password\n") | |
0df7c91f | 3308 | { |
d62a17ae | 3309 | int idx_peer = 2; |
3310 | struct peer *peer; | |
3311 | int ret; | |
0df7c91f | 3312 | |
d62a17ae | 3313 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3314 | if (!peer) | |
3315 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3316 | |
d62a17ae | 3317 | ret = peer_password_unset(peer); |
3318 | return bgp_vty_return(vty, ret); | |
0df7c91f | 3319 | } |
6b0655a2 | 3320 | |
718e3744 | 3321 | DEFUN (neighbor_activate, |
3322 | neighbor_activate_cmd, | |
9ccf14f7 | 3323 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3324 | NEIGHBOR_STR |
3325 | NEIGHBOR_ADDR_STR2 | |
3326 | "Enable the Address Family for this Neighbor\n") | |
3327 | { | |
d62a17ae | 3328 | int idx_peer = 1; |
3329 | int ret; | |
3330 | struct peer *peer; | |
718e3744 | 3331 | |
d62a17ae | 3332 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3333 | if (!peer) | |
3334 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3335 | |
d62a17ae | 3336 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3337 | return bgp_vty_return(vty, ret); | |
718e3744 | 3338 | } |
3339 | ||
d62a17ae | 3340 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
3341 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3342 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3343 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3344 | |
718e3744 | 3345 | DEFUN (no_neighbor_activate, |
3346 | no_neighbor_activate_cmd, | |
9ccf14f7 | 3347 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3348 | NO_STR |
3349 | NEIGHBOR_STR | |
3350 | NEIGHBOR_ADDR_STR2 | |
3351 | "Enable the Address Family for this Neighbor\n") | |
3352 | { | |
d62a17ae | 3353 | int idx_peer = 2; |
3354 | int ret; | |
3355 | struct peer *peer; | |
718e3744 | 3356 | |
d62a17ae | 3357 | /* Lookup peer. */ |
3358 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3359 | if (!peer) | |
3360 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3361 | |
d62a17ae | 3362 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3363 | return bgp_vty_return(vty, ret); | |
718e3744 | 3364 | } |
6b0655a2 | 3365 | |
d62a17ae | 3366 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
3367 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3368 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3369 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3370 | |
718e3744 | 3371 | DEFUN (neighbor_set_peer_group, |
3372 | neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3373 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3374 | NEIGHBOR_STR |
a80beece | 3375 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3376 | "Member of the peer-group\n" |
16cedbb0 | 3377 | "Peer-group name\n") |
718e3744 | 3378 | { |
d62a17ae | 3379 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3380 | int idx_peer = 1; | |
3381 | int idx_word = 3; | |
3382 | int ret; | |
3383 | as_t as; | |
3384 | union sockunion su; | |
3385 | struct peer *peer; | |
3386 | struct peer_group *group; | |
3387 | ||
d62a17ae | 3388 | ret = str2sockunion(argv[idx_peer]->arg, &su); |
3389 | if (ret < 0) { | |
3390 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3391 | if (!peer) { | |
3392 | vty_out(vty, "%% Malformed address or name: %s\n", | |
3393 | argv[idx_peer]->arg); | |
3394 | return CMD_WARNING_CONFIG_FAILED; | |
3395 | } | |
3396 | } else { | |
3397 | if (peer_address_self_check(bgp, &su)) { | |
3398 | vty_out(vty, | |
3399 | "%% Can not configure the local system as neighbor\n"); | |
3400 | return CMD_WARNING_CONFIG_FAILED; | |
3401 | } | |
3402 | ||
3403 | /* Disallow for dynamic neighbor. */ | |
3404 | peer = peer_lookup(bgp, &su); | |
3405 | if (peer && peer_dynamic_neighbor(peer)) { | |
3406 | vty_out(vty, | |
3407 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3408 | return CMD_WARNING_CONFIG_FAILED; | |
3409 | } | |
3410 | } | |
3411 | ||
3412 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3413 | if (!group) { | |
3414 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3415 | return CMD_WARNING_CONFIG_FAILED; | |
3416 | } | |
3417 | ||
3418 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
3419 | ||
3420 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { | |
3421 | vty_out(vty, | |
3422 | "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", | |
3423 | as); | |
3424 | return CMD_WARNING_CONFIG_FAILED; | |
3425 | } | |
3426 | ||
3427 | return bgp_vty_return(vty, ret); | |
3428 | } | |
3429 | ||
3430 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
3431 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", | |
3432 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3433 | "Member of the peer-group\n" | |
3434 | "Peer-group name\n") | |
596c17ba | 3435 | |
718e3744 | 3436 | DEFUN (no_neighbor_set_peer_group, |
3437 | no_neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3438 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3439 | NO_STR |
3440 | NEIGHBOR_STR | |
a80beece | 3441 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3442 | "Member of the peer-group\n" |
16cedbb0 | 3443 | "Peer-group name\n") |
718e3744 | 3444 | { |
d62a17ae | 3445 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3446 | int idx_peer = 2; | |
3447 | int idx_word = 4; | |
3448 | int ret; | |
3449 | struct peer *peer; | |
3450 | struct peer_group *group; | |
3451 | ||
3452 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); | |
3453 | if (!peer) | |
3454 | return CMD_WARNING_CONFIG_FAILED; | |
3455 | ||
3456 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3457 | if (!group) { | |
3458 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3459 | return CMD_WARNING_CONFIG_FAILED; | |
3460 | } | |
718e3744 | 3461 | |
827ed707 | 3462 | ret = peer_delete(peer); |
718e3744 | 3463 | |
d62a17ae | 3464 | return bgp_vty_return(vty, ret); |
718e3744 | 3465 | } |
6b0655a2 | 3466 | |
d62a17ae | 3467 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
3468 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", | |
3469 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3470 | "Member of the peer-group\n" | |
3471 | "Peer-group name\n") | |
596c17ba | 3472 | |
d62a17ae | 3473 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 3474 | uint32_t flag, int set) |
718e3744 | 3475 | { |
d62a17ae | 3476 | int ret; |
3477 | struct peer *peer; | |
718e3744 | 3478 | |
d62a17ae | 3479 | peer = peer_and_group_lookup_vty(vty, ip_str); |
3480 | if (!peer) | |
3481 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3482 | |
7ebe625c QY |
3483 | /* |
3484 | * If 'neighbor <interface>', then this is for directly connected peers, | |
3485 | * we should not accept disable-connected-check. | |
3486 | */ | |
3487 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
3488 | vty_out(vty, | |
3489 | "%s is directly connected peer, cannot accept disable-" | |
3490 | "connected-check\n", | |
3491 | ip_str); | |
3492 | return CMD_WARNING_CONFIG_FAILED; | |
3493 | } | |
3494 | ||
d62a17ae | 3495 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
3496 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 3497 | |
d62a17ae | 3498 | if (set) |
3499 | ret = peer_flag_set(peer, flag); | |
3500 | else | |
3501 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 3502 | |
d62a17ae | 3503 | return bgp_vty_return(vty, ret); |
718e3744 | 3504 | } |
3505 | ||
47cbc09b | 3506 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint32_t flag) |
718e3744 | 3507 | { |
d62a17ae | 3508 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 3509 | } |
3510 | ||
d62a17ae | 3511 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 3512 | uint32_t flag) |
718e3744 | 3513 | { |
d62a17ae | 3514 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 3515 | } |
3516 | ||
3517 | /* neighbor passive. */ | |
3518 | DEFUN (neighbor_passive, | |
3519 | neighbor_passive_cmd, | |
9ccf14f7 | 3520 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3521 | NEIGHBOR_STR |
3522 | NEIGHBOR_ADDR_STR2 | |
3523 | "Don't send open messages to this neighbor\n") | |
3524 | { | |
d62a17ae | 3525 | int idx_peer = 1; |
3526 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3527 | } |
3528 | ||
3529 | DEFUN (no_neighbor_passive, | |
3530 | no_neighbor_passive_cmd, | |
9ccf14f7 | 3531 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3532 | NO_STR |
3533 | NEIGHBOR_STR | |
3534 | NEIGHBOR_ADDR_STR2 | |
3535 | "Don't send open messages to this neighbor\n") | |
3536 | { | |
d62a17ae | 3537 | int idx_peer = 2; |
3538 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3539 | } |
6b0655a2 | 3540 | |
718e3744 | 3541 | /* neighbor shutdown. */ |
73d70fa6 DL |
3542 | DEFUN (neighbor_shutdown_msg, |
3543 | neighbor_shutdown_msg_cmd, | |
3544 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
718e3744 | 3545 | NEIGHBOR_STR |
3546 | NEIGHBOR_ADDR_STR2 | |
73d70fa6 DL |
3547 | "Administratively shut down this neighbor\n" |
3548 | "Add a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3549 | "Shutdown message\n") | |
718e3744 | 3550 | { |
d62a17ae | 3551 | int idx_peer = 1; |
73d70fa6 | 3552 | |
d62a17ae | 3553 | if (argc >= 5) { |
3554 | struct peer *peer = | |
3555 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3556 | char *message; | |
73d70fa6 | 3557 | |
d62a17ae | 3558 | if (!peer) |
3559 | return CMD_WARNING_CONFIG_FAILED; | |
3560 | message = argv_concat(argv, argc, 4); | |
3561 | peer_tx_shutdown_message_set(peer, message); | |
3562 | XFREE(MTYPE_TMP, message); | |
3563 | } | |
73d70fa6 | 3564 | |
d62a17ae | 3565 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 3566 | } |
3567 | ||
d62a17ae | 3568 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
3569 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3570 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3571 | "Administratively shut down this neighbor\n") | |
73d70fa6 DL |
3572 | |
3573 | DEFUN (no_neighbor_shutdown_msg, | |
3574 | no_neighbor_shutdown_msg_cmd, | |
3575 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
3576 | NO_STR | |
3577 | NEIGHBOR_STR | |
3578 | NEIGHBOR_ADDR_STR2 | |
3579 | "Administratively shut down this neighbor\n" | |
3580 | "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3581 | "Shutdown message\n") | |
718e3744 | 3582 | { |
d62a17ae | 3583 | int idx_peer = 2; |
73d70fa6 | 3584 | |
d62a17ae | 3585 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
3586 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 3587 | } |
6b0655a2 | 3588 | |
d62a17ae | 3589 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
3590 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3591 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3592 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 3593 | |
718e3744 | 3594 | /* neighbor capability dynamic. */ |
3595 | DEFUN (neighbor_capability_dynamic, | |
3596 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3597 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3598 | NEIGHBOR_STR |
3599 | NEIGHBOR_ADDR_STR2 | |
3600 | "Advertise capability to the peer\n" | |
3601 | "Advertise dynamic capability to this neighbor\n") | |
3602 | { | |
d62a17ae | 3603 | int idx_peer = 1; |
3604 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3605 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3606 | } |
3607 | ||
3608 | DEFUN (no_neighbor_capability_dynamic, | |
3609 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3610 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3611 | NO_STR |
3612 | NEIGHBOR_STR | |
3613 | NEIGHBOR_ADDR_STR2 | |
3614 | "Advertise capability to the peer\n" | |
3615 | "Advertise dynamic capability to this neighbor\n") | |
3616 | { | |
d62a17ae | 3617 | int idx_peer = 2; |
3618 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3619 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3620 | } |
6b0655a2 | 3621 | |
718e3744 | 3622 | /* neighbor dont-capability-negotiate */ |
3623 | DEFUN (neighbor_dont_capability_negotiate, | |
3624 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3625 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3626 | NEIGHBOR_STR |
3627 | NEIGHBOR_ADDR_STR2 | |
3628 | "Do not perform capability negotiation\n") | |
3629 | { | |
d62a17ae | 3630 | int idx_peer = 1; |
3631 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3632 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3633 | } |
3634 | ||
3635 | DEFUN (no_neighbor_dont_capability_negotiate, | |
3636 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3637 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3638 | NO_STR |
3639 | NEIGHBOR_STR | |
3640 | NEIGHBOR_ADDR_STR2 | |
3641 | "Do not perform capability negotiation\n") | |
3642 | { | |
d62a17ae | 3643 | int idx_peer = 2; |
3644 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3645 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3646 | } |
6b0655a2 | 3647 | |
8a92a8a0 DS |
3648 | /* neighbor capability extended next hop encoding */ |
3649 | DEFUN (neighbor_capability_enhe, | |
3650 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3651 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3652 | NEIGHBOR_STR |
3653 | NEIGHBOR_ADDR_STR2 | |
3654 | "Advertise capability to the peer\n" | |
3655 | "Advertise extended next-hop capability to the peer\n") | |
3656 | { | |
d62a17ae | 3657 | int idx_peer = 1; |
3658 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3659 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3660 | } |
3661 | ||
3662 | DEFUN (no_neighbor_capability_enhe, | |
3663 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3664 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3665 | NO_STR |
3666 | NEIGHBOR_STR | |
3667 | NEIGHBOR_ADDR_STR2 | |
3668 | "Advertise capability to the peer\n" | |
3669 | "Advertise extended next-hop capability to the peer\n") | |
3670 | { | |
d62a17ae | 3671 | int idx_peer = 2; |
3672 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3673 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3674 | } |
3675 | ||
d62a17ae | 3676 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3677 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 3678 | int set) |
718e3744 | 3679 | { |
d62a17ae | 3680 | int ret; |
3681 | struct peer *peer; | |
718e3744 | 3682 | |
d62a17ae | 3683 | peer = peer_and_group_lookup_vty(vty, peer_str); |
3684 | if (!peer) | |
3685 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3686 | |
d62a17ae | 3687 | if (set) |
3688 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
3689 | else | |
3690 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 3691 | |
d62a17ae | 3692 | return bgp_vty_return(vty, ret); |
718e3744 | 3693 | } |
3694 | ||
d62a17ae | 3695 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3696 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 3697 | { |
d62a17ae | 3698 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 3699 | } |
3700 | ||
d62a17ae | 3701 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3702 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 3703 | { |
d62a17ae | 3704 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 3705 | } |
6b0655a2 | 3706 | |
718e3744 | 3707 | /* neighbor capability orf prefix-list. */ |
3708 | DEFUN (neighbor_capability_orf_prefix, | |
3709 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3710 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3711 | NEIGHBOR_STR |
3712 | NEIGHBOR_ADDR_STR2 | |
3713 | "Advertise capability to the peer\n" | |
3714 | "Advertise ORF capability to the peer\n" | |
3715 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3716 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3717 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3718 | "Capability to SEND the ORF to this neighbor\n") | |
3719 | { | |
d62a17ae | 3720 | int idx_peer = 1; |
3721 | int idx_send_recv = 5; | |
d7c0a89a | 3722 | uint16_t flag = 0; |
d62a17ae | 3723 | |
3724 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3725 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3726 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3727 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3728 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3729 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3730 | else { | |
3731 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3732 | return CMD_WARNING_CONFIG_FAILED; | |
3733 | } | |
3734 | ||
3735 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3736 | bgp_node_safi(vty), flag); | |
3737 | } | |
3738 | ||
3739 | ALIAS_HIDDEN( | |
3740 | neighbor_capability_orf_prefix, | |
3741 | neighbor_capability_orf_prefix_hidden_cmd, | |
3742 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3743 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3744 | "Advertise capability to the peer\n" | |
3745 | "Advertise ORF capability to the peer\n" | |
3746 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3747 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3748 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3749 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 3750 | |
718e3744 | 3751 | DEFUN (no_neighbor_capability_orf_prefix, |
3752 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3753 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3754 | NO_STR |
3755 | NEIGHBOR_STR | |
3756 | NEIGHBOR_ADDR_STR2 | |
3757 | "Advertise capability to the peer\n" | |
3758 | "Advertise ORF capability to the peer\n" | |
3759 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3760 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3761 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3762 | "Capability to SEND the ORF to this neighbor\n") | |
3763 | { | |
d62a17ae | 3764 | int idx_peer = 2; |
3765 | int idx_send_recv = 6; | |
d7c0a89a | 3766 | uint16_t flag = 0; |
d62a17ae | 3767 | |
3768 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3769 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3770 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3771 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3772 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3773 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3774 | else { | |
3775 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3776 | return CMD_WARNING_CONFIG_FAILED; | |
3777 | } | |
3778 | ||
3779 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3780 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3781 | flag); | |
3782 | } | |
3783 | ||
3784 | ALIAS_HIDDEN( | |
3785 | no_neighbor_capability_orf_prefix, | |
3786 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
3787 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3788 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3789 | "Advertise capability to the peer\n" | |
3790 | "Advertise ORF capability to the peer\n" | |
3791 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3792 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3793 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3794 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 3795 | |
718e3744 | 3796 | /* neighbor next-hop-self. */ |
3797 | DEFUN (neighbor_nexthop_self, | |
3798 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3799 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3800 | NEIGHBOR_STR |
3801 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3802 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3803 | { |
d62a17ae | 3804 | int idx_peer = 1; |
3805 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3806 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 3807 | } |
9e7a53c1 | 3808 | |
d62a17ae | 3809 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
3810 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3811 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3812 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 3813 | |
a538debe DS |
3814 | /* neighbor next-hop-self. */ |
3815 | DEFUN (neighbor_nexthop_self_force, | |
3816 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 3817 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3818 | NEIGHBOR_STR |
3819 | NEIGHBOR_ADDR_STR2 | |
3820 | "Disable the next hop calculation for this neighbor\n" | |
3821 | "Set the next hop to self for reflected routes\n") | |
3822 | { | |
d62a17ae | 3823 | int idx_peer = 1; |
3824 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3825 | bgp_node_safi(vty), | |
3826 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 3827 | } |
3828 | ||
d62a17ae | 3829 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
3830 | neighbor_nexthop_self_force_hidden_cmd, | |
3831 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3832 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3833 | "Disable the next hop calculation for this neighbor\n" | |
3834 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 3835 | |
718e3744 | 3836 | DEFUN (no_neighbor_nexthop_self, |
3837 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3838 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3839 | NO_STR |
3840 | NEIGHBOR_STR | |
3841 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3842 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3843 | { |
d62a17ae | 3844 | int idx_peer = 2; |
3845 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3846 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3847 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 3848 | } |
6b0655a2 | 3849 | |
d62a17ae | 3850 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
3851 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3852 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3853 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 3854 | |
88b8ed8d | 3855 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 3856 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 3857 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3858 | NO_STR |
3859 | NEIGHBOR_STR | |
3860 | NEIGHBOR_ADDR_STR2 | |
3861 | "Disable the next hop calculation for this neighbor\n" | |
3862 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 3863 | { |
d62a17ae | 3864 | int idx_peer = 2; |
3865 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3866 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3867 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 3868 | } |
a538debe | 3869 | |
d62a17ae | 3870 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
3871 | no_neighbor_nexthop_self_force_hidden_cmd, | |
3872 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3873 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3874 | "Disable the next hop calculation for this neighbor\n" | |
3875 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 3876 | |
c7122e14 DS |
3877 | /* neighbor as-override */ |
3878 | DEFUN (neighbor_as_override, | |
3879 | neighbor_as_override_cmd, | |
9ccf14f7 | 3880 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3881 | NEIGHBOR_STR |
3882 | NEIGHBOR_ADDR_STR2 | |
3883 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3884 | { | |
d62a17ae | 3885 | int idx_peer = 1; |
3886 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3887 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
3888 | } |
3889 | ||
d62a17ae | 3890 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
3891 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
3892 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3893 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 3894 | |
c7122e14 DS |
3895 | DEFUN (no_neighbor_as_override, |
3896 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 3897 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3898 | NO_STR |
3899 | NEIGHBOR_STR | |
3900 | NEIGHBOR_ADDR_STR2 | |
3901 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3902 | { | |
d62a17ae | 3903 | int idx_peer = 2; |
3904 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3905 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3906 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
3907 | } |
3908 | ||
d62a17ae | 3909 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
3910 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
3911 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3912 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 3913 | |
718e3744 | 3914 | /* neighbor remove-private-AS. */ |
3915 | DEFUN (neighbor_remove_private_as, | |
3916 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3917 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3918 | NEIGHBOR_STR |
3919 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3920 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3921 | { |
d62a17ae | 3922 | int idx_peer = 1; |
3923 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3924 | bgp_node_safi(vty), | |
3925 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 3926 | } |
3927 | ||
d62a17ae | 3928 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
3929 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
3930 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3931 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 3932 | |
5000f21c DS |
3933 | DEFUN (neighbor_remove_private_as_all, |
3934 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 3935 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
3936 | NEIGHBOR_STR |
3937 | NEIGHBOR_ADDR_STR2 | |
3938 | "Remove private ASNs in outbound updates\n" | |
efd7904e | 3939 | "Apply to all AS numbers\n") |
5000f21c | 3940 | { |
d62a17ae | 3941 | int idx_peer = 1; |
3942 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3943 | bgp_node_safi(vty), | |
3944 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
3945 | } |
3946 | ||
d62a17ae | 3947 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
3948 | neighbor_remove_private_as_all_hidden_cmd, | |
3949 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
3950 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3951 | "Remove private ASNs in outbound updates\n" | |
3952 | "Apply to all AS numbers") | |
596c17ba | 3953 | |
5000f21c DS |
3954 | DEFUN (neighbor_remove_private_as_replace_as, |
3955 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 3956 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
3957 | NEIGHBOR_STR |
3958 | NEIGHBOR_ADDR_STR2 | |
3959 | "Remove private ASNs in outbound updates\n" | |
3960 | "Replace private ASNs with our ASN in outbound updates\n") | |
3961 | { | |
d62a17ae | 3962 | int idx_peer = 1; |
3963 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3964 | bgp_node_safi(vty), | |
3965 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
3966 | } |
3967 | ||
d62a17ae | 3968 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
3969 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
3970 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
3971 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3972 | "Remove private ASNs in outbound updates\n" | |
3973 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 3974 | |
5000f21c DS |
3975 | DEFUN (neighbor_remove_private_as_all_replace_as, |
3976 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 3977 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
3978 | NEIGHBOR_STR |
3979 | NEIGHBOR_ADDR_STR2 | |
3980 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3981 | "Apply to all AS numbers\n" |
5000f21c DS |
3982 | "Replace private ASNs with our ASN in outbound updates\n") |
3983 | { | |
d62a17ae | 3984 | int idx_peer = 1; |
3985 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3986 | bgp_node_safi(vty), | |
3987 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
3988 | } |
3989 | ||
d62a17ae | 3990 | ALIAS_HIDDEN( |
3991 | neighbor_remove_private_as_all_replace_as, | |
3992 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
3993 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
3994 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3995 | "Remove private ASNs in outbound updates\n" | |
3996 | "Apply to all AS numbers\n" | |
3997 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 3998 | |
718e3744 | 3999 | DEFUN (no_neighbor_remove_private_as, |
4000 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4001 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4002 | NO_STR |
4003 | NEIGHBOR_STR | |
4004 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4005 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4006 | { |
d62a17ae | 4007 | int idx_peer = 2; |
4008 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4009 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4010 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4011 | } |
6b0655a2 | 4012 | |
d62a17ae | 4013 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
4014 | no_neighbor_remove_private_as_hidden_cmd, | |
4015 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4016 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4017 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4018 | |
88b8ed8d | 4019 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 4020 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 4021 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4022 | NO_STR |
4023 | NEIGHBOR_STR | |
4024 | NEIGHBOR_ADDR_STR2 | |
4025 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4026 | "Apply to all AS numbers\n") |
88b8ed8d | 4027 | { |
d62a17ae | 4028 | int idx_peer = 2; |
4029 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4030 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4031 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 4032 | } |
5000f21c | 4033 | |
d62a17ae | 4034 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
4035 | no_neighbor_remove_private_as_all_hidden_cmd, | |
4036 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4037 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4038 | "Remove private ASNs in outbound updates\n" | |
4039 | "Apply to all AS numbers\n") | |
596c17ba | 4040 | |
88b8ed8d | 4041 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 4042 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 4043 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4044 | NO_STR |
4045 | NEIGHBOR_STR | |
4046 | NEIGHBOR_ADDR_STR2 | |
4047 | "Remove private ASNs in outbound updates\n" | |
4048 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 4049 | { |
d62a17ae | 4050 | int idx_peer = 2; |
4051 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4052 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4053 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 4054 | } |
5000f21c | 4055 | |
d62a17ae | 4056 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
4057 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
4058 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4059 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4060 | "Remove private ASNs in outbound updates\n" | |
4061 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4062 | |
88b8ed8d | 4063 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 4064 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 4065 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4066 | NO_STR |
4067 | NEIGHBOR_STR | |
4068 | NEIGHBOR_ADDR_STR2 | |
4069 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4070 | "Apply to all AS numbers\n" |
5000f21c | 4071 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 4072 | { |
d62a17ae | 4073 | int idx_peer = 2; |
4074 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4075 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4076 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 4077 | } |
5000f21c | 4078 | |
d62a17ae | 4079 | ALIAS_HIDDEN( |
4080 | no_neighbor_remove_private_as_all_replace_as, | |
4081 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4082 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4083 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4084 | "Remove private ASNs in outbound updates\n" | |
4085 | "Apply to all AS numbers\n" | |
4086 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4087 | |
5000f21c | 4088 | |
718e3744 | 4089 | /* neighbor send-community. */ |
4090 | DEFUN (neighbor_send_community, | |
4091 | neighbor_send_community_cmd, | |
9ccf14f7 | 4092 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4093 | NEIGHBOR_STR |
4094 | NEIGHBOR_ADDR_STR2 | |
4095 | "Send Community attribute to this neighbor\n") | |
4096 | { | |
d62a17ae | 4097 | int idx_peer = 1; |
27c05d4d | 4098 | |
d62a17ae | 4099 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4100 | bgp_node_safi(vty), | |
4101 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4102 | } |
4103 | ||
d62a17ae | 4104 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
4105 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4106 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4107 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4108 | |
718e3744 | 4109 | DEFUN (no_neighbor_send_community, |
4110 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 4111 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4112 | NO_STR |
4113 | NEIGHBOR_STR | |
4114 | NEIGHBOR_ADDR_STR2 | |
4115 | "Send Community attribute to this neighbor\n") | |
4116 | { | |
d62a17ae | 4117 | int idx_peer = 2; |
27c05d4d | 4118 | |
d62a17ae | 4119 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
4120 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4121 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4122 | } |
6b0655a2 | 4123 | |
d62a17ae | 4124 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
4125 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4126 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4127 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4128 | |
718e3744 | 4129 | /* neighbor send-community extended. */ |
4130 | DEFUN (neighbor_send_community_type, | |
4131 | neighbor_send_community_type_cmd, | |
57d187bc | 4132 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4133 | NEIGHBOR_STR |
4134 | NEIGHBOR_ADDR_STR2 | |
4135 | "Send Community attribute to this neighbor\n" | |
4136 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4137 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4138 | "Send Extended Community attributes\n" |
57d187bc JS |
4139 | "Send Standard Community attributes\n" |
4140 | "Send Large Community attributes\n") | |
718e3744 | 4141 | { |
27c05d4d | 4142 | int idx_peer = 1; |
d7c0a89a | 4143 | uint32_t flag = 0; |
27c05d4d | 4144 | const char *type = argv[argc - 1]->text; |
d62a17ae | 4145 | |
27c05d4d | 4146 | if (strmatch(type, "standard")) { |
d62a17ae | 4147 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
27c05d4d | 4148 | } else if (strmatch(type, "extended")) { |
d62a17ae | 4149 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); |
27c05d4d | 4150 | } else if (strmatch(type, "large")) { |
d62a17ae | 4151 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); |
27c05d4d | 4152 | } else if (strmatch(type, "both")) { |
d62a17ae | 4153 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4154 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
27c05d4d | 4155 | } else { /* if (strmatch(type, "all")) */ |
d62a17ae | 4156 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4157 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4158 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4159 | } | |
4160 | ||
27c05d4d | 4161 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
d62a17ae | 4162 | bgp_node_safi(vty), flag); |
4163 | } | |
4164 | ||
4165 | ALIAS_HIDDEN( | |
4166 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
4167 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4168 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4169 | "Send Community attribute to this neighbor\n" | |
4170 | "Send Standard and Extended Community attributes\n" | |
4171 | "Send Standard, Large and Extended Community attributes\n" | |
4172 | "Send Extended Community attributes\n" | |
4173 | "Send Standard Community attributes\n" | |
4174 | "Send Large Community attributes\n") | |
596c17ba | 4175 | |
718e3744 | 4176 | DEFUN (no_neighbor_send_community_type, |
4177 | no_neighbor_send_community_type_cmd, | |
57d187bc | 4178 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4179 | NO_STR |
4180 | NEIGHBOR_STR | |
4181 | NEIGHBOR_ADDR_STR2 | |
4182 | "Send Community attribute to this neighbor\n" | |
4183 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4184 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4185 | "Send Extended Community attributes\n" |
57d187bc JS |
4186 | "Send Standard Community attributes\n" |
4187 | "Send Large Community attributes\n") | |
718e3744 | 4188 | { |
d62a17ae | 4189 | int idx_peer = 2; |
27c05d4d | 4190 | uint32_t flag = 0; |
d62a17ae | 4191 | const char *type = argv[argc - 1]->text; |
4192 | ||
27c05d4d PM |
4193 | if (strmatch(type, "standard")) { |
4194 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4195 | } else if (strmatch(type, "extended")) { | |
4196 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4197 | } else if (strmatch(type, "large")) { | |
4198 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4199 | } else if (strmatch(type, "both")) { | |
4200 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4201 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4202 | } else { /* if (strmatch(type, "all")) */ | |
4203 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4204 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4205 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4206 | } | |
4207 | ||
4208 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4209 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4210 | flag); | |
d62a17ae | 4211 | } |
4212 | ||
4213 | ALIAS_HIDDEN( | |
4214 | no_neighbor_send_community_type, | |
4215 | no_neighbor_send_community_type_hidden_cmd, | |
4216 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4217 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4218 | "Send Community attribute to this neighbor\n" | |
4219 | "Send Standard and Extended Community attributes\n" | |
4220 | "Send Standard, Large and Extended Community attributes\n" | |
4221 | "Send Extended Community attributes\n" | |
4222 | "Send Standard Community attributes\n" | |
4223 | "Send Large Community attributes\n") | |
596c17ba | 4224 | |
718e3744 | 4225 | /* neighbor soft-reconfig. */ |
4226 | DEFUN (neighbor_soft_reconfiguration, | |
4227 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4228 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4229 | NEIGHBOR_STR |
4230 | NEIGHBOR_ADDR_STR2 | |
4231 | "Per neighbor soft reconfiguration\n" | |
4232 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4233 | { | |
d62a17ae | 4234 | int idx_peer = 1; |
4235 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4236 | bgp_node_safi(vty), | |
4237 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4238 | } |
4239 | ||
d62a17ae | 4240 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
4241 | neighbor_soft_reconfiguration_hidden_cmd, | |
4242 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4243 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4244 | "Per neighbor soft reconfiguration\n" | |
4245 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4246 | |
718e3744 | 4247 | DEFUN (no_neighbor_soft_reconfiguration, |
4248 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4249 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4250 | NO_STR |
4251 | NEIGHBOR_STR | |
4252 | NEIGHBOR_ADDR_STR2 | |
4253 | "Per neighbor soft reconfiguration\n" | |
4254 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4255 | { | |
d62a17ae | 4256 | int idx_peer = 2; |
4257 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4258 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4259 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4260 | } |
6b0655a2 | 4261 | |
d62a17ae | 4262 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
4263 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
4264 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4265 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4266 | "Per neighbor soft reconfiguration\n" | |
4267 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4268 | |
718e3744 | 4269 | DEFUN (neighbor_route_reflector_client, |
4270 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4271 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4272 | NEIGHBOR_STR |
4273 | NEIGHBOR_ADDR_STR2 | |
4274 | "Configure a neighbor as Route Reflector client\n") | |
4275 | { | |
d62a17ae | 4276 | int idx_peer = 1; |
4277 | struct peer *peer; | |
718e3744 | 4278 | |
4279 | ||
d62a17ae | 4280 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4281 | if (!peer) | |
4282 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4283 | |
d62a17ae | 4284 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4285 | bgp_node_safi(vty), | |
4286 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4287 | } |
4288 | ||
d62a17ae | 4289 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
4290 | neighbor_route_reflector_client_hidden_cmd, | |
4291 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4292 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4293 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4294 | |
718e3744 | 4295 | DEFUN (no_neighbor_route_reflector_client, |
4296 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4297 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4298 | NO_STR |
4299 | NEIGHBOR_STR | |
4300 | NEIGHBOR_ADDR_STR2 | |
4301 | "Configure a neighbor as Route Reflector client\n") | |
4302 | { | |
d62a17ae | 4303 | int idx_peer = 2; |
4304 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4305 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4306 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4307 | } |
6b0655a2 | 4308 | |
d62a17ae | 4309 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
4310 | no_neighbor_route_reflector_client_hidden_cmd, | |
4311 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4312 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4313 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4314 | |
718e3744 | 4315 | /* neighbor route-server-client. */ |
4316 | DEFUN (neighbor_route_server_client, | |
4317 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 4318 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4319 | NEIGHBOR_STR |
4320 | NEIGHBOR_ADDR_STR2 | |
4321 | "Configure a neighbor as Route Server client\n") | |
4322 | { | |
d62a17ae | 4323 | int idx_peer = 1; |
4324 | struct peer *peer; | |
2a3d5731 | 4325 | |
d62a17ae | 4326 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4327 | if (!peer) | |
4328 | return CMD_WARNING_CONFIG_FAILED; | |
4329 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4330 | bgp_node_safi(vty), | |
4331 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 4332 | } |
4333 | ||
d62a17ae | 4334 | ALIAS_HIDDEN(neighbor_route_server_client, |
4335 | neighbor_route_server_client_hidden_cmd, | |
4336 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4337 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4338 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4339 | |
718e3744 | 4340 | DEFUN (no_neighbor_route_server_client, |
4341 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 4342 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4343 | NO_STR |
4344 | NEIGHBOR_STR | |
4345 | NEIGHBOR_ADDR_STR2 | |
4346 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 4347 | { |
d62a17ae | 4348 | int idx_peer = 2; |
4349 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4350 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4351 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 4352 | } |
6b0655a2 | 4353 | |
d62a17ae | 4354 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
4355 | no_neighbor_route_server_client_hidden_cmd, | |
4356 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4357 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4358 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4359 | |
fee0f4c6 | 4360 | DEFUN (neighbor_nexthop_local_unchanged, |
4361 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4362 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4363 | NEIGHBOR_STR |
4364 | NEIGHBOR_ADDR_STR2 | |
4365 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
4366 | "Leave link-local nexthop unchanged for this peer\n") | |
4367 | { | |
d62a17ae | 4368 | int idx_peer = 1; |
4369 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4370 | bgp_node_safi(vty), | |
4371 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 4372 | } |
6b0655a2 | 4373 | |
fee0f4c6 | 4374 | DEFUN (no_neighbor_nexthop_local_unchanged, |
4375 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4376 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4377 | NO_STR |
4378 | NEIGHBOR_STR | |
4379 | NEIGHBOR_ADDR_STR2 | |
4380 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
4381 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 4382 | { |
d62a17ae | 4383 | int idx_peer = 2; |
4384 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4385 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4386 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 4387 | } |
6b0655a2 | 4388 | |
718e3744 | 4389 | DEFUN (neighbor_attr_unchanged, |
4390 | neighbor_attr_unchanged_cmd, | |
a8206004 | 4391 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
718e3744 | 4392 | NEIGHBOR_STR |
4393 | NEIGHBOR_ADDR_STR2 | |
4394 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4395 | "As-path attribute\n" | |
4396 | "Nexthop attribute\n" | |
a8206004 | 4397 | "Med attribute\n") |
718e3744 | 4398 | { |
d62a17ae | 4399 | int idx = 0; |
8eeb0335 DW |
4400 | char *peer_str = argv[1]->arg; |
4401 | struct peer *peer; | |
d7c0a89a | 4402 | uint16_t flags = 0; |
8eeb0335 DW |
4403 | afi_t afi = bgp_node_afi(vty); |
4404 | safi_t safi = bgp_node_safi(vty); | |
4405 | ||
4406 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
4407 | if (!peer) | |
4408 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4409 | |
4410 | if (argv_find(argv, argc, "as-path", &idx)) | |
4411 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4412 | idx = 0; | |
4413 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4414 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4415 | idx = 0; | |
4416 | if (argv_find(argv, argc, "med", &idx)) | |
4417 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4418 | ||
8eeb0335 DW |
4419 | /* no flags means all of them! */ |
4420 | if (!flags) { | |
d62a17ae | 4421 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); |
4422 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4423 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 | 4424 | } else { |
a4d82a8a PZ |
4425 | if (!CHECK_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED) |
4426 | && peer_af_flag_check(peer, afi, safi, | |
4427 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
8eeb0335 DW |
4428 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4429 | PEER_FLAG_AS_PATH_UNCHANGED); | |
4430 | } | |
4431 | ||
a4d82a8a PZ |
4432 | if (!CHECK_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED) |
4433 | && peer_af_flag_check(peer, afi, safi, | |
4434 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
8eeb0335 DW |
4435 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4436 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
4437 | } | |
4438 | ||
a4d82a8a PZ |
4439 | if (!CHECK_FLAG(flags, PEER_FLAG_MED_UNCHANGED) |
4440 | && peer_af_flag_check(peer, afi, safi, | |
4441 | PEER_FLAG_MED_UNCHANGED)) { | |
8eeb0335 DW |
4442 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4443 | PEER_FLAG_MED_UNCHANGED); | |
4444 | } | |
d62a17ae | 4445 | } |
4446 | ||
8eeb0335 | 4447 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, flags); |
d62a17ae | 4448 | } |
4449 | ||
4450 | ALIAS_HIDDEN( | |
4451 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
4452 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4453 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4454 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4455 | "As-path attribute\n" | |
4456 | "Nexthop attribute\n" | |
4457 | "Med attribute\n") | |
596c17ba | 4458 | |
718e3744 | 4459 | DEFUN (no_neighbor_attr_unchanged, |
4460 | no_neighbor_attr_unchanged_cmd, | |
a8206004 | 4461 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
e52702f2 | 4462 | NO_STR |
718e3744 | 4463 | NEIGHBOR_STR |
4464 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
4465 | "BGP attribute is propagated unchanged to this neighbor\n" |
4466 | "As-path attribute\n" | |
40e718b5 | 4467 | "Nexthop attribute\n" |
a8206004 | 4468 | "Med attribute\n") |
718e3744 | 4469 | { |
d62a17ae | 4470 | int idx = 0; |
4471 | char *peer = argv[2]->arg; | |
d7c0a89a | 4472 | uint16_t flags = 0; |
d62a17ae | 4473 | |
4474 | if (argv_find(argv, argc, "as-path", &idx)) | |
4475 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4476 | idx = 0; | |
4477 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4478 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4479 | idx = 0; | |
4480 | if (argv_find(argv, argc, "med", &idx)) | |
4481 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4482 | ||
4483 | if (!flags) // no flags means all of them! | |
4484 | { | |
4485 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4486 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4487 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4488 | } | |
4489 | ||
4490 | return peer_af_flag_unset_vty(vty, peer, bgp_node_afi(vty), | |
4491 | bgp_node_safi(vty), flags); | |
4492 | } | |
4493 | ||
4494 | ALIAS_HIDDEN( | |
4495 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
4496 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4497 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4498 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4499 | "As-path attribute\n" | |
4500 | "Nexthop attribute\n" | |
4501 | "Med attribute\n") | |
718e3744 | 4502 | |
718e3744 | 4503 | /* EBGP multihop configuration. */ |
d62a17ae | 4504 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, |
4505 | const char *ttl_str) | |
718e3744 | 4506 | { |
d62a17ae | 4507 | struct peer *peer; |
4508 | unsigned int ttl; | |
718e3744 | 4509 | |
d62a17ae | 4510 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4511 | if (!peer) | |
4512 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4513 | |
d62a17ae | 4514 | if (peer->conf_if) |
4515 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
63fa10b5 | 4516 | |
d62a17ae | 4517 | if (!ttl_str) |
4518 | ttl = MAXTTL; | |
4519 | else | |
4520 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 4521 | |
d62a17ae | 4522 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 4523 | } |
4524 | ||
d62a17ae | 4525 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 4526 | { |
d62a17ae | 4527 | struct peer *peer; |
718e3744 | 4528 | |
d62a17ae | 4529 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4530 | if (!peer) | |
4531 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4532 | |
d62a17ae | 4533 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 4534 | } |
4535 | ||
4536 | /* neighbor ebgp-multihop. */ | |
4537 | DEFUN (neighbor_ebgp_multihop, | |
4538 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 4539 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 4540 | NEIGHBOR_STR |
4541 | NEIGHBOR_ADDR_STR2 | |
4542 | "Allow EBGP neighbors not on directly connected networks\n") | |
4543 | { | |
d62a17ae | 4544 | int idx_peer = 1; |
4545 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4546 | } |
4547 | ||
4548 | DEFUN (neighbor_ebgp_multihop_ttl, | |
4549 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 4550 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 4551 | NEIGHBOR_STR |
4552 | NEIGHBOR_ADDR_STR2 | |
4553 | "Allow EBGP neighbors not on directly connected networks\n" | |
4554 | "maximum hop count\n") | |
4555 | { | |
d62a17ae | 4556 | int idx_peer = 1; |
4557 | int idx_number = 3; | |
4558 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
4559 | argv[idx_number]->arg); | |
718e3744 | 4560 | } |
4561 | ||
4562 | DEFUN (no_neighbor_ebgp_multihop, | |
4563 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 4564 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 4565 | NO_STR |
4566 | NEIGHBOR_STR | |
4567 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4568 | "Allow EBGP neighbors not on directly connected networks\n" |
4569 | "maximum hop count\n") | |
718e3744 | 4570 | { |
d62a17ae | 4571 | int idx_peer = 2; |
4572 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 4573 | } |
4574 | ||
6b0655a2 | 4575 | |
6ffd2079 | 4576 | /* disable-connected-check */ |
4577 | DEFUN (neighbor_disable_connected_check, | |
4578 | neighbor_disable_connected_check_cmd, | |
7ebe625c | 4579 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4580 | NEIGHBOR_STR |
7ebe625c | 4581 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
4582 | "one-hop away EBGP peer using loopback address\n" |
4583 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4584 | { |
d62a17ae | 4585 | int idx_peer = 1; |
4586 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4587 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4588 | } |
4589 | ||
4590 | DEFUN (no_neighbor_disable_connected_check, | |
4591 | no_neighbor_disable_connected_check_cmd, | |
7ebe625c | 4592 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4593 | NO_STR |
4594 | NEIGHBOR_STR | |
7ebe625c | 4595 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
4596 | "one-hop away EBGP peer using loopback address\n" |
4597 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4598 | { |
d62a17ae | 4599 | int idx_peer = 2; |
4600 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4601 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4602 | } |
4603 | ||
47cbc09b PM |
4604 | |
4605 | /* enforce-first-as */ | |
4606 | DEFUN (neighbor_enforce_first_as, | |
4607 | neighbor_enforce_first_as_cmd, | |
4608 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
4609 | NEIGHBOR_STR | |
4610 | NEIGHBOR_ADDR_STR2 | |
4611 | "Enforce the first AS for EBGP routes\n") | |
4612 | { | |
4613 | int idx_peer = 1; | |
4614 | ||
4615 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4616 | PEER_FLAG_ENFORCE_FIRST_AS); | |
4617 | } | |
4618 | ||
4619 | DEFUN (no_neighbor_enforce_first_as, | |
4620 | no_neighbor_enforce_first_as_cmd, | |
4621 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
4622 | NO_STR | |
4623 | NEIGHBOR_STR | |
4624 | NEIGHBOR_ADDR_STR2 | |
4625 | "Enforce the first AS for EBGP routes\n") | |
4626 | { | |
4627 | int idx_peer = 2; | |
4628 | ||
4629 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4630 | PEER_FLAG_ENFORCE_FIRST_AS); | |
4631 | } | |
4632 | ||
4633 | ||
718e3744 | 4634 | DEFUN (neighbor_description, |
4635 | neighbor_description_cmd, | |
e961923c | 4636 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 4637 | NEIGHBOR_STR |
4638 | NEIGHBOR_ADDR_STR2 | |
4639 | "Neighbor specific description\n" | |
4640 | "Up to 80 characters describing this neighbor\n") | |
4641 | { | |
d62a17ae | 4642 | int idx_peer = 1; |
4643 | int idx_line = 3; | |
4644 | struct peer *peer; | |
4645 | char *str; | |
718e3744 | 4646 | |
d62a17ae | 4647 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4648 | if (!peer) | |
4649 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4650 | |
d62a17ae | 4651 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 4652 | |
d62a17ae | 4653 | peer_description_set(peer, str); |
718e3744 | 4654 | |
d62a17ae | 4655 | XFREE(MTYPE_TMP, str); |
718e3744 | 4656 | |
d62a17ae | 4657 | return CMD_SUCCESS; |
718e3744 | 4658 | } |
4659 | ||
4660 | DEFUN (no_neighbor_description, | |
4661 | no_neighbor_description_cmd, | |
a14810f4 | 4662 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", |
718e3744 | 4663 | NO_STR |
4664 | NEIGHBOR_STR | |
4665 | NEIGHBOR_ADDR_STR2 | |
a14810f4 | 4666 | "Neighbor specific description\n") |
718e3744 | 4667 | { |
d62a17ae | 4668 | int idx_peer = 2; |
4669 | struct peer *peer; | |
718e3744 | 4670 | |
d62a17ae | 4671 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4672 | if (!peer) | |
4673 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4674 | |
d62a17ae | 4675 | peer_description_unset(peer); |
718e3744 | 4676 | |
d62a17ae | 4677 | return CMD_SUCCESS; |
718e3744 | 4678 | } |
4679 | ||
a14810f4 PM |
4680 | ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd, |
4681 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
4682 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4683 | "Neighbor specific description\n" | |
4684 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 4685 | |
718e3744 | 4686 | /* Neighbor update-source. */ |
d62a17ae | 4687 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, |
4688 | const char *source_str) | |
4689 | { | |
4690 | struct peer *peer; | |
4691 | struct prefix p; | |
a14810f4 | 4692 | union sockunion su; |
d62a17ae | 4693 | |
4694 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
4695 | if (!peer) | |
4696 | return CMD_WARNING_CONFIG_FAILED; | |
4697 | ||
4698 | if (peer->conf_if) | |
4699 | return CMD_WARNING; | |
4700 | ||
4701 | if (source_str) { | |
a14810f4 | 4702 | if (str2sockunion(source_str, &su) == 0) |
d62a17ae | 4703 | peer_update_source_addr_set(peer, &su); |
4704 | else { | |
4705 | if (str2prefix(source_str, &p)) { | |
4706 | vty_out(vty, | |
4707 | "%% Invalid update-source, remove prefix length \n"); | |
4708 | return CMD_WARNING_CONFIG_FAILED; | |
4709 | } else | |
4710 | peer_update_source_if_set(peer, source_str); | |
4711 | } | |
4712 | } else | |
4713 | peer_update_source_unset(peer); | |
4714 | ||
4715 | return CMD_SUCCESS; | |
4716 | } | |
4717 | ||
4718 | #define BGP_UPDATE_SOURCE_HELP_STR \ | |
4719 | "IPv4 address\n" \ | |
4720 | "IPv6 address\n" \ | |
4721 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 4722 | |
718e3744 | 4723 | DEFUN (neighbor_update_source, |
4724 | neighbor_update_source_cmd, | |
9ccf14f7 | 4725 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 4726 | NEIGHBOR_STR |
4727 | NEIGHBOR_ADDR_STR2 | |
4728 | "Source of routing updates\n" | |
369688c0 | 4729 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 4730 | { |
d62a17ae | 4731 | int idx_peer = 1; |
4732 | int idx_peer_2 = 3; | |
4733 | return peer_update_source_vty(vty, argv[idx_peer]->arg, | |
4734 | argv[idx_peer_2]->arg); | |
718e3744 | 4735 | } |
4736 | ||
4737 | DEFUN (no_neighbor_update_source, | |
4738 | no_neighbor_update_source_cmd, | |
c7178fe7 | 4739 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 4740 | NO_STR |
4741 | NEIGHBOR_STR | |
4742 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
4743 | "Source of routing updates\n" |
4744 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 4745 | { |
d62a17ae | 4746 | int idx_peer = 2; |
4747 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4748 | } |
6b0655a2 | 4749 | |
d62a17ae | 4750 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
4751 | afi_t afi, safi_t safi, | |
4752 | const char *rmap, int set) | |
718e3744 | 4753 | { |
d62a17ae | 4754 | int ret; |
4755 | struct peer *peer; | |
718e3744 | 4756 | |
d62a17ae | 4757 | peer = peer_and_group_lookup_vty(vty, peer_str); |
4758 | if (!peer) | |
4759 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4760 | |
d62a17ae | 4761 | if (set) |
4762 | ret = peer_default_originate_set(peer, afi, safi, rmap); | |
4763 | else | |
4764 | ret = peer_default_originate_unset(peer, afi, safi); | |
718e3744 | 4765 | |
d62a17ae | 4766 | return bgp_vty_return(vty, ret); |
718e3744 | 4767 | } |
4768 | ||
4769 | /* neighbor default-originate. */ | |
4770 | DEFUN (neighbor_default_originate, | |
4771 | neighbor_default_originate_cmd, | |
9ccf14f7 | 4772 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 4773 | NEIGHBOR_STR |
4774 | NEIGHBOR_ADDR_STR2 | |
4775 | "Originate default route to this neighbor\n") | |
4776 | { | |
d62a17ae | 4777 | int idx_peer = 1; |
4778 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
4779 | bgp_node_afi(vty), | |
4780 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 4781 | } |
4782 | ||
d62a17ae | 4783 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
4784 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
4785 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4786 | "Originate default route to this neighbor\n") | |
596c17ba | 4787 | |
718e3744 | 4788 | DEFUN (neighbor_default_originate_rmap, |
4789 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 4790 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 4791 | NEIGHBOR_STR |
4792 | NEIGHBOR_ADDR_STR2 | |
4793 | "Originate default route to this neighbor\n" | |
4794 | "Route-map to specify criteria to originate default\n" | |
4795 | "route-map name\n") | |
4796 | { | |
d62a17ae | 4797 | int idx_peer = 1; |
4798 | int idx_word = 4; | |
4799 | return peer_default_originate_set_vty( | |
4800 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
4801 | argv[idx_word]->arg, 1); | |
718e3744 | 4802 | } |
4803 | ||
d62a17ae | 4804 | ALIAS_HIDDEN( |
4805 | neighbor_default_originate_rmap, | |
4806 | neighbor_default_originate_rmap_hidden_cmd, | |
4807 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
4808 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4809 | "Originate default route to this neighbor\n" | |
4810 | "Route-map to specify criteria to originate default\n" | |
4811 | "route-map name\n") | |
596c17ba | 4812 | |
718e3744 | 4813 | DEFUN (no_neighbor_default_originate, |
4814 | no_neighbor_default_originate_cmd, | |
a636c635 | 4815 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 4816 | NO_STR |
4817 | NEIGHBOR_STR | |
4818 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4819 | "Originate default route to this neighbor\n" |
4820 | "Route-map to specify criteria to originate default\n" | |
4821 | "route-map name\n") | |
718e3744 | 4822 | { |
d62a17ae | 4823 | int idx_peer = 2; |
4824 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
4825 | bgp_node_afi(vty), | |
4826 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 4827 | } |
4828 | ||
d62a17ae | 4829 | ALIAS_HIDDEN( |
4830 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
4831 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
4832 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4833 | "Originate default route to this neighbor\n" | |
4834 | "Route-map to specify criteria to originate default\n" | |
4835 | "route-map name\n") | |
596c17ba | 4836 | |
6b0655a2 | 4837 | |
718e3744 | 4838 | /* Set neighbor's BGP port. */ |
d62a17ae | 4839 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, |
4840 | const char *port_str) | |
4841 | { | |
4842 | struct peer *peer; | |
d7c0a89a | 4843 | uint16_t port; |
d62a17ae | 4844 | struct servent *sp; |
4845 | ||
4846 | peer = peer_lookup_vty(vty, ip_str); | |
4847 | if (!peer) | |
4848 | return CMD_WARNING_CONFIG_FAILED; | |
4849 | ||
4850 | if (!port_str) { | |
4851 | sp = getservbyname("bgp", "tcp"); | |
4852 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
4853 | } else { | |
4854 | port = strtoul(port_str, NULL, 10); | |
4855 | } | |
718e3744 | 4856 | |
d62a17ae | 4857 | peer_port_set(peer, port); |
718e3744 | 4858 | |
d62a17ae | 4859 | return CMD_SUCCESS; |
718e3744 | 4860 | } |
4861 | ||
f418446b | 4862 | /* Set specified peer's BGP port. */ |
718e3744 | 4863 | DEFUN (neighbor_port, |
4864 | neighbor_port_cmd, | |
9ccf14f7 | 4865 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 4866 | NEIGHBOR_STR |
4867 | NEIGHBOR_ADDR_STR | |
4868 | "Neighbor's BGP port\n" | |
4869 | "TCP port number\n") | |
4870 | { | |
d62a17ae | 4871 | int idx_ip = 1; |
4872 | int idx_number = 3; | |
4873 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
4874 | argv[idx_number]->arg); | |
718e3744 | 4875 | } |
4876 | ||
4877 | DEFUN (no_neighbor_port, | |
4878 | no_neighbor_port_cmd, | |
9ccf14f7 | 4879 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 4880 | NO_STR |
4881 | NEIGHBOR_STR | |
4882 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
4883 | "Neighbor's BGP port\n" |
4884 | "TCP port number\n") | |
718e3744 | 4885 | { |
d62a17ae | 4886 | int idx_ip = 2; |
4887 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 4888 | } |
4889 | ||
6b0655a2 | 4890 | |
718e3744 | 4891 | /* neighbor weight. */ |
d62a17ae | 4892 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
4893 | safi_t safi, const char *weight_str) | |
718e3744 | 4894 | { |
d62a17ae | 4895 | int ret; |
4896 | struct peer *peer; | |
4897 | unsigned long weight; | |
718e3744 | 4898 | |
d62a17ae | 4899 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4900 | if (!peer) | |
4901 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4902 | |
d62a17ae | 4903 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 4904 | |
d62a17ae | 4905 | ret = peer_weight_set(peer, afi, safi, weight); |
4906 | return bgp_vty_return(vty, ret); | |
718e3744 | 4907 | } |
4908 | ||
d62a17ae | 4909 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
4910 | safi_t safi) | |
718e3744 | 4911 | { |
d62a17ae | 4912 | int ret; |
4913 | struct peer *peer; | |
718e3744 | 4914 | |
d62a17ae | 4915 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4916 | if (!peer) | |
4917 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4918 | |
d62a17ae | 4919 | ret = peer_weight_unset(peer, afi, safi); |
4920 | return bgp_vty_return(vty, ret); | |
718e3744 | 4921 | } |
4922 | ||
4923 | DEFUN (neighbor_weight, | |
4924 | neighbor_weight_cmd, | |
9ccf14f7 | 4925 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 4926 | NEIGHBOR_STR |
4927 | NEIGHBOR_ADDR_STR2 | |
4928 | "Set default weight for routes from this neighbor\n" | |
4929 | "default weight\n") | |
4930 | { | |
d62a17ae | 4931 | int idx_peer = 1; |
4932 | int idx_number = 3; | |
4933 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4934 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 4935 | } |
4936 | ||
d62a17ae | 4937 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
4938 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
4939 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4940 | "Set default weight for routes from this neighbor\n" | |
4941 | "default weight\n") | |
596c17ba | 4942 | |
718e3744 | 4943 | DEFUN (no_neighbor_weight, |
4944 | no_neighbor_weight_cmd, | |
9ccf14f7 | 4945 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 4946 | NO_STR |
4947 | NEIGHBOR_STR | |
4948 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
4949 | "Set default weight for routes from this neighbor\n" |
4950 | "default weight\n") | |
718e3744 | 4951 | { |
d62a17ae | 4952 | int idx_peer = 2; |
4953 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, | |
4954 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 4955 | } |
4956 | ||
d62a17ae | 4957 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
4958 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
4959 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4960 | "Set default weight for routes from this neighbor\n" | |
4961 | "default weight\n") | |
596c17ba | 4962 | |
6b0655a2 | 4963 | |
718e3744 | 4964 | /* Override capability negotiation. */ |
4965 | DEFUN (neighbor_override_capability, | |
4966 | neighbor_override_capability_cmd, | |
9ccf14f7 | 4967 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 4968 | NEIGHBOR_STR |
4969 | NEIGHBOR_ADDR_STR2 | |
4970 | "Override capability negotiation result\n") | |
4971 | { | |
d62a17ae | 4972 | int idx_peer = 1; |
4973 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4974 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 4975 | } |
4976 | ||
4977 | DEFUN (no_neighbor_override_capability, | |
4978 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 4979 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 4980 | NO_STR |
4981 | NEIGHBOR_STR | |
4982 | NEIGHBOR_ADDR_STR2 | |
4983 | "Override capability negotiation result\n") | |
4984 | { | |
d62a17ae | 4985 | int idx_peer = 2; |
4986 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4987 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 4988 | } |
6b0655a2 | 4989 | |
718e3744 | 4990 | DEFUN (neighbor_strict_capability, |
4991 | neighbor_strict_capability_cmd, | |
9fb964de | 4992 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 4993 | NEIGHBOR_STR |
9fb964de | 4994 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4995 | "Strict capability negotiation match\n") |
4996 | { | |
9fb964de PM |
4997 | int idx_peer = 1; |
4998 | ||
4999 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5000 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5001 | } |
5002 | ||
5003 | DEFUN (no_neighbor_strict_capability, | |
5004 | no_neighbor_strict_capability_cmd, | |
9fb964de | 5005 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5006 | NO_STR |
5007 | NEIGHBOR_STR | |
9fb964de | 5008 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5009 | "Strict capability negotiation match\n") |
5010 | { | |
9fb964de PM |
5011 | int idx_peer = 2; |
5012 | ||
5013 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5014 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5015 | } |
6b0655a2 | 5016 | |
d62a17ae | 5017 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
5018 | const char *keep_str, const char *hold_str) | |
718e3744 | 5019 | { |
d62a17ae | 5020 | int ret; |
5021 | struct peer *peer; | |
d7c0a89a QY |
5022 | uint32_t keepalive; |
5023 | uint32_t holdtime; | |
718e3744 | 5024 | |
d62a17ae | 5025 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5026 | if (!peer) | |
5027 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5028 | |
d62a17ae | 5029 | keepalive = strtoul(keep_str, NULL, 10); |
5030 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 5031 | |
d62a17ae | 5032 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 5033 | |
d62a17ae | 5034 | return bgp_vty_return(vty, ret); |
718e3744 | 5035 | } |
6b0655a2 | 5036 | |
d62a17ae | 5037 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5038 | { |
d62a17ae | 5039 | int ret; |
5040 | struct peer *peer; | |
718e3744 | 5041 | |
d62a17ae | 5042 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5043 | if (!peer) | |
5044 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5045 | |
d62a17ae | 5046 | ret = peer_timers_unset(peer); |
718e3744 | 5047 | |
d62a17ae | 5048 | return bgp_vty_return(vty, ret); |
718e3744 | 5049 | } |
5050 | ||
5051 | DEFUN (neighbor_timers, | |
5052 | neighbor_timers_cmd, | |
9ccf14f7 | 5053 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 5054 | NEIGHBOR_STR |
5055 | NEIGHBOR_ADDR_STR2 | |
5056 | "BGP per neighbor timers\n" | |
5057 | "Keepalive interval\n" | |
5058 | "Holdtime\n") | |
5059 | { | |
d62a17ae | 5060 | int idx_peer = 1; |
5061 | int idx_number = 3; | |
5062 | int idx_number_2 = 4; | |
5063 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
5064 | argv[idx_number]->arg, | |
5065 | argv[idx_number_2]->arg); | |
718e3744 | 5066 | } |
5067 | ||
5068 | DEFUN (no_neighbor_timers, | |
5069 | no_neighbor_timers_cmd, | |
9ccf14f7 | 5070 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 5071 | NO_STR |
5072 | NEIGHBOR_STR | |
5073 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5074 | "BGP per neighbor timers\n" |
5075 | "Keepalive interval\n" | |
5076 | "Holdtime\n") | |
718e3744 | 5077 | { |
d62a17ae | 5078 | int idx_peer = 2; |
5079 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5080 | } |
6b0655a2 | 5081 | |
813d4307 | 5082 | |
d62a17ae | 5083 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, |
5084 | const char *time_str) | |
718e3744 | 5085 | { |
d62a17ae | 5086 | int ret; |
5087 | struct peer *peer; | |
d7c0a89a | 5088 | uint32_t connect; |
718e3744 | 5089 | |
d62a17ae | 5090 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5091 | if (!peer) | |
5092 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5093 | |
d62a17ae | 5094 | connect = strtoul(time_str, NULL, 10); |
718e3744 | 5095 | |
d62a17ae | 5096 | ret = peer_timers_connect_set(peer, connect); |
718e3744 | 5097 | |
d62a17ae | 5098 | return bgp_vty_return(vty, ret); |
718e3744 | 5099 | } |
5100 | ||
d62a17ae | 5101 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5102 | { |
d62a17ae | 5103 | int ret; |
5104 | struct peer *peer; | |
718e3744 | 5105 | |
d62a17ae | 5106 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5107 | if (!peer) | |
5108 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5109 | |
d62a17ae | 5110 | ret = peer_timers_connect_unset(peer); |
718e3744 | 5111 | |
d62a17ae | 5112 | return bgp_vty_return(vty, ret); |
718e3744 | 5113 | } |
5114 | ||
5115 | DEFUN (neighbor_timers_connect, | |
5116 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 5117 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 5118 | NEIGHBOR_STR |
966f821c | 5119 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5120 | "BGP per neighbor timers\n" |
5121 | "BGP connect timer\n" | |
5122 | "Connect timer\n") | |
5123 | { | |
d62a17ae | 5124 | int idx_peer = 1; |
5125 | int idx_number = 4; | |
5126 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
5127 | argv[idx_number]->arg); | |
718e3744 | 5128 | } |
5129 | ||
5130 | DEFUN (no_neighbor_timers_connect, | |
5131 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 5132 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 5133 | NO_STR |
5134 | NEIGHBOR_STR | |
966f821c | 5135 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5136 | "BGP per neighbor timers\n" |
8334fd5a DW |
5137 | "BGP connect timer\n" |
5138 | "Connect timer\n") | |
718e3744 | 5139 | { |
d62a17ae | 5140 | int idx_peer = 2; |
5141 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5142 | } |
5143 | ||
6b0655a2 | 5144 | |
d62a17ae | 5145 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
5146 | const char *time_str, int set) | |
718e3744 | 5147 | { |
d62a17ae | 5148 | int ret; |
5149 | struct peer *peer; | |
d7c0a89a | 5150 | uint32_t routeadv = 0; |
718e3744 | 5151 | |
d62a17ae | 5152 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5153 | if (!peer) | |
5154 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5155 | |
d62a17ae | 5156 | if (time_str) |
5157 | routeadv = strtoul(time_str, NULL, 10); | |
718e3744 | 5158 | |
d62a17ae | 5159 | if (set) |
5160 | ret = peer_advertise_interval_set(peer, routeadv); | |
5161 | else | |
5162 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 5163 | |
d62a17ae | 5164 | return bgp_vty_return(vty, ret); |
718e3744 | 5165 | } |
5166 | ||
5167 | DEFUN (neighbor_advertise_interval, | |
5168 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5169 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 5170 | NEIGHBOR_STR |
966f821c | 5171 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5172 | "Minimum interval between sending BGP routing updates\n" |
5173 | "time in seconds\n") | |
5174 | { | |
d62a17ae | 5175 | int idx_peer = 1; |
5176 | int idx_number = 3; | |
5177 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
5178 | argv[idx_number]->arg, 1); | |
718e3744 | 5179 | } |
5180 | ||
5181 | DEFUN (no_neighbor_advertise_interval, | |
5182 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5183 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 5184 | NO_STR |
5185 | NEIGHBOR_STR | |
966f821c | 5186 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
5187 | "Minimum interval between sending BGP routing updates\n" |
5188 | "time in seconds\n") | |
718e3744 | 5189 | { |
d62a17ae | 5190 | int idx_peer = 2; |
5191 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 5192 | } |
5193 | ||
6b0655a2 | 5194 | |
518f0eb1 DS |
5195 | /* Time to wait before processing route-map updates */ |
5196 | DEFUN (bgp_set_route_map_delay_timer, | |
5197 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 5198 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
5199 | SET_STR |
5200 | "BGP route-map delay timer\n" | |
5201 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 5202 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 5203 | { |
d62a17ae | 5204 | int idx_number = 3; |
d7c0a89a | 5205 | uint32_t rmap_delay_timer; |
d62a17ae | 5206 | |
5207 | if (argv[idx_number]->arg) { | |
5208 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
5209 | bm->rmap_update_timer = rmap_delay_timer; | |
5210 | ||
5211 | /* if the dynamic update handling is being disabled, and a timer | |
5212 | * is | |
5213 | * running, stop the timer and act as if the timer has already | |
5214 | * fired. | |
5215 | */ | |
5216 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
5217 | BGP_TIMER_OFF(bm->t_rmap_update); | |
5218 | thread_execute(bm->master, bgp_route_map_update_timer, | |
5219 | NULL, 0); | |
5220 | } | |
5221 | return CMD_SUCCESS; | |
5222 | } else { | |
5223 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
5224 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 5225 | } |
518f0eb1 DS |
5226 | } |
5227 | ||
5228 | DEFUN (no_bgp_set_route_map_delay_timer, | |
5229 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 5230 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 5231 | NO_STR |
3a2d747c | 5232 | BGP_STR |
518f0eb1 | 5233 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
5234 | "Reset to default time to wait for processing route-map changes\n" |
5235 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 5236 | { |
518f0eb1 | 5237 | |
d62a17ae | 5238 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 5239 | |
d62a17ae | 5240 | return CMD_SUCCESS; |
518f0eb1 DS |
5241 | } |
5242 | ||
f414725f | 5243 | |
718e3744 | 5244 | /* neighbor interface */ |
d62a17ae | 5245 | static int peer_interface_vty(struct vty *vty, const char *ip_str, |
5246 | const char *str) | |
718e3744 | 5247 | { |
d62a17ae | 5248 | struct peer *peer; |
718e3744 | 5249 | |
d62a17ae | 5250 | peer = peer_lookup_vty(vty, ip_str); |
5251 | if (!peer || peer->conf_if) { | |
5252 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
5253 | return CMD_WARNING_CONFIG_FAILED; | |
5254 | } | |
718e3744 | 5255 | |
d62a17ae | 5256 | if (str) |
5257 | peer_interface_set(peer, str); | |
5258 | else | |
5259 | peer_interface_unset(peer); | |
718e3744 | 5260 | |
d62a17ae | 5261 | return CMD_SUCCESS; |
718e3744 | 5262 | } |
5263 | ||
5264 | DEFUN (neighbor_interface, | |
5265 | neighbor_interface_cmd, | |
9ccf14f7 | 5266 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 5267 | NEIGHBOR_STR |
5268 | NEIGHBOR_ADDR_STR | |
5269 | "Interface\n" | |
5270 | "Interface name\n") | |
5271 | { | |
d62a17ae | 5272 | int idx_ip = 1; |
5273 | int idx_word = 3; | |
5274 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); | |
718e3744 | 5275 | } |
5276 | ||
5277 | DEFUN (no_neighbor_interface, | |
5278 | no_neighbor_interface_cmd, | |
9ccf14f7 | 5279 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 5280 | NO_STR |
5281 | NEIGHBOR_STR | |
16cedbb0 | 5282 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5283 | "Interface\n" |
5284 | "Interface name\n") | |
5285 | { | |
d62a17ae | 5286 | int idx_peer = 2; |
5287 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5288 | } |
6b0655a2 | 5289 | |
718e3744 | 5290 | DEFUN (neighbor_distribute_list, |
5291 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 5292 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5293 | NEIGHBOR_STR |
5294 | NEIGHBOR_ADDR_STR2 | |
5295 | "Filter updates to/from this neighbor\n" | |
5296 | "IP access-list number\n" | |
5297 | "IP access-list number (expanded range)\n" | |
5298 | "IP Access-list name\n" | |
5299 | "Filter incoming updates\n" | |
5300 | "Filter outgoing updates\n") | |
5301 | { | |
d62a17ae | 5302 | int idx_peer = 1; |
5303 | int idx_acl = 3; | |
5304 | int direct, ret; | |
5305 | struct peer *peer; | |
a8206004 | 5306 | |
d62a17ae | 5307 | const char *pstr = argv[idx_peer]->arg; |
5308 | const char *acl = argv[idx_acl]->arg; | |
5309 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5310 | |
d62a17ae | 5311 | peer = peer_and_group_lookup_vty(vty, pstr); |
5312 | if (!peer) | |
5313 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5314 | |
d62a17ae | 5315 | /* Check filter direction. */ |
5316 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5317 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5318 | direct, acl); | |
a8206004 | 5319 | |
d62a17ae | 5320 | return bgp_vty_return(vty, ret); |
718e3744 | 5321 | } |
5322 | ||
d62a17ae | 5323 | ALIAS_HIDDEN( |
5324 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
5325 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5326 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5327 | "Filter updates to/from this neighbor\n" | |
5328 | "IP access-list number\n" | |
5329 | "IP access-list number (expanded range)\n" | |
5330 | "IP Access-list name\n" | |
5331 | "Filter incoming updates\n" | |
5332 | "Filter outgoing updates\n") | |
596c17ba | 5333 | |
718e3744 | 5334 | DEFUN (no_neighbor_distribute_list, |
5335 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 5336 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5337 | NO_STR |
5338 | NEIGHBOR_STR | |
5339 | NEIGHBOR_ADDR_STR2 | |
5340 | "Filter updates to/from this neighbor\n" | |
5341 | "IP access-list number\n" | |
5342 | "IP access-list number (expanded range)\n" | |
5343 | "IP Access-list name\n" | |
5344 | "Filter incoming updates\n" | |
5345 | "Filter outgoing updates\n") | |
5346 | { | |
d62a17ae | 5347 | int idx_peer = 2; |
5348 | int direct, ret; | |
5349 | struct peer *peer; | |
a8206004 | 5350 | |
d62a17ae | 5351 | const char *pstr = argv[idx_peer]->arg; |
5352 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5353 | |
d62a17ae | 5354 | peer = peer_and_group_lookup_vty(vty, pstr); |
5355 | if (!peer) | |
5356 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5357 | |
d62a17ae | 5358 | /* Check filter direction. */ |
5359 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5360 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5361 | direct); | |
a8206004 | 5362 | |
d62a17ae | 5363 | return bgp_vty_return(vty, ret); |
718e3744 | 5364 | } |
6b0655a2 | 5365 | |
d62a17ae | 5366 | ALIAS_HIDDEN( |
5367 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
5368 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5369 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5370 | "Filter updates to/from this neighbor\n" | |
5371 | "IP access-list number\n" | |
5372 | "IP access-list number (expanded range)\n" | |
5373 | "IP Access-list name\n" | |
5374 | "Filter incoming updates\n" | |
5375 | "Filter outgoing updates\n") | |
596c17ba | 5376 | |
718e3744 | 5377 | /* Set prefix list to the peer. */ |
d62a17ae | 5378 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
5379 | afi_t afi, safi_t safi, | |
5380 | const char *name_str, | |
5381 | const char *direct_str) | |
718e3744 | 5382 | { |
d62a17ae | 5383 | int ret; |
d62a17ae | 5384 | int direct = FILTER_IN; |
cf9ac8bf | 5385 | struct peer *peer; |
718e3744 | 5386 | |
d62a17ae | 5387 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5388 | if (!peer) | |
5389 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5390 | |
d62a17ae | 5391 | /* Check filter direction. */ |
5392 | if (strncmp(direct_str, "i", 1) == 0) | |
5393 | direct = FILTER_IN; | |
5394 | else if (strncmp(direct_str, "o", 1) == 0) | |
5395 | direct = FILTER_OUT; | |
718e3744 | 5396 | |
d62a17ae | 5397 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 5398 | |
d62a17ae | 5399 | return bgp_vty_return(vty, ret); |
718e3744 | 5400 | } |
5401 | ||
d62a17ae | 5402 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, |
5403 | afi_t afi, safi_t safi, | |
5404 | const char *direct_str) | |
718e3744 | 5405 | { |
d62a17ae | 5406 | int ret; |
5407 | struct peer *peer; | |
5408 | int direct = FILTER_IN; | |
718e3744 | 5409 | |
d62a17ae | 5410 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5411 | if (!peer) | |
5412 | return CMD_WARNING_CONFIG_FAILED; | |
e52702f2 | 5413 | |
d62a17ae | 5414 | /* Check filter direction. */ |
5415 | if (strncmp(direct_str, "i", 1) == 0) | |
5416 | direct = FILTER_IN; | |
5417 | else if (strncmp(direct_str, "o", 1) == 0) | |
5418 | direct = FILTER_OUT; | |
718e3744 | 5419 | |
d62a17ae | 5420 | ret = peer_prefix_list_unset(peer, afi, safi, direct); |
718e3744 | 5421 | |
d62a17ae | 5422 | return bgp_vty_return(vty, ret); |
718e3744 | 5423 | } |
5424 | ||
5425 | DEFUN (neighbor_prefix_list, | |
5426 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 5427 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5428 | NEIGHBOR_STR |
5429 | NEIGHBOR_ADDR_STR2 | |
5430 | "Filter updates to/from this neighbor\n" | |
5431 | "Name of a prefix list\n" | |
5432 | "Filter incoming updates\n" | |
5433 | "Filter outgoing updates\n") | |
5434 | { | |
d62a17ae | 5435 | int idx_peer = 1; |
5436 | int idx_word = 3; | |
5437 | int idx_in_out = 4; | |
5438 | return peer_prefix_list_set_vty( | |
5439 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5440 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5441 | } |
5442 | ||
d62a17ae | 5443 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
5444 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5445 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5446 | "Filter updates to/from this neighbor\n" | |
5447 | "Name of a prefix list\n" | |
5448 | "Filter incoming updates\n" | |
5449 | "Filter outgoing updates\n") | |
596c17ba | 5450 | |
718e3744 | 5451 | DEFUN (no_neighbor_prefix_list, |
5452 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 5453 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5454 | NO_STR |
5455 | NEIGHBOR_STR | |
5456 | NEIGHBOR_ADDR_STR2 | |
5457 | "Filter updates to/from this neighbor\n" | |
5458 | "Name of a prefix list\n" | |
5459 | "Filter incoming updates\n" | |
5460 | "Filter outgoing updates\n") | |
5461 | { | |
d62a17ae | 5462 | int idx_peer = 2; |
5463 | int idx_in_out = 5; | |
5464 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
5465 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5466 | argv[idx_in_out]->arg); | |
718e3744 | 5467 | } |
6b0655a2 | 5468 | |
d62a17ae | 5469 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, |
5470 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5471 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5472 | "Filter updates to/from this neighbor\n" | |
5473 | "Name of a prefix list\n" | |
5474 | "Filter incoming updates\n" | |
5475 | "Filter outgoing updates\n") | |
596c17ba | 5476 | |
d62a17ae | 5477 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5478 | safi_t safi, const char *name_str, | |
5479 | const char *direct_str) | |
718e3744 | 5480 | { |
d62a17ae | 5481 | int ret; |
5482 | struct peer *peer; | |
5483 | int direct = FILTER_IN; | |
718e3744 | 5484 | |
d62a17ae | 5485 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5486 | if (!peer) | |
5487 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5488 | |
d62a17ae | 5489 | /* Check filter direction. */ |
5490 | if (strncmp(direct_str, "i", 1) == 0) | |
5491 | direct = FILTER_IN; | |
5492 | else if (strncmp(direct_str, "o", 1) == 0) | |
5493 | direct = FILTER_OUT; | |
718e3744 | 5494 | |
d62a17ae | 5495 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 5496 | |
d62a17ae | 5497 | return bgp_vty_return(vty, ret); |
718e3744 | 5498 | } |
5499 | ||
d62a17ae | 5500 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5501 | safi_t safi, const char *direct_str) | |
718e3744 | 5502 | { |
d62a17ae | 5503 | int ret; |
5504 | struct peer *peer; | |
5505 | int direct = FILTER_IN; | |
718e3744 | 5506 | |
d62a17ae | 5507 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5508 | if (!peer) | |
5509 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5510 | |
d62a17ae | 5511 | /* Check filter direction. */ |
5512 | if (strncmp(direct_str, "i", 1) == 0) | |
5513 | direct = FILTER_IN; | |
5514 | else if (strncmp(direct_str, "o", 1) == 0) | |
5515 | direct = FILTER_OUT; | |
718e3744 | 5516 | |
d62a17ae | 5517 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 5518 | |
d62a17ae | 5519 | return bgp_vty_return(vty, ret); |
718e3744 | 5520 | } |
5521 | ||
5522 | DEFUN (neighbor_filter_list, | |
5523 | neighbor_filter_list_cmd, | |
9ccf14f7 | 5524 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5525 | NEIGHBOR_STR |
5526 | NEIGHBOR_ADDR_STR2 | |
5527 | "Establish BGP filters\n" | |
5528 | "AS path access-list name\n" | |
5529 | "Filter incoming routes\n" | |
5530 | "Filter outgoing routes\n") | |
5531 | { | |
d62a17ae | 5532 | int idx_peer = 1; |
5533 | int idx_word = 3; | |
5534 | int idx_in_out = 4; | |
5535 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5536 | bgp_node_safi(vty), argv[idx_word]->arg, | |
5537 | argv[idx_in_out]->arg); | |
718e3744 | 5538 | } |
5539 | ||
d62a17ae | 5540 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
5541 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5542 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5543 | "Establish BGP filters\n" | |
5544 | "AS path access-list name\n" | |
5545 | "Filter incoming routes\n" | |
5546 | "Filter outgoing routes\n") | |
596c17ba | 5547 | |
718e3744 | 5548 | DEFUN (no_neighbor_filter_list, |
5549 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 5550 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5551 | NO_STR |
5552 | NEIGHBOR_STR | |
5553 | NEIGHBOR_ADDR_STR2 | |
5554 | "Establish BGP filters\n" | |
5555 | "AS path access-list name\n" | |
5556 | "Filter incoming routes\n" | |
5557 | "Filter outgoing routes\n") | |
5558 | { | |
d62a17ae | 5559 | int idx_peer = 2; |
5560 | int idx_in_out = 5; | |
5561 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
5562 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5563 | argv[idx_in_out]->arg); | |
718e3744 | 5564 | } |
6b0655a2 | 5565 | |
d62a17ae | 5566 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
5567 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5568 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5569 | "Establish BGP filters\n" | |
5570 | "AS path access-list name\n" | |
5571 | "Filter incoming routes\n" | |
5572 | "Filter outgoing routes\n") | |
596c17ba | 5573 | |
718e3744 | 5574 | /* Set route-map to the peer. */ |
d62a17ae | 5575 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
5576 | afi_t afi, safi_t safi, const char *name_str, | |
5577 | const char *direct_str) | |
718e3744 | 5578 | { |
d62a17ae | 5579 | int ret; |
5580 | struct peer *peer; | |
5581 | int direct = RMAP_IN; | |
718e3744 | 5582 | |
d62a17ae | 5583 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5584 | if (!peer) | |
5585 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5586 | |
d62a17ae | 5587 | /* Check filter direction. */ |
5588 | if (strncmp(direct_str, "in", 2) == 0) | |
5589 | direct = RMAP_IN; | |
5590 | else if (strncmp(direct_str, "o", 1) == 0) | |
5591 | direct = RMAP_OUT; | |
718e3744 | 5592 | |
d62a17ae | 5593 | ret = peer_route_map_set(peer, afi, safi, direct, name_str); |
718e3744 | 5594 | |
d62a17ae | 5595 | return bgp_vty_return(vty, ret); |
718e3744 | 5596 | } |
5597 | ||
d62a17ae | 5598 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, |
5599 | afi_t afi, safi_t safi, | |
5600 | const char *direct_str) | |
718e3744 | 5601 | { |
d62a17ae | 5602 | int ret; |
5603 | struct peer *peer; | |
5604 | int direct = RMAP_IN; | |
718e3744 | 5605 | |
d62a17ae | 5606 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5607 | if (!peer) | |
5608 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5609 | |
d62a17ae | 5610 | /* Check filter direction. */ |
5611 | if (strncmp(direct_str, "in", 2) == 0) | |
5612 | direct = RMAP_IN; | |
5613 | else if (strncmp(direct_str, "o", 1) == 0) | |
5614 | direct = RMAP_OUT; | |
718e3744 | 5615 | |
d62a17ae | 5616 | ret = peer_route_map_unset(peer, afi, safi, direct); |
718e3744 | 5617 | |
d62a17ae | 5618 | return bgp_vty_return(vty, ret); |
718e3744 | 5619 | } |
5620 | ||
5621 | DEFUN (neighbor_route_map, | |
5622 | neighbor_route_map_cmd, | |
9ccf14f7 | 5623 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5624 | NEIGHBOR_STR |
5625 | NEIGHBOR_ADDR_STR2 | |
5626 | "Apply route map to neighbor\n" | |
5627 | "Name of route map\n" | |
5628 | "Apply map to incoming routes\n" | |
2a3d5731 | 5629 | "Apply map to outbound routes\n") |
718e3744 | 5630 | { |
d62a17ae | 5631 | int idx_peer = 1; |
5632 | int idx_word = 3; | |
5633 | int idx_in_out = 4; | |
5634 | return peer_route_map_set_vty( | |
5635 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5636 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5637 | } |
5638 | ||
d62a17ae | 5639 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
5640 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5641 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5642 | "Apply route map to neighbor\n" | |
5643 | "Name of route map\n" | |
5644 | "Apply map to incoming routes\n" | |
5645 | "Apply map to outbound routes\n") | |
596c17ba | 5646 | |
718e3744 | 5647 | DEFUN (no_neighbor_route_map, |
5648 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 5649 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5650 | NO_STR |
5651 | NEIGHBOR_STR | |
5652 | NEIGHBOR_ADDR_STR2 | |
5653 | "Apply route map to neighbor\n" | |
5654 | "Name of route map\n" | |
5655 | "Apply map to incoming routes\n" | |
2a3d5731 | 5656 | "Apply map to outbound routes\n") |
718e3744 | 5657 | { |
d62a17ae | 5658 | int idx_peer = 2; |
5659 | int idx_in_out = 5; | |
5660 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
5661 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5662 | argv[idx_in_out]->arg); | |
718e3744 | 5663 | } |
6b0655a2 | 5664 | |
d62a17ae | 5665 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, |
5666 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5667 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5668 | "Apply route map to neighbor\n" | |
5669 | "Name of route map\n" | |
5670 | "Apply map to incoming routes\n" | |
5671 | "Apply map to outbound routes\n") | |
596c17ba | 5672 | |
718e3744 | 5673 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 5674 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
5675 | afi_t afi, safi_t safi, | |
5676 | const char *name_str) | |
718e3744 | 5677 | { |
d62a17ae | 5678 | int ret; |
5679 | struct peer *peer; | |
718e3744 | 5680 | |
d62a17ae | 5681 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5682 | if (!peer) | |
5683 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5684 | |
d62a17ae | 5685 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str); |
718e3744 | 5686 | |
d62a17ae | 5687 | return bgp_vty_return(vty, ret); |
718e3744 | 5688 | } |
5689 | ||
5690 | /* Unset route-map from the peer. */ | |
d62a17ae | 5691 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
5692 | afi_t afi, safi_t safi) | |
718e3744 | 5693 | { |
d62a17ae | 5694 | int ret; |
5695 | struct peer *peer; | |
718e3744 | 5696 | |
d62a17ae | 5697 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5698 | if (!peer) | |
5699 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5700 | |
d62a17ae | 5701 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 5702 | |
d62a17ae | 5703 | return bgp_vty_return(vty, ret); |
718e3744 | 5704 | } |
5705 | ||
5706 | DEFUN (neighbor_unsuppress_map, | |
5707 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5708 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5709 | NEIGHBOR_STR |
5710 | NEIGHBOR_ADDR_STR2 | |
5711 | "Route-map to selectively unsuppress suppressed routes\n" | |
5712 | "Name of route map\n") | |
5713 | { | |
d62a17ae | 5714 | int idx_peer = 1; |
5715 | int idx_word = 3; | |
5716 | return peer_unsuppress_map_set_vty( | |
5717 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5718 | argv[idx_word]->arg); | |
718e3744 | 5719 | } |
5720 | ||
d62a17ae | 5721 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
5722 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5723 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5724 | "Route-map to selectively unsuppress suppressed routes\n" | |
5725 | "Name of route map\n") | |
596c17ba | 5726 | |
718e3744 | 5727 | DEFUN (no_neighbor_unsuppress_map, |
5728 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5729 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5730 | NO_STR |
5731 | NEIGHBOR_STR | |
5732 | NEIGHBOR_ADDR_STR2 | |
5733 | "Route-map to selectively unsuppress suppressed routes\n" | |
5734 | "Name of route map\n") | |
5735 | { | |
d62a17ae | 5736 | int idx_peer = 2; |
5737 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
5738 | bgp_node_afi(vty), | |
5739 | bgp_node_safi(vty)); | |
718e3744 | 5740 | } |
6b0655a2 | 5741 | |
d62a17ae | 5742 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
5743 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5744 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5745 | "Route-map to selectively unsuppress suppressed routes\n" | |
5746 | "Name of route map\n") | |
596c17ba | 5747 | |
d62a17ae | 5748 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
5749 | afi_t afi, safi_t safi, | |
5750 | const char *num_str, | |
5751 | const char *threshold_str, int warning, | |
5752 | const char *restart_str) | |
718e3744 | 5753 | { |
d62a17ae | 5754 | int ret; |
5755 | struct peer *peer; | |
d7c0a89a QY |
5756 | uint32_t max; |
5757 | uint8_t threshold; | |
5758 | uint16_t restart; | |
718e3744 | 5759 | |
d62a17ae | 5760 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5761 | if (!peer) | |
5762 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5763 | |
d62a17ae | 5764 | max = strtoul(num_str, NULL, 10); |
5765 | if (threshold_str) | |
5766 | threshold = atoi(threshold_str); | |
5767 | else | |
5768 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 5769 | |
d62a17ae | 5770 | if (restart_str) |
5771 | restart = atoi(restart_str); | |
5772 | else | |
5773 | restart = 0; | |
0a486e5f | 5774 | |
d62a17ae | 5775 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, |
5776 | restart); | |
718e3744 | 5777 | |
d62a17ae | 5778 | return bgp_vty_return(vty, ret); |
718e3744 | 5779 | } |
5780 | ||
d62a17ae | 5781 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, |
5782 | afi_t afi, safi_t safi) | |
718e3744 | 5783 | { |
d62a17ae | 5784 | int ret; |
5785 | struct peer *peer; | |
718e3744 | 5786 | |
d62a17ae | 5787 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5788 | if (!peer) | |
5789 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5790 | |
d62a17ae | 5791 | ret = peer_maximum_prefix_unset(peer, afi, safi); |
718e3744 | 5792 | |
d62a17ae | 5793 | return bgp_vty_return(vty, ret); |
718e3744 | 5794 | } |
5795 | ||
5796 | /* Maximum number of prefix configuration. prefix count is different | |
5797 | for each peer configuration. So this configuration can be set for | |
5798 | each peer configuration. */ | |
5799 | DEFUN (neighbor_maximum_prefix, | |
5800 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 5801 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 5802 | NEIGHBOR_STR |
5803 | NEIGHBOR_ADDR_STR2 | |
5804 | "Maximum number of prefix accept from this peer\n" | |
5805 | "maximum no. of prefix limit\n") | |
5806 | { | |
d62a17ae | 5807 | int idx_peer = 1; |
5808 | int idx_number = 3; | |
5809 | return peer_maximum_prefix_set_vty( | |
5810 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5811 | argv[idx_number]->arg, NULL, 0, NULL); | |
718e3744 | 5812 | } |
5813 | ||
d62a17ae | 5814 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
5815 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", | |
5816 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5817 | "Maximum number of prefix accept from this peer\n" | |
5818 | "maximum no. of prefix limit\n") | |
596c17ba | 5819 | |
e0701b79 | 5820 | DEFUN (neighbor_maximum_prefix_threshold, |
5821 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 5822 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 5823 | NEIGHBOR_STR |
5824 | NEIGHBOR_ADDR_STR2 | |
5825 | "Maximum number of prefix accept from this peer\n" | |
5826 | "maximum no. of prefix limit\n" | |
5827 | "Threshold value (%) at which to generate a warning msg\n") | |
5828 | { | |
d62a17ae | 5829 | int idx_peer = 1; |
5830 | int idx_number = 3; | |
5831 | int idx_number_2 = 4; | |
5832 | return peer_maximum_prefix_set_vty( | |
5833 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5834 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL); | |
0a486e5f | 5835 | } |
e0701b79 | 5836 | |
d62a17ae | 5837 | ALIAS_HIDDEN( |
5838 | neighbor_maximum_prefix_threshold, | |
5839 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
5840 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", | |
5841 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5842 | "Maximum number of prefix accept from this peer\n" | |
5843 | "maximum no. of prefix limit\n" | |
5844 | "Threshold value (%) at which to generate a warning msg\n") | |
596c17ba | 5845 | |
718e3744 | 5846 | DEFUN (neighbor_maximum_prefix_warning, |
5847 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 5848 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 5849 | NEIGHBOR_STR |
5850 | NEIGHBOR_ADDR_STR2 | |
5851 | "Maximum number of prefix accept from this peer\n" | |
5852 | "maximum no. of prefix limit\n" | |
5853 | "Only give warning message when limit is exceeded\n") | |
5854 | { | |
d62a17ae | 5855 | int idx_peer = 1; |
5856 | int idx_number = 3; | |
5857 | return peer_maximum_prefix_set_vty( | |
5858 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5859 | argv[idx_number]->arg, NULL, 1, NULL); | |
718e3744 | 5860 | } |
5861 | ||
d62a17ae | 5862 | ALIAS_HIDDEN( |
5863 | neighbor_maximum_prefix_warning, | |
5864 | neighbor_maximum_prefix_warning_hidden_cmd, | |
5865 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", | |
5866 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5867 | "Maximum number of prefix accept from this peer\n" | |
5868 | "maximum no. of prefix limit\n" | |
5869 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 5870 | |
e0701b79 | 5871 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
5872 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 5873 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 5874 | NEIGHBOR_STR |
5875 | NEIGHBOR_ADDR_STR2 | |
5876 | "Maximum number of prefix accept from this peer\n" | |
5877 | "maximum no. of prefix limit\n" | |
5878 | "Threshold value (%) at which to generate a warning msg\n" | |
5879 | "Only give warning message when limit is exceeded\n") | |
5880 | { | |
d62a17ae | 5881 | int idx_peer = 1; |
5882 | int idx_number = 3; | |
5883 | int idx_number_2 = 4; | |
5884 | return peer_maximum_prefix_set_vty( | |
5885 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5886 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 5887 | } |
5888 | ||
d62a17ae | 5889 | ALIAS_HIDDEN( |
5890 | neighbor_maximum_prefix_threshold_warning, | |
5891 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
5892 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", | |
5893 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5894 | "Maximum number of prefix accept from this peer\n" | |
5895 | "maximum no. of prefix limit\n" | |
5896 | "Threshold value (%) at which to generate a warning msg\n" | |
5897 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 5898 | |
0a486e5f | 5899 | DEFUN (neighbor_maximum_prefix_restart, |
5900 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 5901 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 5902 | NEIGHBOR_STR |
5903 | NEIGHBOR_ADDR_STR2 | |
5904 | "Maximum number of prefix accept from this peer\n" | |
5905 | "maximum no. of prefix limit\n" | |
5906 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 5907 | "Restart interval in minutes\n") |
0a486e5f | 5908 | { |
d62a17ae | 5909 | int idx_peer = 1; |
5910 | int idx_number = 3; | |
5911 | int idx_number_2 = 5; | |
5912 | return peer_maximum_prefix_set_vty( | |
5913 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5914 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 5915 | } |
5916 | ||
d62a17ae | 5917 | ALIAS_HIDDEN( |
5918 | neighbor_maximum_prefix_restart, | |
5919 | neighbor_maximum_prefix_restart_hidden_cmd, | |
5920 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", | |
5921 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5922 | "Maximum number of prefix accept from this peer\n" | |
5923 | "maximum no. of prefix limit\n" | |
5924 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 5925 | "Restart interval in minutes\n") |
596c17ba | 5926 | |
0a486e5f | 5927 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
5928 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 5929 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 5930 | NEIGHBOR_STR |
5931 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5932 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 5933 | "maximum no. of prefix limit\n" |
5934 | "Threshold value (%) at which to generate a warning msg\n" | |
5935 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 5936 | "Restart interval in minutes\n") |
0a486e5f | 5937 | { |
d62a17ae | 5938 | int idx_peer = 1; |
5939 | int idx_number = 3; | |
5940 | int idx_number_2 = 4; | |
5941 | int idx_number_3 = 6; | |
5942 | return peer_maximum_prefix_set_vty( | |
5943 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5944 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
5945 | argv[idx_number_3]->arg); | |
5946 | } | |
5947 | ||
5948 | ALIAS_HIDDEN( | |
5949 | neighbor_maximum_prefix_threshold_restart, | |
5950 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
5951 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", | |
5952 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5953 | "Maximum number of prefixes to accept from this peer\n" | |
5954 | "maximum no. of prefix limit\n" | |
5955 | "Threshold value (%) at which to generate a warning msg\n" | |
5956 | "Restart bgp connection after limit is exceeded\n" | |
5957 | "Restart interval in minutes\n") | |
596c17ba | 5958 | |
718e3744 | 5959 | DEFUN (no_neighbor_maximum_prefix, |
5960 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 5961 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 5962 | NO_STR |
5963 | NEIGHBOR_STR | |
5964 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5965 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
5966 | "maximum no. of prefix limit\n" |
5967 | "Threshold value (%) at which to generate a warning msg\n" | |
5968 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 5969 | "Restart interval in minutes\n" |
31500417 | 5970 | "Only give warning message when limit is exceeded\n") |
718e3744 | 5971 | { |
d62a17ae | 5972 | int idx_peer = 2; |
5973 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, | |
5974 | bgp_node_afi(vty), | |
5975 | bgp_node_safi(vty)); | |
718e3744 | 5976 | } |
e52702f2 | 5977 | |
d62a17ae | 5978 | ALIAS_HIDDEN( |
5979 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
5980 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", | |
5981 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5982 | "Maximum number of prefixes to accept from this peer\n" | |
5983 | "maximum no. of prefix limit\n" | |
5984 | "Threshold value (%) at which to generate a warning msg\n" | |
5985 | "Restart bgp connection after limit is exceeded\n" | |
5986 | "Restart interval in minutes\n" | |
5987 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 5988 | |
718e3744 | 5989 | |
718e3744 | 5990 | /* "neighbor allowas-in" */ |
5991 | DEFUN (neighbor_allowas_in, | |
5992 | neighbor_allowas_in_cmd, | |
fd8503f5 | 5993 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 5994 | NEIGHBOR_STR |
5995 | NEIGHBOR_ADDR_STR2 | |
31500417 | 5996 | "Accept as-path with my AS present in it\n" |
fd8503f5 QY |
5997 | "Number of occurances of AS number\n" |
5998 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 5999 | { |
d62a17ae | 6000 | int idx_peer = 1; |
6001 | int idx_number_origin = 3; | |
6002 | int ret; | |
6003 | int origin = 0; | |
6004 | struct peer *peer; | |
6005 | int allow_num = 0; | |
6006 | ||
6007 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6008 | if (!peer) | |
6009 | return CMD_WARNING_CONFIG_FAILED; | |
6010 | ||
6011 | if (argc <= idx_number_origin) | |
6012 | allow_num = 3; | |
6013 | else { | |
6014 | if (argv[idx_number_origin]->type == WORD_TKN) | |
6015 | origin = 1; | |
6016 | else | |
6017 | allow_num = atoi(argv[idx_number_origin]->arg); | |
6018 | } | |
6019 | ||
6020 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6021 | allow_num, origin); | |
6022 | ||
6023 | return bgp_vty_return(vty, ret); | |
6024 | } | |
6025 | ||
6026 | ALIAS_HIDDEN( | |
6027 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
6028 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6029 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6030 | "Accept as-path with my AS present in it\n" | |
6031 | "Number of occurances of AS number\n" | |
6032 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
596c17ba | 6033 | |
718e3744 | 6034 | DEFUN (no_neighbor_allowas_in, |
6035 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 6036 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6037 | NO_STR |
6038 | NEIGHBOR_STR | |
6039 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 6040 | "allow local ASN appears in aspath attribute\n" |
fd8503f5 QY |
6041 | "Number of occurances of AS number\n" |
6042 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 6043 | { |
d62a17ae | 6044 | int idx_peer = 2; |
6045 | int ret; | |
6046 | struct peer *peer; | |
718e3744 | 6047 | |
d62a17ae | 6048 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6049 | if (!peer) | |
6050 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6051 | |
d62a17ae | 6052 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
6053 | bgp_node_safi(vty)); | |
718e3744 | 6054 | |
d62a17ae | 6055 | return bgp_vty_return(vty, ret); |
718e3744 | 6056 | } |
6b0655a2 | 6057 | |
d62a17ae | 6058 | ALIAS_HIDDEN( |
6059 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
6060 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6061 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6062 | "allow local ASN appears in aspath attribute\n" | |
6063 | "Number of occurances of AS number\n" | |
6064 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
596c17ba | 6065 | |
fa411a21 NH |
6066 | DEFUN (neighbor_ttl_security, |
6067 | neighbor_ttl_security_cmd, | |
7ebe625c | 6068 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 | 6069 | NEIGHBOR_STR |
7ebe625c | 6070 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6071 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
6072 | "Specify the maximum number of hops to the BGP peer\n" |
6073 | "Number of hops to BGP peer\n") | |
fa411a21 | 6074 | { |
d62a17ae | 6075 | int idx_peer = 1; |
6076 | int idx_number = 4; | |
6077 | struct peer *peer; | |
6078 | int gtsm_hops; | |
6079 | ||
6080 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6081 | if (!peer) | |
6082 | return CMD_WARNING_CONFIG_FAILED; | |
6083 | ||
6084 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); | |
6085 | ||
7ebe625c QY |
6086 | /* |
6087 | * If 'neighbor swpX', then this is for directly connected peers, | |
6088 | * we should not accept a ttl-security hops value greater than 1. | |
6089 | */ | |
6090 | if (peer->conf_if && (gtsm_hops > 1)) { | |
6091 | vty_out(vty, | |
6092 | "%s is directly connected peer, hops cannot exceed 1\n", | |
6093 | argv[idx_peer]->arg); | |
6094 | return CMD_WARNING_CONFIG_FAILED; | |
6095 | } | |
6096 | ||
d62a17ae | 6097 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
6098 | } |
6099 | ||
6100 | DEFUN (no_neighbor_ttl_security, | |
6101 | no_neighbor_ttl_security_cmd, | |
7ebe625c | 6102 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
6103 | NO_STR |
6104 | NEIGHBOR_STR | |
7ebe625c | 6105 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6106 | "BGP ttl-security parameters\n" |
3a2d747c QY |
6107 | "Specify the maximum number of hops to the BGP peer\n" |
6108 | "Number of hops to BGP peer\n") | |
fa411a21 | 6109 | { |
d62a17ae | 6110 | int idx_peer = 2; |
6111 | struct peer *peer; | |
fa411a21 | 6112 | |
d62a17ae | 6113 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6114 | if (!peer) | |
6115 | return CMD_WARNING_CONFIG_FAILED; | |
fa411a21 | 6116 | |
d62a17ae | 6117 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 6118 | } |
6b0655a2 | 6119 | |
adbac85e DW |
6120 | DEFUN (neighbor_addpath_tx_all_paths, |
6121 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6122 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6123 | NEIGHBOR_STR |
6124 | NEIGHBOR_ADDR_STR2 | |
6125 | "Use addpath to advertise all paths to a neighbor\n") | |
6126 | { | |
d62a17ae | 6127 | int idx_peer = 1; |
6128 | struct peer *peer; | |
adbac85e | 6129 | |
d62a17ae | 6130 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6131 | if (!peer) | |
6132 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 6133 | |
d62a17ae | 6134 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
6135 | bgp_node_safi(vty), | |
6136 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
adbac85e DW |
6137 | } |
6138 | ||
d62a17ae | 6139 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
6140 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
6141 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6142 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6143 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6144 | |
adbac85e DW |
6145 | DEFUN (no_neighbor_addpath_tx_all_paths, |
6146 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6147 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6148 | NO_STR |
6149 | NEIGHBOR_STR | |
6150 | NEIGHBOR_ADDR_STR2 | |
6151 | "Use addpath to advertise all paths to a neighbor\n") | |
6152 | { | |
d62a17ae | 6153 | int idx_peer = 2; |
6154 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6155 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6156 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
adbac85e DW |
6157 | } |
6158 | ||
d62a17ae | 6159 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
6160 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
6161 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6162 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6163 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6164 | |
06370dac DW |
6165 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
6166 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6167 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6168 | NEIGHBOR_STR |
6169 | NEIGHBOR_ADDR_STR2 | |
6170 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6171 | { | |
d62a17ae | 6172 | int idx_peer = 1; |
6173 | struct peer *peer; | |
06370dac | 6174 | |
d62a17ae | 6175 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6176 | if (!peer) | |
6177 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 6178 | |
d62a17ae | 6179 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
6180 | bgp_node_safi(vty), | |
6181 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
06370dac DW |
6182 | } |
6183 | ||
d62a17ae | 6184 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
6185 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6186 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6187 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6188 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 6189 | |
06370dac DW |
6190 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
6191 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6192 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6193 | NO_STR |
6194 | NEIGHBOR_STR | |
6195 | NEIGHBOR_ADDR_STR2 | |
6196 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6197 | { | |
d62a17ae | 6198 | int idx_peer = 2; |
6199 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6200 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6201 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
06370dac DW |
6202 | } |
6203 | ||
d62a17ae | 6204 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
6205 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6206 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6207 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6208 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 6209 | |
b9c7bc5a PZ |
6210 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
6211 | struct ecommunity **list) | |
ddb5b488 | 6212 | { |
b9c7bc5a PZ |
6213 | struct ecommunity *ecom = NULL; |
6214 | struct ecommunity *ecomadd; | |
ddb5b488 | 6215 | |
b9c7bc5a | 6216 | for (; argc; --argc, ++argv) { |
ddb5b488 | 6217 | |
b9c7bc5a PZ |
6218 | ecomadd = ecommunity_str2com(argv[0]->arg, |
6219 | ECOMMUNITY_ROUTE_TARGET, 0); | |
6220 | if (!ecomadd) { | |
6221 | vty_out(vty, "Malformed community-list value\n"); | |
6222 | if (ecom) | |
6223 | ecommunity_free(&ecom); | |
6224 | return CMD_WARNING_CONFIG_FAILED; | |
6225 | } | |
ddb5b488 | 6226 | |
b9c7bc5a PZ |
6227 | if (ecom) { |
6228 | ecommunity_merge(ecom, ecomadd); | |
6229 | ecommunity_free(&ecomadd); | |
6230 | } else { | |
6231 | ecom = ecomadd; | |
6232 | } | |
6233 | } | |
6234 | ||
6235 | if (*list) { | |
6236 | ecommunity_free(&*list); | |
ddb5b488 | 6237 | } |
b9c7bc5a PZ |
6238 | *list = ecom; |
6239 | ||
6240 | return CMD_SUCCESS; | |
ddb5b488 PZ |
6241 | } |
6242 | ||
0ca70ba5 DS |
6243 | /* |
6244 | * v2vimport is true if we are handling a `import vrf ...` command | |
6245 | */ | |
6246 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 6247 | { |
0ca70ba5 DS |
6248 | afi_t afi; |
6249 | ||
ddb5b488 | 6250 | switch (vty->node) { |
b9c7bc5a | 6251 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
6252 | afi = AFI_IP; |
6253 | break; | |
b9c7bc5a | 6254 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
6255 | afi = AFI_IP6; |
6256 | break; | |
ddb5b488 PZ |
6257 | default: |
6258 | vty_out(vty, | |
b9c7bc5a | 6259 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 6260 | return AFI_MAX; |
ddb5b488 | 6261 | } |
69b07479 | 6262 | |
0ca70ba5 DS |
6263 | if (!v2vimport) { |
6264 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6265 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
6266 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6267 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
6268 | vty_out(vty, | |
6269 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
6270 | return AFI_MAX; | |
6271 | } | |
6272 | } else { | |
6273 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6274 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
6275 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6276 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
6277 | vty_out(vty, | |
6278 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
6279 | return AFI_MAX; | |
6280 | } | |
6281 | } | |
6282 | return afi; | |
ddb5b488 PZ |
6283 | } |
6284 | ||
b9c7bc5a PZ |
6285 | DEFPY (af_rd_vpn_export, |
6286 | af_rd_vpn_export_cmd, | |
6287 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
6288 | NO_STR | |
ddb5b488 | 6289 | "Specify route distinguisher\n" |
b9c7bc5a PZ |
6290 | "Between current address-family and vpn\n" |
6291 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6292 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") |
6293 | { | |
6294 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6295 | struct prefix_rd prd; | |
6296 | int ret; | |
ddb5b488 | 6297 | afi_t afi; |
b9c7bc5a PZ |
6298 | int idx = 0; |
6299 | int yes = 1; | |
ddb5b488 | 6300 | |
b9c7bc5a | 6301 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6302 | yes = 0; |
b9c7bc5a PZ |
6303 | |
6304 | if (yes) { | |
6305 | ret = str2prefix_rd(rd_str, &prd); | |
6306 | if (!ret) { | |
6307 | vty_out(vty, "%% Malformed rd\n"); | |
6308 | return CMD_WARNING_CONFIG_FAILED; | |
6309 | } | |
ddb5b488 PZ |
6310 | } |
6311 | ||
0ca70ba5 | 6312 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6313 | if (afi == AFI_MAX) |
6314 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6315 | |
69b07479 DS |
6316 | /* |
6317 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6318 | */ | |
6319 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6320 | bgp_get_default(), bgp); | |
ddb5b488 | 6321 | |
69b07479 DS |
6322 | if (yes) { |
6323 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
6324 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6325 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
6326 | } else { | |
6327 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
6328 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
ddb5b488 PZ |
6329 | } |
6330 | ||
69b07479 DS |
6331 | /* post-change: re-export vpn routes */ |
6332 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6333 | bgp_get_default(), bgp); | |
6334 | ||
ddb5b488 PZ |
6335 | return CMD_SUCCESS; |
6336 | } | |
6337 | ||
b9c7bc5a PZ |
6338 | ALIAS (af_rd_vpn_export, |
6339 | af_no_rd_vpn_export_cmd, | |
6340 | "no rd vpn export", | |
ddb5b488 | 6341 | NO_STR |
b9c7bc5a PZ |
6342 | "Specify route distinguisher\n" |
6343 | "Between current address-family and vpn\n" | |
6344 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6345 | |
b9c7bc5a PZ |
6346 | DEFPY (af_label_vpn_export, |
6347 | af_label_vpn_export_cmd, | |
e70e9f8e | 6348 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 6349 | NO_STR |
ddb5b488 | 6350 | "label value for VRF\n" |
b9c7bc5a PZ |
6351 | "Between current address-family and vpn\n" |
6352 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
6353 | "Label Value <0-1048575>\n" |
6354 | "Automatically assign a label\n") | |
ddb5b488 PZ |
6355 | { |
6356 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 6357 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 6358 | afi_t afi; |
b9c7bc5a PZ |
6359 | int idx = 0; |
6360 | int yes = 1; | |
6361 | ||
6362 | if (argv_find(argv, argc, "no", &idx)) | |
d555f3e9 | 6363 | yes = 0; |
ddb5b488 | 6364 | |
21a16cc2 PZ |
6365 | /* If "no ...", squash trailing parameter */ |
6366 | if (!yes) | |
6367 | label_auto = NULL; | |
6368 | ||
e70e9f8e PZ |
6369 | if (yes) { |
6370 | if (!label_auto) | |
6371 | label = label_val; /* parser should force unsigned */ | |
6372 | } | |
ddb5b488 | 6373 | |
0ca70ba5 | 6374 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6375 | if (afi == AFI_MAX) |
6376 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 6377 | |
e70e9f8e | 6378 | |
69b07479 DS |
6379 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
6380 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
6381 | /* no change */ | |
6382 | return CMD_SUCCESS; | |
e70e9f8e | 6383 | |
69b07479 DS |
6384 | /* |
6385 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6386 | */ | |
6387 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6388 | bgp_get_default(), bgp); | |
6389 | ||
6390 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
6391 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
6392 | ||
6393 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
6394 | ||
6395 | /* | |
6396 | * label has previously been automatically | |
6397 | * assigned by labelpool: release it | |
6398 | * | |
6399 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
6400 | * means the automatic assignment is in flight | |
6401 | * and therefore the labelpool callback must | |
6402 | * detect that the auto label is not needed. | |
6403 | */ | |
6404 | ||
6405 | bgp_lp_release(LP_TYPE_VRF, | |
6406 | &bgp->vpn_policy[afi], | |
6407 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 6408 | } |
69b07479 DS |
6409 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
6410 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
6411 | } | |
ddb5b488 | 6412 | |
69b07479 DS |
6413 | bgp->vpn_policy[afi].tovpn_label = label; |
6414 | if (label_auto) { | |
6415 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6416 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
6417 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
6418 | vpn_leak_label_callback); | |
ddb5b488 PZ |
6419 | } |
6420 | ||
69b07479 DS |
6421 | /* post-change: re-export vpn routes */ |
6422 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6423 | bgp_get_default(), bgp); | |
6424 | ||
ddb5b488 PZ |
6425 | return CMD_SUCCESS; |
6426 | } | |
6427 | ||
b9c7bc5a PZ |
6428 | ALIAS (af_label_vpn_export, |
6429 | af_no_label_vpn_export_cmd, | |
6430 | "no label vpn export", | |
6431 | NO_STR | |
6432 | "label value for VRF\n" | |
6433 | "Between current address-family and vpn\n" | |
6434 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6435 | |
b9c7bc5a PZ |
6436 | DEFPY (af_nexthop_vpn_export, |
6437 | af_nexthop_vpn_export_cmd, | |
6438 | "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str", | |
6439 | NO_STR | |
ddb5b488 | 6440 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
6441 | "Between current address-family and vpn\n" |
6442 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6443 | "IPv4 prefix\n" |
6444 | "IPv6 prefix\n") | |
6445 | { | |
6446 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
ddb5b488 | 6447 | afi_t afi; |
ddb5b488 | 6448 | struct prefix p; |
b9c7bc5a PZ |
6449 | int idx = 0; |
6450 | int yes = 1; | |
ddb5b488 | 6451 | |
b9c7bc5a | 6452 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6453 | yes = 0; |
b9c7bc5a PZ |
6454 | |
6455 | if (yes) { | |
6456 | if (!sockunion2hostprefix(nexthop_str, &p)) | |
6457 | return CMD_WARNING_CONFIG_FAILED; | |
6458 | } | |
ddb5b488 | 6459 | |
0ca70ba5 | 6460 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6461 | if (afi == AFI_MAX) |
6462 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6463 | |
69b07479 DS |
6464 | /* |
6465 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6466 | */ | |
6467 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6468 | bgp_get_default(), bgp); | |
ddb5b488 | 6469 | |
69b07479 DS |
6470 | if (yes) { |
6471 | bgp->vpn_policy[afi].tovpn_nexthop = p; | |
6472 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6473 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
6474 | } else { | |
6475 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
6476 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
ddb5b488 PZ |
6477 | } |
6478 | ||
69b07479 DS |
6479 | /* post-change: re-export vpn routes */ |
6480 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6481 | bgp_get_default(), bgp); | |
6482 | ||
ddb5b488 PZ |
6483 | return CMD_SUCCESS; |
6484 | } | |
6485 | ||
b9c7bc5a PZ |
6486 | ALIAS (af_nexthop_vpn_export, |
6487 | af_no_nexthop_vpn_export_cmd, | |
6488 | "no nexthop vpn export", | |
ddb5b488 | 6489 | NO_STR |
b9c7bc5a PZ |
6490 | "Specify next hop to use for VRF advertised prefixes\n" |
6491 | "Between current address-family and vpn\n" | |
6492 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6493 | |
b9c7bc5a | 6494 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 6495 | { |
b9c7bc5a PZ |
6496 | if (!strcmp(dstr, "import")) { |
6497 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
6498 | } else if (!strcmp(dstr, "export")) { | |
6499 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
6500 | } else if (!strcmp(dstr, "both")) { | |
6501 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
6502 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
6503 | } else { | |
6504 | vty_out(vty, "%% direction parse error\n"); | |
6505 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6506 | } |
ddb5b488 PZ |
6507 | return CMD_SUCCESS; |
6508 | } | |
6509 | ||
b9c7bc5a PZ |
6510 | DEFPY (af_rt_vpn_imexport, |
6511 | af_rt_vpn_imexport_cmd, | |
6512 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
6513 | NO_STR | |
6514 | "Specify route target list\n" | |
ddb5b488 | 6515 | "Specify route target list\n" |
b9c7bc5a PZ |
6516 | "Between current address-family and vpn\n" |
6517 | "For routes leaked from vpn to current address-family: match any\n" | |
6518 | "For routes leaked from current address-family to vpn: set\n" | |
6519 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
6520 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
6521 | { | |
6522 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6523 | int ret; | |
6524 | struct ecommunity *ecom = NULL; | |
6525 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
6526 | vpn_policy_direction_t dir; |
6527 | afi_t afi; | |
6528 | int idx = 0; | |
b9c7bc5a | 6529 | int yes = 1; |
ddb5b488 | 6530 | |
b9c7bc5a | 6531 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6532 | yes = 0; |
b9c7bc5a | 6533 | |
0ca70ba5 | 6534 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6535 | if (afi == AFI_MAX) |
6536 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6537 | |
b9c7bc5a | 6538 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
6539 | if (ret != CMD_SUCCESS) |
6540 | return ret; | |
6541 | ||
b9c7bc5a PZ |
6542 | if (yes) { |
6543 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
6544 | vty_out(vty, "%% Missing RTLIST\n"); | |
6545 | return CMD_WARNING_CONFIG_FAILED; | |
6546 | } | |
6547 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
6548 | if (ret != CMD_SUCCESS) { | |
6549 | return ret; | |
6550 | } | |
ddb5b488 PZ |
6551 | } |
6552 | ||
69b07479 DS |
6553 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
6554 | if (!dodir[dir]) | |
ddb5b488 | 6555 | continue; |
ddb5b488 | 6556 | |
69b07479 | 6557 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 6558 | |
69b07479 DS |
6559 | if (yes) { |
6560 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
6561 | ecommunity_free( | |
6562 | &bgp->vpn_policy[afi].rtlist[dir]); | |
6563 | bgp->vpn_policy[afi].rtlist[dir] = | |
6564 | ecommunity_dup(ecom); | |
6565 | } else { | |
6566 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
6567 | ecommunity_free( | |
6568 | &bgp->vpn_policy[afi].rtlist[dir]); | |
6569 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 6570 | } |
69b07479 DS |
6571 | |
6572 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 6573 | } |
69b07479 | 6574 | |
d555f3e9 PZ |
6575 | if (ecom) |
6576 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
6577 | |
6578 | return CMD_SUCCESS; | |
6579 | } | |
6580 | ||
b9c7bc5a PZ |
6581 | ALIAS (af_rt_vpn_imexport, |
6582 | af_no_rt_vpn_imexport_cmd, | |
6583 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
6584 | NO_STR |
6585 | "Specify route target list\n" | |
b9c7bc5a PZ |
6586 | "Specify route target list\n" |
6587 | "Between current address-family and vpn\n" | |
6588 | "For routes leaked from vpn to current address-family\n" | |
6589 | "For routes leaked from current address-family to vpn\n" | |
6590 | "both import and export\n") | |
6591 | ||
6592 | DEFPY (af_route_map_vpn_imexport, | |
6593 | af_route_map_vpn_imexport_cmd, | |
6594 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
6595 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
6596 | NO_STR | |
ddb5b488 | 6597 | "Specify route map\n" |
b9c7bc5a PZ |
6598 | "Between current address-family and vpn\n" |
6599 | "For routes leaked from vpn to current address-family\n" | |
6600 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6601 | "name of route-map\n") |
6602 | { | |
6603 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6604 | int ret; | |
6605 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
6606 | vpn_policy_direction_t dir; |
6607 | afi_t afi; | |
ddb5b488 | 6608 | int idx = 0; |
b9c7bc5a | 6609 | int yes = 1; |
ddb5b488 | 6610 | |
b9c7bc5a | 6611 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6612 | yes = 0; |
b9c7bc5a | 6613 | |
0ca70ba5 | 6614 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6615 | if (afi == AFI_MAX) |
6616 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6617 | |
b9c7bc5a | 6618 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
6619 | if (ret != CMD_SUCCESS) |
6620 | return ret; | |
6621 | ||
69b07479 DS |
6622 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
6623 | if (!dodir[dir]) | |
ddb5b488 | 6624 | continue; |
ddb5b488 | 6625 | |
69b07479 | 6626 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 6627 | |
69b07479 DS |
6628 | if (yes) { |
6629 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6630 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6631 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6632 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
6633 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
6634 | bgp->vpn_policy[afi].rmap[dir] = | |
6635 | route_map_lookup_by_name(rmap_str); | |
6636 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
6637 | return CMD_SUCCESS; | |
6638 | } else { | |
6639 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6640 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6641 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6642 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
6643 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
ddb5b488 | 6644 | } |
69b07479 DS |
6645 | |
6646 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 PZ |
6647 | } |
6648 | ||
6649 | return CMD_SUCCESS; | |
6650 | } | |
6651 | ||
b9c7bc5a PZ |
6652 | ALIAS (af_route_map_vpn_imexport, |
6653 | af_no_route_map_vpn_imexport_cmd, | |
6654 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
6655 | NO_STR |
6656 | "Specify route map\n" | |
b9c7bc5a PZ |
6657 | "Between current address-family and vpn\n" |
6658 | "For routes leaked from vpn to current address-family\n" | |
6659 | "For routes leaked from current address-family to vpn\n") | |
6660 | ||
bb4f6190 DS |
6661 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
6662 | "[no] import vrf route-map RMAP$rmap_str", | |
6663 | NO_STR | |
6664 | "Import routes from another VRF\n" | |
6665 | "Vrf routes being filtered\n" | |
6666 | "Specify route map\n" | |
6667 | "name of route-map\n") | |
6668 | { | |
6669 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
bb4f6190 DS |
6670 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; |
6671 | afi_t afi; | |
6672 | int idx = 0; | |
6673 | int yes = 1; | |
6674 | struct bgp *bgp_default; | |
6675 | ||
6676 | if (argv_find(argv, argc, "no", &idx)) | |
6677 | yes = 0; | |
6678 | ||
0ca70ba5 | 6679 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
6680 | if (afi == AFI_MAX) |
6681 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
6682 | |
6683 | bgp_default = bgp_get_default(); | |
6684 | if (!bgp_default) { | |
6685 | int32_t ret; | |
6686 | as_t as = bgp->as; | |
6687 | ||
6688 | /* Auto-create assuming the same AS */ | |
6689 | ret = bgp_get(&bgp_default, &as, NULL, | |
6690 | BGP_INSTANCE_TYPE_DEFAULT); | |
6691 | ||
6692 | if (ret) { | |
6693 | vty_out(vty, | |
6694 | "VRF default is not configured as a bgp instance\n"); | |
6695 | return CMD_WARNING; | |
6696 | } | |
6697 | } | |
6698 | ||
69b07479 | 6699 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 6700 | |
69b07479 DS |
6701 | if (yes) { |
6702 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6703 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6704 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6705 | bgp->vpn_policy[afi].rmap_name[dir] = | |
6706 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
6707 | bgp->vpn_policy[afi].rmap[dir] = | |
6708 | route_map_lookup_by_name(rmap_str); | |
6709 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
6710 | return CMD_SUCCESS; | |
6711 | } else { | |
6712 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6713 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6714 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6715 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
6716 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
bb4f6190 DS |
6717 | } |
6718 | ||
69b07479 DS |
6719 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
6720 | ||
bb4f6190 DS |
6721 | return CMD_SUCCESS; |
6722 | } | |
6723 | ||
6724 | ALIAS(af_import_vrf_route_map, af_no_import_vrf_route_map_cmd, | |
6725 | "no import vrf route-map", | |
6726 | NO_STR | |
6727 | "Import routes from another VRF\n" | |
6728 | "Vrf routes being filtered\n" | |
6729 | "Specify route map\n") | |
6730 | ||
12a844a5 DS |
6731 | DEFPY (bgp_imexport_vrf, |
6732 | bgp_imexport_vrf_cmd, | |
6733 | "[no] import vrf NAME$import_name", | |
6734 | NO_STR | |
6735 | "Import routes from another VRF\n" | |
6736 | "VRF to import from\n" | |
6737 | "The name of the VRF\n") | |
6738 | { | |
6739 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6740 | struct listnode *node; | |
79ef8664 DS |
6741 | struct bgp *vrf_bgp, *bgp_default; |
6742 | int32_t ret = 0; | |
6743 | as_t as = bgp->as; | |
12a844a5 DS |
6744 | bool remove = false; |
6745 | int32_t idx = 0; | |
6746 | char *vname; | |
a8dadcf6 | 6747 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; |
12a844a5 DS |
6748 | safi_t safi; |
6749 | afi_t afi; | |
6750 | ||
867f0cca | 6751 | if (import_name == NULL) { |
6752 | vty_out(vty, "%% Missing import name\n"); | |
6753 | return CMD_WARNING; | |
6754 | } | |
6755 | ||
12a844a5 DS |
6756 | if (argv_find(argv, argc, "no", &idx)) |
6757 | remove = true; | |
6758 | ||
0ca70ba5 DS |
6759 | afi = vpn_policy_getafi(vty, bgp, true); |
6760 | if (afi == AFI_MAX) | |
6761 | return CMD_WARNING_CONFIG_FAILED; | |
6762 | ||
12a844a5 DS |
6763 | safi = bgp_node_safi(vty); |
6764 | ||
25679caa DS |
6765 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) |
6766 | && (strcmp(import_name, BGP_DEFAULT_NAME) == 0)) | |
6767 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { | |
6768 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
6769 | remove ? "unimport" : "import", import_name); | |
6770 | return CMD_WARNING; | |
6771 | } | |
6772 | ||
79ef8664 DS |
6773 | bgp_default = bgp_get_default(); |
6774 | if (!bgp_default) { | |
6775 | /* Auto-create assuming the same AS */ | |
6776 | ret = bgp_get(&bgp_default, &as, NULL, | |
6777 | BGP_INSTANCE_TYPE_DEFAULT); | |
6778 | ||
6779 | if (ret) { | |
6780 | vty_out(vty, | |
6781 | "VRF default is not configured as a bgp instance\n"); | |
6782 | return CMD_WARNING; | |
6783 | } | |
6784 | } | |
6785 | ||
12a844a5 DS |
6786 | vrf_bgp = bgp_lookup_by_name(import_name); |
6787 | if (!vrf_bgp) { | |
79ef8664 DS |
6788 | if (strcmp(import_name, BGP_DEFAULT_NAME) == 0) |
6789 | vrf_bgp = bgp_default; | |
6790 | else | |
0fb8d6e6 DS |
6791 | /* Auto-create assuming the same AS */ |
6792 | ret = bgp_get(&vrf_bgp, &as, import_name, bgp_type); | |
a8dadcf6 | 6793 | |
6e2c7fe6 | 6794 | if (ret) { |
020a3f60 DS |
6795 | vty_out(vty, |
6796 | "VRF %s is not configured as a bgp instance\n", | |
6e2c7fe6 DS |
6797 | import_name); |
6798 | return CMD_WARNING; | |
6799 | } | |
12a844a5 DS |
6800 | } |
6801 | ||
12a844a5 | 6802 | if (remove) { |
44338987 | 6803 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 | 6804 | } else { |
44338987 | 6805 | /* Already importing from "import_vrf"? */ |
12a844a5 DS |
6806 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, |
6807 | vname)) { | |
6808 | if (strcmp(vname, import_name) == 0) | |
6809 | return CMD_WARNING; | |
6810 | } | |
6811 | ||
44338987 | 6812 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 DS |
6813 | } |
6814 | ||
6815 | return CMD_SUCCESS; | |
6816 | } | |
6817 | ||
b9c7bc5a PZ |
6818 | /* This command is valid only in a bgp vrf instance or the default instance */ |
6819 | DEFPY (bgp_imexport_vpn, | |
6820 | bgp_imexport_vpn_cmd, | |
6821 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
6822 | NO_STR |
6823 | "Import routes to this address-family\n" | |
6824 | "Export routes from this address-family\n" | |
6825 | "to/from default instance VPN RIB\n") | |
ddb5b488 PZ |
6826 | { |
6827 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 6828 | int previous_state; |
ddb5b488 | 6829 | afi_t afi; |
b9c7bc5a | 6830 | safi_t safi; |
ddb5b488 | 6831 | int idx = 0; |
b9c7bc5a PZ |
6832 | int yes = 1; |
6833 | int flag; | |
6834 | vpn_policy_direction_t dir; | |
ddb5b488 | 6835 | |
b9c7bc5a | 6836 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6837 | yes = 0; |
ddb5b488 | 6838 | |
b9c7bc5a PZ |
6839 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && |
6840 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
ddb5b488 | 6841 | |
b9c7bc5a PZ |
6842 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); |
6843 | return CMD_WARNING_CONFIG_FAILED; | |
6844 | } | |
ddb5b488 | 6845 | |
b9c7bc5a PZ |
6846 | afi = bgp_node_afi(vty); |
6847 | safi = bgp_node_safi(vty); | |
6848 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { | |
6849 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
6850 | return CMD_WARNING_CONFIG_FAILED; | |
6851 | } | |
ddb5b488 | 6852 | |
b9c7bc5a PZ |
6853 | if (!strcmp(direction_str, "import")) { |
6854 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; | |
6855 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
6856 | } else if (!strcmp(direction_str, "export")) { | |
6857 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; | |
6858 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
6859 | } else { | |
6860 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
6861 | return CMD_WARNING_CONFIG_FAILED; | |
6862 | } | |
6863 | ||
6864 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 | 6865 | |
b9c7bc5a PZ |
6866 | if (yes) { |
6867 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
6868 | if (!previous_state) { | |
6869 | /* trigger export current vrf */ | |
ddb5b488 PZ |
6870 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
6871 | } | |
b9c7bc5a PZ |
6872 | } else { |
6873 | if (previous_state) { | |
6874 | /* trigger un-export current vrf */ | |
6875 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
6876 | } | |
6877 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 PZ |
6878 | } |
6879 | ||
6880 | return CMD_SUCCESS; | |
6881 | } | |
6882 | ||
301ad80a PG |
6883 | DEFPY (af_routetarget_import, |
6884 | af_routetarget_import_cmd, | |
6885 | "[no] <rt|route-target> redirect import RTLIST...", | |
6886 | NO_STR | |
6887 | "Specify route target list\n" | |
6888 | "Specify route target list\n" | |
6889 | "Flow-spec redirect type route target\n" | |
6890 | "Import routes to this address-family\n" | |
6891 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") | |
6892 | { | |
6893 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6894 | int ret; | |
6895 | struct ecommunity *ecom = NULL; | |
301ad80a PG |
6896 | afi_t afi; |
6897 | int idx = 0; | |
6898 | int yes = 1; | |
6899 | ||
6900 | if (argv_find(argv, argc, "no", &idx)) | |
6901 | yes = 0; | |
6902 | ||
0ca70ba5 | 6903 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6904 | if (afi == AFI_MAX) |
6905 | return CMD_WARNING_CONFIG_FAILED; | |
6906 | ||
301ad80a PG |
6907 | if (yes) { |
6908 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
6909 | vty_out(vty, "%% Missing RTLIST\n"); | |
6910 | return CMD_WARNING_CONFIG_FAILED; | |
6911 | } | |
6912 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
6913 | if (ret != CMD_SUCCESS) | |
6914 | return ret; | |
6915 | } | |
69b07479 DS |
6916 | |
6917 | if (yes) { | |
6918 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
6919 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 6920 | .import_redirect_rtlist); |
69b07479 DS |
6921 | bgp->vpn_policy[afi].import_redirect_rtlist = |
6922 | ecommunity_dup(ecom); | |
6923 | } else { | |
6924 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
6925 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 6926 | .import_redirect_rtlist); |
69b07479 | 6927 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 6928 | } |
69b07479 | 6929 | |
301ad80a PG |
6930 | if (ecom) |
6931 | ecommunity_free(&ecom); | |
6932 | ||
6933 | return CMD_SUCCESS; | |
6934 | } | |
6935 | ||
505e5056 | 6936 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 6937 | address_family_ipv4_safi_cmd, |
6938 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
6939 | "Enter Address Family command mode\n" | |
6940 | "Address Family\n" | |
6941 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
718e3744 | 6942 | { |
f51bae9c | 6943 | |
d62a17ae | 6944 | if (argc == 3) { |
2131d5cf | 6945 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 6946 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
6947 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
6948 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 6949 | && safi != SAFI_EVPN) { |
31947174 MK |
6950 | vty_out(vty, |
6951 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
6952 | return CMD_WARNING_CONFIG_FAILED; |
6953 | } | |
d62a17ae | 6954 | vty->node = bgp_node_type(AFI_IP, safi); |
6955 | } else | |
6956 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 6957 | |
d62a17ae | 6958 | return CMD_SUCCESS; |
718e3744 | 6959 | } |
6960 | ||
505e5056 | 6961 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 6962 | address_family_ipv6_safi_cmd, |
6963 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
6964 | "Enter Address Family command mode\n" | |
6965 | "Address Family\n" | |
6966 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
25ffbdc1 | 6967 | { |
d62a17ae | 6968 | if (argc == 3) { |
2131d5cf | 6969 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 6970 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
6971 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
6972 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 6973 | && safi != SAFI_EVPN) { |
31947174 MK |
6974 | vty_out(vty, |
6975 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
6976 | return CMD_WARNING_CONFIG_FAILED; |
6977 | } | |
d62a17ae | 6978 | vty->node = bgp_node_type(AFI_IP6, safi); |
6979 | } else | |
6980 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 6981 | |
d62a17ae | 6982 | return CMD_SUCCESS; |
25ffbdc1 | 6983 | } |
718e3744 | 6984 | |
d6902373 | 6985 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 6986 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 6987 | address_family_vpnv4_cmd, |
8334fd5a | 6988 | "address-family vpnv4 [unicast]", |
718e3744 | 6989 | "Enter Address Family command mode\n" |
8c3deaae | 6990 | "Address Family\n" |
3a2d747c | 6991 | "Address Family modifier\n") |
718e3744 | 6992 | { |
d62a17ae | 6993 | vty->node = BGP_VPNV4_NODE; |
6994 | return CMD_SUCCESS; | |
718e3744 | 6995 | } |
6996 | ||
505e5056 | 6997 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 6998 | address_family_vpnv6_cmd, |
8334fd5a | 6999 | "address-family vpnv6 [unicast]", |
8ecd3266 | 7000 | "Enter Address Family command mode\n" |
8c3deaae | 7001 | "Address Family\n" |
3a2d747c | 7002 | "Address Family modifier\n") |
8ecd3266 | 7003 | { |
d62a17ae | 7004 | vty->node = BGP_VPNV6_NODE; |
7005 | return CMD_SUCCESS; | |
8ecd3266 | 7006 | } |
c016b6c7 | 7007 | #endif |
d6902373 | 7008 | |
505e5056 | 7009 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 7010 | address_family_evpn_cmd, |
7111c1a0 | 7011 | "address-family l2vpn evpn", |
4e0b7b6d | 7012 | "Enter Address Family command mode\n" |
7111c1a0 QY |
7013 | "Address Family\n" |
7014 | "Address Family modifier\n") | |
4e0b7b6d | 7015 | { |
2131d5cf | 7016 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7017 | vty->node = BGP_EVPN_NODE; |
7018 | return CMD_SUCCESS; | |
4e0b7b6d PG |
7019 | } |
7020 | ||
505e5056 | 7021 | DEFUN_NOSH (exit_address_family, |
718e3744 | 7022 | exit_address_family_cmd, |
7023 | "exit-address-family", | |
7024 | "Exit from Address Family configuration mode\n") | |
7025 | { | |
d62a17ae | 7026 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
7027 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
7028 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
7029 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
7030 | || vty->node == BGP_EVPN_NODE |
7031 | || vty->node == BGP_FLOWSPECV4_NODE | |
7032 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 7033 | vty->node = BGP_NODE; |
7034 | return CMD_SUCCESS; | |
718e3744 | 7035 | } |
6b0655a2 | 7036 | |
8ad7271d | 7037 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 7038 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
7039 | const char *ip_str, afi_t afi, safi_t safi, | |
7040 | struct prefix_rd *prd) | |
7041 | { | |
7042 | int ret; | |
7043 | struct prefix match; | |
7044 | struct bgp_node *rn; | |
7045 | struct bgp_node *rm; | |
7046 | struct bgp *bgp; | |
7047 | struct bgp_table *table; | |
7048 | struct bgp_table *rib; | |
7049 | ||
7050 | /* BGP structure lookup. */ | |
7051 | if (view_name) { | |
7052 | bgp = bgp_lookup_by_name(view_name); | |
7053 | if (bgp == NULL) { | |
7054 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
7055 | view_name); | |
7056 | return CMD_WARNING; | |
7057 | } | |
7058 | } else { | |
7059 | bgp = bgp_get_default(); | |
7060 | if (bgp == NULL) { | |
7061 | vty_out(vty, "%% No BGP process is configured\n"); | |
7062 | return CMD_WARNING; | |
7063 | } | |
7064 | } | |
7065 | ||
7066 | /* Check IP address argument. */ | |
7067 | ret = str2prefix(ip_str, &match); | |
7068 | if (!ret) { | |
7069 | vty_out(vty, "%% address is malformed\n"); | |
7070 | return CMD_WARNING; | |
7071 | } | |
7072 | ||
7073 | match.family = afi2family(afi); | |
7074 | rib = bgp->rib[afi][safi]; | |
7075 | ||
7076 | if (safi == SAFI_MPLS_VPN) { | |
7077 | for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) { | |
7078 | if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0) | |
7079 | continue; | |
7080 | ||
7081 | if ((table = rn->info) != NULL) { | |
7082 | if ((rm = bgp_node_match(table, &match)) | |
7083 | != NULL) { | |
7084 | if (rm->p.prefixlen | |
7085 | == match.prefixlen) { | |
343cdb61 | 7086 | SET_FLAG(rm->flags, |
d62a17ae | 7087 | BGP_NODE_USER_CLEAR); |
7088 | bgp_process(bgp, rm, afi, safi); | |
7089 | } | |
7090 | bgp_unlock_node(rm); | |
7091 | } | |
7092 | } | |
7093 | } | |
7094 | } else { | |
7095 | if ((rn = bgp_node_match(rib, &match)) != NULL) { | |
7096 | if (rn->p.prefixlen == match.prefixlen) { | |
7097 | SET_FLAG(rn->flags, BGP_NODE_USER_CLEAR); | |
7098 | bgp_process(bgp, rn, afi, safi); | |
7099 | } | |
7100 | bgp_unlock_node(rn); | |
7101 | } | |
7102 | } | |
7103 | ||
7104 | return CMD_SUCCESS; | |
8ad7271d DS |
7105 | } |
7106 | ||
b09b5ae0 | 7107 | /* one clear bgp command to rule them all */ |
718e3744 | 7108 | DEFUN (clear_ip_bgp_all, |
7109 | clear_ip_bgp_all_cmd, | |
c1a44e43 | 7110 | "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 | 7111 | CLEAR_STR |
7112 | IP_STR | |
7113 | BGP_STR | |
838758ac | 7114 | BGP_INSTANCE_HELP_STR |
510afcd6 DS |
7115 | BGP_AFI_HELP_STR |
7116 | BGP_SAFI_WITH_LABEL_HELP_STR | |
b09b5ae0 DW |
7117 | "Clear all peers\n" |
7118 | "BGP neighbor address to clear\n" | |
a80beece | 7119 | "BGP IPv6 neighbor to clear\n" |
838758ac | 7120 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
7121 | "Clear peers with the AS number\n" |
7122 | "Clear all external peers\n" | |
718e3744 | 7123 | "Clear all members of peer-group\n" |
b09b5ae0 | 7124 | "BGP peer-group name\n" |
b09b5ae0 DW |
7125 | BGP_SOFT_STR |
7126 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
7127 | BGP_SOFT_OUT_STR |
7128 | BGP_SOFT_IN_STR | |
7129 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 7130 | BGP_SOFT_OUT_STR) |
718e3744 | 7131 | { |
d62a17ae | 7132 | char *vrf = NULL; |
7133 | ||
7134 | afi_t afi = AFI_IP6; | |
7135 | safi_t safi = SAFI_UNICAST; | |
7136 | enum clear_sort clr_sort = clear_peer; | |
7137 | enum bgp_clear_type clr_type; | |
7138 | char *clr_arg = NULL; | |
7139 | ||
7140 | int idx = 0; | |
7141 | ||
7142 | /* clear [ip] bgp */ | |
7143 | if (argv_find(argv, argc, "ip", &idx)) | |
7144 | afi = AFI_IP; | |
7145 | ||
7146 | /* [<view|vrf> VIEWVRFNAME] */ | |
7147 | if (argv_find(argv, argc, "view", &idx) | |
7148 | || argv_find(argv, argc, "vrf", &idx)) { | |
7149 | vrf = argv[idx + 1]->arg; | |
7150 | idx += 2; | |
7151 | } | |
7152 | ||
7153 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
7154 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
7155 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
7156 | ||
7157 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */ | |
7158 | if (argv_find(argv, argc, "*", &idx)) { | |
7159 | clr_sort = clear_all; | |
7160 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
7161 | clr_sort = clear_peer; | |
7162 | clr_arg = argv[idx]->arg; | |
7163 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
7164 | clr_sort = clear_peer; | |
7165 | clr_arg = argv[idx]->arg; | |
7166 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
7167 | clr_sort = clear_group; | |
7168 | idx++; | |
7169 | clr_arg = argv[idx]->arg; | |
7170 | } else if (argv_find(argv, argc, "WORD", &idx)) { | |
7171 | clr_sort = clear_peer; | |
7172 | clr_arg = argv[idx]->arg; | |
7173 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { | |
7174 | clr_sort = clear_as; | |
7175 | clr_arg = argv[idx]->arg; | |
7176 | } else if (argv_find(argv, argc, "external", &idx)) { | |
7177 | clr_sort = clear_external; | |
7178 | } | |
7179 | ||
7180 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
7181 | if (argv_find(argv, argc, "soft", &idx)) { | |
7182 | if (argv_find(argv, argc, "in", &idx) | |
7183 | || argv_find(argv, argc, "out", &idx)) | |
7184 | clr_type = strmatch(argv[idx]->text, "in") | |
7185 | ? BGP_CLEAR_SOFT_IN | |
7186 | : BGP_CLEAR_SOFT_OUT; | |
7187 | else | |
7188 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
7189 | } else if (argv_find(argv, argc, "in", &idx)) { | |
7190 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
7191 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
7192 | : BGP_CLEAR_SOFT_IN; | |
7193 | } else if (argv_find(argv, argc, "out", &idx)) { | |
7194 | clr_type = BGP_CLEAR_SOFT_OUT; | |
7195 | } else | |
7196 | clr_type = BGP_CLEAR_SOFT_NONE; | |
7197 | ||
7198 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); | |
838758ac | 7199 | } |
01080f7c | 7200 | |
8ad7271d DS |
7201 | DEFUN (clear_ip_bgp_prefix, |
7202 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 7203 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
7204 | CLEAR_STR |
7205 | IP_STR | |
7206 | BGP_STR | |
838758ac | 7207 | BGP_INSTANCE_HELP_STR |
8ad7271d | 7208 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7209 | "IPv4 prefix\n") |
8ad7271d | 7210 | { |
d62a17ae | 7211 | char *vrf = NULL; |
7212 | char *prefix = NULL; | |
8ad7271d | 7213 | |
d62a17ae | 7214 | int idx = 0; |
01080f7c | 7215 | |
d62a17ae | 7216 | /* [<view|vrf> VIEWVRFNAME] */ |
1d35f218 | 7217 | if (argv_find(argv, argc, "VIEWVRFNAME", &idx)) |
d62a17ae | 7218 | vrf = argv[idx]->arg; |
0c7b1b01 | 7219 | |
d62a17ae | 7220 | prefix = argv[argc - 1]->arg; |
8ad7271d | 7221 | |
d62a17ae | 7222 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 7223 | } |
8ad7271d | 7224 | |
b09b5ae0 DW |
7225 | DEFUN (clear_bgp_ipv6_safi_prefix, |
7226 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 7227 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 7228 | CLEAR_STR |
3a2d747c | 7229 | IP_STR |
718e3744 | 7230 | BGP_STR |
8c3deaae | 7231 | "Address Family\n" |
46f296b4 | 7232 | BGP_SAFI_HELP_STR |
b09b5ae0 | 7233 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7234 | "IPv6 prefix\n") |
718e3744 | 7235 | { |
9b475e76 PG |
7236 | int idx_safi = 0; |
7237 | int idx_ipv6_prefix = 0; | |
7238 | safi_t safi = SAFI_UNICAST; | |
7239 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
7240 | argv[idx_ipv6_prefix]->arg : NULL; | |
7241 | ||
7242 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 7243 | return bgp_clear_prefix( |
9b475e76 PG |
7244 | vty, NULL, prefix, AFI_IP6, |
7245 | safi, NULL); | |
838758ac | 7246 | } |
01080f7c | 7247 | |
b09b5ae0 DW |
7248 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
7249 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 7250 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 7251 | CLEAR_STR |
3a2d747c | 7252 | IP_STR |
718e3744 | 7253 | BGP_STR |
838758ac | 7254 | BGP_INSTANCE_HELP_STR |
8c3deaae | 7255 | "Address Family\n" |
46f296b4 | 7256 | BGP_SAFI_HELP_STR |
b09b5ae0 | 7257 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7258 | "IPv6 prefix\n") |
718e3744 | 7259 | { |
d62a17ae | 7260 | int idx_word = 3; |
9b475e76 PG |
7261 | int idx_safi = 0; |
7262 | int idx_ipv6_prefix = 0; | |
7263 | safi_t safi = SAFI_UNICAST; | |
7264 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
7265 | argv[idx_ipv6_prefix]->arg : NULL; | |
7266 | /* [<view|vrf> VIEWVRFNAME] */ | |
7267 | char *vrfview = argv_find(argv, argc, "VIEWVRFNAME", &idx_word) ? | |
7268 | argv[idx_word]->arg : NULL; | |
7269 | ||
7270 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
7271 | ||
d62a17ae | 7272 | return bgp_clear_prefix( |
9b475e76 PG |
7273 | vty, vrfview, prefix, |
7274 | AFI_IP6, safi, NULL); | |
718e3744 | 7275 | } |
7276 | ||
b09b5ae0 DW |
7277 | DEFUN (show_bgp_views, |
7278 | show_bgp_views_cmd, | |
d6e3c605 | 7279 | "show [ip] bgp views", |
b09b5ae0 | 7280 | SHOW_STR |
d6e3c605 | 7281 | IP_STR |
01080f7c | 7282 | BGP_STR |
b09b5ae0 | 7283 | "Show the defined BGP views\n") |
01080f7c | 7284 | { |
d62a17ae | 7285 | struct list *inst = bm->bgp; |
7286 | struct listnode *node; | |
7287 | struct bgp *bgp; | |
01080f7c | 7288 | |
d62a17ae | 7289 | if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE)) { |
7290 | vty_out(vty, "BGP Multiple Instance is not enabled\n"); | |
7291 | return CMD_WARNING; | |
7292 | } | |
e52702f2 | 7293 | |
d62a17ae | 7294 | vty_out(vty, "Defined BGP views:\n"); |
7295 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
7296 | /* Skip VRFs. */ | |
7297 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
7298 | continue; | |
7299 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
7300 | bgp->as); | |
7301 | } | |
e52702f2 | 7302 | |
d62a17ae | 7303 | return CMD_SUCCESS; |
e0081f70 ML |
7304 | } |
7305 | ||
8386ac43 | 7306 | DEFUN (show_bgp_vrfs, |
7307 | show_bgp_vrfs_cmd, | |
d6e3c605 | 7308 | "show [ip] bgp vrfs [json]", |
8386ac43 | 7309 | SHOW_STR |
d6e3c605 | 7310 | IP_STR |
8386ac43 | 7311 | BGP_STR |
7312 | "Show BGP VRFs\n" | |
9973d184 | 7313 | JSON_STR) |
8386ac43 | 7314 | { |
fe1dc5a3 | 7315 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 7316 | struct list *inst = bm->bgp; |
7317 | struct listnode *node; | |
7318 | struct bgp *bgp; | |
d7c0a89a | 7319 | uint8_t uj = use_json(argc, argv); |
d62a17ae | 7320 | json_object *json = NULL; |
7321 | json_object *json_vrfs = NULL; | |
7322 | int count = 0; | |
d62a17ae | 7323 | |
7324 | if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE)) { | |
7325 | vty_out(vty, "BGP Multiple Instance is not enabled\n"); | |
7326 | return CMD_WARNING; | |
7327 | } | |
7328 | ||
7329 | if (uj) { | |
7330 | json = json_object_new_object(); | |
7331 | json_vrfs = json_object_new_object(); | |
7332 | } | |
7333 | ||
7334 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
7335 | const char *name, *type; | |
7336 | struct peer *peer; | |
7337 | struct listnode *node, *nnode; | |
7338 | int peers_cfg, peers_estb; | |
7339 | json_object *json_vrf = NULL; | |
d62a17ae | 7340 | |
7341 | /* Skip Views. */ | |
7342 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
7343 | continue; | |
7344 | ||
7345 | count++; | |
7346 | if (!uj && count == 1) | |
fe1dc5a3 MK |
7347 | vty_out(vty, |
7348 | "%4s %-5s %-16s %9s %10s %-37s %-10s %-15s\n", | |
a4d82a8a PZ |
7349 | "Type", "Id", "routerId", "#PeersVfg", |
7350 | "#PeersEstb", "Name", "L3-VNI", "Rmac"); | |
d62a17ae | 7351 | |
7352 | peers_cfg = peers_estb = 0; | |
7353 | if (uj) | |
7354 | json_vrf = json_object_new_object(); | |
7355 | ||
7356 | ||
7357 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
7358 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
7359 | continue; | |
7360 | peers_cfg++; | |
7361 | if (peer->status == Established) | |
7362 | peers_estb++; | |
7363 | } | |
7364 | ||
7365 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
7366 | name = "Default"; | |
7367 | type = "DFLT"; | |
7368 | } else { | |
7369 | name = bgp->name; | |
7370 | type = "VRF"; | |
7371 | } | |
7372 | ||
a8bf7d9c | 7373 | |
d62a17ae | 7374 | if (uj) { |
a4d82a8a PZ |
7375 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
7376 | ? -1 | |
7377 | : (int64_t)bgp->vrf_id; | |
d62a17ae | 7378 | json_object_string_add(json_vrf, "type", type); |
7379 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
7380 | json_object_string_add(json_vrf, "routerId", | |
7381 | inet_ntoa(bgp->router_id)); | |
7382 | json_object_int_add(json_vrf, "numConfiguredPeers", | |
7383 | peers_cfg); | |
7384 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
7385 | peers_estb); | |
7386 | ||
fe1dc5a3 | 7387 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
7388 | json_object_string_add( |
7389 | json_vrf, "rmac", | |
7390 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
d62a17ae | 7391 | json_object_object_add(json_vrfs, name, json_vrf); |
7392 | } else | |
fe1dc5a3 MK |
7393 | vty_out(vty, |
7394 | "%4s %-5d %-16s %9u %10u %-37s %-10u %-15s\n", | |
a4d82a8a PZ |
7395 | type, |
7396 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
7397 | : (int)bgp->vrf_id, | |
7398 | inet_ntoa(bgp->router_id), peers_cfg, | |
7399 | peers_estb, name, bgp->l3vni, | |
fe1dc5a3 | 7400 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); |
d62a17ae | 7401 | } |
7402 | ||
7403 | if (uj) { | |
7404 | json_object_object_add(json, "vrfs", json_vrfs); | |
7405 | ||
7406 | json_object_int_add(json, "totalVrfs", count); | |
7407 | ||
996c9314 LB |
7408 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
7409 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 7410 | json_object_free(json); |
7411 | } else { | |
7412 | if (count) | |
7413 | vty_out(vty, | |
7414 | "\nTotal number of VRFs (including default): %d\n", | |
7415 | count); | |
7416 | } | |
7417 | ||
7418 | return CMD_SUCCESS; | |
8386ac43 | 7419 | } |
7420 | ||
acf71666 MK |
7421 | static void show_address_entry(struct hash_backet *backet, void *args) |
7422 | { | |
60466a63 QY |
7423 | struct vty *vty = (struct vty *)args; |
7424 | struct bgp_addr *addr = (struct bgp_addr *)backet->data; | |
acf71666 | 7425 | |
60466a63 | 7426 | vty_out(vty, "addr: %s, count: %d\n", inet_ntoa(addr->addr), |
acf71666 MK |
7427 | addr->refcnt); |
7428 | } | |
7429 | ||
7430 | static void show_tip_entry(struct hash_backet *backet, void *args) | |
7431 | { | |
0291c246 | 7432 | struct vty *vty = (struct vty *)args; |
60466a63 | 7433 | struct tip_addr *tip = (struct tip_addr *)backet->data; |
acf71666 | 7434 | |
60466a63 | 7435 | vty_out(vty, "addr: %s, count: %d\n", inet_ntoa(tip->addr), |
acf71666 MK |
7436 | tip->refcnt); |
7437 | } | |
7438 | ||
7439 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
7440 | { | |
7441 | vty_out(vty, "self nexthop database:\n"); | |
7442 | hash_iterate(bgp->address_hash, | |
7443 | (void (*)(struct hash_backet *, void *))show_address_entry, | |
7444 | vty); | |
7445 | ||
7446 | vty_out(vty, "Tunnel-ip database:\n"); | |
7447 | hash_iterate(bgp->tip_hash, | |
7448 | (void (*)(struct hash_backet *, void *))show_tip_entry, | |
7449 | vty); | |
7450 | } | |
7451 | ||
15c81ca4 DS |
7452 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
7453 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
7454 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
7455 | "martian next-hops\n" |
7456 | "martian next-hop database\n") | |
acf71666 | 7457 | { |
0291c246 | 7458 | struct bgp *bgp = NULL; |
15c81ca4 DS |
7459 | int idx = 0; |
7460 | ||
7461 | if (argv_find(argv, argc, "view", &idx) | |
7462 | || argv_find(argv, argc, "vrf", &idx)) | |
7463 | bgp = bgp_lookup_by_name(argv[idx + 1]->arg); | |
7464 | else | |
7465 | bgp = bgp_get_default(); | |
acf71666 | 7466 | |
acf71666 MK |
7467 | if (!bgp) { |
7468 | vty_out(vty, "%% No BGP process is configured\n"); | |
7469 | return CMD_WARNING; | |
7470 | } | |
7471 | bgp_show_martian_nexthops(vty, bgp); | |
7472 | ||
7473 | return CMD_SUCCESS; | |
7474 | } | |
7475 | ||
f412b39a | 7476 | DEFUN (show_bgp_memory, |
4bf6a362 | 7477 | show_bgp_memory_cmd, |
7fa12b13 | 7478 | "show [ip] bgp memory", |
4bf6a362 | 7479 | SHOW_STR |
3a2d747c | 7480 | IP_STR |
4bf6a362 PJ |
7481 | BGP_STR |
7482 | "Global BGP memory statistics\n") | |
7483 | { | |
d62a17ae | 7484 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
7485 | unsigned long count; | |
7486 | ||
7487 | /* RIB related usage stats */ | |
7488 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
7489 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
7490 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7491 | count * sizeof(struct bgp_node))); | |
7492 | ||
7493 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
7494 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
7495 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7496 | count * sizeof(struct bgp_info))); | |
7497 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) | |
7498 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
7499 | count, | |
7500 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7501 | count * sizeof(struct bgp_info_extra))); | |
7502 | ||
7503 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
7504 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
7505 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7506 | count * sizeof(struct bgp_static))); | |
7507 | ||
7508 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
7509 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
7510 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7511 | count * sizeof(struct bpacket))); | |
7512 | ||
7513 | /* Adj-In/Out */ | |
7514 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
7515 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
7516 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7517 | count * sizeof(struct bgp_adj_in))); | |
7518 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
7519 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
7520 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7521 | count * sizeof(struct bgp_adj_out))); | |
7522 | ||
7523 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
7524 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
7525 | count, | |
7526 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7527 | count * sizeof(struct bgp_nexthop_cache))); | |
7528 | ||
7529 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
7530 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
7531 | count, | |
7532 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7533 | count * sizeof(struct bgp_damp_info))); | |
7534 | ||
7535 | /* Attributes */ | |
7536 | count = attr_count(); | |
7537 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
7538 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7539 | count * sizeof(struct attr))); | |
7540 | ||
7541 | if ((count = attr_unknown_count())) | |
7542 | vty_out(vty, "%ld unknown attributes\n", count); | |
7543 | ||
7544 | /* AS_PATH attributes */ | |
7545 | count = aspath_count(); | |
7546 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
7547 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7548 | count * sizeof(struct aspath))); | |
7549 | ||
7550 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
7551 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
7552 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7553 | count * sizeof(struct assegment))); | |
7554 | ||
7555 | /* Other attributes */ | |
7556 | if ((count = community_count())) | |
7557 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
7558 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7559 | count * sizeof(struct community))); | |
d62a17ae | 7560 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
7561 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
7562 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7563 | count * sizeof(struct ecommunity))); | |
d62a17ae | 7564 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
7565 | vty_out(vty, | |
7566 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
7567 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7568 | count * sizeof(struct lcommunity))); | |
d62a17ae | 7569 | |
7570 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
7571 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
7572 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7573 | count * sizeof(struct cluster_list))); | |
7574 | ||
7575 | /* Peer related usage */ | |
7576 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
7577 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
7578 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7579 | count * sizeof(struct peer))); | |
7580 | ||
7581 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
7582 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
7583 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7584 | count * sizeof(struct peer_group))); | |
7585 | ||
7586 | /* Other */ | |
7587 | if ((count = mtype_stats_alloc(MTYPE_HASH))) | |
7588 | vty_out(vty, "%ld hash tables, using %s of memory\n", count, | |
7589 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7590 | count * sizeof(struct hash))); | |
7591 | if ((count = mtype_stats_alloc(MTYPE_HASH_BACKET))) | |
7592 | vty_out(vty, "%ld hash buckets, using %s of memory\n", count, | |
7593 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7594 | count * sizeof(struct hash_backet))); | |
7595 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) | |
7596 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
7597 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7598 | count * sizeof(regex_t))); | |
d62a17ae | 7599 | return CMD_SUCCESS; |
4bf6a362 | 7600 | } |
fee0f4c6 | 7601 | |
57a9c8a8 DS |
7602 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
7603 | { | |
7604 | json_object *bestpath = json_object_new_object(); | |
7605 | ||
7606 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_IGNORE)) | |
7607 | json_object_string_add(bestpath, "asPath", "ignore"); | |
7608 | ||
7609 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_CONFED)) | |
7610 | json_object_string_add(bestpath, "asPath", "confed"); | |
7611 | ||
7612 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { | |
a4d82a8a PZ |
7613 | if (bgp_flag_check(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) |
7614 | json_object_string_add(bestpath, "multiPathRelax", | |
57a9c8a8 DS |
7615 | "as-set"); |
7616 | else | |
a4d82a8a | 7617 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
7618 | "true"); |
7619 | } else | |
a4d82a8a | 7620 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 DS |
7621 | |
7622 | if (bgp_flag_check(bgp, BGP_FLAG_COMPARE_ROUTER_ID)) | |
7623 | json_object_string_add(bestpath, "compareRouterId", "true"); | |
7624 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED) | |
7625 | || bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
7626 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 7627 | json_object_string_add(bestpath, "med", "confed"); |
57a9c8a8 DS |
7628 | if (bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) |
7629 | json_object_string_add(bestpath, "med", | |
7630 | "missing-as-worst"); | |
7631 | else | |
7632 | json_object_string_add(bestpath, "med", "true"); | |
7633 | } | |
7634 | ||
7635 | json_object_object_add(json, "bestPath", bestpath); | |
7636 | } | |
7637 | ||
718e3744 | 7638 | /* Show BGP peer's summary information. */ |
d62a17ae | 7639 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
d7c0a89a | 7640 | uint8_t use_json, json_object *json) |
d62a17ae | 7641 | { |
7642 | struct peer *peer; | |
7643 | struct listnode *node, *nnode; | |
7644 | unsigned int count = 0, dn_count = 0; | |
7645 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
7646 | char neighbor_buf[VTY_BUFSIZ]; | |
7647 | int neighbor_col_default_width = 16; | |
7648 | int len; | |
7649 | int max_neighbor_width = 0; | |
7650 | int pfx_rcd_safi; | |
7651 | json_object *json_peer = NULL; | |
7652 | json_object *json_peers = NULL; | |
7653 | ||
7654 | /* labeled-unicast routes are installed in the unicast table so in order | |
7655 | * to | |
7656 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
7657 | */ | |
7658 | if (safi == SAFI_LABELED_UNICAST) | |
7659 | pfx_rcd_safi = SAFI_UNICAST; | |
7660 | else | |
7661 | pfx_rcd_safi = safi; | |
7662 | ||
7663 | if (use_json) { | |
7664 | if (json == NULL) | |
7665 | json = json_object_new_object(); | |
7666 | ||
7667 | json_peers = json_object_new_object(); | |
7668 | } else { | |
7669 | /* Loop over all neighbors that will be displayed to determine | |
7670 | * how many | |
7671 | * characters are needed for the Neighbor column | |
7672 | */ | |
7673 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
7674 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
7675 | continue; | |
7676 | ||
7677 | if (peer->afc[afi][safi]) { | |
7678 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
7679 | if (peer_dynamic_neighbor(peer)) | |
7680 | dn_flag[0] = '*'; | |
7681 | ||
7682 | if (peer->hostname | |
7683 | && bgp_flag_check(bgp, | |
7684 | BGP_FLAG_SHOW_HOSTNAME)) | |
7685 | sprintf(neighbor_buf, "%s%s(%s) ", | |
7686 | dn_flag, peer->hostname, | |
7687 | peer->host); | |
7688 | else | |
7689 | sprintf(neighbor_buf, "%s%s ", dn_flag, | |
7690 | peer->host); | |
7691 | ||
7692 | len = strlen(neighbor_buf); | |
7693 | ||
7694 | if (len > max_neighbor_width) | |
7695 | max_neighbor_width = len; | |
7696 | } | |
7697 | } | |
f933309e | 7698 | |
d62a17ae | 7699 | /* Originally we displayed the Neighbor column as 16 |
7700 | * characters wide so make that the default | |
7701 | */ | |
7702 | if (max_neighbor_width < neighbor_col_default_width) | |
7703 | max_neighbor_width = neighbor_col_default_width; | |
7704 | } | |
f933309e | 7705 | |
d62a17ae | 7706 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
7707 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
7708 | continue; | |
7709 | ||
ea47320b DL |
7710 | if (!peer->afc[afi][safi]) |
7711 | continue; | |
d62a17ae | 7712 | |
ea47320b DL |
7713 | if (!count) { |
7714 | unsigned long ents; | |
7715 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 7716 | int64_t vrf_id_ui; |
d62a17ae | 7717 | |
a4d82a8a PZ |
7718 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
7719 | ? -1 | |
7720 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
7721 | |
7722 | /* Usage summary and header */ | |
7723 | if (use_json) { | |
7724 | json_object_string_add( | |
7725 | json, "routerId", | |
7726 | inet_ntoa(bgp->router_id)); | |
60466a63 QY |
7727 | json_object_int_add(json, "as", bgp->as); |
7728 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
7729 | json_object_string_add( |
7730 | json, "vrfName", | |
7731 | (bgp->inst_type | |
7732 | == BGP_INSTANCE_TYPE_DEFAULT) | |
7733 | ? "Default" | |
7734 | : bgp->name); | |
7735 | } else { | |
7736 | vty_out(vty, | |
7737 | "BGP router identifier %s, local AS number %u vrf-id %d", | |
60466a63 | 7738 | inet_ntoa(bgp->router_id), bgp->as, |
a4d82a8a PZ |
7739 | bgp->vrf_id == VRF_UNKNOWN |
7740 | ? -1 | |
7741 | : (int)bgp->vrf_id); | |
ea47320b DL |
7742 | vty_out(vty, "\n"); |
7743 | } | |
d62a17ae | 7744 | |
ea47320b | 7745 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 7746 | if (use_json) { |
ea47320b | 7747 | json_object_int_add( |
60466a63 | 7748 | json, "updateDelayLimit", |
ea47320b | 7749 | bgp->v_update_delay); |
d62a17ae | 7750 | |
ea47320b DL |
7751 | if (bgp->v_update_delay |
7752 | != bgp->v_establish_wait) | |
d62a17ae | 7753 | json_object_int_add( |
7754 | json, | |
ea47320b DL |
7755 | "updateDelayEstablishWait", |
7756 | bgp->v_establish_wait); | |
d62a17ae | 7757 | |
60466a63 | 7758 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
7759 | json_object_string_add( |
7760 | json, | |
7761 | "updateDelayFirstNeighbor", | |
7762 | bgp->update_delay_begin_time); | |
7763 | json_object_boolean_true_add( | |
7764 | json, | |
7765 | "updateDelayInProgress"); | |
7766 | } else { | |
7767 | if (bgp->update_delay_over) { | |
d62a17ae | 7768 | json_object_string_add( |
7769 | json, | |
7770 | "updateDelayFirstNeighbor", | |
7771 | bgp->update_delay_begin_time); | |
ea47320b | 7772 | json_object_string_add( |
d62a17ae | 7773 | json, |
ea47320b DL |
7774 | "updateDelayBestpathResumed", |
7775 | bgp->update_delay_end_time); | |
7776 | json_object_string_add( | |
d62a17ae | 7777 | json, |
ea47320b DL |
7778 | "updateDelayZebraUpdateResume", |
7779 | bgp->update_delay_zebra_resume_time); | |
7780 | json_object_string_add( | |
7781 | json, | |
7782 | "updateDelayPeerUpdateResume", | |
7783 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 7784 | } |
ea47320b DL |
7785 | } |
7786 | } else { | |
7787 | vty_out(vty, | |
7788 | "Read-only mode update-delay limit: %d seconds\n", | |
7789 | bgp->v_update_delay); | |
7790 | if (bgp->v_update_delay | |
7791 | != bgp->v_establish_wait) | |
d62a17ae | 7792 | vty_out(vty, |
ea47320b DL |
7793 | " Establish wait: %d seconds\n", |
7794 | bgp->v_establish_wait); | |
d62a17ae | 7795 | |
60466a63 | 7796 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
7797 | vty_out(vty, |
7798 | " First neighbor established: %s\n", | |
7799 | bgp->update_delay_begin_time); | |
7800 | vty_out(vty, | |
7801 | " Delay in progress\n"); | |
7802 | } else { | |
7803 | if (bgp->update_delay_over) { | |
d62a17ae | 7804 | vty_out(vty, |
7805 | " First neighbor established: %s\n", | |
7806 | bgp->update_delay_begin_time); | |
7807 | vty_out(vty, | |
ea47320b DL |
7808 | " Best-paths resumed: %s\n", |
7809 | bgp->update_delay_end_time); | |
7810 | vty_out(vty, | |
7811 | " zebra update resumed: %s\n", | |
7812 | bgp->update_delay_zebra_resume_time); | |
7813 | vty_out(vty, | |
7814 | " peers update resumed: %s\n", | |
7815 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 7816 | } |
7817 | } | |
7818 | } | |
ea47320b | 7819 | } |
d62a17ae | 7820 | |
ea47320b DL |
7821 | if (use_json) { |
7822 | if (bgp_maxmed_onstartup_configured(bgp) | |
7823 | && bgp->maxmed_active) | |
7824 | json_object_boolean_true_add( | |
60466a63 | 7825 | json, "maxMedOnStartup"); |
ea47320b DL |
7826 | if (bgp->v_maxmed_admin) |
7827 | json_object_boolean_true_add( | |
60466a63 | 7828 | json, "maxMedAdministrative"); |
d62a17ae | 7829 | |
ea47320b DL |
7830 | json_object_int_add( |
7831 | json, "tableVersion", | |
60466a63 | 7832 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 7833 | |
60466a63 QY |
7834 | ents = bgp_table_count(bgp->rib[afi][safi]); |
7835 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
7836 | json_object_int_add( |
7837 | json, "ribMemory", | |
7838 | ents * sizeof(struct bgp_node)); | |
d62a17ae | 7839 | |
ea47320b | 7840 | ents = listcount(bgp->peer); |
60466a63 QY |
7841 | json_object_int_add(json, "peerCount", ents); |
7842 | json_object_int_add(json, "peerMemory", | |
7843 | ents * sizeof(struct peer)); | |
d62a17ae | 7844 | |
ea47320b DL |
7845 | if ((ents = listcount(bgp->group))) { |
7846 | json_object_int_add( | |
60466a63 | 7847 | json, "peerGroupCount", ents); |
ea47320b DL |
7848 | json_object_int_add( |
7849 | json, "peerGroupMemory", | |
996c9314 LB |
7850 | ents * sizeof(struct |
7851 | peer_group)); | |
ea47320b | 7852 | } |
d62a17ae | 7853 | |
ea47320b DL |
7854 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
7855 | BGP_CONFIG_DAMPENING)) | |
7856 | json_object_boolean_true_add( | |
60466a63 | 7857 | json, "dampeningEnabled"); |
ea47320b DL |
7858 | } else { |
7859 | if (bgp_maxmed_onstartup_configured(bgp) | |
7860 | && bgp->maxmed_active) | |
d62a17ae | 7861 | vty_out(vty, |
ea47320b DL |
7862 | "Max-med on-startup active\n"); |
7863 | if (bgp->v_maxmed_admin) | |
d62a17ae | 7864 | vty_out(vty, |
ea47320b | 7865 | "Max-med administrative active\n"); |
d62a17ae | 7866 | |
60466a63 QY |
7867 | vty_out(vty, "BGP table version %" PRIu64 "\n", |
7868 | bgp_table_version(bgp->rib[afi][safi])); | |
d62a17ae | 7869 | |
60466a63 | 7870 | ents = bgp_table_count(bgp->rib[afi][safi]); |
ea47320b DL |
7871 | vty_out(vty, |
7872 | "RIB entries %ld, using %s of memory\n", | |
7873 | ents, | |
996c9314 LB |
7874 | mtype_memstr(memstrbuf, |
7875 | sizeof(memstrbuf), | |
7876 | ents * sizeof(struct | |
7877 | bgp_node))); | |
ea47320b DL |
7878 | |
7879 | /* Peer related usage */ | |
7880 | ents = listcount(bgp->peer); | |
60466a63 | 7881 | vty_out(vty, "Peers %ld, using %s of memory\n", |
ea47320b DL |
7882 | ents, |
7883 | mtype_memstr( | |
60466a63 QY |
7884 | memstrbuf, sizeof(memstrbuf), |
7885 | ents * sizeof(struct peer))); | |
ea47320b DL |
7886 | |
7887 | if ((ents = listcount(bgp->group))) | |
d62a17ae | 7888 | vty_out(vty, |
ea47320b | 7889 | "Peer groups %ld, using %s of memory\n", |
d62a17ae | 7890 | ents, |
7891 | mtype_memstr( | |
7892 | memstrbuf, | |
7893 | sizeof(memstrbuf), | |
996c9314 LB |
7894 | ents * sizeof(struct |
7895 | peer_group))); | |
d62a17ae | 7896 | |
ea47320b DL |
7897 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
7898 | BGP_CONFIG_DAMPENING)) | |
60466a63 | 7899 | vty_out(vty, "Dampening enabled.\n"); |
ea47320b | 7900 | vty_out(vty, "\n"); |
d62a17ae | 7901 | |
ea47320b DL |
7902 | /* Subtract 8 here because 'Neighbor' is |
7903 | * 8 characters */ | |
7904 | vty_out(vty, "Neighbor"); | |
60466a63 QY |
7905 | vty_out(vty, "%*s", max_neighbor_width - 8, |
7906 | " "); | |
ea47320b DL |
7907 | vty_out(vty, |
7908 | "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n"); | |
d62a17ae | 7909 | } |
ea47320b | 7910 | } |
d62a17ae | 7911 | |
ea47320b | 7912 | count++; |
d62a17ae | 7913 | |
ea47320b DL |
7914 | if (use_json) { |
7915 | json_peer = json_object_new_object(); | |
d62a17ae | 7916 | |
b4e9dcba DD |
7917 | if (peer_dynamic_neighbor(peer)) { |
7918 | dn_count++; | |
60466a63 QY |
7919 | json_object_boolean_true_add(json_peer, |
7920 | "dynamicPeer"); | |
b4e9dcba | 7921 | } |
d62a17ae | 7922 | |
ea47320b | 7923 | if (peer->hostname) |
60466a63 | 7924 | json_object_string_add(json_peer, "hostname", |
ea47320b | 7925 | peer->hostname); |
d62a17ae | 7926 | |
ea47320b | 7927 | if (peer->domainname) |
60466a63 QY |
7928 | json_object_string_add(json_peer, "domainname", |
7929 | peer->domainname); | |
d62a17ae | 7930 | |
60466a63 | 7931 | json_object_int_add(json_peer, "remoteAs", peer->as); |
ea47320b | 7932 | json_object_int_add(json_peer, "version", 4); |
60466a63 | 7933 | json_object_int_add(json_peer, "msgRcvd", |
0112e9e0 | 7934 | PEER_TOTAL_RX(peer)); |
60466a63 | 7935 | json_object_int_add(json_peer, "msgSent", |
0112e9e0 | 7936 | PEER_TOTAL_TX(peer)); |
ea47320b DL |
7937 | |
7938 | json_object_int_add(json_peer, "tableVersion", | |
7939 | peer->version[afi][safi]); | |
7940 | json_object_int_add(json_peer, "outq", | |
7941 | peer->obuf->count); | |
7942 | json_object_int_add(json_peer, "inq", 0); | |
60466a63 QY |
7943 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, |
7944 | use_json, json_peer); | |
7945 | json_object_int_add(json_peer, "prefixReceivedCount", | |
7946 | peer->pcount[afi][pfx_rcd_safi]); | |
d62a17ae | 7947 | |
ea47320b | 7948 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) |
60466a63 | 7949 | json_object_string_add(json_peer, "state", |
ea47320b | 7950 | "Idle (Admin)"); |
9199a725 TM |
7951 | else if (peer->afc_recv[afi][safi]) |
7952 | json_object_string_add( | |
7953 | json_peer, "state", | |
7954 | lookup_msg(bgp_status_msg, peer->status, | |
7955 | NULL)); | |
60466a63 QY |
7956 | else if (CHECK_FLAG(peer->sflags, |
7957 | PEER_STATUS_PREFIX_OVERFLOW)) | |
7958 | json_object_string_add(json_peer, "state", | |
ea47320b DL |
7959 | "Idle (PfxCt)"); |
7960 | else | |
7961 | json_object_string_add( | |
7962 | json_peer, "state", | |
60466a63 QY |
7963 | lookup_msg(bgp_status_msg, peer->status, |
7964 | NULL)); | |
ea47320b DL |
7965 | |
7966 | if (peer->conf_if) | |
60466a63 | 7967 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
7968 | "interface"); |
7969 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
7970 | json_object_string_add(json_peer, "idType", |
7971 | "ipv4"); | |
ea47320b | 7972 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
7973 | json_object_string_add(json_peer, "idType", |
7974 | "ipv6"); | |
d62a17ae | 7975 | |
ea47320b DL |
7976 | json_object_object_add(json_peers, peer->host, |
7977 | json_peer); | |
7978 | } else { | |
7979 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
7980 | if (peer_dynamic_neighbor(peer)) { | |
7981 | dn_count++; | |
7982 | dn_flag[0] = '*'; | |
7983 | } | |
d62a17ae | 7984 | |
ea47320b | 7985 | if (peer->hostname |
60466a63 | 7986 | && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) |
ea47320b | 7987 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
60466a63 | 7988 | peer->hostname, peer->host); |
ea47320b | 7989 | else |
60466a63 | 7990 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
ea47320b DL |
7991 | |
7992 | /* pad the neighbor column with spaces */ | |
7993 | if (len < max_neighbor_width) | |
60466a63 QY |
7994 | vty_out(vty, "%*s", max_neighbor_width - len, |
7995 | " "); | |
ea47320b | 7996 | |
86a55b99 | 7997 | vty_out(vty, "4 %10u %7u %7u %8" PRIu64 " %4d %4zd %8s", |
0112e9e0 QY |
7998 | peer->as, PEER_TOTAL_RX(peer), |
7999 | PEER_TOTAL_TX(peer), peer->version[afi][safi], | |
8000 | 0, peer->obuf->count, | |
d62a17ae | 8001 | peer_uptime(peer->uptime, timebuf, |
ea47320b | 8002 | BGP_UPTIME_LEN, 0, NULL)); |
d62a17ae | 8003 | |
ea47320b | 8004 | if (peer->status == Established) |
2f8f4f10 | 8005 | if (peer->afc_recv[afi][safi]) |
95077abf | 8006 | vty_out(vty, " %12ld", |
a4d82a8a PZ |
8007 | peer->pcount[afi] |
8008 | [pfx_rcd_safi]); | |
95077abf DW |
8009 | else |
8010 | vty_out(vty, " NoNeg"); | |
ea47320b | 8011 | else { |
60466a63 | 8012 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) |
ea47320b | 8013 | vty_out(vty, " Idle (Admin)"); |
60466a63 QY |
8014 | else if (CHECK_FLAG( |
8015 | peer->sflags, | |
8016 | PEER_STATUS_PREFIX_OVERFLOW)) | |
ea47320b | 8017 | vty_out(vty, " Idle (PfxCt)"); |
d62a17ae | 8018 | else |
ea47320b | 8019 | vty_out(vty, " %12s", |
60466a63 QY |
8020 | lookup_msg(bgp_status_msg, |
8021 | peer->status, NULL)); | |
d62a17ae | 8022 | } |
ea47320b | 8023 | vty_out(vty, "\n"); |
d62a17ae | 8024 | } |
8025 | } | |
f933309e | 8026 | |
d62a17ae | 8027 | if (use_json) { |
8028 | json_object_object_add(json, "peers", json_peers); | |
8029 | ||
8030 | json_object_int_add(json, "totalPeers", count); | |
8031 | json_object_int_add(json, "dynamicPeers", dn_count); | |
8032 | ||
57a9c8a8 DS |
8033 | bgp_show_bestpath_json(bgp, json); |
8034 | ||
996c9314 LB |
8035 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
8036 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 8037 | json_object_free(json); |
8038 | } else { | |
8039 | if (count) | |
8040 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
8041 | else { | |
d6ceaca3 | 8042 | vty_out(vty, "No %s neighbor is configured\n", |
8043 | afi_safi_print(afi, safi)); | |
d62a17ae | 8044 | } |
b05a1c8b | 8045 | |
d6ceaca3 | 8046 | if (dn_count) { |
d62a17ae | 8047 | vty_out(vty, "* - dynamic neighbor\n"); |
8048 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
8049 | dn_count, bgp->dynamic_neighbors_limit); | |
8050 | } | |
8051 | } | |
1ff9a340 | 8052 | |
d62a17ae | 8053 | return CMD_SUCCESS; |
718e3744 | 8054 | } |
8055 | ||
d62a17ae | 8056 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
d7c0a89a | 8057 | int safi, uint8_t use_json, |
d62a17ae | 8058 | json_object *json) |
8059 | { | |
8060 | int is_first = 1; | |
8061 | int afi_wildcard = (afi == AFI_MAX); | |
8062 | int safi_wildcard = (safi == SAFI_MAX); | |
8063 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
8064 | bool json_output = false; | |
8065 | ||
8066 | if (use_json && is_wildcard) | |
8067 | vty_out(vty, "{\n"); | |
8068 | if (afi_wildcard) | |
8069 | afi = 1; /* AFI_IP */ | |
8070 | while (afi < AFI_MAX) { | |
8071 | if (safi_wildcard) | |
8072 | safi = 1; /* SAFI_UNICAST */ | |
8073 | while (safi < SAFI_MAX) { | |
318cac96 | 8074 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
d62a17ae | 8075 | json_output = true; |
8076 | if (is_wildcard) { | |
8077 | /* | |
8078 | * So limit output to those afi/safi | |
8079 | * pairs that | |
8080 | * actualy have something interesting in | |
8081 | * them | |
8082 | */ | |
8083 | if (use_json) { | |
8084 | json = json_object_new_object(); | |
8085 | ||
8086 | if (!is_first) | |
8087 | vty_out(vty, ",\n"); | |
8088 | else | |
8089 | is_first = 0; | |
8090 | ||
8091 | vty_out(vty, "\"%s\":", | |
8092 | afi_safi_json(afi, | |
8093 | safi)); | |
8094 | } else { | |
8095 | vty_out(vty, "\n%s Summary:\n", | |
8096 | afi_safi_print(afi, | |
8097 | safi)); | |
8098 | } | |
8099 | } | |
8100 | bgp_show_summary(vty, bgp, afi, safi, use_json, | |
8101 | json); | |
8102 | } | |
8103 | safi++; | |
d62a17ae | 8104 | if (!safi_wildcard) |
8105 | safi = SAFI_MAX; | |
8106 | } | |
8107 | afi++; | |
ee851c8c | 8108 | if (!afi_wildcard) |
d62a17ae | 8109 | afi = AFI_MAX; |
8110 | } | |
8111 | ||
8112 | if (use_json && is_wildcard) | |
8113 | vty_out(vty, "}\n"); | |
8114 | else if (use_json && !json_output) | |
8115 | vty_out(vty, "{}\n"); | |
8116 | } | |
8117 | ||
8118 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
d7c0a89a | 8119 | safi_t safi, uint8_t use_json) |
d62a17ae | 8120 | { |
8121 | struct listnode *node, *nnode; | |
8122 | struct bgp *bgp; | |
8123 | json_object *json = NULL; | |
8124 | int is_first = 1; | |
8125 | ||
8126 | if (use_json) | |
8127 | vty_out(vty, "{\n"); | |
8128 | ||
8129 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
8130 | if (use_json) { | |
8131 | json = json_object_new_object(); | |
8132 | ||
8133 | if (!is_first) | |
8134 | vty_out(vty, ",\n"); | |
8135 | else | |
8136 | is_first = 0; | |
8137 | ||
8138 | vty_out(vty, "\"%s\":", | |
8139 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
8140 | ? "Default" | |
8141 | : bgp->name); | |
8142 | } else { | |
8143 | vty_out(vty, "\nInstance %s:\n", | |
8144 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
8145 | ? "Default" | |
8146 | : bgp->name); | |
8147 | } | |
8148 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, json); | |
8149 | } | |
8150 | ||
8151 | if (use_json) | |
8152 | vty_out(vty, "}\n"); | |
8153 | } | |
8154 | ||
8155 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
d7c0a89a | 8156 | safi_t safi, uint8_t use_json) |
d62a17ae | 8157 | { |
8158 | struct bgp *bgp; | |
8159 | ||
8160 | if (name) { | |
8161 | if (strmatch(name, "all")) { | |
8162 | bgp_show_all_instances_summary_vty(vty, afi, safi, | |
8163 | use_json); | |
8164 | return CMD_SUCCESS; | |
8165 | } else { | |
8166 | bgp = bgp_lookup_by_name(name); | |
8167 | ||
8168 | if (!bgp) { | |
8169 | if (use_json) | |
8170 | vty_out(vty, "{}\n"); | |
8171 | else | |
8172 | vty_out(vty, | |
8173 | "%% No such BGP instance exist\n"); | |
8174 | return CMD_WARNING; | |
8175 | } | |
8176 | ||
8177 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, | |
8178 | NULL); | |
8179 | return CMD_SUCCESS; | |
8180 | } | |
8181 | } | |
8182 | ||
8183 | bgp = bgp_get_default(); | |
8184 | ||
8185 | if (bgp) | |
8186 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, NULL); | |
8187 | ||
8188 | return CMD_SUCCESS; | |
4fb25c53 DW |
8189 | } |
8190 | ||
716b2d8a | 8191 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 8192 | DEFUN (show_ip_bgp_summary, |
718e3744 | 8193 | show_ip_bgp_summary_cmd, |
dd6bd0f1 | 8194 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] summary [json]", |
718e3744 | 8195 | SHOW_STR |
8196 | IP_STR | |
8197 | BGP_STR | |
8386ac43 | 8198 | BGP_INSTANCE_HELP_STR |
46f296b4 | 8199 | BGP_AFI_HELP_STR |
dd6bd0f1 | 8200 | BGP_SAFI_WITH_LABEL_HELP_STR |
b05a1c8b | 8201 | "Summary of BGP neighbor status\n" |
9973d184 | 8202 | JSON_STR) |
718e3744 | 8203 | { |
d62a17ae | 8204 | char *vrf = NULL; |
8205 | afi_t afi = AFI_MAX; | |
8206 | safi_t safi = SAFI_MAX; | |
8207 | ||
8208 | int idx = 0; | |
8209 | ||
8210 | /* show [ip] bgp */ | |
8211 | if (argv_find(argv, argc, "ip", &idx)) | |
8212 | afi = AFI_IP; | |
8213 | /* [<view|vrf> VIEWVRFNAME] */ | |
8214 | if (argv_find(argv, argc, "view", &idx) | |
8215 | || argv_find(argv, argc, "vrf", &idx)) | |
8216 | vrf = argv[++idx]->arg; | |
8217 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
8218 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
8219 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
8220 | } | |
8221 | ||
8222 | int uj = use_json(argc, argv); | |
8223 | ||
8224 | return bgp_show_summary_vty(vty, vrf, afi, safi, uj); | |
8225 | } | |
8226 | ||
8227 | const char *afi_safi_print(afi_t afi, safi_t safi) | |
8228 | { | |
8229 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
8230 | return "IPv4 Unicast"; | |
8231 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
8232 | return "IPv4 Multicast"; | |
8233 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
8234 | return "IPv4 Labeled Unicast"; | |
8235 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
8236 | return "IPv4 VPN"; | |
8237 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
8238 | return "IPv4 Encap"; | |
7c40bf39 | 8239 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) |
8240 | return "IPv4 Flowspec"; | |
d62a17ae | 8241 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
8242 | return "IPv6 Unicast"; | |
8243 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
8244 | return "IPv6 Multicast"; | |
8245 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
8246 | return "IPv6 Labeled Unicast"; | |
8247 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
8248 | return "IPv6 VPN"; | |
8249 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
8250 | return "IPv6 Encap"; | |
7c40bf39 | 8251 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) |
8252 | return "IPv6 Flowspec"; | |
d62a17ae | 8253 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) |
8254 | return "L2VPN EVPN"; | |
8255 | else | |
8256 | return "Unknown"; | |
538621f2 | 8257 | } |
8258 | ||
b9f77ec8 DS |
8259 | /* |
8260 | * Please note that we have intentionally camelCased | |
8261 | * the return strings here. So if you want | |
8262 | * to use this function, please ensure you | |
8263 | * are doing this within json output | |
8264 | */ | |
d62a17ae | 8265 | const char *afi_safi_json(afi_t afi, safi_t safi) |
8266 | { | |
8267 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
8268 | return "ipv4Unicast"; | |
8269 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
8270 | return "ipv4Multicast"; | |
8271 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
8272 | return "ipv4LabeledUnicast"; | |
8273 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
8274 | return "ipv4Vpn"; | |
8275 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
8276 | return "ipv4Encap"; | |
7c40bf39 | 8277 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) |
8278 | return "ipv4Flowspec"; | |
d62a17ae | 8279 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
8280 | return "ipv6Unicast"; | |
8281 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
8282 | return "ipv6Multicast"; | |
8283 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
8284 | return "ipv6LabeledUnicast"; | |
8285 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
8286 | return "ipv6Vpn"; | |
8287 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
8288 | return "ipv6Encap"; | |
7c40bf39 | 8289 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) |
8290 | return "ipv6Flowspec"; | |
d62a17ae | 8291 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) |
8292 | return "l2VpnEvpn"; | |
8293 | else | |
8294 | return "Unknown"; | |
27162734 LB |
8295 | } |
8296 | ||
718e3744 | 8297 | /* Show BGP peer's information. */ |
d62a17ae | 8298 | enum show_type { show_all, show_peer }; |
8299 | ||
8300 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
8301 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
8302 | uint16_t adv_smcap, uint16_t adv_rmcap, |
8303 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
8304 | uint8_t use_json, json_object *json_pref) | |
d62a17ae | 8305 | { |
8306 | /* Send-Mode */ | |
8307 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
8308 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
8309 | if (use_json) { | |
8310 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
8311 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8312 | json_object_string_add(json_pref, "sendMode", | |
8313 | "advertisedAndReceived"); | |
8314 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
8315 | json_object_string_add(json_pref, "sendMode", | |
8316 | "advertised"); | |
8317 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8318 | json_object_string_add(json_pref, "sendMode", | |
8319 | "received"); | |
8320 | } else { | |
8321 | vty_out(vty, " Send-mode: "); | |
8322 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
8323 | vty_out(vty, "advertised"); | |
8324 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8325 | vty_out(vty, "%sreceived", | |
8326 | CHECK_FLAG(p->af_cap[afi][safi], | |
8327 | adv_smcap) | |
8328 | ? ", " | |
8329 | : ""); | |
8330 | vty_out(vty, "\n"); | |
8331 | } | |
8332 | } | |
8333 | ||
8334 | /* Receive-Mode */ | |
8335 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
8336 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
8337 | if (use_json) { | |
8338 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
8339 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8340 | json_object_string_add(json_pref, "recvMode", | |
8341 | "advertisedAndReceived"); | |
8342 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
8343 | json_object_string_add(json_pref, "recvMode", | |
8344 | "advertised"); | |
8345 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8346 | json_object_string_add(json_pref, "recvMode", | |
8347 | "received"); | |
8348 | } else { | |
8349 | vty_out(vty, " Receive-mode: "); | |
8350 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
8351 | vty_out(vty, "advertised"); | |
8352 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8353 | vty_out(vty, "%sreceived", | |
8354 | CHECK_FLAG(p->af_cap[afi][safi], | |
8355 | adv_rmcap) | |
8356 | ? ", " | |
8357 | : ""); | |
8358 | vty_out(vty, "\n"); | |
8359 | } | |
8360 | } | |
8361 | } | |
8362 | ||
8363 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, | |
d7c0a89a | 8364 | safi_t safi, uint8_t use_json, |
d62a17ae | 8365 | json_object *json_neigh) |
8366 | { | |
0291c246 MK |
8367 | struct bgp_filter *filter; |
8368 | struct peer_af *paf; | |
8369 | char orf_pfx_name[BUFSIZ]; | |
8370 | int orf_pfx_count; | |
8371 | json_object *json_af = NULL; | |
8372 | json_object *json_prefA = NULL; | |
8373 | json_object *json_prefB = NULL; | |
8374 | json_object *json_addr = NULL; | |
d62a17ae | 8375 | |
8376 | if (use_json) { | |
8377 | json_addr = json_object_new_object(); | |
8378 | json_af = json_object_new_object(); | |
8379 | filter = &p->filter[afi][safi]; | |
8380 | ||
8381 | if (peer_group_active(p)) | |
8382 | json_object_string_add(json_addr, "peerGroupMember", | |
8383 | p->group->name); | |
8384 | ||
8385 | paf = peer_af_find(p, afi, safi); | |
8386 | if (paf && PAF_SUBGRP(paf)) { | |
8387 | json_object_int_add(json_addr, "updateGroupId", | |
8388 | PAF_UPDGRP(paf)->id); | |
8389 | json_object_int_add(json_addr, "subGroupId", | |
8390 | PAF_SUBGRP(paf)->id); | |
8391 | json_object_int_add(json_addr, "packetQueueLength", | |
8392 | bpacket_queue_virtual_length(paf)); | |
8393 | } | |
8394 | ||
8395 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8396 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8397 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8398 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8399 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8400 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8401 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
8402 | json_object_int_add(json_af, "orfType", | |
8403 | ORF_TYPE_PREFIX); | |
8404 | json_prefA = json_object_new_object(); | |
8405 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
8406 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
8407 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8408 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
8409 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
8410 | use_json, json_prefA); | |
8411 | json_object_object_add(json_af, "orfPrefixList", | |
8412 | json_prefA); | |
8413 | } | |
8414 | ||
8415 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8416 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8417 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8418 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8419 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8420 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8421 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
8422 | json_object_int_add(json_af, "orfOldType", | |
8423 | ORF_TYPE_PREFIX_OLD); | |
8424 | json_prefB = json_object_new_object(); | |
8425 | bgp_show_peer_afi_orf_cap( | |
8426 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
8427 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8428 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
8429 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
8430 | json_prefB); | |
8431 | json_object_object_add(json_af, "orfOldPrefixList", | |
8432 | json_prefB); | |
8433 | } | |
8434 | ||
8435 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8436 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8437 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8438 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8439 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8440 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8441 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8442 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8443 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
8444 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8445 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
8446 | json_object_object_add(json_addr, "afDependentCap", | |
8447 | json_af); | |
8448 | else | |
8449 | json_object_free(json_af); | |
8450 | ||
8451 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
8452 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
8453 | NULL, afi, orf_pfx_name, use_json); | |
8454 | ||
8455 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8456 | PEER_STATUS_ORF_PREFIX_SEND) | |
8457 | || orf_pfx_count) { | |
8458 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8459 | PEER_STATUS_ORF_PREFIX_SEND)) | |
8460 | json_object_boolean_true_add(json_neigh, | |
8461 | "orfSent"); | |
8462 | if (orf_pfx_count) | |
8463 | json_object_int_add(json_addr, "orfRecvCounter", | |
8464 | orf_pfx_count); | |
8465 | } | |
8466 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8467 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
8468 | json_object_string_add( | |
8469 | json_addr, "orfFirstUpdate", | |
8470 | "deferredUntilORFOrRouteRefreshRecvd"); | |
8471 | ||
8472 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8473 | PEER_FLAG_REFLECTOR_CLIENT)) | |
8474 | json_object_boolean_true_add(json_addr, | |
8475 | "routeReflectorClient"); | |
8476 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8477 | PEER_FLAG_RSERVER_CLIENT)) | |
8478 | json_object_boolean_true_add(json_addr, | |
8479 | "routeServerClient"); | |
8480 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
8481 | json_object_boolean_true_add(json_addr, | |
8482 | "inboundSoftConfigPermit"); | |
8483 | ||
8484 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8485 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
8486 | json_object_boolean_true_add( | |
8487 | json_addr, | |
8488 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
8489 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8490 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
8491 | json_object_boolean_true_add( | |
8492 | json_addr, | |
8493 | "privateAsNumsReplacedInUpdatesToNbr"); | |
8494 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8495 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
8496 | json_object_boolean_true_add( | |
8497 | json_addr, | |
8498 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
8499 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8500 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
8501 | json_object_boolean_true_add( | |
8502 | json_addr, | |
8503 | "privateAsNumsRemovedInUpdatesToNbr"); | |
8504 | ||
8505 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8506 | PEER_FLAG_ADDPATH_TX_ALL_PATHS)) | |
8507 | json_object_boolean_true_add(json_addr, | |
8508 | "addpathTxAllPaths"); | |
8509 | ||
8510 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8511 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) | |
8512 | json_object_boolean_true_add(json_addr, | |
8513 | "addpathTxBestpathPerAS"); | |
8514 | ||
8515 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
8516 | json_object_string_add(json_addr, | |
8517 | "overrideASNsInOutboundUpdates", | |
8518 | "ifAspathEqualRemoteAs"); | |
8519 | ||
8520 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
8521 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8522 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
8523 | json_object_boolean_true_add(json_addr, | |
8524 | "routerAlwaysNextHop"); | |
8525 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8526 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
8527 | json_object_boolean_true_add( | |
8528 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
8529 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8530 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
8531 | json_object_boolean_true_add( | |
8532 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
8533 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
8534 | json_object_boolean_true_add( | |
8535 | json_addr, "unchangedMedPropogatedToNbr"); | |
8536 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
8537 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8538 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
8539 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8540 | PEER_FLAG_SEND_COMMUNITY) | |
8541 | && CHECK_FLAG(p->af_flags[afi][safi], | |
8542 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
8543 | json_object_string_add(json_addr, | |
8544 | "commAttriSentToNbr", | |
8545 | "extendedAndStandard"); | |
8546 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8547 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
8548 | json_object_string_add(json_addr, | |
8549 | "commAttriSentToNbr", | |
8550 | "extended"); | |
8551 | else | |
8552 | json_object_string_add(json_addr, | |
8553 | "commAttriSentToNbr", | |
8554 | "standard"); | |
8555 | } | |
8556 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8557 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
8558 | if (p->default_rmap[afi][safi].name) | |
8559 | json_object_string_add( | |
8560 | json_addr, "defaultRouteMap", | |
8561 | p->default_rmap[afi][safi].name); | |
8562 | ||
8563 | if (paf && PAF_SUBGRP(paf) | |
8564 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
8565 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
8566 | json_object_boolean_true_add(json_addr, | |
8567 | "defaultSent"); | |
8568 | else | |
8569 | json_object_boolean_true_add(json_addr, | |
8570 | "defaultNotSent"); | |
8571 | } | |
8572 | ||
dff8f48d | 8573 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 8574 | if (is_evpn_enabled()) |
60466a63 QY |
8575 | json_object_boolean_true_add( |
8576 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
8577 | } |
8578 | ||
d62a17ae | 8579 | if (filter->plist[FILTER_IN].name |
8580 | || filter->dlist[FILTER_IN].name | |
8581 | || filter->aslist[FILTER_IN].name | |
8582 | || filter->map[RMAP_IN].name) | |
8583 | json_object_boolean_true_add(json_addr, | |
8584 | "inboundPathPolicyConfig"); | |
8585 | if (filter->plist[FILTER_OUT].name | |
8586 | || filter->dlist[FILTER_OUT].name | |
8587 | || filter->aslist[FILTER_OUT].name | |
8588 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
8589 | json_object_boolean_true_add( | |
8590 | json_addr, "outboundPathPolicyConfig"); | |
8591 | ||
8592 | /* prefix-list */ | |
8593 | if (filter->plist[FILTER_IN].name) | |
8594 | json_object_string_add(json_addr, | |
8595 | "incomingUpdatePrefixFilterList", | |
8596 | filter->plist[FILTER_IN].name); | |
8597 | if (filter->plist[FILTER_OUT].name) | |
8598 | json_object_string_add(json_addr, | |
8599 | "outgoingUpdatePrefixFilterList", | |
8600 | filter->plist[FILTER_OUT].name); | |
8601 | ||
8602 | /* distribute-list */ | |
8603 | if (filter->dlist[FILTER_IN].name) | |
8604 | json_object_string_add( | |
8605 | json_addr, "incomingUpdateNetworkFilterList", | |
8606 | filter->dlist[FILTER_IN].name); | |
8607 | if (filter->dlist[FILTER_OUT].name) | |
8608 | json_object_string_add( | |
8609 | json_addr, "outgoingUpdateNetworkFilterList", | |
8610 | filter->dlist[FILTER_OUT].name); | |
8611 | ||
8612 | /* filter-list. */ | |
8613 | if (filter->aslist[FILTER_IN].name) | |
8614 | json_object_string_add(json_addr, | |
8615 | "incomingUpdateAsPathFilterList", | |
8616 | filter->aslist[FILTER_IN].name); | |
8617 | if (filter->aslist[FILTER_OUT].name) | |
8618 | json_object_string_add(json_addr, | |
8619 | "outgoingUpdateAsPathFilterList", | |
8620 | filter->aslist[FILTER_OUT].name); | |
8621 | ||
8622 | /* route-map. */ | |
8623 | if (filter->map[RMAP_IN].name) | |
8624 | json_object_string_add( | |
8625 | json_addr, "routeMapForIncomingAdvertisements", | |
8626 | filter->map[RMAP_IN].name); | |
8627 | if (filter->map[RMAP_OUT].name) | |
8628 | json_object_string_add( | |
8629 | json_addr, "routeMapForOutgoingAdvertisements", | |
8630 | filter->map[RMAP_OUT].name); | |
8631 | ||
8632 | /* unsuppress-map */ | |
8633 | if (filter->usmap.name) | |
8634 | json_object_string_add(json_addr, | |
8635 | "selectiveUnsuppressRouteMap", | |
8636 | filter->usmap.name); | |
8637 | ||
8638 | /* Receive prefix count */ | |
8639 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
8640 | p->pcount[afi][safi]); | |
8641 | ||
8642 | /* Maximum prefix */ | |
8643 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
8644 | json_object_int_add(json_addr, "prefixAllowedMax", | |
8645 | p->pmax[afi][safi]); | |
8646 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8647 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
8648 | json_object_boolean_true_add( | |
8649 | json_addr, "prefixAllowedMaxWarning"); | |
8650 | json_object_int_add(json_addr, | |
8651 | "prefixAllowedWarningThresh", | |
8652 | p->pmax_threshold[afi][safi]); | |
8653 | if (p->pmax_restart[afi][safi]) | |
8654 | json_object_int_add( | |
8655 | json_addr, | |
8656 | "prefixAllowedRestartIntervalMsecs", | |
8657 | p->pmax_restart[afi][safi] * 60000); | |
8658 | } | |
8659 | json_object_object_add(json_neigh, afi_safi_print(afi, safi), | |
8660 | json_addr); | |
8661 | ||
8662 | } else { | |
8663 | filter = &p->filter[afi][safi]; | |
8664 | ||
8665 | vty_out(vty, " For address family: %s\n", | |
8666 | afi_safi_print(afi, safi)); | |
8667 | ||
8668 | if (peer_group_active(p)) | |
8669 | vty_out(vty, " %s peer-group member\n", | |
8670 | p->group->name); | |
8671 | ||
8672 | paf = peer_af_find(p, afi, safi); | |
8673 | if (paf && PAF_SUBGRP(paf)) { | |
996c9314 LB |
8674 | vty_out(vty, " Update group %" PRIu64 |
8675 | ", subgroup %" PRIu64 "\n", | |
d62a17ae | 8676 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
8677 | vty_out(vty, " Packet Queue length %d\n", | |
8678 | bpacket_queue_virtual_length(paf)); | |
8679 | } else { | |
8680 | vty_out(vty, " Not part of any update group\n"); | |
8681 | } | |
8682 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8683 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8684 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8685 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8686 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8687 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8688 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8689 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8690 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
8691 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8692 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
8693 | vty_out(vty, " AF-dependant capabilities:\n"); | |
8694 | ||
8695 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8696 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8697 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8698 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8699 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8700 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8701 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
8702 | vty_out(vty, | |
8703 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
8704 | ORF_TYPE_PREFIX); | |
8705 | bgp_show_peer_afi_orf_cap( | |
8706 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
8707 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8708 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
8709 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
8710 | } | |
8711 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8712 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8713 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8714 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8715 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8716 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8717 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
8718 | vty_out(vty, | |
8719 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
8720 | ORF_TYPE_PREFIX_OLD); | |
8721 | bgp_show_peer_afi_orf_cap( | |
8722 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
8723 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8724 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
8725 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
8726 | } | |
8727 | ||
8728 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
8729 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
8730 | NULL, afi, orf_pfx_name, use_json); | |
8731 | ||
8732 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8733 | PEER_STATUS_ORF_PREFIX_SEND) | |
8734 | || orf_pfx_count) { | |
8735 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
8736 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8737 | PEER_STATUS_ORF_PREFIX_SEND)) | |
8738 | vty_out(vty, " sent;"); | |
8739 | if (orf_pfx_count) | |
8740 | vty_out(vty, " received (%d entries)", | |
8741 | orf_pfx_count); | |
8742 | vty_out(vty, "\n"); | |
8743 | } | |
8744 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8745 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
8746 | vty_out(vty, | |
8747 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
8748 | ||
8749 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8750 | PEER_FLAG_REFLECTOR_CLIENT)) | |
8751 | vty_out(vty, " Route-Reflector Client\n"); | |
8752 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8753 | PEER_FLAG_RSERVER_CLIENT)) | |
8754 | vty_out(vty, " Route-Server Client\n"); | |
8755 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
8756 | vty_out(vty, | |
8757 | " Inbound soft reconfiguration allowed\n"); | |
8758 | ||
8759 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8760 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
8761 | vty_out(vty, | |
8762 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
8763 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8764 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
8765 | vty_out(vty, | |
8766 | " Private AS numbers replaced in updates to this neighbor\n"); | |
8767 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8768 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
8769 | vty_out(vty, | |
8770 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
8771 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8772 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
8773 | vty_out(vty, | |
8774 | " Private AS numbers removed in updates to this neighbor\n"); | |
8775 | ||
8776 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8777 | PEER_FLAG_ADDPATH_TX_ALL_PATHS)) | |
8778 | vty_out(vty, " Advertise all paths via addpath\n"); | |
8779 | ||
8780 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8781 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) | |
8782 | vty_out(vty, | |
8783 | " Advertise bestpath per AS via addpath\n"); | |
8784 | ||
8785 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
8786 | vty_out(vty, | |
8787 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
8788 | ||
8789 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
8790 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8791 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
8792 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
8793 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8794 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
8795 | vty_out(vty, | |
8796 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
8797 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8798 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
8799 | vty_out(vty, | |
8800 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
8801 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
8802 | vty_out(vty, | |
8803 | " MED is propagated unchanged to this neighbor\n"); | |
8804 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
8805 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8806 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
8807 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8808 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
8809 | vty_out(vty, | |
8810 | " Community attribute sent to this neighbor"); | |
8811 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8812 | PEER_FLAG_SEND_COMMUNITY) | |
8813 | && CHECK_FLAG(p->af_flags[afi][safi], | |
8814 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
8815 | && CHECK_FLAG(p->af_flags[afi][safi], | |
8816 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
8817 | vty_out(vty, "(all)\n"); | |
8818 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8819 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
8820 | vty_out(vty, "(large)\n"); | |
8821 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8822 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
8823 | vty_out(vty, "(extended)\n"); | |
8824 | else | |
8825 | vty_out(vty, "(standard)\n"); | |
8826 | } | |
8827 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8828 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
8829 | vty_out(vty, " Default information originate,"); | |
8830 | ||
8831 | if (p->default_rmap[afi][safi].name) | |
8832 | vty_out(vty, " default route-map %s%s,", | |
8833 | p->default_rmap[afi][safi].map ? "*" | |
8834 | : "", | |
8835 | p->default_rmap[afi][safi].name); | |
8836 | if (paf && PAF_SUBGRP(paf) | |
8837 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
8838 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
8839 | vty_out(vty, " default sent\n"); | |
8840 | else | |
8841 | vty_out(vty, " default not sent\n"); | |
8842 | } | |
8843 | ||
dff8f48d MK |
8844 | /* advertise-vni-all */ |
8845 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 8846 | if (is_evpn_enabled()) |
dff8f48d MK |
8847 | vty_out(vty, " advertise-all-vni\n"); |
8848 | } | |
8849 | ||
d62a17ae | 8850 | if (filter->plist[FILTER_IN].name |
8851 | || filter->dlist[FILTER_IN].name | |
8852 | || filter->aslist[FILTER_IN].name | |
8853 | || filter->map[RMAP_IN].name) | |
8854 | vty_out(vty, " Inbound path policy configured\n"); | |
8855 | if (filter->plist[FILTER_OUT].name | |
8856 | || filter->dlist[FILTER_OUT].name | |
8857 | || filter->aslist[FILTER_OUT].name | |
8858 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
8859 | vty_out(vty, " Outbound path policy configured\n"); | |
8860 | ||
8861 | /* prefix-list */ | |
8862 | if (filter->plist[FILTER_IN].name) | |
8863 | vty_out(vty, | |
8864 | " Incoming update prefix filter list is %s%s\n", | |
8865 | filter->plist[FILTER_IN].plist ? "*" : "", | |
8866 | filter->plist[FILTER_IN].name); | |
8867 | if (filter->plist[FILTER_OUT].name) | |
8868 | vty_out(vty, | |
8869 | " Outgoing update prefix filter list is %s%s\n", | |
8870 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
8871 | filter->plist[FILTER_OUT].name); | |
8872 | ||
8873 | /* distribute-list */ | |
8874 | if (filter->dlist[FILTER_IN].name) | |
8875 | vty_out(vty, | |
8876 | " Incoming update network filter list is %s%s\n", | |
8877 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
8878 | filter->dlist[FILTER_IN].name); | |
8879 | if (filter->dlist[FILTER_OUT].name) | |
8880 | vty_out(vty, | |
8881 | " Outgoing update network filter list is %s%s\n", | |
8882 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
8883 | filter->dlist[FILTER_OUT].name); | |
8884 | ||
8885 | /* filter-list. */ | |
8886 | if (filter->aslist[FILTER_IN].name) | |
8887 | vty_out(vty, | |
8888 | " Incoming update AS path filter list is %s%s\n", | |
8889 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
8890 | filter->aslist[FILTER_IN].name); | |
8891 | if (filter->aslist[FILTER_OUT].name) | |
8892 | vty_out(vty, | |
8893 | " Outgoing update AS path filter list is %s%s\n", | |
8894 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
8895 | filter->aslist[FILTER_OUT].name); | |
8896 | ||
8897 | /* route-map. */ | |
8898 | if (filter->map[RMAP_IN].name) | |
8899 | vty_out(vty, | |
8900 | " Route map for incoming advertisements is %s%s\n", | |
8901 | filter->map[RMAP_IN].map ? "*" : "", | |
8902 | filter->map[RMAP_IN].name); | |
8903 | if (filter->map[RMAP_OUT].name) | |
8904 | vty_out(vty, | |
8905 | " Route map for outgoing advertisements is %s%s\n", | |
8906 | filter->map[RMAP_OUT].map ? "*" : "", | |
8907 | filter->map[RMAP_OUT].name); | |
8908 | ||
8909 | /* unsuppress-map */ | |
8910 | if (filter->usmap.name) | |
8911 | vty_out(vty, | |
8912 | " Route map for selective unsuppress is %s%s\n", | |
8913 | filter->usmap.map ? "*" : "", | |
8914 | filter->usmap.name); | |
8915 | ||
8916 | /* Receive prefix count */ | |
8917 | vty_out(vty, " %ld accepted prefixes\n", p->pcount[afi][safi]); | |
8918 | ||
8919 | /* Maximum prefix */ | |
8920 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
8921 | vty_out(vty, " Maximum prefixes allowed %ld%s\n", | |
8922 | p->pmax[afi][safi], | |
8923 | CHECK_FLAG(p->af_flags[afi][safi], | |
8924 | PEER_FLAG_MAX_PREFIX_WARNING) | |
8925 | ? " (warning-only)" | |
8926 | : ""); | |
8927 | vty_out(vty, " Threshold for warning message %d%%", | |
8928 | p->pmax_threshold[afi][safi]); | |
8929 | if (p->pmax_restart[afi][safi]) | |
8930 | vty_out(vty, ", restart interval %d min", | |
8931 | p->pmax_restart[afi][safi]); | |
8932 | vty_out(vty, "\n"); | |
8933 | } | |
8934 | ||
8935 | vty_out(vty, "\n"); | |
8936 | } | |
8937 | } | |
8938 | ||
d7c0a89a | 8939 | static void bgp_show_peer(struct vty *vty, struct peer *p, uint8_t use_json, |
d62a17ae | 8940 | json_object *json) |
718e3744 | 8941 | { |
d62a17ae | 8942 | struct bgp *bgp; |
8943 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
8944 | char timebuf[BGP_UPTIME_LEN]; | |
8945 | char dn_flag[2]; | |
8946 | const char *subcode_str; | |
8947 | const char *code_str; | |
8948 | afi_t afi; | |
8949 | safi_t safi; | |
d7c0a89a QY |
8950 | uint16_t i; |
8951 | uint8_t *msg; | |
d62a17ae | 8952 | json_object *json_neigh = NULL; |
8953 | time_t epoch_tbuf; | |
718e3744 | 8954 | |
d62a17ae | 8955 | bgp = p->bgp; |
8956 | ||
8957 | if (use_json) | |
8958 | json_neigh = json_object_new_object(); | |
8959 | ||
8960 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
8961 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
8962 | dn_flag[0] = '*'; | |
8963 | ||
8964 | if (!use_json) { | |
8965 | if (p->conf_if) /* Configured interface name. */ | |
8966 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
8967 | BGP_PEER_SU_UNSPEC(p) | |
8968 | ? "None" | |
8969 | : sockunion2str(&p->su, buf, | |
8970 | SU_ADDRSTRLEN)); | |
8971 | else /* Configured IP address. */ | |
8972 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
8973 | p->host); | |
8974 | } | |
8975 | ||
8976 | if (use_json) { | |
8977 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
8978 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
8979 | "none"); | |
8980 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
8981 | json_object_string_add( | |
8982 | json_neigh, "bgpNeighborAddr", | |
8983 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
8984 | ||
8985 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
8986 | ||
8987 | if (p->change_local_as) | |
8988 | json_object_int_add(json_neigh, "localAs", | |
8989 | p->change_local_as); | |
8990 | else | |
8991 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
8992 | ||
8993 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
8994 | json_object_boolean_true_add(json_neigh, | |
8995 | "localAsNoPrepend"); | |
8996 | ||
8997 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
8998 | json_object_boolean_true_add(json_neigh, | |
8999 | "localAsReplaceAs"); | |
9000 | } else { | |
9001 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
9002 | || (p->as_type == AS_INTERNAL)) | |
9003 | vty_out(vty, "remote AS %u, ", p->as); | |
9004 | else | |
9005 | vty_out(vty, "remote AS Unspecified, "); | |
9006 | vty_out(vty, "local AS %u%s%s, ", | |
9007 | p->change_local_as ? p->change_local_as : p->local_as, | |
9008 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
9009 | ? " no-prepend" | |
9010 | : "", | |
9011 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
9012 | ? " replace-as" | |
9013 | : ""); | |
9014 | } | |
9015 | /* peer type internal, external, confed-internal or confed-external */ | |
9016 | if (p->as == p->local_as) { | |
9017 | if (use_json) { | |
9018 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9019 | json_object_boolean_true_add( | |
9020 | json_neigh, "nbrConfedInternalLink"); | |
9021 | else | |
9022 | json_object_boolean_true_add(json_neigh, | |
9023 | "nbrInternalLink"); | |
9024 | } else { | |
9025 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9026 | vty_out(vty, "confed-internal link\n"); | |
9027 | else | |
9028 | vty_out(vty, "internal link\n"); | |
9029 | } | |
9030 | } else { | |
9031 | if (use_json) { | |
9032 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9033 | json_object_boolean_true_add( | |
9034 | json_neigh, "nbrConfedExternalLink"); | |
9035 | else | |
9036 | json_object_boolean_true_add(json_neigh, | |
9037 | "nbrExternalLink"); | |
9038 | } else { | |
9039 | if (bgp_confederation_peers_check(bgp, p->as)) | |
9040 | vty_out(vty, "confed-external link\n"); | |
9041 | else | |
9042 | vty_out(vty, "external link\n"); | |
9043 | } | |
9044 | } | |
9045 | ||
9046 | /* Description. */ | |
9047 | if (p->desc) { | |
9048 | if (use_json) | |
9049 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
9050 | else | |
9051 | vty_out(vty, " Description: %s\n", p->desc); | |
9052 | } | |
9053 | ||
9054 | if (p->hostname) { | |
9055 | if (use_json) { | |
9056 | if (p->hostname) | |
9057 | json_object_string_add(json_neigh, "hostname", | |
9058 | p->hostname); | |
9059 | ||
9060 | if (p->domainname) | |
9061 | json_object_string_add(json_neigh, "domainname", | |
9062 | p->domainname); | |
9063 | } else { | |
9064 | if (p->domainname && (p->domainname[0] != '\0')) | |
9065 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
9066 | p->domainname); | |
9067 | else | |
9068 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
9069 | } | |
9070 | } | |
9071 | ||
9072 | /* Peer-group */ | |
9073 | if (p->group) { | |
9074 | if (use_json) { | |
9075 | json_object_string_add(json_neigh, "peerGroup", | |
9076 | p->group->name); | |
9077 | ||
9078 | if (dn_flag[0]) { | |
9079 | struct prefix prefix, *range = NULL; | |
9080 | ||
9081 | sockunion2hostprefix(&(p->su), &prefix); | |
9082 | range = peer_group_lookup_dynamic_neighbor_range( | |
9083 | p->group, &prefix); | |
9084 | ||
9085 | if (range) { | |
9086 | prefix2str(range, buf1, sizeof(buf1)); | |
9087 | json_object_string_add( | |
9088 | json_neigh, | |
9089 | "peerSubnetRangeGroup", buf1); | |
9090 | } | |
9091 | } | |
9092 | } else { | |
9093 | vty_out(vty, | |
9094 | " Member of peer-group %s for session parameters\n", | |
9095 | p->group->name); | |
9096 | ||
9097 | if (dn_flag[0]) { | |
9098 | struct prefix prefix, *range = NULL; | |
9099 | ||
9100 | sockunion2hostprefix(&(p->su), &prefix); | |
9101 | range = peer_group_lookup_dynamic_neighbor_range( | |
9102 | p->group, &prefix); | |
9103 | ||
9104 | if (range) { | |
9105 | prefix2str(range, buf1, sizeof(buf1)); | |
9106 | vty_out(vty, | |
9107 | " Belongs to the subnet range group: %s\n", | |
9108 | buf1); | |
9109 | } | |
9110 | } | |
9111 | } | |
9112 | } | |
9113 | ||
9114 | if (use_json) { | |
9115 | /* Administrative shutdown. */ | |
9116 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
9117 | json_object_boolean_true_add(json_neigh, | |
9118 | "adminShutDown"); | |
9119 | ||
9120 | /* BGP Version. */ | |
9121 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
9122 | json_object_string_add( | |
9123 | json_neigh, "remoteRouterId", | |
9124 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
d0086e8e AD |
9125 | json_object_string_add( |
9126 | json_neigh, "localRouterId", | |
9127 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
9128 | sizeof(buf1))); | |
d62a17ae | 9129 | |
9130 | /* Confederation */ | |
9131 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
9132 | && bgp_confederation_peers_check(bgp, p->as)) | |
9133 | json_object_boolean_true_add(json_neigh, | |
9134 | "nbrCommonAdmin"); | |
9135 | ||
9136 | /* Status. */ | |
9137 | json_object_string_add( | |
9138 | json_neigh, "bgpState", | |
9139 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
9140 | ||
9141 | if (p->status == Established) { | |
9142 | time_t uptime; | |
d62a17ae | 9143 | |
9144 | uptime = bgp_clock(); | |
9145 | uptime -= p->uptime; | |
d62a17ae | 9146 | epoch_tbuf = time(NULL) - uptime; |
9147 | ||
bee57a7a | 9148 | #if CONFDATE > 20200101 |
a4d82a8a PZ |
9149 | CPP_NOTICE( |
9150 | "bgpTimerUp should be deprecated and can be removed now"); | |
d3c7efed DS |
9151 | #endif |
9152 | /* | |
9153 | * bgpTimerUp was miliseconds that was accurate | |
9154 | * up to 1 day, then the value returned | |
9155 | * became garbage. So in order to provide | |
9156 | * some level of backwards compatability, | |
9157 | * we still provde the data, but now | |
9158 | * we are returning the correct value | |
9159 | * and also adding a new bgpTimerUpMsec | |
9160 | * which will allow us to deprecate | |
9161 | * this eventually | |
9162 | */ | |
d62a17ae | 9163 | json_object_int_add(json_neigh, "bgpTimerUp", |
e0330274 | 9164 | uptime * 1000); |
d3c7efed DS |
9165 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
9166 | uptime * 1000); | |
d62a17ae | 9167 | json_object_string_add(json_neigh, "bgpTimerUpString", |
9168 | peer_uptime(p->uptime, timebuf, | |
9169 | BGP_UPTIME_LEN, 0, | |
9170 | NULL)); | |
9171 | json_object_int_add(json_neigh, | |
9172 | "bgpTimerUpEstablishedEpoch", | |
9173 | epoch_tbuf); | |
9174 | } | |
9175 | ||
9176 | else if (p->status == Active) { | |
9177 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
9178 | json_object_string_add(json_neigh, "bgpStateIs", | |
9179 | "passive"); | |
9180 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
9181 | json_object_string_add(json_neigh, "bgpStateIs", | |
9182 | "passiveNSF"); | |
9183 | } | |
9184 | ||
9185 | /* read timer */ | |
9186 | time_t uptime; | |
9187 | struct tm *tm; | |
9188 | ||
9189 | uptime = bgp_clock(); | |
9190 | uptime -= p->readtime; | |
9191 | tm = gmtime(&uptime); | |
9192 | json_object_int_add(json_neigh, "bgpTimerLastRead", | |
9193 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9194 | + (tm->tm_hour * 3600000)); | |
9195 | ||
9196 | uptime = bgp_clock(); | |
9197 | uptime -= p->last_write; | |
9198 | tm = gmtime(&uptime); | |
9199 | json_object_int_add(json_neigh, "bgpTimerLastWrite", | |
9200 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9201 | + (tm->tm_hour * 3600000)); | |
9202 | ||
9203 | uptime = bgp_clock(); | |
9204 | uptime -= p->update_time; | |
9205 | tm = gmtime(&uptime); | |
9206 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", | |
9207 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9208 | + (tm->tm_hour * 3600000)); | |
9209 | ||
9210 | /* Configured timer values. */ | |
9211 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
9212 | p->v_holdtime * 1000); | |
9213 | json_object_int_add(json_neigh, | |
9214 | "bgpTimerKeepAliveIntervalMsecs", | |
9215 | p->v_keepalive * 1000); | |
b90a8e13 | 9216 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 9217 | json_object_int_add(json_neigh, |
9218 | "bgpTimerConfiguredHoldTimeMsecs", | |
9219 | p->holdtime * 1000); | |
9220 | json_object_int_add( | |
9221 | json_neigh, | |
9222 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
9223 | p->keepalive * 1000); | |
d25e4efc | 9224 | } else if ((bgp->default_holdtime != BGP_DEFAULT_HOLDTIME) |
a4d82a8a PZ |
9225 | || (bgp->default_keepalive |
9226 | != BGP_DEFAULT_KEEPALIVE)) { | |
d25e4efc DS |
9227 | json_object_int_add(json_neigh, |
9228 | "bgpTimerConfiguredHoldTimeMsecs", | |
9229 | bgp->default_holdtime); | |
9230 | json_object_int_add( | |
9231 | json_neigh, | |
9232 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
9233 | bgp->default_keepalive); | |
d62a17ae | 9234 | } |
9235 | } else { | |
9236 | /* Administrative shutdown. */ | |
9237 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
9238 | vty_out(vty, " Administratively shut down\n"); | |
9239 | ||
9240 | /* BGP Version. */ | |
9241 | vty_out(vty, " BGP version 4"); | |
0e38aeb4 | 9242 | vty_out(vty, ", remote router ID %s", |
d62a17ae | 9243 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
0e38aeb4 AD |
9244 | vty_out(vty, ", local router ID %s\n", |
9245 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
9246 | sizeof(buf1))); | |
d62a17ae | 9247 | |
9248 | /* Confederation */ | |
9249 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
9250 | && bgp_confederation_peers_check(bgp, p->as)) | |
9251 | vty_out(vty, | |
9252 | " Neighbor under common administration\n"); | |
9253 | ||
9254 | /* Status. */ | |
9255 | vty_out(vty, " BGP state = %s", | |
9256 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
9257 | ||
9258 | if (p->status == Established) | |
9259 | vty_out(vty, ", up for %8s", | |
9260 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
9261 | 0, NULL)); | |
9262 | ||
9263 | else if (p->status == Active) { | |
9264 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
9265 | vty_out(vty, " (passive)"); | |
9266 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
9267 | vty_out(vty, " (NSF passive)"); | |
9268 | } | |
9269 | vty_out(vty, "\n"); | |
9270 | ||
9271 | /* read timer */ | |
9272 | vty_out(vty, " Last read %s", | |
9273 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
9274 | NULL)); | |
9275 | vty_out(vty, ", Last write %s\n", | |
9276 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
9277 | NULL)); | |
9278 | ||
9279 | /* Configured timer values. */ | |
9280 | vty_out(vty, | |
9281 | " Hold time is %d, keepalive interval is %d seconds\n", | |
9282 | p->v_holdtime, p->v_keepalive); | |
b90a8e13 | 9283 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 9284 | vty_out(vty, " Configured hold time is %d", |
9285 | p->holdtime); | |
9286 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
9287 | p->keepalive); | |
d25e4efc | 9288 | } else if ((bgp->default_holdtime != BGP_DEFAULT_HOLDTIME) |
a4d82a8a PZ |
9289 | || (bgp->default_keepalive |
9290 | != BGP_DEFAULT_KEEPALIVE)) { | |
d25e4efc DS |
9291 | vty_out(vty, " Configured hold time is %d", |
9292 | bgp->default_holdtime); | |
9293 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
9294 | bgp->default_keepalive); | |
d62a17ae | 9295 | } |
9296 | } | |
9297 | /* Capability. */ | |
9298 | if (p->status == Established) { | |
9299 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] | |
9300 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
9301 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
9302 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
9303 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
9304 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
9305 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
9306 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
9307 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
9308 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
9309 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
9310 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
7c40bf39 | 9311 | || p->afc_adv[AFI_IP6][SAFI_FLOWSPEC] |
9312 | || p->afc_recv[AFI_IP6][SAFI_FLOWSPEC] | |
d62a17ae | 9313 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
9314 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
7c40bf39 | 9315 | || p->afc_adv[AFI_IP][SAFI_FLOWSPEC] |
9316 | || p->afc_recv[AFI_IP][SAFI_FLOWSPEC] | |
d62a17ae | 9317 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
9318 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
9319 | if (use_json) { | |
9320 | json_object *json_cap = NULL; | |
9321 | ||
9322 | json_cap = json_object_new_object(); | |
9323 | ||
9324 | /* AS4 */ | |
9325 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
9326 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
9327 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
9328 | && CHECK_FLAG(p->cap, | |
9329 | PEER_CAP_AS4_RCV)) | |
9330 | json_object_string_add( | |
9331 | json_cap, "4byteAs", | |
9332 | "advertisedAndReceived"); | |
9333 | else if (CHECK_FLAG(p->cap, | |
9334 | PEER_CAP_AS4_ADV)) | |
9335 | json_object_string_add( | |
9336 | json_cap, "4byteAs", | |
9337 | "advertised"); | |
9338 | else if (CHECK_FLAG(p->cap, | |
9339 | PEER_CAP_AS4_RCV)) | |
9340 | json_object_string_add( | |
9341 | json_cap, "4byteAs", | |
9342 | "received"); | |
9343 | } | |
9344 | ||
9345 | /* AddPath */ | |
9346 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
9347 | || CHECK_FLAG(p->cap, | |
9348 | PEER_CAP_ADDPATH_ADV)) { | |
9349 | json_object *json_add = NULL; | |
9350 | const char *print_store; | |
9351 | ||
9352 | json_add = json_object_new_object(); | |
9353 | ||
05c7a1cc QY |
9354 | FOREACH_AFI_SAFI (afi, safi) { |
9355 | json_object *json_sub = NULL; | |
9356 | json_sub = | |
9357 | json_object_new_object(); | |
9358 | print_store = afi_safi_print( | |
9359 | afi, safi); | |
d62a17ae | 9360 | |
05c7a1cc QY |
9361 | if (CHECK_FLAG( |
9362 | p->af_cap[afi] | |
9363 | [safi], | |
9364 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9365 | || CHECK_FLAG( | |
9366 | p->af_cap[afi] | |
9367 | [safi], | |
9368 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 9369 | if (CHECK_FLAG( |
9370 | p->af_cap | |
9371 | [afi] | |
9372 | [safi], | |
9373 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 9374 | && CHECK_FLAG( |
d62a17ae | 9375 | p->af_cap |
9376 | [afi] | |
9377 | [safi], | |
05c7a1cc QY |
9378 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
9379 | json_object_boolean_true_add( | |
9380 | json_sub, | |
9381 | "txAdvertisedAndReceived"); | |
9382 | else if ( | |
9383 | CHECK_FLAG( | |
9384 | p->af_cap | |
9385 | [afi] | |
9386 | [safi], | |
9387 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
9388 | json_object_boolean_true_add( | |
9389 | json_sub, | |
9390 | "txAdvertised"); | |
9391 | else if ( | |
9392 | CHECK_FLAG( | |
9393 | p->af_cap | |
9394 | [afi] | |
9395 | [safi], | |
9396 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
9397 | json_object_boolean_true_add( | |
9398 | json_sub, | |
9399 | "txReceived"); | |
9400 | } | |
d62a17ae | 9401 | |
05c7a1cc QY |
9402 | if (CHECK_FLAG( |
9403 | p->af_cap[afi] | |
9404 | [safi], | |
9405 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9406 | || CHECK_FLAG( | |
9407 | p->af_cap[afi] | |
9408 | [safi], | |
9409 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 9410 | if (CHECK_FLAG( |
9411 | p->af_cap | |
9412 | [afi] | |
9413 | [safi], | |
9414 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 9415 | && CHECK_FLAG( |
d62a17ae | 9416 | p->af_cap |
9417 | [afi] | |
9418 | [safi], | |
9419 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
9420 | json_object_boolean_true_add( |
9421 | json_sub, | |
9422 | "rxAdvertisedAndReceived"); | |
9423 | else if ( | |
9424 | CHECK_FLAG( | |
9425 | p->af_cap | |
9426 | [afi] | |
9427 | [safi], | |
9428 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
9429 | json_object_boolean_true_add( | |
9430 | json_sub, | |
9431 | "rxAdvertised"); | |
9432 | else if ( | |
9433 | CHECK_FLAG( | |
9434 | p->af_cap | |
9435 | [afi] | |
9436 | [safi], | |
9437 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
9438 | json_object_boolean_true_add( | |
9439 | json_sub, | |
9440 | "rxReceived"); | |
d62a17ae | 9441 | } |
9442 | ||
05c7a1cc QY |
9443 | if (CHECK_FLAG( |
9444 | p->af_cap[afi] | |
9445 | [safi], | |
9446 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9447 | || CHECK_FLAG( | |
9448 | p->af_cap[afi] | |
9449 | [safi], | |
9450 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
9451 | || CHECK_FLAG( | |
9452 | p->af_cap[afi] | |
9453 | [safi], | |
9454 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9455 | || CHECK_FLAG( | |
9456 | p->af_cap[afi] | |
9457 | [safi], | |
9458 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
9459 | json_object_object_add( | |
9460 | json_add, | |
9461 | print_store, | |
9462 | json_sub); | |
9463 | else | |
9464 | json_object_free( | |
9465 | json_sub); | |
9466 | } | |
9467 | ||
d62a17ae | 9468 | json_object_object_add( |
9469 | json_cap, "addPath", json_add); | |
9470 | } | |
9471 | ||
9472 | /* Dynamic */ | |
9473 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
9474 | || CHECK_FLAG(p->cap, | |
9475 | PEER_CAP_DYNAMIC_ADV)) { | |
9476 | if (CHECK_FLAG(p->cap, | |
9477 | PEER_CAP_DYNAMIC_ADV) | |
9478 | && CHECK_FLAG(p->cap, | |
9479 | PEER_CAP_DYNAMIC_RCV)) | |
9480 | json_object_string_add( | |
9481 | json_cap, "dynamic", | |
9482 | "advertisedAndReceived"); | |
9483 | else if (CHECK_FLAG( | |
9484 | p->cap, | |
9485 | PEER_CAP_DYNAMIC_ADV)) | |
9486 | json_object_string_add( | |
9487 | json_cap, "dynamic", | |
9488 | "advertised"); | |
9489 | else if (CHECK_FLAG( | |
9490 | p->cap, | |
9491 | PEER_CAP_DYNAMIC_RCV)) | |
9492 | json_object_string_add( | |
9493 | json_cap, "dynamic", | |
9494 | "received"); | |
9495 | } | |
9496 | ||
9497 | /* Extended nexthop */ | |
9498 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
9499 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
9500 | json_object *json_nxt = NULL; | |
9501 | const char *print_store; | |
9502 | ||
9503 | ||
9504 | if (CHECK_FLAG(p->cap, | |
9505 | PEER_CAP_ENHE_ADV) | |
9506 | && CHECK_FLAG(p->cap, | |
9507 | PEER_CAP_ENHE_RCV)) | |
9508 | json_object_string_add( | |
9509 | json_cap, | |
9510 | "extendedNexthop", | |
9511 | "advertisedAndReceived"); | |
9512 | else if (CHECK_FLAG(p->cap, | |
9513 | PEER_CAP_ENHE_ADV)) | |
9514 | json_object_string_add( | |
9515 | json_cap, | |
9516 | "extendedNexthop", | |
9517 | "advertised"); | |
9518 | else if (CHECK_FLAG(p->cap, | |
9519 | PEER_CAP_ENHE_RCV)) | |
9520 | json_object_string_add( | |
9521 | json_cap, | |
9522 | "extendedNexthop", | |
9523 | "received"); | |
9524 | ||
9525 | if (CHECK_FLAG(p->cap, | |
9526 | PEER_CAP_ENHE_RCV)) { | |
9527 | json_nxt = | |
9528 | json_object_new_object(); | |
9529 | ||
9530 | for (safi = SAFI_UNICAST; | |
9531 | safi < SAFI_MAX; safi++) { | |
9532 | if (CHECK_FLAG( | |
9533 | p->af_cap | |
9534 | [AFI_IP] | |
9535 | [safi], | |
9536 | PEER_CAP_ENHE_AF_RCV)) { | |
9537 | print_store = afi_safi_print( | |
9538 | AFI_IP, | |
9539 | safi); | |
9540 | json_object_string_add( | |
9541 | json_nxt, | |
9542 | print_store, | |
9543 | "recieved"); | |
9544 | } | |
9545 | } | |
9546 | json_object_object_add( | |
9547 | json_cap, | |
9548 | "extendedNexthopFamililesByPeer", | |
9549 | json_nxt); | |
9550 | } | |
9551 | } | |
9552 | ||
9553 | /* Route Refresh */ | |
9554 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
9555 | || CHECK_FLAG(p->cap, | |
9556 | PEER_CAP_REFRESH_NEW_RCV) | |
9557 | || CHECK_FLAG(p->cap, | |
9558 | PEER_CAP_REFRESH_OLD_RCV)) { | |
9559 | if (CHECK_FLAG(p->cap, | |
9560 | PEER_CAP_REFRESH_ADV) | |
9561 | && (CHECK_FLAG( | |
9562 | p->cap, | |
9563 | PEER_CAP_REFRESH_NEW_RCV) | |
9564 | || CHECK_FLAG( | |
9565 | p->cap, | |
9566 | PEER_CAP_REFRESH_OLD_RCV))) { | |
9567 | if (CHECK_FLAG( | |
9568 | p->cap, | |
9569 | PEER_CAP_REFRESH_OLD_RCV) | |
9570 | && CHECK_FLAG( | |
9571 | p->cap, | |
9572 | PEER_CAP_REFRESH_NEW_RCV)) | |
9573 | json_object_string_add( | |
9574 | json_cap, | |
9575 | "routeRefresh", | |
9576 | "advertisedAndReceivedOldNew"); | |
9577 | else { | |
9578 | if (CHECK_FLAG( | |
9579 | p->cap, | |
9580 | PEER_CAP_REFRESH_OLD_RCV)) | |
9581 | json_object_string_add( | |
9582 | json_cap, | |
9583 | "routeRefresh", | |
9584 | "advertisedAndReceivedOld"); | |
9585 | else | |
9586 | json_object_string_add( | |
9587 | json_cap, | |
9588 | "routeRefresh", | |
9589 | "advertisedAndReceivedNew"); | |
9590 | } | |
9591 | } else if ( | |
9592 | CHECK_FLAG( | |
9593 | p->cap, | |
9594 | PEER_CAP_REFRESH_ADV)) | |
9595 | json_object_string_add( | |
9596 | json_cap, | |
9597 | "routeRefresh", | |
9598 | "advertised"); | |
9599 | else if ( | |
9600 | CHECK_FLAG( | |
9601 | p->cap, | |
9602 | PEER_CAP_REFRESH_NEW_RCV) | |
9603 | || CHECK_FLAG( | |
9604 | p->cap, | |
9605 | PEER_CAP_REFRESH_OLD_RCV)) | |
9606 | json_object_string_add( | |
9607 | json_cap, | |
9608 | "routeRefresh", | |
9609 | "received"); | |
9610 | } | |
9611 | ||
9612 | /* Multiprotocol Extensions */ | |
9613 | json_object *json_multi = NULL; | |
9614 | json_multi = json_object_new_object(); | |
9615 | ||
05c7a1cc QY |
9616 | FOREACH_AFI_SAFI (afi, safi) { |
9617 | if (p->afc_adv[afi][safi] | |
9618 | || p->afc_recv[afi][safi]) { | |
9619 | json_object *json_exten = NULL; | |
9620 | json_exten = | |
9621 | json_object_new_object(); | |
9622 | ||
d62a17ae | 9623 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
9624 | && p->afc_recv[afi][safi]) |
9625 | json_object_boolean_true_add( | |
9626 | json_exten, | |
9627 | "advertisedAndReceived"); | |
9628 | else if (p->afc_adv[afi][safi]) | |
9629 | json_object_boolean_true_add( | |
9630 | json_exten, | |
9631 | "advertised"); | |
9632 | else if (p->afc_recv[afi][safi]) | |
9633 | json_object_boolean_true_add( | |
9634 | json_exten, | |
9635 | "received"); | |
d62a17ae | 9636 | |
05c7a1cc QY |
9637 | json_object_object_add( |
9638 | json_multi, | |
9639 | afi_safi_print(afi, | |
9640 | safi), | |
9641 | json_exten); | |
d62a17ae | 9642 | } |
9643 | } | |
9644 | json_object_object_add( | |
9645 | json_cap, "multiprotocolExtensions", | |
9646 | json_multi); | |
9647 | ||
d77114b7 | 9648 | /* Hostname capabilities */ |
60466a63 | 9649 | json_object *json_hname = NULL; |
d77114b7 MK |
9650 | |
9651 | json_hname = json_object_new_object(); | |
9652 | ||
9653 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
9654 | json_object_string_add( | |
60466a63 QY |
9655 | json_hname, "advHostName", |
9656 | bgp->peer_self->hostname | |
9657 | ? bgp->peer_self | |
9658 | ->hostname | |
d77114b7 MK |
9659 | : "n/a"); |
9660 | json_object_string_add( | |
60466a63 QY |
9661 | json_hname, "advDomainName", |
9662 | bgp->peer_self->domainname | |
9663 | ? bgp->peer_self | |
9664 | ->domainname | |
d77114b7 MK |
9665 | : "n/a"); |
9666 | } | |
9667 | ||
9668 | ||
9669 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
9670 | json_object_string_add( | |
60466a63 QY |
9671 | json_hname, "rcvHostName", |
9672 | p->hostname ? p->hostname | |
9673 | : "n/a"); | |
d77114b7 | 9674 | json_object_string_add( |
60466a63 QY |
9675 | json_hname, "rcvDomainName", |
9676 | p->domainname ? p->domainname | |
9677 | : "n/a"); | |
d77114b7 MK |
9678 | } |
9679 | ||
60466a63 | 9680 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
9681 | json_hname); |
9682 | ||
d62a17ae | 9683 | /* Gracefull Restart */ |
9684 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
9685 | || CHECK_FLAG(p->cap, | |
9686 | PEER_CAP_RESTART_ADV)) { | |
9687 | if (CHECK_FLAG(p->cap, | |
9688 | PEER_CAP_RESTART_ADV) | |
9689 | && CHECK_FLAG(p->cap, | |
9690 | PEER_CAP_RESTART_RCV)) | |
9691 | json_object_string_add( | |
9692 | json_cap, | |
9693 | "gracefulRestart", | |
9694 | "advertisedAndReceived"); | |
9695 | else if (CHECK_FLAG( | |
9696 | p->cap, | |
9697 | PEER_CAP_RESTART_ADV)) | |
9698 | json_object_string_add( | |
9699 | json_cap, | |
9700 | "gracefulRestartCapability", | |
9701 | "advertised"); | |
9702 | else if (CHECK_FLAG( | |
9703 | p->cap, | |
9704 | PEER_CAP_RESTART_RCV)) | |
9705 | json_object_string_add( | |
9706 | json_cap, | |
9707 | "gracefulRestartCapability", | |
9708 | "received"); | |
9709 | ||
9710 | if (CHECK_FLAG(p->cap, | |
9711 | PEER_CAP_RESTART_RCV)) { | |
9712 | int restart_af_count = 0; | |
9713 | json_object *json_restart = | |
9714 | NULL; | |
9715 | json_restart = | |
9716 | json_object_new_object(); | |
9717 | ||
9718 | json_object_int_add( | |
9719 | json_cap, | |
9720 | "gracefulRestartRemoteTimerMsecs", | |
9721 | p->v_gr_restart * 1000); | |
9722 | ||
05c7a1cc QY |
9723 | FOREACH_AFI_SAFI (afi, safi) { |
9724 | if (CHECK_FLAG( | |
9725 | p->af_cap | |
9726 | [afi] | |
9727 | [safi], | |
9728 | PEER_CAP_RESTART_AF_RCV)) { | |
9729 | json_object * | |
9730 | json_sub = | |
9731 | NULL; | |
9732 | json_sub = | |
9733 | json_object_new_object(); | |
9734 | ||
d62a17ae | 9735 | if (CHECK_FLAG( |
9736 | p->af_cap | |
9737 | [afi] | |
9738 | [safi], | |
05c7a1cc QY |
9739 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
9740 | json_object_boolean_true_add( | |
9741 | json_sub, | |
9742 | "preserved"); | |
9743 | restart_af_count++; | |
9744 | json_object_object_add( | |
9745 | json_restart, | |
9746 | afi_safi_print( | |
9747 | afi, | |
9748 | safi), | |
9749 | json_sub); | |
d62a17ae | 9750 | } |
9751 | } | |
9752 | if (!restart_af_count) { | |
9753 | json_object_string_add( | |
9754 | json_cap, | |
9755 | "addressFamiliesByPeer", | |
9756 | "none"); | |
9757 | json_object_free( | |
9758 | json_restart); | |
9759 | } else | |
9760 | json_object_object_add( | |
9761 | json_cap, | |
9762 | "addressFamiliesByPeer", | |
9763 | json_restart); | |
9764 | } | |
9765 | } | |
9766 | json_object_object_add(json_neigh, | |
9767 | "neighborCapabilities", | |
9768 | json_cap); | |
9769 | } else { | |
9770 | vty_out(vty, " Neighbor capabilities:\n"); | |
9771 | ||
9772 | /* AS4 */ | |
9773 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
9774 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
9775 | vty_out(vty, " 4 Byte AS:"); | |
9776 | if (CHECK_FLAG(p->cap, | |
9777 | PEER_CAP_AS4_ADV)) | |
9778 | vty_out(vty, " advertised"); | |
9779 | if (CHECK_FLAG(p->cap, | |
9780 | PEER_CAP_AS4_RCV)) | |
9781 | vty_out(vty, " %sreceived", | |
9782 | CHECK_FLAG( | |
9783 | p->cap, | |
9784 | PEER_CAP_AS4_ADV) | |
9785 | ? "and " | |
9786 | : ""); | |
9787 | vty_out(vty, "\n"); | |
9788 | } | |
9789 | ||
9790 | /* AddPath */ | |
9791 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
9792 | || CHECK_FLAG(p->cap, | |
9793 | PEER_CAP_ADDPATH_ADV)) { | |
9794 | vty_out(vty, " AddPath:\n"); | |
9795 | ||
05c7a1cc QY |
9796 | FOREACH_AFI_SAFI (afi, safi) { |
9797 | if (CHECK_FLAG( | |
9798 | p->af_cap[afi] | |
9799 | [safi], | |
9800 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9801 | || CHECK_FLAG( | |
9802 | p->af_cap[afi] | |
9803 | [safi], | |
9804 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
9805 | vty_out(vty, | |
9806 | " %s: TX ", | |
9807 | afi_safi_print( | |
9808 | afi, | |
9809 | safi)); | |
9810 | ||
d62a17ae | 9811 | if (CHECK_FLAG( |
9812 | p->af_cap | |
9813 | [afi] | |
9814 | [safi], | |
05c7a1cc | 9815 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 9816 | vty_out(vty, |
05c7a1cc | 9817 | "advertised %s", |
d62a17ae | 9818 | afi_safi_print( |
9819 | afi, | |
9820 | safi)); | |
9821 | ||
05c7a1cc QY |
9822 | if (CHECK_FLAG( |
9823 | p->af_cap | |
9824 | [afi] | |
9825 | [safi], | |
9826 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
9827 | vty_out(vty, | |
9828 | "%sreceived", | |
9829 | CHECK_FLAG( | |
9830 | p->af_cap | |
9831 | [afi] | |
9832 | [safi], | |
9833 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9834 | ? " and " | |
9835 | : ""); | |
d62a17ae | 9836 | |
05c7a1cc QY |
9837 | vty_out(vty, "\n"); |
9838 | } | |
d62a17ae | 9839 | |
05c7a1cc QY |
9840 | if (CHECK_FLAG( |
9841 | p->af_cap[afi] | |
9842 | [safi], | |
9843 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9844 | || CHECK_FLAG( | |
9845 | p->af_cap[afi] | |
9846 | [safi], | |
9847 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
9848 | vty_out(vty, | |
9849 | " %s: RX ", | |
9850 | afi_safi_print( | |
9851 | afi, | |
9852 | safi)); | |
d62a17ae | 9853 | |
9854 | if (CHECK_FLAG( | |
9855 | p->af_cap | |
9856 | [afi] | |
9857 | [safi], | |
05c7a1cc | 9858 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 9859 | vty_out(vty, |
05c7a1cc | 9860 | "advertised %s", |
d62a17ae | 9861 | afi_safi_print( |
9862 | afi, | |
9863 | safi)); | |
9864 | ||
05c7a1cc QY |
9865 | if (CHECK_FLAG( |
9866 | p->af_cap | |
9867 | [afi] | |
9868 | [safi], | |
9869 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 9870 | vty_out(vty, |
05c7a1cc QY |
9871 | "%sreceived", |
9872 | CHECK_FLAG( | |
9873 | p->af_cap | |
9874 | [afi] | |
9875 | [safi], | |
9876 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9877 | ? " and " | |
9878 | : ""); | |
9879 | ||
9880 | vty_out(vty, "\n"); | |
d62a17ae | 9881 | } |
05c7a1cc | 9882 | } |
d62a17ae | 9883 | } |
9884 | ||
9885 | /* Dynamic */ | |
9886 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
9887 | || CHECK_FLAG(p->cap, | |
9888 | PEER_CAP_DYNAMIC_ADV)) { | |
9889 | vty_out(vty, " Dynamic:"); | |
9890 | if (CHECK_FLAG(p->cap, | |
9891 | PEER_CAP_DYNAMIC_ADV)) | |
9892 | vty_out(vty, " advertised"); | |
9893 | if (CHECK_FLAG(p->cap, | |
9894 | PEER_CAP_DYNAMIC_RCV)) | |
9895 | vty_out(vty, " %sreceived", | |
9896 | CHECK_FLAG( | |
9897 | p->cap, | |
9898 | PEER_CAP_DYNAMIC_ADV) | |
9899 | ? "and " | |
9900 | : ""); | |
9901 | vty_out(vty, "\n"); | |
9902 | } | |
9903 | ||
9904 | /* Extended nexthop */ | |
9905 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
9906 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
9907 | vty_out(vty, " Extended nexthop:"); | |
9908 | if (CHECK_FLAG(p->cap, | |
9909 | PEER_CAP_ENHE_ADV)) | |
9910 | vty_out(vty, " advertised"); | |
9911 | if (CHECK_FLAG(p->cap, | |
9912 | PEER_CAP_ENHE_RCV)) | |
9913 | vty_out(vty, " %sreceived", | |
9914 | CHECK_FLAG( | |
9915 | p->cap, | |
9916 | PEER_CAP_ENHE_ADV) | |
9917 | ? "and " | |
9918 | : ""); | |
9919 | vty_out(vty, "\n"); | |
9920 | ||
9921 | if (CHECK_FLAG(p->cap, | |
9922 | PEER_CAP_ENHE_RCV)) { | |
9923 | vty_out(vty, | |
9924 | " Address families by peer:\n "); | |
9925 | for (safi = SAFI_UNICAST; | |
9926 | safi < SAFI_MAX; safi++) | |
9927 | if (CHECK_FLAG( | |
9928 | p->af_cap | |
9929 | [AFI_IP] | |
9930 | [safi], | |
9931 | PEER_CAP_ENHE_AF_RCV)) | |
9932 | vty_out(vty, | |
9933 | " %s\n", | |
9934 | afi_safi_print( | |
9935 | AFI_IP, | |
9936 | safi)); | |
9937 | } | |
9938 | } | |
9939 | ||
9940 | /* Route Refresh */ | |
9941 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
9942 | || CHECK_FLAG(p->cap, | |
9943 | PEER_CAP_REFRESH_NEW_RCV) | |
9944 | || CHECK_FLAG(p->cap, | |
9945 | PEER_CAP_REFRESH_OLD_RCV)) { | |
9946 | vty_out(vty, " Route refresh:"); | |
9947 | if (CHECK_FLAG(p->cap, | |
9948 | PEER_CAP_REFRESH_ADV)) | |
9949 | vty_out(vty, " advertised"); | |
9950 | if (CHECK_FLAG(p->cap, | |
9951 | PEER_CAP_REFRESH_NEW_RCV) | |
9952 | || CHECK_FLAG( | |
9953 | p->cap, | |
9954 | PEER_CAP_REFRESH_OLD_RCV)) | |
9955 | vty_out(vty, " %sreceived(%s)", | |
9956 | CHECK_FLAG( | |
9957 | p->cap, | |
9958 | PEER_CAP_REFRESH_ADV) | |
9959 | ? "and " | |
9960 | : "", | |
9961 | (CHECK_FLAG( | |
9962 | p->cap, | |
9963 | PEER_CAP_REFRESH_OLD_RCV) | |
9964 | && CHECK_FLAG( | |
9965 | p->cap, | |
9966 | PEER_CAP_REFRESH_NEW_RCV)) | |
9967 | ? "old & new" | |
9968 | : CHECK_FLAG( | |
9969 | p->cap, | |
9970 | PEER_CAP_REFRESH_OLD_RCV) | |
9971 | ? "old" | |
9972 | : "new"); | |
9973 | ||
9974 | vty_out(vty, "\n"); | |
9975 | } | |
9976 | ||
9977 | /* Multiprotocol Extensions */ | |
05c7a1cc QY |
9978 | FOREACH_AFI_SAFI (afi, safi) |
9979 | if (p->afc_adv[afi][safi] | |
9980 | || p->afc_recv[afi][safi]) { | |
9981 | vty_out(vty, | |
9982 | " Address Family %s:", | |
9983 | afi_safi_print(afi, | |
9984 | safi)); | |
9985 | if (p->afc_adv[afi][safi]) | |
d62a17ae | 9986 | vty_out(vty, |
05c7a1cc QY |
9987 | " advertised"); |
9988 | if (p->afc_recv[afi][safi]) | |
9989 | vty_out(vty, | |
9990 | " %sreceived", | |
9991 | p->afc_adv[afi] | |
9992 | [safi] | |
9993 | ? "and " | |
9994 | : ""); | |
9995 | vty_out(vty, "\n"); | |
9996 | } | |
d62a17ae | 9997 | |
9998 | /* Hostname capability */ | |
60466a63 | 9999 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
10000 | |
10001 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
10002 | vty_out(vty, |
10003 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
10004 | bgp->peer_self->hostname |
10005 | ? bgp->peer_self | |
10006 | ->hostname | |
d77114b7 | 10007 | : "n/a", |
60466a63 QY |
10008 | bgp->peer_self->domainname |
10009 | ? bgp->peer_self | |
10010 | ->domainname | |
d77114b7 MK |
10011 | : "n/a"); |
10012 | } else { | |
10013 | vty_out(vty, " not advertised"); | |
d62a17ae | 10014 | } |
10015 | ||
d77114b7 | 10016 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
10017 | vty_out(vty, |
10018 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
10019 | p->hostname ? p->hostname |
10020 | : "n/a", | |
10021 | p->domainname ? p->domainname | |
10022 | : "n/a"); | |
d77114b7 MK |
10023 | } else { |
10024 | vty_out(vty, " not received"); | |
10025 | } | |
10026 | ||
10027 | vty_out(vty, "\n"); | |
10028 | ||
d62a17ae | 10029 | /* Gracefull Restart */ |
10030 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
10031 | || CHECK_FLAG(p->cap, | |
10032 | PEER_CAP_RESTART_ADV)) { | |
10033 | vty_out(vty, | |
10034 | " Graceful Restart Capabilty:"); | |
10035 | if (CHECK_FLAG(p->cap, | |
10036 | PEER_CAP_RESTART_ADV)) | |
10037 | vty_out(vty, " advertised"); | |
10038 | if (CHECK_FLAG(p->cap, | |
10039 | PEER_CAP_RESTART_RCV)) | |
10040 | vty_out(vty, " %sreceived", | |
10041 | CHECK_FLAG( | |
10042 | p->cap, | |
10043 | PEER_CAP_RESTART_ADV) | |
10044 | ? "and " | |
10045 | : ""); | |
10046 | vty_out(vty, "\n"); | |
10047 | ||
10048 | if (CHECK_FLAG(p->cap, | |
10049 | PEER_CAP_RESTART_RCV)) { | |
10050 | int restart_af_count = 0; | |
10051 | ||
10052 | vty_out(vty, | |
10053 | " Remote Restart timer is %d seconds\n", | |
10054 | p->v_gr_restart); | |
10055 | vty_out(vty, | |
10056 | " Address families by peer:\n "); | |
10057 | ||
05c7a1cc QY |
10058 | FOREACH_AFI_SAFI (afi, safi) |
10059 | if (CHECK_FLAG( | |
10060 | p->af_cap | |
10061 | [afi] | |
10062 | [safi], | |
10063 | PEER_CAP_RESTART_AF_RCV)) { | |
10064 | vty_out(vty, | |
10065 | "%s%s(%s)", | |
10066 | restart_af_count | |
10067 | ? ", " | |
10068 | : "", | |
10069 | afi_safi_print( | |
10070 | afi, | |
10071 | safi), | |
10072 | CHECK_FLAG( | |
10073 | p->af_cap | |
10074 | [afi] | |
10075 | [safi], | |
10076 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
10077 | ? "preserved" | |
10078 | : "not preserved"); | |
10079 | restart_af_count++; | |
10080 | } | |
d62a17ae | 10081 | if (!restart_af_count) |
10082 | vty_out(vty, "none"); | |
10083 | vty_out(vty, "\n"); | |
10084 | } | |
10085 | } | |
10086 | } | |
10087 | } | |
10088 | } | |
10089 | ||
10090 | /* graceful restart information */ | |
10091 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) || p->t_gr_restart | |
10092 | || p->t_gr_stale) { | |
10093 | json_object *json_grace = NULL; | |
10094 | json_object *json_grace_send = NULL; | |
10095 | json_object *json_grace_recv = NULL; | |
10096 | int eor_send_af_count = 0; | |
10097 | int eor_receive_af_count = 0; | |
10098 | ||
10099 | if (use_json) { | |
10100 | json_grace = json_object_new_object(); | |
10101 | json_grace_send = json_object_new_object(); | |
10102 | json_grace_recv = json_object_new_object(); | |
10103 | ||
10104 | if (p->status == Established) { | |
05c7a1cc QY |
10105 | FOREACH_AFI_SAFI (afi, safi) { |
10106 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10107 | PEER_STATUS_EOR_SEND)) { | |
10108 | json_object_boolean_true_add( | |
10109 | json_grace_send, | |
10110 | afi_safi_print(afi, | |
10111 | safi)); | |
10112 | eor_send_af_count++; | |
d62a17ae | 10113 | } |
10114 | } | |
05c7a1cc QY |
10115 | FOREACH_AFI_SAFI (afi, safi) { |
10116 | if (CHECK_FLAG( | |
10117 | p->af_sflags[afi][safi], | |
10118 | PEER_STATUS_EOR_RECEIVED)) { | |
10119 | json_object_boolean_true_add( | |
10120 | json_grace_recv, | |
10121 | afi_safi_print(afi, | |
10122 | safi)); | |
10123 | eor_receive_af_count++; | |
d62a17ae | 10124 | } |
10125 | } | |
10126 | } | |
10127 | ||
10128 | json_object_object_add(json_grace, "endOfRibSend", | |
10129 | json_grace_send); | |
10130 | json_object_object_add(json_grace, "endOfRibRecv", | |
10131 | json_grace_recv); | |
10132 | ||
10133 | if (p->t_gr_restart) | |
10134 | json_object_int_add(json_grace, | |
10135 | "gracefulRestartTimerMsecs", | |
10136 | thread_timer_remain_second( | |
10137 | p->t_gr_restart) | |
10138 | * 1000); | |
10139 | ||
10140 | if (p->t_gr_stale) | |
10141 | json_object_int_add( | |
10142 | json_grace, | |
10143 | "gracefulStalepathTimerMsecs", | |
10144 | thread_timer_remain_second( | |
10145 | p->t_gr_stale) | |
10146 | * 1000); | |
10147 | ||
10148 | json_object_object_add( | |
10149 | json_neigh, "gracefulRestartInfo", json_grace); | |
10150 | } else { | |
10151 | vty_out(vty, " Graceful restart informations:\n"); | |
10152 | if (p->status == Established) { | |
10153 | vty_out(vty, " End-of-RIB send: "); | |
05c7a1cc QY |
10154 | FOREACH_AFI_SAFI (afi, safi) { |
10155 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10156 | PEER_STATUS_EOR_SEND)) { | |
10157 | vty_out(vty, "%s%s", | |
10158 | eor_send_af_count ? ", " | |
10159 | : "", | |
10160 | afi_safi_print(afi, | |
10161 | safi)); | |
10162 | eor_send_af_count++; | |
d62a17ae | 10163 | } |
10164 | } | |
10165 | vty_out(vty, "\n"); | |
10166 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
10167 | FOREACH_AFI_SAFI (afi, safi) { |
10168 | if (CHECK_FLAG( | |
10169 | p->af_sflags[afi][safi], | |
10170 | PEER_STATUS_EOR_RECEIVED)) { | |
10171 | vty_out(vty, "%s%s", | |
10172 | eor_receive_af_count | |
10173 | ? ", " | |
10174 | : "", | |
10175 | afi_safi_print(afi, | |
10176 | safi)); | |
10177 | eor_receive_af_count++; | |
d62a17ae | 10178 | } |
10179 | } | |
10180 | vty_out(vty, "\n"); | |
10181 | } | |
10182 | ||
10183 | if (p->t_gr_restart) | |
10184 | vty_out(vty, | |
10185 | " The remaining time of restart timer is %ld\n", | |
10186 | thread_timer_remain_second( | |
10187 | p->t_gr_restart)); | |
10188 | ||
10189 | if (p->t_gr_stale) | |
10190 | vty_out(vty, | |
10191 | " The remaining time of stalepath timer is %ld\n", | |
10192 | thread_timer_remain_second( | |
10193 | p->t_gr_stale)); | |
10194 | } | |
10195 | } | |
10196 | if (use_json) { | |
10197 | json_object *json_stat = NULL; | |
10198 | json_stat = json_object_new_object(); | |
10199 | /* Packet counts. */ | |
10200 | json_object_int_add(json_stat, "depthInq", 0); | |
10201 | json_object_int_add(json_stat, "depthOutq", | |
10202 | (unsigned long)p->obuf->count); | |
0112e9e0 QY |
10203 | json_object_int_add(json_stat, "opensSent", |
10204 | atomic_load_explicit(&p->open_out, | |
10205 | memory_order_relaxed)); | |
10206 | json_object_int_add(json_stat, "opensRecv", | |
10207 | atomic_load_explicit(&p->open_in, | |
10208 | memory_order_relaxed)); | |
d62a17ae | 10209 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
10210 | atomic_load_explicit(&p->notify_out, |
10211 | memory_order_relaxed)); | |
d62a17ae | 10212 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
10213 | atomic_load_explicit(&p->notify_in, |
10214 | memory_order_relaxed)); | |
10215 | json_object_int_add(json_stat, "updatesSent", | |
10216 | atomic_load_explicit(&p->update_out, | |
10217 | memory_order_relaxed)); | |
10218 | json_object_int_add(json_stat, "updatesRecv", | |
10219 | atomic_load_explicit(&p->update_in, | |
10220 | memory_order_relaxed)); | |
d62a17ae | 10221 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
10222 | atomic_load_explicit(&p->keepalive_out, |
10223 | memory_order_relaxed)); | |
d62a17ae | 10224 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
10225 | atomic_load_explicit(&p->keepalive_in, |
10226 | memory_order_relaxed)); | |
d62a17ae | 10227 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
10228 | atomic_load_explicit(&p->refresh_out, |
10229 | memory_order_relaxed)); | |
d62a17ae | 10230 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
10231 | atomic_load_explicit(&p->refresh_in, |
10232 | memory_order_relaxed)); | |
d62a17ae | 10233 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
10234 | atomic_load_explicit(&p->dynamic_cap_out, |
10235 | memory_order_relaxed)); | |
d62a17ae | 10236 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
10237 | atomic_load_explicit(&p->dynamic_cap_in, |
10238 | memory_order_relaxed)); | |
10239 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
10240 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 10241 | json_object_object_add(json_neigh, "messageStats", json_stat); |
10242 | } else { | |
10243 | /* Packet counts. */ | |
10244 | vty_out(vty, " Message statistics:\n"); | |
10245 | vty_out(vty, " Inq depth is 0\n"); | |
10246 | vty_out(vty, " Outq depth is %lu\n", | |
10247 | (unsigned long)p->obuf->count); | |
10248 | vty_out(vty, " Sent Rcvd\n"); | |
0112e9e0 QY |
10249 | vty_out(vty, " Opens: %10d %10d\n", |
10250 | atomic_load_explicit(&p->open_out, | |
10251 | memory_order_relaxed), | |
10252 | atomic_load_explicit(&p->open_in, | |
10253 | memory_order_relaxed)); | |
10254 | vty_out(vty, " Notifications: %10d %10d\n", | |
10255 | atomic_load_explicit(&p->notify_out, | |
10256 | memory_order_relaxed), | |
10257 | atomic_load_explicit(&p->notify_in, | |
10258 | memory_order_relaxed)); | |
10259 | vty_out(vty, " Updates: %10d %10d\n", | |
10260 | atomic_load_explicit(&p->update_out, | |
10261 | memory_order_relaxed), | |
10262 | atomic_load_explicit(&p->update_in, | |
10263 | memory_order_relaxed)); | |
10264 | vty_out(vty, " Keepalives: %10d %10d\n", | |
10265 | atomic_load_explicit(&p->keepalive_out, | |
10266 | memory_order_relaxed), | |
10267 | atomic_load_explicit(&p->keepalive_in, | |
10268 | memory_order_relaxed)); | |
10269 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
10270 | atomic_load_explicit(&p->refresh_out, | |
10271 | memory_order_relaxed), | |
10272 | atomic_load_explicit(&p->refresh_in, | |
10273 | memory_order_relaxed)); | |
d62a17ae | 10274 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
10275 | atomic_load_explicit(&p->dynamic_cap_out, |
10276 | memory_order_relaxed), | |
10277 | atomic_load_explicit(&p->dynamic_cap_in, | |
10278 | memory_order_relaxed)); | |
10279 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
10280 | PEER_TOTAL_RX(p)); | |
d62a17ae | 10281 | } |
10282 | ||
10283 | if (use_json) { | |
10284 | /* advertisement-interval */ | |
10285 | json_object_int_add(json_neigh, | |
10286 | "minBtwnAdvertisementRunsTimerMsecs", | |
10287 | p->v_routeadv * 1000); | |
10288 | ||
10289 | /* Update-source. */ | |
10290 | if (p->update_if || p->update_source) { | |
10291 | if (p->update_if) | |
10292 | json_object_string_add(json_neigh, | |
10293 | "updateSource", | |
10294 | p->update_if); | |
10295 | else if (p->update_source) | |
10296 | json_object_string_add( | |
10297 | json_neigh, "updateSource", | |
10298 | sockunion2str(p->update_source, buf1, | |
10299 | SU_ADDRSTRLEN)); | |
10300 | } | |
10301 | } else { | |
10302 | /* advertisement-interval */ | |
10303 | vty_out(vty, | |
10304 | " Minimum time between advertisement runs is %d seconds\n", | |
10305 | p->v_routeadv); | |
10306 | ||
10307 | /* Update-source. */ | |
10308 | if (p->update_if || p->update_source) { | |
10309 | vty_out(vty, " Update source is "); | |
10310 | if (p->update_if) | |
10311 | vty_out(vty, "%s", p->update_if); | |
10312 | else if (p->update_source) | |
10313 | vty_out(vty, "%s", | |
10314 | sockunion2str(p->update_source, buf1, | |
10315 | SU_ADDRSTRLEN)); | |
10316 | vty_out(vty, "\n"); | |
10317 | } | |
10318 | ||
10319 | vty_out(vty, "\n"); | |
10320 | } | |
10321 | ||
10322 | /* Address Family Information */ | |
10323 | json_object *json_hold = NULL; | |
10324 | ||
10325 | if (use_json) | |
10326 | json_hold = json_object_new_object(); | |
10327 | ||
05c7a1cc QY |
10328 | FOREACH_AFI_SAFI (afi, safi) |
10329 | if (p->afc[afi][safi]) | |
10330 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
10331 | json_hold); | |
d62a17ae | 10332 | |
10333 | if (use_json) { | |
10334 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
10335 | json_hold); | |
10336 | json_object_int_add(json_neigh, "connectionsEstablished", | |
10337 | p->established); | |
10338 | json_object_int_add(json_neigh, "connectionsDropped", | |
10339 | p->dropped); | |
10340 | } else | |
10341 | vty_out(vty, " Connections established %d; dropped %d\n", | |
10342 | p->established, p->dropped); | |
10343 | ||
10344 | if (!p->last_reset) { | |
10345 | if (use_json) | |
10346 | json_object_string_add(json_neigh, "lastReset", | |
10347 | "never"); | |
10348 | else | |
10349 | vty_out(vty, " Last reset never\n"); | |
10350 | } else { | |
10351 | if (use_json) { | |
10352 | time_t uptime; | |
10353 | struct tm *tm; | |
10354 | ||
10355 | uptime = bgp_clock(); | |
10356 | uptime -= p->resettime; | |
10357 | tm = gmtime(&uptime); | |
10358 | json_object_int_add(json_neigh, "lastResetTimerMsecs", | |
10359 | (tm->tm_sec * 1000) | |
10360 | + (tm->tm_min * 60000) | |
10361 | + (tm->tm_hour * 3600000)); | |
10362 | json_object_string_add( | |
10363 | json_neigh, "lastResetDueTo", | |
10364 | peer_down_str[(int)p->last_reset]); | |
10365 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND | |
10366 | || p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10367 | char errorcodesubcode_hexstr[5]; | |
10368 | char errorcodesubcode_str[256]; | |
10369 | ||
10370 | code_str = bgp_notify_code_str(p->notify.code); | |
10371 | subcode_str = bgp_notify_subcode_str( | |
10372 | p->notify.code, p->notify.subcode); | |
10373 | ||
10374 | sprintf(errorcodesubcode_hexstr, "%02X%02X", | |
10375 | p->notify.code, p->notify.subcode); | |
10376 | json_object_string_add(json_neigh, | |
10377 | "lastErrorCodeSubcode", | |
10378 | errorcodesubcode_hexstr); | |
10379 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
10380 | code_str, subcode_str); | |
10381 | json_object_string_add(json_neigh, | |
10382 | "lastNotificationReason", | |
10383 | errorcodesubcode_str); | |
10384 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
10385 | && p->notify.code == BGP_NOTIFY_CEASE | |
10386 | && (p->notify.subcode | |
10387 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
10388 | || p->notify.subcode | |
10389 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
10390 | && p->notify.length) { | |
10391 | char msgbuf[1024]; | |
10392 | const char *msg_str; | |
10393 | ||
10394 | msg_str = bgp_notify_admin_message( | |
10395 | msgbuf, sizeof(msgbuf), | |
d7c0a89a | 10396 | (uint8_t *)p->notify.data, |
d62a17ae | 10397 | p->notify.length); |
10398 | if (msg_str) | |
10399 | json_object_string_add( | |
10400 | json_neigh, | |
10401 | "lastShutdownDescription", | |
10402 | msg_str); | |
10403 | } | |
10404 | } | |
10405 | } else { | |
10406 | vty_out(vty, " Last reset %s, ", | |
10407 | peer_uptime(p->resettime, timebuf, | |
10408 | BGP_UPTIME_LEN, 0, NULL)); | |
10409 | ||
10410 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND | |
10411 | || p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10412 | code_str = bgp_notify_code_str(p->notify.code); | |
10413 | subcode_str = bgp_notify_subcode_str( | |
10414 | p->notify.code, p->notify.subcode); | |
10415 | vty_out(vty, "due to NOTIFICATION %s (%s%s)\n", | |
10416 | p->last_reset == PEER_DOWN_NOTIFY_SEND | |
10417 | ? "sent" | |
10418 | : "received", | |
10419 | code_str, subcode_str); | |
10420 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
10421 | && p->notify.code == BGP_NOTIFY_CEASE | |
10422 | && (p->notify.subcode | |
10423 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
10424 | || p->notify.subcode | |
10425 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
10426 | && p->notify.length) { | |
10427 | char msgbuf[1024]; | |
10428 | const char *msg_str; | |
10429 | ||
10430 | msg_str = bgp_notify_admin_message( | |
10431 | msgbuf, sizeof(msgbuf), | |
d7c0a89a | 10432 | (uint8_t *)p->notify.data, |
d62a17ae | 10433 | p->notify.length); |
10434 | if (msg_str) | |
10435 | vty_out(vty, | |
10436 | " Message: \"%s\"\n", | |
10437 | msg_str); | |
10438 | } | |
10439 | } else { | |
10440 | vty_out(vty, "due to %s\n", | |
10441 | peer_down_str[(int)p->last_reset]); | |
10442 | } | |
10443 | ||
10444 | if (p->last_reset_cause_size) { | |
10445 | msg = p->last_reset_cause; | |
10446 | vty_out(vty, | |
10447 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
10448 | for (i = 1; i <= p->last_reset_cause_size; | |
10449 | i++) { | |
10450 | vty_out(vty, "%02X", *msg++); | |
10451 | ||
10452 | if (i != p->last_reset_cause_size) { | |
10453 | if (i % 16 == 0) { | |
10454 | vty_out(vty, "\n "); | |
10455 | } else if (i % 4 == 0) { | |
10456 | vty_out(vty, " "); | |
10457 | } | |
10458 | } | |
10459 | } | |
10460 | vty_out(vty, "\n"); | |
10461 | } | |
10462 | } | |
10463 | } | |
10464 | ||
10465 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
10466 | if (use_json) | |
10467 | json_object_boolean_true_add(json_neigh, | |
10468 | "prefixesConfigExceedMax"); | |
10469 | else | |
10470 | vty_out(vty, | |
10471 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
10472 | ||
10473 | if (p->t_pmax_restart) { | |
10474 | if (use_json) { | |
10475 | json_object_boolean_true_add( | |
10476 | json_neigh, "reducePrefixNumFrom"); | |
10477 | json_object_int_add(json_neigh, | |
10478 | "restartInTimerMsec", | |
10479 | thread_timer_remain_second( | |
10480 | p->t_pmax_restart) | |
10481 | * 1000); | |
10482 | } else | |
10483 | vty_out(vty, | |
10484 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
10485 | p->host, thread_timer_remain_second( |
10486 | p->t_pmax_restart)); | |
d62a17ae | 10487 | } else { |
10488 | if (use_json) | |
10489 | json_object_boolean_true_add( | |
10490 | json_neigh, | |
10491 | "reducePrefixNumAndClearIpBgp"); | |
10492 | else | |
10493 | vty_out(vty, | |
10494 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
10495 | p->host); | |
10496 | } | |
10497 | } | |
10498 | ||
10499 | /* EBGP Multihop and GTSM */ | |
10500 | if (p->sort != BGP_PEER_IBGP) { | |
10501 | if (use_json) { | |
10502 | if (p->gtsm_hops > 0) | |
10503 | json_object_int_add(json_neigh, | |
10504 | "externalBgpNbrMaxHopsAway", | |
10505 | p->gtsm_hops); | |
10506 | else if (p->ttl > 1) | |
10507 | json_object_int_add(json_neigh, | |
10508 | "externalBgpNbrMaxHopsAway", | |
10509 | p->ttl); | |
10510 | } else { | |
10511 | if (p->gtsm_hops > 0) | |
10512 | vty_out(vty, | |
10513 | " External BGP neighbor may be up to %d hops away.\n", | |
10514 | p->gtsm_hops); | |
10515 | else if (p->ttl > 1) | |
10516 | vty_out(vty, | |
10517 | " External BGP neighbor may be up to %d hops away.\n", | |
10518 | p->ttl); | |
10519 | } | |
10520 | } else { | |
10521 | if (p->gtsm_hops > 0) { | |
10522 | if (use_json) | |
10523 | json_object_int_add(json_neigh, | |
10524 | "internalBgpNbrMaxHopsAway", | |
10525 | p->gtsm_hops); | |
10526 | else | |
10527 | vty_out(vty, | |
10528 | " Internal BGP neighbor may be up to %d hops away.\n", | |
10529 | p->gtsm_hops); | |
10530 | } | |
10531 | } | |
10532 | ||
10533 | /* Local address. */ | |
10534 | if (p->su_local) { | |
10535 | if (use_json) { | |
10536 | json_object_string_add(json_neigh, "hostLocal", | |
10537 | sockunion2str(p->su_local, buf1, | |
10538 | SU_ADDRSTRLEN)); | |
10539 | json_object_int_add(json_neigh, "portLocal", | |
10540 | ntohs(p->su_local->sin.sin_port)); | |
10541 | } else | |
10542 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
10543 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
10544 | ntohs(p->su_local->sin.sin_port)); | |
10545 | } | |
10546 | ||
10547 | /* Remote address. */ | |
10548 | if (p->su_remote) { | |
10549 | if (use_json) { | |
10550 | json_object_string_add(json_neigh, "hostForeign", | |
10551 | sockunion2str(p->su_remote, buf1, | |
10552 | SU_ADDRSTRLEN)); | |
10553 | json_object_int_add(json_neigh, "portForeign", | |
10554 | ntohs(p->su_remote->sin.sin_port)); | |
10555 | } else | |
10556 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
10557 | sockunion2str(p->su_remote, buf1, | |
10558 | SU_ADDRSTRLEN), | |
10559 | ntohs(p->su_remote->sin.sin_port)); | |
10560 | } | |
10561 | ||
10562 | /* Nexthop display. */ | |
10563 | if (p->su_local) { | |
10564 | if (use_json) { | |
10565 | json_object_string_add(json_neigh, "nexthop", | |
10566 | inet_ntop(AF_INET, | |
10567 | &p->nexthop.v4, buf1, | |
10568 | sizeof(buf1))); | |
10569 | json_object_string_add(json_neigh, "nexthopGlobal", | |
10570 | inet_ntop(AF_INET6, | |
10571 | &p->nexthop.v6_global, | |
10572 | buf1, sizeof(buf1))); | |
10573 | json_object_string_add(json_neigh, "nexthopLocal", | |
10574 | inet_ntop(AF_INET6, | |
10575 | &p->nexthop.v6_local, | |
10576 | buf1, sizeof(buf1))); | |
10577 | if (p->shared_network) | |
10578 | json_object_string_add(json_neigh, | |
10579 | "bgpConnection", | |
10580 | "sharedNetwork"); | |
10581 | else | |
10582 | json_object_string_add(json_neigh, | |
10583 | "bgpConnection", | |
10584 | "nonSharedNetwork"); | |
10585 | } else { | |
10586 | vty_out(vty, "Nexthop: %s\n", | |
10587 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
10588 | sizeof(buf1))); | |
10589 | vty_out(vty, "Nexthop global: %s\n", | |
10590 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
10591 | sizeof(buf1))); | |
10592 | vty_out(vty, "Nexthop local: %s\n", | |
10593 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
10594 | sizeof(buf1))); | |
10595 | vty_out(vty, "BGP connection: %s\n", | |
10596 | p->shared_network ? "shared network" | |
10597 | : "non shared network"); | |
10598 | } | |
10599 | } | |
10600 | ||
10601 | /* Timer information. */ | |
10602 | if (use_json) { | |
10603 | json_object_int_add(json_neigh, "connectRetryTimer", | |
10604 | p->v_connect); | |
10605 | if (p->status == Established && p->rtt) | |
10606 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
10607 | p->rtt); | |
10608 | if (p->t_start) | |
10609 | json_object_int_add( | |
10610 | json_neigh, "nextStartTimerDueInMsecs", | |
10611 | thread_timer_remain_second(p->t_start) * 1000); | |
10612 | if (p->t_connect) | |
10613 | json_object_int_add( | |
10614 | json_neigh, "nextConnectTimerDueInMsecs", | |
10615 | thread_timer_remain_second(p->t_connect) | |
10616 | * 1000); | |
10617 | if (p->t_routeadv) { | |
10618 | json_object_int_add(json_neigh, "mraiInterval", | |
10619 | p->v_routeadv); | |
10620 | json_object_int_add( | |
10621 | json_neigh, "mraiTimerExpireInMsecs", | |
10622 | thread_timer_remain_second(p->t_routeadv) | |
10623 | * 1000); | |
10624 | } | |
10625 | if (p->password) | |
10626 | json_object_int_add(json_neigh, "authenticationEnabled", | |
10627 | 1); | |
10628 | ||
10629 | if (p->t_read) | |
10630 | json_object_string_add(json_neigh, "readThread", "on"); | |
10631 | else | |
10632 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
10633 | |
10634 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 10635 | json_object_string_add(json_neigh, "writeThread", "on"); |
10636 | else | |
10637 | json_object_string_add(json_neigh, "writeThread", | |
10638 | "off"); | |
10639 | } else { | |
10640 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
10641 | p->v_connect); | |
10642 | if (p->status == Established && p->rtt) | |
10643 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
10644 | p->rtt); | |
10645 | if (p->t_start) | |
10646 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
10647 | thread_timer_remain_second(p->t_start)); | |
10648 | if (p->t_connect) | |
10649 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
10650 | thread_timer_remain_second(p->t_connect)); | |
10651 | if (p->t_routeadv) | |
10652 | vty_out(vty, | |
10653 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
10654 | p->v_routeadv, | |
10655 | thread_timer_remain_second(p->t_routeadv)); | |
10656 | if (p->password) | |
10657 | vty_out(vty, "Peer Authentication Enabled\n"); | |
10658 | ||
10659 | vty_out(vty, "Read thread: %s Write thread: %s\n", | |
49507a6f QY |
10660 | p->t_read ? "on" : "off", |
10661 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
10662 | ? "on" | |
10663 | : "off"); | |
d62a17ae | 10664 | } |
10665 | ||
10666 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
10667 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
10668 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
10669 | ||
10670 | if (!use_json) | |
10671 | vty_out(vty, "\n"); | |
10672 | ||
10673 | /* BFD information. */ | |
10674 | bgp_bfd_show_info(vty, p, use_json, json_neigh); | |
10675 | ||
10676 | if (use_json) { | |
10677 | if (p->conf_if) /* Configured interface name. */ | |
10678 | json_object_object_add(json, p->conf_if, json_neigh); | |
10679 | else /* Configured IP address. */ | |
10680 | json_object_object_add(json, p->host, json_neigh); | |
10681 | } | |
10682 | } | |
10683 | ||
10684 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, | |
10685 | enum show_type type, union sockunion *su, | |
d7c0a89a | 10686 | const char *conf_if, uint8_t use_json, |
d62a17ae | 10687 | json_object *json) |
10688 | { | |
10689 | struct listnode *node, *nnode; | |
10690 | struct peer *peer; | |
10691 | int find = 0; | |
10692 | ||
10693 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
10694 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
10695 | continue; | |
10696 | ||
10697 | switch (type) { | |
10698 | case show_all: | |
10699 | bgp_show_peer(vty, peer, use_json, json); | |
10700 | break; | |
10701 | case show_peer: | |
10702 | if (conf_if) { | |
10703 | if ((peer->conf_if | |
10704 | && !strcmp(peer->conf_if, conf_if)) | |
10705 | || (peer->hostname | |
10706 | && !strcmp(peer->hostname, conf_if))) { | |
10707 | find = 1; | |
10708 | bgp_show_peer(vty, peer, use_json, | |
10709 | json); | |
10710 | } | |
10711 | } else { | |
10712 | if (sockunion_same(&peer->su, su)) { | |
10713 | find = 1; | |
10714 | bgp_show_peer(vty, peer, use_json, | |
10715 | json); | |
10716 | } | |
10717 | } | |
10718 | break; | |
10719 | } | |
10720 | } | |
10721 | ||
10722 | if (type == show_peer && !find) { | |
10723 | if (use_json) | |
10724 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
10725 | else | |
88b7d255 | 10726 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 10727 | } |
10728 | ||
10729 | if (use_json) { | |
996c9314 LB |
10730 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
10731 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 10732 | json_object_free(json); |
10733 | } else { | |
10734 | vty_out(vty, "\n"); | |
10735 | } | |
10736 | ||
10737 | return CMD_SUCCESS; | |
10738 | } | |
10739 | ||
10740 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, | |
71aedaa3 DS |
10741 | enum show_type type, |
10742 | const char *ip_str, | |
d7c0a89a | 10743 | uint8_t use_json) |
d62a17ae | 10744 | { |
0291c246 MK |
10745 | struct listnode *node, *nnode; |
10746 | struct bgp *bgp; | |
71aedaa3 | 10747 | union sockunion su; |
0291c246 | 10748 | json_object *json = NULL; |
71aedaa3 | 10749 | int ret, is_first = 1; |
d62a17ae | 10750 | |
10751 | if (use_json) | |
10752 | vty_out(vty, "{\n"); | |
10753 | ||
10754 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
10755 | if (use_json) { | |
10756 | if (!(json = json_object_new_object())) { | |
10757 | zlog_err( | |
10758 | "Unable to allocate memory for JSON object"); | |
10759 | vty_out(vty, | |
10760 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
10761 | return; | |
10762 | } | |
10763 | ||
10764 | json_object_int_add(json, "vrfId", | |
10765 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
10766 | ? -1 |
10767 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 10768 | json_object_string_add( |
10769 | json, "vrfName", | |
10770 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
10771 | ? "Default" | |
10772 | : bgp->name); | |
10773 | ||
10774 | if (!is_first) | |
10775 | vty_out(vty, ",\n"); | |
10776 | else | |
10777 | is_first = 0; | |
10778 | ||
10779 | vty_out(vty, "\"%s\":", | |
10780 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
10781 | ? "Default" | |
10782 | : bgp->name); | |
10783 | } else { | |
10784 | vty_out(vty, "\nInstance %s:\n", | |
10785 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
10786 | ? "Default" | |
10787 | : bgp->name); | |
10788 | } | |
71aedaa3 DS |
10789 | |
10790 | if (type == show_peer) { | |
10791 | ret = str2sockunion(ip_str, &su); | |
10792 | if (ret < 0) | |
10793 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
10794 | use_json, json); | |
10795 | else | |
10796 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
10797 | use_json, json); | |
10798 | } else { | |
10799 | bgp_show_neighbor(vty, bgp, show_all, NULL, NULL, | |
10800 | use_json, json); | |
10801 | } | |
d62a17ae | 10802 | } |
10803 | ||
10804 | if (use_json) | |
10805 | vty_out(vty, "}\n"); | |
10806 | } | |
10807 | ||
10808 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
10809 | enum show_type type, const char *ip_str, | |
d7c0a89a | 10810 | uint8_t use_json) |
d62a17ae | 10811 | { |
10812 | int ret; | |
10813 | struct bgp *bgp; | |
10814 | union sockunion su; | |
10815 | json_object *json = NULL; | |
10816 | ||
10817 | if (name) { | |
10818 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
10819 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
10820 | use_json); | |
d62a17ae | 10821 | return CMD_SUCCESS; |
10822 | } else { | |
10823 | bgp = bgp_lookup_by_name(name); | |
10824 | if (!bgp) { | |
10825 | if (use_json) { | |
10826 | json = json_object_new_object(); | |
10827 | json_object_boolean_true_add( | |
10828 | json, "bgpNoSuchInstance"); | |
10829 | vty_out(vty, "%s\n", | |
10830 | json_object_to_json_string_ext( | |
10831 | json, | |
10832 | JSON_C_TO_STRING_PRETTY)); | |
10833 | json_object_free(json); | |
10834 | } else | |
10835 | vty_out(vty, | |
10836 | "%% No such BGP instance exist\n"); | |
10837 | ||
10838 | return CMD_WARNING; | |
10839 | } | |
10840 | } | |
10841 | } else { | |
10842 | bgp = bgp_get_default(); | |
10843 | } | |
10844 | ||
10845 | if (bgp) { | |
10846 | json = json_object_new_object(); | |
10847 | if (ip_str) { | |
10848 | ret = str2sockunion(ip_str, &su); | |
10849 | if (ret < 0) | |
10850 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
10851 | use_json, json); | |
10852 | else | |
10853 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
10854 | use_json, json); | |
10855 | } else { | |
10856 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
10857 | json); | |
10858 | } | |
10859 | json_object_free(json); | |
10860 | } | |
10861 | ||
10862 | return CMD_SUCCESS; | |
4fb25c53 DW |
10863 | } |
10864 | ||
716b2d8a | 10865 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 10866 | DEFUN (show_ip_bgp_neighbors, |
10867 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 10868 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 10869 | SHOW_STR |
10870 | IP_STR | |
10871 | BGP_STR | |
f2a8972b | 10872 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
10873 | "Address Family\n" |
10874 | "Address Family\n" | |
718e3744 | 10875 | "Detailed information on TCP and BGP neighbor connections\n" |
10876 | "Neighbor to display information about\n" | |
a80beece | 10877 | "Neighbor to display information about\n" |
91d37724 | 10878 | "Neighbor on BGP configured interface\n" |
9973d184 | 10879 | JSON_STR) |
718e3744 | 10880 | { |
d62a17ae | 10881 | char *vrf = NULL; |
10882 | char *sh_arg = NULL; | |
10883 | enum show_type sh_type; | |
718e3744 | 10884 | |
d7c0a89a | 10885 | uint8_t uj = use_json(argc, argv); |
718e3744 | 10886 | |
d62a17ae | 10887 | int idx = 0; |
718e3744 | 10888 | |
d62a17ae | 10889 | if (argv_find(argv, argc, "view", &idx) |
10890 | || argv_find(argv, argc, "vrf", &idx)) | |
10891 | vrf = argv[idx + 1]->arg; | |
718e3744 | 10892 | |
d62a17ae | 10893 | idx++; |
10894 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
10895 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
10896 | || argv_find(argv, argc, "WORD", &idx)) { | |
10897 | sh_type = show_peer; | |
10898 | sh_arg = argv[idx]->arg; | |
10899 | } else | |
10900 | sh_type = show_all; | |
856ca177 | 10901 | |
d62a17ae | 10902 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 10903 | } |
10904 | ||
716b2d8a | 10905 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 10906 | paths' and `show ip mbgp paths'. Those functions results are the |
10907 | same.*/ | |
f412b39a | 10908 | DEFUN (show_ip_bgp_paths, |
718e3744 | 10909 | show_ip_bgp_paths_cmd, |
46f296b4 | 10910 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 10911 | SHOW_STR |
10912 | IP_STR | |
10913 | BGP_STR | |
46f296b4 | 10914 | BGP_SAFI_HELP_STR |
718e3744 | 10915 | "Path information\n") |
10916 | { | |
d62a17ae | 10917 | vty_out(vty, "Address Refcnt Path\n"); |
10918 | aspath_print_all_vty(vty); | |
10919 | return CMD_SUCCESS; | |
718e3744 | 10920 | } |
10921 | ||
718e3744 | 10922 | #include "hash.h" |
10923 | ||
d62a17ae | 10924 | static void community_show_all_iterator(struct hash_backet *backet, |
10925 | struct vty *vty) | |
718e3744 | 10926 | { |
d62a17ae | 10927 | struct community *com; |
718e3744 | 10928 | |
d62a17ae | 10929 | com = (struct community *)backet->data; |
3f65c5b1 | 10930 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 10931 | community_str(com, false)); |
718e3744 | 10932 | } |
10933 | ||
10934 | /* Show BGP's community internal data. */ | |
f412b39a | 10935 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 10936 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 10937 | "show [ip] bgp community-info", |
718e3744 | 10938 | SHOW_STR |
10939 | IP_STR | |
10940 | BGP_STR | |
10941 | "List all bgp community information\n") | |
10942 | { | |
d62a17ae | 10943 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 10944 | |
d62a17ae | 10945 | hash_iterate(community_hash(), |
10946 | (void (*)(struct hash_backet *, | |
10947 | void *))community_show_all_iterator, | |
10948 | vty); | |
718e3744 | 10949 | |
d62a17ae | 10950 | return CMD_SUCCESS; |
718e3744 | 10951 | } |
10952 | ||
d62a17ae | 10953 | static void lcommunity_show_all_iterator(struct hash_backet *backet, |
10954 | struct vty *vty) | |
57d187bc | 10955 | { |
d62a17ae | 10956 | struct lcommunity *lcom; |
57d187bc | 10957 | |
d62a17ae | 10958 | lcom = (struct lcommunity *)backet->data; |
3f65c5b1 | 10959 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
8d9b8ed9 | 10960 | lcommunity_str(lcom, false)); |
57d187bc JS |
10961 | } |
10962 | ||
10963 | /* Show BGP's community internal data. */ | |
10964 | DEFUN (show_ip_bgp_lcommunity_info, | |
10965 | show_ip_bgp_lcommunity_info_cmd, | |
10966 | "show ip bgp large-community-info", | |
10967 | SHOW_STR | |
10968 | IP_STR | |
10969 | BGP_STR | |
10970 | "List all bgp large-community information\n") | |
10971 | { | |
d62a17ae | 10972 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 10973 | |
d62a17ae | 10974 | hash_iterate(lcommunity_hash(), |
10975 | (void (*)(struct hash_backet *, | |
10976 | void *))lcommunity_show_all_iterator, | |
10977 | vty); | |
57d187bc | 10978 | |
d62a17ae | 10979 | return CMD_SUCCESS; |
57d187bc JS |
10980 | } |
10981 | ||
10982 | ||
f412b39a | 10983 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 10984 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 10985 | "show [ip] bgp attribute-info", |
718e3744 | 10986 | SHOW_STR |
10987 | IP_STR | |
10988 | BGP_STR | |
10989 | "List all bgp attribute information\n") | |
10990 | { | |
d62a17ae | 10991 | attr_show_all(vty); |
10992 | return CMD_SUCCESS; | |
718e3744 | 10993 | } |
6b0655a2 | 10994 | |
53089bec | 10995 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
10996 | afi_t afi, safi_t safi) | |
10997 | { | |
10998 | struct bgp *bgp; | |
10999 | struct listnode *node; | |
11000 | char *vname; | |
11001 | char buf1[INET6_ADDRSTRLEN]; | |
11002 | char *ecom_str; | |
11003 | vpn_policy_direction_t dir; | |
11004 | ||
11005 | if (name) { | |
11006 | bgp = bgp_lookup_by_name(name); | |
11007 | if (!bgp) { | |
11008 | vty_out(vty, "%% No such BGP instance exist\n"); | |
11009 | return CMD_WARNING; | |
11010 | } | |
11011 | } else { | |
11012 | bgp = bgp_get_default(); | |
11013 | if (!bgp) { | |
020a3f60 DS |
11014 | vty_out(vty, |
11015 | "%% Default BGP instance does not exist\n"); | |
53089bec | 11016 | return CMD_WARNING; |
11017 | } | |
11018 | } | |
11019 | ||
11020 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
11021 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
020a3f60 DS |
11022 | vty_out(vty, |
11023 | "This VRF is not importing %s routes from any other VRF\n", | |
53089bec | 11024 | afi_safi_print(afi, safi)); |
11025 | } else { | |
020a3f60 DS |
11026 | vty_out(vty, |
11027 | "This VRF is importing %s routes from the following VRFs:\n", | |
53089bec | 11028 | afi_safi_print(afi, safi)); |
11029 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, | |
11030 | vname)) { | |
11031 | vty_out(vty, " %s\n", vname); | |
11032 | } | |
11033 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
11034 | ecom_str = ecommunity_ecom2str( | |
11035 | bgp->vpn_policy[afi].rtlist[dir], | |
11036 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
11037 | vty_out(vty, "Import RT(s): %s\n", ecom_str); | |
11038 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
11039 | } | |
11040 | ||
11041 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
11042 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
020a3f60 DS |
11043 | vty_out(vty, |
11044 | "This VRF is not exporting %s routes to any other VRF\n", | |
53089bec | 11045 | afi_safi_print(afi, safi)); |
11046 | } else { | |
020a3f60 DS |
11047 | vty_out(vty, |
11048 | "This VRF is exporting %s routes to the following VRFs:\n", | |
53089bec | 11049 | afi_safi_print(afi, safi)); |
11050 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].export_vrf, node, | |
11051 | vname)) { | |
11052 | vty_out(vty, " %s\n", vname); | |
11053 | } | |
11054 | vty_out(vty, "RD: %s\n", | |
11055 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
11056 | buf1, RD_ADDRSTRLEN)); | |
11057 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
11058 | ecom_str = ecommunity_ecom2str( | |
11059 | bgp->vpn_policy[afi].rtlist[dir], | |
11060 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
11061 | vty_out(vty, "Emport RT: %s\n", ecom_str); | |
11062 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
11063 | } | |
11064 | ||
11065 | return CMD_SUCCESS; | |
11066 | } | |
11067 | ||
11068 | /* "show [ip] bgp route-leak" command. */ | |
11069 | DEFUN (show_ip_bgp_route_leak, | |
11070 | show_ip_bgp_route_leak_cmd, | |
11071 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak", | |
11072 | SHOW_STR | |
11073 | IP_STR | |
11074 | BGP_STR | |
11075 | BGP_INSTANCE_HELP_STR | |
11076 | BGP_AFI_HELP_STR | |
11077 | BGP_SAFI_HELP_STR | |
11078 | "Route leaking information\n") | |
11079 | { | |
11080 | char *vrf = NULL; | |
11081 | afi_t afi = AFI_MAX; | |
11082 | safi_t safi = SAFI_MAX; | |
11083 | ||
11084 | int idx = 0; | |
11085 | ||
11086 | /* show [ip] bgp */ | |
11087 | if (argv_find(argv, argc, "ip", &idx)) { | |
11088 | afi = AFI_IP; | |
11089 | safi = SAFI_UNICAST; | |
11090 | } | |
11091 | /* [vrf VIEWVRFNAME] */ | |
11092 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
11093 | vty_out(vty, |
11094 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 11095 | return CMD_WARNING; |
11096 | } | |
11097 | ||
11098 | if (argv_find(argv, argc, "vrf", &idx)) | |
11099 | vrf = argv[++idx]->arg; | |
11100 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
11101 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11102 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11103 | } | |
11104 | ||
11105 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
11106 | vty_out(vty, |
11107 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 11108 | return CMD_WARNING; |
11109 | } | |
11110 | ||
11111 | return bgp_show_route_leak_vty(vty, vrf, afi, safi); | |
11112 | } | |
11113 | ||
d62a17ae | 11114 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
11115 | safi_t safi) | |
f186de26 | 11116 | { |
d62a17ae | 11117 | struct listnode *node, *nnode; |
11118 | struct bgp *bgp; | |
f186de26 | 11119 | |
d62a17ae | 11120 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
11121 | vty_out(vty, "\nInstance %s:\n", | |
11122 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
11123 | ? "Default" | |
11124 | : bgp->name); | |
11125 | update_group_show(bgp, afi, safi, vty, 0); | |
11126 | } | |
f186de26 | 11127 | } |
11128 | ||
d62a17ae | 11129 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
11130 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 11131 | { |
d62a17ae | 11132 | struct bgp *bgp; |
4fb25c53 | 11133 | |
d62a17ae | 11134 | if (name) { |
11135 | if (strmatch(name, "all")) { | |
11136 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
11137 | return CMD_SUCCESS; | |
11138 | } else { | |
11139 | bgp = bgp_lookup_by_name(name); | |
11140 | } | |
11141 | } else { | |
11142 | bgp = bgp_get_default(); | |
11143 | } | |
4fb25c53 | 11144 | |
d62a17ae | 11145 | if (bgp) |
11146 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
11147 | return CMD_SUCCESS; | |
4fb25c53 DW |
11148 | } |
11149 | ||
8fe8a7f6 DS |
11150 | DEFUN (show_ip_bgp_updgrps, |
11151 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 11152 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 11153 | SHOW_STR |
11154 | IP_STR | |
11155 | BGP_STR | |
11156 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 11157 | BGP_AFI_HELP_STR |
9bedbb1e | 11158 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
11159 | "Detailed info about dynamic update groups\n" |
11160 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 11161 | { |
d62a17ae | 11162 | char *vrf = NULL; |
11163 | afi_t afi = AFI_IP6; | |
11164 | safi_t safi = SAFI_UNICAST; | |
11165 | uint64_t subgrp_id = 0; | |
11166 | ||
11167 | int idx = 0; | |
11168 | ||
11169 | /* show [ip] bgp */ | |
11170 | if (argv_find(argv, argc, "ip", &idx)) | |
11171 | afi = AFI_IP; | |
11172 | /* [<view|vrf> VIEWVRFNAME] */ | |
11173 | if (argv_find(argv, argc, "view", &idx) | |
11174 | || argv_find(argv, argc, "vrf", &idx)) | |
11175 | vrf = argv[++idx]->arg; | |
11176 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
11177 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11178 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11179 | } | |
5bf15956 | 11180 | |
d62a17ae | 11181 | /* get subgroup id, if provided */ |
11182 | idx = argc - 1; | |
11183 | if (argv[idx]->type == VARIABLE_TKN) | |
11184 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 11185 | |
d62a17ae | 11186 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
11187 | } |
11188 | ||
f186de26 | 11189 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
11190 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 11191 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 11192 | SHOW_STR |
716b2d8a | 11193 | IP_STR |
f186de26 | 11194 | BGP_STR |
11195 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 11196 | "Detailed info about dynamic update groups\n") |
f186de26 | 11197 | { |
d62a17ae | 11198 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
11199 | return CMD_SUCCESS; | |
f186de26 | 11200 | } |
11201 | ||
5bf15956 DW |
11202 | DEFUN (show_bgp_updgrps_stats, |
11203 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 11204 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 11205 | SHOW_STR |
716b2d8a | 11206 | IP_STR |
3f9c7369 | 11207 | BGP_STR |
0c7b1b01 | 11208 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
11209 | "Statistics\n") |
11210 | { | |
d62a17ae | 11211 | struct bgp *bgp; |
3f9c7369 | 11212 | |
d62a17ae | 11213 | bgp = bgp_get_default(); |
11214 | if (bgp) | |
11215 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 11216 | |
d62a17ae | 11217 | return CMD_SUCCESS; |
3f9c7369 DS |
11218 | } |
11219 | ||
8386ac43 | 11220 | DEFUN (show_bgp_instance_updgrps_stats, |
11221 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 11222 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 11223 | SHOW_STR |
716b2d8a | 11224 | IP_STR |
8386ac43 | 11225 | BGP_STR |
11226 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 11227 | "Detailed info about dynamic update groups\n" |
8386ac43 | 11228 | "Statistics\n") |
11229 | { | |
d62a17ae | 11230 | int idx_word = 3; |
11231 | struct bgp *bgp; | |
8386ac43 | 11232 | |
d62a17ae | 11233 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
11234 | if (bgp) | |
11235 | update_group_show_stats(bgp, vty); | |
8386ac43 | 11236 | |
d62a17ae | 11237 | return CMD_SUCCESS; |
8386ac43 | 11238 | } |
11239 | ||
d62a17ae | 11240 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
11241 | afi_t afi, safi_t safi, | |
11242 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 11243 | { |
d62a17ae | 11244 | struct bgp *bgp; |
8386ac43 | 11245 | |
d62a17ae | 11246 | if (name) |
11247 | bgp = bgp_lookup_by_name(name); | |
11248 | else | |
11249 | bgp = bgp_get_default(); | |
8386ac43 | 11250 | |
d62a17ae | 11251 | if (bgp) { |
11252 | if (!strcmp(what, "advertise-queue")) | |
11253 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
11254 | subgrp_id); | |
11255 | else if (!strcmp(what, "advertised-routes")) | |
11256 | update_group_show_advertised(bgp, afi, safi, vty, | |
11257 | subgrp_id); | |
11258 | else if (!strcmp(what, "packet-queue")) | |
11259 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
11260 | subgrp_id); | |
11261 | } | |
3f9c7369 DS |
11262 | } |
11263 | ||
dc64bdec QY |
11264 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
11265 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
11266 | "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", | |
11267 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
11268 | BGP_SAFI_HELP_STR | |
11269 | "Detailed info about dynamic update groups\n" | |
11270 | "Specific subgroup to display info for\n" | |
11271 | "Advertisement queue\n" | |
11272 | "Announced routes\n" | |
11273 | "Packet queue\n") | |
3f9c7369 | 11274 | { |
dc64bdec QY |
11275 | uint64_t subgrp_id = 0; |
11276 | afi_t afiz; | |
11277 | safi_t safiz; | |
11278 | if (sgid) | |
11279 | subgrp_id = strtoull(sgid, NULL, 10); | |
11280 | ||
11281 | if (!ip && !afi) | |
11282 | afiz = AFI_IP6; | |
11283 | if (!ip && afi) | |
11284 | afiz = bgp_vty_afi_from_str(afi); | |
11285 | if (ip && !afi) | |
11286 | afiz = AFI_IP; | |
11287 | if (ip && afi) { | |
11288 | afiz = bgp_vty_afi_from_str(afi); | |
11289 | if (afiz != AFI_IP) | |
11290 | vty_out(vty, | |
11291 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
11292 | return CMD_WARNING; | |
11293 | } | |
d62a17ae | 11294 | |
dc64bdec | 11295 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 11296 | |
dc64bdec | 11297 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 11298 | return CMD_SUCCESS; |
11299 | } | |
11300 | ||
d62a17ae | 11301 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group) |
11302 | { | |
11303 | struct listnode *node, *nnode; | |
11304 | struct prefix *range; | |
11305 | struct peer *conf; | |
11306 | struct peer *peer; | |
11307 | char buf[PREFIX2STR_BUFFER]; | |
11308 | afi_t afi; | |
11309 | safi_t safi; | |
11310 | const char *peer_status; | |
11311 | const char *af_str; | |
11312 | int lr_count; | |
11313 | int dynamic; | |
11314 | int af_cfgd; | |
11315 | ||
11316 | conf = group->conf; | |
11317 | ||
11318 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
11319 | vty_out(vty, "\nBGP peer-group %s, remote AS %d\n", group->name, | |
11320 | conf->as); | |
11321 | } else if (conf->as_type == AS_INTERNAL) { | |
11322 | vty_out(vty, "\nBGP peer-group %s, remote AS %d\n", group->name, | |
11323 | group->bgp->as); | |
11324 | } else { | |
11325 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
11326 | } | |
f14e6fdb | 11327 | |
d62a17ae | 11328 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
11329 | vty_out(vty, " Peer-group type is internal\n"); | |
11330 | else | |
11331 | vty_out(vty, " Peer-group type is external\n"); | |
11332 | ||
11333 | /* Display AFs configured. */ | |
11334 | vty_out(vty, " Configured address-families:"); | |
05c7a1cc QY |
11335 | FOREACH_AFI_SAFI (afi, safi) { |
11336 | if (conf->afc[afi][safi]) { | |
11337 | af_cfgd = 1; | |
11338 | vty_out(vty, " %s;", afi_safi_print(afi, safi)); | |
d62a17ae | 11339 | } |
05c7a1cc | 11340 | } |
d62a17ae | 11341 | if (!af_cfgd) |
11342 | vty_out(vty, " none\n"); | |
11343 | else | |
11344 | vty_out(vty, "\n"); | |
11345 | ||
11346 | /* Display listen ranges (for dynamic neighbors), if any */ | |
11347 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
11348 | if (afi == AFI_IP) | |
11349 | af_str = "IPv4"; | |
11350 | else if (afi == AFI_IP6) | |
11351 | af_str = "IPv6"; | |
11352 | else | |
11353 | af_str = "???"; | |
11354 | lr_count = listcount(group->listen_range[afi]); | |
11355 | if (lr_count) { | |
11356 | vty_out(vty, " %d %s listen range(s)\n", lr_count, | |
11357 | af_str); | |
11358 | ||
11359 | ||
11360 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
11361 | nnode, range)) { | |
11362 | prefix2str(range, buf, sizeof(buf)); | |
11363 | vty_out(vty, " %s\n", buf); | |
11364 | } | |
11365 | } | |
11366 | } | |
f14e6fdb | 11367 | |
d62a17ae | 11368 | /* Display group members and their status */ |
11369 | if (listcount(group->peer)) { | |
11370 | vty_out(vty, " Peer-group members:\n"); | |
11371 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
11372 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
11373 | peer_status = "Idle (Admin)"; | |
11374 | else if (CHECK_FLAG(peer->sflags, | |
11375 | PEER_STATUS_PREFIX_OVERFLOW)) | |
11376 | peer_status = "Idle (PfxCt)"; | |
11377 | else | |
11378 | peer_status = lookup_msg(bgp_status_msg, | |
11379 | peer->status, NULL); | |
11380 | ||
11381 | dynamic = peer_dynamic_neighbor(peer); | |
11382 | vty_out(vty, " %s %s %s \n", peer->host, | |
11383 | dynamic ? "(dynamic)" : "", peer_status); | |
11384 | } | |
11385 | } | |
f14e6fdb | 11386 | |
d62a17ae | 11387 | return CMD_SUCCESS; |
11388 | } | |
11389 | ||
ff9959b0 QY |
11390 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
11391 | const char *group_name) | |
d62a17ae | 11392 | { |
ff9959b0 | 11393 | struct bgp *bgp; |
d62a17ae | 11394 | struct listnode *node, *nnode; |
11395 | struct peer_group *group; | |
ff9959b0 QY |
11396 | bool found = false; |
11397 | ||
11398 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
11399 | ||
11400 | if (!bgp) { | |
11401 | vty_out(vty, "%% No such BGP instance exists\n"); | |
11402 | return CMD_WARNING; | |
11403 | } | |
d62a17ae | 11404 | |
11405 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
11406 | if (group_name) { |
11407 | if (strmatch(group->name, group_name)) { | |
d62a17ae | 11408 | bgp_show_one_peer_group(vty, group); |
ff9959b0 QY |
11409 | found = true; |
11410 | break; | |
d62a17ae | 11411 | } |
ff9959b0 QY |
11412 | } else { |
11413 | bgp_show_one_peer_group(vty, group); | |
d62a17ae | 11414 | } |
f14e6fdb | 11415 | } |
f14e6fdb | 11416 | |
ff9959b0 | 11417 | if (group_name && !found) |
d62a17ae | 11418 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 11419 | |
d62a17ae | 11420 | return CMD_SUCCESS; |
f14e6fdb DS |
11421 | } |
11422 | ||
f14e6fdb DS |
11423 | DEFUN (show_ip_bgp_peer_groups, |
11424 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 11425 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
11426 | SHOW_STR |
11427 | IP_STR | |
11428 | BGP_STR | |
8386ac43 | 11429 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
11430 | "Detailed information on BGP peer groups\n" |
11431 | "Peer group name\n") | |
f14e6fdb | 11432 | { |
d62a17ae | 11433 | char *vrf, *pg; |
d62a17ae | 11434 | int idx = 0; |
f14e6fdb | 11435 | |
a4d82a8a PZ |
11436 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
11437 | : NULL; | |
d62a17ae | 11438 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 11439 | |
ff9959b0 | 11440 | return bgp_show_peer_group_vty(vty, vrf, pg); |
f14e6fdb | 11441 | } |
3f9c7369 | 11442 | |
d6e3c605 | 11443 | |
718e3744 | 11444 | /* Redistribute VTY commands. */ |
11445 | ||
718e3744 | 11446 | DEFUN (bgp_redistribute_ipv4, |
11447 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 11448 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 11449 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11450 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 11451 | { |
d62a17ae | 11452 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11453 | int idx_protocol = 1; | |
11454 | int type; | |
718e3744 | 11455 | |
d62a17ae | 11456 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
11457 | if (type < 0) { | |
11458 | vty_out(vty, "%% Invalid route type\n"); | |
11459 | return CMD_WARNING_CONFIG_FAILED; | |
11460 | } | |
7f323236 | 11461 | |
d62a17ae | 11462 | bgp_redist_add(bgp, AFI_IP, type, 0); |
11463 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
718e3744 | 11464 | } |
11465 | ||
d62a17ae | 11466 | ALIAS_HIDDEN( |
11467 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
11468 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
11469 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 11470 | |
718e3744 | 11471 | DEFUN (bgp_redistribute_ipv4_rmap, |
11472 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 11473 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 11474 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11475 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 11476 | "Route map reference\n" |
11477 | "Pointer to route-map entries\n") | |
11478 | { | |
d62a17ae | 11479 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11480 | int idx_protocol = 1; | |
11481 | int idx_word = 3; | |
11482 | int type; | |
11483 | struct bgp_redist *red; | |
718e3744 | 11484 | |
d62a17ae | 11485 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
11486 | if (type < 0) { | |
11487 | vty_out(vty, "%% Invalid route type\n"); | |
11488 | return CMD_WARNING_CONFIG_FAILED; | |
11489 | } | |
718e3744 | 11490 | |
d62a17ae | 11491 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
11492 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11493 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
718e3744 | 11494 | } |
11495 | ||
d62a17ae | 11496 | ALIAS_HIDDEN( |
11497 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
11498 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
11499 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
11500 | "Route map reference\n" | |
11501 | "Pointer to route-map entries\n") | |
596c17ba | 11502 | |
718e3744 | 11503 | DEFUN (bgp_redistribute_ipv4_metric, |
11504 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 11505 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 11506 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11507 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 11508 | "Metric for redistributed routes\n" |
11509 | "Default metric\n") | |
11510 | { | |
d62a17ae | 11511 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11512 | int idx_protocol = 1; | |
11513 | int idx_number = 3; | |
11514 | int type; | |
d7c0a89a | 11515 | uint32_t metric; |
d62a17ae | 11516 | struct bgp_redist *red; |
11517 | ||
11518 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
11519 | if (type < 0) { | |
11520 | vty_out(vty, "%% Invalid route type\n"); | |
11521 | return CMD_WARNING_CONFIG_FAILED; | |
11522 | } | |
11523 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
11524 | ||
11525 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
11526 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
11527 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
11528 | } | |
11529 | ||
11530 | ALIAS_HIDDEN( | |
11531 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
11532 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
11533 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
11534 | "Metric for redistributed routes\n" | |
11535 | "Default metric\n") | |
596c17ba | 11536 | |
718e3744 | 11537 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
11538 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 11539 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 11540 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11541 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 11542 | "Route map reference\n" |
11543 | "Pointer to route-map entries\n" | |
11544 | "Metric for redistributed routes\n" | |
11545 | "Default metric\n") | |
11546 | { | |
d62a17ae | 11547 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11548 | int idx_protocol = 1; | |
11549 | int idx_word = 3; | |
11550 | int idx_number = 5; | |
11551 | int type; | |
d7c0a89a | 11552 | uint32_t metric; |
d62a17ae | 11553 | struct bgp_redist *red; |
11554 | ||
11555 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
11556 | if (type < 0) { | |
11557 | vty_out(vty, "%% Invalid route type\n"); | |
11558 | return CMD_WARNING_CONFIG_FAILED; | |
11559 | } | |
11560 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
11561 | ||
11562 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
11563 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11564 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
11565 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
11566 | } | |
11567 | ||
11568 | ALIAS_HIDDEN( | |
11569 | bgp_redistribute_ipv4_rmap_metric, | |
11570 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
11571 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
11572 | " route-map WORD metric (0-4294967295)", | |
11573 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
11574 | "Route map reference\n" | |
11575 | "Pointer to route-map entries\n" | |
11576 | "Metric for redistributed routes\n" | |
11577 | "Default metric\n") | |
596c17ba | 11578 | |
718e3744 | 11579 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
11580 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 11581 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 11582 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11583 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 11584 | "Metric for redistributed routes\n" |
11585 | "Default metric\n" | |
11586 | "Route map reference\n" | |
11587 | "Pointer to route-map entries\n") | |
11588 | { | |
d62a17ae | 11589 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11590 | int idx_protocol = 1; | |
11591 | int idx_number = 3; | |
11592 | int idx_word = 5; | |
11593 | int type; | |
d7c0a89a | 11594 | uint32_t metric; |
d62a17ae | 11595 | struct bgp_redist *red; |
11596 | ||
11597 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
11598 | if (type < 0) { | |
11599 | vty_out(vty, "%% Invalid route type\n"); | |
11600 | return CMD_WARNING_CONFIG_FAILED; | |
11601 | } | |
11602 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
11603 | ||
11604 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
11605 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
11606 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11607 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
11608 | } | |
11609 | ||
11610 | ALIAS_HIDDEN( | |
11611 | bgp_redistribute_ipv4_metric_rmap, | |
11612 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
11613 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
11614 | " metric (0-4294967295) route-map WORD", | |
11615 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
11616 | "Metric for redistributed routes\n" | |
11617 | "Default metric\n" | |
11618 | "Route map reference\n" | |
11619 | "Pointer to route-map entries\n") | |
596c17ba | 11620 | |
7c8ff89e DS |
11621 | DEFUN (bgp_redistribute_ipv4_ospf, |
11622 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 11623 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
11624 | "Redistribute information from another routing protocol\n" |
11625 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
11626 | "Non-main Kernel Routing Table\n" |
11627 | "Instance ID/Table ID\n") | |
7c8ff89e | 11628 | { |
d62a17ae | 11629 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11630 | int idx_ospf_table = 1; | |
11631 | int idx_number = 2; | |
d7c0a89a QY |
11632 | unsigned short instance; |
11633 | unsigned short protocol; | |
7c8ff89e | 11634 | |
d62a17ae | 11635 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 11636 | |
d62a17ae | 11637 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
11638 | protocol = ZEBRA_ROUTE_OSPF; | |
11639 | else | |
11640 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 11641 | |
d62a17ae | 11642 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
11643 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
11644 | } |
11645 | ||
d62a17ae | 11646 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
11647 | "redistribute <ospf|table> (1-65535)", | |
11648 | "Redistribute information from another routing protocol\n" | |
11649 | "Open Shortest Path First (OSPFv2)\n" | |
11650 | "Non-main Kernel Routing Table\n" | |
11651 | "Instance ID/Table ID\n") | |
596c17ba | 11652 | |
7c8ff89e DS |
11653 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
11654 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 11655 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
11656 | "Redistribute information from another routing protocol\n" |
11657 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
11658 | "Non-main Kernel Routing Table\n" |
11659 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
11660 | "Route map reference\n" |
11661 | "Pointer to route-map entries\n") | |
11662 | { | |
d62a17ae | 11663 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11664 | int idx_ospf_table = 1; | |
11665 | int idx_number = 2; | |
11666 | int idx_word = 4; | |
11667 | struct bgp_redist *red; | |
d7c0a89a | 11668 | unsigned short instance; |
d62a17ae | 11669 | int protocol; |
11670 | ||
11671 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
11672 | protocol = ZEBRA_ROUTE_OSPF; | |
11673 | else | |
11674 | protocol = ZEBRA_ROUTE_TABLE; | |
11675 | ||
11676 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
11677 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
11678 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11679 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
11680 | } | |
11681 | ||
11682 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
11683 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
11684 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
11685 | "Redistribute information from another routing protocol\n" | |
11686 | "Open Shortest Path First (OSPFv2)\n" | |
11687 | "Non-main Kernel Routing Table\n" | |
11688 | "Instance ID/Table ID\n" | |
11689 | "Route map reference\n" | |
11690 | "Pointer to route-map entries\n") | |
596c17ba | 11691 | |
7c8ff89e DS |
11692 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
11693 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 11694 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
11695 | "Redistribute information from another routing protocol\n" |
11696 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
11697 | "Non-main Kernel Routing Table\n" |
11698 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
11699 | "Metric for redistributed routes\n" |
11700 | "Default metric\n") | |
11701 | { | |
d62a17ae | 11702 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11703 | int idx_ospf_table = 1; | |
11704 | int idx_number = 2; | |
11705 | int idx_number_2 = 4; | |
d7c0a89a | 11706 | uint32_t metric; |
d62a17ae | 11707 | struct bgp_redist *red; |
d7c0a89a | 11708 | unsigned short instance; |
d62a17ae | 11709 | int protocol; |
11710 | ||
11711 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
11712 | protocol = ZEBRA_ROUTE_OSPF; | |
11713 | else | |
11714 | protocol = ZEBRA_ROUTE_TABLE; | |
11715 | ||
11716 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
11717 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
11718 | ||
11719 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
11720 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
11721 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
11722 | } | |
11723 | ||
11724 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
11725 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
11726 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
11727 | "Redistribute information from another routing protocol\n" | |
11728 | "Open Shortest Path First (OSPFv2)\n" | |
11729 | "Non-main Kernel Routing Table\n" | |
11730 | "Instance ID/Table ID\n" | |
11731 | "Metric for redistributed routes\n" | |
11732 | "Default metric\n") | |
596c17ba | 11733 | |
7c8ff89e DS |
11734 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
11735 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 11736 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
11737 | "Redistribute information from another routing protocol\n" |
11738 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
11739 | "Non-main Kernel Routing Table\n" |
11740 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
11741 | "Route map reference\n" |
11742 | "Pointer to route-map entries\n" | |
11743 | "Metric for redistributed routes\n" | |
11744 | "Default metric\n") | |
11745 | { | |
d62a17ae | 11746 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11747 | int idx_ospf_table = 1; | |
11748 | int idx_number = 2; | |
11749 | int idx_word = 4; | |
11750 | int idx_number_2 = 6; | |
d7c0a89a | 11751 | uint32_t metric; |
d62a17ae | 11752 | struct bgp_redist *red; |
d7c0a89a | 11753 | unsigned short instance; |
d62a17ae | 11754 | int protocol; |
11755 | ||
11756 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
11757 | protocol = ZEBRA_ROUTE_OSPF; | |
11758 | else | |
11759 | protocol = ZEBRA_ROUTE_TABLE; | |
11760 | ||
11761 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
11762 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
11763 | ||
11764 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
11765 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11766 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
11767 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
11768 | } | |
11769 | ||
11770 | ALIAS_HIDDEN( | |
11771 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
11772 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
11773 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
11774 | "Redistribute information from another routing protocol\n" | |
11775 | "Open Shortest Path First (OSPFv2)\n" | |
11776 | "Non-main Kernel Routing Table\n" | |
11777 | "Instance ID/Table ID\n" | |
11778 | "Route map reference\n" | |
11779 | "Pointer to route-map entries\n" | |
11780 | "Metric for redistributed routes\n" | |
11781 | "Default metric\n") | |
596c17ba | 11782 | |
7c8ff89e DS |
11783 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
11784 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 11785 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
11786 | "Redistribute information from another routing protocol\n" |
11787 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
11788 | "Non-main Kernel Routing Table\n" |
11789 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
11790 | "Metric for redistributed routes\n" |
11791 | "Default metric\n" | |
11792 | "Route map reference\n" | |
11793 | "Pointer to route-map entries\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; | |
11799 | int idx_word = 6; | |
d7c0a89a | 11800 | uint32_t metric; |
d62a17ae | 11801 | struct bgp_redist *red; |
d7c0a89a | 11802 | unsigned short instance; |
d62a17ae | 11803 | int protocol; |
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); | |
11814 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
11815 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11816 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
11817 | } | |
11818 | ||
11819 | ALIAS_HIDDEN( | |
11820 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
11821 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
11822 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
11823 | "Redistribute information from another routing protocol\n" | |
11824 | "Open Shortest Path First (OSPFv2)\n" | |
11825 | "Non-main Kernel Routing Table\n" | |
11826 | "Instance ID/Table ID\n" | |
11827 | "Metric for redistributed routes\n" | |
11828 | "Default metric\n" | |
11829 | "Route map reference\n" | |
11830 | "Pointer to route-map entries\n") | |
596c17ba | 11831 | |
7c8ff89e DS |
11832 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
11833 | no_bgp_redistribute_ipv4_ospf_cmd, | |
d04c479d | 11834 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", |
7c8ff89e DS |
11835 | NO_STR |
11836 | "Redistribute information from another routing protocol\n" | |
11837 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 11838 | "Non-main Kernel Routing Table\n" |
31500417 DW |
11839 | "Instance ID/Table ID\n" |
11840 | "Metric for redistributed routes\n" | |
11841 | "Default metric\n" | |
11842 | "Route map reference\n" | |
11843 | "Pointer to route-map entries\n") | |
7c8ff89e | 11844 | { |
d62a17ae | 11845 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11846 | int idx_ospf_table = 2; | |
11847 | int idx_number = 3; | |
d7c0a89a | 11848 | unsigned short instance; |
d62a17ae | 11849 | int protocol; |
11850 | ||
11851 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
11852 | protocol = ZEBRA_ROUTE_OSPF; | |
11853 | else | |
11854 | protocol = ZEBRA_ROUTE_TABLE; | |
11855 | ||
11856 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
11857 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
11858 | } | |
11859 | ||
11860 | ALIAS_HIDDEN( | |
11861 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
11862 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", | |
11863 | NO_STR | |
11864 | "Redistribute information from another routing protocol\n" | |
11865 | "Open Shortest Path First (OSPFv2)\n" | |
11866 | "Non-main Kernel Routing Table\n" | |
11867 | "Instance ID/Table ID\n" | |
11868 | "Metric for redistributed routes\n" | |
11869 | "Default metric\n" | |
11870 | "Route map reference\n" | |
11871 | "Pointer to route-map entries\n") | |
596c17ba | 11872 | |
718e3744 | 11873 | DEFUN (no_bgp_redistribute_ipv4, |
11874 | no_bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 11875 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 11876 | NO_STR |
11877 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 11878 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
11879 | "Metric for redistributed routes\n" |
11880 | "Default metric\n" | |
11881 | "Route map reference\n" | |
11882 | "Pointer to route-map entries\n") | |
718e3744 | 11883 | { |
d62a17ae | 11884 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11885 | int idx_protocol = 2; | |
11886 | int type; | |
11887 | ||
11888 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
11889 | if (type < 0) { | |
11890 | vty_out(vty, "%% Invalid route type\n"); | |
11891 | return CMD_WARNING_CONFIG_FAILED; | |
11892 | } | |
11893 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
11894 | } | |
11895 | ||
11896 | ALIAS_HIDDEN( | |
11897 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
11898 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
11899 | " [metric (0-4294967295)] [route-map WORD]", | |
11900 | NO_STR | |
11901 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
11902 | "Metric for redistributed routes\n" | |
11903 | "Default metric\n" | |
11904 | "Route map reference\n" | |
11905 | "Pointer to route-map entries\n") | |
596c17ba | 11906 | |
718e3744 | 11907 | DEFUN (bgp_redistribute_ipv6, |
11908 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 11909 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 11910 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11911 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 11912 | { |
d62a17ae | 11913 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11914 | int idx_protocol = 1; | |
11915 | int type; | |
718e3744 | 11916 | |
d62a17ae | 11917 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
11918 | if (type < 0) { | |
11919 | vty_out(vty, "%% Invalid route type\n"); | |
11920 | return CMD_WARNING_CONFIG_FAILED; | |
11921 | } | |
718e3744 | 11922 | |
d62a17ae | 11923 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
11924 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 11925 | } |
11926 | ||
11927 | DEFUN (bgp_redistribute_ipv6_rmap, | |
11928 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 11929 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 11930 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11931 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 11932 | "Route map reference\n" |
11933 | "Pointer to route-map entries\n") | |
11934 | { | |
d62a17ae | 11935 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11936 | int idx_protocol = 1; | |
11937 | int idx_word = 3; | |
11938 | int type; | |
11939 | struct bgp_redist *red; | |
718e3744 | 11940 | |
d62a17ae | 11941 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
11942 | if (type < 0) { | |
11943 | vty_out(vty, "%% Invalid route type\n"); | |
11944 | return CMD_WARNING_CONFIG_FAILED; | |
11945 | } | |
718e3744 | 11946 | |
d62a17ae | 11947 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
11948 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11949 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 11950 | } |
11951 | ||
11952 | DEFUN (bgp_redistribute_ipv6_metric, | |
11953 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 11954 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 11955 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11956 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 11957 | "Metric for redistributed routes\n" |
11958 | "Default metric\n") | |
11959 | { | |
d62a17ae | 11960 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11961 | int idx_protocol = 1; | |
11962 | int idx_number = 3; | |
11963 | int type; | |
d7c0a89a | 11964 | uint32_t metric; |
d62a17ae | 11965 | struct bgp_redist *red; |
11966 | ||
11967 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
11968 | if (type < 0) { | |
11969 | vty_out(vty, "%% Invalid route type\n"); | |
11970 | return CMD_WARNING_CONFIG_FAILED; | |
11971 | } | |
11972 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 11973 | |
d62a17ae | 11974 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
11975 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
11976 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 11977 | } |
11978 | ||
11979 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
11980 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 11981 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 11982 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11983 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 11984 | "Route map reference\n" |
11985 | "Pointer to route-map entries\n" | |
11986 | "Metric for redistributed routes\n" | |
11987 | "Default metric\n") | |
11988 | { | |
d62a17ae | 11989 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11990 | int idx_protocol = 1; | |
11991 | int idx_word = 3; | |
11992 | int idx_number = 5; | |
11993 | int type; | |
d7c0a89a | 11994 | uint32_t metric; |
d62a17ae | 11995 | struct bgp_redist *red; |
11996 | ||
11997 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
11998 | if (type < 0) { | |
11999 | vty_out(vty, "%% Invalid route type\n"); | |
12000 | return CMD_WARNING_CONFIG_FAILED; | |
12001 | } | |
12002 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 12003 | |
d62a17ae | 12004 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
12005 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
12006 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
12007 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 12008 | } |
12009 | ||
12010 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
12011 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 12012 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 12013 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12014 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12015 | "Metric for redistributed routes\n" |
12016 | "Default metric\n" | |
12017 | "Route map reference\n" | |
12018 | "Pointer to route-map entries\n") | |
12019 | { | |
d62a17ae | 12020 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12021 | int idx_protocol = 1; | |
12022 | int idx_number = 3; | |
12023 | int idx_word = 5; | |
12024 | int type; | |
d7c0a89a | 12025 | uint32_t metric; |
d62a17ae | 12026 | struct bgp_redist *red; |
12027 | ||
12028 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
12029 | if (type < 0) { | |
12030 | vty_out(vty, "%% Invalid route type\n"); | |
12031 | return CMD_WARNING_CONFIG_FAILED; | |
12032 | } | |
12033 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 12034 | |
d62a17ae | 12035 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
12036 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, metric); | |
12037 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
12038 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 12039 | } |
12040 | ||
12041 | DEFUN (no_bgp_redistribute_ipv6, | |
12042 | no_bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 12043 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 12044 | NO_STR |
12045 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 12046 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
12047 | "Metric for redistributed routes\n" |
12048 | "Default metric\n" | |
12049 | "Route map reference\n" | |
12050 | "Pointer to route-map entries\n") | |
718e3744 | 12051 | { |
d62a17ae | 12052 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12053 | int idx_protocol = 2; | |
12054 | int type; | |
718e3744 | 12055 | |
d62a17ae | 12056 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
12057 | if (type < 0) { | |
12058 | vty_out(vty, "%% Invalid route type\n"); | |
12059 | return CMD_WARNING_CONFIG_FAILED; | |
12060 | } | |
718e3744 | 12061 | |
d62a17ae | 12062 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
12063 | } | |
12064 | ||
2b791107 | 12065 | void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, afi_t afi, |
60466a63 | 12066 | safi_t safi) |
d62a17ae | 12067 | { |
12068 | int i; | |
12069 | ||
12070 | /* Unicast redistribution only. */ | |
12071 | if (safi != SAFI_UNICAST) | |
2b791107 | 12072 | return; |
d62a17ae | 12073 | |
12074 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
12075 | /* Redistribute BGP does not make sense. */ | |
12076 | if (i != ZEBRA_ROUTE_BGP) { | |
12077 | struct list *red_list; | |
12078 | struct listnode *node; | |
12079 | struct bgp_redist *red; | |
12080 | ||
12081 | red_list = bgp->redist[afi][i]; | |
12082 | if (!red_list) | |
12083 | continue; | |
12084 | ||
12085 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 12086 | /* "redistribute" configuration. */ |
12087 | vty_out(vty, " redistribute %s", | |
12088 | zebra_route_string(i)); | |
12089 | if (red->instance) | |
12090 | vty_out(vty, " %d", red->instance); | |
12091 | if (red->redist_metric_flag) | |
12092 | vty_out(vty, " metric %u", | |
12093 | red->redist_metric); | |
12094 | if (red->rmap.name) | |
12095 | vty_out(vty, " route-map %s", | |
12096 | red->rmap.name); | |
12097 | vty_out(vty, "\n"); | |
12098 | } | |
12099 | } | |
12100 | } | |
718e3744 | 12101 | } |
6b0655a2 | 12102 | |
b9c7bc5a PZ |
12103 | /* This is part of the address-family block (unicast only) */ |
12104 | void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, | |
ddb5b488 PZ |
12105 | afi_t afi) |
12106 | { | |
b9c7bc5a | 12107 | int indent = 2; |
ddb5b488 | 12108 | |
bb4f6190 DS |
12109 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) |
12110 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", | |
12111 | bgp->vpn_policy[afi] | |
12112 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
12113 | ||
12a844a5 DS |
12114 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
12115 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
12116 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
12117 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
12118 | return; | |
12119 | ||
e70e9f8e PZ |
12120 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
12121 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
12122 | ||
12123 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
12124 | ||
12125 | } else { | |
12126 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
12127 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
12128 | bgp->vpn_policy[afi].tovpn_label); | |
12129 | } | |
ddb5b488 PZ |
12130 | } |
12131 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
12132 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
12133 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 12134 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
12135 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
12136 | sizeof(buf))); | |
12137 | } | |
12138 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
12139 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
12140 | ||
12141 | char buf[PREFIX_STRLEN]; | |
12142 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
12143 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
12144 | sizeof(buf))) { | |
12145 | ||
b9c7bc5a PZ |
12146 | vty_out(vty, "%*snexthop vpn export %s\n", |
12147 | indent, "", buf); | |
ddb5b488 PZ |
12148 | } |
12149 | } | |
12150 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
12151 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
12152 | && ecommunity_cmp( | |
12153 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
12154 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
12155 | ||
12156 | char *b = ecommunity_ecom2str( | |
12157 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
12158 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12159 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
12160 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12161 | } else { | |
12162 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
12163 | char *b = ecommunity_ecom2str( | |
12164 | bgp->vpn_policy[afi] | |
12165 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
12166 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12167 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12168 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
12169 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12170 | } | |
12171 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
12172 | char *b = ecommunity_ecom2str( | |
12173 | bgp->vpn_policy[afi] | |
12174 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
12175 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12176 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12177 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
12178 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12179 | } | |
12180 | } | |
bb4f6190 DS |
12181 | |
12182 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 12183 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
12184 | bgp->vpn_policy[afi] |
12185 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 12186 | |
301ad80a PG |
12187 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
12188 | char *b = ecommunity_ecom2str( | |
12189 | bgp->vpn_policy[afi] | |
12190 | .import_redirect_rtlist, | |
12191 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12192 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 12193 | |
301ad80a PG |
12194 | vty_out(vty, "%*srt redirect import %s\n", indent, "", b); |
12195 | XFREE(MTYPE_ECOMMUNITY_STR, b); | |
12196 | } | |
ddb5b488 PZ |
12197 | } |
12198 | ||
12199 | ||
718e3744 | 12200 | /* BGP node structure. */ |
d62a17ae | 12201 | static struct cmd_node bgp_node = { |
9d303b37 | 12202 | BGP_NODE, "%s(config-router)# ", 1, |
718e3744 | 12203 | }; |
12204 | ||
d62a17ae | 12205 | static struct cmd_node bgp_ipv4_unicast_node = { |
9d303b37 | 12206 | BGP_IPV4_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12207 | }; |
12208 | ||
d62a17ae | 12209 | static struct cmd_node bgp_ipv4_multicast_node = { |
9d303b37 | 12210 | BGP_IPV4M_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12211 | }; |
12212 | ||
d62a17ae | 12213 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
9d303b37 | 12214 | BGP_IPV4L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
12215 | }; |
12216 | ||
d62a17ae | 12217 | static struct cmd_node bgp_ipv6_unicast_node = { |
9d303b37 | 12218 | BGP_IPV6_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12219 | }; |
12220 | ||
d62a17ae | 12221 | static struct cmd_node bgp_ipv6_multicast_node = { |
9d303b37 | 12222 | BGP_IPV6M_NODE, "%s(config-router-af)# ", 1, |
25ffbdc1 | 12223 | }; |
12224 | ||
d62a17ae | 12225 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
9d303b37 | 12226 | BGP_IPV6L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
12227 | }; |
12228 | ||
d62a17ae | 12229 | static struct cmd_node bgp_vpnv4_node = {BGP_VPNV4_NODE, |
12230 | "%s(config-router-af)# ", 1}; | |
6b0655a2 | 12231 | |
d62a17ae | 12232 | static struct cmd_node bgp_vpnv6_node = {BGP_VPNV6_NODE, |
12233 | "%s(config-router-af-vpnv6)# ", 1}; | |
8ecd3266 | 12234 | |
d62a17ae | 12235 | static struct cmd_node bgp_evpn_node = {BGP_EVPN_NODE, |
12236 | "%s(config-router-evpn)# ", 1}; | |
4e0b7b6d | 12237 | |
d62a17ae | 12238 | static struct cmd_node bgp_evpn_vni_node = {BGP_EVPN_VNI_NODE, |
12239 | "%s(config-router-af-vni)# ", 1}; | |
90e60aa7 | 12240 | |
7c40bf39 | 12241 | static struct cmd_node bgp_flowspecv4_node = {BGP_FLOWSPECV4_NODE, |
12242 | "%s(config-router-af)# ", 1}; | |
12243 | ||
12244 | static struct cmd_node bgp_flowspecv6_node = {BGP_FLOWSPECV6_NODE, | |
12245 | "%s(config-router-af-vpnv6)# ", 1}; | |
12246 | ||
d62a17ae | 12247 | static void community_list_vty(void); |
1f8ae70b | 12248 | |
d62a17ae | 12249 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 12250 | { |
d62a17ae | 12251 | struct bgp *bgp; |
12252 | struct peer *peer; | |
d62a17ae | 12253 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 12254 | |
d62a17ae | 12255 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
12256 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
12257 | /* only provide suggestions on the appropriate input | |
12258 | * token type, | |
12259 | * they'll otherwise show up multiple times */ | |
12260 | enum cmd_token_type match_type; | |
12261 | char *name = peer->host; | |
d48ed3e0 | 12262 | |
d62a17ae | 12263 | if (peer->conf_if) { |
12264 | match_type = VARIABLE_TKN; | |
12265 | name = peer->conf_if; | |
12266 | } else if (strchr(peer->host, ':')) | |
12267 | match_type = IPV6_TKN; | |
12268 | else | |
12269 | match_type = IPV4_TKN; | |
d48ed3e0 | 12270 | |
d62a17ae | 12271 | if (token->type != match_type) |
12272 | continue; | |
d48ed3e0 | 12273 | |
d62a17ae | 12274 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
12275 | } | |
d62a17ae | 12276 | } |
b8a815e5 DL |
12277 | } |
12278 | ||
12279 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 12280 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
12281 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 12282 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 12283 | {.completions = NULL}}; |
12284 | ||
47a306a0 DS |
12285 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
12286 | { | |
12287 | struct bgp *bgp; | |
12288 | struct peer_group *group; | |
12289 | struct listnode *lnbgp, *lnpeer; | |
12290 | ||
12291 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
12292 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
12293 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
12294 | group->name)); | |
12295 | } | |
12296 | } | |
12297 | ||
12298 | static const struct cmd_variable_handler bgp_var_peergroup[] = { | |
12299 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
12300 | {.completions = NULL} }; | |
12301 | ||
d62a17ae | 12302 | void bgp_vty_init(void) |
12303 | { | |
12304 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 12305 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 12306 | |
12307 | /* Install bgp top node. */ | |
12308 | install_node(&bgp_node, bgp_config_write); | |
12309 | install_node(&bgp_ipv4_unicast_node, NULL); | |
12310 | install_node(&bgp_ipv4_multicast_node, NULL); | |
12311 | install_node(&bgp_ipv4_labeled_unicast_node, NULL); | |
12312 | install_node(&bgp_ipv6_unicast_node, NULL); | |
12313 | install_node(&bgp_ipv6_multicast_node, NULL); | |
12314 | install_node(&bgp_ipv6_labeled_unicast_node, NULL); | |
12315 | install_node(&bgp_vpnv4_node, NULL); | |
12316 | install_node(&bgp_vpnv6_node, NULL); | |
12317 | install_node(&bgp_evpn_node, NULL); | |
12318 | install_node(&bgp_evpn_vni_node, NULL); | |
7c40bf39 | 12319 | install_node(&bgp_flowspecv4_node, NULL); |
12320 | install_node(&bgp_flowspecv6_node, NULL); | |
d62a17ae | 12321 | |
12322 | /* Install default VTY commands to new nodes. */ | |
12323 | install_default(BGP_NODE); | |
12324 | install_default(BGP_IPV4_NODE); | |
12325 | install_default(BGP_IPV4M_NODE); | |
12326 | install_default(BGP_IPV4L_NODE); | |
12327 | install_default(BGP_IPV6_NODE); | |
12328 | install_default(BGP_IPV6M_NODE); | |
12329 | install_default(BGP_IPV6L_NODE); | |
12330 | install_default(BGP_VPNV4_NODE); | |
12331 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 12332 | install_default(BGP_FLOWSPECV4_NODE); |
12333 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 12334 | install_default(BGP_EVPN_NODE); |
12335 | install_default(BGP_EVPN_VNI_NODE); | |
12336 | ||
12337 | /* "bgp multiple-instance" commands. */ | |
12338 | install_element(CONFIG_NODE, &bgp_multiple_instance_cmd); | |
12339 | install_element(CONFIG_NODE, &no_bgp_multiple_instance_cmd); | |
12340 | ||
12341 | /* "bgp config-type" commands. */ | |
12342 | install_element(CONFIG_NODE, &bgp_config_type_cmd); | |
12343 | install_element(CONFIG_NODE, &no_bgp_config_type_cmd); | |
12344 | ||
12345 | /* bgp route-map delay-timer commands. */ | |
12346 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
12347 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
12348 | ||
12349 | /* Dummy commands (Currently not supported) */ | |
12350 | install_element(BGP_NODE, &no_synchronization_cmd); | |
12351 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
12352 | ||
12353 | /* "router bgp" commands. */ | |
12354 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
12355 | ||
12356 | /* "no router bgp" commands. */ | |
12357 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
12358 | ||
12359 | /* "bgp router-id" commands. */ | |
12360 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
12361 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
12362 | ||
12363 | /* "bgp cluster-id" commands. */ | |
12364 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
12365 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
12366 | ||
12367 | /* "bgp confederation" commands. */ | |
12368 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
12369 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
12370 | ||
12371 | /* "bgp confederation peers" commands. */ | |
12372 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
12373 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
12374 | ||
12375 | /* bgp max-med command */ | |
12376 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
12377 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
12378 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
12379 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
12380 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
12381 | ||
12382 | /* bgp disable-ebgp-connected-nh-check */ | |
12383 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
12384 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
12385 | ||
12386 | /* bgp update-delay command */ | |
12387 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
12388 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
12389 | install_element(BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
12390 | ||
12391 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
12392 | install_element(BGP_NODE, &no_bgp_wpkt_quanta_cmd); | |
555e09d4 QY |
12393 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
12394 | install_element(BGP_NODE, &no_bgp_rpkt_quanta_cmd); | |
d62a17ae | 12395 | |
12396 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
12397 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
12398 | ||
12399 | /* "maximum-paths" commands. */ | |
12400 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
12401 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
12402 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
12403 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
12404 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
12405 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
12406 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
12407 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
12408 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
12409 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
12410 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
12411 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
12412 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
12413 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
12414 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
12415 | ||
12416 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); | |
12417 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
12418 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
12419 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
12420 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
12421 | ||
12422 | /* "timers bgp" commands. */ | |
12423 | install_element(BGP_NODE, &bgp_timers_cmd); | |
12424 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
12425 | ||
12426 | /* route-map delay-timer commands - per instance for backwards compat. | |
12427 | */ | |
12428 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
12429 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
12430 | ||
12431 | /* "bgp client-to-client reflection" commands */ | |
12432 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
12433 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
12434 | ||
12435 | /* "bgp always-compare-med" commands */ | |
12436 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
12437 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
12438 | ||
12439 | /* "bgp deterministic-med" commands */ | |
12440 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
12441 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
12442 | ||
12443 | /* "bgp graceful-restart" commands */ | |
12444 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); | |
12445 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
12446 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); | |
12447 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
12448 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
12449 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
12450 | ||
12451 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); | |
12452 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
12453 | ||
7f323236 DW |
12454 | /* "bgp graceful-shutdown" commands */ |
12455 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
12456 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
12457 | ||
d62a17ae | 12458 | /* "bgp fast-external-failover" commands */ |
12459 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
12460 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
12461 | ||
12462 | /* "bgp enforce-first-as" commands */ | |
12463 | install_element(BGP_NODE, &bgp_enforce_first_as_cmd); | |
d62a17ae | 12464 | |
12465 | /* "bgp bestpath compare-routerid" commands */ | |
12466 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
12467 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
12468 | ||
12469 | /* "bgp bestpath as-path ignore" commands */ | |
12470 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
12471 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
12472 | ||
12473 | /* "bgp bestpath as-path confed" commands */ | |
12474 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
12475 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
12476 | ||
12477 | /* "bgp bestpath as-path multipath-relax" commands */ | |
12478 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
12479 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
12480 | ||
12481 | /* "bgp log-neighbor-changes" commands */ | |
12482 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
12483 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
12484 | ||
12485 | /* "bgp bestpath med" commands */ | |
12486 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
12487 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
12488 | ||
12489 | /* "no bgp default ipv4-unicast" commands. */ | |
12490 | install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
12491 | install_element(BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
12492 | ||
12493 | /* "bgp network import-check" commands. */ | |
12494 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
12495 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
12496 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
12497 | ||
12498 | /* "bgp default local-preference" commands. */ | |
12499 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
12500 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
12501 | ||
12502 | /* bgp default show-hostname */ | |
12503 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
12504 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
12505 | ||
12506 | /* "bgp default subgroup-pkt-queue-max" commands. */ | |
12507 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
12508 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
12509 | ||
12510 | /* bgp ibgp-allow-policy-mods command */ | |
12511 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
12512 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
12513 | ||
12514 | /* "bgp listen limit" commands. */ | |
12515 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
12516 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
12517 | ||
12518 | /* "bgp listen range" commands. */ | |
12519 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
12520 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
12521 | ||
8175f54a | 12522 | /* "bgp default shutdown" command */ |
f26845f9 QY |
12523 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
12524 | ||
d62a17ae | 12525 | /* "neighbor remote-as" commands. */ |
12526 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
12527 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
12528 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
12529 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
12530 | install_element(BGP_NODE, | |
12531 | &neighbor_interface_v6only_config_remote_as_cmd); | |
12532 | install_element(BGP_NODE, &no_neighbor_cmd); | |
12533 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
12534 | ||
12535 | /* "neighbor peer-group" commands. */ | |
12536 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
12537 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
12538 | install_element(BGP_NODE, | |
12539 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
12540 | ||
12541 | /* "neighbor local-as" commands. */ | |
12542 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
12543 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
12544 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
12545 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
12546 | ||
12547 | /* "neighbor solo" commands. */ | |
12548 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
12549 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
12550 | ||
12551 | /* "neighbor password" commands. */ | |
12552 | install_element(BGP_NODE, &neighbor_password_cmd); | |
12553 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
12554 | ||
12555 | /* "neighbor activate" commands. */ | |
12556 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
12557 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
12558 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
12559 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
12560 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
12561 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
12562 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
12563 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
12564 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 12565 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
12566 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 12567 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
12568 | ||
12569 | /* "no neighbor activate" commands. */ | |
12570 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
12571 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
12572 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
12573 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
12574 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
12575 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
12576 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
12577 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
12578 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 12579 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
12580 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 12581 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
12582 | ||
12583 | /* "neighbor peer-group" set commands. */ | |
12584 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
12585 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12586 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12587 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12588 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12589 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12590 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12591 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 12592 | install_element(BGP_FLOWSPECV4_NODE, |
12593 | &neighbor_set_peer_group_hidden_cmd); | |
12594 | install_element(BGP_FLOWSPECV6_NODE, | |
12595 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 12596 | |
12597 | /* "no neighbor peer-group unset" commands. */ | |
12598 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
12599 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12600 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12601 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12602 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12603 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12604 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12605 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 12606 | install_element(BGP_FLOWSPECV4_NODE, |
12607 | &no_neighbor_set_peer_group_hidden_cmd); | |
12608 | install_element(BGP_FLOWSPECV6_NODE, | |
12609 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 12610 | |
12611 | /* "neighbor softreconfiguration inbound" commands.*/ | |
12612 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
12613 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
12614 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
12615 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12616 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
12617 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12618 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
12619 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12620 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
12621 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12622 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
12623 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12624 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
12625 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12626 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
12627 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12628 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
12629 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 12630 | install_element(BGP_FLOWSPECV4_NODE, |
12631 | &neighbor_soft_reconfiguration_cmd); | |
12632 | install_element(BGP_FLOWSPECV4_NODE, | |
12633 | &no_neighbor_soft_reconfiguration_cmd); | |
12634 | install_element(BGP_FLOWSPECV6_NODE, | |
12635 | &neighbor_soft_reconfiguration_cmd); | |
12636 | install_element(BGP_FLOWSPECV6_NODE, | |
12637 | &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 12638 | |
12639 | /* "neighbor attribute-unchanged" commands. */ | |
12640 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
12641 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
12642 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
12643 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
12644 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
12645 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
12646 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
12647 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
12648 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
12649 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
12650 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
12651 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
12652 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
12653 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
12654 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
12655 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
12656 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
12657 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
12658 | ||
12659 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
12660 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
12661 | ||
12662 | /* "nexthop-local unchanged" commands */ | |
12663 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
12664 | install_element(BGP_IPV6_NODE, | |
12665 | &no_neighbor_nexthop_local_unchanged_cmd); | |
12666 | ||
12667 | /* "neighbor next-hop-self" commands. */ | |
12668 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
12669 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
12670 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
12671 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
12672 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
12673 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
12674 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
12675 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
12676 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
12677 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
12678 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
12679 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
12680 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
12681 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
12682 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
12683 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
12684 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
12685 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
12686 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
12687 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 12688 | |
12689 | /* "neighbor next-hop-self force" commands. */ | |
12690 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
12691 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
12692 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); | |
12693 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
12694 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); | |
12695 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
12696 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); | |
12697 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
12698 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); | |
12699 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
12700 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); | |
12701 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
12702 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); | |
12703 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
12704 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); | |
12705 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
12706 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); | |
12707 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
12708 | ||
12709 | /* "neighbor as-override" commands. */ | |
12710 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
12711 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
12712 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
12713 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
12714 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
12715 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
12716 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
12717 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
12718 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
12719 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
12720 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
12721 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
12722 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
12723 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
12724 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
12725 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
12726 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
12727 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
12728 | ||
12729 | /* "neighbor remove-private-AS" commands. */ | |
12730 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
12731 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
12732 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
12733 | install_element(BGP_NODE, | |
12734 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
12735 | install_element(BGP_NODE, | |
12736 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
12737 | install_element(BGP_NODE, | |
12738 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
12739 | install_element(BGP_NODE, | |
12740 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
12741 | install_element( | |
12742 | BGP_NODE, | |
12743 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
12744 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
12745 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
12746 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
12747 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
12748 | install_element(BGP_IPV4_NODE, | |
12749 | &neighbor_remove_private_as_replace_as_cmd); | |
12750 | install_element(BGP_IPV4_NODE, | |
12751 | &no_neighbor_remove_private_as_replace_as_cmd); | |
12752 | install_element(BGP_IPV4_NODE, | |
12753 | &neighbor_remove_private_as_all_replace_as_cmd); | |
12754 | install_element(BGP_IPV4_NODE, | |
12755 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
12756 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
12757 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
12758 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
12759 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
12760 | install_element(BGP_IPV4M_NODE, | |
12761 | &neighbor_remove_private_as_replace_as_cmd); | |
12762 | install_element(BGP_IPV4M_NODE, | |
12763 | &no_neighbor_remove_private_as_replace_as_cmd); | |
12764 | install_element(BGP_IPV4M_NODE, | |
12765 | &neighbor_remove_private_as_all_replace_as_cmd); | |
12766 | install_element(BGP_IPV4M_NODE, | |
12767 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
12768 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
12769 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
12770 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
12771 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
12772 | install_element(BGP_IPV4L_NODE, | |
12773 | &neighbor_remove_private_as_replace_as_cmd); | |
12774 | install_element(BGP_IPV4L_NODE, | |
12775 | &no_neighbor_remove_private_as_replace_as_cmd); | |
12776 | install_element(BGP_IPV4L_NODE, | |
12777 | &neighbor_remove_private_as_all_replace_as_cmd); | |
12778 | install_element(BGP_IPV4L_NODE, | |
12779 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
12780 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
12781 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
12782 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
12783 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
12784 | install_element(BGP_IPV6_NODE, | |
12785 | &neighbor_remove_private_as_replace_as_cmd); | |
12786 | install_element(BGP_IPV6_NODE, | |
12787 | &no_neighbor_remove_private_as_replace_as_cmd); | |
12788 | install_element(BGP_IPV6_NODE, | |
12789 | &neighbor_remove_private_as_all_replace_as_cmd); | |
12790 | install_element(BGP_IPV6_NODE, | |
12791 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
12792 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
12793 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
12794 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
12795 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
12796 | install_element(BGP_IPV6M_NODE, | |
12797 | &neighbor_remove_private_as_replace_as_cmd); | |
12798 | install_element(BGP_IPV6M_NODE, | |
12799 | &no_neighbor_remove_private_as_replace_as_cmd); | |
12800 | install_element(BGP_IPV6M_NODE, | |
12801 | &neighbor_remove_private_as_all_replace_as_cmd); | |
12802 | install_element(BGP_IPV6M_NODE, | |
12803 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
12804 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
12805 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
12806 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
12807 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
12808 | install_element(BGP_IPV6L_NODE, | |
12809 | &neighbor_remove_private_as_replace_as_cmd); | |
12810 | install_element(BGP_IPV6L_NODE, | |
12811 | &no_neighbor_remove_private_as_replace_as_cmd); | |
12812 | install_element(BGP_IPV6L_NODE, | |
12813 | &neighbor_remove_private_as_all_replace_as_cmd); | |
12814 | install_element(BGP_IPV6L_NODE, | |
12815 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
12816 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
12817 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
12818 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
12819 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
12820 | install_element(BGP_VPNV4_NODE, | |
12821 | &neighbor_remove_private_as_replace_as_cmd); | |
12822 | install_element(BGP_VPNV4_NODE, | |
12823 | &no_neighbor_remove_private_as_replace_as_cmd); | |
12824 | install_element(BGP_VPNV4_NODE, | |
12825 | &neighbor_remove_private_as_all_replace_as_cmd); | |
12826 | install_element(BGP_VPNV4_NODE, | |
12827 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
12828 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
12829 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
12830 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
12831 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
12832 | install_element(BGP_VPNV6_NODE, | |
12833 | &neighbor_remove_private_as_replace_as_cmd); | |
12834 | install_element(BGP_VPNV6_NODE, | |
12835 | &no_neighbor_remove_private_as_replace_as_cmd); | |
12836 | install_element(BGP_VPNV6_NODE, | |
12837 | &neighbor_remove_private_as_all_replace_as_cmd); | |
12838 | install_element(BGP_VPNV6_NODE, | |
12839 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
12840 | ||
12841 | /* "neighbor send-community" commands.*/ | |
12842 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
12843 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
12844 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
12845 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
12846 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
12847 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
12848 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
12849 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
12850 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
12851 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
12852 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
12853 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
12854 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
12855 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
12856 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
12857 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
12858 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
12859 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
12860 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
12861 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
12862 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
12863 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
12864 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
12865 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
12866 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
12867 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
12868 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
12869 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
12870 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
12871 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
12872 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
12873 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
12874 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
12875 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
12876 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
12877 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
12878 | ||
12879 | /* "neighbor route-reflector" commands.*/ | |
12880 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
12881 | install_element(BGP_NODE, | |
12882 | &no_neighbor_route_reflector_client_hidden_cmd); | |
12883 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
12884 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
12885 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
12886 | install_element(BGP_IPV4M_NODE, | |
12887 | &no_neighbor_route_reflector_client_cmd); | |
12888 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
12889 | install_element(BGP_IPV4L_NODE, | |
12890 | &no_neighbor_route_reflector_client_cmd); | |
12891 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
12892 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
12893 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
12894 | install_element(BGP_IPV6M_NODE, | |
12895 | &no_neighbor_route_reflector_client_cmd); | |
12896 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
12897 | install_element(BGP_IPV6L_NODE, | |
12898 | &no_neighbor_route_reflector_client_cmd); | |
12899 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
12900 | install_element(BGP_VPNV4_NODE, | |
12901 | &no_neighbor_route_reflector_client_cmd); | |
12902 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
12903 | install_element(BGP_VPNV6_NODE, | |
12904 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 12905 | install_element(BGP_FLOWSPECV4_NODE, |
12906 | &neighbor_route_reflector_client_cmd); | |
12907 | install_element(BGP_FLOWSPECV4_NODE, | |
12908 | &no_neighbor_route_reflector_client_cmd); | |
12909 | install_element(BGP_FLOWSPECV6_NODE, | |
12910 | &neighbor_route_reflector_client_cmd); | |
12911 | install_element(BGP_FLOWSPECV6_NODE, | |
12912 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 12913 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
12914 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
12915 | ||
12916 | /* "neighbor route-server" commands.*/ | |
12917 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
12918 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
12919 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
12920 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
12921 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
12922 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
12923 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
12924 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
12925 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
12926 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
12927 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
12928 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
12929 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
12930 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
12931 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
12932 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
12933 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
12934 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 12935 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
12936 | install_element(BGP_FLOWSPECV4_NODE, | |
12937 | &no_neighbor_route_server_client_cmd); | |
12938 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
12939 | install_element(BGP_FLOWSPECV6_NODE, | |
12940 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 12941 | |
12942 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
12943 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
12944 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
12945 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
12946 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
12947 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
12948 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
12949 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
12950 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
12951 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
12952 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
12953 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
12954 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
12955 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
12956 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
12957 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
12958 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
12959 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
12960 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
12961 | ||
12962 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
12963 | install_element(BGP_NODE, | |
12964 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
12965 | install_element(BGP_NODE, | |
12966 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
12967 | install_element(BGP_IPV4_NODE, | |
12968 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
12969 | install_element(BGP_IPV4_NODE, | |
12970 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
12971 | install_element(BGP_IPV4M_NODE, | |
12972 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
12973 | install_element(BGP_IPV4M_NODE, | |
12974 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
12975 | install_element(BGP_IPV4L_NODE, | |
12976 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
12977 | install_element(BGP_IPV4L_NODE, | |
12978 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
12979 | install_element(BGP_IPV6_NODE, | |
12980 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
12981 | install_element(BGP_IPV6_NODE, | |
12982 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
12983 | install_element(BGP_IPV6M_NODE, | |
12984 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
12985 | install_element(BGP_IPV6M_NODE, | |
12986 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
12987 | install_element(BGP_IPV6L_NODE, | |
12988 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
12989 | install_element(BGP_IPV6L_NODE, | |
12990 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
12991 | install_element(BGP_VPNV4_NODE, | |
12992 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
12993 | install_element(BGP_VPNV4_NODE, | |
12994 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
12995 | install_element(BGP_VPNV6_NODE, | |
12996 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
12997 | install_element(BGP_VPNV6_NODE, | |
12998 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
12999 | ||
13000 | /* "neighbor passive" commands. */ | |
13001 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
13002 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
13003 | ||
13004 | ||
13005 | /* "neighbor shutdown" commands. */ | |
13006 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
13007 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
13008 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
13009 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
13010 | ||
13011 | /* "neighbor capability extended-nexthop" commands.*/ | |
13012 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
13013 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
13014 | ||
13015 | /* "neighbor capability orf prefix-list" commands.*/ | |
13016 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
13017 | install_element(BGP_NODE, | |
13018 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
13019 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
13020 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13021 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
13022 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13023 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
13024 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13025 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
13026 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13027 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
13028 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13029 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
13030 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13031 | ||
13032 | /* "neighbor capability dynamic" commands.*/ | |
13033 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
13034 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
13035 | ||
13036 | /* "neighbor dont-capability-negotiate" commands. */ | |
13037 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
13038 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
13039 | ||
13040 | /* "neighbor ebgp-multihop" commands. */ | |
13041 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
13042 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
13043 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
13044 | ||
13045 | /* "neighbor disable-connected-check" commands. */ | |
13046 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
13047 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
13048 | ||
47cbc09b PM |
13049 | /* "neighbor enforce-first-as" commands. */ |
13050 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
13051 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
13052 | ||
d62a17ae | 13053 | /* "neighbor description" commands. */ |
13054 | install_element(BGP_NODE, &neighbor_description_cmd); | |
13055 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 13056 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 13057 | |
13058 | /* "neighbor update-source" commands. "*/ | |
13059 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
13060 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
13061 | ||
13062 | /* "neighbor default-originate" commands. */ | |
13063 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
13064 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
13065 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
13066 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
13067 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
13068 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
13069 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
13070 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
13071 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
13072 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
13073 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
13074 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
13075 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
13076 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
13077 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
13078 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
13079 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
13080 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
13081 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
13082 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
13083 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
13084 | ||
13085 | /* "neighbor port" commands. */ | |
13086 | install_element(BGP_NODE, &neighbor_port_cmd); | |
13087 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
13088 | ||
13089 | /* "neighbor weight" commands. */ | |
13090 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
13091 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
13092 | ||
13093 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
13094 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
13095 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
13096 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
13097 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
13098 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
13099 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
13100 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
13101 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
13102 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
13103 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
13104 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
13105 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
13106 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
13107 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
13108 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
13109 | ||
13110 | /* "neighbor override-capability" commands. */ | |
13111 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
13112 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
13113 | ||
13114 | /* "neighbor strict-capability-match" commands. */ | |
13115 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
13116 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
13117 | ||
13118 | /* "neighbor timers" commands. */ | |
13119 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
13120 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
13121 | ||
13122 | /* "neighbor timers connect" commands. */ | |
13123 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
13124 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
13125 | ||
13126 | /* "neighbor advertisement-interval" commands. */ | |
13127 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
13128 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
13129 | ||
13130 | /* "neighbor interface" commands. */ | |
13131 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
13132 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
13133 | ||
13134 | /* "neighbor distribute" commands. */ | |
13135 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
13136 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
13137 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
13138 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
13139 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
13140 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
13141 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
13142 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
13143 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
13144 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
13145 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
13146 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
13147 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
13148 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
13149 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
13150 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
13151 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
13152 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
13153 | ||
13154 | /* "neighbor prefix-list" commands. */ | |
13155 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
13156 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
13157 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
13158 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
13159 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
13160 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
13161 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); | |
13162 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
13163 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
13164 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
13165 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); | |
13166 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
13167 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); | |
13168 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
13169 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); | |
13170 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
13171 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); | |
13172 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
7c40bf39 | 13173 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
13174 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); | |
13175 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); | |
13176 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); | |
d62a17ae | 13177 | |
13178 | /* "neighbor filter-list" commands. */ | |
13179 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
13180 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
13181 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
13182 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
13183 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
13184 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
13185 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
13186 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
13187 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
13188 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
13189 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
13190 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
13191 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
13192 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
13193 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
13194 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
13195 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
13196 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 13197 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
13198 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
13199 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
13200 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 13201 | |
13202 | /* "neighbor route-map" commands. */ | |
13203 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); | |
13204 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
13205 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
13206 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
13207 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
13208 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
13209 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); | |
13210 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
13211 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
13212 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
13213 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); | |
13214 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
13215 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); | |
13216 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
13217 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); | |
13218 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
13219 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); | |
13220 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
7c40bf39 | 13221 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
13222 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); | |
13223 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); | |
13224 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); | |
d37ba549 MK |
13225 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
13226 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); | |
d62a17ae | 13227 | |
13228 | /* "neighbor unsuppress-map" commands. */ | |
13229 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
13230 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
13231 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
13232 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
13233 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
13234 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
13235 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
13236 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
13237 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
13238 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
13239 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
13240 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
13241 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
13242 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
13243 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
13244 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
13245 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
13246 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
13247 | ||
13248 | /* "neighbor maximum-prefix" commands. */ | |
13249 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
13250 | install_element(BGP_NODE, | |
13251 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
13252 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
13253 | install_element(BGP_NODE, | |
13254 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
13255 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
13256 | install_element(BGP_NODE, | |
13257 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
13258 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
13259 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
13260 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13261 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13262 | install_element(BGP_IPV4_NODE, | |
13263 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13264 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13265 | install_element(BGP_IPV4_NODE, | |
13266 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13267 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
13268 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
13269 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13270 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13271 | install_element(BGP_IPV4M_NODE, | |
13272 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13273 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13274 | install_element(BGP_IPV4M_NODE, | |
13275 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13276 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
13277 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
13278 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13279 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13280 | install_element(BGP_IPV4L_NODE, | |
13281 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13282 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13283 | install_element(BGP_IPV4L_NODE, | |
13284 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13285 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
13286 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
13287 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13288 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13289 | install_element(BGP_IPV6_NODE, | |
13290 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13291 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13292 | install_element(BGP_IPV6_NODE, | |
13293 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13294 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
13295 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
13296 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13297 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13298 | install_element(BGP_IPV6M_NODE, | |
13299 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13300 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13301 | install_element(BGP_IPV6M_NODE, | |
13302 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13303 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
13304 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
13305 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13306 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13307 | install_element(BGP_IPV6L_NODE, | |
13308 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13309 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13310 | install_element(BGP_IPV6L_NODE, | |
13311 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13312 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
13313 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
13314 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13315 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13316 | install_element(BGP_VPNV4_NODE, | |
13317 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13318 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13319 | install_element(BGP_VPNV4_NODE, | |
13320 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13321 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
13322 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
13323 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13324 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13325 | install_element(BGP_VPNV6_NODE, | |
13326 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13327 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13328 | install_element(BGP_VPNV6_NODE, | |
13329 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13330 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
13331 | ||
13332 | /* "neighbor allowas-in" */ | |
13333 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
13334 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
13335 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
13336 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
13337 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
13338 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
13339 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
13340 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
13341 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
13342 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
13343 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
13344 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
13345 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
13346 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
13347 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
13348 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
13349 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
13350 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
13351 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
13352 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
13353 | ||
13354 | /* address-family commands. */ | |
13355 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
13356 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 13357 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 13358 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
13359 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 13360 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 13361 | |
d62a17ae | 13362 | install_element(BGP_NODE, &address_family_evpn_cmd); |
13363 | ||
13364 | /* "exit-address-family" command. */ | |
13365 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
13366 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
13367 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
13368 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
13369 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
13370 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
13371 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
13372 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 13373 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
13374 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 13375 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
13376 | ||
13377 | /* "clear ip bgp commands" */ | |
13378 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
13379 | ||
13380 | /* clear ip bgp prefix */ | |
13381 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
13382 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
13383 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
13384 | ||
13385 | /* "show [ip] bgp summary" commands. */ | |
13386 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
d62a17ae | 13387 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 13388 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 13389 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
13390 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 13391 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
13392 | ||
13393 | /* "show [ip] bgp neighbors" commands. */ | |
13394 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
13395 | ||
13396 | /* "show [ip] bgp peer-group" commands. */ | |
13397 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
13398 | ||
13399 | /* "show [ip] bgp paths" commands. */ | |
13400 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
13401 | ||
13402 | /* "show [ip] bgp community" commands. */ | |
13403 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
13404 | ||
13405 | /* "show ip bgp large-community" commands. */ | |
13406 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
13407 | /* "show [ip] bgp attribute-info" commands. */ | |
13408 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 13409 | /* "show [ip] bgp route-leak" command */ |
13410 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 13411 | |
13412 | /* "redistribute" commands. */ | |
13413 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
13414 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
13415 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
13416 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
13417 | install_element(BGP_NODE, | |
13418 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
13419 | install_element(BGP_NODE, | |
13420 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
13421 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
13422 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
13423 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
13424 | install_element(BGP_NODE, | |
13425 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
13426 | install_element(BGP_NODE, | |
13427 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
13428 | install_element(BGP_NODE, | |
13429 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
13430 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
13431 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
13432 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
13433 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
13434 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
13435 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
13436 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
13437 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
13438 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
13439 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
13440 | install_element(BGP_IPV4_NODE, | |
13441 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
13442 | install_element(BGP_IPV4_NODE, | |
13443 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
13444 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
13445 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
13446 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
13447 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
13448 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
13449 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
13450 | ||
b9c7bc5a PZ |
13451 | /* import|export vpn [route-map WORD] */ |
13452 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
13453 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 13454 | |
12a844a5 DS |
13455 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
13456 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
13457 | ||
d62a17ae | 13458 | /* ttl_security commands */ |
13459 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
13460 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
13461 | ||
13462 | /* "show [ip] bgp memory" commands. */ | |
13463 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
13464 | ||
acf71666 MK |
13465 | /* "show bgp martian next-hop" */ |
13466 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
13467 | ||
d62a17ae | 13468 | /* "show [ip] bgp views" commands. */ |
13469 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
13470 | ||
13471 | /* "show [ip] bgp vrfs" commands. */ | |
13472 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
13473 | ||
13474 | /* Community-list. */ | |
13475 | community_list_vty(); | |
ddb5b488 PZ |
13476 | |
13477 | /* vpn-policy commands */ | |
b9c7bc5a PZ |
13478 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
13479 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
13480 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
13481 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
13482 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
13483 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
13484 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
13485 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
13486 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
13487 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
13488 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
13489 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 13490 | |
301ad80a PG |
13491 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
13492 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
13493 | ||
b9c7bc5a PZ |
13494 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
13495 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
13496 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
13497 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
13498 | install_element(BGP_IPV4_NODE, &af_no_nexthop_vpn_export_cmd); | |
13499 | install_element(BGP_IPV6_NODE, &af_no_nexthop_vpn_export_cmd); | |
13500 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); | |
13501 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
13502 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
13503 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
13504 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
13505 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
718e3744 | 13506 | } |
6b0655a2 | 13507 | |
718e3744 | 13508 | #include "memory.h" |
13509 | #include "bgp_regex.h" | |
13510 | #include "bgp_clist.h" | |
13511 | #include "bgp_ecommunity.h" | |
13512 | ||
13513 | /* VTY functions. */ | |
13514 | ||
13515 | /* Direction value to string conversion. */ | |
d62a17ae | 13516 | static const char *community_direct_str(int direct) |
13517 | { | |
13518 | switch (direct) { | |
13519 | case COMMUNITY_DENY: | |
13520 | return "deny"; | |
13521 | case COMMUNITY_PERMIT: | |
13522 | return "permit"; | |
13523 | default: | |
13524 | return "unknown"; | |
13525 | } | |
718e3744 | 13526 | } |
13527 | ||
13528 | /* Display error string. */ | |
d62a17ae | 13529 | static void community_list_perror(struct vty *vty, int ret) |
13530 | { | |
13531 | switch (ret) { | |
13532 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
13533 | vty_out(vty, "%% Can't find community-list\n"); | |
13534 | break; | |
13535 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
13536 | vty_out(vty, "%% Malformed community-list value\n"); | |
13537 | break; | |
13538 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
13539 | vty_out(vty, | |
13540 | "%% Community name conflict, previously defined as standard community\n"); | |
13541 | break; | |
13542 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
13543 | vty_out(vty, | |
13544 | "%% Community name conflict, previously defined as expanded community\n"); | |
13545 | break; | |
13546 | } | |
718e3744 | 13547 | } |
13548 | ||
5bf15956 DW |
13549 | /* "community-list" keyword help string. */ |
13550 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
13551 | ||
5bf15956 | 13552 | /* ip community-list standard */ |
718e3744 | 13553 | DEFUN (ip_community_list_standard, |
13554 | ip_community_list_standard_cmd, | |
e961923c | 13555 | "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 13556 | IP_STR |
13557 | COMMUNITY_LIST_STR | |
13558 | "Community list number (standard)\n" | |
5bf15956 | 13559 | "Add an standard community-list entry\n" |
718e3744 | 13560 | "Community list name\n" |
13561 | "Specify community to reject\n" | |
13562 | "Specify community to accept\n" | |
13563 | COMMUNITY_VAL_STR) | |
13564 | { | |
d62a17ae | 13565 | char *cl_name_or_number = NULL; |
13566 | int direct = 0; | |
13567 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 13568 | |
d62a17ae | 13569 | int idx = 0; |
13570 | argv_find(argv, argc, "(1-99)", &idx); | |
13571 | argv_find(argv, argc, "WORD", &idx); | |
13572 | cl_name_or_number = argv[idx]->arg; | |
13573 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13574 | : COMMUNITY_DENY; | |
13575 | argv_find(argv, argc, "AA:NN", &idx); | |
13576 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 13577 | |
d62a17ae | 13578 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
13579 | style); | |
42f914d4 | 13580 | |
d62a17ae | 13581 | XFREE(MTYPE_TMP, str); |
42f914d4 | 13582 | |
d62a17ae | 13583 | if (ret < 0) { |
13584 | /* Display error string. */ | |
13585 | community_list_perror(vty, ret); | |
13586 | return CMD_WARNING_CONFIG_FAILED; | |
13587 | } | |
42f914d4 | 13588 | |
d62a17ae | 13589 | return CMD_SUCCESS; |
718e3744 | 13590 | } |
13591 | ||
fee6e4e4 | 13592 | DEFUN (no_ip_community_list_standard_all, |
13593 | no_ip_community_list_standard_all_cmd, | |
e961923c | 13594 | "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 13595 | NO_STR |
13596 | IP_STR | |
13597 | COMMUNITY_LIST_STR | |
13598 | "Community list number (standard)\n" | |
5bf15956 DW |
13599 | "Add an standard community-list entry\n" |
13600 | "Community list name\n" | |
718e3744 | 13601 | "Specify community to reject\n" |
13602 | "Specify community to accept\n" | |
13603 | COMMUNITY_VAL_STR) | |
13604 | { | |
d62a17ae | 13605 | char *cl_name_or_number = NULL; |
13606 | int direct = 0; | |
13607 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 13608 | |
d62a17ae | 13609 | int idx = 0; |
13610 | argv_find(argv, argc, "(1-99)", &idx); | |
13611 | argv_find(argv, argc, "WORD", &idx); | |
13612 | cl_name_or_number = argv[idx]->arg; | |
13613 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13614 | : COMMUNITY_DENY; | |
13615 | argv_find(argv, argc, "AA:NN", &idx); | |
13616 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 13617 | |
d62a17ae | 13618 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
7298a8e1 | 13619 | direct, style); |
42f914d4 | 13620 | |
d62a17ae | 13621 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 13622 | |
d62a17ae | 13623 | if (ret < 0) { |
13624 | community_list_perror(vty, ret); | |
13625 | return CMD_WARNING_CONFIG_FAILED; | |
13626 | } | |
42f914d4 | 13627 | |
d62a17ae | 13628 | return CMD_SUCCESS; |
718e3744 | 13629 | } |
13630 | ||
5bf15956 DW |
13631 | /* ip community-list expanded */ |
13632 | DEFUN (ip_community_list_expanded_all, | |
13633 | ip_community_list_expanded_all_cmd, | |
42f914d4 | 13634 | "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 13635 | IP_STR |
13636 | COMMUNITY_LIST_STR | |
13637 | "Community list number (expanded)\n" | |
5bf15956 | 13638 | "Add an expanded community-list entry\n" |
718e3744 | 13639 | "Community list name\n" |
13640 | "Specify community to reject\n" | |
13641 | "Specify community to accept\n" | |
13642 | COMMUNITY_VAL_STR) | |
13643 | { | |
d62a17ae | 13644 | char *cl_name_or_number = NULL; |
13645 | int direct = 0; | |
13646 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 13647 | |
d62a17ae | 13648 | int idx = 0; |
13649 | argv_find(argv, argc, "(100-500)", &idx); | |
13650 | argv_find(argv, argc, "WORD", &idx); | |
13651 | cl_name_or_number = argv[idx]->arg; | |
13652 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13653 | : COMMUNITY_DENY; | |
13654 | argv_find(argv, argc, "AA:NN", &idx); | |
13655 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 13656 | |
d62a17ae | 13657 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
13658 | style); | |
42f914d4 | 13659 | |
d62a17ae | 13660 | XFREE(MTYPE_TMP, str); |
42f914d4 | 13661 | |
d62a17ae | 13662 | if (ret < 0) { |
13663 | /* Display error string. */ | |
13664 | community_list_perror(vty, ret); | |
13665 | return CMD_WARNING_CONFIG_FAILED; | |
13666 | } | |
42f914d4 | 13667 | |
d62a17ae | 13668 | return CMD_SUCCESS; |
718e3744 | 13669 | } |
13670 | ||
5bf15956 DW |
13671 | DEFUN (no_ip_community_list_expanded_all, |
13672 | no_ip_community_list_expanded_all_cmd, | |
42f914d4 | 13673 | "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 13674 | NO_STR |
13675 | IP_STR | |
13676 | COMMUNITY_LIST_STR | |
5bf15956 DW |
13677 | "Community list number (expanded)\n" |
13678 | "Add an expanded community-list entry\n" | |
718e3744 | 13679 | "Community list name\n" |
13680 | "Specify community to reject\n" | |
13681 | "Specify community to accept\n" | |
5bf15956 | 13682 | COMMUNITY_VAL_STR) |
718e3744 | 13683 | { |
d62a17ae | 13684 | char *cl_name_or_number = NULL; |
13685 | int direct = 0; | |
13686 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 13687 | |
d62a17ae | 13688 | int idx = 0; |
13689 | argv_find(argv, argc, "(100-500)", &idx); | |
13690 | argv_find(argv, argc, "WORD", &idx); | |
13691 | cl_name_or_number = argv[idx]->arg; | |
13692 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13693 | : COMMUNITY_DENY; | |
13694 | argv_find(argv, argc, "AA:NN", &idx); | |
13695 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 13696 | |
d62a17ae | 13697 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
7298a8e1 | 13698 | direct, style); |
42f914d4 | 13699 | |
d62a17ae | 13700 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 13701 | |
d62a17ae | 13702 | if (ret < 0) { |
13703 | community_list_perror(vty, ret); | |
13704 | return CMD_WARNING_CONFIG_FAILED; | |
13705 | } | |
42f914d4 | 13706 | |
d62a17ae | 13707 | return CMD_SUCCESS; |
718e3744 | 13708 | } |
13709 | ||
8d9b8ed9 PM |
13710 | /* Return configuration string of community-list entry. */ |
13711 | static const char *community_list_config_str(struct community_entry *entry) | |
13712 | { | |
13713 | const char *str; | |
13714 | ||
13715 | if (entry->any) | |
13716 | str = ""; | |
13717 | else { | |
13718 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
13719 | str = community_str(entry->u.com, false); | |
13720 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
13721 | str = lcommunity_str(entry->u.lcom, false); | |
13722 | else | |
13723 | str = entry->config; | |
13724 | } | |
13725 | return str; | |
13726 | } | |
13727 | ||
d62a17ae | 13728 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 13729 | { |
d62a17ae | 13730 | struct community_entry *entry; |
718e3744 | 13731 | |
d62a17ae | 13732 | for (entry = list->head; entry; entry = entry->next) { |
13733 | if (entry == list->head) { | |
13734 | if (all_digit(list->name)) | |
13735 | vty_out(vty, "Community %s list %s\n", | |
13736 | entry->style == COMMUNITY_LIST_STANDARD | |
13737 | ? "standard" | |
13738 | : "(expanded) access", | |
13739 | list->name); | |
13740 | else | |
13741 | vty_out(vty, "Named Community %s list %s\n", | |
13742 | entry->style == COMMUNITY_LIST_STANDARD | |
13743 | ? "standard" | |
13744 | : "expanded", | |
13745 | list->name); | |
13746 | } | |
13747 | if (entry->any) | |
13748 | vty_out(vty, " %s\n", | |
13749 | community_direct_str(entry->direct)); | |
13750 | else | |
13751 | vty_out(vty, " %s %s\n", | |
13752 | community_direct_str(entry->direct), | |
8d9b8ed9 | 13753 | community_list_config_str(entry)); |
d62a17ae | 13754 | } |
718e3744 | 13755 | } |
13756 | ||
13757 | DEFUN (show_ip_community_list, | |
13758 | show_ip_community_list_cmd, | |
13759 | "show ip community-list", | |
13760 | SHOW_STR | |
13761 | IP_STR | |
13762 | "List community-list\n") | |
13763 | { | |
d62a17ae | 13764 | struct community_list *list; |
13765 | struct community_list_master *cm; | |
718e3744 | 13766 | |
d62a17ae | 13767 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
13768 | if (!cm) | |
13769 | return CMD_SUCCESS; | |
718e3744 | 13770 | |
d62a17ae | 13771 | for (list = cm->num.head; list; list = list->next) |
13772 | community_list_show(vty, list); | |
718e3744 | 13773 | |
d62a17ae | 13774 | for (list = cm->str.head; list; list = list->next) |
13775 | community_list_show(vty, list); | |
718e3744 | 13776 | |
d62a17ae | 13777 | return CMD_SUCCESS; |
718e3744 | 13778 | } |
13779 | ||
13780 | DEFUN (show_ip_community_list_arg, | |
13781 | show_ip_community_list_arg_cmd, | |
6147e2c6 | 13782 | "show ip community-list <(1-500)|WORD>", |
718e3744 | 13783 | SHOW_STR |
13784 | IP_STR | |
13785 | "List community-list\n" | |
13786 | "Community-list number\n" | |
13787 | "Community-list name\n") | |
13788 | { | |
d62a17ae | 13789 | int idx_comm_list = 3; |
13790 | struct community_list *list; | |
718e3744 | 13791 | |
d62a17ae | 13792 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, |
13793 | COMMUNITY_LIST_MASTER); | |
13794 | if (!list) { | |
13795 | vty_out(vty, "%% Can't find community-list\n"); | |
13796 | return CMD_WARNING; | |
13797 | } | |
718e3744 | 13798 | |
d62a17ae | 13799 | community_list_show(vty, list); |
718e3744 | 13800 | |
d62a17ae | 13801 | return CMD_SUCCESS; |
718e3744 | 13802 | } |
6b0655a2 | 13803 | |
57d187bc JS |
13804 | /* |
13805 | * Large Community code. | |
13806 | */ | |
d62a17ae | 13807 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
13808 | struct cmd_token **argv, int style, | |
13809 | int reject_all_digit_name) | |
13810 | { | |
13811 | int ret; | |
13812 | int direct; | |
13813 | char *str; | |
13814 | int idx = 0; | |
13815 | char *cl_name; | |
13816 | ||
13817 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13818 | : COMMUNITY_DENY; | |
13819 | ||
13820 | /* All digit name check. */ | |
13821 | idx = 0; | |
13822 | argv_find(argv, argc, "WORD", &idx); | |
13823 | argv_find(argv, argc, "(1-99)", &idx); | |
13824 | argv_find(argv, argc, "(100-500)", &idx); | |
13825 | cl_name = argv[idx]->arg; | |
13826 | if (reject_all_digit_name && all_digit(cl_name)) { | |
13827 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
13828 | return CMD_WARNING_CONFIG_FAILED; | |
13829 | } | |
13830 | ||
13831 | idx = 0; | |
13832 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
13833 | argv_find(argv, argc, "LINE", &idx); | |
13834 | /* Concat community string argument. */ | |
13835 | if (idx) | |
13836 | str = argv_concat(argv, argc, idx); | |
13837 | else | |
13838 | str = NULL; | |
13839 | ||
13840 | ret = lcommunity_list_set(bgp_clist, cl_name, str, direct, style); | |
13841 | ||
13842 | /* Free temporary community list string allocated by | |
13843 | argv_concat(). */ | |
13844 | if (str) | |
13845 | XFREE(MTYPE_TMP, str); | |
13846 | ||
13847 | if (ret < 0) { | |
13848 | community_list_perror(vty, ret); | |
13849 | return CMD_WARNING_CONFIG_FAILED; | |
13850 | } | |
13851 | return CMD_SUCCESS; | |
13852 | } | |
13853 | ||
13854 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
13855 | struct cmd_token **argv, int style) | |
13856 | { | |
13857 | int ret; | |
13858 | int direct = 0; | |
13859 | char *str = NULL; | |
13860 | int idx = 0; | |
13861 | ||
13862 | argv_find(argv, argc, "permit", &idx); | |
13863 | argv_find(argv, argc, "deny", &idx); | |
13864 | ||
13865 | if (idx) { | |
13866 | /* Check the list direct. */ | |
13867 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
13868 | direct = COMMUNITY_PERMIT; | |
13869 | else | |
13870 | direct = COMMUNITY_DENY; | |
13871 | ||
13872 | idx = 0; | |
13873 | argv_find(argv, argc, "LINE", &idx); | |
13874 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
13875 | /* Concat community string argument. */ | |
13876 | str = argv_concat(argv, argc, idx); | |
13877 | } | |
13878 | ||
13879 | idx = 0; | |
13880 | argv_find(argv, argc, "(1-99)", &idx); | |
13881 | argv_find(argv, argc, "(100-500)", &idx); | |
13882 | argv_find(argv, argc, "WORD", &idx); | |
13883 | ||
13884 | /* Unset community list. */ | |
13885 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, direct, | |
13886 | style); | |
13887 | ||
13888 | /* Free temporary community list string allocated by | |
13889 | argv_concat(). */ | |
13890 | if (str) | |
13891 | XFREE(MTYPE_TMP, str); | |
13892 | ||
13893 | if (ret < 0) { | |
13894 | community_list_perror(vty, ret); | |
13895 | return CMD_WARNING_CONFIG_FAILED; | |
13896 | } | |
13897 | ||
13898 | return CMD_SUCCESS; | |
57d187bc JS |
13899 | } |
13900 | ||
13901 | /* "large-community-list" keyword help string. */ | |
13902 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
13903 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
13904 | ||
13905 | DEFUN (ip_lcommunity_list_standard, | |
13906 | ip_lcommunity_list_standard_cmd, | |
52951b63 DS |
13907 | "ip large-community-list (1-99) <deny|permit>", |
13908 | IP_STR | |
13909 | LCOMMUNITY_LIST_STR | |
13910 | "Large Community list number (standard)\n" | |
13911 | "Specify large community to reject\n" | |
7111c1a0 | 13912 | "Specify large community to accept\n") |
52951b63 | 13913 | { |
d62a17ae | 13914 | return lcommunity_list_set_vty(vty, argc, argv, |
13915 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
13916 | } |
13917 | ||
13918 | DEFUN (ip_lcommunity_list_standard1, | |
13919 | ip_lcommunity_list_standard1_cmd, | |
13920 | "ip large-community-list (1-99) <deny|permit> AA:BB:CC...", | |
57d187bc JS |
13921 | IP_STR |
13922 | LCOMMUNITY_LIST_STR | |
13923 | "Large Community list number (standard)\n" | |
13924 | "Specify large community to reject\n" | |
13925 | "Specify large community to accept\n" | |
13926 | LCOMMUNITY_VAL_STR) | |
13927 | { | |
d62a17ae | 13928 | return lcommunity_list_set_vty(vty, argc, argv, |
13929 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
57d187bc JS |
13930 | } |
13931 | ||
13932 | DEFUN (ip_lcommunity_list_expanded, | |
13933 | ip_lcommunity_list_expanded_cmd, | |
13934 | "ip large-community-list (100-500) <deny|permit> LINE...", | |
13935 | IP_STR | |
13936 | LCOMMUNITY_LIST_STR | |
13937 | "Large Community list number (expanded)\n" | |
13938 | "Specify large community to reject\n" | |
13939 | "Specify large community to accept\n" | |
13940 | "An ordered list as a regular-expression\n") | |
13941 | { | |
d62a17ae | 13942 | return lcommunity_list_set_vty(vty, argc, argv, |
13943 | LARGE_COMMUNITY_LIST_EXPANDED, 0); | |
57d187bc JS |
13944 | } |
13945 | ||
13946 | DEFUN (ip_lcommunity_list_name_standard, | |
13947 | ip_lcommunity_list_name_standard_cmd, | |
52951b63 DS |
13948 | "ip large-community-list standard WORD <deny|permit>", |
13949 | IP_STR | |
13950 | LCOMMUNITY_LIST_STR | |
13951 | "Specify standard large-community-list\n" | |
13952 | "Large Community list name\n" | |
13953 | "Specify large community to reject\n" | |
13954 | "Specify large community to accept\n") | |
13955 | { | |
d62a17ae | 13956 | return lcommunity_list_set_vty(vty, argc, argv, |
13957 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
13958 | } |
13959 | ||
13960 | DEFUN (ip_lcommunity_list_name_standard1, | |
13961 | ip_lcommunity_list_name_standard1_cmd, | |
13962 | "ip large-community-list standard WORD <deny|permit> AA:BB:CC...", | |
57d187bc JS |
13963 | IP_STR |
13964 | LCOMMUNITY_LIST_STR | |
13965 | "Specify standard large-community-list\n" | |
13966 | "Large Community list name\n" | |
13967 | "Specify large community to reject\n" | |
13968 | "Specify large community to accept\n" | |
13969 | LCOMMUNITY_VAL_STR) | |
13970 | { | |
d62a17ae | 13971 | return lcommunity_list_set_vty(vty, argc, argv, |
13972 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
57d187bc JS |
13973 | } |
13974 | ||
13975 | DEFUN (ip_lcommunity_list_name_expanded, | |
13976 | ip_lcommunity_list_name_expanded_cmd, | |
13977 | "ip large-community-list expanded WORD <deny|permit> LINE...", | |
13978 | IP_STR | |
13979 | LCOMMUNITY_LIST_STR | |
13980 | "Specify expanded large-community-list\n" | |
13981 | "Large Community list name\n" | |
13982 | "Specify large community to reject\n" | |
13983 | "Specify large community to accept\n" | |
13984 | "An ordered list as a regular-expression\n") | |
13985 | { | |
d62a17ae | 13986 | return lcommunity_list_set_vty(vty, argc, argv, |
13987 | LARGE_COMMUNITY_LIST_EXPANDED, 1); | |
57d187bc JS |
13988 | } |
13989 | ||
13990 | DEFUN (no_ip_lcommunity_list_standard_all, | |
13991 | no_ip_lcommunity_list_standard_all_cmd, | |
13992 | "no ip large-community-list <(1-99)|(100-500)|WORD>", | |
13993 | NO_STR | |
13994 | IP_STR | |
13995 | LCOMMUNITY_LIST_STR | |
13996 | "Large Community list number (standard)\n" | |
13997 | "Large Community list number (expanded)\n" | |
13998 | "Large Community list name\n") | |
13999 | { | |
d62a17ae | 14000 | return lcommunity_list_unset_vty(vty, argc, argv, |
14001 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
14002 | } |
14003 | ||
14004 | DEFUN (no_ip_lcommunity_list_name_expanded_all, | |
14005 | no_ip_lcommunity_list_name_expanded_all_cmd, | |
14006 | "no ip large-community-list expanded WORD", | |
14007 | NO_STR | |
14008 | IP_STR | |
14009 | LCOMMUNITY_LIST_STR | |
14010 | "Specify expanded large-community-list\n" | |
14011 | "Large Community list name\n") | |
14012 | { | |
d62a17ae | 14013 | return lcommunity_list_unset_vty(vty, argc, argv, |
14014 | LARGE_COMMUNITY_LIST_EXPANDED); | |
57d187bc JS |
14015 | } |
14016 | ||
14017 | DEFUN (no_ip_lcommunity_list_standard, | |
14018 | no_ip_lcommunity_list_standard_cmd, | |
14019 | "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...", | |
14020 | NO_STR | |
14021 | IP_STR | |
14022 | LCOMMUNITY_LIST_STR | |
14023 | "Large Community list number (standard)\n" | |
14024 | "Specify large community to reject\n" | |
14025 | "Specify large community to accept\n" | |
14026 | LCOMMUNITY_VAL_STR) | |
14027 | { | |
d62a17ae | 14028 | return lcommunity_list_unset_vty(vty, argc, argv, |
14029 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
14030 | } |
14031 | ||
14032 | DEFUN (no_ip_lcommunity_list_expanded, | |
14033 | no_ip_lcommunity_list_expanded_cmd, | |
14034 | "no ip large-community-list (100-500) <deny|permit> LINE...", | |
14035 | NO_STR | |
14036 | IP_STR | |
14037 | LCOMMUNITY_LIST_STR | |
14038 | "Large Community list number (expanded)\n" | |
14039 | "Specify large community to reject\n" | |
14040 | "Specify large community to accept\n" | |
14041 | "An ordered list as a regular-expression\n") | |
14042 | { | |
d62a17ae | 14043 | return lcommunity_list_unset_vty(vty, argc, argv, |
14044 | LARGE_COMMUNITY_LIST_EXPANDED); | |
57d187bc JS |
14045 | } |
14046 | ||
14047 | DEFUN (no_ip_lcommunity_list_name_standard, | |
14048 | no_ip_lcommunity_list_name_standard_cmd, | |
14049 | "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...", | |
14050 | NO_STR | |
14051 | IP_STR | |
14052 | LCOMMUNITY_LIST_STR | |
14053 | "Specify standard large-community-list\n" | |
14054 | "Large Community list name\n" | |
14055 | "Specify large community to reject\n" | |
14056 | "Specify large community to accept\n" | |
14057 | LCOMMUNITY_VAL_STR) | |
14058 | { | |
d62a17ae | 14059 | return lcommunity_list_unset_vty(vty, argc, argv, |
14060 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
14061 | } |
14062 | ||
14063 | DEFUN (no_ip_lcommunity_list_name_expanded, | |
14064 | no_ip_lcommunity_list_name_expanded_cmd, | |
14065 | "no ip large-community-list expanded WORD <deny|permit> LINE...", | |
14066 | NO_STR | |
14067 | IP_STR | |
14068 | LCOMMUNITY_LIST_STR | |
14069 | "Specify expanded large-community-list\n" | |
14070 | "Large community list name\n" | |
14071 | "Specify large community to reject\n" | |
14072 | "Specify large community to accept\n" | |
14073 | "An ordered list as a regular-expression\n") | |
14074 | { | |
d62a17ae | 14075 | return lcommunity_list_unset_vty(vty, argc, argv, |
14076 | LARGE_COMMUNITY_LIST_EXPANDED); | |
14077 | } | |
14078 | ||
14079 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) | |
14080 | { | |
14081 | struct community_entry *entry; | |
14082 | ||
14083 | for (entry = list->head; entry; entry = entry->next) { | |
14084 | if (entry == list->head) { | |
14085 | if (all_digit(list->name)) | |
14086 | vty_out(vty, "Large community %s list %s\n", | |
14087 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
14088 | ? "standard" | |
14089 | : "(expanded) access", | |
14090 | list->name); | |
14091 | else | |
14092 | vty_out(vty, | |
14093 | "Named large community %s list %s\n", | |
14094 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
14095 | ? "standard" | |
14096 | : "expanded", | |
14097 | list->name); | |
14098 | } | |
14099 | if (entry->any) | |
14100 | vty_out(vty, " %s\n", | |
14101 | community_direct_str(entry->direct)); | |
14102 | else | |
14103 | vty_out(vty, " %s %s\n", | |
14104 | community_direct_str(entry->direct), | |
8d9b8ed9 | 14105 | community_list_config_str(entry)); |
d62a17ae | 14106 | } |
57d187bc JS |
14107 | } |
14108 | ||
14109 | DEFUN (show_ip_lcommunity_list, | |
14110 | show_ip_lcommunity_list_cmd, | |
14111 | "show ip large-community-list", | |
14112 | SHOW_STR | |
14113 | IP_STR | |
14114 | "List large-community list\n") | |
14115 | { | |
d62a17ae | 14116 | struct community_list *list; |
14117 | struct community_list_master *cm; | |
57d187bc | 14118 | |
d62a17ae | 14119 | cm = community_list_master_lookup(bgp_clist, |
14120 | LARGE_COMMUNITY_LIST_MASTER); | |
14121 | if (!cm) | |
14122 | return CMD_SUCCESS; | |
57d187bc | 14123 | |
d62a17ae | 14124 | for (list = cm->num.head; list; list = list->next) |
14125 | lcommunity_list_show(vty, list); | |
57d187bc | 14126 | |
d62a17ae | 14127 | for (list = cm->str.head; list; list = list->next) |
14128 | lcommunity_list_show(vty, list); | |
57d187bc | 14129 | |
d62a17ae | 14130 | return CMD_SUCCESS; |
57d187bc JS |
14131 | } |
14132 | ||
14133 | DEFUN (show_ip_lcommunity_list_arg, | |
14134 | show_ip_lcommunity_list_arg_cmd, | |
14135 | "show ip large-community-list <(1-500)|WORD>", | |
14136 | SHOW_STR | |
14137 | IP_STR | |
14138 | "List large-community list\n" | |
14139 | "large-community-list number\n" | |
14140 | "large-community-list name\n") | |
14141 | { | |
d62a17ae | 14142 | struct community_list *list; |
57d187bc | 14143 | |
d62a17ae | 14144 | list = community_list_lookup(bgp_clist, argv[3]->arg, |
14145 | LARGE_COMMUNITY_LIST_MASTER); | |
14146 | if (!list) { | |
14147 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
14148 | return CMD_WARNING; | |
14149 | } | |
57d187bc | 14150 | |
d62a17ae | 14151 | lcommunity_list_show(vty, list); |
57d187bc | 14152 | |
d62a17ae | 14153 | return CMD_SUCCESS; |
57d187bc JS |
14154 | } |
14155 | ||
718e3744 | 14156 | /* "extcommunity-list" keyword help string. */ |
14157 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
14158 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
14159 | ||
14160 | DEFUN (ip_extcommunity_list_standard, | |
14161 | ip_extcommunity_list_standard_cmd, | |
e961923c | 14162 | "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 14163 | IP_STR |
14164 | EXTCOMMUNITY_LIST_STR | |
14165 | "Extended Community list number (standard)\n" | |
718e3744 | 14166 | "Specify standard extcommunity-list\n" |
5bf15956 | 14167 | "Community list name\n" |
718e3744 | 14168 | "Specify community to reject\n" |
14169 | "Specify community to accept\n" | |
14170 | EXTCOMMUNITY_VAL_STR) | |
14171 | { | |
d62a17ae | 14172 | int style = EXTCOMMUNITY_LIST_STANDARD; |
14173 | int direct = 0; | |
14174 | char *cl_number_or_name = NULL; | |
42f914d4 | 14175 | |
d62a17ae | 14176 | int idx = 0; |
14177 | argv_find(argv, argc, "(1-99)", &idx); | |
14178 | argv_find(argv, argc, "WORD", &idx); | |
14179 | cl_number_or_name = argv[idx]->arg; | |
14180 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14181 | : COMMUNITY_DENY; | |
14182 | argv_find(argv, argc, "AA:NN", &idx); | |
14183 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14184 | |
d62a17ae | 14185 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
14186 | direct, style); | |
42f914d4 | 14187 | |
d62a17ae | 14188 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14189 | |
d62a17ae | 14190 | if (ret < 0) { |
14191 | community_list_perror(vty, ret); | |
14192 | return CMD_WARNING_CONFIG_FAILED; | |
14193 | } | |
42f914d4 | 14194 | |
d62a17ae | 14195 | return CMD_SUCCESS; |
718e3744 | 14196 | } |
14197 | ||
718e3744 | 14198 | DEFUN (ip_extcommunity_list_name_expanded, |
14199 | ip_extcommunity_list_name_expanded_cmd, | |
e961923c | 14200 | "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 14201 | IP_STR |
14202 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 14203 | "Extended Community list number (expanded)\n" |
718e3744 | 14204 | "Specify expanded extcommunity-list\n" |
14205 | "Extended Community list name\n" | |
14206 | "Specify community to reject\n" | |
14207 | "Specify community to accept\n" | |
14208 | "An ordered list as a regular-expression\n") | |
14209 | { | |
d62a17ae | 14210 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
14211 | int direct = 0; | |
14212 | char *cl_number_or_name = NULL; | |
42f914d4 | 14213 | |
d62a17ae | 14214 | int idx = 0; |
14215 | argv_find(argv, argc, "(100-500)", &idx); | |
14216 | argv_find(argv, argc, "WORD", &idx); | |
14217 | cl_number_or_name = argv[idx]->arg; | |
14218 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14219 | : COMMUNITY_DENY; | |
14220 | argv_find(argv, argc, "LINE", &idx); | |
14221 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14222 | |
d62a17ae | 14223 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
14224 | direct, style); | |
42f914d4 | 14225 | |
d62a17ae | 14226 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14227 | |
d62a17ae | 14228 | if (ret < 0) { |
14229 | community_list_perror(vty, ret); | |
14230 | return CMD_WARNING_CONFIG_FAILED; | |
14231 | } | |
42f914d4 | 14232 | |
d62a17ae | 14233 | return CMD_SUCCESS; |
718e3744 | 14234 | } |
14235 | ||
fee6e4e4 | 14236 | DEFUN (no_ip_extcommunity_list_standard_all, |
14237 | no_ip_extcommunity_list_standard_all_cmd, | |
e961923c | 14238 | "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
813d4307 DW |
14239 | NO_STR |
14240 | IP_STR | |
14241 | EXTCOMMUNITY_LIST_STR | |
14242 | "Extended Community list number (standard)\n" | |
718e3744 | 14243 | "Specify standard extcommunity-list\n" |
5bf15956 | 14244 | "Community list name\n" |
718e3744 | 14245 | "Specify community to reject\n" |
14246 | "Specify community to accept\n" | |
14247 | EXTCOMMUNITY_VAL_STR) | |
14248 | { | |
d62a17ae | 14249 | int style = EXTCOMMUNITY_LIST_STANDARD; |
14250 | int direct = 0; | |
14251 | char *cl_number_or_name = NULL; | |
42f914d4 | 14252 | |
d62a17ae | 14253 | int idx = 0; |
14254 | argv_find(argv, argc, "(1-99)", &idx); | |
14255 | argv_find(argv, argc, "WORD", &idx); | |
14256 | cl_number_or_name = argv[idx]->arg; | |
14257 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14258 | : COMMUNITY_DENY; | |
14259 | argv_find(argv, argc, "AA:NN", &idx); | |
14260 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14261 | |
d62a17ae | 14262 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
7298a8e1 | 14263 | direct, style); |
42f914d4 | 14264 | |
d62a17ae | 14265 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14266 | |
d62a17ae | 14267 | if (ret < 0) { |
14268 | community_list_perror(vty, ret); | |
14269 | return CMD_WARNING_CONFIG_FAILED; | |
14270 | } | |
42f914d4 | 14271 | |
d62a17ae | 14272 | return CMD_SUCCESS; |
718e3744 | 14273 | } |
14274 | ||
5bf15956 DW |
14275 | DEFUN (no_ip_extcommunity_list_expanded_all, |
14276 | no_ip_extcommunity_list_expanded_all_cmd, | |
e961923c | 14277 | "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 14278 | NO_STR |
14279 | IP_STR | |
14280 | EXTCOMMUNITY_LIST_STR | |
14281 | "Extended Community list number (expanded)\n" | |
718e3744 | 14282 | "Specify expanded extcommunity-list\n" |
5bf15956 | 14283 | "Extended Community list name\n" |
718e3744 | 14284 | "Specify community to reject\n" |
14285 | "Specify community to accept\n" | |
14286 | "An ordered list as a regular-expression\n") | |
14287 | { | |
d62a17ae | 14288 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
14289 | int direct = 0; | |
14290 | char *cl_number_or_name = NULL; | |
42f914d4 | 14291 | |
d62a17ae | 14292 | int idx = 0; |
14293 | argv_find(argv, argc, "(100-500)", &idx); | |
14294 | argv_find(argv, argc, "WORD", &idx); | |
14295 | cl_number_or_name = argv[idx]->arg; | |
14296 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14297 | : COMMUNITY_DENY; | |
14298 | argv_find(argv, argc, "LINE", &idx); | |
14299 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14300 | |
d62a17ae | 14301 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
7298a8e1 | 14302 | direct, style); |
42f914d4 | 14303 | |
d62a17ae | 14304 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14305 | |
d62a17ae | 14306 | if (ret < 0) { |
14307 | community_list_perror(vty, ret); | |
14308 | return CMD_WARNING_CONFIG_FAILED; | |
14309 | } | |
42f914d4 | 14310 | |
d62a17ae | 14311 | return CMD_SUCCESS; |
718e3744 | 14312 | } |
14313 | ||
d62a17ae | 14314 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 14315 | { |
d62a17ae | 14316 | struct community_entry *entry; |
718e3744 | 14317 | |
d62a17ae | 14318 | for (entry = list->head; entry; entry = entry->next) { |
14319 | if (entry == list->head) { | |
14320 | if (all_digit(list->name)) | |
14321 | vty_out(vty, "Extended community %s list %s\n", | |
14322 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
14323 | ? "standard" | |
14324 | : "(expanded) access", | |
14325 | list->name); | |
14326 | else | |
14327 | vty_out(vty, | |
14328 | "Named extended community %s list %s\n", | |
14329 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
14330 | ? "standard" | |
14331 | : "expanded", | |
14332 | list->name); | |
14333 | } | |
14334 | if (entry->any) | |
14335 | vty_out(vty, " %s\n", | |
14336 | community_direct_str(entry->direct)); | |
14337 | else | |
14338 | vty_out(vty, " %s %s\n", | |
14339 | community_direct_str(entry->direct), | |
8d9b8ed9 | 14340 | community_list_config_str(entry)); |
d62a17ae | 14341 | } |
718e3744 | 14342 | } |
14343 | ||
14344 | DEFUN (show_ip_extcommunity_list, | |
14345 | show_ip_extcommunity_list_cmd, | |
14346 | "show ip extcommunity-list", | |
14347 | SHOW_STR | |
14348 | IP_STR | |
14349 | "List extended-community list\n") | |
14350 | { | |
d62a17ae | 14351 | struct community_list *list; |
14352 | struct community_list_master *cm; | |
718e3744 | 14353 | |
d62a17ae | 14354 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
14355 | if (!cm) | |
14356 | return CMD_SUCCESS; | |
718e3744 | 14357 | |
d62a17ae | 14358 | for (list = cm->num.head; list; list = list->next) |
14359 | extcommunity_list_show(vty, list); | |
718e3744 | 14360 | |
d62a17ae | 14361 | for (list = cm->str.head; list; list = list->next) |
14362 | extcommunity_list_show(vty, list); | |
718e3744 | 14363 | |
d62a17ae | 14364 | return CMD_SUCCESS; |
718e3744 | 14365 | } |
14366 | ||
14367 | DEFUN (show_ip_extcommunity_list_arg, | |
14368 | show_ip_extcommunity_list_arg_cmd, | |
6147e2c6 | 14369 | "show ip extcommunity-list <(1-500)|WORD>", |
718e3744 | 14370 | SHOW_STR |
14371 | IP_STR | |
14372 | "List extended-community list\n" | |
14373 | "Extcommunity-list number\n" | |
14374 | "Extcommunity-list name\n") | |
14375 | { | |
d62a17ae | 14376 | int idx_comm_list = 3; |
14377 | struct community_list *list; | |
718e3744 | 14378 | |
d62a17ae | 14379 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, |
14380 | EXTCOMMUNITY_LIST_MASTER); | |
14381 | if (!list) { | |
14382 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
14383 | return CMD_WARNING; | |
14384 | } | |
718e3744 | 14385 | |
d62a17ae | 14386 | extcommunity_list_show(vty, list); |
718e3744 | 14387 | |
d62a17ae | 14388 | return CMD_SUCCESS; |
718e3744 | 14389 | } |
6b0655a2 | 14390 | |
718e3744 | 14391 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 14392 | static int community_list_config_write(struct vty *vty) |
14393 | { | |
14394 | struct community_list *list; | |
14395 | struct community_entry *entry; | |
14396 | struct community_list_master *cm; | |
14397 | int write = 0; | |
14398 | ||
14399 | /* Community-list. */ | |
14400 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
14401 | ||
14402 | for (list = cm->num.head; list; list = list->next) | |
14403 | for (entry = list->head; entry; entry = entry->next) { | |
14404 | vty_out(vty, "ip community-list %s %s %s\n", list->name, | |
14405 | community_direct_str(entry->direct), | |
14406 | community_list_config_str(entry)); | |
14407 | write++; | |
14408 | } | |
14409 | for (list = cm->str.head; list; list = list->next) | |
14410 | for (entry = list->head; entry; entry = entry->next) { | |
14411 | vty_out(vty, "ip community-list %s %s %s %s\n", | |
14412 | entry->style == COMMUNITY_LIST_STANDARD | |
14413 | ? "standard" | |
14414 | : "expanded", | |
14415 | list->name, community_direct_str(entry->direct), | |
14416 | community_list_config_str(entry)); | |
14417 | write++; | |
14418 | } | |
14419 | ||
14420 | /* Extcommunity-list. */ | |
14421 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
14422 | ||
14423 | for (list = cm->num.head; list; list = list->next) | |
14424 | for (entry = list->head; entry; entry = entry->next) { | |
14425 | vty_out(vty, "ip extcommunity-list %s %s %s\n", | |
14426 | list->name, community_direct_str(entry->direct), | |
14427 | community_list_config_str(entry)); | |
14428 | write++; | |
14429 | } | |
14430 | for (list = cm->str.head; list; list = list->next) | |
14431 | for (entry = list->head; entry; entry = entry->next) { | |
14432 | vty_out(vty, "ip extcommunity-list %s %s %s %s\n", | |
14433 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
14434 | ? "standard" | |
14435 | : "expanded", | |
14436 | list->name, community_direct_str(entry->direct), | |
14437 | community_list_config_str(entry)); | |
14438 | write++; | |
14439 | } | |
14440 | ||
14441 | ||
14442 | /* lcommunity-list. */ | |
14443 | cm = community_list_master_lookup(bgp_clist, | |
14444 | LARGE_COMMUNITY_LIST_MASTER); | |
14445 | ||
14446 | for (list = cm->num.head; list; list = list->next) | |
14447 | for (entry = list->head; entry; entry = entry->next) { | |
14448 | vty_out(vty, "ip large-community-list %s %s %s\n", | |
14449 | list->name, community_direct_str(entry->direct), | |
14450 | community_list_config_str(entry)); | |
14451 | write++; | |
14452 | } | |
14453 | for (list = cm->str.head; list; list = list->next) | |
14454 | for (entry = list->head; entry; entry = entry->next) { | |
14455 | vty_out(vty, "ip large-community-list %s %s %s %s\n", | |
14456 | entry->style == LARGE_COMMUNITY_LIST_STANDARD | |
14457 | ? "standard" | |
14458 | : "expanded", | |
14459 | list->name, community_direct_str(entry->direct), | |
14460 | community_list_config_str(entry)); | |
14461 | write++; | |
14462 | } | |
14463 | ||
14464 | return write; | |
14465 | } | |
14466 | ||
14467 | static struct cmd_node community_list_node = { | |
14468 | COMMUNITY_LIST_NODE, "", 1 /* Export to vtysh. */ | |
718e3744 | 14469 | }; |
14470 | ||
d62a17ae | 14471 | static void community_list_vty(void) |
14472 | { | |
14473 | install_node(&community_list_node, community_list_config_write); | |
14474 | ||
14475 | /* Community-list. */ | |
14476 | install_element(CONFIG_NODE, &ip_community_list_standard_cmd); | |
14477 | install_element(CONFIG_NODE, &ip_community_list_expanded_all_cmd); | |
14478 | install_element(CONFIG_NODE, &no_ip_community_list_standard_all_cmd); | |
14479 | install_element(CONFIG_NODE, &no_ip_community_list_expanded_all_cmd); | |
14480 | install_element(VIEW_NODE, &show_ip_community_list_cmd); | |
14481 | install_element(VIEW_NODE, &show_ip_community_list_arg_cmd); | |
14482 | ||
14483 | /* Extcommunity-list. */ | |
14484 | install_element(CONFIG_NODE, &ip_extcommunity_list_standard_cmd); | |
14485 | install_element(CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd); | |
14486 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd); | |
14487 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd); | |
14488 | install_element(VIEW_NODE, &show_ip_extcommunity_list_cmd); | |
14489 | install_element(VIEW_NODE, &show_ip_extcommunity_list_arg_cmd); | |
14490 | ||
14491 | /* Large Community List */ | |
14492 | install_element(CONFIG_NODE, &ip_lcommunity_list_standard_cmd); | |
14493 | install_element(CONFIG_NODE, &ip_lcommunity_list_standard1_cmd); | |
14494 | install_element(CONFIG_NODE, &ip_lcommunity_list_expanded_cmd); | |
14495 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_standard_cmd); | |
14496 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_standard1_cmd); | |
14497 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_expanded_cmd); | |
14498 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_standard_all_cmd); | |
14499 | install_element(CONFIG_NODE, | |
14500 | &no_ip_lcommunity_list_name_expanded_all_cmd); | |
14501 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_standard_cmd); | |
14502 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_expanded_cmd); | |
14503 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_name_standard_cmd); | |
14504 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_cmd); | |
14505 | install_element(VIEW_NODE, &show_ip_lcommunity_list_cmd); | |
14506 | install_element(VIEW_NODE, &show_ip_lcommunity_list_arg_cmd); | |
5bf15956 | 14507 | } |