]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* BGP VTY interface. |
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 | |
17 | along with GNU Zebra; see the file COPYING. If not, write to the Free | |
18 | Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
19 | 02111-1307, USA. */ | |
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" |
718e3744 | 37 | |
38 | #include "bgpd/bgpd.h" | |
4bf6a362 | 39 | #include "bgpd/bgp_advertise.h" |
718e3744 | 40 | #include "bgpd/bgp_attr.h" |
41 | #include "bgpd/bgp_aspath.h" | |
42 | #include "bgpd/bgp_community.h" | |
4bf6a362 | 43 | #include "bgpd/bgp_ecommunity.h" |
57d187bc | 44 | #include "bgpd/bgp_lcommunity.h" |
4bf6a362 | 45 | #include "bgpd/bgp_damp.h" |
718e3744 | 46 | #include "bgpd/bgp_debug.h" |
e0701b79 | 47 | #include "bgpd/bgp_fsm.h" |
4bf6a362 | 48 | #include "bgpd/bgp_nexthop.h" |
718e3744 | 49 | #include "bgpd/bgp_open.h" |
4bf6a362 | 50 | #include "bgpd/bgp_regex.h" |
718e3744 | 51 | #include "bgpd/bgp_route.h" |
c016b6c7 | 52 | #include "bgpd/bgp_mplsvpn.h" |
718e3744 | 53 | #include "bgpd/bgp_zebra.h" |
fee0f4c6 | 54 | #include "bgpd/bgp_table.h" |
94f2b392 | 55 | #include "bgpd/bgp_vty.h" |
165b5fff | 56 | #include "bgpd/bgp_mpath.h" |
cb1faec9 | 57 | #include "bgpd/bgp_packet.h" |
3f9c7369 | 58 | #include "bgpd/bgp_updgrp.h" |
c43ed2e4 | 59 | #include "bgpd/bgp_bfd.h" |
718e3744 | 60 | |
20eb8864 | 61 | static struct peer_group * |
62 | listen_range_exists (struct bgp *bgp, struct prefix *range, int exact); | |
f51bae9c DS |
63 | #if 0 |
64 | #define INSTALL_CMD_ON_AF_NODES(cmd) \ | |
65 | install_element(BGP_IPV4_NODE, cmd); \ | |
66 | install_element(BGP_IPV4M_NODE, cmd); \ | |
67 | install_element(BGP_IPV4L_NODE, cmd); \ | |
68 | install_element(BGP_IPV6_NODE, cmd); \ | |
69 | install_element(BGP_IPV6M_NODE, cmd); \ | |
70 | install_element(BGP_IPV6L_NODE, cmd); \ | |
71 | install_element(BGP_VPNV4_NODE, cmd); | |
72 | #endif | |
73 | static enum node_type | |
74 | bgp_node_type (afi_t afi, safi_t safi) | |
75 | { | |
76 | switch (afi) | |
77 | { | |
78 | case AFI_IP: | |
79 | switch (safi) | |
80 | { | |
81 | case SAFI_UNICAST: | |
82 | return BGP_IPV4_NODE; | |
83 | break; | |
84 | case SAFI_MULTICAST: | |
85 | return BGP_IPV4M_NODE; | |
86 | break; | |
87 | case SAFI_LABELED_UNICAST: | |
88 | return BGP_IPV4L_NODE; | |
89 | break; | |
90 | case SAFI_MPLS_VPN: | |
91 | return BGP_VPNV4_NODE; | |
92 | break; | |
93 | case SAFI_ENCAP: | |
94 | return BGP_ENCAP_NODE; | |
95 | break; | |
f51bae9c DS |
96 | } |
97 | break; | |
98 | case AFI_IP6: | |
99 | switch (safi) | |
100 | { | |
101 | case SAFI_UNICAST: | |
102 | return BGP_IPV6_NODE; | |
103 | break; | |
104 | case SAFI_MULTICAST: | |
105 | return BGP_IPV6M_NODE; | |
106 | break; | |
107 | case SAFI_LABELED_UNICAST: | |
108 | return BGP_IPV6L_NODE; | |
109 | break; | |
110 | case SAFI_MPLS_VPN: | |
111 | return BGP_VPNV6_NODE; | |
112 | break; | |
113 | case SAFI_ENCAP: | |
114 | return BGP_ENCAP_NODE; | |
115 | break; | |
f51bae9c DS |
116 | } |
117 | break; | |
b3b3879c DS |
118 | case AFI_L2VPN: |
119 | return BGP_EVPN_NODE; | |
120 | break; | |
121 | case AFI_MAX: | |
122 | // We should never be here but to clarify the switch statement.. | |
123 | return BGP_IPV4_NODE; | |
f51bae9c DS |
124 | break; |
125 | } | |
b3b3879c DS |
126 | |
127 | // Impossible to happen | |
128 | return BGP_IPV4_NODE; | |
f51bae9c | 129 | } |
20eb8864 | 130 | |
718e3744 | 131 | /* Utility function to get address family from current node. */ |
132 | afi_t | |
133 | bgp_node_afi (struct vty *vty) | |
134 | { | |
4e851f1f LB |
135 | afi_t afi; |
136 | switch (vty->node) | |
137 | { | |
138 | case BGP_IPV6_NODE: | |
139 | case BGP_IPV6M_NODE: | |
f51bae9c | 140 | case BGP_IPV6L_NODE: |
4e851f1f LB |
141 | case BGP_VPNV6_NODE: |
142 | case BGP_ENCAPV6_NODE: | |
143 | afi = AFI_IP6; | |
144 | break; | |
4e0b7b6d PG |
145 | case BGP_EVPN_NODE: |
146 | afi = AFI_L2VPN; | |
147 | break; | |
4e851f1f LB |
148 | default: |
149 | afi = AFI_IP; | |
150 | break; | |
151 | } | |
152 | return afi; | |
718e3744 | 153 | } |
154 | ||
155 | /* Utility function to get subsequent address family from current | |
156 | node. */ | |
157 | safi_t | |
158 | bgp_node_safi (struct vty *vty) | |
159 | { | |
4e851f1f LB |
160 | safi_t safi; |
161 | switch (vty->node) | |
162 | { | |
163 | case BGP_ENCAP_NODE: | |
164 | case BGP_ENCAPV6_NODE: | |
165 | safi = SAFI_ENCAP; | |
166 | break; | |
167 | case BGP_VPNV4_NODE: | |
168 | case BGP_VPNV6_NODE: | |
169 | safi = SAFI_MPLS_VPN; | |
170 | break; | |
171 | case BGP_IPV4M_NODE: | |
172 | case BGP_IPV6M_NODE: | |
173 | safi = SAFI_MULTICAST; | |
174 | break; | |
4e0b7b6d PG |
175 | case BGP_EVPN_NODE: |
176 | safi = SAFI_EVPN; | |
177 | break; | |
f51bae9c DS |
178 | case BGP_IPV4L_NODE: |
179 | case BGP_IPV6L_NODE: | |
180 | safi = SAFI_LABELED_UNICAST; | |
181 | break; | |
4e851f1f LB |
182 | default: |
183 | safi = SAFI_UNICAST; | |
184 | break; | |
185 | } | |
186 | return safi; | |
718e3744 | 187 | } |
188 | ||
46f296b4 LB |
189 | /* supports <ipv4|ipv6> */ |
190 | afi_t | |
191 | bgp_vty_afi_from_arg(const char *afi_str) | |
8b1fb8be | 192 | { |
46f296b4 LB |
193 | afi_t afi = AFI_MAX; /* unknown */ |
194 | if (!strcmp(afi_str, "ipv4")) { | |
195 | afi = AFI_IP; | |
8b1fb8be | 196 | } |
46f296b4 LB |
197 | else if (!strcmp(afi_str, "ipv6")) { |
198 | afi = AFI_IP6; | |
199 | } | |
4e0b7b6d PG |
200 | else if (!strcmp(afi_str, "l2vpn")) { |
201 | afi = AFI_L2VPN; | |
202 | } | |
46f296b4 LB |
203 | return afi; |
204 | } | |
205 | ||
206 | int | |
207 | bgp_parse_afi(const char *str, afi_t *afi) | |
208 | { | |
209 | *afi = bgp_vty_afi_from_arg(str); | |
210 | if (*afi != AFI_MAX) | |
211 | return 0; | |
212 | else | |
8b1fb8be LB |
213 | return -1; |
214 | } | |
215 | ||
46f296b4 LB |
216 | int |
217 | argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, afi_t *afi) | |
218 | { | |
219 | int ret = 0; | |
220 | if (argv_find (argv, argc, "ipv4", index)) | |
221 | { | |
222 | ret = 1; | |
223 | if (afi) | |
224 | *afi = AFI_IP; | |
225 | } | |
226 | else if (argv_find (argv, argc, "ipv6", index)) | |
227 | { | |
228 | ret = 1; | |
229 | if (afi) | |
230 | *afi = AFI_IP6; | |
231 | } | |
232 | return ret; | |
233 | } | |
234 | ||
f51bae9c | 235 | /* supports <unicast|multicast|vpn|encap|labeled-unicast> */ |
ccbb332a | 236 | safi_t |
3b14d86e | 237 | bgp_vty_safi_from_arg(const char *safi_str) |
ccbb332a LB |
238 | { |
239 | safi_t safi = SAFI_MAX; /* unknown */ | |
240 | if (strncmp (safi_str, "m", 1) == 0) | |
241 | safi = SAFI_MULTICAST; | |
242 | else if (strncmp (safi_str, "u", 1) == 0) | |
243 | safi = SAFI_UNICAST; | |
244 | else if (strncmp (safi_str, "e", 1) == 0) | |
245 | safi = SAFI_ENCAP; | |
246 | else if (strncmp (safi_str, "v", 1) == 0) | |
46f296b4 | 247 | safi = SAFI_MPLS_VPN; |
f51bae9c DS |
248 | else if (strncmp (safi_str, "l", 1) == 0) |
249 | safi = SAFI_LABELED_UNICAST; | |
ccbb332a LB |
250 | return safi; |
251 | } | |
252 | ||
8b1fb8be | 253 | int |
3289141f | 254 | argv_find_and_parse_safi (struct cmd_token **argv, int argc, int *index, safi_t *safi) |
46f296b4 LB |
255 | { |
256 | int ret = 0; | |
257 | if (argv_find (argv, argc, "unicast", index)) | |
258 | { | |
259 | ret = 1; | |
260 | if (safi) | |
261 | *safi = SAFI_UNICAST; | |
262 | } | |
263 | else if (argv_find (argv, argc, "multicast", index)) | |
264 | { | |
265 | ret = 1; | |
266 | if (safi) | |
267 | *safi = SAFI_MULTICAST; | |
268 | } | |
b60f5275 DS |
269 | else if (argv_find (argv, argc, "labeled-unicast", index)) |
270 | { | |
271 | ret = 1; | |
272 | if (safi) | |
273 | *safi = SAFI_LABELED_UNICAST; | |
274 | } | |
46f296b4 LB |
275 | else if (argv_find (argv, argc, "vpn", index)) |
276 | { | |
277 | ret = 1; | |
278 | if (safi) | |
279 | *safi = SAFI_MPLS_VPN; | |
280 | } | |
281 | else if (argv_find (argv, argc, "encap", index)) | |
282 | { | |
283 | ret = 1; | |
284 | if (safi) | |
285 | *safi = SAFI_ENCAP; | |
286 | } | |
4e0b7b6d PG |
287 | else if (argv_find (argv, argc, "evpn", index)) |
288 | { | |
289 | ret = 1; | |
290 | if (safi) | |
291 | *safi = SAFI_EVPN; | |
292 | } | |
46f296b4 LB |
293 | return ret; |
294 | } | |
295 | ||
7eeee51e | 296 | /* |
f212a857 | 297 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 298 | * |
f212a857 DS |
299 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
300 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
301 | * to appropriate values for the calling function. This is to allow the |
302 | * calling function to make decisions appropriate for the show command | |
303 | * that is being parsed. | |
304 | * | |
305 | * The show commands are generally of the form: | |
b60f5275 | 306 | * "show [ip] bgp [<view|vrf> WORD] [<ipv4|ipv6> [<unicast|multicast|vpn|encap|labeled-unicast>]] ..." |
7eeee51e DS |
307 | * |
308 | * Since we use argv_find if the show command in particular doesn't have: | |
309 | * [ip] | |
310 | * [<view|vrf> WORD] | |
b60f5275 | 311 | * [<ipv4|ipv6> [<unicast|multicast|vpn|encap|labeled-unicast>]] |
7eeee51e DS |
312 | * The command parsing should still be ok. |
313 | * | |
314 | * vty -> The vty for the command so we can output some useful data in | |
315 | * the event of a parse error in the vrf. | |
316 | * argv -> The command tokens | |
317 | * argc -> How many command tokens we have | |
318 | * idx -> The current place in the command, generally should be 0 for this function | |
319 | * afi -> The parsed afi if it was included in the show command, returned here | |
320 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 321 | * bgp -> Pointer to the bgp data structure we need to fill in. |
7eeee51e DS |
322 | * |
323 | * The function returns the correct location in the parse tree for the | |
324 | * last token found. | |
0e37c258 DS |
325 | * |
326 | * Returns 0 for failure to parse correctly, else the idx position of where | |
327 | * it found the last token. | |
7eeee51e | 328 | */ |
af462945 | 329 | int |
f212a857 DS |
330 | bgp_vty_find_and_parse_afi_safi_bgp (struct vty *vty, struct cmd_token **argv, int argc, int *idx, |
331 | afi_t *afi, safi_t *safi, struct bgp **bgp) | |
af462945 DS |
332 | { |
333 | char *vrf_name = NULL; | |
334 | ||
b4898a38 DS |
335 | assert (afi); |
336 | assert (safi); | |
f212a857 | 337 | assert (bgp); |
b4898a38 | 338 | |
9317e17d | 339 | if (argv_find (argv, argc, "ip", idx)) |
af462945 DS |
340 | *afi = AFI_IP; |
341 | ||
9317e17d | 342 | if (argv_find (argv, argc, "view", idx) || argv_find (argv, argc, "vrf", idx)) |
af462945 | 343 | { |
9317e17d DS |
344 | vrf_name = argv[*idx + 1]->arg; |
345 | *idx += 2; | |
af462945 | 346 | |
f212a857 DS |
347 | if (strmatch (vrf_name, "all")) |
348 | *bgp = NULL; | |
af462945 | 349 | else |
f212a857 DS |
350 | { |
351 | *bgp = bgp_lookup_by_name (vrf_name); | |
352 | if (!*bgp) | |
353 | { | |
354 | vty_out (vty, "View/Vrf specified is unknown: %s%s", vrf_name, VTY_NEWLINE); | |
355 | *idx = 0; | |
356 | return 0; | |
357 | } | |
358 | } | |
af462945 | 359 | } |
f212a857 | 360 | else |
af462945 | 361 | { |
f212a857 DS |
362 | *bgp = bgp_get_default (); |
363 | if (!*bgp) | |
364 | { | |
365 | vty_out (vty, "Unable to find default BGP instance%s", VTY_NEWLINE); | |
366 | *idx = 0; | |
367 | return 0; | |
368 | } | |
af462945 | 369 | } |
9317e17d | 370 | |
f212a857 DS |
371 | if (argv_find_and_parse_afi (argv, argc, idx, afi)) |
372 | argv_find_and_parse_safi (argv, argc, idx, safi); | |
373 | ||
9317e17d DS |
374 | *idx += 1; |
375 | return *idx; | |
af462945 DS |
376 | } |
377 | ||
94f2b392 | 378 | static int |
6aeb9e78 | 379 | peer_address_self_check (struct bgp *bgp, union sockunion *su) |
718e3744 | 380 | { |
381 | struct interface *ifp = NULL; | |
382 | ||
383 | if (su->sa.sa_family == AF_INET) | |
6aeb9e78 | 384 | ifp = if_lookup_by_ipv4_exact (&su->sin.sin_addr, bgp->vrf_id); |
718e3744 | 385 | else if (su->sa.sa_family == AF_INET6) |
f2345335 | 386 | ifp = if_lookup_by_ipv6_exact (&su->sin6.sin6_addr, |
6aeb9e78 | 387 | su->sin6.sin6_scope_id, bgp->vrf_id); |
718e3744 | 388 | |
389 | if (ifp) | |
390 | return 1; | |
391 | ||
392 | return 0; | |
393 | } | |
394 | ||
395 | /* Utility function for looking up peer from VTY. */ | |
f14e6fdb DS |
396 | /* This is used only for configuration, so disallow if attempted on |
397 | * a dynamic neighbor. | |
398 | */ | |
94f2b392 | 399 | static struct peer * |
fd79ac91 | 400 | peer_lookup_vty (struct vty *vty, const char *ip_str) |
718e3744 | 401 | { |
cdc2d765 | 402 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); |
718e3744 | 403 | int ret; |
718e3744 | 404 | union sockunion su; |
405 | struct peer *peer; | |
406 | ||
cdc2d765 DL |
407 | if (!bgp) { |
408 | return NULL; | |
409 | } | |
718e3744 | 410 | |
411 | ret = str2sockunion (ip_str, &su); | |
412 | if (ret < 0) | |
413 | { | |
a80beece DS |
414 | peer = peer_lookup_by_conf_if (bgp, ip_str); |
415 | if (!peer) | |
416 | { | |
04b6bdc0 DW |
417 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) == NULL) |
418 | { | |
419 | vty_out (vty, "%% Malformed address or name: %s%s", ip_str, VTY_NEWLINE); | |
420 | return NULL; | |
421 | } | |
a80beece | 422 | } |
718e3744 | 423 | } |
a80beece | 424 | else |
718e3744 | 425 | { |
a80beece DS |
426 | peer = peer_lookup (bgp, &su); |
427 | if (! peer) | |
428 | { | |
429 | vty_out (vty, "%% Specify remote-as or peer-group commands first%s", | |
430 | VTY_NEWLINE); | |
431 | return NULL; | |
432 | } | |
f14e6fdb DS |
433 | if (peer_dynamic_neighbor (peer)) |
434 | { | |
435 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
436 | VTY_NEWLINE); | |
437 | return NULL; | |
438 | } | |
439 | ||
718e3744 | 440 | } |
441 | return peer; | |
442 | } | |
443 | ||
444 | /* Utility function for looking up peer or peer group. */ | |
f14e6fdb DS |
445 | /* This is used only for configuration, so disallow if attempted on |
446 | * a dynamic neighbor. | |
447 | */ | |
c43ed2e4 | 448 | struct peer * |
fd79ac91 | 449 | peer_and_group_lookup_vty (struct vty *vty, const char *peer_str) |
718e3744 | 450 | { |
cdc2d765 | 451 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); |
718e3744 | 452 | int ret; |
718e3744 | 453 | union sockunion su; |
f14e6fdb DS |
454 | struct peer *peer = NULL; |
455 | struct peer_group *group = NULL; | |
718e3744 | 456 | |
cdc2d765 DL |
457 | if (!bgp) { |
458 | return NULL; | |
459 | } | |
718e3744 | 460 | |
461 | ret = str2sockunion (peer_str, &su); | |
462 | if (ret == 0) | |
463 | { | |
f14e6fdb | 464 | /* IP address, locate peer. */ |
718e3744 | 465 | peer = peer_lookup (bgp, &su); |
718e3744 | 466 | } |
467 | else | |
468 | { | |
f14e6fdb | 469 | /* Not IP, could match either peer configured on interface or a group. */ |
a80beece | 470 | peer = peer_lookup_by_conf_if (bgp, peer_str); |
f14e6fdb DS |
471 | if (!peer) |
472 | group = peer_group_lookup (bgp, peer_str); | |
473 | } | |
a80beece | 474 | |
f14e6fdb DS |
475 | if (peer) |
476 | { | |
477 | if (peer_dynamic_neighbor (peer)) | |
478 | { | |
479 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
480 | VTY_NEWLINE); | |
481 | return NULL; | |
482 | } | |
483 | ||
484 | return peer; | |
718e3744 | 485 | } |
486 | ||
f14e6fdb DS |
487 | if (group) |
488 | return group->conf; | |
489 | ||
718e3744 | 490 | vty_out (vty, "%% Specify remote-as or peer-group commands first%s", |
491 | VTY_NEWLINE); | |
492 | ||
493 | return NULL; | |
494 | } | |
495 | ||
c43ed2e4 | 496 | int |
718e3744 | 497 | bgp_vty_return (struct vty *vty, int ret) |
498 | { | |
fd79ac91 | 499 | const char *str = NULL; |
718e3744 | 500 | |
501 | switch (ret) | |
502 | { | |
503 | case BGP_ERR_INVALID_VALUE: | |
504 | str = "Invalid value"; | |
505 | break; | |
506 | case BGP_ERR_INVALID_FLAG: | |
507 | str = "Invalid flag"; | |
508 | break; | |
718e3744 | 509 | case BGP_ERR_PEER_GROUP_SHUTDOWN: |
510 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
511 | break; | |
718e3744 | 512 | case BGP_ERR_PEER_FLAG_CONFLICT: |
513 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
514 | break; | |
718e3744 | 515 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: |
516 | str = "Specify remote-as or peer-group remote AS first"; | |
517 | break; | |
518 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
519 | str = "Cannot change the peer-group. Deconfigure first"; | |
520 | break; | |
521 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
4c48cf63 | 522 | str = "Peer is not a member of this peer-group"; |
718e3744 | 523 | break; |
524 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
525 | str = "Prefix/distribute list can not co-exist"; | |
526 | break; | |
527 | case BGP_ERR_NOT_INTERNAL_PEER: | |
528 | str = "Invalid command. Not an internal neighbor"; | |
529 | break; | |
530 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
5000f21c | 531 | str = "remove-private-AS cannot be configured for IBGP peers"; |
718e3744 | 532 | break; |
533 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
534 | str = "Local-AS allowed only for EBGP peers"; | |
535 | break; | |
536 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
537 | str = "Cannot have local-as same as BGP AS number"; | |
538 | break; | |
0df7c91f PJ |
539 | case BGP_ERR_TCPSIG_FAILED: |
540 | str = "Error while applying TCP-Sig to session(s)"; | |
541 | break; | |
fa411a21 NH |
542 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: |
543 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
544 | break; | |
f5a4827d SH |
545 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: |
546 | str = "ttl-security only allowed for EBGP peers"; | |
547 | break; | |
c7122e14 DS |
548 | case BGP_ERR_AS_OVERRIDE: |
549 | str = "as-override cannot be configured for IBGP peers"; | |
550 | break; | |
f14e6fdb DS |
551 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: |
552 | str = "Invalid limit for number of dynamic neighbors"; | |
553 | break; | |
554 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
555 | str = "Dynamic neighbor listen range already exists"; | |
556 | break; | |
557 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
558 | str = "Operation not allowed on a dynamic neighbor"; | |
559 | break; | |
63fa10b5 QY |
560 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: |
561 | str = "Operation not allowed on a directly connected neighbor"; | |
562 | break; | |
718e3744 | 563 | } |
564 | if (str) | |
565 | { | |
566 | vty_out (vty, "%% %s%s", str, VTY_NEWLINE); | |
567 | return CMD_WARNING; | |
568 | } | |
569 | return CMD_SUCCESS; | |
570 | } | |
571 | ||
7aafcaca DS |
572 | /* BGP clear sort. */ |
573 | enum clear_sort | |
574 | { | |
575 | clear_all, | |
576 | clear_peer, | |
577 | clear_group, | |
578 | clear_external, | |
579 | clear_as | |
580 | }; | |
581 | ||
7aafcaca DS |
582 | static void |
583 | bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi, | |
584 | safi_t safi, int error) | |
585 | { | |
586 | switch (error) | |
587 | { | |
588 | case BGP_ERR_AF_UNCONFIGURED: | |
589 | vty_out (vty, | |
46f296b4 LB |
590 | "%%BGP: Enable %s address family for the neighbor %s%s", |
591 | afi_safi_print(afi, safi), peer->host, VTY_NEWLINE); | |
7aafcaca DS |
592 | break; |
593 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
594 | vty_out (vty, "%%BGP: Inbound soft reconfig for %s not possible as it%s has neither refresh capability, nor inbound soft reconfig%s", peer->host, VTY_NEWLINE, VTY_NEWLINE); | |
595 | break; | |
596 | default: | |
597 | break; | |
598 | } | |
599 | } | |
600 | ||
601 | /* `clear ip bgp' functions. */ | |
602 | static int | |
603 | bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, | |
604 | enum clear_sort sort,enum bgp_clear_type stype, const char *arg) | |
605 | { | |
606 | int ret; | |
607 | struct peer *peer; | |
608 | struct listnode *node, *nnode; | |
609 | ||
610 | /* Clear all neighbors. */ | |
611 | /* | |
612 | * Pass along pointer to next node to peer_clear() when walking all nodes | |
613 | * on the BGP instance as that may get freed if it is a doppelganger | |
614 | */ | |
615 | if (sort == clear_all) | |
616 | { | |
617 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
618 | { | |
619 | if (stype == BGP_CLEAR_SOFT_NONE) | |
620 | ret = peer_clear (peer, &nnode); | |
621 | else if (peer->afc[afi][safi]) | |
622 | ret = peer_clear_soft (peer, afi, safi, stype); | |
623 | else | |
624 | ret = 0; | |
625 | ||
626 | if (ret < 0) | |
627 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
628 | } | |
629 | ||
630 | /* This is to apply read-only mode on this clear. */ | |
631 | if (stype == BGP_CLEAR_SOFT_NONE) | |
632 | bgp->update_delay_over = 0; | |
633 | ||
634 | return CMD_SUCCESS; | |
635 | } | |
636 | ||
637 | /* Clear specified neighbors. */ | |
638 | if (sort == clear_peer) | |
639 | { | |
640 | union sockunion su; | |
641 | int ret; | |
642 | ||
643 | /* Make sockunion for lookup. */ | |
644 | ret = str2sockunion (arg, &su); | |
645 | if (ret < 0) | |
646 | { | |
647 | peer = peer_lookup_by_conf_if (bgp, arg); | |
648 | if (!peer) | |
649 | { | |
04b6bdc0 DW |
650 | peer = peer_lookup_by_hostname(bgp, arg); |
651 | if (!peer) | |
652 | { | |
653 | vty_out (vty, "Malformed address or name: %s%s", arg, VTY_NEWLINE); | |
654 | return CMD_WARNING; | |
655 | } | |
7aafcaca DS |
656 | } |
657 | } | |
658 | else | |
659 | { | |
660 | peer = peer_lookup (bgp, &su); | |
661 | if (! peer) | |
662 | { | |
663 | vty_out (vty, "%%BGP: Unknown neighbor - \"%s\"%s", arg, VTY_NEWLINE); | |
664 | return CMD_WARNING; | |
665 | } | |
666 | } | |
667 | ||
668 | if (stype == BGP_CLEAR_SOFT_NONE) | |
669 | ret = peer_clear (peer, NULL); | |
670 | else | |
671 | ret = peer_clear_soft (peer, afi, safi, stype); | |
672 | ||
673 | if (ret < 0) | |
674 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
675 | ||
676 | return CMD_SUCCESS; | |
677 | } | |
678 | ||
679 | /* Clear all peer-group members. */ | |
680 | if (sort == clear_group) | |
681 | { | |
682 | struct peer_group *group; | |
683 | ||
684 | group = peer_group_lookup (bgp, arg); | |
685 | if (! group) | |
686 | { | |
687 | vty_out (vty, "%%BGP: No such peer-group %s%s", arg, VTY_NEWLINE); | |
688 | return CMD_WARNING; | |
689 | } | |
690 | ||
691 | for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) | |
692 | { | |
693 | if (stype == BGP_CLEAR_SOFT_NONE) | |
694 | { | |
18f1dc06 | 695 | peer_clear (peer, NULL); |
7aafcaca DS |
696 | continue; |
697 | } | |
698 | ||
c8560b44 | 699 | if (! peer->afc[afi][safi]) |
7aafcaca DS |
700 | continue; |
701 | ||
702 | ret = peer_clear_soft (peer, afi, safi, stype); | |
703 | ||
704 | if (ret < 0) | |
705 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
706 | } | |
707 | return CMD_SUCCESS; | |
708 | } | |
709 | ||
710 | if (sort == clear_external) | |
711 | { | |
712 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
713 | { | |
714 | if (peer->sort == BGP_PEER_IBGP) | |
715 | continue; | |
716 | ||
717 | if (stype == BGP_CLEAR_SOFT_NONE) | |
718 | ret = peer_clear (peer, &nnode); | |
719 | else | |
720 | ret = peer_clear_soft (peer, afi, safi, stype); | |
721 | ||
722 | if (ret < 0) | |
723 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
724 | } | |
725 | return CMD_SUCCESS; | |
726 | } | |
727 | ||
728 | if (sort == clear_as) | |
729 | { | |
730 | as_t as; | |
731 | int find = 0; | |
732 | ||
733 | VTY_GET_INTEGER_RANGE ("AS", as, arg, 1, BGP_AS4_MAX); | |
734 | ||
735 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
736 | { | |
737 | if (peer->as != as) | |
738 | continue; | |
739 | ||
740 | find = 1; | |
741 | if (stype == BGP_CLEAR_SOFT_NONE) | |
742 | ret = peer_clear (peer, &nnode); | |
743 | else | |
744 | ret = peer_clear_soft (peer, afi, safi, stype); | |
745 | ||
746 | if (ret < 0) | |
747 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
748 | } | |
749 | if (! find) | |
750 | vty_out (vty, "%%BGP: No peer is configured with AS %s%s", arg, | |
751 | VTY_NEWLINE); | |
752 | return CMD_SUCCESS; | |
753 | } | |
754 | ||
755 | return CMD_SUCCESS; | |
756 | } | |
757 | ||
758 | static int | |
759 | bgp_clear_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi, | |
760 | enum clear_sort sort, enum bgp_clear_type stype, | |
761 | const char *arg) | |
762 | { | |
763 | struct bgp *bgp; | |
764 | ||
765 | /* BGP structure lookup. */ | |
766 | if (name) | |
767 | { | |
768 | bgp = bgp_lookup_by_name (name); | |
769 | if (bgp == NULL) | |
770 | { | |
6aeb9e78 | 771 | vty_out (vty, "Can't find BGP instance %s%s", name, VTY_NEWLINE); |
7aafcaca DS |
772 | return CMD_WARNING; |
773 | } | |
774 | } | |
775 | else | |
776 | { | |
f31fa004 | 777 | bgp = bgp_get_default (); |
7aafcaca DS |
778 | if (bgp == NULL) |
779 | { | |
780 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
781 | return CMD_WARNING; | |
782 | } | |
783 | } | |
784 | ||
785 | return bgp_clear (vty, bgp, afi, safi, sort, stype, arg); | |
786 | } | |
787 | ||
788 | /* clear soft inbound */ | |
789 | static void | |
f31fa004 | 790 | bgp_clear_star_soft_in (struct vty *vty, const char *name) |
7aafcaca | 791 | { |
b09b5ae0 | 792 | bgp_clear_vty (vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
7aafcaca | 793 | BGP_CLEAR_SOFT_IN, NULL); |
f31fa004 | 794 | bgp_clear_vty (vty, name, AFI_IP6, SAFI_UNICAST, clear_all, |
7aafcaca | 795 | BGP_CLEAR_SOFT_IN, NULL); |
7aafcaca DS |
796 | } |
797 | ||
798 | /* clear soft outbound */ | |
799 | static void | |
f31fa004 | 800 | bgp_clear_star_soft_out (struct vty *vty, const char *name) |
7aafcaca | 801 | { |
f31fa004 | 802 | bgp_clear_vty (vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
7aafcaca | 803 | BGP_CLEAR_SOFT_OUT, NULL); |
f31fa004 | 804 | bgp_clear_vty (vty, name, AFI_IP6, SAFI_UNICAST, clear_all, |
7aafcaca | 805 | BGP_CLEAR_SOFT_OUT, NULL); |
7aafcaca DS |
806 | } |
807 | ||
808 | ||
718e3744 | 809 | /* BGP global configuration. */ |
810 | ||
811 | DEFUN (bgp_multiple_instance_func, | |
812 | bgp_multiple_instance_cmd, | |
813 | "bgp multiple-instance", | |
814 | BGP_STR | |
815 | "Enable bgp multiple instance\n") | |
816 | { | |
817 | bgp_option_set (BGP_OPT_MULTIPLE_INSTANCE); | |
818 | return CMD_SUCCESS; | |
819 | } | |
820 | ||
821 | DEFUN (no_bgp_multiple_instance, | |
822 | no_bgp_multiple_instance_cmd, | |
823 | "no bgp multiple-instance", | |
824 | NO_STR | |
825 | BGP_STR | |
826 | "BGP multiple instance\n") | |
827 | { | |
828 | int ret; | |
829 | ||
830 | ret = bgp_option_unset (BGP_OPT_MULTIPLE_INSTANCE); | |
831 | if (ret < 0) | |
832 | { | |
833 | vty_out (vty, "%% There are more than two BGP instances%s", VTY_NEWLINE); | |
834 | return CMD_WARNING; | |
835 | } | |
836 | return CMD_SUCCESS; | |
837 | } | |
838 | ||
839 | DEFUN (bgp_config_type, | |
840 | bgp_config_type_cmd, | |
6147e2c6 | 841 | "bgp config-type <cisco|zebra>", |
718e3744 | 842 | BGP_STR |
843 | "Configuration type\n" | |
844 | "cisco\n" | |
845 | "zebra\n") | |
846 | { | |
c500ae40 DW |
847 | int idx_vendor = 2; |
848 | if (strncmp (argv[idx_vendor]->arg, "c", 1) == 0) | |
718e3744 | 849 | bgp_option_set (BGP_OPT_CONFIG_CISCO); |
850 | else | |
851 | bgp_option_unset (BGP_OPT_CONFIG_CISCO); | |
852 | ||
853 | return CMD_SUCCESS; | |
854 | } | |
855 | ||
856 | DEFUN (no_bgp_config_type, | |
857 | no_bgp_config_type_cmd, | |
c7178fe7 | 858 | "no bgp config-type [<cisco|zebra>]", |
718e3744 | 859 | NO_STR |
860 | BGP_STR | |
838758ac DW |
861 | "Display configuration type\n" |
862 | "cisco\n" | |
863 | "zebra\n") | |
718e3744 | 864 | { |
865 | bgp_option_unset (BGP_OPT_CONFIG_CISCO); | |
866 | return CMD_SUCCESS; | |
867 | } | |
868 | ||
813d4307 | 869 | |
718e3744 | 870 | DEFUN (no_synchronization, |
871 | no_synchronization_cmd, | |
872 | "no synchronization", | |
873 | NO_STR | |
874 | "Perform IGP synchronization\n") | |
875 | { | |
876 | return CMD_SUCCESS; | |
877 | } | |
878 | ||
879 | DEFUN (no_auto_summary, | |
880 | no_auto_summary_cmd, | |
881 | "no auto-summary", | |
882 | NO_STR | |
883 | "Enable automatic network number summarization\n") | |
884 | { | |
885 | return CMD_SUCCESS; | |
886 | } | |
3d515fd9 | 887 | |
718e3744 | 888 | /* "router bgp" commands. */ |
505e5056 | 889 | DEFUN_NOSH (router_bgp, |
f412b39a | 890 | router_bgp_cmd, |
31500417 | 891 | "router bgp [(1-4294967295) [<view|vrf> WORD]]", |
718e3744 | 892 | ROUTER_STR |
893 | BGP_STR | |
31500417 DW |
894 | AS_STR |
895 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 896 | { |
31500417 DW |
897 | int idx_asn = 2; |
898 | int idx_view_vrf = 3; | |
899 | int idx_vrf = 4; | |
718e3744 | 900 | int ret; |
901 | as_t as; | |
902 | struct bgp *bgp; | |
fd79ac91 | 903 | const char *name = NULL; |
ad4cbda1 | 904 | enum bgp_instance_type inst_type; |
718e3744 | 905 | |
2385a876 | 906 | // "router bgp" without an ASN |
31500417 | 907 | if (argc == 2) |
2385a876 | 908 | { |
6aeb9e78 | 909 | //Pending: Make VRF option available for ASN less config |
2385a876 | 910 | bgp = bgp_get_default(); |
718e3744 | 911 | |
2385a876 DW |
912 | if (bgp == NULL) |
913 | { | |
914 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
915 | return CMD_WARNING; | |
916 | } | |
718e3744 | 917 | |
2385a876 DW |
918 | if (listcount(bm->bgp) > 1) |
919 | { | |
920 | vty_out (vty, "%% Multiple BGP processes are configured%s", VTY_NEWLINE); | |
921 | return CMD_WARNING; | |
922 | } | |
923 | } | |
924 | ||
925 | // "router bgp X" | |
926 | else | |
718e3744 | 927 | { |
31500417 | 928 | VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_asn]->arg, 1, BGP_AS4_MAX); |
2385a876 | 929 | |
ad4cbda1 | 930 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; |
31500417 | 931 | if (argc > 3) |
ad4cbda1 | 932 | { |
31500417 DW |
933 | name = argv[idx_vrf]->arg; |
934 | ||
e52702f2 | 935 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) |
ad4cbda1 | 936 | inst_type = BGP_INSTANCE_TYPE_VRF; |
e52702f2 | 937 | else if (!strcmp(argv[idx_view_vrf]->text, "view")) |
ad4cbda1 | 938 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
939 | } | |
2385a876 | 940 | |
ad4cbda1 | 941 | ret = bgp_get (&bgp, &as, name, inst_type); |
2385a876 DW |
942 | switch (ret) |
943 | { | |
944 | case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET: | |
945 | vty_out (vty, "Please specify 'bgp multiple-instance' first%s", | |
946 | VTY_NEWLINE); | |
947 | return CMD_WARNING; | |
948 | case BGP_ERR_AS_MISMATCH: | |
949 | vty_out (vty, "BGP is already running; AS is %u%s", as, VTY_NEWLINE); | |
950 | return CMD_WARNING; | |
951 | case BGP_ERR_INSTANCE_MISMATCH: | |
6aeb9e78 | 952 | vty_out (vty, "BGP instance name and AS number mismatch%s", VTY_NEWLINE); |
2385a876 DW |
953 | vty_out (vty, "BGP instance is already running; AS is %u%s", |
954 | as, VTY_NEWLINE); | |
955 | return CMD_WARNING; | |
956 | } | |
6aeb9e78 DS |
957 | |
958 | /* Pending: handle when user tries to change a view to vrf n vv. */ | |
718e3744 | 959 | } |
960 | ||
cdc2d765 | 961 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); |
718e3744 | 962 | |
963 | return CMD_SUCCESS; | |
964 | } | |
965 | ||
718e3744 | 966 | /* "no router bgp" commands. */ |
967 | DEFUN (no_router_bgp, | |
968 | no_router_bgp_cmd, | |
31500417 | 969 | "no router bgp [(1-4294967295) [<view|vrf> WORD]]", |
718e3744 | 970 | NO_STR |
971 | ROUTER_STR | |
972 | BGP_STR | |
31500417 DW |
973 | AS_STR |
974 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 975 | { |
31500417 | 976 | int idx_asn = 3; |
31500417 | 977 | int idx_vrf = 5; |
718e3744 | 978 | as_t as; |
979 | struct bgp *bgp; | |
fd79ac91 | 980 | const char *name = NULL; |
718e3744 | 981 | |
7fb21a9f | 982 | // "no router bgp" without an ASN |
31500417 | 983 | if (argc == 3) |
7fb21a9f QY |
984 | { |
985 | //Pending: Make VRF option available for ASN less config | |
986 | bgp = bgp_get_default(); | |
718e3744 | 987 | |
7fb21a9f QY |
988 | if (bgp == NULL) |
989 | { | |
990 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
991 | return CMD_WARNING; | |
992 | } | |
993 | ||
994 | if (listcount(bm->bgp) > 1) | |
995 | { | |
996 | vty_out (vty, "%% Multiple BGP processes are configured%s", VTY_NEWLINE); | |
997 | return CMD_WARNING; | |
998 | } | |
999 | } | |
1000 | else | |
718e3744 | 1001 | { |
31500417 | 1002 | VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_asn]->arg, 1, BGP_AS4_MAX); |
7fb21a9f | 1003 | |
31500417 DW |
1004 | if (argc > 4) |
1005 | name = argv[idx_vrf]->arg; | |
7fb21a9f QY |
1006 | |
1007 | /* Lookup bgp structure. */ | |
1008 | bgp = bgp_lookup (as, name); | |
1009 | if (! bgp) | |
1010 | { | |
1011 | vty_out (vty, "%% Can't find BGP instance%s", VTY_NEWLINE); | |
1012 | return CMD_WARNING; | |
1013 | } | |
718e3744 | 1014 | } |
1015 | ||
1016 | bgp_delete (bgp); | |
1017 | ||
1018 | return CMD_SUCCESS; | |
1019 | } | |
1020 | ||
6b0655a2 | 1021 | |
7fb21a9f | 1022 | |
718e3744 | 1023 | /* BGP router-id. */ |
1024 | ||
1025 | DEFUN (bgp_router_id, | |
1026 | bgp_router_id_cmd, | |
1027 | "bgp router-id A.B.C.D", | |
1028 | BGP_STR | |
1029 | "Override configured router identifier\n" | |
1030 | "Manually configured router identifier\n") | |
1031 | { | |
cdc2d765 | 1032 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1033 | int idx_ipv4 = 2; |
718e3744 | 1034 | int ret; |
1035 | struct in_addr id; | |
718e3744 | 1036 | |
c500ae40 | 1037 | ret = inet_aton (argv[idx_ipv4]->arg, &id); |
718e3744 | 1038 | if (! ret) |
1039 | { | |
1040 | vty_out (vty, "%% Malformed bgp router identifier%s", VTY_NEWLINE); | |
1041 | return CMD_WARNING; | |
1042 | } | |
1043 | ||
0e6cb743 | 1044 | bgp_router_id_static_set (bgp, id); |
718e3744 | 1045 | |
1046 | return CMD_SUCCESS; | |
1047 | } | |
1048 | ||
1049 | DEFUN (no_bgp_router_id, | |
1050 | no_bgp_router_id_cmd, | |
31500417 | 1051 | "no bgp router-id [A.B.C.D]", |
718e3744 | 1052 | NO_STR |
1053 | BGP_STR | |
31500417 DW |
1054 | "Override configured router identifier\n" |
1055 | "Manually configured router identifier\n") | |
718e3744 | 1056 | { |
cdc2d765 | 1057 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
31500417 | 1058 | int idx_router_id = 3; |
718e3744 | 1059 | int ret; |
1060 | struct in_addr id; | |
718e3744 | 1061 | |
31500417 | 1062 | if (argc > idx_router_id) |
718e3744 | 1063 | { |
31500417 | 1064 | ret = inet_aton (argv[idx_router_id]->arg, &id); |
718e3744 | 1065 | if (! ret) |
e018c7cc SK |
1066 | { |
1067 | vty_out (vty, "%% Malformed BGP router identifier%s", VTY_NEWLINE); | |
1068 | return CMD_WARNING; | |
1069 | } | |
718e3744 | 1070 | |
18a6dce6 | 1071 | if (! IPV4_ADDR_SAME (&bgp->router_id_static, &id)) |
e018c7cc SK |
1072 | { |
1073 | vty_out (vty, "%% BGP router-id doesn't match%s", VTY_NEWLINE); | |
1074 | return CMD_WARNING; | |
1075 | } | |
718e3744 | 1076 | } |
1077 | ||
0e6cb743 DL |
1078 | id.s_addr = 0; |
1079 | bgp_router_id_static_set (bgp, id); | |
718e3744 | 1080 | |
1081 | return CMD_SUCCESS; | |
1082 | } | |
1083 | ||
6b0655a2 | 1084 | |
718e3744 | 1085 | /* BGP Cluster ID. */ |
718e3744 | 1086 | DEFUN (bgp_cluster_id, |
1087 | bgp_cluster_id_cmd, | |
838758ac | 1088 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", |
718e3744 | 1089 | BGP_STR |
1090 | "Configure Route-Reflector Cluster-id\n" | |
838758ac DW |
1091 | "Route-Reflector Cluster-id in IP address format\n" |
1092 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1093 | { |
cdc2d765 | 1094 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1095 | int idx_ipv4 = 2; |
718e3744 | 1096 | int ret; |
718e3744 | 1097 | struct in_addr cluster; |
1098 | ||
c500ae40 | 1099 | ret = inet_aton (argv[idx_ipv4]->arg, &cluster); |
718e3744 | 1100 | if (! ret) |
1101 | { | |
1102 | vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE); | |
1103 | return CMD_WARNING; | |
1104 | } | |
1105 | ||
1106 | bgp_cluster_id_set (bgp, &cluster); | |
f31fa004 | 1107 | bgp_clear_star_soft_out (vty, bgp->name); |
718e3744 | 1108 | |
1109 | return CMD_SUCCESS; | |
1110 | } | |
1111 | ||
718e3744 | 1112 | DEFUN (no_bgp_cluster_id, |
1113 | no_bgp_cluster_id_cmd, | |
c7178fe7 | 1114 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", |
718e3744 | 1115 | NO_STR |
1116 | BGP_STR | |
838758ac DW |
1117 | "Configure Route-Reflector Cluster-id\n" |
1118 | "Route-Reflector Cluster-id in IP address format\n" | |
1119 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1120 | { |
cdc2d765 | 1121 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1122 | bgp_cluster_id_unset (bgp); |
f31fa004 | 1123 | bgp_clear_star_soft_out (vty, bgp->name); |
718e3744 | 1124 | |
1125 | return CMD_SUCCESS; | |
1126 | } | |
1127 | ||
718e3744 | 1128 | DEFUN (bgp_confederation_identifier, |
1129 | bgp_confederation_identifier_cmd, | |
9ccf14f7 | 1130 | "bgp confederation identifier (1-4294967295)", |
718e3744 | 1131 | "BGP specific commands\n" |
1132 | "AS confederation parameters\n" | |
1133 | "AS number\n" | |
1134 | "Set routing domain confederation AS\n") | |
1135 | { | |
cdc2d765 | 1136 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1137 | int idx_number = 3; |
718e3744 | 1138 | as_t as; |
1139 | ||
c500ae40 | 1140 | VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); |
718e3744 | 1141 | |
1142 | bgp_confederation_id_set (bgp, as); | |
1143 | ||
1144 | return CMD_SUCCESS; | |
1145 | } | |
1146 | ||
1147 | DEFUN (no_bgp_confederation_identifier, | |
1148 | no_bgp_confederation_identifier_cmd, | |
838758ac | 1149 | "no bgp confederation identifier [(1-4294967295)]", |
718e3744 | 1150 | NO_STR |
1151 | "BGP specific commands\n" | |
1152 | "AS confederation parameters\n" | |
3a2d747c QY |
1153 | "AS number\n" |
1154 | "Set routing domain confederation AS\n") | |
718e3744 | 1155 | { |
cdc2d765 | 1156 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1157 | bgp_confederation_id_unset (bgp); |
1158 | ||
1159 | return CMD_SUCCESS; | |
1160 | } | |
1161 | ||
718e3744 | 1162 | DEFUN (bgp_confederation_peers, |
1163 | bgp_confederation_peers_cmd, | |
12dcf78e | 1164 | "bgp confederation peers (1-4294967295)...", |
718e3744 | 1165 | "BGP specific commands\n" |
1166 | "AS confederation parameters\n" | |
1167 | "Peer ASs in BGP confederation\n" | |
1168 | AS_STR) | |
1169 | { | |
cdc2d765 | 1170 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
58749582 | 1171 | int idx_asn = 3; |
718e3744 | 1172 | as_t as; |
1173 | int i; | |
1174 | ||
58749582 | 1175 | for (i = idx_asn; i < argc; i++) |
718e3744 | 1176 | { |
afec25d9 | 1177 | VTY_GET_INTEGER_RANGE ("AS", as, argv[i]->arg, 1, BGP_AS4_MAX); |
718e3744 | 1178 | |
1179 | if (bgp->as == as) | |
1180 | { | |
1181 | vty_out (vty, "%% Local member-AS not allowed in confed peer list%s", | |
1182 | VTY_NEWLINE); | |
1183 | continue; | |
1184 | } | |
1185 | ||
1186 | bgp_confederation_peers_add (bgp, as); | |
1187 | } | |
1188 | return CMD_SUCCESS; | |
1189 | } | |
1190 | ||
1191 | DEFUN (no_bgp_confederation_peers, | |
1192 | no_bgp_confederation_peers_cmd, | |
e83a9414 | 1193 | "no bgp confederation peers (1-4294967295)...", |
718e3744 | 1194 | NO_STR |
1195 | "BGP specific commands\n" | |
1196 | "AS confederation parameters\n" | |
1197 | "Peer ASs in BGP confederation\n" | |
1198 | AS_STR) | |
1199 | { | |
cdc2d765 | 1200 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
58749582 | 1201 | int idx_asn = 4; |
718e3744 | 1202 | as_t as; |
1203 | int i; | |
1204 | ||
58749582 | 1205 | for (i = idx_asn; i < argc; i++) |
718e3744 | 1206 | { |
afec25d9 | 1207 | VTY_GET_INTEGER_RANGE ("AS", as, argv[i]->arg, 1, BGP_AS4_MAX); |
0b2aa3a0 | 1208 | |
718e3744 | 1209 | bgp_confederation_peers_remove (bgp, as); |
1210 | } | |
1211 | return CMD_SUCCESS; | |
1212 | } | |
6b0655a2 | 1213 | |
5e242b0d DS |
1214 | /** |
1215 | * Central routine for maximum-paths configuration. | |
1216 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1217 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1218 | */ | |
ffd0c037 DS |
1219 | static int |
1220 | bgp_maxpaths_config_vty (struct vty *vty, int peer_type, const char *mpaths, | |
5e242b0d | 1221 | u_int16_t options, int set) |
165b5fff | 1222 | { |
cdc2d765 | 1223 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4c9dee98 | 1224 | u_int16_t maxpaths = 0; |
165b5fff | 1225 | int ret; |
5e242b0d DS |
1226 | afi_t afi; |
1227 | safi_t safi; | |
165b5fff | 1228 | |
5e242b0d DS |
1229 | afi = bgp_node_afi (vty); |
1230 | safi = bgp_node_safi (vty); | |
165b5fff | 1231 | |
5e242b0d | 1232 | if (set) |
4c9dee98 | 1233 | { |
c59f2066 | 1234 | maxpaths = strtol(mpaths, NULL, 10); |
37fe7731 DS |
1235 | if (maxpaths > multipath_num) |
1236 | { | |
1237 | vty_out (vty, | |
1238 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", | |
1239 | maxpaths, multipath_num); | |
1240 | return CMD_WARNING; | |
1241 | } | |
dff6764a | 1242 | ret = bgp_maximum_paths_set (bgp, afi, safi, peer_type, maxpaths, options); |
4c9dee98 | 1243 | } |
5e242b0d DS |
1244 | else |
1245 | ret = bgp_maximum_paths_unset (bgp, afi, safi, peer_type); | |
165b5fff | 1246 | |
165b5fff JB |
1247 | if (ret < 0) |
1248 | { | |
1249 | vty_out (vty, | |
5e242b0d DS |
1250 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u%s", |
1251 | (set == 1) ? "" : "un", | |
1252 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1253 | maxpaths, afi, safi, VTY_NEWLINE); | |
165b5fff JB |
1254 | return CMD_WARNING; |
1255 | } | |
1256 | ||
7aafcaca DS |
1257 | bgp_recalculate_all_bestpaths (bgp); |
1258 | ||
165b5fff JB |
1259 | return CMD_SUCCESS; |
1260 | } | |
1261 | ||
abc920f8 DS |
1262 | DEFUN (bgp_maxmed_admin, |
1263 | bgp_maxmed_admin_cmd, | |
1264 | "bgp max-med administrative ", | |
1265 | BGP_STR | |
1266 | "Advertise routes with max-med\n" | |
1267 | "Administratively applied, for an indefinite period\n") | |
1268 | { | |
cdc2d765 | 1269 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 DS |
1270 | |
1271 | bgp->v_maxmed_admin = 1; | |
1272 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1273 | ||
1274 | bgp_maxmed_update(bgp); | |
1275 | ||
1276 | return CMD_SUCCESS; | |
1277 | } | |
1278 | ||
1279 | DEFUN (bgp_maxmed_admin_medv, | |
1280 | bgp_maxmed_admin_medv_cmd, | |
6147e2c6 | 1281 | "bgp max-med administrative (0-4294967294)", |
abc920f8 DS |
1282 | BGP_STR |
1283 | "Advertise routes with max-med\n" | |
1284 | "Administratively applied, for an indefinite period\n" | |
1285 | "Max MED value to be used\n") | |
1286 | { | |
cdc2d765 | 1287 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1288 | int idx_number = 3; |
abc920f8 DS |
1289 | |
1290 | bgp->v_maxmed_admin = 1; | |
c500ae40 | 1291 | VTY_GET_INTEGER ("max-med admin med-value", bgp->maxmed_admin_value, argv[idx_number]->arg); |
abc920f8 DS |
1292 | |
1293 | bgp_maxmed_update(bgp); | |
1294 | ||
1295 | return CMD_SUCCESS; | |
1296 | } | |
1297 | ||
1298 | DEFUN (no_bgp_maxmed_admin, | |
1299 | no_bgp_maxmed_admin_cmd, | |
8334fd5a | 1300 | "no bgp max-med administrative [(0-4294967294)]", |
abc920f8 DS |
1301 | NO_STR |
1302 | BGP_STR | |
1303 | "Advertise routes with max-med\n" | |
838758ac DW |
1304 | "Administratively applied, for an indefinite period\n" |
1305 | "Max MED value to be used\n") | |
abc920f8 | 1306 | { |
cdc2d765 | 1307 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 DS |
1308 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; |
1309 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 DS |
1310 | bgp_maxmed_update(bgp); |
1311 | ||
1312 | return CMD_SUCCESS; | |
1313 | } | |
1314 | ||
abc920f8 DS |
1315 | DEFUN (bgp_maxmed_onstartup, |
1316 | bgp_maxmed_onstartup_cmd, | |
6147e2c6 | 1317 | "bgp max-med on-startup (5-86400)", |
abc920f8 DS |
1318 | BGP_STR |
1319 | "Advertise routes with max-med\n" | |
1320 | "Effective on a startup\n" | |
1321 | "Time (seconds) period for max-med\n") | |
1322 | { | |
cdc2d765 | 1323 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1324 | int idx_number = 3; |
c500ae40 | 1325 | VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[idx_number]->arg); |
abc920f8 | 1326 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; |
abc920f8 DS |
1327 | bgp_maxmed_update(bgp); |
1328 | ||
1329 | return CMD_SUCCESS; | |
1330 | } | |
1331 | ||
1332 | DEFUN (bgp_maxmed_onstartup_medv, | |
1333 | bgp_maxmed_onstartup_medv_cmd, | |
6147e2c6 | 1334 | "bgp max-med on-startup (5-86400) (0-4294967294)", |
abc920f8 DS |
1335 | BGP_STR |
1336 | "Advertise routes with max-med\n" | |
1337 | "Effective on a startup\n" | |
1338 | "Time (seconds) period for max-med\n" | |
1339 | "Max MED value to be used\n") | |
1340 | { | |
cdc2d765 | 1341 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
1342 | int idx_number = 3; |
1343 | int idx_number_2 = 4; | |
c500ae40 DW |
1344 | VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[idx_number]->arg); |
1345 | VTY_GET_INTEGER ("max-med on-startup med-value", bgp->maxmed_onstartup_value, argv[idx_number_2]->arg); | |
abc920f8 DS |
1346 | bgp_maxmed_update(bgp); |
1347 | ||
1348 | return CMD_SUCCESS; | |
1349 | } | |
1350 | ||
1351 | DEFUN (no_bgp_maxmed_onstartup, | |
1352 | no_bgp_maxmed_onstartup_cmd, | |
8334fd5a | 1353 | "no bgp max-med on-startup [(5-86400) [(0-4294967294)]]", |
abc920f8 DS |
1354 | NO_STR |
1355 | BGP_STR | |
1356 | "Advertise routes with max-med\n" | |
838758ac DW |
1357 | "Effective on a startup\n" |
1358 | "Time (seconds) period for max-med\n" | |
1359 | "Max MED value to be used\n") | |
abc920f8 | 1360 | { |
cdc2d765 | 1361 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 DS |
1362 | |
1363 | /* Cancel max-med onstartup if its on */ | |
1364 | if (bgp->t_maxmed_onstartup) | |
1365 | { | |
1366 | THREAD_TIMER_OFF (bgp->t_maxmed_onstartup); | |
1367 | bgp->maxmed_onstartup_over = 1; | |
1368 | } | |
1369 | ||
1370 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; | |
1371 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
1372 | ||
1373 | bgp_maxmed_update(bgp); | |
1374 | ||
1375 | return CMD_SUCCESS; | |
1376 | } | |
1377 | ||
f188f2c4 DS |
1378 | static int |
1379 | bgp_update_delay_config_vty (struct vty *vty, const char *delay, | |
1380 | const char *wait) | |
1381 | { | |
cdc2d765 | 1382 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 DS |
1383 | u_int16_t update_delay; |
1384 | u_int16_t establish_wait; | |
1385 | ||
f188f2c4 DS |
1386 | VTY_GET_INTEGER_RANGE ("update-delay", update_delay, delay, |
1387 | BGP_UPDATE_DELAY_MIN, BGP_UPDATE_DELAY_MAX); | |
1388 | ||
1389 | if (!wait) /* update-delay <delay> */ | |
1390 | { | |
1391 | bgp->v_update_delay = update_delay; | |
1392 | bgp->v_establish_wait = bgp->v_update_delay; | |
1393 | return CMD_SUCCESS; | |
1394 | } | |
1395 | ||
1396 | /* update-delay <delay> <establish-wait> */ | |
1397 | establish_wait = atoi (wait); | |
1398 | if (update_delay < establish_wait) | |
1399 | { | |
1400 | vty_out (vty, "%%Failed: update-delay less than the establish-wait!%s", | |
1401 | VTY_NEWLINE); | |
1402 | return CMD_WARNING; | |
1403 | } | |
1404 | ||
1405 | bgp->v_update_delay = update_delay; | |
1406 | bgp->v_establish_wait = establish_wait; | |
1407 | ||
1408 | return CMD_SUCCESS; | |
1409 | } | |
1410 | ||
1411 | static int | |
1412 | bgp_update_delay_deconfig_vty (struct vty *vty) | |
1413 | { | |
cdc2d765 | 1414 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 DS |
1415 | |
1416 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; | |
1417 | bgp->v_establish_wait = bgp->v_update_delay; | |
1418 | ||
1419 | return CMD_SUCCESS; | |
1420 | } | |
1421 | ||
1422 | int | |
1423 | bgp_config_write_update_delay (struct vty *vty, struct bgp *bgp) | |
1424 | { | |
1425 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) | |
1426 | { | |
1427 | vty_out (vty, " update-delay %d", bgp->v_update_delay); | |
1428 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1429 | vty_out (vty, " %d", bgp->v_establish_wait); | |
1430 | vty_out (vty, "%s", VTY_NEWLINE); | |
1431 | } | |
1432 | ||
1433 | return 0; | |
1434 | } | |
1435 | ||
1436 | ||
1437 | /* Update-delay configuration */ | |
1438 | DEFUN (bgp_update_delay, | |
1439 | bgp_update_delay_cmd, | |
6147e2c6 | 1440 | "update-delay (0-3600)", |
f188f2c4 DS |
1441 | "Force initial delay for best-path and updates\n" |
1442 | "Seconds\n") | |
1443 | { | |
c500ae40 DW |
1444 | int idx_number = 1; |
1445 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); | |
f188f2c4 DS |
1446 | } |
1447 | ||
1448 | DEFUN (bgp_update_delay_establish_wait, | |
1449 | bgp_update_delay_establish_wait_cmd, | |
6147e2c6 | 1450 | "update-delay (0-3600) (1-3600)", |
f188f2c4 DS |
1451 | "Force initial delay for best-path and updates\n" |
1452 | "Seconds\n" | |
1453 | "Wait for peers to be established\n" | |
1454 | "Seconds\n") | |
1455 | { | |
c500ae40 DW |
1456 | int idx_number = 1; |
1457 | int idx_number_2 = 2; | |
1458 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, argv[idx_number_2]->arg); | |
f188f2c4 DS |
1459 | } |
1460 | ||
1461 | /* Update-delay deconfiguration */ | |
1462 | DEFUN (no_bgp_update_delay, | |
1463 | no_bgp_update_delay_cmd, | |
838758ac DW |
1464 | "no update-delay [(0-3600) [(1-3600)]]", |
1465 | NO_STR | |
f188f2c4 | 1466 | "Force initial delay for best-path and updates\n" |
838758ac DW |
1467 | "Seconds\n" |
1468 | "Wait for peers to be established\n") | |
f188f2c4 DS |
1469 | { |
1470 | return bgp_update_delay_deconfig_vty(vty); | |
1471 | } | |
1472 | ||
5e242b0d | 1473 | |
ffd0c037 DS |
1474 | static int |
1475 | bgp_wpkt_quanta_config_vty (struct vty *vty, const char *num, char set) | |
cb1faec9 | 1476 | { |
cdc2d765 | 1477 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
cb1faec9 DS |
1478 | |
1479 | if (set) | |
1480 | VTY_GET_INTEGER_RANGE ("write-quanta", bgp->wpkt_quanta, num, | |
4543bbb4 | 1481 | 1, 10000); |
cb1faec9 DS |
1482 | else |
1483 | bgp->wpkt_quanta = BGP_WRITE_PACKET_MAX; | |
1484 | ||
1485 | return CMD_SUCCESS; | |
1486 | } | |
1487 | ||
1488 | int | |
1489 | bgp_config_write_wpkt_quanta (struct vty *vty, struct bgp *bgp) | |
1490 | { | |
1491 | if (bgp->wpkt_quanta != BGP_WRITE_PACKET_MAX) | |
1492 | vty_out (vty, " write-quanta %d%s", | |
1493 | bgp->wpkt_quanta, VTY_NEWLINE); | |
1494 | ||
1495 | return 0; | |
1496 | } | |
1497 | ||
1498 | ||
1499 | /* Update-delay configuration */ | |
1500 | DEFUN (bgp_wpkt_quanta, | |
1501 | bgp_wpkt_quanta_cmd, | |
6147e2c6 | 1502 | "write-quanta (1-10000)", |
cb1faec9 DS |
1503 | "How many packets to write to peer socket per run\n" |
1504 | "Number of packets\n") | |
1505 | { | |
c500ae40 DW |
1506 | int idx_number = 1; |
1507 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
cb1faec9 DS |
1508 | } |
1509 | ||
1510 | /* Update-delay deconfiguration */ | |
1511 | DEFUN (no_bgp_wpkt_quanta, | |
1512 | no_bgp_wpkt_quanta_cmd, | |
6147e2c6 | 1513 | "no write-quanta (1-10000)", |
d7fa34c1 | 1514 | NO_STR |
cb1faec9 DS |
1515 | "How many packets to write to peer socket per run\n" |
1516 | "Number of packets\n") | |
1517 | { | |
c500ae40 DW |
1518 | int idx_number = 2; |
1519 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
cb1faec9 DS |
1520 | } |
1521 | ||
ffd0c037 | 1522 | static int |
3f9c7369 DS |
1523 | bgp_coalesce_config_vty (struct vty *vty, const char *num, char set) |
1524 | { | |
cdc2d765 | 1525 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3f9c7369 DS |
1526 | |
1527 | if (set) | |
1528 | VTY_GET_INTEGER_RANGE ("coalesce-time", bgp->coalesce_time, num, | |
1529 | 0, 4294967295); | |
1530 | else | |
1531 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; | |
1532 | ||
1533 | return CMD_SUCCESS; | |
1534 | } | |
1535 | ||
1536 | int | |
1537 | bgp_config_write_coalesce_time (struct vty *vty, struct bgp *bgp) | |
1538 | { | |
1539 | if (bgp->coalesce_time != BGP_DEFAULT_SUBGROUP_COALESCE_TIME) | |
1540 | vty_out (vty, " coalesce-time %d%s", | |
1541 | bgp->coalesce_time, VTY_NEWLINE); | |
1542 | ||
1543 | return 0; | |
1544 | } | |
1545 | ||
1546 | ||
1547 | DEFUN (bgp_coalesce_time, | |
1548 | bgp_coalesce_time_cmd, | |
6147e2c6 | 1549 | "coalesce-time (0-4294967295)", |
3f9c7369 DS |
1550 | "Subgroup coalesce timer\n" |
1551 | "Subgroup coalesce timer value (in ms)\n") | |
1552 | { | |
c500ae40 DW |
1553 | int idx_number = 1; |
1554 | return bgp_coalesce_config_vty(vty, argv[idx_number]->arg, 1); | |
3f9c7369 DS |
1555 | } |
1556 | ||
1557 | DEFUN (no_bgp_coalesce_time, | |
1558 | no_bgp_coalesce_time_cmd, | |
6147e2c6 | 1559 | "no coalesce-time (0-4294967295)", |
3a2d747c | 1560 | NO_STR |
3f9c7369 DS |
1561 | "Subgroup coalesce timer\n" |
1562 | "Subgroup coalesce timer value (in ms)\n") | |
1563 | { | |
c500ae40 DW |
1564 | int idx_number = 2; |
1565 | return bgp_coalesce_config_vty(vty, argv[idx_number]->arg, 0); | |
3f9c7369 DS |
1566 | } |
1567 | ||
5e242b0d DS |
1568 | /* Maximum-paths configuration */ |
1569 | DEFUN (bgp_maxpaths, | |
1570 | bgp_maxpaths_cmd, | |
9ccf14f7 | 1571 | "maximum-paths (1-255)", |
5e242b0d DS |
1572 | "Forward packets over multiple paths\n" |
1573 | "Number of paths\n") | |
1574 | { | |
c500ae40 DW |
1575 | int idx_number = 1; |
1576 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
1577 | } |
1578 | ||
165b5fff JB |
1579 | DEFUN (bgp_maxpaths_ibgp, |
1580 | bgp_maxpaths_ibgp_cmd, | |
9ccf14f7 | 1581 | "maximum-paths ibgp (1-255)", |
165b5fff JB |
1582 | "Forward packets over multiple paths\n" |
1583 | "iBGP-multipath\n" | |
1584 | "Number of paths\n") | |
1585 | { | |
c500ae40 DW |
1586 | int idx_number = 2; |
1587 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[idx_number]->arg, 0, 1); | |
5e242b0d | 1588 | } |
165b5fff | 1589 | |
5e242b0d DS |
1590 | DEFUN (bgp_maxpaths_ibgp_cluster, |
1591 | bgp_maxpaths_ibgp_cluster_cmd, | |
9ccf14f7 | 1592 | "maximum-paths ibgp (1-255) equal-cluster-length", |
5e242b0d DS |
1593 | "Forward packets over multiple paths\n" |
1594 | "iBGP-multipath\n" | |
1595 | "Number of paths\n" | |
1596 | "Match the cluster length\n") | |
1597 | { | |
c500ae40 DW |
1598 | int idx_number = 2; |
1599 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
5e242b0d | 1600 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); |
165b5fff JB |
1601 | } |
1602 | ||
1603 | DEFUN (no_bgp_maxpaths, | |
1604 | no_bgp_maxpaths_cmd, | |
9ccf14f7 | 1605 | "no maximum-paths [(1-255)]", |
165b5fff JB |
1606 | NO_STR |
1607 | "Forward packets over multiple paths\n" | |
1608 | "Number of paths\n") | |
1609 | { | |
5e242b0d | 1610 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
1611 | } |
1612 | ||
165b5fff JB |
1613 | DEFUN (no_bgp_maxpaths_ibgp, |
1614 | no_bgp_maxpaths_ibgp_cmd, | |
9ccf14f7 | 1615 | "no maximum-paths ibgp [(1-255) [equal-cluster-length]]", |
165b5fff JB |
1616 | NO_STR |
1617 | "Forward packets over multiple paths\n" | |
1618 | "iBGP-multipath\n" | |
838758ac DW |
1619 | "Number of paths\n" |
1620 | "Match the cluster length\n") | |
165b5fff | 1621 | { |
5e242b0d | 1622 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1623 | } |
1624 | ||
165b5fff JB |
1625 | int |
1626 | bgp_config_write_maxpaths (struct vty *vty, struct bgp *bgp, afi_t afi, | |
1627 | safi_t safi, int *write) | |
1628 | { | |
d5b77cc2 | 1629 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) |
165b5fff JB |
1630 | { |
1631 | bgp_config_write_family_header (vty, afi, safi, write); | |
0b960b4d | 1632 | vty_out (vty, " maximum-paths %d%s", |
165b5fff JB |
1633 | bgp->maxpaths[afi][safi].maxpaths_ebgp, VTY_NEWLINE); |
1634 | } | |
1635 | ||
d5b77cc2 | 1636 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) |
165b5fff JB |
1637 | { |
1638 | bgp_config_write_family_header (vty, afi, safi, write); | |
0b960b4d | 1639 | vty_out (vty, " maximum-paths ibgp %d", |
5e242b0d DS |
1640 | bgp->maxpaths[afi][safi].maxpaths_ibgp); |
1641 | if (CHECK_FLAG (bgp->maxpaths[afi][safi].ibgp_flags, | |
1642 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1643 | vty_out (vty, " equal-cluster-length"); | |
1644 | vty_out (vty, "%s", VTY_NEWLINE); | |
165b5fff JB |
1645 | } |
1646 | ||
1647 | return 0; | |
1648 | } | |
6b0655a2 | 1649 | |
718e3744 | 1650 | /* BGP timers. */ |
1651 | ||
1652 | DEFUN (bgp_timers, | |
1653 | bgp_timers_cmd, | |
6147e2c6 | 1654 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1655 | "Adjust routing timers\n" |
1656 | "BGP timers\n" | |
1657 | "Keepalive interval\n" | |
1658 | "Holdtime\n") | |
1659 | { | |
cdc2d765 | 1660 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
1661 | int idx_number = 2; |
1662 | int idx_number_2 = 3; | |
718e3744 | 1663 | unsigned long keepalive = 0; |
1664 | unsigned long holdtime = 0; | |
1665 | ||
c500ae40 DW |
1666 | VTY_GET_INTEGER ("keepalive", keepalive, argv[idx_number]->arg); |
1667 | VTY_GET_INTEGER ("holdtime", holdtime, argv[idx_number_2]->arg); | |
718e3744 | 1668 | |
1669 | /* Holdtime value check. */ | |
1670 | if (holdtime < 3 && holdtime != 0) | |
1671 | { | |
1672 | vty_out (vty, "%% hold time value must be either 0 or greater than 3%s", | |
1673 | VTY_NEWLINE); | |
1674 | return CMD_WARNING; | |
1675 | } | |
1676 | ||
1677 | bgp_timers_set (bgp, keepalive, holdtime); | |
1678 | ||
1679 | return CMD_SUCCESS; | |
1680 | } | |
1681 | ||
1682 | DEFUN (no_bgp_timers, | |
1683 | no_bgp_timers_cmd, | |
838758ac | 1684 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1685 | NO_STR |
1686 | "Adjust routing timers\n" | |
838758ac DW |
1687 | "BGP timers\n" |
1688 | "Keepalive interval\n" | |
1689 | "Holdtime\n") | |
718e3744 | 1690 | { |
cdc2d765 | 1691 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1692 | bgp_timers_unset (bgp); |
1693 | ||
1694 | return CMD_SUCCESS; | |
1695 | } | |
1696 | ||
6b0655a2 | 1697 | |
718e3744 | 1698 | DEFUN (bgp_client_to_client_reflection, |
1699 | bgp_client_to_client_reflection_cmd, | |
1700 | "bgp client-to-client reflection", | |
1701 | "BGP specific commands\n" | |
1702 | "Configure client to client route reflection\n" | |
1703 | "reflection of routes allowed\n") | |
1704 | { | |
cdc2d765 | 1705 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1706 | bgp_flag_unset (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); |
f31fa004 | 1707 | bgp_clear_star_soft_out (vty, bgp->name); |
7aafcaca | 1708 | |
718e3744 | 1709 | return CMD_SUCCESS; |
1710 | } | |
1711 | ||
1712 | DEFUN (no_bgp_client_to_client_reflection, | |
1713 | no_bgp_client_to_client_reflection_cmd, | |
1714 | "no bgp client-to-client reflection", | |
1715 | NO_STR | |
1716 | "BGP specific commands\n" | |
1717 | "Configure client to client route reflection\n" | |
1718 | "reflection of routes allowed\n") | |
1719 | { | |
cdc2d765 | 1720 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1721 | bgp_flag_set (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); |
f31fa004 | 1722 | bgp_clear_star_soft_out (vty, bgp->name); |
7aafcaca | 1723 | |
718e3744 | 1724 | return CMD_SUCCESS; |
1725 | } | |
1726 | ||
1727 | /* "bgp always-compare-med" configuration. */ | |
1728 | DEFUN (bgp_always_compare_med, | |
1729 | bgp_always_compare_med_cmd, | |
1730 | "bgp always-compare-med", | |
1731 | "BGP specific commands\n" | |
1732 | "Allow comparing MED from different neighbors\n") | |
1733 | { | |
cdc2d765 | 1734 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1735 | bgp_flag_set (bgp, BGP_FLAG_ALWAYS_COMPARE_MED); |
7aafcaca DS |
1736 | bgp_recalculate_all_bestpaths (bgp); |
1737 | ||
718e3744 | 1738 | return CMD_SUCCESS; |
1739 | } | |
1740 | ||
1741 | DEFUN (no_bgp_always_compare_med, | |
1742 | no_bgp_always_compare_med_cmd, | |
1743 | "no bgp always-compare-med", | |
1744 | NO_STR | |
1745 | "BGP specific commands\n" | |
1746 | "Allow comparing MED from different neighbors\n") | |
1747 | { | |
cdc2d765 | 1748 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1749 | bgp_flag_unset (bgp, BGP_FLAG_ALWAYS_COMPARE_MED); |
7aafcaca DS |
1750 | bgp_recalculate_all_bestpaths (bgp); |
1751 | ||
718e3744 | 1752 | return CMD_SUCCESS; |
1753 | } | |
6b0655a2 | 1754 | |
718e3744 | 1755 | /* "bgp deterministic-med" configuration. */ |
1756 | DEFUN (bgp_deterministic_med, | |
1757 | bgp_deterministic_med_cmd, | |
1758 | "bgp deterministic-med", | |
1759 | "BGP specific commands\n" | |
1760 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1761 | { | |
cdc2d765 | 1762 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1475ac87 DW |
1763 | |
1764 | if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) | |
1765 | { | |
1766 | bgp_flag_set (bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1767 | bgp_recalculate_all_bestpaths (bgp); | |
1768 | } | |
7aafcaca | 1769 | |
718e3744 | 1770 | return CMD_SUCCESS; |
1771 | } | |
1772 | ||
1773 | DEFUN (no_bgp_deterministic_med, | |
1774 | no_bgp_deterministic_med_cmd, | |
1775 | "no bgp deterministic-med", | |
1776 | NO_STR | |
1777 | "BGP specific commands\n" | |
1778 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1779 | { | |
cdc2d765 | 1780 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
06370dac DW |
1781 | int bestpath_per_as_used; |
1782 | afi_t afi; | |
1783 | safi_t safi; | |
1784 | struct peer *peer; | |
1785 | struct listnode *node, *nnode; | |
718e3744 | 1786 | |
1475ac87 DW |
1787 | if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) |
1788 | { | |
06370dac DW |
1789 | bestpath_per_as_used = 0; |
1790 | ||
1791 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
1792 | { | |
1793 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
1794 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
1795 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) | |
1796 | { | |
1797 | bestpath_per_as_used = 1; | |
1798 | break; | |
1799 | } | |
1800 | ||
1801 | if (bestpath_per_as_used) | |
1802 | break; | |
1803 | } | |
1804 | ||
1805 | if (bestpath_per_as_used) | |
1806 | { | |
1807 | vty_out (vty, "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use%s", | |
1808 | VTY_NEWLINE); | |
1809 | return CMD_WARNING; | |
1810 | } | |
1811 | else | |
1812 | { | |
1813 | bgp_flag_unset (bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1814 | bgp_recalculate_all_bestpaths (bgp); | |
1815 | } | |
1475ac87 | 1816 | } |
7aafcaca | 1817 | |
718e3744 | 1818 | return CMD_SUCCESS; |
1819 | } | |
538621f2 | 1820 | |
1821 | /* "bgp graceful-restart" configuration. */ | |
1822 | DEFUN (bgp_graceful_restart, | |
1823 | bgp_graceful_restart_cmd, | |
1824 | "bgp graceful-restart", | |
1825 | "BGP specific commands\n" | |
1826 | "Graceful restart capability parameters\n") | |
1827 | { | |
cdc2d765 | 1828 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
538621f2 | 1829 | bgp_flag_set (bgp, BGP_FLAG_GRACEFUL_RESTART); |
1830 | return CMD_SUCCESS; | |
1831 | } | |
1832 | ||
1833 | DEFUN (no_bgp_graceful_restart, | |
1834 | no_bgp_graceful_restart_cmd, | |
1835 | "no bgp graceful-restart", | |
1836 | NO_STR | |
1837 | "BGP specific commands\n" | |
1838 | "Graceful restart capability parameters\n") | |
1839 | { | |
cdc2d765 | 1840 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
538621f2 | 1841 | bgp_flag_unset (bgp, BGP_FLAG_GRACEFUL_RESTART); |
1842 | return CMD_SUCCESS; | |
1843 | } | |
1844 | ||
93406d87 | 1845 | DEFUN (bgp_graceful_restart_stalepath_time, |
1846 | bgp_graceful_restart_stalepath_time_cmd, | |
6147e2c6 | 1847 | "bgp graceful-restart stalepath-time (1-3600)", |
93406d87 | 1848 | "BGP specific commands\n" |
1849 | "Graceful restart capability parameters\n" | |
1850 | "Set the max time to hold onto restarting peer's stale paths\n" | |
1851 | "Delay value (seconds)\n") | |
1852 | { | |
cdc2d765 | 1853 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1854 | int idx_number = 3; |
93406d87 | 1855 | u_int32_t stalepath; |
1856 | ||
c500ae40 | 1857 | VTY_GET_INTEGER_RANGE ("stalepath-time", stalepath, argv[idx_number]->arg, 1, 3600); |
93406d87 | 1858 | bgp->stalepath_time = stalepath; |
1859 | return CMD_SUCCESS; | |
1860 | } | |
1861 | ||
eb6f1b41 PG |
1862 | DEFUN (bgp_graceful_restart_restart_time, |
1863 | bgp_graceful_restart_restart_time_cmd, | |
6147e2c6 | 1864 | "bgp graceful-restart restart-time (1-3600)", |
eb6f1b41 PG |
1865 | "BGP specific commands\n" |
1866 | "Graceful restart capability parameters\n" | |
1867 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
1868 | "Delay value (seconds)\n") | |
1869 | { | |
cdc2d765 | 1870 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1871 | int idx_number = 3; |
eb6f1b41 PG |
1872 | u_int32_t restart; |
1873 | ||
c500ae40 | 1874 | VTY_GET_INTEGER_RANGE ("restart-time", restart, argv[idx_number]->arg, 1, 3600); |
eb6f1b41 PG |
1875 | bgp->restart_time = restart; |
1876 | return CMD_SUCCESS; | |
1877 | } | |
1878 | ||
93406d87 | 1879 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
1880 | no_bgp_graceful_restart_stalepath_time_cmd, | |
838758ac | 1881 | "no bgp graceful-restart stalepath-time [(1-3600)]", |
93406d87 | 1882 | NO_STR |
1883 | "BGP specific commands\n" | |
1884 | "Graceful restart capability parameters\n" | |
838758ac DW |
1885 | "Set the max time to hold onto restarting peer's stale paths\n" |
1886 | "Delay value (seconds)\n") | |
93406d87 | 1887 | { |
cdc2d765 | 1888 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 1889 | |
1890 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; | |
1891 | return CMD_SUCCESS; | |
1892 | } | |
1893 | ||
eb6f1b41 PG |
1894 | DEFUN (no_bgp_graceful_restart_restart_time, |
1895 | no_bgp_graceful_restart_restart_time_cmd, | |
838758ac | 1896 | "no bgp graceful-restart restart-time [(1-3600)]", |
eb6f1b41 PG |
1897 | NO_STR |
1898 | "BGP specific commands\n" | |
1899 | "Graceful restart capability parameters\n" | |
838758ac DW |
1900 | "Set the time to wait to delete stale routes before a BGP open message is received\n" |
1901 | "Delay value (seconds)\n") | |
eb6f1b41 | 1902 | { |
cdc2d765 | 1903 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 PG |
1904 | |
1905 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; | |
1906 | return CMD_SUCCESS; | |
1907 | } | |
1908 | ||
43fc21b3 JC |
1909 | DEFUN (bgp_graceful_restart_preserve_fw, |
1910 | bgp_graceful_restart_preserve_fw_cmd, | |
1911 | "bgp graceful-restart preserve-fw-state", | |
1912 | "BGP specific commands\n" | |
1913 | "Graceful restart capability parameters\n" | |
1914 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1915 | { | |
1916 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1917 | bgp_flag_set(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1918 | return CMD_SUCCESS; | |
1919 | } | |
1920 | ||
1921 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
1922 | no_bgp_graceful_restart_preserve_fw_cmd, | |
1923 | "no bgp graceful-restart preserve-fw-state", | |
1924 | NO_STR | |
1925 | "BGP specific commands\n" | |
1926 | "Graceful restart capability parameters\n" | |
1927 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1928 | { | |
1929 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1930 | bgp_flag_unset(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1931 | return CMD_SUCCESS; | |
1932 | } | |
1933 | ||
718e3744 | 1934 | /* "bgp fast-external-failover" configuration. */ |
1935 | DEFUN (bgp_fast_external_failover, | |
1936 | bgp_fast_external_failover_cmd, | |
1937 | "bgp fast-external-failover", | |
1938 | BGP_STR | |
1939 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
1940 | { | |
cdc2d765 | 1941 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1942 | bgp_flag_unset (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); |
1943 | return CMD_SUCCESS; | |
1944 | } | |
1945 | ||
1946 | DEFUN (no_bgp_fast_external_failover, | |
1947 | no_bgp_fast_external_failover_cmd, | |
1948 | "no bgp fast-external-failover", | |
1949 | NO_STR | |
1950 | BGP_STR | |
1951 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
1952 | { | |
cdc2d765 | 1953 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1954 | bgp_flag_set (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); |
1955 | return CMD_SUCCESS; | |
1956 | } | |
6b0655a2 | 1957 | |
718e3744 | 1958 | /* "bgp enforce-first-as" configuration. */ |
1959 | DEFUN (bgp_enforce_first_as, | |
1960 | bgp_enforce_first_as_cmd, | |
1961 | "bgp enforce-first-as", | |
1962 | BGP_STR | |
1963 | "Enforce the first AS for EBGP routes\n") | |
1964 | { | |
cdc2d765 | 1965 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1966 | bgp_flag_set (bgp, BGP_FLAG_ENFORCE_FIRST_AS); |
f31fa004 | 1967 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 1968 | |
718e3744 | 1969 | return CMD_SUCCESS; |
1970 | } | |
1971 | ||
1972 | DEFUN (no_bgp_enforce_first_as, | |
1973 | no_bgp_enforce_first_as_cmd, | |
1974 | "no bgp enforce-first-as", | |
1975 | NO_STR | |
1976 | BGP_STR | |
1977 | "Enforce the first AS for EBGP routes\n") | |
1978 | { | |
cdc2d765 | 1979 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1980 | bgp_flag_unset (bgp, BGP_FLAG_ENFORCE_FIRST_AS); |
f31fa004 | 1981 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 1982 | |
718e3744 | 1983 | return CMD_SUCCESS; |
1984 | } | |
6b0655a2 | 1985 | |
718e3744 | 1986 | /* "bgp bestpath compare-routerid" configuration. */ |
1987 | DEFUN (bgp_bestpath_compare_router_id, | |
1988 | bgp_bestpath_compare_router_id_cmd, | |
1989 | "bgp bestpath compare-routerid", | |
1990 | "BGP specific commands\n" | |
1991 | "Change the default bestpath selection\n" | |
1992 | "Compare router-id for identical EBGP paths\n") | |
1993 | { | |
cdc2d765 | 1994 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1995 | bgp_flag_set (bgp, BGP_FLAG_COMPARE_ROUTER_ID); |
7aafcaca DS |
1996 | bgp_recalculate_all_bestpaths (bgp); |
1997 | ||
718e3744 | 1998 | return CMD_SUCCESS; |
1999 | } | |
2000 | ||
2001 | DEFUN (no_bgp_bestpath_compare_router_id, | |
2002 | no_bgp_bestpath_compare_router_id_cmd, | |
2003 | "no bgp bestpath compare-routerid", | |
2004 | NO_STR | |
2005 | "BGP specific commands\n" | |
2006 | "Change the default bestpath selection\n" | |
2007 | "Compare router-id for identical EBGP paths\n") | |
2008 | { | |
cdc2d765 | 2009 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2010 | bgp_flag_unset (bgp, BGP_FLAG_COMPARE_ROUTER_ID); |
7aafcaca DS |
2011 | bgp_recalculate_all_bestpaths (bgp); |
2012 | ||
718e3744 | 2013 | return CMD_SUCCESS; |
2014 | } | |
6b0655a2 | 2015 | |
718e3744 | 2016 | /* "bgp bestpath as-path ignore" configuration. */ |
2017 | DEFUN (bgp_bestpath_aspath_ignore, | |
2018 | bgp_bestpath_aspath_ignore_cmd, | |
2019 | "bgp bestpath as-path ignore", | |
2020 | "BGP specific commands\n" | |
2021 | "Change the default bestpath selection\n" | |
2022 | "AS-path attribute\n" | |
2023 | "Ignore as-path length in selecting a route\n") | |
2024 | { | |
cdc2d765 | 2025 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2026 | bgp_flag_set (bgp, BGP_FLAG_ASPATH_IGNORE); |
7aafcaca DS |
2027 | bgp_recalculate_all_bestpaths (bgp); |
2028 | ||
718e3744 | 2029 | return CMD_SUCCESS; |
2030 | } | |
2031 | ||
2032 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
2033 | no_bgp_bestpath_aspath_ignore_cmd, | |
2034 | "no bgp bestpath as-path ignore", | |
2035 | NO_STR | |
2036 | "BGP specific commands\n" | |
2037 | "Change the default bestpath selection\n" | |
2038 | "AS-path attribute\n" | |
2039 | "Ignore as-path length in selecting a route\n") | |
2040 | { | |
cdc2d765 | 2041 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2042 | bgp_flag_unset (bgp, BGP_FLAG_ASPATH_IGNORE); |
7aafcaca DS |
2043 | bgp_recalculate_all_bestpaths (bgp); |
2044 | ||
718e3744 | 2045 | return CMD_SUCCESS; |
2046 | } | |
6b0655a2 | 2047 | |
6811845b | 2048 | /* "bgp bestpath as-path confed" configuration. */ |
2049 | DEFUN (bgp_bestpath_aspath_confed, | |
2050 | bgp_bestpath_aspath_confed_cmd, | |
2051 | "bgp bestpath as-path confed", | |
2052 | "BGP specific commands\n" | |
2053 | "Change the default bestpath selection\n" | |
2054 | "AS-path attribute\n" | |
2055 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2056 | { | |
cdc2d765 | 2057 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6811845b | 2058 | bgp_flag_set (bgp, BGP_FLAG_ASPATH_CONFED); |
7aafcaca DS |
2059 | bgp_recalculate_all_bestpaths (bgp); |
2060 | ||
6811845b | 2061 | return CMD_SUCCESS; |
2062 | } | |
2063 | ||
2064 | DEFUN (no_bgp_bestpath_aspath_confed, | |
2065 | no_bgp_bestpath_aspath_confed_cmd, | |
2066 | "no bgp bestpath as-path confed", | |
2067 | NO_STR | |
2068 | "BGP specific commands\n" | |
2069 | "Change the default bestpath selection\n" | |
2070 | "AS-path attribute\n" | |
2071 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2072 | { | |
cdc2d765 | 2073 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6811845b | 2074 | bgp_flag_unset (bgp, BGP_FLAG_ASPATH_CONFED); |
7aafcaca DS |
2075 | bgp_recalculate_all_bestpaths (bgp); |
2076 | ||
6811845b | 2077 | return CMD_SUCCESS; |
2078 | } | |
6b0655a2 | 2079 | |
2fdd455c PM |
2080 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
2081 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
2082 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2083 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2084 | "BGP specific commands\n" |
2085 | "Change the default bestpath selection\n" | |
2086 | "AS-path attribute\n" | |
2087 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2088 | "Generate an AS_SET\n" |
16fc1eec DS |
2089 | "Do not generate an AS_SET\n") |
2090 | { | |
cdc2d765 | 2091 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4c4ff4c1 | 2092 | int idx = 0; |
16fc1eec | 2093 | bgp_flag_set (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); |
219178b6 DW |
2094 | |
2095 | /* no-as-set is now the default behavior so we can silently | |
2096 | * ignore it */ | |
4c4ff4c1 | 2097 | if (argv_find (argv, argc, "as-set", &idx)) |
219178b6 DW |
2098 | bgp_flag_set (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
2099 | else | |
2100 | bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET) ; | |
2101 | ||
7aafcaca DS |
2102 | bgp_recalculate_all_bestpaths (bgp); |
2103 | ||
16fc1eec DS |
2104 | return CMD_SUCCESS; |
2105 | } | |
2106 | ||
219178b6 DW |
2107 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
2108 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2109 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2110 | NO_STR |
2111 | "BGP specific commands\n" | |
2112 | "Change the default bestpath selection\n" | |
2113 | "AS-path attribute\n" | |
2114 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2115 | "Generate an AS_SET\n" |
16fc1eec DS |
2116 | "Do not generate an AS_SET\n") |
2117 | { | |
cdc2d765 | 2118 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
16fc1eec | 2119 | bgp_flag_unset (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); |
219178b6 | 2120 | bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
7aafcaca DS |
2121 | bgp_recalculate_all_bestpaths (bgp); |
2122 | ||
2fdd455c PM |
2123 | return CMD_SUCCESS; |
2124 | } | |
6b0655a2 | 2125 | |
848973c7 | 2126 | /* "bgp log-neighbor-changes" configuration. */ |
2127 | DEFUN (bgp_log_neighbor_changes, | |
2128 | bgp_log_neighbor_changes_cmd, | |
2129 | "bgp log-neighbor-changes", | |
2130 | "BGP specific commands\n" | |
2131 | "Log neighbor up/down and reset reason\n") | |
2132 | { | |
cdc2d765 | 2133 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
848973c7 | 2134 | bgp_flag_set (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
2135 | return CMD_SUCCESS; | |
2136 | } | |
2137 | ||
2138 | DEFUN (no_bgp_log_neighbor_changes, | |
2139 | no_bgp_log_neighbor_changes_cmd, | |
2140 | "no bgp log-neighbor-changes", | |
2141 | NO_STR | |
2142 | "BGP specific commands\n" | |
2143 | "Log neighbor up/down and reset reason\n") | |
2144 | { | |
cdc2d765 | 2145 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
848973c7 | 2146 | bgp_flag_unset (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
2147 | return CMD_SUCCESS; | |
2148 | } | |
6b0655a2 | 2149 | |
718e3744 | 2150 | /* "bgp bestpath med" configuration. */ |
2151 | DEFUN (bgp_bestpath_med, | |
2152 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 2153 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2154 | "BGP specific commands\n" |
2155 | "Change the default bestpath selection\n" | |
2156 | "MED attribute\n" | |
2157 | "Compare MED among confederation paths\n" | |
838758ac DW |
2158 | "Treat missing MED as the least preferred one\n" |
2159 | "Treat missing MED as the least preferred one\n" | |
2160 | "Compare MED among confederation paths\n") | |
718e3744 | 2161 | { |
cdc2d765 | 2162 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6cbd1915 QY |
2163 | |
2164 | int idx = 0; | |
2165 | if (argv_find (argv, argc, "confed", &idx)) | |
2166 | bgp_flag_set (bgp, BGP_FLAG_MED_CONFED); | |
2167 | idx = 0; | |
2168 | if (argv_find (argv, argc, "missing-as-worst", &idx)) | |
2169 | bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
e52702f2 | 2170 | |
7aafcaca DS |
2171 | bgp_recalculate_all_bestpaths (bgp); |
2172 | ||
718e3744 | 2173 | return CMD_SUCCESS; |
2174 | } | |
2175 | ||
718e3744 | 2176 | DEFUN (no_bgp_bestpath_med, |
2177 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2178 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2179 | NO_STR |
2180 | "BGP specific commands\n" | |
2181 | "Change the default bestpath selection\n" | |
2182 | "MED attribute\n" | |
2183 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2184 | "Treat missing MED as the least preferred one\n" |
2185 | "Treat missing MED as the least preferred one\n" | |
2186 | "Compare MED among confederation paths\n") | |
718e3744 | 2187 | { |
cdc2d765 | 2188 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
e52702f2 | 2189 | |
6cbd1915 QY |
2190 | int idx = 0; |
2191 | if (argv_find (argv, argc, "confed", &idx)) | |
718e3744 | 2192 | bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED); |
6cbd1915 QY |
2193 | idx = 0; |
2194 | if (argv_find (argv, argc, "missing-as-worst", &idx)) | |
718e3744 | 2195 | bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST); |
2196 | ||
7aafcaca DS |
2197 | bgp_recalculate_all_bestpaths (bgp); |
2198 | ||
718e3744 | 2199 | return CMD_SUCCESS; |
2200 | } | |
2201 | ||
718e3744 | 2202 | /* "no bgp default ipv4-unicast". */ |
2203 | DEFUN (no_bgp_default_ipv4_unicast, | |
2204 | no_bgp_default_ipv4_unicast_cmd, | |
2205 | "no bgp default ipv4-unicast", | |
2206 | NO_STR | |
2207 | "BGP specific commands\n" | |
2208 | "Configure BGP defaults\n" | |
2209 | "Activate ipv4-unicast for a peer by default\n") | |
2210 | { | |
cdc2d765 | 2211 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2212 | bgp_flag_set (bgp, BGP_FLAG_NO_DEFAULT_IPV4); |
2213 | return CMD_SUCCESS; | |
2214 | } | |
2215 | ||
2216 | DEFUN (bgp_default_ipv4_unicast, | |
2217 | bgp_default_ipv4_unicast_cmd, | |
2218 | "bgp default ipv4-unicast", | |
2219 | "BGP specific commands\n" | |
2220 | "Configure BGP defaults\n" | |
2221 | "Activate ipv4-unicast for a peer by default\n") | |
2222 | { | |
cdc2d765 | 2223 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2224 | bgp_flag_unset (bgp, BGP_FLAG_NO_DEFAULT_IPV4); |
2225 | return CMD_SUCCESS; | |
2226 | } | |
6b0655a2 | 2227 | |
04b6bdc0 DW |
2228 | /* Display hostname in certain command outputs */ |
2229 | DEFUN (bgp_default_show_hostname, | |
2230 | bgp_default_show_hostname_cmd, | |
2231 | "bgp default show-hostname", | |
2232 | "BGP specific commands\n" | |
2233 | "Configure BGP defaults\n" | |
2234 | "Show hostname in certain command ouputs\n") | |
2235 | { | |
cdc2d765 | 2236 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
04b6bdc0 DW |
2237 | bgp_flag_set (bgp, BGP_FLAG_SHOW_HOSTNAME); |
2238 | return CMD_SUCCESS; | |
2239 | } | |
2240 | ||
2241 | DEFUN (no_bgp_default_show_hostname, | |
2242 | no_bgp_default_show_hostname_cmd, | |
2243 | "no bgp default show-hostname", | |
2244 | NO_STR | |
2245 | "BGP specific commands\n" | |
2246 | "Configure BGP defaults\n" | |
2247 | "Show hostname in certain command ouputs\n") | |
2248 | { | |
cdc2d765 | 2249 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
04b6bdc0 DW |
2250 | bgp_flag_unset (bgp, BGP_FLAG_SHOW_HOSTNAME); |
2251 | return CMD_SUCCESS; | |
2252 | } | |
2253 | ||
8233ef81 | 2254 | /* "bgp network import-check" configuration. */ |
718e3744 | 2255 | DEFUN (bgp_network_import_check, |
2256 | bgp_network_import_check_cmd, | |
5623e905 | 2257 | "bgp network import-check", |
718e3744 | 2258 | "BGP specific commands\n" |
2259 | "BGP network command\n" | |
5623e905 | 2260 | "Check BGP network route exists in IGP\n") |
718e3744 | 2261 | { |
cdc2d765 | 2262 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
078430f6 DS |
2263 | if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) |
2264 | { | |
2265 | bgp_flag_set (bgp, BGP_FLAG_IMPORT_CHECK); | |
5623e905 | 2266 | bgp_static_redo_import_check(bgp); |
078430f6 DS |
2267 | } |
2268 | ||
718e3744 | 2269 | return CMD_SUCCESS; |
2270 | } | |
2271 | ||
8233ef81 DW |
2272 | ALIAS_HIDDEN (bgp_network_import_check, |
2273 | bgp_network_import_check_exact_cmd, | |
2274 | "bgp network import-check exact", | |
2275 | "BGP specific commands\n" | |
2276 | "BGP network command\n" | |
2277 | "Check BGP network route exists in IGP\n" | |
2278 | "Match route precisely\n") | |
2279 | ||
718e3744 | 2280 | DEFUN (no_bgp_network_import_check, |
2281 | no_bgp_network_import_check_cmd, | |
5623e905 | 2282 | "no bgp network import-check", |
718e3744 | 2283 | NO_STR |
2284 | "BGP specific commands\n" | |
2285 | "BGP network command\n" | |
2286 | "Check BGP network route exists in IGP\n") | |
2287 | { | |
cdc2d765 | 2288 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
078430f6 DS |
2289 | if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) |
2290 | { | |
2291 | bgp_flag_unset (bgp, BGP_FLAG_IMPORT_CHECK); | |
078430f6 DS |
2292 | bgp_static_redo_import_check(bgp); |
2293 | } | |
5623e905 | 2294 | |
718e3744 | 2295 | return CMD_SUCCESS; |
2296 | } | |
6b0655a2 | 2297 | |
718e3744 | 2298 | DEFUN (bgp_default_local_preference, |
2299 | bgp_default_local_preference_cmd, | |
6147e2c6 | 2300 | "bgp default local-preference (0-4294967295)", |
718e3744 | 2301 | "BGP specific commands\n" |
2302 | "Configure BGP defaults\n" | |
2303 | "local preference (higher=more preferred)\n" | |
2304 | "Configure default local preference value\n") | |
2305 | { | |
cdc2d765 | 2306 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2307 | int idx_number = 3; |
718e3744 | 2308 | u_int32_t local_pref; |
2309 | ||
c500ae40 | 2310 | VTY_GET_INTEGER ("local preference", local_pref, argv[idx_number]->arg); |
718e3744 | 2311 | |
2312 | bgp_default_local_preference_set (bgp, local_pref); | |
f31fa004 | 2313 | bgp_clear_star_soft_in (vty, bgp->name); |
718e3744 | 2314 | |
2315 | return CMD_SUCCESS; | |
2316 | } | |
2317 | ||
2318 | DEFUN (no_bgp_default_local_preference, | |
2319 | no_bgp_default_local_preference_cmd, | |
838758ac | 2320 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 2321 | NO_STR |
2322 | "BGP specific commands\n" | |
2323 | "Configure BGP defaults\n" | |
838758ac DW |
2324 | "local preference (higher=more preferred)\n" |
2325 | "Configure default local preference value\n") | |
718e3744 | 2326 | { |
cdc2d765 | 2327 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2328 | bgp_default_local_preference_unset (bgp); |
f31fa004 | 2329 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 2330 | |
718e3744 | 2331 | return CMD_SUCCESS; |
2332 | } | |
2333 | ||
6b0655a2 | 2334 | |
3f9c7369 DS |
2335 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
2336 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 2337 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
2338 | "BGP specific commands\n" |
2339 | "Configure BGP defaults\n" | |
2340 | "subgroup-pkt-queue-max\n" | |
2341 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 2342 | { |
cdc2d765 | 2343 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2344 | int idx_number = 3; |
3f9c7369 | 2345 | u_int32_t max_size; |
8bd9d948 | 2346 | |
c500ae40 | 2347 | VTY_GET_INTEGER ("subgroup packet queue max", max_size, argv[idx_number]->arg); |
3f9c7369 DS |
2348 | |
2349 | bgp_default_subgroup_pkt_queue_max_set (bgp, max_size); | |
2350 | ||
2351 | return CMD_SUCCESS; | |
2352 | } | |
2353 | ||
2354 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
2355 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 2356 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
2357 | NO_STR |
2358 | "BGP specific commands\n" | |
2359 | "Configure BGP defaults\n" | |
838758ac DW |
2360 | "subgroup-pkt-queue-max\n" |
2361 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 2362 | { |
cdc2d765 | 2363 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3f9c7369 DS |
2364 | bgp_default_subgroup_pkt_queue_max_unset (bgp); |
2365 | return CMD_SUCCESS; | |
8bd9d948 DS |
2366 | } |
2367 | ||
813d4307 | 2368 | |
8bd9d948 DS |
2369 | DEFUN (bgp_rr_allow_outbound_policy, |
2370 | bgp_rr_allow_outbound_policy_cmd, | |
2371 | "bgp route-reflector allow-outbound-policy", | |
2372 | "BGP specific commands\n" | |
2373 | "Allow modifications made by out route-map\n" | |
2374 | "on ibgp neighbors\n") | |
2375 | { | |
cdc2d765 | 2376 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 DS |
2377 | |
2378 | if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) | |
2379 | { | |
2380 | bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3f9c7369 | 2381 | update_group_announce_rrclients(bgp); |
f31fa004 | 2382 | bgp_clear_star_soft_out (vty, bgp->name); |
8bd9d948 DS |
2383 | } |
2384 | ||
2385 | return CMD_SUCCESS; | |
2386 | } | |
2387 | ||
2388 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
2389 | no_bgp_rr_allow_outbound_policy_cmd, | |
2390 | "no bgp route-reflector allow-outbound-policy", | |
2391 | NO_STR | |
2392 | "BGP specific commands\n" | |
2393 | "Allow modifications made by out route-map\n" | |
2394 | "on ibgp neighbors\n") | |
2395 | { | |
cdc2d765 | 2396 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 DS |
2397 | |
2398 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) | |
2399 | { | |
2400 | bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3f9c7369 | 2401 | update_group_announce_rrclients(bgp); |
f31fa004 | 2402 | bgp_clear_star_soft_out (vty, bgp->name); |
8bd9d948 DS |
2403 | } |
2404 | ||
2405 | return CMD_SUCCESS; | |
2406 | } | |
2407 | ||
f14e6fdb DS |
2408 | DEFUN (bgp_listen_limit, |
2409 | bgp_listen_limit_cmd, | |
9ccf14f7 | 2410 | "bgp listen limit (1-5000)", |
f14e6fdb DS |
2411 | "BGP specific commands\n" |
2412 | "Configure BGP defaults\n" | |
2413 | "maximum number of BGP Dynamic Neighbors that can be created\n" | |
2414 | "Configure Dynamic Neighbors listen limit value\n") | |
2415 | { | |
cdc2d765 | 2416 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2417 | int idx_number = 3; |
f14e6fdb DS |
2418 | int listen_limit; |
2419 | ||
c500ae40 | 2420 | VTY_GET_INTEGER_RANGE ("listen limit", listen_limit, argv[idx_number]->arg, |
f14e6fdb DS |
2421 | BGP_DYNAMIC_NEIGHBORS_LIMIT_MIN, |
2422 | BGP_DYNAMIC_NEIGHBORS_LIMIT_MAX); | |
2423 | ||
2424 | bgp_listen_limit_set (bgp, listen_limit); | |
2425 | ||
2426 | return CMD_SUCCESS; | |
2427 | } | |
2428 | ||
2429 | DEFUN (no_bgp_listen_limit, | |
2430 | no_bgp_listen_limit_cmd, | |
838758ac | 2431 | "no bgp listen limit [(1-5000)]", |
f14e6fdb DS |
2432 | "BGP specific commands\n" |
2433 | "Configure BGP defaults\n" | |
2434 | "unset maximum number of BGP Dynamic Neighbors that can be created\n" | |
838758ac DW |
2435 | "Configure Dynamic Neighbors listen limit value to default\n" |
2436 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 2437 | { |
cdc2d765 | 2438 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f14e6fdb DS |
2439 | bgp_listen_limit_unset (bgp); |
2440 | return CMD_SUCCESS; | |
2441 | } | |
2442 | ||
2443 | ||
20eb8864 | 2444 | /* |
2445 | * Check if this listen range is already configured. Check for exact | |
2446 | * match or overlap based on input. | |
2447 | */ | |
2448 | static struct peer_group * | |
2449 | listen_range_exists (struct bgp *bgp, struct prefix *range, int exact) | |
2450 | { | |
2451 | struct listnode *node, *nnode; | |
2452 | struct listnode *node1, *nnode1; | |
2453 | struct peer_group *group; | |
2454 | struct prefix *lr; | |
2455 | afi_t afi; | |
2456 | int match; | |
2457 | ||
2458 | afi = family2afi(range->family); | |
2459 | for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) | |
2460 | { | |
2461 | for (ALL_LIST_ELEMENTS (group->listen_range[afi], node1, | |
2462 | nnode1, lr)) | |
2463 | { | |
2464 | if (exact) | |
2465 | match = prefix_same (range, lr); | |
2466 | else | |
2467 | match = (prefix_match (range, lr) || prefix_match (lr, range)); | |
2468 | if (match) | |
2469 | return group; | |
2470 | } | |
2471 | } | |
2472 | ||
2473 | return NULL; | |
2474 | } | |
2475 | ||
f14e6fdb DS |
2476 | DEFUN (bgp_listen_range, |
2477 | bgp_listen_range_cmd, | |
9ccf14f7 | 2478 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
f14e6fdb | 2479 | "BGP specific commands\n" |
d7fa34c1 QY |
2480 | "Configure BGP dynamic neighbors listen range\n" |
2481 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
2482 | NEIGHBOR_ADDR_STR |
2483 | "Member of the peer-group\n" | |
2484 | "Peer-group name\n") | |
f14e6fdb | 2485 | { |
cdc2d765 | 2486 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f14e6fdb | 2487 | struct prefix range; |
20eb8864 | 2488 | struct peer_group *group, *existing_group; |
f14e6fdb DS |
2489 | afi_t afi; |
2490 | int ret; | |
d7fa34c1 | 2491 | int idx = 0; |
f14e6fdb | 2492 | |
d7fa34c1 QY |
2493 | argv_find (argv, argc, "A.B.C.D/M", &idx); |
2494 | argv_find (argv, argc, "X:X::X:X/M", &idx); | |
2495 | char *prefix = argv[idx]->arg; | |
2496 | argv_find (argv, argc, "WORD", &idx); | |
2497 | char *peergroup = argv[idx]->arg; | |
f14e6fdb | 2498 | |
f14e6fdb | 2499 | /* Convert IP prefix string to struct prefix. */ |
d7fa34c1 | 2500 | ret = str2prefix (prefix, &range); |
f14e6fdb DS |
2501 | if (! ret) |
2502 | { | |
2503 | vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE); | |
2504 | return CMD_WARNING; | |
2505 | } | |
2506 | ||
2507 | afi = family2afi(range.family); | |
2508 | ||
f14e6fdb DS |
2509 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6)) |
2510 | { | |
2511 | vty_out (vty, "%% Malformed listen range (link-local address)%s", | |
2512 | VTY_NEWLINE); | |
2513 | return CMD_WARNING; | |
2514 | } | |
f14e6fdb DS |
2515 | |
2516 | apply_mask (&range); | |
2517 | ||
20eb8864 | 2518 | /* Check if same listen range is already configured. */ |
2519 | existing_group = listen_range_exists (bgp, &range, 1); | |
2520 | if (existing_group) | |
2521 | { | |
d7fa34c1 | 2522 | if (strcmp (existing_group->name, peergroup) == 0) |
20eb8864 | 2523 | return CMD_SUCCESS; |
2524 | else | |
2525 | { | |
2526 | vty_out (vty, "%% Same listen range is attached to peer-group %s%s", | |
2527 | existing_group->name, VTY_NEWLINE); | |
2528 | return CMD_WARNING; | |
2529 | } | |
2530 | } | |
2531 | ||
2532 | /* Check if an overlapping listen range exists. */ | |
2533 | if (listen_range_exists (bgp, &range, 0)) | |
2534 | { | |
2535 | vty_out (vty, "%% Listen range overlaps with existing listen range%s", | |
2536 | VTY_NEWLINE); | |
2537 | return CMD_WARNING; | |
2538 | } | |
f14e6fdb | 2539 | |
d7fa34c1 | 2540 | group = peer_group_lookup (bgp, peergroup); |
f14e6fdb DS |
2541 | if (! group) |
2542 | { | |
2543 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
2544 | return CMD_WARNING; | |
2545 | } | |
2546 | ||
2547 | ret = peer_group_listen_range_add(group, &range); | |
2548 | return bgp_vty_return (vty, ret); | |
2549 | } | |
2550 | ||
2551 | DEFUN (no_bgp_listen_range, | |
2552 | no_bgp_listen_range_cmd, | |
d7fa34c1 QY |
2553 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
2554 | NO_STR | |
f14e6fdb | 2555 | "BGP specific commands\n" |
d7fa34c1 QY |
2556 | "Unconfigure BGP dynamic neighbors listen range\n" |
2557 | "Unconfigure BGP dynamic neighbors listen range\n" | |
2558 | NEIGHBOR_ADDR_STR | |
2559 | "Member of the peer-group\n" | |
2560 | "Peer-group name\n") | |
f14e6fdb | 2561 | { |
cdc2d765 | 2562 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f14e6fdb DS |
2563 | struct prefix range; |
2564 | struct peer_group *group; | |
2565 | afi_t afi; | |
2566 | int ret; | |
d7fa34c1 QY |
2567 | int idx = 0; |
2568 | ||
2569 | argv_find (argv, argc, "A.B.C.D/M", &idx); | |
2570 | argv_find (argv, argc, "X:X::X:X/M", &idx); | |
2571 | char *prefix = argv[idx]->arg; | |
2572 | argv_find (argv, argc, "WORD", &idx); | |
2573 | char *peergroup = argv[idx]->arg; | |
f14e6fdb | 2574 | |
c500ae40 | 2575 | // VTY_GET_IPV4_PREFIX ("listen range", range, argv[idx_ipv4_prefixlen]->arg); |
f14e6fdb DS |
2576 | |
2577 | /* Convert IP prefix string to struct prefix. */ | |
d7fa34c1 | 2578 | ret = str2prefix (prefix, &range); |
f14e6fdb DS |
2579 | if (! ret) |
2580 | { | |
2581 | vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE); | |
2582 | return CMD_WARNING; | |
2583 | } | |
2584 | ||
2585 | afi = family2afi(range.family); | |
2586 | ||
f14e6fdb DS |
2587 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6)) |
2588 | { | |
2589 | vty_out (vty, "%% Malformed listen range (link-local address)%s", | |
2590 | VTY_NEWLINE); | |
2591 | return CMD_WARNING; | |
2592 | } | |
f14e6fdb DS |
2593 | |
2594 | apply_mask (&range); | |
2595 | ||
d7fa34c1 | 2596 | group = peer_group_lookup (bgp, peergroup); |
f14e6fdb DS |
2597 | if (! group) |
2598 | { | |
2599 | vty_out (vty, "%% Peer-group does not exist%s", VTY_NEWLINE); | |
2600 | return CMD_WARNING; | |
2601 | } | |
2602 | ||
2603 | ret = peer_group_listen_range_del(group, &range); | |
2604 | return bgp_vty_return (vty, ret); | |
2605 | } | |
2606 | ||
2607 | int | |
2608 | bgp_config_write_listen (struct vty *vty, struct bgp *bgp) | |
2609 | { | |
2610 | struct peer_group *group; | |
2611 | struct listnode *node, *nnode, *rnode, *nrnode; | |
2612 | struct prefix *range; | |
2613 | afi_t afi; | |
4690c7d7 | 2614 | char buf[PREFIX2STR_BUFFER]; |
f14e6fdb DS |
2615 | |
2616 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
2617 | vty_out (vty, " bgp listen limit %d%s", | |
2618 | bgp->dynamic_neighbors_limit, VTY_NEWLINE); | |
2619 | ||
2620 | for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) | |
2621 | { | |
2622 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
2623 | { | |
2624 | for (ALL_LIST_ELEMENTS (group->listen_range[afi], rnode, nrnode, range)) | |
2625 | { | |
2626 | prefix2str(range, buf, sizeof(buf)); | |
2627 | vty_out(vty, " bgp listen range %s peer-group %s%s", | |
2628 | buf, group->name, VTY_NEWLINE); | |
2629 | } | |
2630 | } | |
2631 | } | |
2632 | ||
2633 | return 0; | |
2634 | } | |
2635 | ||
2636 | ||
907f92c8 DS |
2637 | DEFUN (bgp_disable_connected_route_check, |
2638 | bgp_disable_connected_route_check_cmd, | |
2639 | "bgp disable-ebgp-connected-route-check", | |
2640 | "BGP specific commands\n" | |
2641 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2642 | { | |
cdc2d765 | 2643 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
907f92c8 | 2644 | bgp_flag_set (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); |
f31fa004 | 2645 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 2646 | |
907f92c8 DS |
2647 | return CMD_SUCCESS; |
2648 | } | |
2649 | ||
2650 | DEFUN (no_bgp_disable_connected_route_check, | |
2651 | no_bgp_disable_connected_route_check_cmd, | |
2652 | "no bgp disable-ebgp-connected-route-check", | |
2653 | NO_STR | |
2654 | "BGP specific commands\n" | |
2655 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2656 | { | |
cdc2d765 | 2657 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
907f92c8 | 2658 | bgp_flag_unset (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); |
f31fa004 | 2659 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 2660 | |
907f92c8 DS |
2661 | return CMD_SUCCESS; |
2662 | } | |
2663 | ||
2664 | ||
718e3744 | 2665 | static int |
e52702f2 | 2666 | peer_remote_as_vty (struct vty *vty, const char *peer_str, |
fd79ac91 | 2667 | const char *as_str, afi_t afi, safi_t safi) |
718e3744 | 2668 | { |
cdc2d765 | 2669 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2670 | int ret; |
718e3744 | 2671 | as_t as; |
0299c004 | 2672 | int as_type = AS_SPECIFIED; |
718e3744 | 2673 | union sockunion su; |
2674 | ||
7ae5fc81 | 2675 | if (as_str[0] == 'i') |
0299c004 DS |
2676 | { |
2677 | as = 0; | |
2678 | as_type = AS_INTERNAL; | |
2679 | } | |
7ae5fc81 | 2680 | else if (as_str[0] == 'e') |
0299c004 DS |
2681 | { |
2682 | as = 0; | |
2683 | as_type = AS_EXTERNAL; | |
2684 | } | |
2685 | else | |
2686 | { | |
2687 | /* Get AS number. */ | |
2688 | VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX); | |
2689 | } | |
718e3744 | 2690 | |
2691 | /* If peer is peer group, call proper function. */ | |
2692 | ret = str2sockunion (peer_str, &su); | |
2693 | if (ret < 0) | |
2694 | { | |
a80beece | 2695 | /* Check for peer by interface */ |
0299c004 | 2696 | ret = peer_remote_as (bgp, NULL, peer_str, &as, as_type, afi, safi); |
718e3744 | 2697 | if (ret < 0) |
a80beece | 2698 | { |
0299c004 | 2699 | ret = peer_group_remote_as (bgp, peer_str, &as, as_type); |
a80beece DS |
2700 | if (ret < 0) |
2701 | { | |
2702 | vty_out (vty, "%% Create the peer-group or interface first%s", | |
2703 | VTY_NEWLINE); | |
2704 | return CMD_WARNING; | |
2705 | } | |
2706 | return CMD_SUCCESS; | |
2707 | } | |
718e3744 | 2708 | } |
a80beece | 2709 | else |
718e3744 | 2710 | { |
6aeb9e78 | 2711 | if (peer_address_self_check (bgp, &su)) |
a80beece DS |
2712 | { |
2713 | vty_out (vty, "%% Can not configure the local system as neighbor%s", | |
2714 | VTY_NEWLINE); | |
2715 | return CMD_WARNING; | |
2716 | } | |
0299c004 | 2717 | ret = peer_remote_as (bgp, &su, NULL, &as, as_type, afi, safi); |
718e3744 | 2718 | } |
2719 | ||
718e3744 | 2720 | /* This peer belongs to peer group. */ |
2721 | switch (ret) | |
2722 | { | |
2723 | case BGP_ERR_PEER_GROUP_MEMBER: | |
aea339f7 | 2724 | vty_out (vty, "%% Peer-group AS %u. Cannot configure remote-as for member%s", as, VTY_NEWLINE); |
718e3744 | 2725 | return CMD_WARNING; |
718e3744 | 2726 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: |
aea339f7 | 2727 | vty_out (vty, "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external%s", as, as_str, VTY_NEWLINE); |
718e3744 | 2728 | return CMD_WARNING; |
718e3744 | 2729 | } |
2730 | return bgp_vty_return (vty, ret); | |
2731 | } | |
2732 | ||
2733 | DEFUN (neighbor_remote_as, | |
2734 | neighbor_remote_as_cmd, | |
3a2d747c | 2735 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2736 | NEIGHBOR_STR |
2737 | NEIGHBOR_ADDR_STR2 | |
2738 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 2739 | AS_STR |
3a2d747c QY |
2740 | "Internal BGP peer\n" |
2741 | "External BGP peer\n") | |
718e3744 | 2742 | { |
c500ae40 DW |
2743 | int idx_peer = 1; |
2744 | int idx_remote_as = 3; | |
2745 | return peer_remote_as_vty (vty, argv[idx_peer]->arg, argv[idx_remote_as]->arg, AFI_IP, SAFI_UNICAST); | |
718e3744 | 2746 | } |
6b0655a2 | 2747 | |
4c48cf63 DW |
2748 | static int |
2749 | peer_conf_interface_get (struct vty *vty, const char *conf_if, afi_t afi, | |
b3a39dc5 DD |
2750 | safi_t safi, int v6only, const char *peer_group_name, |
2751 | const char *as_str) | |
a80beece | 2752 | { |
cdc2d765 | 2753 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
b3a39dc5 DD |
2754 | as_t as = 0; |
2755 | int as_type = AS_UNSPECIFIED; | |
a80beece DS |
2756 | struct peer *peer; |
2757 | struct peer_group *group; | |
4c48cf63 DW |
2758 | int ret = 0; |
2759 | union sockunion su; | |
a80beece | 2760 | |
4c48cf63 DW |
2761 | group = peer_group_lookup (bgp, conf_if); |
2762 | ||
a80beece DS |
2763 | if (group) |
2764 | { | |
2765 | vty_out (vty, "%% Name conflict with peer-group %s", VTY_NEWLINE); | |
2766 | return CMD_WARNING; | |
2767 | } | |
2768 | ||
b3a39dc5 DD |
2769 | if (as_str) |
2770 | { | |
7ae5fc81 | 2771 | if (as_str[0] == 'i') |
b3a39dc5 DD |
2772 | { |
2773 | as_type = AS_INTERNAL; | |
2774 | } | |
7ae5fc81 | 2775 | else if (as_str[0] == 'e') |
b3a39dc5 DD |
2776 | { |
2777 | as_type = AS_EXTERNAL; | |
2778 | } | |
2779 | else | |
2780 | { | |
2781 | /* Get AS number. */ | |
2782 | VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX); | |
2783 | as_type = AS_SPECIFIED; | |
2784 | } | |
2785 | } | |
2786 | ||
4c48cf63 DW |
2787 | peer = peer_lookup_by_conf_if (bgp, conf_if); |
2788 | if (!peer) | |
2789 | { | |
2790 | if (bgp_flag_check (bgp, BGP_FLAG_NO_DEFAULT_IPV4) | |
2791 | && afi == AFI_IP && safi == SAFI_UNICAST) | |
b3a39dc5 DD |
2792 | peer = peer_create (NULL, conf_if, bgp, bgp->as, as, as_type, 0, 0, |
2793 | NULL); | |
4c48cf63 | 2794 | else |
b3a39dc5 DD |
2795 | peer = peer_create (NULL, conf_if, bgp, bgp->as, as, as_type, afi, safi, |
2796 | NULL); | |
4c48cf63 DW |
2797 | |
2798 | if (peer && v6only) | |
2799 | SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
4a04e5f7 | 2800 | |
2801 | /* Request zebra to initiate IPv6 RAs on this interface. We do this | |
2802 | * any unnumbered peer in order to not worry about run-time transitions | |
2803 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 address | |
2804 | * gets deleted later etc.) | |
2805 | */ | |
2806 | if (peer->ifp) | |
b3a39dc5 DD |
2807 | { |
2808 | bgp_zebra_initiate_radv (bgp, peer); | |
2809 | } | |
2810 | peer_flag_set (peer, PEER_FLAG_CAPABILITY_ENHE); | |
4c48cf63 DW |
2811 | } |
2812 | else if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) || | |
2813 | (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) | |
2814 | { | |
2815 | if (v6only) | |
2816 | SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2817 | else | |
2818 | UNSET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2819 | ||
2820 | /* v6only flag changed. Reset bgp seesion */ | |
2821 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) | |
2822 | { | |
2823 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
2824 | bgp_notify_send (peer, BGP_NOTIFY_CEASE, | |
2825 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2826 | } | |
2827 | else | |
2828 | bgp_session_reset(peer); | |
2829 | } | |
2830 | ||
a80beece DS |
2831 | if (!peer) |
2832 | return CMD_WARNING; | |
2833 | ||
4c48cf63 DW |
2834 | if (peer_group_name) |
2835 | { | |
2836 | group = peer_group_lookup (bgp, peer_group_name); | |
2837 | if (! group) | |
2838 | { | |
2839 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
2840 | return CMD_WARNING; | |
2841 | } | |
2842 | ||
2843 | ret = peer_group_bind (bgp, &su, peer, group, &as); | |
2844 | } | |
2845 | ||
2846 | return bgp_vty_return (vty, ret); | |
a80beece DS |
2847 | } |
2848 | ||
4c48cf63 DW |
2849 | DEFUN (neighbor_interface_config, |
2850 | neighbor_interface_config_cmd, | |
31500417 | 2851 | "neighbor WORD interface [peer-group WORD]", |
4c48cf63 DW |
2852 | NEIGHBOR_STR |
2853 | "Interface name or neighbor tag\n" | |
31500417 DW |
2854 | "Enable BGP on interface\n" |
2855 | "Member of the peer-group\n" | |
16cedbb0 | 2856 | "Peer-group name\n") |
4c48cf63 | 2857 | { |
c500ae40 | 2858 | int idx_word = 1; |
31500417 DW |
2859 | int idx_peer_group_word = 4; |
2860 | ||
2861 | if (argc > idx_peer_group_word) | |
c500ae40 | 2862 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, |
31500417 | 2863 | argv[idx_peer_group_word]->arg, NULL); |
4c48cf63 | 2864 | else |
c500ae40 | 2865 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, |
b3a39dc5 | 2866 | NULL, NULL); |
4c48cf63 DW |
2867 | } |
2868 | ||
4c48cf63 DW |
2869 | DEFUN (neighbor_interface_config_v6only, |
2870 | neighbor_interface_config_v6only_cmd, | |
31500417 | 2871 | "neighbor WORD interface v6only [peer-group WORD]", |
4c48cf63 DW |
2872 | NEIGHBOR_STR |
2873 | "Interface name or neighbor tag\n" | |
2874 | "Enable BGP on interface\n" | |
31500417 DW |
2875 | "Enable BGP with v6 link-local only\n" |
2876 | "Member of the peer-group\n" | |
16cedbb0 | 2877 | "Peer-group name\n") |
4c48cf63 | 2878 | { |
c500ae40 | 2879 | int idx_word = 1; |
31500417 DW |
2880 | int idx_peer_group_word = 5; |
2881 | ||
2882 | if (argc > idx_peer_group_word) | |
2883 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
2884 | argv[idx_peer_group_word]->arg, NULL); | |
2885 | ||
c500ae40 | 2886 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, |
31500417 | 2887 | NULL, NULL); |
4c48cf63 DW |
2888 | } |
2889 | ||
a80beece | 2890 | |
b3a39dc5 DD |
2891 | DEFUN (neighbor_interface_config_remote_as, |
2892 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 2893 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2894 | NEIGHBOR_STR |
2895 | "Interface name or neighbor tag\n" | |
2896 | "Enable BGP on interface\n" | |
3a2d747c | 2897 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2898 | AS_STR |
3a2d747c QY |
2899 | "Internal BGP peer\n" |
2900 | "External BGP peer\n") | |
b3a39dc5 | 2901 | { |
c500ae40 DW |
2902 | int idx_word = 1; |
2903 | int idx_remote_as = 4; | |
2904 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
2905 | NULL, argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2906 | } |
2907 | ||
2908 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
2909 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 2910 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2911 | NEIGHBOR_STR |
2912 | "Interface name or neighbor tag\n" | |
3a2d747c | 2913 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 2914 | "Enable BGP on interface\n" |
3a2d747c | 2915 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2916 | AS_STR |
3a2d747c QY |
2917 | "Internal BGP peer\n" |
2918 | "External BGP peer\n") | |
b3a39dc5 | 2919 | { |
c500ae40 DW |
2920 | int idx_word = 1; |
2921 | int idx_remote_as = 5; | |
2922 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
2923 | NULL, argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2924 | } |
2925 | ||
718e3744 | 2926 | DEFUN (neighbor_peer_group, |
2927 | neighbor_peer_group_cmd, | |
2928 | "neighbor WORD peer-group", | |
2929 | NEIGHBOR_STR | |
a80beece | 2930 | "Interface name or neighbor tag\n" |
718e3744 | 2931 | "Configure peer-group\n") |
2932 | { | |
cdc2d765 | 2933 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2934 | int idx_word = 1; |
a80beece | 2935 | struct peer *peer; |
718e3744 | 2936 | struct peer_group *group; |
2937 | ||
c500ae40 | 2938 | peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg); |
a80beece DS |
2939 | if (peer) |
2940 | { | |
2941 | vty_out (vty, "%% Name conflict with interface: %s", VTY_NEWLINE); | |
2942 | return CMD_WARNING; | |
2943 | } | |
718e3744 | 2944 | |
c500ae40 | 2945 | group = peer_group_get (bgp, argv[idx_word]->arg); |
718e3744 | 2946 | if (! group) |
2947 | return CMD_WARNING; | |
2948 | ||
2949 | return CMD_SUCCESS; | |
2950 | } | |
2951 | ||
2952 | DEFUN (no_neighbor, | |
2953 | no_neighbor_cmd, | |
dab8cd00 | 2954 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 2955 | NO_STR |
2956 | NEIGHBOR_STR | |
3a2d747c QY |
2957 | NEIGHBOR_ADDR_STR2 |
2958 | "Specify a BGP neighbor\n" | |
2959 | AS_STR | |
2960 | "Internal BGP peer\n" | |
2961 | "External BGP peer\n") | |
718e3744 | 2962 | { |
cdc2d765 | 2963 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2964 | int idx_peer = 2; |
718e3744 | 2965 | int ret; |
2966 | union sockunion su; | |
2967 | struct peer_group *group; | |
2968 | struct peer *peer; | |
1ff9a340 | 2969 | struct peer *other; |
718e3744 | 2970 | |
c500ae40 | 2971 | ret = str2sockunion (argv[idx_peer]->arg, &su); |
718e3744 | 2972 | if (ret < 0) |
2973 | { | |
a80beece | 2974 | /* look up for neighbor by interface name config. */ |
cdc2d765 | 2975 | peer = peer_lookup_by_conf_if (bgp, argv[idx_peer]->arg); |
a80beece DS |
2976 | if (peer) |
2977 | { | |
4a04e5f7 | 2978 | /* Request zebra to terminate IPv6 RAs on this interface. */ |
2979 | if (peer->ifp) | |
2980 | bgp_zebra_terminate_radv (peer->bgp, peer); | |
a80beece DS |
2981 | peer_delete (peer); |
2982 | return CMD_SUCCESS; | |
2983 | } | |
2984 | ||
cdc2d765 | 2985 | group = peer_group_lookup (bgp, argv[idx_peer]->arg); |
718e3744 | 2986 | if (group) |
2987 | peer_group_delete (group); | |
2988 | else | |
2989 | { | |
2990 | vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE); | |
2991 | return CMD_WARNING; | |
2992 | } | |
2993 | } | |
2994 | else | |
2995 | { | |
cdc2d765 | 2996 | peer = peer_lookup (bgp, &su); |
718e3744 | 2997 | if (peer) |
1ff9a340 | 2998 | { |
f14e6fdb DS |
2999 | if (peer_dynamic_neighbor (peer)) |
3000 | { | |
3001 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
3002 | VTY_NEWLINE); | |
3003 | return CMD_WARNING; | |
3004 | } | |
3005 | ||
1ff9a340 DS |
3006 | other = peer->doppelganger; |
3007 | peer_delete (peer); | |
3008 | if (other && other->status != Deleted) | |
3009 | peer_delete(other); | |
3010 | } | |
718e3744 | 3011 | } |
3012 | ||
3013 | return CMD_SUCCESS; | |
3014 | } | |
3015 | ||
a80beece DS |
3016 | DEFUN (no_neighbor_interface_config, |
3017 | no_neighbor_interface_config_cmd, | |
31500417 | 3018 | "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
3019 | NO_STR |
3020 | NEIGHBOR_STR | |
3021 | "Interface name\n" | |
31500417 DW |
3022 | "Configure BGP on interface\n" |
3023 | "Enable BGP with v6 link-local only\n" | |
3024 | "Member of the peer-group\n" | |
16cedbb0 | 3025 | "Peer-group name\n" |
3a2d747c QY |
3026 | "Specify a BGP neighbor\n" |
3027 | AS_STR | |
3028 | "Internal BGP peer\n" | |
3029 | "External BGP peer\n") | |
a80beece | 3030 | { |
cdc2d765 | 3031 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 3032 | int idx_word = 2; |
a80beece DS |
3033 | struct peer *peer; |
3034 | ||
3035 | /* look up for neighbor by interface name config. */ | |
cdc2d765 | 3036 | peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg); |
a80beece DS |
3037 | if (peer) |
3038 | { | |
4a04e5f7 | 3039 | /* Request zebra to terminate IPv6 RAs on this interface. */ |
3040 | if (peer->ifp) | |
3041 | bgp_zebra_terminate_radv (peer->bgp, peer); | |
a80beece DS |
3042 | peer_delete (peer); |
3043 | } | |
3044 | else | |
3045 | { | |
3046 | vty_out (vty, "%% Create the bgp interface first%s", VTY_NEWLINE); | |
3047 | return CMD_WARNING; | |
3048 | } | |
3049 | return CMD_SUCCESS; | |
3050 | } | |
3051 | ||
718e3744 | 3052 | DEFUN (no_neighbor_peer_group, |
3053 | no_neighbor_peer_group_cmd, | |
3054 | "no neighbor WORD peer-group", | |
3055 | NO_STR | |
3056 | NEIGHBOR_STR | |
3057 | "Neighbor tag\n" | |
3058 | "Configure peer-group\n") | |
3059 | { | |
cdc2d765 | 3060 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 3061 | int idx_word = 2; |
718e3744 | 3062 | struct peer_group *group; |
3063 | ||
cdc2d765 | 3064 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 3065 | if (group) |
3066 | peer_group_delete (group); | |
3067 | else | |
3068 | { | |
3069 | vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE); | |
3070 | return CMD_WARNING; | |
3071 | } | |
3072 | return CMD_SUCCESS; | |
3073 | } | |
3074 | ||
a80beece DS |
3075 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
3076 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 3077 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3078 | NO_STR |
3079 | NEIGHBOR_STR | |
a80beece | 3080 | "Interface name or neighbor tag\n" |
718e3744 | 3081 | "Specify a BGP neighbor\n" |
3a2d747c QY |
3082 | AS_STR |
3083 | "Internal BGP peer\n" | |
3084 | "External BGP peer\n") | |
718e3744 | 3085 | { |
cdc2d765 | 3086 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 3087 | int idx_word = 2; |
718e3744 | 3088 | struct peer_group *group; |
a80beece DS |
3089 | struct peer *peer; |
3090 | ||
3091 | /* look up for neighbor by interface name config. */ | |
cdc2d765 | 3092 | peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg); |
a80beece DS |
3093 | if (peer) |
3094 | { | |
0299c004 | 3095 | peer_as_change (peer, 0, AS_SPECIFIED); |
a80beece DS |
3096 | return CMD_SUCCESS; |
3097 | } | |
718e3744 | 3098 | |
cdc2d765 | 3099 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 3100 | if (group) |
3101 | peer_group_remote_as_delete (group); | |
3102 | else | |
3103 | { | |
a80beece | 3104 | vty_out (vty, "%% Create the peer-group or interface first%s", VTY_NEWLINE); |
718e3744 | 3105 | return CMD_WARNING; |
3106 | } | |
3107 | return CMD_SUCCESS; | |
3108 | } | |
6b0655a2 | 3109 | |
718e3744 | 3110 | DEFUN (neighbor_local_as, |
3111 | neighbor_local_as_cmd, | |
9ccf14f7 | 3112 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 3113 | NEIGHBOR_STR |
3114 | NEIGHBOR_ADDR_STR2 | |
3115 | "Specify a local-as number\n" | |
3116 | "AS number used as local AS\n") | |
3117 | { | |
c500ae40 DW |
3118 | int idx_peer = 1; |
3119 | int idx_number = 3; | |
718e3744 | 3120 | struct peer *peer; |
3121 | int ret; | |
e14fda0f | 3122 | as_t as; |
718e3744 | 3123 | |
c500ae40 | 3124 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3125 | if (! peer) |
3126 | return CMD_WARNING; | |
3127 | ||
b6f1faf0 | 3128 | VTY_GET_INTEGER_RANGE ("Local AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); |
e14fda0f | 3129 | ret = peer_local_as_set (peer, as, 0, 0); |
718e3744 | 3130 | return bgp_vty_return (vty, ret); |
3131 | } | |
3132 | ||
3133 | DEFUN (neighbor_local_as_no_prepend, | |
3134 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 3135 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 3136 | NEIGHBOR_STR |
3137 | NEIGHBOR_ADDR_STR2 | |
3138 | "Specify a local-as number\n" | |
3139 | "AS number used as local AS\n" | |
3140 | "Do not prepend local-as to updates from ebgp peers\n") | |
3141 | { | |
c500ae40 DW |
3142 | int idx_peer = 1; |
3143 | int idx_number = 3; | |
718e3744 | 3144 | struct peer *peer; |
3145 | int ret; | |
e14fda0f | 3146 | as_t as; |
718e3744 | 3147 | |
c500ae40 | 3148 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3149 | if (! peer) |
3150 | return CMD_WARNING; | |
3151 | ||
b6f1faf0 | 3152 | VTY_GET_INTEGER_RANGE ("Local AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); |
e14fda0f | 3153 | ret = peer_local_as_set (peer, as, 1, 0); |
718e3744 | 3154 | return bgp_vty_return (vty, ret); |
3155 | } | |
3156 | ||
9d3f9705 AC |
3157 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
3158 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 3159 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
3160 | NEIGHBOR_STR |
3161 | NEIGHBOR_ADDR_STR2 | |
3162 | "Specify a local-as number\n" | |
3163 | "AS number used as local AS\n" | |
3164 | "Do not prepend local-as to updates from ebgp peers\n" | |
3165 | "Do not prepend local-as to updates from ibgp peers\n") | |
3166 | { | |
c500ae40 DW |
3167 | int idx_peer = 1; |
3168 | int idx_number = 3; | |
9d3f9705 AC |
3169 | struct peer *peer; |
3170 | int ret; | |
e14fda0f | 3171 | as_t as; |
9d3f9705 | 3172 | |
c500ae40 | 3173 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
9d3f9705 AC |
3174 | if (! peer) |
3175 | return CMD_WARNING; | |
3176 | ||
b6f1faf0 | 3177 | VTY_GET_INTEGER_RANGE ("Local AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); |
e14fda0f | 3178 | ret = peer_local_as_set (peer, as, 1, 1); |
9d3f9705 AC |
3179 | return bgp_vty_return (vty, ret); |
3180 | } | |
3181 | ||
718e3744 | 3182 | DEFUN (no_neighbor_local_as, |
3183 | no_neighbor_local_as_cmd, | |
a636c635 | 3184 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 3185 | NO_STR |
3186 | NEIGHBOR_STR | |
3187 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
3188 | "Specify a local-as number\n" |
3189 | "AS number used as local AS\n" | |
3190 | "Do not prepend local-as to updates from ebgp peers\n" | |
3191 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 3192 | { |
c500ae40 | 3193 | int idx_peer = 2; |
718e3744 | 3194 | struct peer *peer; |
3195 | int ret; | |
3196 | ||
c500ae40 | 3197 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3198 | if (! peer) |
3199 | return CMD_WARNING; | |
3200 | ||
3201 | ret = peer_local_as_unset (peer); | |
3202 | return bgp_vty_return (vty, ret); | |
3203 | } | |
3204 | ||
718e3744 | 3205 | |
9d3f9705 | 3206 | |
6b0655a2 | 3207 | |
3f9c7369 DS |
3208 | DEFUN (neighbor_solo, |
3209 | neighbor_solo_cmd, | |
9ccf14f7 | 3210 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3211 | NEIGHBOR_STR |
3212 | NEIGHBOR_ADDR_STR2 | |
3213 | "Solo peer - part of its own update group\n") | |
3214 | { | |
c500ae40 | 3215 | int idx_peer = 1; |
3f9c7369 DS |
3216 | struct peer *peer; |
3217 | int ret; | |
3218 | ||
c500ae40 | 3219 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
3f9c7369 DS |
3220 | if (! peer) |
3221 | return CMD_WARNING; | |
3222 | ||
3223 | ret = update_group_adjust_soloness(peer, 1); | |
3224 | return bgp_vty_return (vty, ret); | |
3225 | } | |
3226 | ||
3227 | DEFUN (no_neighbor_solo, | |
3228 | no_neighbor_solo_cmd, | |
9ccf14f7 | 3229 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3230 | NO_STR |
3231 | NEIGHBOR_STR | |
3232 | NEIGHBOR_ADDR_STR2 | |
3233 | "Solo peer - part of its own update group\n") | |
3234 | { | |
c500ae40 | 3235 | int idx_peer = 2; |
3f9c7369 DS |
3236 | struct peer *peer; |
3237 | int ret; | |
3238 | ||
c500ae40 | 3239 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
3f9c7369 DS |
3240 | if (! peer) |
3241 | return CMD_WARNING; | |
3242 | ||
3243 | ret = update_group_adjust_soloness(peer, 0); | |
3244 | return bgp_vty_return (vty, ret); | |
3245 | } | |
3246 | ||
0df7c91f PJ |
3247 | DEFUN (neighbor_password, |
3248 | neighbor_password_cmd, | |
9ccf14f7 | 3249 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
3250 | NEIGHBOR_STR |
3251 | NEIGHBOR_ADDR_STR2 | |
3252 | "Set a password\n" | |
3253 | "The password\n") | |
3254 | { | |
c500ae40 DW |
3255 | int idx_peer = 1; |
3256 | int idx_line = 3; | |
0df7c91f PJ |
3257 | struct peer *peer; |
3258 | int ret; | |
3259 | ||
c500ae40 | 3260 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
0df7c91f PJ |
3261 | if (! peer) |
3262 | return CMD_WARNING; | |
3263 | ||
c500ae40 | 3264 | ret = peer_password_set (peer, argv[idx_line]->arg); |
0df7c91f PJ |
3265 | return bgp_vty_return (vty, ret); |
3266 | } | |
3267 | ||
3268 | DEFUN (no_neighbor_password, | |
3269 | no_neighbor_password_cmd, | |
a636c635 | 3270 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
3271 | NO_STR |
3272 | NEIGHBOR_STR | |
3273 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
3274 | "Set a password\n" |
3275 | "The password\n") | |
0df7c91f | 3276 | { |
c500ae40 | 3277 | int idx_peer = 2; |
0df7c91f PJ |
3278 | struct peer *peer; |
3279 | int ret; | |
3280 | ||
c500ae40 | 3281 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
0df7c91f PJ |
3282 | if (! peer) |
3283 | return CMD_WARNING; | |
3284 | ||
3285 | ret = peer_password_unset (peer); | |
3286 | return bgp_vty_return (vty, ret); | |
3287 | } | |
6b0655a2 | 3288 | |
813d4307 | 3289 | |
718e3744 | 3290 | DEFUN (neighbor_activate, |
3291 | neighbor_activate_cmd, | |
9ccf14f7 | 3292 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3293 | NEIGHBOR_STR |
3294 | NEIGHBOR_ADDR_STR2 | |
3295 | "Enable the Address Family for this Neighbor\n") | |
3296 | { | |
c500ae40 | 3297 | int idx_peer = 1; |
c8560b44 | 3298 | int ret; |
718e3744 | 3299 | struct peer *peer; |
3300 | ||
c500ae40 | 3301 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3302 | if (! peer) |
3303 | return CMD_WARNING; | |
3304 | ||
c8560b44 | 3305 | ret = peer_activate (peer, bgp_node_afi (vty), bgp_node_safi (vty)); |
718e3744 | 3306 | |
c8560b44 DW |
3307 | if (ret) |
3308 | return CMD_WARNING; | |
718e3744 | 3309 | return CMD_SUCCESS; |
3310 | } | |
3311 | ||
3312 | DEFUN (no_neighbor_activate, | |
3313 | no_neighbor_activate_cmd, | |
9ccf14f7 | 3314 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3315 | NO_STR |
3316 | NEIGHBOR_STR | |
3317 | NEIGHBOR_ADDR_STR2 | |
3318 | "Enable the Address Family for this Neighbor\n") | |
3319 | { | |
c500ae40 | 3320 | int idx_peer = 2; |
718e3744 | 3321 | int ret; |
3322 | struct peer *peer; | |
3323 | ||
3324 | /* Lookup peer. */ | |
c500ae40 | 3325 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3326 | if (! peer) |
3327 | return CMD_WARNING; | |
3328 | ||
3329 | ret = peer_deactivate (peer, bgp_node_afi (vty), bgp_node_safi (vty)); | |
3330 | ||
c8560b44 DW |
3331 | if (ret) |
3332 | return CMD_WARNING; | |
3333 | return CMD_SUCCESS; | |
718e3744 | 3334 | } |
6b0655a2 | 3335 | |
718e3744 | 3336 | DEFUN (neighbor_set_peer_group, |
3337 | neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3338 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3339 | NEIGHBOR_STR |
a80beece | 3340 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3341 | "Member of the peer-group\n" |
16cedbb0 | 3342 | "Peer-group name\n") |
718e3744 | 3343 | { |
cdc2d765 | 3344 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
3345 | int idx_peer = 1; |
3346 | int idx_word = 3; | |
718e3744 | 3347 | int ret; |
3348 | as_t as; | |
3349 | union sockunion su; | |
a80beece | 3350 | struct peer *peer; |
718e3744 | 3351 | struct peer_group *group; |
3352 | ||
a80beece | 3353 | peer = NULL; |
718e3744 | 3354 | |
c500ae40 | 3355 | ret = str2sockunion (argv[idx_peer]->arg, &su); |
718e3744 | 3356 | if (ret < 0) |
3357 | { | |
c500ae40 | 3358 | peer = peer_lookup_by_conf_if (bgp, argv[idx_peer]->arg); |
a80beece DS |
3359 | if (!peer) |
3360 | { | |
c500ae40 | 3361 | vty_out (vty, "%% Malformed address or name: %s%s", argv[idx_peer]->arg, VTY_NEWLINE); |
a80beece DS |
3362 | return CMD_WARNING; |
3363 | } | |
3364 | } | |
3365 | else | |
3366 | { | |
6aeb9e78 | 3367 | if (peer_address_self_check (bgp, &su)) |
a80beece DS |
3368 | { |
3369 | vty_out (vty, "%% Can not configure the local system as neighbor%s", | |
3370 | VTY_NEWLINE); | |
3371 | return CMD_WARNING; | |
3372 | } | |
f14e6fdb DS |
3373 | |
3374 | /* Disallow for dynamic neighbor. */ | |
3375 | peer = peer_lookup (bgp, &su); | |
3376 | if (peer && peer_dynamic_neighbor (peer)) | |
3377 | { | |
3378 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
3379 | VTY_NEWLINE); | |
3380 | return CMD_WARNING; | |
3381 | } | |
718e3744 | 3382 | } |
3383 | ||
c500ae40 | 3384 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 3385 | if (! group) |
3386 | { | |
3387 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
3388 | return CMD_WARNING; | |
3389 | } | |
3390 | ||
c8560b44 | 3391 | ret = peer_group_bind (bgp, &su, peer, group, &as); |
718e3744 | 3392 | |
3393 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) | |
3394 | { | |
aea339f7 | 3395 | vty_out (vty, "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external%s", as, VTY_NEWLINE); |
718e3744 | 3396 | return CMD_WARNING; |
3397 | } | |
3398 | ||
3399 | return bgp_vty_return (vty, ret); | |
3400 | } | |
3401 | ||
3402 | DEFUN (no_neighbor_set_peer_group, | |
3403 | no_neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3404 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3405 | NO_STR |
3406 | NEIGHBOR_STR | |
a80beece | 3407 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3408 | "Member of the peer-group\n" |
16cedbb0 | 3409 | "Peer-group name\n") |
718e3744 | 3410 | { |
cdc2d765 | 3411 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
3412 | int idx_peer = 2; |
3413 | int idx_word = 4; | |
718e3744 | 3414 | int ret; |
718e3744 | 3415 | struct peer *peer; |
3416 | struct peer_group *group; | |
3417 | ||
c500ae40 | 3418 | peer = peer_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3419 | if (! peer) |
3420 | return CMD_WARNING; | |
3421 | ||
c500ae40 | 3422 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 3423 | if (! group) |
3424 | { | |
3425 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
3426 | return CMD_WARNING; | |
3427 | } | |
3428 | ||
c8560b44 | 3429 | ret = peer_group_unbind (bgp, peer, group); |
718e3744 | 3430 | |
3431 | return bgp_vty_return (vty, ret); | |
3432 | } | |
6b0655a2 | 3433 | |
94f2b392 | 3434 | static int |
e52702f2 | 3435 | peer_flag_modify_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 3436 | u_int16_t flag, int set) |
718e3744 | 3437 | { |
3438 | int ret; | |
3439 | struct peer *peer; | |
3440 | ||
3441 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
3442 | if (! peer) | |
3443 | return CMD_WARNING; | |
3444 | ||
8cdabf90 SK |
3445 | /* |
3446 | * If 'neighbor <interface>', then this is for directly connected peers, | |
3447 | * we should not accept disable-connected-check. | |
3448 | */ | |
3449 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
3450 | vty_out (vty, "%s is directly connected peer, cannot accept disable-" | |
3451 | "connected-check%s", ip_str, VTY_NEWLINE); | |
3452 | return CMD_WARNING; | |
3453 | } | |
3454 | ||
718e3744 | 3455 | if (set) |
3456 | ret = peer_flag_set (peer, flag); | |
3457 | else | |
3458 | ret = peer_flag_unset (peer, flag); | |
3459 | ||
3460 | return bgp_vty_return (vty, ret); | |
3461 | } | |
3462 | ||
94f2b392 | 3463 | static int |
fd79ac91 | 3464 | peer_flag_set_vty (struct vty *vty, const char *ip_str, u_int16_t flag) |
718e3744 | 3465 | { |
3466 | return peer_flag_modify_vty (vty, ip_str, flag, 1); | |
3467 | } | |
3468 | ||
94f2b392 | 3469 | static int |
fd79ac91 | 3470 | peer_flag_unset_vty (struct vty *vty, const char *ip_str, u_int16_t flag) |
718e3744 | 3471 | { |
3472 | return peer_flag_modify_vty (vty, ip_str, flag, 0); | |
3473 | } | |
3474 | ||
3475 | /* neighbor passive. */ | |
3476 | DEFUN (neighbor_passive, | |
3477 | neighbor_passive_cmd, | |
9ccf14f7 | 3478 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3479 | NEIGHBOR_STR |
3480 | NEIGHBOR_ADDR_STR2 | |
3481 | "Don't send open messages to this neighbor\n") | |
3482 | { | |
c500ae40 DW |
3483 | int idx_peer = 1; |
3484 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3485 | } |
3486 | ||
3487 | DEFUN (no_neighbor_passive, | |
3488 | no_neighbor_passive_cmd, | |
9ccf14f7 | 3489 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3490 | NO_STR |
3491 | NEIGHBOR_STR | |
3492 | NEIGHBOR_ADDR_STR2 | |
3493 | "Don't send open messages to this neighbor\n") | |
3494 | { | |
c500ae40 DW |
3495 | int idx_peer = 2; |
3496 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3497 | } |
6b0655a2 | 3498 | |
718e3744 | 3499 | /* neighbor shutdown. */ |
73d70fa6 DL |
3500 | DEFUN (neighbor_shutdown_msg, |
3501 | neighbor_shutdown_msg_cmd, | |
3502 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
718e3744 | 3503 | NEIGHBOR_STR |
3504 | NEIGHBOR_ADDR_STR2 | |
73d70fa6 DL |
3505 | "Administratively shut down this neighbor\n" |
3506 | "Add a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3507 | "Shutdown message\n") | |
718e3744 | 3508 | { |
c500ae40 | 3509 | int idx_peer = 1; |
73d70fa6 DL |
3510 | |
3511 | if (argc >= 5) | |
3512 | { | |
3513 | struct peer *peer = peer_lookup_vty (vty, argv[idx_peer]->arg); | |
3514 | char *message; | |
3515 | ||
3516 | message = argv_concat (argv, argc, 4); | |
3517 | peer_tx_shutdown_message_set (peer, message); | |
3518 | XFREE (MTYPE_TMP, message); | |
3519 | } | |
3520 | ||
c500ae40 | 3521 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 3522 | } |
3523 | ||
73d70fa6 DL |
3524 | ALIAS (neighbor_shutdown_msg, |
3525 | neighbor_shutdown_cmd, | |
3526 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
718e3744 | 3527 | NEIGHBOR_STR |
3528 | NEIGHBOR_ADDR_STR2 | |
3529 | "Administratively shut down this neighbor\n") | |
73d70fa6 DL |
3530 | |
3531 | DEFUN (no_neighbor_shutdown_msg, | |
3532 | no_neighbor_shutdown_msg_cmd, | |
3533 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
3534 | NO_STR | |
3535 | NEIGHBOR_STR | |
3536 | NEIGHBOR_ADDR_STR2 | |
3537 | "Administratively shut down this neighbor\n" | |
3538 | "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3539 | "Shutdown message\n") | |
718e3744 | 3540 | { |
c500ae40 | 3541 | int idx_peer = 2; |
73d70fa6 DL |
3542 | |
3543 | struct peer *peer = peer_lookup_vty (vty, argv[idx_peer]->arg); | |
3544 | peer_tx_shutdown_message_unset (peer); | |
3545 | ||
c500ae40 | 3546 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 3547 | } |
6b0655a2 | 3548 | |
73d70fa6 DL |
3549 | ALIAS (no_neighbor_shutdown_msg, |
3550 | no_neighbor_shutdown_cmd, | |
3551 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3552 | NO_STR | |
3553 | NEIGHBOR_STR | |
3554 | NEIGHBOR_ADDR_STR2 | |
3555 | "Administratively shut down this neighbor\n") | |
3556 | ||
718e3744 | 3557 | /* neighbor capability dynamic. */ |
3558 | DEFUN (neighbor_capability_dynamic, | |
3559 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3560 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3561 | NEIGHBOR_STR |
3562 | NEIGHBOR_ADDR_STR2 | |
3563 | "Advertise capability to the peer\n" | |
3564 | "Advertise dynamic capability to this neighbor\n") | |
3565 | { | |
c500ae40 DW |
3566 | int idx_peer = 1; |
3567 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3568 | } |
3569 | ||
3570 | DEFUN (no_neighbor_capability_dynamic, | |
3571 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3572 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3573 | NO_STR |
3574 | NEIGHBOR_STR | |
3575 | NEIGHBOR_ADDR_STR2 | |
3576 | "Advertise capability to the peer\n" | |
3577 | "Advertise dynamic capability to this neighbor\n") | |
3578 | { | |
c500ae40 DW |
3579 | int idx_peer = 2; |
3580 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3581 | } |
6b0655a2 | 3582 | |
718e3744 | 3583 | /* neighbor dont-capability-negotiate */ |
3584 | DEFUN (neighbor_dont_capability_negotiate, | |
3585 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3586 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3587 | NEIGHBOR_STR |
3588 | NEIGHBOR_ADDR_STR2 | |
3589 | "Do not perform capability negotiation\n") | |
3590 | { | |
c500ae40 DW |
3591 | int idx_peer = 1; |
3592 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3593 | } |
3594 | ||
3595 | DEFUN (no_neighbor_dont_capability_negotiate, | |
3596 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3597 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3598 | NO_STR |
3599 | NEIGHBOR_STR | |
3600 | NEIGHBOR_ADDR_STR2 | |
3601 | "Do not perform capability negotiation\n") | |
3602 | { | |
c500ae40 DW |
3603 | int idx_peer = 2; |
3604 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3605 | } |
6b0655a2 | 3606 | |
8a92a8a0 DS |
3607 | /* neighbor capability extended next hop encoding */ |
3608 | DEFUN (neighbor_capability_enhe, | |
3609 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3610 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3611 | NEIGHBOR_STR |
3612 | NEIGHBOR_ADDR_STR2 | |
3613 | "Advertise capability to the peer\n" | |
3614 | "Advertise extended next-hop capability to the peer\n") | |
3615 | { | |
c500ae40 DW |
3616 | int idx_peer = 1; |
3617 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3618 | } |
3619 | ||
3620 | DEFUN (no_neighbor_capability_enhe, | |
3621 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3622 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3623 | NO_STR |
3624 | NEIGHBOR_STR | |
3625 | NEIGHBOR_ADDR_STR2 | |
3626 | "Advertise capability to the peer\n" | |
3627 | "Advertise extended next-hop capability to the peer\n") | |
3628 | { | |
c500ae40 DW |
3629 | int idx_peer = 2; |
3630 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3631 | } |
3632 | ||
94f2b392 | 3633 | static int |
fd79ac91 | 3634 | peer_af_flag_modify_vty (struct vty *vty, const char *peer_str, afi_t afi, |
fee0f4c6 | 3635 | safi_t safi, u_int32_t flag, int set) |
718e3744 | 3636 | { |
3637 | int ret; | |
3638 | struct peer *peer; | |
3639 | ||
3640 | peer = peer_and_group_lookup_vty (vty, peer_str); | |
3641 | if (! peer) | |
3642 | return CMD_WARNING; | |
3643 | ||
3644 | if (set) | |
3645 | ret = peer_af_flag_set (peer, afi, safi, flag); | |
3646 | else | |
3647 | ret = peer_af_flag_unset (peer, afi, safi, flag); | |
3648 | ||
3649 | return bgp_vty_return (vty, ret); | |
3650 | } | |
3651 | ||
94f2b392 | 3652 | static int |
fd79ac91 | 3653 | peer_af_flag_set_vty (struct vty *vty, const char *peer_str, afi_t afi, |
fee0f4c6 | 3654 | safi_t safi, u_int32_t flag) |
718e3744 | 3655 | { |
3656 | return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 1); | |
3657 | } | |
3658 | ||
94f2b392 | 3659 | static int |
fd79ac91 | 3660 | peer_af_flag_unset_vty (struct vty *vty, const char *peer_str, afi_t afi, |
fee0f4c6 | 3661 | safi_t safi, u_int32_t flag) |
718e3744 | 3662 | { |
3663 | return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 0); | |
3664 | } | |
6b0655a2 | 3665 | |
718e3744 | 3666 | /* neighbor capability orf prefix-list. */ |
3667 | DEFUN (neighbor_capability_orf_prefix, | |
3668 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3669 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3670 | NEIGHBOR_STR |
3671 | NEIGHBOR_ADDR_STR2 | |
3672 | "Advertise capability to the peer\n" | |
3673 | "Advertise ORF capability to the peer\n" | |
3674 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3675 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3676 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3677 | "Capability to SEND the ORF to this neighbor\n") | |
3678 | { | |
c500ae40 DW |
3679 | int idx_peer = 1; |
3680 | int idx_send_recv = 5; | |
718e3744 | 3681 | u_int16_t flag = 0; |
3682 | ||
c500ae40 | 3683 | if (strncmp (argv[idx_send_recv]->arg, "s", 1) == 0) |
718e3744 | 3684 | flag = PEER_FLAG_ORF_PREFIX_SM; |
c500ae40 | 3685 | else if (strncmp (argv[idx_send_recv]->arg, "r", 1) == 0) |
718e3744 | 3686 | flag = PEER_FLAG_ORF_PREFIX_RM; |
c500ae40 | 3687 | else if (strncmp (argv[idx_send_recv]->arg, "b", 1) == 0) |
718e3744 | 3688 | flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM; |
3689 | else | |
3690 | return CMD_WARNING; | |
3691 | ||
c500ae40 | 3692 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 3693 | bgp_node_safi (vty), flag); |
3694 | } | |
3695 | ||
3696 | DEFUN (no_neighbor_capability_orf_prefix, | |
3697 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3698 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3699 | NO_STR |
3700 | NEIGHBOR_STR | |
3701 | NEIGHBOR_ADDR_STR2 | |
3702 | "Advertise capability to the peer\n" | |
3703 | "Advertise ORF capability to the peer\n" | |
3704 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3705 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3706 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3707 | "Capability to SEND the ORF to this neighbor\n") | |
3708 | { | |
c500ae40 DW |
3709 | int idx_peer = 2; |
3710 | int idx_send_recv = 6; | |
718e3744 | 3711 | u_int16_t flag = 0; |
3712 | ||
c500ae40 | 3713 | if (strncmp (argv[idx_send_recv]->arg, "s", 1) == 0) |
718e3744 | 3714 | flag = PEER_FLAG_ORF_PREFIX_SM; |
c500ae40 | 3715 | else if (strncmp (argv[idx_send_recv]->arg, "r", 1) == 0) |
718e3744 | 3716 | flag = PEER_FLAG_ORF_PREFIX_RM; |
c500ae40 | 3717 | else if (strncmp (argv[idx_send_recv]->arg, "b", 1) == 0) |
718e3744 | 3718 | flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM; |
3719 | else | |
3720 | return CMD_WARNING; | |
3721 | ||
c500ae40 | 3722 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 3723 | bgp_node_safi (vty), flag); |
3724 | } | |
6b0655a2 | 3725 | |
718e3744 | 3726 | /* neighbor next-hop-self. */ |
3727 | DEFUN (neighbor_nexthop_self, | |
3728 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3729 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3730 | NEIGHBOR_STR |
3731 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3732 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3733 | { |
c500ae40 DW |
3734 | int idx_peer = 1; |
3735 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
a538debe DS |
3736 | bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF); |
3737 | } | |
9e7a53c1 | 3738 | |
a538debe DS |
3739 | /* neighbor next-hop-self. */ |
3740 | DEFUN (neighbor_nexthop_self_force, | |
3741 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 3742 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3743 | NEIGHBOR_STR |
3744 | NEIGHBOR_ADDR_STR2 | |
3745 | "Disable the next hop calculation for this neighbor\n" | |
3746 | "Set the next hop to self for reflected routes\n") | |
3747 | { | |
c500ae40 DW |
3748 | int idx_peer = 1; |
3749 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
a538debe | 3750 | bgp_node_safi (vty), |
88b8ed8d | 3751 | PEER_FLAG_FORCE_NEXTHOP_SELF); |
718e3744 | 3752 | } |
3753 | ||
3754 | DEFUN (no_neighbor_nexthop_self, | |
3755 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3756 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3757 | NO_STR |
3758 | NEIGHBOR_STR | |
3759 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3760 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3761 | { |
c500ae40 DW |
3762 | int idx_peer = 2; |
3763 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
9e7a53c1 | 3764 | bgp_node_safi (vty), |
88b8ed8d | 3765 | PEER_FLAG_NEXTHOP_SELF); |
718e3744 | 3766 | } |
6b0655a2 | 3767 | |
88b8ed8d | 3768 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 3769 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 3770 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3771 | NO_STR |
3772 | NEIGHBOR_STR | |
3773 | NEIGHBOR_ADDR_STR2 | |
3774 | "Disable the next hop calculation for this neighbor\n" | |
3775 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 3776 | { |
c500ae40 DW |
3777 | int idx_peer = 2; |
3778 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
3779 | bgp_node_safi (vty), |
3780 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
3781 | } | |
a538debe | 3782 | |
c7122e14 DS |
3783 | /* neighbor as-override */ |
3784 | DEFUN (neighbor_as_override, | |
3785 | neighbor_as_override_cmd, | |
9ccf14f7 | 3786 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3787 | NEIGHBOR_STR |
3788 | NEIGHBOR_ADDR_STR2 | |
3789 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3790 | { | |
c500ae40 DW |
3791 | int idx_peer = 1; |
3792 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
c7122e14 DS |
3793 | bgp_node_safi (vty), |
3794 | PEER_FLAG_AS_OVERRIDE); | |
3795 | } | |
3796 | ||
3797 | DEFUN (no_neighbor_as_override, | |
3798 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 3799 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3800 | NO_STR |
3801 | NEIGHBOR_STR | |
3802 | NEIGHBOR_ADDR_STR2 | |
3803 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3804 | { | |
c500ae40 DW |
3805 | int idx_peer = 2; |
3806 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
c7122e14 DS |
3807 | bgp_node_safi (vty), |
3808 | PEER_FLAG_AS_OVERRIDE); | |
3809 | } | |
3810 | ||
718e3744 | 3811 | /* neighbor remove-private-AS. */ |
3812 | DEFUN (neighbor_remove_private_as, | |
3813 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3814 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3815 | NEIGHBOR_STR |
3816 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3817 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3818 | { |
c500ae40 DW |
3819 | int idx_peer = 1; |
3820 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3821 | bgp_node_safi (vty), |
3822 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
3823 | } | |
3824 | ||
5000f21c DS |
3825 | DEFUN (neighbor_remove_private_as_all, |
3826 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 3827 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
3828 | NEIGHBOR_STR |
3829 | NEIGHBOR_ADDR_STR2 | |
3830 | "Remove private ASNs in outbound updates\n" | |
3831 | "Apply to all AS numbers") | |
3832 | { | |
c500ae40 DW |
3833 | int idx_peer = 1; |
3834 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5000f21c | 3835 | bgp_node_safi (vty), |
5000f21c DS |
3836 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); |
3837 | } | |
3838 | ||
3839 | DEFUN (neighbor_remove_private_as_replace_as, | |
3840 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 3841 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
3842 | NEIGHBOR_STR |
3843 | NEIGHBOR_ADDR_STR2 | |
3844 | "Remove private ASNs in outbound updates\n" | |
3845 | "Replace private ASNs with our ASN in outbound updates\n") | |
3846 | { | |
c500ae40 DW |
3847 | int idx_peer = 1; |
3848 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5000f21c | 3849 | bgp_node_safi (vty), |
5000f21c DS |
3850 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); |
3851 | } | |
3852 | ||
3853 | DEFUN (neighbor_remove_private_as_all_replace_as, | |
3854 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 3855 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
3856 | NEIGHBOR_STR |
3857 | NEIGHBOR_ADDR_STR2 | |
3858 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3859 | "Apply to all AS numbers\n" |
5000f21c DS |
3860 | "Replace private ASNs with our ASN in outbound updates\n") |
3861 | { | |
c500ae40 DW |
3862 | int idx_peer = 1; |
3863 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5000f21c | 3864 | bgp_node_safi (vty), |
88b8ed8d | 3865 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); |
5000f21c DS |
3866 | } |
3867 | ||
718e3744 | 3868 | DEFUN (no_neighbor_remove_private_as, |
3869 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3870 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3871 | NO_STR |
3872 | NEIGHBOR_STR | |
3873 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3874 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3875 | { |
c500ae40 DW |
3876 | int idx_peer = 2; |
3877 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3878 | bgp_node_safi (vty), |
88b8ed8d | 3879 | PEER_FLAG_REMOVE_PRIVATE_AS); |
718e3744 | 3880 | } |
6b0655a2 | 3881 | |
88b8ed8d | 3882 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 3883 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 3884 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
3885 | NO_STR |
3886 | NEIGHBOR_STR | |
3887 | NEIGHBOR_ADDR_STR2 | |
3888 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3889 | "Apply to all AS numbers\n") |
88b8ed8d | 3890 | { |
c500ae40 DW |
3891 | int idx_peer = 2; |
3892 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
3893 | bgp_node_safi (vty), |
3894 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
3895 | } | |
5000f21c | 3896 | |
88b8ed8d | 3897 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 3898 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 3899 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
3900 | NO_STR |
3901 | NEIGHBOR_STR | |
3902 | NEIGHBOR_ADDR_STR2 | |
3903 | "Remove private ASNs in outbound updates\n" | |
3904 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 3905 | { |
c500ae40 DW |
3906 | int idx_peer = 2; |
3907 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
3908 | bgp_node_safi (vty), |
3909 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
3910 | } | |
5000f21c | 3911 | |
88b8ed8d | 3912 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 3913 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 3914 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
3915 | NO_STR |
3916 | NEIGHBOR_STR | |
3917 | NEIGHBOR_ADDR_STR2 | |
3918 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3919 | "Apply to all AS numbers\n" |
5000f21c | 3920 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 3921 | { |
c500ae40 DW |
3922 | int idx_peer = 2; |
3923 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
3924 | bgp_node_safi (vty), |
3925 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
3926 | } | |
5000f21c DS |
3927 | |
3928 | ||
718e3744 | 3929 | /* neighbor send-community. */ |
3930 | DEFUN (neighbor_send_community, | |
3931 | neighbor_send_community_cmd, | |
9ccf14f7 | 3932 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 3933 | NEIGHBOR_STR |
3934 | NEIGHBOR_ADDR_STR2 | |
3935 | "Send Community attribute to this neighbor\n") | |
3936 | { | |
c500ae40 DW |
3937 | int idx_peer = 1; |
3938 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3939 | bgp_node_safi (vty), |
3940 | PEER_FLAG_SEND_COMMUNITY); | |
3941 | } | |
3942 | ||
3943 | DEFUN (no_neighbor_send_community, | |
3944 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 3945 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 3946 | NO_STR |
3947 | NEIGHBOR_STR | |
3948 | NEIGHBOR_ADDR_STR2 | |
3949 | "Send Community attribute to this neighbor\n") | |
3950 | { | |
c500ae40 DW |
3951 | int idx_peer = 2; |
3952 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3953 | bgp_node_safi (vty), |
3954 | PEER_FLAG_SEND_COMMUNITY); | |
3955 | } | |
6b0655a2 | 3956 | |
718e3744 | 3957 | /* neighbor send-community extended. */ |
3958 | DEFUN (neighbor_send_community_type, | |
3959 | neighbor_send_community_type_cmd, | |
57d187bc | 3960 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 3961 | NEIGHBOR_STR |
3962 | NEIGHBOR_ADDR_STR2 | |
3963 | "Send Community attribute to this neighbor\n" | |
3964 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 3965 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 3966 | "Send Extended Community attributes\n" |
57d187bc JS |
3967 | "Send Standard Community attributes\n" |
3968 | "Send Large Community attributes\n") | |
718e3744 | 3969 | { |
4c4ff4c1 QY |
3970 | int idx = 0; |
3971 | u_int32_t flag = 0; | |
718e3744 | 3972 | |
4c4ff4c1 QY |
3973 | char *peer = argv[1]->arg; |
3974 | ||
3975 | if (argv_find (argv, argc, "standard", &idx)) | |
3976 | SET_FLAG (flag, PEER_FLAG_SEND_COMMUNITY); | |
3977 | else if (argv_find (argv, argc, "extended", &idx)) | |
3978 | SET_FLAG (flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
57d187bc JS |
3979 | else if (argv_find (argv, argc, "large", &idx)) |
3980 | SET_FLAG (flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
3981 | else if (argv_find (argv, argc, "both", &idx)) | |
3982 | { | |
3983 | SET_FLAG (flag, PEER_FLAG_SEND_COMMUNITY); | |
3984 | SET_FLAG (flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
3985 | } | |
4c4ff4c1 | 3986 | else |
57d187bc JS |
3987 | { |
3988 | SET_FLAG (flag, PEER_FLAG_SEND_COMMUNITY); | |
3989 | SET_FLAG (flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
3990 | SET_FLAG (flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
3991 | } | |
4c4ff4c1 QY |
3992 | |
3993 | return peer_af_flag_set_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flag); | |
718e3744 | 3994 | } |
3995 | ||
3996 | DEFUN (no_neighbor_send_community_type, | |
3997 | no_neighbor_send_community_type_cmd, | |
57d187bc | 3998 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 3999 | NO_STR |
4000 | NEIGHBOR_STR | |
4001 | NEIGHBOR_ADDR_STR2 | |
4002 | "Send Community attribute to this neighbor\n" | |
4003 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4004 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4005 | "Send Extended Community attributes\n" |
57d187bc JS |
4006 | "Send Standard Community attributes\n" |
4007 | "Send Large Community attributes\n") | |
718e3744 | 4008 | { |
c500ae40 DW |
4009 | int idx_peer = 2; |
4010 | int idx_type = 4; | |
4011 | if (strncmp (argv[idx_type]->arg, "s", 1) == 0) | |
4012 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4013 | bgp_node_safi (vty), |
4014 | PEER_FLAG_SEND_COMMUNITY); | |
c500ae40 DW |
4015 | if (strncmp (argv[idx_type]->arg, "e", 1) == 0) |
4016 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4017 | bgp_node_safi (vty), |
4018 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
57d187bc JS |
4019 | if (strncmp (argv[idx_type]->arg, "l", 1) == 0) |
4020 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4021 | bgp_node_safi (vty), | |
4022 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4023 | if (strncmp (argv[idx_type]->arg, "b", 1) == 0) | |
4024 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4025 | bgp_node_safi (vty), | |
4026 | PEER_FLAG_SEND_COMMUNITY | | |
4027 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
718e3744 | 4028 | |
c500ae40 | 4029 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 4030 | bgp_node_safi (vty), |
4031 | (PEER_FLAG_SEND_COMMUNITY | | |
57d187bc JS |
4032 | PEER_FLAG_SEND_EXT_COMMUNITY| |
4033 | PEER_FLAG_SEND_LARGE_COMMUNITY)); | |
718e3744 | 4034 | } |
6b0655a2 | 4035 | |
718e3744 | 4036 | /* neighbor soft-reconfig. */ |
4037 | DEFUN (neighbor_soft_reconfiguration, | |
4038 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4039 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4040 | NEIGHBOR_STR |
4041 | NEIGHBOR_ADDR_STR2 | |
4042 | "Per neighbor soft reconfiguration\n" | |
4043 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4044 | { | |
c500ae40 DW |
4045 | int idx_peer = 1; |
4046 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, | |
718e3744 | 4047 | bgp_node_afi (vty), bgp_node_safi (vty), |
4048 | PEER_FLAG_SOFT_RECONFIG); | |
4049 | } | |
4050 | ||
4051 | DEFUN (no_neighbor_soft_reconfiguration, | |
4052 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4053 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4054 | NO_STR |
4055 | NEIGHBOR_STR | |
4056 | NEIGHBOR_ADDR_STR2 | |
4057 | "Per neighbor soft reconfiguration\n" | |
4058 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4059 | { | |
c500ae40 DW |
4060 | int idx_peer = 2; |
4061 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, | |
718e3744 | 4062 | bgp_node_afi (vty), bgp_node_safi (vty), |
4063 | PEER_FLAG_SOFT_RECONFIG); | |
4064 | } | |
6b0655a2 | 4065 | |
718e3744 | 4066 | DEFUN (neighbor_route_reflector_client, |
4067 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4068 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4069 | NEIGHBOR_STR |
4070 | NEIGHBOR_ADDR_STR2 | |
4071 | "Configure a neighbor as Route Reflector client\n") | |
4072 | { | |
c500ae40 | 4073 | int idx_peer = 1; |
718e3744 | 4074 | struct peer *peer; |
4075 | ||
4076 | ||
c500ae40 | 4077 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 4078 | if (! peer) |
4079 | return CMD_WARNING; | |
4080 | ||
c500ae40 | 4081 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 4082 | bgp_node_safi (vty), |
4083 | PEER_FLAG_REFLECTOR_CLIENT); | |
4084 | } | |
4085 | ||
4086 | DEFUN (no_neighbor_route_reflector_client, | |
4087 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4088 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4089 | NO_STR |
4090 | NEIGHBOR_STR | |
4091 | NEIGHBOR_ADDR_STR2 | |
4092 | "Configure a neighbor as Route Reflector client\n") | |
4093 | { | |
c500ae40 DW |
4094 | int idx_peer = 2; |
4095 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4096 | bgp_node_safi (vty), |
4097 | PEER_FLAG_REFLECTOR_CLIENT); | |
4098 | } | |
6b0655a2 | 4099 | |
718e3744 | 4100 | /* neighbor route-server-client. */ |
4101 | DEFUN (neighbor_route_server_client, | |
4102 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 4103 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4104 | NEIGHBOR_STR |
4105 | NEIGHBOR_ADDR_STR2 | |
4106 | "Configure a neighbor as Route Server client\n") | |
4107 | { | |
c500ae40 | 4108 | int idx_peer = 1; |
2a3d5731 DW |
4109 | struct peer *peer; |
4110 | ||
c500ae40 | 4111 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
2a3d5731 DW |
4112 | if (! peer) |
4113 | return CMD_WARNING; | |
c500ae40 | 4114 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
2a3d5731 DW |
4115 | bgp_node_safi (vty), |
4116 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 4117 | } |
4118 | ||
4119 | DEFUN (no_neighbor_route_server_client, | |
4120 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 4121 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4122 | NO_STR |
4123 | NEIGHBOR_STR | |
4124 | NEIGHBOR_ADDR_STR2 | |
4125 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 4126 | { |
c500ae40 DW |
4127 | int idx_peer = 2; |
4128 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
2a3d5731 DW |
4129 | bgp_node_safi (vty), |
4130 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 4131 | } |
6b0655a2 | 4132 | |
fee0f4c6 | 4133 | DEFUN (neighbor_nexthop_local_unchanged, |
4134 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4135 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4136 | NEIGHBOR_STR |
4137 | NEIGHBOR_ADDR_STR2 | |
4138 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
4139 | "Leave link-local nexthop unchanged for this peer\n") | |
4140 | { | |
c500ae40 DW |
4141 | int idx_peer = 1; |
4142 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
fee0f4c6 | 4143 | bgp_node_safi (vty), |
4144 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED ); | |
4145 | } | |
6b0655a2 | 4146 | |
fee0f4c6 | 4147 | DEFUN (no_neighbor_nexthop_local_unchanged, |
4148 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4149 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4150 | NO_STR |
4151 | NEIGHBOR_STR | |
4152 | NEIGHBOR_ADDR_STR2 | |
4153 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
4154 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 4155 | { |
c500ae40 DW |
4156 | int idx_peer = 2; |
4157 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4158 | bgp_node_safi (vty), |
fee0f4c6 | 4159 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED ); |
718e3744 | 4160 | } |
6b0655a2 | 4161 | |
718e3744 | 4162 | DEFUN (neighbor_attr_unchanged, |
4163 | neighbor_attr_unchanged_cmd, | |
1084263f QY |
4164 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged\ |
4165 | [<\ | |
ddbaf941 QY |
4166 | as-path [<next-hop [med]|med [next-hop]>]|\ |
4167 | next-hop [<as-path [med]|med [as-path]>]|\ | |
4168 | med [<as-path [next-hop]|next-hop [as-path]>]\ | |
1084263f | 4169 | >]", |
718e3744 | 4170 | NEIGHBOR_STR |
4171 | NEIGHBOR_ADDR_STR2 | |
4172 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4173 | "As-path attribute\n" | |
4174 | "Nexthop attribute\n" | |
40e718b5 | 4175 | "Med attribute\n" |
1084263f QY |
4176 | "Med attribute\n" |
4177 | "Nexthop attribute\n" | |
4178 | "Nexthop attribute\n" | |
4179 | "As-path attribute\n" | |
4180 | "Med attribute\n" | |
40e718b5 | 4181 | "Med attribute\n" |
718e3744 | 4182 | "As-path attribute\n" |
1084263f QY |
4183 | "Med attribute\n" |
4184 | "As-path attribute\n" | |
4185 | "Nexthop attribute\n" | |
40e718b5 | 4186 | "Nexthop attribute\n" |
1084263f | 4187 | "As-path attribute\n") |
718e3744 | 4188 | { |
40e718b5 QY |
4189 | int idx = 0; |
4190 | char *peer = argv[1]->arg; | |
4191 | u_int16_t flags = 0; | |
718e3744 | 4192 | |
40e718b5 | 4193 | if (argv_find (argv, argc, "as-path", &idx)) |
718e3744 | 4194 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
40e718b5 QY |
4195 | idx = 0; |
4196 | if (argv_find (argv, argc, "next-hop", &idx)) | |
4197 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4198 | idx = 0; | |
4199 | if (argv_find (argv, argc, "med", &idx)) | |
718e3744 | 4200 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
4201 | ||
40e718b5 QY |
4202 | if (!flags) // no flags means all of them! |
4203 | { | |
718e3744 | 4204 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
718e3744 | 4205 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); |
40e718b5 QY |
4206 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
4207 | } | |
718e3744 | 4208 | |
40e718b5 | 4209 | return peer_af_flag_set_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flags); |
718e3744 | 4210 | } |
4211 | ||
718e3744 | 4212 | DEFUN (no_neighbor_attr_unchanged, |
4213 | no_neighbor_attr_unchanged_cmd, | |
1084263f QY |
4214 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged\ |
4215 | [<\ | |
ddbaf941 QY |
4216 | as-path [<next-hop [med]|med [next-hop]>]|\ |
4217 | next-hop [<as-path [med]|med [as-path]>]|\ | |
4218 | med [<as-path [next-hop]|next-hop [as-path]>]\ | |
1084263f | 4219 | >]", |
e52702f2 | 4220 | NO_STR |
718e3744 | 4221 | NEIGHBOR_STR |
4222 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
4223 | "BGP attribute is propagated unchanged to this neighbor\n" |
4224 | "As-path attribute\n" | |
40e718b5 | 4225 | "Nexthop attribute\n" |
31500417 | 4226 | "Med attribute\n" |
1084263f QY |
4227 | "Med attribute\n" |
4228 | "Nexthop attribute\n" | |
4229 | "Nexthop attribute\n" | |
4230 | "As-path attribute\n" | |
4231 | "Med attribute\n" | |
40e718b5 | 4232 | "Med attribute\n" |
718e3744 | 4233 | "As-path attribute\n" |
1084263f QY |
4234 | "Med attribute\n" |
4235 | "As-path attribute\n" | |
4236 | "Nexthop attribute\n" | |
718e3744 | 4237 | "Nexthop attribute\n" |
1084263f | 4238 | "As-path attribute\n") |
718e3744 | 4239 | { |
40e718b5 QY |
4240 | int idx = 0; |
4241 | char *peer = argv[2]->arg; | |
4242 | u_int16_t flags = 0; | |
718e3744 | 4243 | |
40e718b5 | 4244 | if (argv_find (argv, argc, "as-path", &idx)) |
718e3744 | 4245 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
40e718b5 QY |
4246 | idx = 0; |
4247 | if (argv_find (argv, argc, "next-hop", &idx)) | |
4248 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4249 | idx = 0; | |
4250 | if (argv_find (argv, argc, "med", &idx)) | |
718e3744 | 4251 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
4252 | ||
40e718b5 QY |
4253 | if (!flags) // no flags means all of them! |
4254 | { | |
718e3744 | 4255 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
718e3744 | 4256 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); |
40e718b5 QY |
4257 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
4258 | } | |
718e3744 | 4259 | |
40e718b5 | 4260 | return peer_af_flag_unset_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flags); |
718e3744 | 4261 | } |
4262 | ||
718e3744 | 4263 | |
718e3744 | 4264 | /* EBGP multihop configuration. */ |
94f2b392 | 4265 | static int |
e52702f2 | 4266 | peer_ebgp_multihop_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4267 | const char *ttl_str) |
718e3744 | 4268 | { |
4269 | struct peer *peer; | |
fd79ac91 | 4270 | unsigned int ttl; |
718e3744 | 4271 | |
4272 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4273 | if (! peer) | |
4274 | return CMD_WARNING; | |
4275 | ||
63fa10b5 QY |
4276 | if (peer->conf_if) |
4277 | return bgp_vty_return (vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
4278 | ||
718e3744 | 4279 | if (! ttl_str) |
9b1be336 | 4280 | ttl = MAXTTL; |
718e3744 | 4281 | else |
9b1be336 | 4282 | VTY_GET_INTEGER_RANGE ("TTL", ttl, ttl_str, 1, MAXTTL); |
718e3744 | 4283 | |
89b6d1f8 | 4284 | return bgp_vty_return (vty, peer_ebgp_multihop_set (peer, ttl)); |
718e3744 | 4285 | } |
4286 | ||
94f2b392 | 4287 | static int |
e52702f2 | 4288 | peer_ebgp_multihop_unset_vty (struct vty *vty, const char *ip_str) |
718e3744 | 4289 | { |
4290 | struct peer *peer; | |
4291 | ||
4292 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4293 | if (! peer) | |
4294 | return CMD_WARNING; | |
4295 | ||
89b6d1f8 | 4296 | return bgp_vty_return (vty, peer_ebgp_multihop_unset (peer)); |
718e3744 | 4297 | } |
4298 | ||
4299 | /* neighbor ebgp-multihop. */ | |
4300 | DEFUN (neighbor_ebgp_multihop, | |
4301 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 4302 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 4303 | NEIGHBOR_STR |
4304 | NEIGHBOR_ADDR_STR2 | |
4305 | "Allow EBGP neighbors not on directly connected networks\n") | |
4306 | { | |
c500ae40 DW |
4307 | int idx_peer = 1; |
4308 | return peer_ebgp_multihop_set_vty (vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4309 | } |
4310 | ||
4311 | DEFUN (neighbor_ebgp_multihop_ttl, | |
4312 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 4313 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 4314 | NEIGHBOR_STR |
4315 | NEIGHBOR_ADDR_STR2 | |
4316 | "Allow EBGP neighbors not on directly connected networks\n" | |
4317 | "maximum hop count\n") | |
4318 | { | |
c500ae40 DW |
4319 | int idx_peer = 1; |
4320 | int idx_number = 3; | |
4321 | return peer_ebgp_multihop_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg); | |
718e3744 | 4322 | } |
4323 | ||
4324 | DEFUN (no_neighbor_ebgp_multihop, | |
4325 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 4326 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 4327 | NO_STR |
4328 | NEIGHBOR_STR | |
4329 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4330 | "Allow EBGP neighbors not on directly connected networks\n" |
4331 | "maximum hop count\n") | |
718e3744 | 4332 | { |
c500ae40 DW |
4333 | int idx_peer = 2; |
4334 | return peer_ebgp_multihop_unset_vty (vty, argv[idx_peer]->arg); | |
718e3744 | 4335 | } |
4336 | ||
6b0655a2 | 4337 | |
6ffd2079 | 4338 | /* disable-connected-check */ |
4339 | DEFUN (neighbor_disable_connected_check, | |
4340 | neighbor_disable_connected_check_cmd, | |
a636c635 | 4341 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4342 | NEIGHBOR_STR |
4343 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4344 | "one-hop away EBGP peer using loopback address\n" |
4345 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4346 | { |
c500ae40 DW |
4347 | int idx_peer = 1; |
4348 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4349 | } |
4350 | ||
4351 | DEFUN (no_neighbor_disable_connected_check, | |
4352 | no_neighbor_disable_connected_check_cmd, | |
a636c635 | 4353 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4354 | NO_STR |
4355 | NEIGHBOR_STR | |
4356 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4357 | "one-hop away EBGP peer using loopback address\n" |
4358 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4359 | { |
c500ae40 DW |
4360 | int idx_peer = 2; |
4361 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4362 | } |
4363 | ||
718e3744 | 4364 | DEFUN (neighbor_description, |
4365 | neighbor_description_cmd, | |
e961923c | 4366 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 4367 | NEIGHBOR_STR |
4368 | NEIGHBOR_ADDR_STR2 | |
4369 | "Neighbor specific description\n" | |
4370 | "Up to 80 characters describing this neighbor\n") | |
4371 | { | |
c500ae40 | 4372 | int idx_peer = 1; |
58749582 | 4373 | int idx_line = 3; |
718e3744 | 4374 | struct peer *peer; |
718e3744 | 4375 | char *str; |
718e3744 | 4376 | |
c500ae40 | 4377 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 4378 | if (! peer) |
4379 | return CMD_WARNING; | |
4380 | ||
58749582 | 4381 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 4382 | |
4383 | peer_description_set (peer, str); | |
4384 | ||
3b8b1855 | 4385 | XFREE (MTYPE_TMP, str); |
718e3744 | 4386 | |
4387 | return CMD_SUCCESS; | |
4388 | } | |
4389 | ||
4390 | DEFUN (no_neighbor_description, | |
4391 | no_neighbor_description_cmd, | |
a636c635 | 4392 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description [LINE]", |
718e3744 | 4393 | NO_STR |
4394 | NEIGHBOR_STR | |
4395 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4396 | "Neighbor specific description\n" |
4397 | "Up to 80 characters describing this neighbor\n") | |
718e3744 | 4398 | { |
c500ae40 | 4399 | int idx_peer = 2; |
718e3744 | 4400 | struct peer *peer; |
4401 | ||
c500ae40 | 4402 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 4403 | if (! peer) |
4404 | return CMD_WARNING; | |
4405 | ||
4406 | peer_description_unset (peer); | |
4407 | ||
4408 | return CMD_SUCCESS; | |
4409 | } | |
4410 | ||
6b0655a2 | 4411 | |
718e3744 | 4412 | /* Neighbor update-source. */ |
94f2b392 | 4413 | static int |
e52702f2 | 4414 | peer_update_source_vty (struct vty *vty, const char *peer_str, |
fd79ac91 | 4415 | const char *source_str) |
718e3744 | 4416 | { |
4417 | struct peer *peer; | |
3b69fd51 | 4418 | struct prefix p; |
718e3744 | 4419 | |
4420 | peer = peer_and_group_lookup_vty (vty, peer_str); | |
4421 | if (! peer) | |
4422 | return CMD_WARNING; | |
4423 | ||
a80beece DS |
4424 | if (peer->conf_if) |
4425 | return CMD_WARNING; | |
4426 | ||
718e3744 | 4427 | if (source_str) |
4428 | { | |
c63b83fe JBD |
4429 | union sockunion su; |
4430 | int ret = str2sockunion (source_str, &su); | |
4431 | ||
4432 | if (ret == 0) | |
4433 | peer_update_source_addr_set (peer, &su); | |
718e3744 | 4434 | else |
3b69fd51 DS |
4435 | { |
4436 | if (str2prefix (source_str, &p)) | |
4437 | { | |
4438 | vty_out (vty, "%% Invalid update-source, remove prefix length %s", | |
4439 | VTY_NEWLINE); | |
4440 | return CMD_WARNING; | |
4441 | } | |
4442 | else | |
4443 | peer_update_source_if_set (peer, source_str); | |
4444 | } | |
718e3744 | 4445 | } |
4446 | else | |
4447 | peer_update_source_unset (peer); | |
4448 | ||
4449 | return CMD_SUCCESS; | |
4450 | } | |
4451 | ||
369688c0 PJ |
4452 | #define BGP_UPDATE_SOURCE_HELP_STR \ |
4453 | "IPv4 address\n" \ | |
9a1a331d PJ |
4454 | "IPv6 address\n" \ |
4455 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 4456 | |
718e3744 | 4457 | DEFUN (neighbor_update_source, |
4458 | neighbor_update_source_cmd, | |
9ccf14f7 | 4459 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 4460 | NEIGHBOR_STR |
4461 | NEIGHBOR_ADDR_STR2 | |
4462 | "Source of routing updates\n" | |
369688c0 | 4463 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 4464 | { |
c500ae40 DW |
4465 | int idx_peer = 1; |
4466 | int idx_peer_2 = 3; | |
4467 | return peer_update_source_vty (vty, argv[idx_peer]->arg, argv[idx_peer_2]->arg); | |
718e3744 | 4468 | } |
4469 | ||
4470 | DEFUN (no_neighbor_update_source, | |
4471 | no_neighbor_update_source_cmd, | |
c7178fe7 | 4472 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 4473 | NO_STR |
4474 | NEIGHBOR_STR | |
4475 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
4476 | "Source of routing updates\n" |
4477 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 4478 | { |
c500ae40 DW |
4479 | int idx_peer = 2; |
4480 | return peer_update_source_vty (vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4481 | } |
6b0655a2 | 4482 | |
94f2b392 | 4483 | static int |
e52702f2 QY |
4484 | peer_default_originate_set_vty (struct vty *vty, const char *peer_str, |
4485 | afi_t afi, safi_t safi, | |
fd79ac91 | 4486 | const char *rmap, int set) |
718e3744 | 4487 | { |
4488 | int ret; | |
4489 | struct peer *peer; | |
4490 | ||
4491 | peer = peer_and_group_lookup_vty (vty, peer_str); | |
4492 | if (! peer) | |
4493 | return CMD_WARNING; | |
4494 | ||
4495 | if (set) | |
4496 | ret = peer_default_originate_set (peer, afi, safi, rmap); | |
4497 | else | |
4498 | ret = peer_default_originate_unset (peer, afi, safi); | |
4499 | ||
4500 | return bgp_vty_return (vty, ret); | |
4501 | } | |
4502 | ||
4503 | /* neighbor default-originate. */ | |
4504 | DEFUN (neighbor_default_originate, | |
4505 | neighbor_default_originate_cmd, | |
9ccf14f7 | 4506 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 4507 | NEIGHBOR_STR |
4508 | NEIGHBOR_ADDR_STR2 | |
4509 | "Originate default route to this neighbor\n") | |
4510 | { | |
c500ae40 DW |
4511 | int idx_peer = 1; |
4512 | return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4513 | bgp_node_safi (vty), NULL, 1); |
4514 | } | |
4515 | ||
4516 | DEFUN (neighbor_default_originate_rmap, | |
4517 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 4518 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 4519 | NEIGHBOR_STR |
4520 | NEIGHBOR_ADDR_STR2 | |
4521 | "Originate default route to this neighbor\n" | |
4522 | "Route-map to specify criteria to originate default\n" | |
4523 | "route-map name\n") | |
4524 | { | |
c500ae40 DW |
4525 | int idx_peer = 1; |
4526 | int idx_word = 4; | |
4527 | return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4528 | bgp_node_safi (vty), argv[idx_word]->arg, 1); | |
718e3744 | 4529 | } |
4530 | ||
4531 | DEFUN (no_neighbor_default_originate, | |
4532 | no_neighbor_default_originate_cmd, | |
a636c635 | 4533 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 4534 | NO_STR |
4535 | NEIGHBOR_STR | |
4536 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4537 | "Originate default route to this neighbor\n" |
4538 | "Route-map to specify criteria to originate default\n" | |
4539 | "route-map name\n") | |
718e3744 | 4540 | { |
c500ae40 DW |
4541 | int idx_peer = 2; |
4542 | return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4543 | bgp_node_safi (vty), NULL, 0); |
4544 | } | |
4545 | ||
6b0655a2 | 4546 | |
718e3744 | 4547 | /* Set neighbor's BGP port. */ |
94f2b392 | 4548 | static int |
e52702f2 | 4549 | peer_port_vty (struct vty *vty, const char *ip_str, int afi, |
fd79ac91 | 4550 | const char *port_str) |
718e3744 | 4551 | { |
4552 | struct peer *peer; | |
4553 | u_int16_t port; | |
4554 | struct servent *sp; | |
4555 | ||
4556 | peer = peer_lookup_vty (vty, ip_str); | |
4557 | if (! peer) | |
4558 | return CMD_WARNING; | |
4559 | ||
4560 | if (! port_str) | |
e52702f2 | 4561 | { |
718e3744 | 4562 | sp = getservbyname ("bgp", "tcp"); |
4563 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs (sp->s_port); | |
4564 | } | |
4565 | else | |
4566 | { | |
4567 | VTY_GET_INTEGER("port", port, port_str); | |
4568 | } | |
4569 | ||
4570 | peer_port_set (peer, port); | |
4571 | ||
4572 | return CMD_SUCCESS; | |
4573 | } | |
4574 | ||
f418446b | 4575 | /* Set specified peer's BGP port. */ |
718e3744 | 4576 | DEFUN (neighbor_port, |
4577 | neighbor_port_cmd, | |
9ccf14f7 | 4578 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 4579 | NEIGHBOR_STR |
4580 | NEIGHBOR_ADDR_STR | |
4581 | "Neighbor's BGP port\n" | |
4582 | "TCP port number\n") | |
4583 | { | |
c500ae40 DW |
4584 | int idx_ip = 1; |
4585 | int idx_number = 3; | |
4586 | return peer_port_vty (vty, argv[idx_ip]->arg, AFI_IP, argv[idx_number]->arg); | |
718e3744 | 4587 | } |
4588 | ||
4589 | DEFUN (no_neighbor_port, | |
4590 | no_neighbor_port_cmd, | |
9ccf14f7 | 4591 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 4592 | NO_STR |
4593 | NEIGHBOR_STR | |
4594 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
4595 | "Neighbor's BGP port\n" |
4596 | "TCP port number\n") | |
718e3744 | 4597 | { |
c500ae40 DW |
4598 | int idx_ip = 2; |
4599 | return peer_port_vty (vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 4600 | } |
4601 | ||
6b0655a2 | 4602 | |
718e3744 | 4603 | /* neighbor weight. */ |
94f2b392 | 4604 | static int |
e52702f2 | 4605 | peer_weight_set_vty (struct vty *vty, const char *ip_str, |
d93f7ffc | 4606 | afi_t afi, safi_t safi, |
fd79ac91 | 4607 | const char *weight_str) |
718e3744 | 4608 | { |
1f9a9fff | 4609 | int ret; |
718e3744 | 4610 | struct peer *peer; |
4611 | unsigned long weight; | |
4612 | ||
4613 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4614 | if (! peer) | |
4615 | return CMD_WARNING; | |
4616 | ||
4617 | VTY_GET_INTEGER_RANGE("weight", weight, weight_str, 0, 65535); | |
4618 | ||
d93f7ffc | 4619 | ret = peer_weight_set (peer, afi, safi, weight); |
1f9a9fff | 4620 | return bgp_vty_return (vty, ret); |
718e3744 | 4621 | } |
4622 | ||
94f2b392 | 4623 | static int |
d93f7ffc DW |
4624 | peer_weight_unset_vty (struct vty *vty, const char *ip_str, |
4625 | afi_t afi, safi_t safi) | |
718e3744 | 4626 | { |
1f9a9fff | 4627 | int ret; |
718e3744 | 4628 | struct peer *peer; |
4629 | ||
4630 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4631 | if (! peer) | |
4632 | return CMD_WARNING; | |
4633 | ||
d93f7ffc | 4634 | ret = peer_weight_unset (peer, afi, safi); |
1f9a9fff | 4635 | return bgp_vty_return (vty, ret); |
718e3744 | 4636 | } |
4637 | ||
4638 | DEFUN (neighbor_weight, | |
4639 | neighbor_weight_cmd, | |
9ccf14f7 | 4640 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 4641 | NEIGHBOR_STR |
4642 | NEIGHBOR_ADDR_STR2 | |
4643 | "Set default weight for routes from this neighbor\n" | |
4644 | "default weight\n") | |
4645 | { | |
c500ae40 DW |
4646 | int idx_peer = 1; |
4647 | int idx_number = 3; | |
e52702f2 QY |
4648 | return peer_weight_set_vty (vty, |
4649 | argv[idx_peer]->arg, | |
4650 | bgp_node_afi (vty), | |
4651 | bgp_node_safi (vty), | |
4652 | argv[idx_number]->arg); | |
718e3744 | 4653 | } |
4654 | ||
4655 | DEFUN (no_neighbor_weight, | |
4656 | no_neighbor_weight_cmd, | |
9ccf14f7 | 4657 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 4658 | NO_STR |
4659 | NEIGHBOR_STR | |
4660 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
4661 | "Set default weight for routes from this neighbor\n" |
4662 | "default weight\n") | |
718e3744 | 4663 | { |
c500ae40 | 4664 | int idx_peer = 2; |
e52702f2 | 4665 | return peer_weight_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty)); |
718e3744 | 4666 | } |
4667 | ||
6b0655a2 | 4668 | |
718e3744 | 4669 | /* Override capability negotiation. */ |
4670 | DEFUN (neighbor_override_capability, | |
4671 | neighbor_override_capability_cmd, | |
9ccf14f7 | 4672 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 4673 | NEIGHBOR_STR |
4674 | NEIGHBOR_ADDR_STR2 | |
4675 | "Override capability negotiation result\n") | |
4676 | { | |
c500ae40 DW |
4677 | int idx_peer = 1; |
4678 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 4679 | } |
4680 | ||
4681 | DEFUN (no_neighbor_override_capability, | |
4682 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 4683 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 4684 | NO_STR |
4685 | NEIGHBOR_STR | |
4686 | NEIGHBOR_ADDR_STR2 | |
4687 | "Override capability negotiation result\n") | |
4688 | { | |
c500ae40 DW |
4689 | int idx_peer = 2; |
4690 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 4691 | } |
6b0655a2 | 4692 | |
718e3744 | 4693 | DEFUN (neighbor_strict_capability, |
4694 | neighbor_strict_capability_cmd, | |
9ccf14f7 | 4695 | "neighbor <A.B.C.D|X:X::X:X> strict-capability-match", |
718e3744 | 4696 | NEIGHBOR_STR |
4697 | NEIGHBOR_ADDR_STR | |
4698 | "Strict capability negotiation match\n") | |
4699 | { | |
c500ae40 DW |
4700 | int idx_ip = 1; |
4701 | return peer_flag_set_vty (vty, argv[idx_ip]->arg, PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 4702 | } |
4703 | ||
4704 | DEFUN (no_neighbor_strict_capability, | |
4705 | no_neighbor_strict_capability_cmd, | |
9ccf14f7 | 4706 | "no neighbor <A.B.C.D|X:X::X:X> strict-capability-match", |
718e3744 | 4707 | NO_STR |
4708 | NEIGHBOR_STR | |
4709 | NEIGHBOR_ADDR_STR | |
4710 | "Strict capability negotiation match\n") | |
4711 | { | |
c500ae40 DW |
4712 | int idx_ip = 2; |
4713 | return peer_flag_unset_vty (vty, argv[idx_ip]->arg, PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 4714 | } |
6b0655a2 | 4715 | |
94f2b392 | 4716 | static int |
e52702f2 | 4717 | peer_timers_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4718 | const char *keep_str, const char *hold_str) |
718e3744 | 4719 | { |
4720 | int ret; | |
4721 | struct peer *peer; | |
4722 | u_int32_t keepalive; | |
4723 | u_int32_t holdtime; | |
4724 | ||
4725 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4726 | if (! peer) | |
4727 | return CMD_WARNING; | |
4728 | ||
4729 | VTY_GET_INTEGER_RANGE ("Keepalive", keepalive, keep_str, 0, 65535); | |
4730 | VTY_GET_INTEGER_RANGE ("Holdtime", holdtime, hold_str, 0, 65535); | |
4731 | ||
4732 | ret = peer_timers_set (peer, keepalive, holdtime); | |
4733 | ||
4734 | return bgp_vty_return (vty, ret); | |
4735 | } | |
6b0655a2 | 4736 | |
94f2b392 | 4737 | static int |
fd79ac91 | 4738 | peer_timers_unset_vty (struct vty *vty, const char *ip_str) |
718e3744 | 4739 | { |
4740 | int ret; | |
4741 | struct peer *peer; | |
4742 | ||
0c412461 | 4743 | peer = peer_and_group_lookup_vty (vty, ip_str); |
718e3744 | 4744 | if (! peer) |
4745 | return CMD_WARNING; | |
4746 | ||
4747 | ret = peer_timers_unset (peer); | |
4748 | ||
4749 | return bgp_vty_return (vty, ret); | |
4750 | } | |
4751 | ||
4752 | DEFUN (neighbor_timers, | |
4753 | neighbor_timers_cmd, | |
9ccf14f7 | 4754 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 4755 | NEIGHBOR_STR |
4756 | NEIGHBOR_ADDR_STR2 | |
4757 | "BGP per neighbor timers\n" | |
4758 | "Keepalive interval\n" | |
4759 | "Holdtime\n") | |
4760 | { | |
c500ae40 DW |
4761 | int idx_peer = 1; |
4762 | int idx_number = 3; | |
4763 | int idx_number_2 = 4; | |
4764 | return peer_timers_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg); | |
718e3744 | 4765 | } |
4766 | ||
4767 | DEFUN (no_neighbor_timers, | |
4768 | no_neighbor_timers_cmd, | |
9ccf14f7 | 4769 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 4770 | NO_STR |
4771 | NEIGHBOR_STR | |
4772 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
4773 | "BGP per neighbor timers\n" |
4774 | "Keepalive interval\n" | |
4775 | "Holdtime\n") | |
718e3744 | 4776 | { |
c500ae40 DW |
4777 | int idx_peer = 2; |
4778 | return peer_timers_unset_vty (vty, argv[idx_peer]->arg); | |
718e3744 | 4779 | } |
6b0655a2 | 4780 | |
813d4307 | 4781 | |
94f2b392 | 4782 | static int |
e52702f2 | 4783 | peer_timers_connect_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4784 | const char *time_str) |
718e3744 | 4785 | { |
4786 | int ret; | |
4787 | struct peer *peer; | |
4788 | u_int32_t connect; | |
4789 | ||
966f821c | 4790 | peer = peer_and_group_lookup_vty (vty, ip_str); |
718e3744 | 4791 | if (! peer) |
4792 | return CMD_WARNING; | |
4793 | ||
4794 | VTY_GET_INTEGER_RANGE ("Connect time", connect, time_str, 0, 65535); | |
4795 | ||
4796 | ret = peer_timers_connect_set (peer, connect); | |
4797 | ||
966f821c | 4798 | return bgp_vty_return (vty, ret); |
718e3744 | 4799 | } |
4800 | ||
94f2b392 | 4801 | static int |
fd79ac91 | 4802 | peer_timers_connect_unset_vty (struct vty *vty, const char *ip_str) |
718e3744 | 4803 | { |
4804 | int ret; | |
4805 | struct peer *peer; | |
4806 | ||
4807 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4808 | if (! peer) | |
4809 | return CMD_WARNING; | |
4810 | ||
4811 | ret = peer_timers_connect_unset (peer); | |
4812 | ||
966f821c | 4813 | return bgp_vty_return (vty, ret); |
718e3744 | 4814 | } |
4815 | ||
4816 | DEFUN (neighbor_timers_connect, | |
4817 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 4818 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 4819 | NEIGHBOR_STR |
966f821c | 4820 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4821 | "BGP per neighbor timers\n" |
4822 | "BGP connect timer\n" | |
4823 | "Connect timer\n") | |
4824 | { | |
c500ae40 DW |
4825 | int idx_peer = 1; |
4826 | int idx_number = 4; | |
4827 | return peer_timers_connect_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg); | |
718e3744 | 4828 | } |
4829 | ||
4830 | DEFUN (no_neighbor_timers_connect, | |
4831 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 4832 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 4833 | NO_STR |
4834 | NEIGHBOR_STR | |
966f821c | 4835 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4836 | "BGP per neighbor timers\n" |
8334fd5a DW |
4837 | "BGP connect timer\n" |
4838 | "Connect timer\n") | |
718e3744 | 4839 | { |
c500ae40 DW |
4840 | int idx_peer = 2; |
4841 | return peer_timers_connect_unset_vty (vty, argv[idx_peer]->arg); | |
718e3744 | 4842 | } |
4843 | ||
6b0655a2 | 4844 | |
94f2b392 | 4845 | static int |
e52702f2 QY |
4846 | peer_advertise_interval_vty (struct vty *vty, const char *ip_str, |
4847 | const char *time_str, int set) | |
718e3744 | 4848 | { |
4849 | int ret; | |
4850 | struct peer *peer; | |
4851 | u_int32_t routeadv = 0; | |
4852 | ||
966f821c | 4853 | peer = peer_and_group_lookup_vty (vty, ip_str); |
718e3744 | 4854 | if (! peer) |
4855 | return CMD_WARNING; | |
4856 | ||
4857 | if (time_str) | |
4858 | VTY_GET_INTEGER_RANGE ("advertise interval", routeadv, time_str, 0, 600); | |
4859 | ||
4860 | if (set) | |
4861 | ret = peer_advertise_interval_set (peer, routeadv); | |
4862 | else | |
4863 | ret = peer_advertise_interval_unset (peer); | |
4864 | ||
966f821c | 4865 | return bgp_vty_return (vty, ret); |
718e3744 | 4866 | } |
4867 | ||
4868 | DEFUN (neighbor_advertise_interval, | |
4869 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 4870 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 4871 | NEIGHBOR_STR |
966f821c | 4872 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4873 | "Minimum interval between sending BGP routing updates\n" |
4874 | "time in seconds\n") | |
4875 | { | |
c500ae40 DW |
4876 | int idx_peer = 1; |
4877 | int idx_number = 3; | |
4878 | return peer_advertise_interval_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg, 1); | |
718e3744 | 4879 | } |
4880 | ||
4881 | DEFUN (no_neighbor_advertise_interval, | |
4882 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 4883 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 4884 | NO_STR |
4885 | NEIGHBOR_STR | |
966f821c | 4886 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
4887 | "Minimum interval between sending BGP routing updates\n" |
4888 | "time in seconds\n") | |
718e3744 | 4889 | { |
c500ae40 DW |
4890 | int idx_peer = 2; |
4891 | return peer_advertise_interval_vty (vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 4892 | } |
4893 | ||
6b0655a2 | 4894 | |
518f0eb1 DS |
4895 | /* Time to wait before processing route-map updates */ |
4896 | DEFUN (bgp_set_route_map_delay_timer, | |
4897 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 4898 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
4899 | SET_STR |
4900 | "BGP route-map delay timer\n" | |
4901 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 4902 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 4903 | { |
c500ae40 | 4904 | int idx_number = 3; |
518f0eb1 | 4905 | u_int32_t rmap_delay_timer; |
518f0eb1 | 4906 | |
c500ae40 | 4907 | if (argv[idx_number]->arg) |
518f0eb1 | 4908 | { |
c500ae40 | 4909 | VTY_GET_INTEGER_RANGE ("delay-timer", rmap_delay_timer, argv[idx_number]->arg, 0, 600); |
5fe9f963 | 4910 | bm->rmap_update_timer = rmap_delay_timer; |
518f0eb1 DS |
4911 | |
4912 | /* if the dynamic update handling is being disabled, and a timer is | |
4913 | * running, stop the timer and act as if the timer has already fired. | |
4914 | */ | |
5fe9f963 | 4915 | if (!rmap_delay_timer && bm->t_rmap_update ) |
518f0eb1 | 4916 | { |
5fe9f963 | 4917 | BGP_TIMER_OFF(bm->t_rmap_update); |
4918 | thread_execute (bm->master, bgp_route_map_update_timer, NULL, 0); | |
518f0eb1 DS |
4919 | } |
4920 | return CMD_SUCCESS; | |
4921 | } | |
4922 | else | |
ffd0c037 | 4923 | return CMD_WARNING; |
518f0eb1 DS |
4924 | } |
4925 | ||
4926 | DEFUN (no_bgp_set_route_map_delay_timer, | |
4927 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 4928 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 4929 | NO_STR |
3a2d747c | 4930 | BGP_STR |
518f0eb1 | 4931 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
4932 | "Reset to default time to wait for processing route-map changes\n" |
4933 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 4934 | { |
518f0eb1 | 4935 | |
5fe9f963 | 4936 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 DS |
4937 | |
4938 | return CMD_SUCCESS; | |
4939 | } | |
4940 | ||
f414725f | 4941 | |
718e3744 | 4942 | /* neighbor interface */ |
94f2b392 | 4943 | static int |
fd79ac91 | 4944 | peer_interface_vty (struct vty *vty, const char *ip_str, const char *str) |
718e3744 | 4945 | { |
718e3744 | 4946 | struct peer *peer; |
4947 | ||
4948 | peer = peer_lookup_vty (vty, ip_str); | |
a80beece | 4949 | if (! peer || peer->conf_if) |
718e3744 | 4950 | return CMD_WARNING; |
4951 | ||
4952 | if (str) | |
ffd0c037 | 4953 | peer_interface_set (peer, str); |
718e3744 | 4954 | else |
ffd0c037 | 4955 | peer_interface_unset (peer); |
718e3744 | 4956 | |
4957 | return CMD_SUCCESS; | |
4958 | } | |
4959 | ||
4960 | DEFUN (neighbor_interface, | |
4961 | neighbor_interface_cmd, | |
9ccf14f7 | 4962 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 4963 | NEIGHBOR_STR |
4964 | NEIGHBOR_ADDR_STR | |
4965 | "Interface\n" | |
4966 | "Interface name\n") | |
4967 | { | |
c500ae40 DW |
4968 | int idx_ip = 1; |
4969 | int idx_word = 3; | |
00d7d2d3 | 4970 | return peer_interface_vty (vty, argv[idx_ip]->arg, argv[idx_word]->arg); |
718e3744 | 4971 | } |
4972 | ||
4973 | DEFUN (no_neighbor_interface, | |
4974 | no_neighbor_interface_cmd, | |
9ccf14f7 | 4975 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 4976 | NO_STR |
4977 | NEIGHBOR_STR | |
16cedbb0 | 4978 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4979 | "Interface\n" |
4980 | "Interface name\n") | |
4981 | { | |
c500ae40 DW |
4982 | int idx_peer = 2; |
4983 | return peer_interface_vty (vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4984 | } |
6b0655a2 | 4985 | |
718e3744 | 4986 | /* Set distribute list to the peer. */ |
94f2b392 | 4987 | static int |
e52702f2 | 4988 | peer_distribute_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4989 | afi_t afi, safi_t safi, |
4990 | const char *name_str, const char *direct_str) | |
718e3744 | 4991 | { |
4992 | int ret; | |
4993 | struct peer *peer; | |
4994 | int direct = FILTER_IN; | |
4995 | ||
4996 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4997 | if (! peer) | |
4998 | return CMD_WARNING; | |
4999 | ||
5000 | /* Check filter direction. */ | |
5001 | if (strncmp (direct_str, "i", 1) == 0) | |
5002 | direct = FILTER_IN; | |
5003 | else if (strncmp (direct_str, "o", 1) == 0) | |
5004 | direct = FILTER_OUT; | |
5005 | ||
5006 | ret = peer_distribute_set (peer, afi, safi, direct, name_str); | |
5007 | ||
5008 | return bgp_vty_return (vty, ret); | |
5009 | } | |
5010 | ||
94f2b392 | 5011 | static int |
fd79ac91 | 5012 | peer_distribute_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
5013 | safi_t safi, const char *direct_str) | |
718e3744 | 5014 | { |
5015 | int ret; | |
5016 | struct peer *peer; | |
5017 | int direct = FILTER_IN; | |
5018 | ||
5019 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5020 | if (! peer) | |
5021 | return CMD_WARNING; | |
5022 | ||
5023 | /* Check filter direction. */ | |
5024 | if (strncmp (direct_str, "i", 1) == 0) | |
5025 | direct = FILTER_IN; | |
5026 | else if (strncmp (direct_str, "o", 1) == 0) | |
5027 | direct = FILTER_OUT; | |
5028 | ||
5029 | ret = peer_distribute_unset (peer, afi, safi, direct); | |
5030 | ||
5031 | return bgp_vty_return (vty, ret); | |
5032 | } | |
5033 | ||
5034 | DEFUN (neighbor_distribute_list, | |
5035 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 5036 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5037 | NEIGHBOR_STR |
5038 | NEIGHBOR_ADDR_STR2 | |
5039 | "Filter updates to/from this neighbor\n" | |
5040 | "IP access-list number\n" | |
5041 | "IP access-list number (expanded range)\n" | |
5042 | "IP Access-list name\n" | |
5043 | "Filter incoming updates\n" | |
5044 | "Filter outgoing updates\n") | |
5045 | { | |
c500ae40 DW |
5046 | int idx_peer = 1; |
5047 | int idx_acl = 3; | |
5048 | int idx_in_out = 4; | |
5049 | return peer_distribute_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5050 | bgp_node_safi (vty), argv[idx_acl]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5051 | } |
5052 | ||
5053 | DEFUN (no_neighbor_distribute_list, | |
5054 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 5055 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5056 | NO_STR |
5057 | NEIGHBOR_STR | |
5058 | NEIGHBOR_ADDR_STR2 | |
5059 | "Filter updates to/from this neighbor\n" | |
5060 | "IP access-list number\n" | |
5061 | "IP access-list number (expanded range)\n" | |
5062 | "IP Access-list name\n" | |
5063 | "Filter incoming updates\n" | |
5064 | "Filter outgoing updates\n") | |
5065 | { | |
c500ae40 DW |
5066 | int idx_peer = 2; |
5067 | int idx_in_out = 5; | |
5068 | return peer_distribute_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5069 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 5070 | } |
6b0655a2 | 5071 | |
718e3744 | 5072 | /* Set prefix list to the peer. */ |
94f2b392 | 5073 | static int |
fd79ac91 | 5074 | peer_prefix_list_set_vty (struct vty *vty, const char *ip_str, afi_t afi, |
e52702f2 | 5075 | safi_t safi, const char *name_str, |
fd79ac91 | 5076 | const char *direct_str) |
718e3744 | 5077 | { |
5078 | int ret; | |
5079 | struct peer *peer; | |
5080 | int direct = FILTER_IN; | |
5081 | ||
5082 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5083 | if (! peer) | |
5084 | return CMD_WARNING; | |
5085 | ||
5086 | /* Check filter direction. */ | |
5087 | if (strncmp (direct_str, "i", 1) == 0) | |
5088 | direct = FILTER_IN; | |
5089 | else if (strncmp (direct_str, "o", 1) == 0) | |
5090 | direct = FILTER_OUT; | |
5091 | ||
5092 | ret = peer_prefix_list_set (peer, afi, safi, direct, name_str); | |
5093 | ||
5094 | return bgp_vty_return (vty, ret); | |
5095 | } | |
5096 | ||
94f2b392 | 5097 | static int |
fd79ac91 | 5098 | peer_prefix_list_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
5099 | safi_t safi, const char *direct_str) | |
718e3744 | 5100 | { |
5101 | int ret; | |
5102 | struct peer *peer; | |
5103 | int direct = FILTER_IN; | |
5104 | ||
5105 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5106 | if (! peer) | |
5107 | return CMD_WARNING; | |
e52702f2 | 5108 | |
718e3744 | 5109 | /* Check filter direction. */ |
5110 | if (strncmp (direct_str, "i", 1) == 0) | |
5111 | direct = FILTER_IN; | |
5112 | else if (strncmp (direct_str, "o", 1) == 0) | |
5113 | direct = FILTER_OUT; | |
5114 | ||
5115 | ret = peer_prefix_list_unset (peer, afi, safi, direct); | |
5116 | ||
5117 | return bgp_vty_return (vty, ret); | |
5118 | } | |
5119 | ||
5120 | DEFUN (neighbor_prefix_list, | |
5121 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 5122 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5123 | NEIGHBOR_STR |
5124 | NEIGHBOR_ADDR_STR2 | |
5125 | "Filter updates to/from this neighbor\n" | |
5126 | "Name of a prefix list\n" | |
5127 | "Filter incoming updates\n" | |
5128 | "Filter outgoing updates\n") | |
5129 | { | |
c500ae40 DW |
5130 | int idx_peer = 1; |
5131 | int idx_word = 3; | |
5132 | int idx_in_out = 4; | |
5133 | return peer_prefix_list_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5134 | bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5135 | } |
5136 | ||
5137 | DEFUN (no_neighbor_prefix_list, | |
5138 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 5139 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5140 | NO_STR |
5141 | NEIGHBOR_STR | |
5142 | NEIGHBOR_ADDR_STR2 | |
5143 | "Filter updates to/from this neighbor\n" | |
5144 | "Name of a prefix list\n" | |
5145 | "Filter incoming updates\n" | |
5146 | "Filter outgoing updates\n") | |
5147 | { | |
c500ae40 DW |
5148 | int idx_peer = 2; |
5149 | int idx_in_out = 5; | |
5150 | return peer_prefix_list_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5151 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 5152 | } |
6b0655a2 | 5153 | |
94f2b392 | 5154 | static int |
e52702f2 | 5155 | peer_aslist_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 5156 | afi_t afi, safi_t safi, |
5157 | const char *name_str, const char *direct_str) | |
718e3744 | 5158 | { |
5159 | int ret; | |
5160 | struct peer *peer; | |
5161 | int direct = FILTER_IN; | |
5162 | ||
5163 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5164 | if (! peer) | |
5165 | return CMD_WARNING; | |
5166 | ||
5167 | /* Check filter direction. */ | |
5168 | if (strncmp (direct_str, "i", 1) == 0) | |
5169 | direct = FILTER_IN; | |
5170 | else if (strncmp (direct_str, "o", 1) == 0) | |
5171 | direct = FILTER_OUT; | |
5172 | ||
5173 | ret = peer_aslist_set (peer, afi, safi, direct, name_str); | |
5174 | ||
5175 | return bgp_vty_return (vty, ret); | |
5176 | } | |
5177 | ||
94f2b392 | 5178 | static int |
e52702f2 | 5179 | peer_aslist_unset_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 5180 | afi_t afi, safi_t safi, |
5181 | const char *direct_str) | |
718e3744 | 5182 | { |
5183 | int ret; | |
5184 | struct peer *peer; | |
5185 | int direct = FILTER_IN; | |
5186 | ||
5187 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5188 | if (! peer) | |
5189 | return CMD_WARNING; | |
5190 | ||
5191 | /* Check filter direction. */ | |
5192 | if (strncmp (direct_str, "i", 1) == 0) | |
5193 | direct = FILTER_IN; | |
5194 | else if (strncmp (direct_str, "o", 1) == 0) | |
5195 | direct = FILTER_OUT; | |
5196 | ||
5197 | ret = peer_aslist_unset (peer, afi, safi, direct); | |
5198 | ||
5199 | return bgp_vty_return (vty, ret); | |
5200 | } | |
5201 | ||
5202 | DEFUN (neighbor_filter_list, | |
5203 | neighbor_filter_list_cmd, | |
9ccf14f7 | 5204 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5205 | NEIGHBOR_STR |
5206 | NEIGHBOR_ADDR_STR2 | |
5207 | "Establish BGP filters\n" | |
5208 | "AS path access-list name\n" | |
5209 | "Filter incoming routes\n" | |
5210 | "Filter outgoing routes\n") | |
5211 | { | |
c500ae40 DW |
5212 | int idx_peer = 1; |
5213 | int idx_word = 3; | |
5214 | int idx_in_out = 4; | |
5215 | return peer_aslist_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5216 | bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5217 | } |
5218 | ||
5219 | DEFUN (no_neighbor_filter_list, | |
5220 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 5221 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5222 | NO_STR |
5223 | NEIGHBOR_STR | |
5224 | NEIGHBOR_ADDR_STR2 | |
5225 | "Establish BGP filters\n" | |
5226 | "AS path access-list name\n" | |
5227 | "Filter incoming routes\n" | |
5228 | "Filter outgoing routes\n") | |
5229 | { | |
c500ae40 DW |
5230 | int idx_peer = 2; |
5231 | int idx_in_out = 5; | |
5232 | return peer_aslist_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5233 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 5234 | } |
6b0655a2 | 5235 | |
718e3744 | 5236 | /* Set route-map to the peer. */ |
94f2b392 | 5237 | static int |
e52702f2 | 5238 | peer_route_map_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 5239 | afi_t afi, safi_t safi, |
5240 | const char *name_str, const char *direct_str) | |
718e3744 | 5241 | { |
5242 | int ret; | |
5243 | struct peer *peer; | |
fee0f4c6 | 5244 | int direct = RMAP_IN; |
718e3744 | 5245 | |
5246 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5247 | if (! peer) | |
5248 | return CMD_WARNING; | |
5249 | ||
5250 | /* Check filter direction. */ | |
fee0f4c6 | 5251 | if (strncmp (direct_str, "in", 2) == 0) |
5252 | direct = RMAP_IN; | |
718e3744 | 5253 | else if (strncmp (direct_str, "o", 1) == 0) |
fee0f4c6 | 5254 | direct = RMAP_OUT; |
718e3744 | 5255 | |
5256 | ret = peer_route_map_set (peer, afi, safi, direct, name_str); | |
5257 | ||
5258 | return bgp_vty_return (vty, ret); | |
5259 | } | |
5260 | ||
94f2b392 | 5261 | static int |
fd79ac91 | 5262 | peer_route_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
5263 | safi_t safi, const char *direct_str) | |
718e3744 | 5264 | { |
5265 | int ret; | |
5266 | struct peer *peer; | |
fee0f4c6 | 5267 | int direct = RMAP_IN; |
718e3744 | 5268 | |
5269 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5270 | if (! peer) | |
5271 | return CMD_WARNING; | |
5272 | ||
5273 | /* Check filter direction. */ | |
fee0f4c6 | 5274 | if (strncmp (direct_str, "in", 2) == 0) |
5275 | direct = RMAP_IN; | |
718e3744 | 5276 | else if (strncmp (direct_str, "o", 1) == 0) |
fee0f4c6 | 5277 | direct = RMAP_OUT; |
718e3744 | 5278 | |
5279 | ret = peer_route_map_unset (peer, afi, safi, direct); | |
5280 | ||
5281 | return bgp_vty_return (vty, ret); | |
5282 | } | |
5283 | ||
5284 | DEFUN (neighbor_route_map, | |
5285 | neighbor_route_map_cmd, | |
9ccf14f7 | 5286 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5287 | NEIGHBOR_STR |
5288 | NEIGHBOR_ADDR_STR2 | |
5289 | "Apply route map to neighbor\n" | |
5290 | "Name of route map\n" | |
5291 | "Apply map to incoming routes\n" | |
2a3d5731 | 5292 | "Apply map to outbound routes\n") |
718e3744 | 5293 | { |
c500ae40 DW |
5294 | int idx_peer = 1; |
5295 | int idx_word = 3; | |
5296 | int idx_in_out = 4; | |
5297 | return peer_route_map_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5298 | bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5299 | } |
5300 | ||
5301 | DEFUN (no_neighbor_route_map, | |
5302 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 5303 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5304 | NO_STR |
5305 | NEIGHBOR_STR | |
5306 | NEIGHBOR_ADDR_STR2 | |
5307 | "Apply route map to neighbor\n" | |
5308 | "Name of route map\n" | |
5309 | "Apply map to incoming routes\n" | |
2a3d5731 | 5310 | "Apply map to outbound routes\n") |
718e3744 | 5311 | { |
c500ae40 DW |
5312 | int idx_peer = 2; |
5313 | int idx_in_out = 5; | |
5314 | return peer_route_map_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5315 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 5316 | } |
6b0655a2 | 5317 | |
718e3744 | 5318 | /* Set unsuppress-map to the peer. */ |
94f2b392 | 5319 | static int |
fd79ac91 | 5320 | peer_unsuppress_map_set_vty (struct vty *vty, const char *ip_str, afi_t afi, |
5321 | safi_t safi, const char *name_str) | |
718e3744 | 5322 | { |
5323 | int ret; | |
5324 | struct peer *peer; | |
5325 | ||
5326 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5327 | if (! peer) | |
5328 | return CMD_WARNING; | |
5329 | ||
5330 | ret = peer_unsuppress_map_set (peer, afi, safi, name_str); | |
5331 | ||
5332 | return bgp_vty_return (vty, ret); | |
5333 | } | |
5334 | ||
5335 | /* Unset route-map from the peer. */ | |
94f2b392 | 5336 | static int |
fd79ac91 | 5337 | peer_unsuppress_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
718e3744 | 5338 | safi_t safi) |
5339 | { | |
5340 | int ret; | |
5341 | struct peer *peer; | |
5342 | ||
5343 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5344 | if (! peer) | |
5345 | return CMD_WARNING; | |
5346 | ||
5347 | ret = peer_unsuppress_map_unset (peer, afi, safi); | |
5348 | ||
5349 | return bgp_vty_return (vty, ret); | |
5350 | } | |
5351 | ||
5352 | DEFUN (neighbor_unsuppress_map, | |
5353 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5354 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5355 | NEIGHBOR_STR |
5356 | NEIGHBOR_ADDR_STR2 | |
5357 | "Route-map to selectively unsuppress suppressed routes\n" | |
5358 | "Name of route map\n") | |
5359 | { | |
c500ae40 DW |
5360 | int idx_peer = 1; |
5361 | int idx_word = 3; | |
5362 | return peer_unsuppress_map_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5363 | bgp_node_safi (vty), argv[idx_word]->arg); | |
718e3744 | 5364 | } |
5365 | ||
5366 | DEFUN (no_neighbor_unsuppress_map, | |
5367 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5368 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5369 | NO_STR |
5370 | NEIGHBOR_STR | |
5371 | NEIGHBOR_ADDR_STR2 | |
5372 | "Route-map to selectively unsuppress suppressed routes\n" | |
5373 | "Name of route map\n") | |
5374 | { | |
c500ae40 DW |
5375 | int idx_peer = 2; |
5376 | return peer_unsuppress_map_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 5377 | bgp_node_safi (vty)); |
5378 | } | |
6b0655a2 | 5379 | |
94f2b392 | 5380 | static int |
fd79ac91 | 5381 | peer_maximum_prefix_set_vty (struct vty *vty, const char *ip_str, afi_t afi, |
e52702f2 | 5382 | safi_t safi, const char *num_str, |
0a486e5f | 5383 | const char *threshold_str, int warning, |
5384 | const char *restart_str) | |
718e3744 | 5385 | { |
5386 | int ret; | |
5387 | struct peer *peer; | |
5388 | u_int32_t max; | |
e0701b79 | 5389 | u_char threshold; |
0a486e5f | 5390 | u_int16_t restart; |
718e3744 | 5391 | |
5392 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5393 | if (! peer) | |
5394 | return CMD_WARNING; | |
5395 | ||
e6ec1c36 | 5396 | VTY_GET_INTEGER ("maximum number", max, num_str); |
e0701b79 | 5397 | if (threshold_str) |
5398 | threshold = atoi (threshold_str); | |
5399 | else | |
5400 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 5401 | |
0a486e5f | 5402 | if (restart_str) |
5403 | restart = atoi (restart_str); | |
5404 | else | |
5405 | restart = 0; | |
5406 | ||
5407 | ret = peer_maximum_prefix_set (peer, afi, safi, max, threshold, warning, restart); | |
718e3744 | 5408 | |
5409 | return bgp_vty_return (vty, ret); | |
5410 | } | |
5411 | ||
94f2b392 | 5412 | static int |
fd79ac91 | 5413 | peer_maximum_prefix_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
718e3744 | 5414 | safi_t safi) |
5415 | { | |
5416 | int ret; | |
5417 | struct peer *peer; | |
5418 | ||
5419 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5420 | if (! peer) | |
5421 | return CMD_WARNING; | |
5422 | ||
5423 | ret = peer_maximum_prefix_unset (peer, afi, safi); | |
5424 | ||
5425 | return bgp_vty_return (vty, ret); | |
5426 | } | |
5427 | ||
5428 | /* Maximum number of prefix configuration. prefix count is different | |
5429 | for each peer configuration. So this configuration can be set for | |
5430 | each peer configuration. */ | |
5431 | DEFUN (neighbor_maximum_prefix, | |
5432 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 5433 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 5434 | NEIGHBOR_STR |
5435 | NEIGHBOR_ADDR_STR2 | |
5436 | "Maximum number of prefix accept from this peer\n" | |
5437 | "maximum no. of prefix limit\n") | |
5438 | { | |
c500ae40 DW |
5439 | int idx_peer = 1; |
5440 | int idx_number = 3; | |
5441 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5442 | bgp_node_safi (vty), argv[idx_number]->arg, NULL, 0, | |
0a486e5f | 5443 | NULL); |
718e3744 | 5444 | } |
5445 | ||
e0701b79 | 5446 | DEFUN (neighbor_maximum_prefix_threshold, |
5447 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 5448 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 5449 | NEIGHBOR_STR |
5450 | NEIGHBOR_ADDR_STR2 | |
5451 | "Maximum number of prefix accept from this peer\n" | |
5452 | "maximum no. of prefix limit\n" | |
5453 | "Threshold value (%) at which to generate a warning msg\n") | |
5454 | { | |
c500ae40 DW |
5455 | int idx_peer = 1; |
5456 | int idx_number = 3; | |
5457 | int idx_number_2 = 4; | |
5458 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5459 | bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
0a486e5f | 5460 | NULL); |
5461 | } | |
e0701b79 | 5462 | |
718e3744 | 5463 | DEFUN (neighbor_maximum_prefix_warning, |
5464 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 5465 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 5466 | NEIGHBOR_STR |
5467 | NEIGHBOR_ADDR_STR2 | |
5468 | "Maximum number of prefix accept from this peer\n" | |
5469 | "maximum no. of prefix limit\n" | |
5470 | "Only give warning message when limit is exceeded\n") | |
5471 | { | |
c500ae40 DW |
5472 | int idx_peer = 1; |
5473 | int idx_number = 3; | |
5474 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5475 | bgp_node_safi (vty), argv[idx_number]->arg, NULL, 1, | |
0a486e5f | 5476 | NULL); |
718e3744 | 5477 | } |
5478 | ||
e0701b79 | 5479 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
5480 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 5481 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 5482 | NEIGHBOR_STR |
5483 | NEIGHBOR_ADDR_STR2 | |
5484 | "Maximum number of prefix accept from this peer\n" | |
5485 | "maximum no. of prefix limit\n" | |
5486 | "Threshold value (%) at which to generate a warning msg\n" | |
5487 | "Only give warning message when limit is exceeded\n") | |
5488 | { | |
c500ae40 DW |
5489 | int idx_peer = 1; |
5490 | int idx_number = 3; | |
5491 | int idx_number_2 = 4; | |
5492 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5493 | bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 5494 | } |
5495 | ||
5496 | DEFUN (neighbor_maximum_prefix_restart, | |
5497 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 5498 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 5499 | NEIGHBOR_STR |
5500 | NEIGHBOR_ADDR_STR2 | |
5501 | "Maximum number of prefix accept from this peer\n" | |
5502 | "maximum no. of prefix limit\n" | |
5503 | "Restart bgp connection after limit is exceeded\n" | |
5504 | "Restart interval in minutes") | |
5505 | { | |
c500ae40 DW |
5506 | int idx_peer = 1; |
5507 | int idx_number = 3; | |
5508 | int idx_number_2 = 5; | |
5509 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5510 | bgp_node_safi (vty), argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 5511 | } |
5512 | ||
5513 | DEFUN (neighbor_maximum_prefix_threshold_restart, | |
5514 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 5515 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 5516 | NEIGHBOR_STR |
5517 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5518 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 5519 | "maximum no. of prefix limit\n" |
5520 | "Threshold value (%) at which to generate a warning msg\n" | |
5521 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 5522 | "Restart interval in minutes\n") |
0a486e5f | 5523 | { |
c500ae40 DW |
5524 | int idx_peer = 1; |
5525 | int idx_number = 3; | |
5526 | int idx_number_2 = 4; | |
5527 | int idx_number_3 = 6; | |
5528 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5529 | bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 0, argv[idx_number_3]->arg); | |
0a486e5f | 5530 | } |
e0701b79 | 5531 | |
718e3744 | 5532 | DEFUN (no_neighbor_maximum_prefix, |
5533 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 5534 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 5535 | NO_STR |
5536 | NEIGHBOR_STR | |
5537 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5538 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
5539 | "maximum no. of prefix limit\n" |
5540 | "Threshold value (%) at which to generate a warning msg\n" | |
5541 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 5542 | "Restart interval in minutes\n" |
31500417 | 5543 | "Only give warning message when limit is exceeded\n") |
718e3744 | 5544 | { |
c500ae40 DW |
5545 | int idx_peer = 2; |
5546 | return peer_maximum_prefix_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 5547 | bgp_node_safi (vty)); |
5548 | } | |
e52702f2 | 5549 | |
718e3744 | 5550 | |
718e3744 | 5551 | /* "neighbor allowas-in" */ |
5552 | DEFUN (neighbor_allowas_in, | |
5553 | neighbor_allowas_in_cmd, | |
fd8503f5 | 5554 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 5555 | NEIGHBOR_STR |
5556 | NEIGHBOR_ADDR_STR2 | |
31500417 | 5557 | "Accept as-path with my AS present in it\n" |
fd8503f5 QY |
5558 | "Number of occurances of AS number\n" |
5559 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 5560 | { |
c500ae40 | 5561 | int idx_peer = 1; |
fd8503f5 | 5562 | int idx_number_origin = 3; |
718e3744 | 5563 | int ret; |
aac9ef6c | 5564 | int origin = 0; |
718e3744 | 5565 | struct peer *peer; |
aac9ef6c | 5566 | int allow_num = 0; |
718e3744 | 5567 | |
c500ae40 | 5568 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 5569 | if (! peer) |
5570 | return CMD_WARNING; | |
5571 | ||
fd8503f5 | 5572 | if (argc <= idx_number_origin) |
718e3744 | 5573 | allow_num = 3; |
5574 | else | |
aac9ef6c | 5575 | { |
fd8503f5 | 5576 | if (argv[idx_number_origin]->type == WORD_TKN) |
aac9ef6c DW |
5577 | origin = 1; |
5578 | else | |
fd8503f5 | 5579 | allow_num = atoi (argv[idx_number_origin]->arg); |
aac9ef6c | 5580 | } |
718e3744 | 5581 | |
5582 | ret = peer_allowas_in_set (peer, bgp_node_afi (vty), bgp_node_safi (vty), | |
aac9ef6c | 5583 | allow_num, origin); |
718e3744 | 5584 | |
5585 | return bgp_vty_return (vty, ret); | |
5586 | } | |
5587 | ||
718e3744 | 5588 | DEFUN (no_neighbor_allowas_in, |
5589 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 5590 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 5591 | NO_STR |
5592 | NEIGHBOR_STR | |
5593 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 5594 | "allow local ASN appears in aspath attribute\n" |
fd8503f5 QY |
5595 | "Number of occurances of AS number\n" |
5596 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 5597 | { |
c500ae40 | 5598 | int idx_peer = 2; |
718e3744 | 5599 | int ret; |
5600 | struct peer *peer; | |
5601 | ||
c500ae40 | 5602 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 5603 | if (! peer) |
5604 | return CMD_WARNING; | |
5605 | ||
5606 | ret = peer_allowas_in_unset (peer, bgp_node_afi (vty), bgp_node_safi (vty)); | |
5607 | ||
5608 | return bgp_vty_return (vty, ret); | |
5609 | } | |
6b0655a2 | 5610 | |
fa411a21 NH |
5611 | DEFUN (neighbor_ttl_security, |
5612 | neighbor_ttl_security_cmd, | |
9ccf14f7 | 5613 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
5614 | NEIGHBOR_STR |
5615 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5616 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
5617 | "Specify the maximum number of hops to the BGP peer\n" |
5618 | "Number of hops to BGP peer\n") | |
fa411a21 | 5619 | { |
c500ae40 DW |
5620 | int idx_peer = 1; |
5621 | int idx_number = 4; | |
fa411a21 | 5622 | struct peer *peer; |
89b6d1f8 | 5623 | int gtsm_hops; |
fa411a21 | 5624 | |
c500ae40 | 5625 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
fa411a21 NH |
5626 | if (! peer) |
5627 | return CMD_WARNING; | |
e52702f2 | 5628 | |
c500ae40 | 5629 | VTY_GET_INTEGER_RANGE ("", gtsm_hops, argv[idx_number]->arg, 1, 254); |
fa411a21 | 5630 | |
8cdabf90 SK |
5631 | /* |
5632 | * If 'neighbor swpX', then this is for directly connected peers, | |
5633 | * we should not accept a ttl-security hops value greater than 1. | |
5634 | */ | |
5635 | if (peer->conf_if && (gtsm_hops > 1)) { | |
5636 | vty_out (vty, "%s is directly connected peer, hops cannot exceed 1%s", | |
c500ae40 | 5637 | argv[idx_peer]->arg, VTY_NEWLINE); |
8cdabf90 SK |
5638 | return CMD_WARNING; |
5639 | } | |
5640 | ||
89b6d1f8 | 5641 | return bgp_vty_return (vty, peer_ttl_security_hops_set (peer, gtsm_hops)); |
fa411a21 NH |
5642 | } |
5643 | ||
5644 | DEFUN (no_neighbor_ttl_security, | |
5645 | no_neighbor_ttl_security_cmd, | |
9ccf14f7 | 5646 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
5647 | NO_STR |
5648 | NEIGHBOR_STR | |
5649 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5650 | "BGP ttl-security parameters\n" |
3a2d747c QY |
5651 | "Specify the maximum number of hops to the BGP peer\n" |
5652 | "Number of hops to BGP peer\n") | |
fa411a21 | 5653 | { |
c500ae40 | 5654 | int idx_peer = 2; |
fa411a21 | 5655 | struct peer *peer; |
fa411a21 | 5656 | |
c500ae40 | 5657 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
fa411a21 NH |
5658 | if (! peer) |
5659 | return CMD_WARNING; | |
5660 | ||
89b6d1f8 | 5661 | return bgp_vty_return (vty, peer_ttl_security_hops_unset (peer)); |
fa411a21 | 5662 | } |
6b0655a2 | 5663 | |
adbac85e DW |
5664 | DEFUN (neighbor_addpath_tx_all_paths, |
5665 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 5666 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
5667 | NEIGHBOR_STR |
5668 | NEIGHBOR_ADDR_STR2 | |
5669 | "Use addpath to advertise all paths to a neighbor\n") | |
5670 | { | |
c500ae40 | 5671 | int idx_peer = 1; |
adbac85e DW |
5672 | struct peer *peer; |
5673 | ||
c500ae40 | 5674 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
adbac85e DW |
5675 | if (! peer) |
5676 | return CMD_WARNING; | |
5677 | ||
c500ae40 | 5678 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
adbac85e DW |
5679 | bgp_node_safi (vty), |
5680 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
5681 | } | |
5682 | ||
5683 | DEFUN (no_neighbor_addpath_tx_all_paths, | |
5684 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 5685 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
5686 | NO_STR |
5687 | NEIGHBOR_STR | |
5688 | NEIGHBOR_ADDR_STR2 | |
5689 | "Use addpath to advertise all paths to a neighbor\n") | |
5690 | { | |
c500ae40 DW |
5691 | int idx_peer = 2; |
5692 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
adbac85e DW |
5693 | bgp_node_safi (vty), |
5694 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
5695 | } | |
5696 | ||
06370dac DW |
5697 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
5698 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 5699 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
5700 | NEIGHBOR_STR |
5701 | NEIGHBOR_ADDR_STR2 | |
5702 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
5703 | { | |
c500ae40 | 5704 | int idx_peer = 1; |
06370dac DW |
5705 | struct peer *peer; |
5706 | ||
c500ae40 | 5707 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
06370dac DW |
5708 | if (! peer) |
5709 | return CMD_WARNING; | |
5710 | ||
c500ae40 | 5711 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
06370dac DW |
5712 | bgp_node_safi (vty), |
5713 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
5714 | } | |
5715 | ||
5716 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, | |
5717 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 5718 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
5719 | NO_STR |
5720 | NEIGHBOR_STR | |
5721 | NEIGHBOR_ADDR_STR2 | |
5722 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
5723 | { | |
c500ae40 DW |
5724 | int idx_peer = 2; |
5725 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
06370dac DW |
5726 | bgp_node_safi (vty), |
5727 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
5728 | } | |
5729 | ||
505e5056 | 5730 | DEFUN_NOSH (address_family_ipv4_safi, |
718e3744 | 5731 | address_family_ipv4_safi_cmd, |
f51bae9c | 5732 | "address-family ipv4 [<unicast|multicast|vpn|encap|labeled-unicast>]", |
718e3744 | 5733 | "Enter Address Family command mode\n" |
8c3deaae | 5734 | "Address Family\n" |
46f296b4 | 5735 | BGP_SAFI_HELP_STR) |
718e3744 | 5736 | { |
f51bae9c DS |
5737 | |
5738 | if (argc == 3) | |
ccbb332a | 5739 | { |
f51bae9c DS |
5740 | safi_t safi = bgp_vty_safi_from_arg(argv[2]->arg); |
5741 | vty->node = bgp_node_type(AFI_IP, safi); | |
ccbb332a | 5742 | } |
c7f1274b DS |
5743 | else |
5744 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 5745 | |
5746 | return CMD_SUCCESS; | |
5747 | } | |
5748 | ||
505e5056 | 5749 | DEFUN_NOSH (address_family_ipv6_safi, |
25ffbdc1 | 5750 | address_family_ipv6_safi_cmd, |
f51bae9c | 5751 | "address-family ipv6 [<unicast|multicast|vpn|encap|labeled-unicast>]", |
718e3744 | 5752 | "Enter Address Family command mode\n" |
8c3deaae | 5753 | "Address Family\n" |
46f296b4 | 5754 | BGP_SAFI_HELP_STR) |
25ffbdc1 | 5755 | { |
f51bae9c | 5756 | if (argc == 3) |
46f296b4 | 5757 | { |
f51bae9c DS |
5758 | safi_t safi = bgp_vty_safi_from_arg(argv[2]->arg); |
5759 | vty->node = bgp_node_type(AFI_IP6, safi); | |
46f296b4 | 5760 | } |
c7f1274b DS |
5761 | else |
5762 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 5763 | |
5764 | return CMD_SUCCESS; | |
5765 | } | |
718e3744 | 5766 | |
d6902373 | 5767 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 5768 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 5769 | address_family_vpnv4_cmd, |
8334fd5a | 5770 | "address-family vpnv4 [unicast]", |
718e3744 | 5771 | "Enter Address Family command mode\n" |
8c3deaae | 5772 | "Address Family\n" |
3a2d747c | 5773 | "Address Family modifier\n") |
718e3744 | 5774 | { |
5775 | vty->node = BGP_VPNV4_NODE; | |
5776 | return CMD_SUCCESS; | |
5777 | } | |
5778 | ||
505e5056 | 5779 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 5780 | address_family_vpnv6_cmd, |
8334fd5a | 5781 | "address-family vpnv6 [unicast]", |
8ecd3266 | 5782 | "Enter Address Family command mode\n" |
8c3deaae | 5783 | "Address Family\n" |
3a2d747c | 5784 | "Address Family modifier\n") |
8ecd3266 | 5785 | { |
5786 | vty->node = BGP_VPNV6_NODE; | |
5787 | return CMD_SUCCESS; | |
5788 | } | |
c016b6c7 | 5789 | #endif |
d6902373 | 5790 | |
505e5056 | 5791 | DEFUN_NOSH (address_family_encap, |
8b1fb8be | 5792 | address_family_encap_cmd, |
8334fd5a | 5793 | "address-family <encap|encapv4>", |
8b1fb8be | 5794 | "Enter Address Family command mode\n" |
8c3deaae QY |
5795 | "Address Family\n" |
5796 | "Address Family\n") | |
8b1fb8be LB |
5797 | { |
5798 | vty->node = BGP_ENCAP_NODE; | |
5799 | return CMD_SUCCESS; | |
5800 | } | |
5801 | ||
8b1fb8be | 5802 | |
505e5056 | 5803 | DEFUN_NOSH (address_family_encapv6, |
8b1fb8be LB |
5804 | address_family_encapv6_cmd, |
5805 | "address-family encapv6", | |
5806 | "Enter Address Family command mode\n" | |
8c3deaae | 5807 | "Address Family\n") |
8b1fb8be LB |
5808 | { |
5809 | vty->node = BGP_ENCAPV6_NODE; | |
5810 | return CMD_SUCCESS; | |
5811 | } | |
5812 | ||
505e5056 | 5813 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 5814 | address_family_evpn_cmd, |
b194703e | 5815 | "address-family <l2vpn evpn>", |
4e0b7b6d | 5816 | "Enter Address Family command mode\n" |
61a51962 PG |
5817 | "EVPN Address family\n" |
5818 | "Layer2 VPN Address family\n" | |
5819 | "Ethernet Virtual Private Network Subsequent Address Family\n") | |
4e0b7b6d | 5820 | { |
4e0b7b6d | 5821 | vty->node = BGP_EVPN_NODE; |
4e0b7b6d PG |
5822 | return CMD_SUCCESS; |
5823 | } | |
5824 | ||
505e5056 | 5825 | DEFUN_NOSH (exit_address_family, |
718e3744 | 5826 | exit_address_family_cmd, |
5827 | "exit-address-family", | |
5828 | "Exit from Address Family configuration mode\n") | |
5829 | { | |
a8a80d53 | 5830 | if (vty->node == BGP_IPV4_NODE |
5831 | || vty->node == BGP_IPV4M_NODE | |
f51bae9c | 5832 | || vty->node == BGP_IPV4L_NODE |
718e3744 | 5833 | || vty->node == BGP_VPNV4_NODE |
25ffbdc1 | 5834 | || vty->node == BGP_IPV6_NODE |
8ecd3266 | 5835 | || vty->node == BGP_IPV6M_NODE |
f51bae9c | 5836 | || vty->node == BGP_IPV6L_NODE |
8b1fb8be LB |
5837 | || vty->node == BGP_VPNV6_NODE |
5838 | || vty->node == BGP_ENCAP_NODE | |
4e0b7b6d PG |
5839 | || vty->node == BGP_ENCAPV6_NODE |
5840 | || vty->node == BGP_EVPN_NODE) | |
718e3744 | 5841 | vty->node = BGP_NODE; |
5842 | return CMD_SUCCESS; | |
5843 | } | |
6b0655a2 | 5844 | |
8ad7271d DS |
5845 | /* Recalculate bestpath and re-advertise a prefix */ |
5846 | static int | |
01080f7c | 5847 | bgp_clear_prefix (struct vty *vty, const char *view_name, const char *ip_str, |
8ad7271d DS |
5848 | afi_t afi, safi_t safi, struct prefix_rd *prd) |
5849 | { | |
5850 | int ret; | |
5851 | struct prefix match; | |
5852 | struct bgp_node *rn; | |
5853 | struct bgp_node *rm; | |
8ad7271d DS |
5854 | struct bgp *bgp; |
5855 | struct bgp_table *table; | |
5856 | struct bgp_table *rib; | |
5857 | ||
5858 | /* BGP structure lookup. */ | |
5859 | if (view_name) | |
5860 | { | |
5861 | bgp = bgp_lookup_by_name (view_name); | |
5862 | if (bgp == NULL) | |
5863 | { | |
6aeb9e78 | 5864 | vty_out (vty, "%% Can't find BGP instance %s%s", view_name, VTY_NEWLINE); |
8ad7271d DS |
5865 | return CMD_WARNING; |
5866 | } | |
5867 | } | |
5868 | else | |
5869 | { | |
5870 | bgp = bgp_get_default (); | |
5871 | if (bgp == NULL) | |
5872 | { | |
5873 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
5874 | return CMD_WARNING; | |
5875 | } | |
5876 | } | |
5877 | ||
5878 | /* Check IP address argument. */ | |
5879 | ret = str2prefix (ip_str, &match); | |
5880 | if (! ret) | |
5881 | { | |
5882 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); | |
5883 | return CMD_WARNING; | |
5884 | } | |
5885 | ||
5886 | match.family = afi2family (afi); | |
5887 | rib = bgp->rib[afi][safi]; | |
5888 | ||
5889 | if (safi == SAFI_MPLS_VPN) | |
5890 | { | |
5891 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) | |
5892 | { | |
5893 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) | |
5894 | continue; | |
5895 | ||
5896 | if ((table = rn->info) != NULL) | |
5897 | { | |
5898 | if ((rm = bgp_node_match (table, &match)) != NULL) | |
5899 | { | |
5900 | if (rm->p.prefixlen == match.prefixlen) | |
5901 | { | |
5902 | SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR); | |
5903 | bgp_process (bgp, rm, afi, safi); | |
5904 | } | |
5905 | bgp_unlock_node (rm); | |
5906 | } | |
5907 | } | |
5908 | } | |
5909 | } | |
5910 | else | |
5911 | { | |
5912 | if ((rn = bgp_node_match (rib, &match)) != NULL) | |
5913 | { | |
5914 | if (rn->p.prefixlen == match.prefixlen) | |
5915 | { | |
5916 | SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR); | |
5917 | bgp_process (bgp, rn, afi, safi); | |
5918 | } | |
5919 | bgp_unlock_node (rn); | |
5920 | } | |
5921 | } | |
5922 | ||
5923 | return CMD_SUCCESS; | |
5924 | } | |
5925 | ||
b09b5ae0 | 5926 | /* one clear bgp command to rule them all */ |
718e3744 | 5927 | DEFUN (clear_ip_bgp_all, |
5928 | clear_ip_bgp_all_cmd, | |
46f296b4 | 5929 | "clear [ip] bgp [<view|vrf> WORD] ["BGP_AFI_CMD_STR" ["BGP_SAFI_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 | 5930 | CLEAR_STR |
5931 | IP_STR | |
5932 | BGP_STR | |
838758ac | 5933 | BGP_INSTANCE_HELP_STR |
b09b5ae0 DW |
5934 | "Clear all peers\n" |
5935 | "BGP neighbor address to clear\n" | |
a80beece | 5936 | "BGP IPv6 neighbor to clear\n" |
838758ac | 5937 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
5938 | "Clear peers with the AS number\n" |
5939 | "Clear all external peers\n" | |
718e3744 | 5940 | "Clear all members of peer-group\n" |
b09b5ae0 | 5941 | "BGP peer-group name\n" |
46f296b4 LB |
5942 | BGP_AFI_HELP_STR |
5943 | BGP_SAFI_HELP_STR | |
b09b5ae0 DW |
5944 | BGP_SOFT_STR |
5945 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
5946 | BGP_SOFT_OUT_STR |
5947 | BGP_SOFT_IN_STR | |
5948 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 5949 | BGP_SOFT_OUT_STR) |
718e3744 | 5950 | { |
8334fd5a | 5951 | char *vrf = NULL; |
630a298c | 5952 | |
ae19d7dd QY |
5953 | afi_t afi = AFI_IP6; |
5954 | safi_t safi = SAFI_UNICAST; | |
5bf15956 | 5955 | enum clear_sort clr_sort = clear_peer; |
b09b5ae0 DW |
5956 | enum bgp_clear_type clr_type; |
5957 | char *clr_arg = NULL; | |
718e3744 | 5958 | |
ae19d7dd | 5959 | int idx = 0; |
01080f7c | 5960 | |
ae19d7dd QY |
5961 | /* clear [ip] bgp */ |
5962 | if (argv_find (argv, argc, "ip", &idx)) | |
5963 | afi = AFI_IP; | |
5964 | /* [<view|vrf> WORD] */ | |
5965 | if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) | |
838758ac | 5966 | { |
ae19d7dd QY |
5967 | vrf = argv[idx + 1]->arg; |
5968 | idx += 2; | |
838758ac | 5969 | } |
ae19d7dd QY |
5970 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */ |
5971 | if (argv_find (argv, argc, "*", &idx)) | |
b09b5ae0 | 5972 | { |
ae19d7dd | 5973 | clr_sort = clear_all; |
b09b5ae0 | 5974 | } |
ae19d7dd | 5975 | else if (argv_find (argv, argc, "A.B.C.D", &idx)) |
b09b5ae0 DW |
5976 | { |
5977 | clr_sort = clear_peer; | |
ae19d7dd | 5978 | clr_arg = argv[idx]->arg; |
b09b5ae0 | 5979 | } |
ae19d7dd | 5980 | else if (argv_find (argv, argc, "X:X::X:X", &idx)) |
b09b5ae0 | 5981 | { |
ae19d7dd QY |
5982 | clr_sort = clear_peer; |
5983 | clr_arg = argv[idx]->arg; | |
838758ac | 5984 | } |
ae19d7dd | 5985 | else if (argv_find (argv, argc, "peer-group", &idx)) |
b09b5ae0 DW |
5986 | { |
5987 | clr_sort = clear_group; | |
ae19d7dd QY |
5988 | idx++; |
5989 | clr_arg = argv[idx]->arg; | |
b09b5ae0 | 5990 | } |
ae19d7dd | 5991 | else if (argv_find (argv, argc, "WORD", &idx)) |
b09b5ae0 | 5992 | { |
f0dac89f RW |
5993 | clr_sort = clear_peer; |
5994 | clr_arg = argv[idx]->arg; | |
b09b5ae0 | 5995 | } |
ae19d7dd QY |
5996 | else if (argv_find (argv, argc, "(1-4294967295)", &idx)) |
5997 | { | |
5998 | clr_sort = clear_as; | |
5999 | clr_arg = argv[idx]->arg; | |
6000 | } | |
6001 | else if (argv_find (argv, argc, "external", &idx)) | |
6002 | { | |
6003 | clr_sort = clear_external; | |
6004 | } | |
46f296b4 LB |
6005 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
6006 | if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) | |
ae19d7dd | 6007 | { |
46f296b4 | 6008 | argv_find_and_parse_safi (argv, argc, &idx, &safi); |
ae19d7dd QY |
6009 | } |
6010 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
6011 | if (argv_find (argv, argc, "soft", &idx)) | |
6012 | { | |
6013 | if (argv_find (argv, argc, "in", &idx) || argv_find (argv, argc, "out", &idx)) | |
6014 | clr_type = strmatch (argv[idx]->text, "in") ? BGP_CLEAR_SOFT_IN : BGP_CLEAR_SOFT_OUT; | |
6015 | else | |
6016 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
6017 | } | |
6018 | else if (argv_find (argv, argc, "in", &idx)) | |
6019 | { | |
6020 | clr_type = argv_find (argv, argc, "prefix-filter", &idx) ? BGP_CLEAR_SOFT_IN_ORF_PREFIX : BGP_CLEAR_SOFT_IN; | |
6021 | } | |
6022 | else if (argv_find (argv, argc, "out", &idx)) | |
6023 | { | |
5daa3e5e | 6024 | clr_type = BGP_CLEAR_SOFT_OUT; |
ae19d7dd QY |
6025 | } |
6026 | else | |
6027 | clr_type = BGP_CLEAR_SOFT_NONE; | |
718e3744 | 6028 | |
b09b5ae0 | 6029 | return bgp_clear_vty (vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); |
838758ac | 6030 | } |
01080f7c | 6031 | |
8ad7271d DS |
6032 | DEFUN (clear_ip_bgp_prefix, |
6033 | clear_ip_bgp_prefix_cmd, | |
838758ac | 6034 | "clear [ip] bgp [<view|vrf> WORD] prefix A.B.C.D/M", |
8ad7271d DS |
6035 | CLEAR_STR |
6036 | IP_STR | |
6037 | BGP_STR | |
838758ac | 6038 | BGP_INSTANCE_HELP_STR |
8ad7271d | 6039 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 6040 | "IPv4 prefix\n") |
8ad7271d | 6041 | { |
8334fd5a | 6042 | char *vrf = NULL; |
630a298c | 6043 | char *prefix = NULL; |
8ad7271d | 6044 | |
630a298c | 6045 | int idx = 0; |
01080f7c | 6046 | |
630a298c QY |
6047 | /* [<view|vrf> WORD] */ |
6048 | if (argv_find (argv, argc, "WORD", &idx)) | |
6049 | vrf = argv[idx]->arg; | |
0c7b1b01 | 6050 | |
630a298c | 6051 | prefix = argv[argc-1]->arg; |
8ad7271d | 6052 | |
630a298c | 6053 | return bgp_clear_prefix (vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 6054 | } |
8ad7271d | 6055 | |
b09b5ae0 DW |
6056 | DEFUN (clear_bgp_ipv6_safi_prefix, |
6057 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 6058 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 6059 | CLEAR_STR |
3a2d747c | 6060 | IP_STR |
718e3744 | 6061 | BGP_STR |
8c3deaae | 6062 | "Address Family\n" |
46f296b4 | 6063 | BGP_SAFI_HELP_STR |
b09b5ae0 | 6064 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 6065 | "IPv6 prefix\n") |
718e3744 | 6066 | { |
b09b5ae0 DW |
6067 | int idx_safi = 3; |
6068 | int idx_ipv6_prefixlen = 5; | |
46f296b4 LB |
6069 | return bgp_clear_prefix (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, |
6070 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), NULL); | |
838758ac | 6071 | } |
01080f7c | 6072 | |
b09b5ae0 DW |
6073 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
6074 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
46f296b4 | 6075 | "clear [ip] bgp <view|vrf> WORD ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 6076 | CLEAR_STR |
3a2d747c | 6077 | IP_STR |
718e3744 | 6078 | BGP_STR |
838758ac | 6079 | BGP_INSTANCE_HELP_STR |
8c3deaae | 6080 | "Address Family\n" |
46f296b4 | 6081 | BGP_SAFI_HELP_STR |
b09b5ae0 | 6082 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 6083 | "IPv6 prefix\n") |
718e3744 | 6084 | { |
b09b5ae0 | 6085 | int idx_word = 3; |
c500ae40 | 6086 | int idx_safi = 5; |
b09b5ae0 | 6087 | int idx_ipv6_prefixlen = 7; |
46f296b4 LB |
6088 | return bgp_clear_prefix (vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, |
6089 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), NULL); | |
718e3744 | 6090 | } |
6091 | ||
b09b5ae0 DW |
6092 | DEFUN (show_bgp_views, |
6093 | show_bgp_views_cmd, | |
d6e3c605 | 6094 | "show [ip] bgp views", |
b09b5ae0 | 6095 | SHOW_STR |
d6e3c605 | 6096 | IP_STR |
01080f7c | 6097 | BGP_STR |
b09b5ae0 | 6098 | "Show the defined BGP views\n") |
01080f7c | 6099 | { |
b09b5ae0 DW |
6100 | struct list *inst = bm->bgp; |
6101 | struct listnode *node; | |
6102 | struct bgp *bgp; | |
01080f7c | 6103 | |
b09b5ae0 DW |
6104 | if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE)) |
6105 | { | |
6106 | vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE); | |
6107 | return CMD_WARNING; | |
6108 | } | |
e52702f2 | 6109 | |
b09b5ae0 DW |
6110 | vty_out (vty, "Defined BGP views:%s", VTY_NEWLINE); |
6111 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) | |
6112 | { | |
6113 | /* Skip VRFs. */ | |
6114 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
6115 | continue; | |
6116 | vty_out (vty, "\t%s (AS%u)%s", | |
6117 | bgp->name ? bgp->name : "(null)", | |
6118 | bgp->as, VTY_NEWLINE); | |
6119 | } | |
e52702f2 | 6120 | |
b09b5ae0 | 6121 | return CMD_SUCCESS; |
e0081f70 ML |
6122 | } |
6123 | ||
8386ac43 | 6124 | DEFUN (show_bgp_vrfs, |
6125 | show_bgp_vrfs_cmd, | |
d6e3c605 | 6126 | "show [ip] bgp vrfs [json]", |
8386ac43 | 6127 | SHOW_STR |
d6e3c605 | 6128 | IP_STR |
8386ac43 | 6129 | BGP_STR |
6130 | "Show BGP VRFs\n" | |
9973d184 | 6131 | JSON_STR) |
8386ac43 | 6132 | { |
6133 | struct list *inst = bm->bgp; | |
6134 | struct listnode *node; | |
6135 | struct bgp *bgp; | |
6136 | u_char uj = use_json(argc, argv); | |
6137 | json_object *json = NULL; | |
6138 | json_object *json_vrfs = NULL; | |
6139 | int count = 0; | |
6140 | static char header[] = "Type Id RouterId #PeersCfg #PeersEstb Name"; | |
6141 | ||
6142 | if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE)) | |
6143 | { | |
6144 | vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE); | |
6145 | return CMD_WARNING; | |
6146 | } | |
6147 | ||
6148 | if (uj) | |
6149 | { | |
6150 | json = json_object_new_object(); | |
6151 | json_vrfs = json_object_new_object(); | |
6152 | } | |
6153 | ||
6154 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) | |
6155 | { | |
6156 | const char *name, *type; | |
6157 | struct peer *peer; | |
6158 | struct listnode *node, *nnode; | |
6159 | int peers_cfg, peers_estb; | |
6160 | json_object *json_vrf = NULL; | |
5c81a5f3 | 6161 | int vrf_id_ui; |
8386ac43 | 6162 | |
6163 | /* Skip Views. */ | |
6164 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
6165 | continue; | |
6166 | ||
6167 | count++; | |
6168 | if (!uj && count == 1) | |
6169 | vty_out (vty, "%s%s", header, VTY_NEWLINE); | |
6170 | ||
6171 | peers_cfg = peers_estb = 0; | |
6172 | if (uj) | |
6173 | json_vrf = json_object_new_object(); | |
6174 | ||
6175 | ||
6176 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
6177 | { | |
6178 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6179 | continue; | |
6180 | peers_cfg++; | |
6181 | if (peer->status == Established) | |
6182 | peers_estb++; | |
6183 | } | |
6184 | ||
6185 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
6186 | { | |
6187 | name = "Default"; | |
6188 | type = "DFLT"; | |
6189 | } | |
6190 | else | |
6191 | { | |
6192 | name = bgp->name; | |
6193 | type = "VRF"; | |
6194 | } | |
6195 | ||
5c81a5f3 | 6196 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id; |
8386ac43 | 6197 | if (uj) |
6198 | { | |
6199 | json_object_string_add(json_vrf, "type", type); | |
5c81a5f3 | 6200 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); |
8386ac43 | 6201 | json_object_string_add(json_vrf, "routerId", inet_ntoa (bgp->router_id)); |
6202 | json_object_int_add(json_vrf, "numConfiguredPeers", peers_cfg); | |
6203 | json_object_int_add(json_vrf, "numEstablishedPeers", peers_estb); | |
6204 | ||
6205 | json_object_object_add(json_vrfs, name, json_vrf); | |
6206 | } | |
6207 | else | |
5c81a5f3 | 6208 | vty_out (vty, "%4s %-5d %-16s %9u %10u %s%s", |
6209 | type, vrf_id_ui, inet_ntoa (bgp->router_id), | |
8386ac43 | 6210 | peers_cfg, peers_estb, name, |
6211 | VTY_NEWLINE); | |
6212 | } | |
6213 | ||
6214 | if (uj) | |
6215 | { | |
6216 | json_object_object_add(json, "vrfs", json_vrfs); | |
6217 | ||
6218 | json_object_int_add(json, "totalVrfs", count); | |
6219 | ||
2aac5767 | 6220 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
8386ac43 | 6221 | json_object_free(json); |
6222 | } | |
6223 | else | |
6224 | { | |
6225 | if (count) | |
6226 | vty_out (vty, "%sTotal number of VRFs (including default): %d%s", | |
6227 | VTY_NEWLINE, count, VTY_NEWLINE); | |
6228 | } | |
6229 | ||
6230 | return CMD_SUCCESS; | |
6231 | } | |
6232 | ||
f412b39a | 6233 | DEFUN (show_bgp_memory, |
4bf6a362 | 6234 | show_bgp_memory_cmd, |
7fa12b13 | 6235 | "show [ip] bgp memory", |
4bf6a362 | 6236 | SHOW_STR |
3a2d747c | 6237 | IP_STR |
4bf6a362 PJ |
6238 | BGP_STR |
6239 | "Global BGP memory statistics\n") | |
6240 | { | |
6241 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
6242 | unsigned long count; | |
e52702f2 | 6243 | |
4bf6a362 PJ |
6244 | /* RIB related usage stats */ |
6245 | count = mtype_stats_alloc (MTYPE_BGP_NODE); | |
6246 | vty_out (vty, "%ld RIB nodes, using %s of memory%s", count, | |
6247 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6248 | count * sizeof (struct bgp_node)), | |
6249 | VTY_NEWLINE); | |
e52702f2 | 6250 | |
4bf6a362 PJ |
6251 | count = mtype_stats_alloc (MTYPE_BGP_ROUTE); |
6252 | vty_out (vty, "%ld BGP routes, using %s of memory%s", count, | |
6253 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6254 | count * sizeof (struct bgp_info)), | |
6255 | VTY_NEWLINE); | |
fb982c25 PJ |
6256 | if ((count = mtype_stats_alloc (MTYPE_BGP_ROUTE_EXTRA))) |
6257 | vty_out (vty, "%ld BGP route ancillaries, using %s of memory%s", count, | |
6258 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6259 | count * sizeof (struct bgp_info_extra)), | |
6260 | VTY_NEWLINE); | |
e52702f2 | 6261 | |
4bf6a362 PJ |
6262 | if ((count = mtype_stats_alloc (MTYPE_BGP_STATIC))) |
6263 | vty_out (vty, "%ld Static routes, using %s of memory%s", count, | |
6264 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6265 | count * sizeof (struct bgp_static)), | |
6266 | VTY_NEWLINE); | |
3f9c7369 DS |
6267 | |
6268 | if ((count = mtype_stats_alloc (MTYPE_BGP_PACKET))) | |
6269 | vty_out (vty, "%ld Packets, using %s of memory%s", count, | |
6270 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6271 | count * sizeof (struct bpacket)), | |
6272 | VTY_NEWLINE); | |
e52702f2 | 6273 | |
4bf6a362 PJ |
6274 | /* Adj-In/Out */ |
6275 | if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_IN))) | |
6276 | vty_out (vty, "%ld Adj-In entries, using %s of memory%s", count, | |
6277 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6278 | count * sizeof (struct bgp_adj_in)), | |
6279 | VTY_NEWLINE); | |
6280 | if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_OUT))) | |
6281 | vty_out (vty, "%ld Adj-Out entries, using %s of memory%s", count, | |
6282 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6283 | count * sizeof (struct bgp_adj_out)), | |
6284 | VTY_NEWLINE); | |
e52702f2 | 6285 | |
4bf6a362 PJ |
6286 | if ((count = mtype_stats_alloc (MTYPE_BGP_NEXTHOP_CACHE))) |
6287 | vty_out (vty, "%ld Nexthop cache entries, using %s of memory%s", count, | |
6288 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6289 | count * sizeof (struct bgp_nexthop_cache)), | |
6290 | VTY_NEWLINE); | |
6291 | ||
6292 | if ((count = mtype_stats_alloc (MTYPE_BGP_DAMP_INFO))) | |
6293 | vty_out (vty, "%ld Dampening entries, using %s of memory%s", count, | |
6294 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6295 | count * sizeof (struct bgp_damp_info)), | |
6296 | VTY_NEWLINE); | |
6297 | ||
6298 | /* Attributes */ | |
6299 | count = attr_count(); | |
e52702f2 QY |
6300 | vty_out (vty, "%ld BGP attributes, using %s of memory%s", count, |
6301 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6302 | count * sizeof(struct attr)), | |
4bf6a362 | 6303 | VTY_NEWLINE); |
fb982c25 | 6304 | if ((count = mtype_stats_alloc (MTYPE_ATTR_EXTRA))) |
e52702f2 QY |
6305 | vty_out (vty, "%ld BGP extra attributes, using %s of memory%s", count, |
6306 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6307 | count * sizeof(struct attr_extra)), | |
fb982c25 | 6308 | VTY_NEWLINE); |
e52702f2 | 6309 | |
4bf6a362 PJ |
6310 | if ((count = attr_unknown_count())) |
6311 | vty_out (vty, "%ld unknown attributes%s", count, VTY_NEWLINE); | |
e52702f2 | 6312 | |
4bf6a362 PJ |
6313 | /* AS_PATH attributes */ |
6314 | count = aspath_count (); | |
6315 | vty_out (vty, "%ld BGP AS-PATH entries, using %s of memory%s", count, | |
6316 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6317 | count * sizeof (struct aspath)), | |
6318 | VTY_NEWLINE); | |
e52702f2 | 6319 | |
4bf6a362 PJ |
6320 | count = mtype_stats_alloc (MTYPE_AS_SEG); |
6321 | vty_out (vty, "%ld BGP AS-PATH segments, using %s of memory%s", count, | |
6322 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6323 | count * sizeof (struct assegment)), | |
6324 | VTY_NEWLINE); | |
e52702f2 | 6325 | |
4bf6a362 PJ |
6326 | /* Other attributes */ |
6327 | if ((count = community_count ())) | |
6328 | vty_out (vty, "%ld BGP community entries, using %s of memory%s", count, | |
6329 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6330 | count * sizeof (struct community)), | |
6331 | VTY_NEWLINE); | |
6332 | if ((count = mtype_stats_alloc (MTYPE_ECOMMUNITY))) | |
6333 | vty_out (vty, "%ld BGP community entries, using %s of memory%s", count, | |
6334 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6335 | count * sizeof (struct ecommunity)), | |
6336 | VTY_NEWLINE); | |
57d187bc JS |
6337 | if ((count = mtype_stats_alloc (MTYPE_LCOMMUNITY))) |
6338 | vty_out (vty, "%ld BGP large-community entries, using %s of memory%s", | |
2acb4ac2 | 6339 | count, |
57d187bc JS |
6340 | mtype_memstr (memstrbuf, sizeof (memstrbuf), |
6341 | count * sizeof (struct lcommunity)), | |
6342 | VTY_NEWLINE); | |
e52702f2 | 6343 | |
4bf6a362 PJ |
6344 | if ((count = mtype_stats_alloc (MTYPE_CLUSTER))) |
6345 | vty_out (vty, "%ld Cluster lists, using %s of memory%s", count, | |
6346 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6347 | count * sizeof (struct cluster_list)), | |
6348 | VTY_NEWLINE); | |
e52702f2 | 6349 | |
4bf6a362 PJ |
6350 | /* Peer related usage */ |
6351 | count = mtype_stats_alloc (MTYPE_BGP_PEER); | |
6352 | vty_out (vty, "%ld peers, using %s of memory%s", count, | |
6353 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6354 | count * sizeof (struct peer)), | |
6355 | VTY_NEWLINE); | |
e52702f2 | 6356 | |
4a1ab8e4 | 6357 | if ((count = mtype_stats_alloc (MTYPE_PEER_GROUP))) |
4bf6a362 PJ |
6358 | vty_out (vty, "%ld peer groups, using %s of memory%s", count, |
6359 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6360 | count * sizeof (struct peer_group)), | |
6361 | VTY_NEWLINE); | |
e52702f2 | 6362 | |
4bf6a362 PJ |
6363 | /* Other */ |
6364 | if ((count = mtype_stats_alloc (MTYPE_HASH))) | |
6365 | vty_out (vty, "%ld hash tables, using %s of memory%s", count, | |
6366 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6367 | count * sizeof (struct hash)), | |
6368 | VTY_NEWLINE); | |
6369 | if ((count = mtype_stats_alloc (MTYPE_HASH_BACKET))) | |
6370 | vty_out (vty, "%ld hash buckets, using %s of memory%s", count, | |
6371 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6372 | count * sizeof (struct hash_backet)), | |
6373 | VTY_NEWLINE); | |
6374 | if ((count = mtype_stats_alloc (MTYPE_BGP_REGEXP))) | |
6375 | vty_out (vty, "%ld compiled regexes, using %s of memory%s", count, | |
6376 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6377 | count * sizeof (regex_t)), | |
6378 | VTY_NEWLINE); | |
6379 | return CMD_SUCCESS; | |
6380 | } | |
fee0f4c6 | 6381 | |
718e3744 | 6382 | /* Show BGP peer's summary information. */ |
94f2b392 | 6383 | static int |
b05a1c8b | 6384 | bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi, |
9f689658 | 6385 | u_char use_json, json_object *json) |
718e3744 | 6386 | { |
6387 | struct peer *peer; | |
1eb8ef25 | 6388 | struct listnode *node, *nnode; |
f14e6fdb DS |
6389 | unsigned int count = 0, dn_count = 0; |
6390 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
f933309e DW |
6391 | char neighbor_buf[VTY_BUFSIZ]; |
6392 | int neighbor_col_default_width = 16; | |
718e3744 | 6393 | int len; |
f933309e | 6394 | int max_neighbor_width = 0; |
ffd0c037 DS |
6395 | json_object *json_peer = NULL; |
6396 | json_object *json_peers = NULL; | |
718e3744 | 6397 | |
b05a1c8b DS |
6398 | if (use_json) |
6399 | { | |
9f689658 DD |
6400 | if (json == NULL) |
6401 | json = json_object_new_object(); | |
6402 | ||
f1aa5d8a | 6403 | json_peers = json_object_new_object(); |
b05a1c8b | 6404 | } |
f933309e DW |
6405 | else |
6406 | { | |
6407 | /* Loop over all neighbors that will be displayed to determine how many | |
6408 | * characters are needed for the Neighbor column | |
6409 | */ | |
6410 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
6411 | { | |
6412 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6413 | continue; | |
6414 | ||
6415 | if (peer->afc[afi][safi]) | |
6416 | { | |
c9d5bd27 DS |
6417 | memset(dn_flag, '\0', sizeof(dn_flag)); |
6418 | if (peer_dynamic_neighbor(peer)) | |
6419 | dn_flag[0] = '*'; | |
6420 | ||
f933309e DW |
6421 | if (peer->hostname && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) |
6422 | sprintf(neighbor_buf, "%s%s(%s) ", dn_flag, peer->hostname, peer->host); | |
6423 | else | |
6424 | sprintf(neighbor_buf, "%s%s ", dn_flag, peer->host); | |
6425 | ||
6426 | len = strlen(neighbor_buf); | |
6427 | ||
6428 | if (len > max_neighbor_width) | |
6429 | max_neighbor_width = len; | |
6430 | } | |
6431 | } | |
6432 | ||
6433 | /* Originally we displayed the Neighbor column as 16 | |
6434 | * characters wide so make that the default | |
6435 | */ | |
6436 | if (max_neighbor_width < neighbor_col_default_width) | |
6437 | max_neighbor_width = neighbor_col_default_width; | |
6438 | } | |
b05a1c8b | 6439 | |
1eb8ef25 | 6440 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
718e3744 | 6441 | { |
1ff9a340 DS |
6442 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
6443 | continue; | |
6444 | ||
718e3744 | 6445 | if (peer->afc[afi][safi]) |
6446 | { | |
b05a1c8b | 6447 | if (!count) |
4bf6a362 PJ |
6448 | { |
6449 | unsigned long ents; | |
6450 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
5c81a5f3 | 6451 | int vrf_id_ui; |
6452 | ||
6453 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id; | |
b05a1c8b | 6454 | |
4bf6a362 | 6455 | /* Usage summary and header */ |
b05a1c8b DS |
6456 | if (use_json) |
6457 | { | |
62d6dca0 | 6458 | json_object_string_add(json, "routerId", inet_ntoa (bgp->router_id)); |
f1aa5d8a | 6459 | json_object_int_add(json, "as", bgp->as); |
9f689658 DD |
6460 | json_object_int_add(json, "vrfId", vrf_id_ui); |
6461 | json_object_string_add(json, "vrfName", | |
6462 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
6463 | ? "Default" : bgp->name); | |
b05a1c8b DS |
6464 | } |
6465 | else | |
6466 | { | |
6467 | vty_out (vty, | |
5c81a5f3 | 6468 | "BGP router identifier %s, local AS number %u vrf-id %d", |
6469 | inet_ntoa (bgp->router_id), bgp->as, vrf_id_ui); | |
6aeb9e78 | 6470 | vty_out (vty, "%s", VTY_NEWLINE); |
b05a1c8b DS |
6471 | } |
6472 | ||
f188f2c4 DS |
6473 | if (bgp_update_delay_configured(bgp)) |
6474 | { | |
b05a1c8b | 6475 | if (use_json) |
f188f2c4 | 6476 | { |
62d6dca0 | 6477 | json_object_int_add(json, "updateDelayLimit", bgp->v_update_delay); |
b05a1c8b DS |
6478 | |
6479 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
62d6dca0 | 6480 | json_object_int_add(json, "updateDelayEstablishWait", bgp->v_establish_wait); |
b05a1c8b DS |
6481 | |
6482 | if (bgp_update_delay_active(bgp)) | |
6483 | { | |
62d6dca0 DS |
6484 | json_object_string_add(json, "updateDelayFirstNeighbor", bgp->update_delay_begin_time); |
6485 | json_object_boolean_true_add(json, "updateDelayInProgress"); | |
b05a1c8b DS |
6486 | } |
6487 | else | |
6488 | { | |
6489 | if (bgp->update_delay_over) | |
6490 | { | |
62d6dca0 | 6491 | json_object_string_add(json, "updateDelayFirstNeighbor", |
f1aa5d8a | 6492 | bgp->update_delay_begin_time); |
62d6dca0 | 6493 | json_object_string_add(json, "updateDelayBestpathResumed", |
f1aa5d8a | 6494 | bgp->update_delay_end_time); |
62d6dca0 | 6495 | json_object_string_add(json, "updateDelayZebraUpdateResume", |
f1aa5d8a | 6496 | bgp->update_delay_zebra_resume_time); |
62d6dca0 | 6497 | json_object_string_add(json, "updateDelayPeerUpdateResume", |
f1aa5d8a | 6498 | bgp->update_delay_peers_resume_time); |
b05a1c8b DS |
6499 | } |
6500 | } | |
f188f2c4 DS |
6501 | } |
6502 | else | |
6503 | { | |
b05a1c8b DS |
6504 | vty_out (vty, "Read-only mode update-delay limit: %d seconds%s", |
6505 | bgp->v_update_delay, VTY_NEWLINE); | |
6506 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
6507 | vty_out (vty, " Establish wait: %d seconds%s", | |
6508 | bgp->v_establish_wait, VTY_NEWLINE); | |
6509 | ||
6510 | if (bgp_update_delay_active(bgp)) | |
f188f2c4 DS |
6511 | { |
6512 | vty_out (vty, " First neighbor established: %s%s", | |
6513 | bgp->update_delay_begin_time, VTY_NEWLINE); | |
b05a1c8b DS |
6514 | vty_out (vty, " Delay in progress%s", VTY_NEWLINE); |
6515 | } | |
6516 | else | |
6517 | { | |
6518 | if (bgp->update_delay_over) | |
6519 | { | |
6520 | vty_out (vty, " First neighbor established: %s%s", | |
6521 | bgp->update_delay_begin_time, VTY_NEWLINE); | |
6522 | vty_out (vty, " Best-paths resumed: %s%s", | |
6523 | bgp->update_delay_end_time, VTY_NEWLINE); | |
6524 | vty_out (vty, " zebra update resumed: %s%s", | |
6525 | bgp->update_delay_zebra_resume_time, VTY_NEWLINE); | |
6526 | vty_out (vty, " peers update resumed: %s%s", | |
6527 | bgp->update_delay_peers_resume_time, VTY_NEWLINE); | |
6528 | } | |
f188f2c4 DS |
6529 | } |
6530 | } | |
6531 | } | |
4bf6a362 | 6532 | |
b05a1c8b DS |
6533 | if (use_json) |
6534 | { | |
6535 | if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active) | |
62d6dca0 | 6536 | json_object_boolean_true_add(json, "maxMedOnStartup"); |
b05a1c8b | 6537 | if (bgp->v_maxmed_admin) |
62d6dca0 | 6538 | json_object_boolean_true_add(json, "maxMedAdministrative"); |
b05a1c8b | 6539 | |
62d6dca0 | 6540 | json_object_int_add(json, "tableVersion", bgp_table_version(bgp->rib[afi][safi])); |
b05a1c8b DS |
6541 | |
6542 | ents = bgp_table_count (bgp->rib[afi][safi]); | |
62d6dca0 DS |
6543 | json_object_int_add(json, "ribCount", ents); |
6544 | json_object_int_add(json, "ribMemory", ents * sizeof (struct bgp_node)); | |
b05a1c8b DS |
6545 | |
6546 | ents = listcount (bgp->peer); | |
62d6dca0 DS |
6547 | json_object_int_add(json, "peerCount", ents); |
6548 | json_object_int_add(json, "peerMemory", ents * sizeof (struct peer)); | |
b05a1c8b | 6549 | |
b05a1c8b DS |
6550 | if ((ents = listcount (bgp->group))) |
6551 | { | |
62d6dca0 DS |
6552 | json_object_int_add(json, "peerGroupCount", ents); |
6553 | json_object_int_add(json, "peerGroupMemory", ents * sizeof (struct peer_group)); | |
b05a1c8b | 6554 | } |
3f9c7369 | 6555 | |
b05a1c8b | 6556 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) |
62d6dca0 | 6557 | json_object_boolean_true_add(json, "dampeningEnabled"); |
b05a1c8b DS |
6558 | } |
6559 | else | |
6560 | { | |
6561 | if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active) | |
6562 | vty_out (vty, "Max-med on-startup active%s", VTY_NEWLINE); | |
6563 | if (bgp->v_maxmed_admin) | |
6564 | vty_out (vty, "Max-med administrative active%s", VTY_NEWLINE); | |
6565 | ||
ffd0c037 | 6566 | vty_out(vty, "BGP table version %" PRIu64 "%s", |
b05a1c8b DS |
6567 | bgp_table_version(bgp->rib[afi][safi]), VTY_NEWLINE); |
6568 | ||
6569 | ents = bgp_table_count (bgp->rib[afi][safi]); | |
6570 | vty_out (vty, "RIB entries %ld, using %s of memory%s", ents, | |
6571 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6572 | ents * sizeof (struct bgp_node)), | |
6573 | VTY_NEWLINE); | |
6574 | ||
6575 | /* Peer related usage */ | |
6576 | ents = listcount (bgp->peer); | |
6577 | vty_out (vty, "Peers %ld, using %s of memory%s", | |
6578 | ents, | |
6579 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6580 | ents * sizeof (struct peer)), | |
6581 | VTY_NEWLINE); | |
6582 | ||
b05a1c8b DS |
6583 | if ((ents = listcount (bgp->group))) |
6584 | vty_out (vty, "Peer groups %ld, using %s of memory%s", ents, | |
6585 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6586 | ents * sizeof (struct peer_group)), | |
6587 | VTY_NEWLINE); | |
6588 | ||
6589 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) | |
6590 | vty_out (vty, "Dampening enabled.%s", VTY_NEWLINE); | |
6591 | vty_out (vty, "%s", VTY_NEWLINE); | |
f933309e DW |
6592 | |
6593 | /* Subtract 8 here because 'Neighbor' is 8 characters */ | |
6594 | vty_out (vty, "Neighbor"); | |
6595 | vty_out (vty, "%*s", max_neighbor_width - 8, " "); | |
6596 | vty_out (vty, "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd%s", VTY_NEWLINE); | |
b05a1c8b | 6597 | } |
4bf6a362 | 6598 | } |
e52702f2 | 6599 | |
b05a1c8b | 6600 | count++; |
718e3744 | 6601 | |
b05a1c8b DS |
6602 | if (use_json) |
6603 | { | |
6604 | json_peer = json_object_new_object(); | |
f14e6fdb | 6605 | |
b05a1c8b | 6606 | if (peer_dynamic_neighbor(peer)) |
62d6dca0 | 6607 | json_object_boolean_true_add(json_peer, "dynamicPeer"); |
b05a1c8b | 6608 | |
04b6bdc0 DW |
6609 | if (peer->hostname) |
6610 | json_object_string_add(json_peer, "hostname", peer->hostname); | |
6611 | ||
6612 | if (peer->domainname) | |
6613 | json_object_string_add(json_peer, "domainname", peer->domainname); | |
6614 | ||
62d6dca0 | 6615 | json_object_int_add(json_peer, "remoteAs", peer->as); |
f1aa5d8a | 6616 | json_object_int_add(json_peer, "version", 4); |
62d6dca0 | 6617 | json_object_int_add(json_peer, "msgRcvd", |
f1aa5d8a DS |
6618 | peer->open_in + peer->update_in + peer->keepalive_in |
6619 | + peer->notify_in + peer->refresh_in | |
6620 | + peer->dynamic_cap_in); | |
62d6dca0 | 6621 | json_object_int_add(json_peer, "msgSent", |
f1aa5d8a DS |
6622 | peer->open_out + peer->update_out + peer->keepalive_out |
6623 | + peer->notify_out + peer->refresh_out | |
6624 | + peer->dynamic_cap_out); | |
6625 | ||
62d6dca0 | 6626 | json_object_int_add(json_peer, "tableVersion", peer->version[afi][safi]); |
f1aa5d8a DS |
6627 | json_object_int_add(json_peer, "outq", peer->obuf->count); |
6628 | json_object_int_add(json_peer, "inq", 0); | |
856ca177 | 6629 | peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, use_json, json_peer); |
62d6dca0 | 6630 | json_object_int_add(json_peer, "prefixReceivedCount", peer->pcount[afi][safi]); |
b05a1c8b DS |
6631 | |
6632 | if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) | |
f1aa5d8a | 6633 | json_object_string_add(json_peer, "state", "Idle (Admin)"); |
b05a1c8b | 6634 | else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) |
f1aa5d8a | 6635 | json_object_string_add(json_peer, "state", "Idle (PfxCt)"); |
b05a1c8b | 6636 | else |
f1aa5d8a | 6637 | json_object_string_add(json_peer, "state", LOOKUP(bgp_status_msg, peer->status)); |
b05a1c8b | 6638 | |
f1aa5d8a | 6639 | if (peer->conf_if) |
62d6dca0 | 6640 | json_object_string_add(json_peer, "idType", "interface"); |
f1aa5d8a | 6641 | else if (peer->su.sa.sa_family == AF_INET) |
62d6dca0 | 6642 | json_object_string_add(json_peer, "idType", "ipv4"); |
f1aa5d8a | 6643 | else if (peer->su.sa.sa_family == AF_INET6) |
62d6dca0 | 6644 | json_object_string_add(json_peer, "idType", "ipv6"); |
b05a1c8b | 6645 | |
f1aa5d8a | 6646 | json_object_object_add(json_peers, peer->host, json_peer); |
b05a1c8b DS |
6647 | } |
6648 | else | |
6649 | { | |
6650 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
6651 | if (peer_dynamic_neighbor(peer)) | |
6652 | { | |
6653 | dn_count++; | |
6654 | dn_flag[0] = '*'; | |
6655 | } | |
6656 | ||
04b6bdc0 DW |
6657 | if (peer->hostname && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) |
6658 | len = vty_out (vty, "%s%s(%s)", dn_flag, peer->hostname, | |
6659 | peer->host); | |
6660 | else | |
6661 | len = vty_out (vty, "%s%s", dn_flag, peer->host); | |
b05a1c8b | 6662 | |
f933309e DW |
6663 | /* pad the neighbor column with spaces */ |
6664 | if (len < max_neighbor_width) | |
6665 | vty_out (vty, "%*s", max_neighbor_width - len, " "); | |
b05a1c8b | 6666 | |
f933309e | 6667 | vty_out (vty, "4 %10u %7d %7d %8" PRIu64 " %4d %4zd %8s", |
b05a1c8b DS |
6668 | peer->as, |
6669 | peer->open_in + peer->update_in + peer->keepalive_in | |
6670 | + peer->notify_in + peer->refresh_in | |
6671 | + peer->dynamic_cap_in, | |
6672 | peer->open_out + peer->update_out + peer->keepalive_out | |
6673 | + peer->notify_out + peer->refresh_out | |
6674 | + peer->dynamic_cap_out, | |
6675 | peer->version[afi][safi], | |
6676 | 0, | |
f933309e | 6677 | peer->obuf->count, |
856ca177 | 6678 | peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL)); |
b05a1c8b DS |
6679 | |
6680 | if (peer->status == Established) | |
46f8c104 | 6681 | vty_out (vty, " %12ld", peer->pcount[afi][safi]); |
b05a1c8b DS |
6682 | else |
6683 | { | |
6684 | if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) | |
6685 | vty_out (vty, " Idle (Admin)"); | |
6686 | else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) | |
6687 | vty_out (vty, " Idle (PfxCt)"); | |
6688 | else | |
f933309e | 6689 | vty_out (vty, " %12s", LOOKUP(bgp_status_msg, peer->status)); |
b05a1c8b DS |
6690 | } |
6691 | vty_out (vty, "%s", VTY_NEWLINE); | |
6692 | } | |
718e3744 | 6693 | } |
6694 | } | |
6695 | ||
b05a1c8b DS |
6696 | if (use_json) |
6697 | { | |
6698 | json_object_object_add(json, "peers", json_peers); | |
14151a32 | 6699 | |
62d6dca0 DS |
6700 | json_object_int_add(json, "totalPeers", count); |
6701 | json_object_int_add(json, "dynamicPeers", dn_count); | |
14151a32 | 6702 | |
2aac5767 | 6703 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
f1aa5d8a | 6704 | json_object_free(json); |
b05a1c8b DS |
6705 | } |
6706 | else | |
f14e6fdb | 6707 | { |
b05a1c8b DS |
6708 | if (count) |
6709 | vty_out (vty, "%sTotal number of neighbors %d%s", VTY_NEWLINE, | |
6710 | count, VTY_NEWLINE); | |
6711 | else | |
9f689658 DD |
6712 | { |
6713 | if (use_json) | |
6714 | vty_out(vty, "{\"error\": {\"message\": \"No %s neighbor configured\"}}%s", | |
46f296b4 | 6715 | afi_safi_print(afi, safi), VTY_NEWLINE); |
9f689658 DD |
6716 | else |
6717 | vty_out (vty, "No %s neighbor is configured%s", | |
46f296b4 | 6718 | afi_safi_print(afi, safi), VTY_NEWLINE); |
9f689658 | 6719 | } |
b05a1c8b | 6720 | |
9f689658 | 6721 | if (dn_count && ! use_json) |
b05a1c8b DS |
6722 | { |
6723 | vty_out(vty, "* - dynamic neighbor%s", VTY_NEWLINE); | |
6724 | vty_out(vty, | |
6725 | "%d dynamic neighbor(s), limit %d%s", | |
6726 | dn_count, bgp->dynamic_neighbors_limit, VTY_NEWLINE); | |
6727 | } | |
f14e6fdb DS |
6728 | } |
6729 | ||
718e3744 | 6730 | return CMD_SUCCESS; |
6731 | } | |
6732 | ||
798c3572 DS |
6733 | /* |
6734 | * Return if we have a peer configured to use this afi/safi | |
6735 | */ | |
6736 | static int | |
6737 | bgp_show_summary_afi_safi_peer_exists (struct bgp *bgp, int afi, int safi) | |
6738 | { | |
6739 | struct listnode *node; | |
6740 | struct peer *peer; | |
6741 | ||
6742 | for (ALL_LIST_ELEMENTS_RO (bgp->peer, node, peer)) | |
6743 | { | |
6744 | if (!CHECK_FLAG (peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6745 | continue; | |
6746 | ||
6747 | if (peer->afc[afi][safi]) | |
6748 | return 1; | |
6749 | } | |
6750 | ||
6751 | return 0; | |
6752 | } | |
6753 | ||
27162734 LB |
6754 | static void |
6755 | bgp_show_summary_afi_safi (struct vty *vty, struct bgp *bgp, int afi, int safi, | |
6756 | u_char use_json, json_object *json) | |
6757 | { | |
6758 | int is_first = 1; | |
6759 | int afi_wildcard = (afi == AFI_MAX); | |
6760 | int safi_wildcard = (safi == SAFI_MAX); | |
6761 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
798c3572 | 6762 | |
27162734 LB |
6763 | if (use_json && is_wildcard) |
6764 | vty_out (vty, "{%s", VTY_NEWLINE); | |
6765 | if (afi_wildcard) | |
6766 | afi = 1; /* AFI_IP */ | |
6767 | while (afi < AFI_MAX) | |
6768 | { | |
6769 | if (safi_wildcard) | |
6770 | safi = 1; /* SAFI_UNICAST */ | |
6771 | while (safi < SAFI_MAX) | |
6772 | { | |
798c3572 | 6773 | if (bgp_show_summary_afi_safi_peer_exists (bgp, afi, safi)) |
27162734 | 6774 | { |
798c3572 | 6775 | if (is_wildcard) |
27162734 | 6776 | { |
798c3572 DS |
6777 | /* |
6778 | * So limit output to those afi/safi pairs that | |
6779 | * actualy have something interesting in them | |
6780 | */ | |
6781 | if (use_json) | |
6782 | { | |
6783 | json = json_object_new_object(); | |
27162734 | 6784 | |
798c3572 DS |
6785 | if (! is_first) |
6786 | vty_out (vty, ",%s", VTY_NEWLINE); | |
6787 | else | |
6788 | is_first = 0; | |
27162734 | 6789 | |
798c3572 DS |
6790 | vty_out(vty, "\"%s\":", afi_safi_json(afi, safi)); |
6791 | } | |
6792 | else | |
6793 | { | |
6794 | vty_out (vty, "%s%s Summary:%s", | |
6795 | VTY_NEWLINE, afi_safi_print(afi, safi), VTY_NEWLINE); | |
6796 | } | |
27162734 | 6797 | } |
798c3572 | 6798 | bgp_show_summary (vty, bgp, afi, safi, use_json, json); |
27162734 | 6799 | } |
f62a5c33 LB |
6800 | safi++; |
6801 | if (safi == SAFI_RESERVED_4 || | |
6802 | safi == SAFI_RESERVED_5) /* handle special cases to match zebra.h */ | |
6803 | safi++; | |
27162734 LB |
6804 | if (! safi_wildcard) |
6805 | safi = SAFI_MAX; | |
6806 | } | |
6807 | afi++; | |
6808 | if (! afi_wildcard || | |
5ef6cd69 | 6809 | afi == AFI_L2VPN) /* special case, not handled yet */ |
27162734 LB |
6810 | afi = AFI_MAX; |
6811 | } | |
6812 | ||
6813 | if (use_json && is_wildcard) | |
6814 | vty_out (vty, "}%s", VTY_NEWLINE); | |
6815 | ||
6816 | } | |
6817 | ||
f186de26 | 6818 | static void |
6819 | bgp_show_all_instances_summary_vty (struct vty *vty, afi_t afi, safi_t safi, | |
6820 | u_char use_json) | |
6821 | { | |
6822 | struct listnode *node, *nnode; | |
6823 | struct bgp *bgp; | |
9f689658 DD |
6824 | json_object *json = NULL; |
6825 | int is_first = 1; | |
6826 | ||
6827 | if (use_json) | |
6828 | vty_out (vty, "{%s", VTY_NEWLINE); | |
f186de26 | 6829 | |
6830 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) | |
6831 | { | |
9f689658 DD |
6832 | if (use_json) |
6833 | { | |
4fb25c53 | 6834 | json = json_object_new_object(); |
9f689658 DD |
6835 | |
6836 | if (! is_first) | |
6837 | vty_out (vty, ",%s", VTY_NEWLINE); | |
6838 | else | |
6839 | is_first = 0; | |
6840 | ||
6841 | vty_out(vty, "\"%s\":", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
6842 | ? "Default" : bgp->name); | |
6843 | } | |
6844 | else | |
6845 | { | |
6846 | vty_out (vty, "%sInstance %s:%s", | |
6847 | VTY_NEWLINE, | |
6848 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
6849 | ? "Default" : bgp->name, VTY_NEWLINE); | |
6850 | } | |
27162734 | 6851 | bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, json); |
f186de26 | 6852 | } |
9f689658 DD |
6853 | |
6854 | if (use_json) | |
6855 | vty_out (vty, "}%s", VTY_NEWLINE); | |
6856 | ||
f186de26 | 6857 | } |
6858 | ||
4fb25c53 DW |
6859 | static int |
6860 | bgp_show_summary_vty (struct vty *vty, const char *name, | |
6861 | afi_t afi, safi_t safi, u_char use_json) | |
6862 | { | |
6863 | struct bgp *bgp; | |
6864 | ||
6865 | if (name) | |
6866 | { | |
6867 | if (strmatch(name, "all")) | |
6868 | { | |
6869 | bgp_show_all_instances_summary_vty (vty, afi, safi, use_json); | |
6870 | return CMD_SUCCESS; | |
6871 | } | |
6872 | else | |
6873 | { | |
6874 | bgp = bgp_lookup_by_name (name); | |
6875 | ||
6876 | if (! bgp) | |
6877 | { | |
6878 | if (use_json) | |
6879 | vty_out (vty, "{}%s", VTY_NEWLINE); | |
6880 | else | |
6881 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
6882 | return CMD_WARNING; | |
6883 | } | |
6884 | ||
27162734 | 6885 | bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, NULL); |
4fb25c53 DW |
6886 | return CMD_SUCCESS; |
6887 | } | |
6888 | } | |
6889 | ||
6890 | bgp = bgp_get_default (); | |
6891 | ||
6892 | if (bgp) | |
27162734 | 6893 | bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, NULL); |
4fb25c53 DW |
6894 | |
6895 | return CMD_SUCCESS; | |
6896 | } | |
6897 | ||
716b2d8a | 6898 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 6899 | DEFUN (show_ip_bgp_summary, |
718e3744 | 6900 | show_ip_bgp_summary_cmd, |
46f296b4 | 6901 | "show [ip] bgp [<view|vrf> WORD] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] summary [json]", |
718e3744 | 6902 | SHOW_STR |
6903 | IP_STR | |
6904 | BGP_STR | |
8386ac43 | 6905 | BGP_INSTANCE_HELP_STR |
46f296b4 LB |
6906 | BGP_AFI_HELP_STR |
6907 | BGP_SAFI_HELP_STR | |
b05a1c8b | 6908 | "Summary of BGP neighbor status\n" |
9973d184 | 6909 | JSON_STR) |
718e3744 | 6910 | { |
74ca3d33 | 6911 | char *vrf = NULL; |
27162734 LB |
6912 | afi_t afi = AFI_MAX; |
6913 | safi_t safi = SAFI_MAX; | |
ae19d7dd QY |
6914 | |
6915 | int idx = 0; | |
6916 | ||
6917 | /* show [ip] bgp */ | |
6918 | if (argv_find (argv, argc, "ip", &idx)) | |
6919 | afi = AFI_IP; | |
6920 | /* [<view|vrf> WORD] */ | |
6921 | if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) | |
6922 | vrf = argv[++idx]->arg; | |
46f296b4 LB |
6923 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
6924 | if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) | |
ae19d7dd | 6925 | { |
46f296b4 | 6926 | argv_find_and_parse_safi (argv, argc, &idx, &safi); |
91d37724 QY |
6927 | } |
6928 | ||
ae19d7dd | 6929 | int uj = use_json (argc, argv); |
74ca3d33 DW |
6930 | |
6931 | return bgp_show_summary_vty (vty, vrf, afi, safi, uj); | |
718e3744 | 6932 | } |
6933 | ||
fd79ac91 | 6934 | const char * |
538621f2 | 6935 | afi_safi_print (afi_t afi, safi_t safi) |
6936 | { | |
6937 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
6938 | return "IPv4 Unicast"; | |
6939 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
6940 | return "IPv4 Multicast"; | |
b60f5275 DS |
6941 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) |
6942 | return "IPv4 labeled-unicast"; | |
538621f2 | 6943 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) |
46f296b4 | 6944 | return "IPv4 VPN"; |
8b1fb8be | 6945 | else if (afi == AFI_IP && safi == SAFI_ENCAP) |
46f296b4 | 6946 | return "IPv4 Encap"; |
538621f2 | 6947 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
6948 | return "IPv6 Unicast"; | |
6949 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
6950 | return "IPv6 Multicast"; | |
b60f5275 DS |
6951 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) |
6952 | return "IPv6 labeled-unicast"; | |
945c8fe9 | 6953 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) |
46f296b4 | 6954 | return "IPv6 VPN"; |
8b1fb8be | 6955 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) |
46f296b4 | 6956 | return "IPv6 Encap"; |
3d6c0dfa PG |
6957 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) |
6958 | return "L2VPN EVPN"; | |
538621f2 | 6959 | else |
6960 | return "Unknown"; | |
6961 | } | |
6962 | ||
b9f77ec8 DS |
6963 | /* |
6964 | * Please note that we have intentionally camelCased | |
6965 | * the return strings here. So if you want | |
6966 | * to use this function, please ensure you | |
6967 | * are doing this within json output | |
6968 | */ | |
27162734 LB |
6969 | const char * |
6970 | afi_safi_json (afi_t afi, safi_t safi) | |
6971 | { | |
6972 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
b9f77ec8 | 6973 | return "ipv4Unicast"; |
27162734 | 6974 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) |
b9f77ec8 | 6975 | return "ipv4Multicast"; |
b60f5275 | 6976 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) |
05ba625a | 6977 | return "ipv4LabeledUnicast"; |
27162734 | 6978 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) |
b9f77ec8 | 6979 | return "ipv4Vpn"; |
27162734 | 6980 | else if (afi == AFI_IP && safi == SAFI_ENCAP) |
b9f77ec8 | 6981 | return "ipv4Encap"; |
27162734 | 6982 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
b9f77ec8 | 6983 | return "ipv6Unicast"; |
27162734 | 6984 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) |
b9f77ec8 | 6985 | return "ipv6Multicast"; |
b60f5275 | 6986 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) |
05ba625a | 6987 | return "ipv6LabeledUnicast"; |
27162734 | 6988 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) |
b9f77ec8 | 6989 | return "ipv6Vpn"; |
27162734 | 6990 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) |
b9f77ec8 | 6991 | return "ipv6Encap"; |
3d6c0dfa | 6992 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) |
b9f77ec8 | 6993 | return "l2VpnEvpn"; |
27162734 LB |
6994 | else |
6995 | return "Unknown"; | |
6996 | } | |
6997 | ||
718e3744 | 6998 | /* Show BGP peer's information. */ |
6999 | enum show_type | |
7000 | { | |
7001 | show_all, | |
7002 | show_peer | |
7003 | }; | |
7004 | ||
94f2b392 | 7005 | static void |
856ca177 MS |
7006 | bgp_show_peer_afi_orf_cap (struct vty *vty, struct peer *p, afi_t afi, safi_t safi, |
7007 | u_int16_t adv_smcap, u_int16_t adv_rmcap, u_int16_t rcv_smcap, | |
7008 | u_int16_t rcv_rmcap, u_char use_json, json_object *json_pref) | |
718e3744 | 7009 | { |
7010 | /* Send-Mode */ | |
7011 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) | |
7012 | || CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
7013 | { | |
856ca177 MS |
7014 | if (use_json) |
7015 | { | |
7016 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
7017 | json_object_string_add(json_pref, "sendMode", "advertisedAndReceived"); | |
7018 | else if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)) | |
7019 | json_object_string_add(json_pref, "sendMode", "advertised"); | |
7020 | else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
7021 | json_object_string_add(json_pref, "sendMode", "received"); | |
7022 | } | |
7023 | else | |
7024 | { | |
7025 | vty_out (vty, " Send-mode: "); | |
7026 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)) | |
7027 | vty_out (vty, "advertised"); | |
7028 | if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
7029 | vty_out (vty, "%sreceived", | |
7030 | CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) ? | |
7031 | ", " : ""); | |
7032 | vty_out (vty, "%s", VTY_NEWLINE); | |
7033 | } | |
718e3744 | 7034 | } |
7035 | ||
7036 | /* Receive-Mode */ | |
7037 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) | |
7038 | || CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
7039 | { | |
856ca177 MS |
7040 | if (use_json) |
7041 | { | |
7042 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
7043 | json_object_string_add(json_pref, "recvMode", "advertisedAndReceived"); | |
7044 | else if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)) | |
7045 | json_object_string_add(json_pref, "recvMode", "advertised"); | |
7046 | else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
7047 | json_object_string_add(json_pref, "recvMode", "received"); | |
7048 | } | |
7049 | else | |
7050 | { | |
7051 | vty_out (vty, " Receive-mode: "); | |
7052 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)) | |
7053 | vty_out (vty, "advertised"); | |
7054 | if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
7055 | vty_out (vty, "%sreceived", | |
7056 | CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) ? | |
7057 | ", " : ""); | |
7058 | vty_out (vty, "%s", VTY_NEWLINE); | |
7059 | } | |
718e3744 | 7060 | } |
7061 | } | |
7062 | ||
94f2b392 | 7063 | static void |
856ca177 MS |
7064 | bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi, |
7065 | u_char use_json, json_object *json_neigh) | |
718e3744 | 7066 | { |
7067 | struct bgp_filter *filter; | |
3f9c7369 | 7068 | struct peer_af *paf; |
718e3744 | 7069 | char orf_pfx_name[BUFSIZ]; |
7070 | int orf_pfx_count; | |
856ca177 MS |
7071 | json_object *json_af = NULL; |
7072 | json_object *json_prefA = NULL; | |
7073 | json_object *json_prefB = NULL; | |
7074 | json_object *json_addr = NULL; | |
718e3744 | 7075 | |
856ca177 MS |
7076 | if (use_json) |
7077 | { | |
7078 | json_addr = json_object_new_object(); | |
7079 | json_af = json_object_new_object(); | |
856ca177 | 7080 | filter = &p->filter[afi][safi]; |
718e3744 | 7081 | |
c8560b44 | 7082 | if (peer_group_active(p)) |
856ca177 | 7083 | json_object_string_add(json_addr, "peerGroupMember", p->group->name); |
538621f2 | 7084 | |
856ca177 MS |
7085 | paf = peer_af_find(p, afi, safi); |
7086 | if (paf && PAF_SUBGRP(paf)) | |
7087 | { | |
7088 | json_object_int_add(json_addr, "updateGroupId", PAF_UPDGRP(paf)->id); | |
7089 | json_object_int_add(json_addr, "subGroupId", PAF_SUBGRP(paf)->id); | |
7090 | json_object_int_add(json_addr, "packetQueueLength", bpacket_queue_virtual_length(paf)); | |
7091 | } | |
7092 | ||
7093 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7094 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
7095 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7096 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)) | |
7097 | { | |
7098 | json_object_int_add(json_af, "orfType", ORF_TYPE_PREFIX); | |
b6df4090 | 7099 | json_prefA = json_object_new_object(); |
856ca177 MS |
7100 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, |
7101 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
7102 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7103 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
7104 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, json_prefA); | |
7105 | json_object_object_add(json_af, "orfPrefixList", json_prefA); | |
7106 | } | |
7107 | ||
7108 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7109 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7110 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7111 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7112 | { | |
7113 | json_object_int_add(json_af, "orfOldType", ORF_TYPE_PREFIX_OLD); | |
b6df4090 | 7114 | json_prefB = json_object_new_object(); |
856ca177 MS |
7115 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, |
7116 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
7117 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7118 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
7119 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, json_prefB); | |
7120 | json_object_object_add(json_af, "orfOldPrefixList", json_prefB); | |
7121 | } | |
7122 | ||
7123 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7124 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
7125 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7126 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7127 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV) | |
7128 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7129 | json_object_object_add(json_addr, "afDependentCap", json_af); | |
b6df4090 DS |
7130 | else |
7131 | json_object_free(json_af); | |
856ca177 MS |
7132 | |
7133 | sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
7134 | orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json); | |
7135 | ||
7136 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND) | |
7137 | || orf_pfx_count) | |
7138 | { | |
7139 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)) | |
7140 | json_object_boolean_true_add(json_neigh, "orfSent"); | |
7141 | if (orf_pfx_count) | |
7142 | json_object_int_add(json_addr, "orfRecvCounter", orf_pfx_count); | |
7143 | } | |
7144 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) | |
7145 | json_object_string_add(json_addr, "orfFirstUpdate", "deferredUntilORFOrRouteRefreshRecvd"); | |
7146 | ||
7147 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) | |
7148 | json_object_boolean_true_add(json_addr, "routeReflectorClient"); | |
7149 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
7150 | json_object_boolean_true_add(json_addr, "routeServerClient"); | |
7151 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
7152 | json_object_boolean_true_add(json_addr, "inboundSoftConfigPermit"); | |
7153 | ||
88b8ed8d DW |
7154 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) |
7155 | json_object_boolean_true_add(json_addr, "privateAsNumsAllReplacedInUpdatesToNbr"); | |
7156 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
856ca177 | 7157 | json_object_boolean_true_add(json_addr, "privateAsNumsReplacedInUpdatesToNbr"); |
88b8ed8d DW |
7158 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) |
7159 | json_object_boolean_true_add(json_addr, "privateAsNumsAllRemovedInUpdatesToNbr"); | |
856ca177 MS |
7160 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS)) |
7161 | json_object_boolean_true_add(json_addr, "privateAsNumsRemovedInUpdatesToNbr"); | |
7162 | ||
adbac85e DW |
7163 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS)) |
7164 | json_object_boolean_true_add(json_addr, "addpathTxAllPaths"); | |
7165 | ||
06370dac DW |
7166 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) |
7167 | json_object_boolean_true_add(json_addr, "addpathTxBestpathPerAS"); | |
7168 | ||
856ca177 MS |
7169 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) |
7170 | json_object_string_add(json_addr, "overrideASNsInOutboundUpdates", "ifAspathEqualRemoteAs"); | |
7171 | ||
7172 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) || | |
7173 | CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
7174 | json_object_boolean_true_add(json_addr, "routerAlwaysNextHop"); | |
7175 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED)) | |
7176 | json_object_boolean_true_add(json_addr, "unchangedAsPathPropogatedToNbr"); | |
7177 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)) | |
7178 | json_object_boolean_true_add(json_addr, "unchangedNextHopPropogatedToNbr"); | |
7179 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
7180 | json_object_boolean_true_add(json_addr, "unchangedMedPropogatedToNbr"); | |
718e3744 | 7181 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) |
856ca177 MS |
7182 | || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) |
7183 | { | |
7184 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
7185 | && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7186 | json_object_string_add(json_addr, "commAttriSentToNbr", "extendedAndStandard"); | |
7187 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7188 | json_object_string_add(json_addr, "commAttriSentToNbr", "extended"); | |
7189 | else | |
7190 | json_object_string_add(json_addr, "commAttriSentToNbr", "standard"); | |
7191 | } | |
7192 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) | |
7193 | { | |
7194 | if (p->default_rmap[afi][safi].name) | |
7195 | json_object_string_add(json_addr, "defaultRouteMap", p->default_rmap[afi][safi].name); | |
7196 | ||
7197 | if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
7198 | json_object_boolean_true_add(json_addr, "defaultSent"); | |
7199 | else | |
7200 | json_object_boolean_true_add(json_addr, "defaultNotSent"); | |
7201 | } | |
7202 | ||
7203 | if (filter->plist[FILTER_IN].name | |
7204 | || filter->dlist[FILTER_IN].name | |
7205 | || filter->aslist[FILTER_IN].name | |
7206 | || filter->map[RMAP_IN].name) | |
7207 | json_object_boolean_true_add(json_addr, "inboundPathPolicyConfig"); | |
7208 | if (filter->plist[FILTER_OUT].name | |
7209 | || filter->dlist[FILTER_OUT].name | |
7210 | || filter->aslist[FILTER_OUT].name | |
7211 | || filter->map[RMAP_OUT].name | |
7212 | || filter->usmap.name) | |
7213 | json_object_boolean_true_add(json_addr, "outboundPathPolicyConfig"); | |
856ca177 MS |
7214 | |
7215 | /* prefix-list */ | |
7216 | if (filter->plist[FILTER_IN].name) | |
7217 | json_object_string_add(json_addr, "incomingUpdatePrefixFilterList", filter->plist[FILTER_IN].name); | |
7218 | if (filter->plist[FILTER_OUT].name) | |
7219 | json_object_string_add(json_addr, "outgoingUpdatePrefixFilterList", filter->plist[FILTER_OUT].name); | |
7220 | ||
7221 | /* distribute-list */ | |
7222 | if (filter->dlist[FILTER_IN].name) | |
7223 | json_object_string_add(json_addr, "incomingUpdateNetworkFilterList", filter->dlist[FILTER_IN].name); | |
7224 | if (filter->dlist[FILTER_OUT].name) | |
7225 | json_object_string_add(json_addr, "outgoingUpdateNetworkFilterList", filter->dlist[FILTER_OUT].name); | |
7226 | ||
7227 | /* filter-list. */ | |
7228 | if (filter->aslist[FILTER_IN].name) | |
7229 | json_object_string_add(json_addr, "incomingUpdateAsPathFilterList", filter->aslist[FILTER_IN].name); | |
7230 | if (filter->aslist[FILTER_OUT].name) | |
7231 | json_object_string_add(json_addr, "outgoingUpdateAsPathFilterList", filter->aslist[FILTER_OUT].name); | |
7232 | ||
7233 | /* route-map. */ | |
7234 | if (filter->map[RMAP_IN].name) | |
7235 | json_object_string_add(json_addr, "routeMapForIncomingAdvertisements", filter->map[RMAP_IN].name); | |
7236 | if (filter->map[RMAP_OUT].name) | |
7237 | json_object_string_add(json_addr, "routeMapForOutgoingAdvertisements", filter->map[RMAP_OUT].name); | |
856ca177 MS |
7238 | |
7239 | /* unsuppress-map */ | |
7240 | if (filter->usmap.name) | |
7241 | json_object_string_add(json_addr, "selectiveUnsuppressRouteMap", filter->usmap.name); | |
7242 | ||
7243 | /* Receive prefix count */ | |
7244 | json_object_int_add(json_addr, "acceptedPrefixCounter", p->pcount[afi][safi]); | |
7245 | ||
7246 | /* Maximum prefix */ | |
7247 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) | |
7248 | { | |
7249 | json_object_int_add(json_addr, "prefixAllowedMax", p->pmax[afi][safi]); | |
7250 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) | |
7251 | json_object_boolean_true_add(json_addr, "prefixAllowedMaxWarning"); | |
7252 | json_object_int_add(json_addr, "prefixAllowedWarningThresh", p->pmax_threshold[afi][safi]); | |
7253 | if (p->pmax_restart[afi][safi]) | |
7254 | json_object_int_add(json_addr, "prefixAllowedRestartIntervalMsecs", p->pmax_restart[afi][safi] * 60000); | |
7255 | } | |
7256 | json_object_object_add(json_neigh, afi_safi_print (afi, safi), json_addr); | |
7257 | ||
7258 | } | |
7259 | else | |
7260 | { | |
7261 | filter = &p->filter[afi][safi]; | |
7262 | ||
7263 | vty_out (vty, " For address family: %s%s", afi_safi_print (afi, safi), | |
7264 | VTY_NEWLINE); | |
7265 | ||
c8560b44 | 7266 | if (peer_group_active(p)) |
856ca177 MS |
7267 | vty_out (vty, " %s peer-group member%s", p->group->name, VTY_NEWLINE); |
7268 | ||
7269 | paf = peer_af_find(p, afi, safi); | |
7270 | if (paf && PAF_SUBGRP(paf)) | |
7271 | { | |
7272 | vty_out (vty, " Update group %" PRIu64 ", subgroup %" PRIu64 "%s", | |
7273 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id, VTY_NEWLINE); | |
7274 | vty_out (vty, " Packet Queue length %d%s", | |
7275 | bpacket_queue_virtual_length(paf), VTY_NEWLINE); | |
7276 | } | |
718e3744 | 7277 | else |
856ca177 MS |
7278 | { |
7279 | vty_out(vty, " Not part of any update group%s", VTY_NEWLINE); | |
7280 | } | |
7281 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7282 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
7283 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7284 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7285 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV) | |
7286 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7287 | vty_out (vty, " AF-dependant capabilities:%s", VTY_NEWLINE); | |
7288 | ||
7289 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7290 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
7291 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7292 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)) | |
7293 | { | |
7294 | vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s", | |
7295 | ORF_TYPE_PREFIX, VTY_NEWLINE); | |
7296 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, | |
7297 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
7298 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7299 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
7300 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
7301 | } | |
7302 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7303 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7304 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7305 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7306 | { | |
7307 | vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s", | |
7308 | ORF_TYPE_PREFIX_OLD, VTY_NEWLINE); | |
7309 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, | |
7310 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
7311 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7312 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
7313 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
7314 | } | |
718e3744 | 7315 | |
856ca177 MS |
7316 | sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi); |
7317 | orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json); | |
718e3744 | 7318 | |
856ca177 MS |
7319 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND) |
7320 | || orf_pfx_count) | |
7321 | { | |
7322 | vty_out (vty, " Outbound Route Filter (ORF):"); | |
7323 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)) | |
7324 | vty_out (vty, " sent;"); | |
7325 | if (orf_pfx_count) | |
7326 | vty_out (vty, " received (%d entries)", orf_pfx_count); | |
7327 | vty_out (vty, "%s", VTY_NEWLINE); | |
7328 | } | |
7329 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) | |
7330 | vty_out (vty, " First update is deferred until ORF or ROUTE-REFRESH is received%s", VTY_NEWLINE); | |
7331 | ||
7332 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) | |
7333 | vty_out (vty, " Route-Reflector Client%s", VTY_NEWLINE); | |
7334 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
7335 | vty_out (vty, " Route-Server Client%s", VTY_NEWLINE); | |
7336 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
7337 | vty_out (vty, " Inbound soft reconfiguration allowed%s", VTY_NEWLINE); | |
7338 | ||
88b8ed8d DW |
7339 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) |
7340 | vty_out (vty, " Private AS numbers (all) replaced in updates to this neighbor%s", VTY_NEWLINE); | |
7341 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
856ca177 | 7342 | vty_out (vty, " Private AS numbers replaced in updates to this neighbor%s", VTY_NEWLINE); |
88b8ed8d DW |
7343 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) |
7344 | vty_out (vty, " Private AS numbers (all) removed in updates to this neighbor%s", VTY_NEWLINE); | |
856ca177 MS |
7345 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS)) |
7346 | vty_out (vty, " Private AS numbers removed in updates to this neighbor%s", VTY_NEWLINE); | |
7347 | ||
adbac85e DW |
7348 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS)) |
7349 | vty_out (vty, " Advertise all paths via addpath%s", VTY_NEWLINE); | |
7350 | ||
06370dac DW |
7351 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) |
7352 | vty_out (vty, " Advertise bestpath per AS via addpath%s", VTY_NEWLINE); | |
7353 | ||
856ca177 MS |
7354 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) |
7355 | vty_out (vty, " Override ASNs in outbound updates if aspath equals remote-as%s", VTY_NEWLINE); | |
7356 | ||
7357 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) || | |
7358 | CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
7359 | vty_out (vty, " NEXT_HOP is always this router%s", VTY_NEWLINE); | |
7360 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED)) | |
7361 | vty_out (vty, " AS_PATH is propagated unchanged to this neighbor%s", VTY_NEWLINE); | |
7362 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)) | |
7363 | vty_out (vty, " NEXT_HOP is propagated unchanged to this neighbor%s", VTY_NEWLINE); | |
7364 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
7365 | vty_out (vty, " MED is propagated unchanged to this neighbor%s", VTY_NEWLINE); | |
7366 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
57d187bc JS |
7367 | || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY) |
7368 | || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
856ca177 MS |
7369 | { |
7370 | vty_out (vty, " Community attribute sent to this neighbor"); | |
7371 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
57d187bc JS |
7372 | && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY) |
7373 | && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
7374 | vty_out (vty, "(all)%s", VTY_NEWLINE); | |
7375 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
7376 | vty_out (vty, "(large)%s", VTY_NEWLINE); | |
856ca177 MS |
7377 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) |
7378 | vty_out (vty, "(extended)%s", VTY_NEWLINE); | |
7379 | else | |
7380 | vty_out (vty, "(standard)%s", VTY_NEWLINE); | |
7381 | } | |
7382 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) | |
7383 | { | |
7384 | vty_out (vty, " Default information originate,"); | |
7385 | ||
7386 | if (p->default_rmap[afi][safi].name) | |
7387 | vty_out (vty, " default route-map %s%s,", | |
7388 | p->default_rmap[afi][safi].map ? "*" : "", | |
7389 | p->default_rmap[afi][safi].name); | |
7390 | if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
7391 | vty_out (vty, " default sent%s", VTY_NEWLINE); | |
7392 | else | |
7393 | vty_out (vty, " default not sent%s", VTY_NEWLINE); | |
7394 | } | |
718e3744 | 7395 | |
856ca177 MS |
7396 | if (filter->plist[FILTER_IN].name |
7397 | || filter->dlist[FILTER_IN].name | |
7398 | || filter->aslist[FILTER_IN].name | |
7399 | || filter->map[RMAP_IN].name) | |
7400 | vty_out (vty, " Inbound path policy configured%s", VTY_NEWLINE); | |
7401 | if (filter->plist[FILTER_OUT].name | |
7402 | || filter->dlist[FILTER_OUT].name | |
7403 | || filter->aslist[FILTER_OUT].name | |
7404 | || filter->map[RMAP_OUT].name | |
7405 | || filter->usmap.name) | |
7406 | vty_out (vty, " Outbound path policy configured%s", VTY_NEWLINE); | |
856ca177 MS |
7407 | |
7408 | /* prefix-list */ | |
7409 | if (filter->plist[FILTER_IN].name) | |
7410 | vty_out (vty, " Incoming update prefix filter list is %s%s%s", | |
7411 | filter->plist[FILTER_IN].plist ? "*" : "", | |
7412 | filter->plist[FILTER_IN].name, | |
7413 | VTY_NEWLINE); | |
7414 | if (filter->plist[FILTER_OUT].name) | |
7415 | vty_out (vty, " Outgoing update prefix filter list is %s%s%s", | |
7416 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
7417 | filter->plist[FILTER_OUT].name, | |
7418 | VTY_NEWLINE); | |
7419 | ||
7420 | /* distribute-list */ | |
7421 | if (filter->dlist[FILTER_IN].name) | |
7422 | vty_out (vty, " Incoming update network filter list is %s%s%s", | |
7423 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
7424 | filter->dlist[FILTER_IN].name, | |
7425 | VTY_NEWLINE); | |
7426 | if (filter->dlist[FILTER_OUT].name) | |
7427 | vty_out (vty, " Outgoing update network filter list is %s%s%s", | |
7428 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
7429 | filter->dlist[FILTER_OUT].name, | |
7430 | VTY_NEWLINE); | |
7431 | ||
7432 | /* filter-list. */ | |
7433 | if (filter->aslist[FILTER_IN].name) | |
7434 | vty_out (vty, " Incoming update AS path filter list is %s%s%s", | |
7435 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
7436 | filter->aslist[FILTER_IN].name, | |
7437 | VTY_NEWLINE); | |
7438 | if (filter->aslist[FILTER_OUT].name) | |
7439 | vty_out (vty, " Outgoing update AS path filter list is %s%s%s", | |
7440 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
7441 | filter->aslist[FILTER_OUT].name, | |
7442 | VTY_NEWLINE); | |
7443 | ||
7444 | /* route-map. */ | |
7445 | if (filter->map[RMAP_IN].name) | |
7446 | vty_out (vty, " Route map for incoming advertisements is %s%s%s", | |
7447 | filter->map[RMAP_IN].map ? "*" : "", | |
7448 | filter->map[RMAP_IN].name, | |
7449 | VTY_NEWLINE); | |
7450 | if (filter->map[RMAP_OUT].name) | |
7451 | vty_out (vty, " Route map for outgoing advertisements is %s%s%s", | |
7452 | filter->map[RMAP_OUT].map ? "*" : "", | |
7453 | filter->map[RMAP_OUT].name, | |
7454 | VTY_NEWLINE); | |
856ca177 MS |
7455 | |
7456 | /* unsuppress-map */ | |
7457 | if (filter->usmap.name) | |
7458 | vty_out (vty, " Route map for selective unsuppress is %s%s%s", | |
7459 | filter->usmap.map ? "*" : "", | |
7460 | filter->usmap.name, VTY_NEWLINE); | |
7461 | ||
7462 | /* Receive prefix count */ | |
7463 | vty_out (vty, " %ld accepted prefixes%s", p->pcount[afi][safi], VTY_NEWLINE); | |
7464 | ||
7465 | /* Maximum prefix */ | |
7466 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) | |
7467 | { | |
7468 | vty_out (vty, " Maximum prefixes allowed %ld%s%s", p->pmax[afi][safi], | |
7469 | CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING) | |
7470 | ? " (warning-only)" : "", VTY_NEWLINE); | |
7471 | vty_out (vty, " Threshold for warning message %d%%", | |
7472 | p->pmax_threshold[afi][safi]); | |
7473 | if (p->pmax_restart[afi][safi]) | |
7474 | vty_out (vty, ", restart interval %d min", p->pmax_restart[afi][safi]); | |
7475 | vty_out (vty, "%s", VTY_NEWLINE); | |
7476 | } | |
718e3744 | 7477 | |
0a486e5f | 7478 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 7479 | } |
718e3744 | 7480 | } |
7481 | ||
94f2b392 | 7482 | static void |
e8f7da3a | 7483 | bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *json) |
718e3744 | 7484 | { |
7485 | struct bgp *bgp; | |
4690c7d7 | 7486 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; |
718e3744 | 7487 | char timebuf[BGP_UPTIME_LEN]; |
f14e6fdb | 7488 | char dn_flag[2]; |
3a8c7ba1 DW |
7489 | const char *subcode_str; |
7490 | const char *code_str; | |
538621f2 | 7491 | afi_t afi; |
7492 | safi_t safi; | |
d6661008 DS |
7493 | u_int16_t i; |
7494 | u_char *msg; | |
e8f7da3a | 7495 | json_object *json_neigh = NULL; |
718e3744 | 7496 | |
7497 | bgp = p->bgp; | |
7498 | ||
e8f7da3a DW |
7499 | if (use_json) |
7500 | json_neigh = json_object_new_object(); | |
7501 | ||
517cd68a DS |
7502 | memset (dn_flag, '\0', sizeof (dn_flag)); |
7503 | if (!p->conf_if && peer_dynamic_neighbor (p)) | |
7504 | dn_flag[0] = '*'; | |
7505 | ||
856ca177 | 7506 | if (!use_json) |
f14e6fdb | 7507 | { |
856ca177 MS |
7508 | if (p->conf_if) /* Configured interface name. */ |
7509 | vty_out (vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
7510 | BGP_PEER_SU_UNSPEC(p) ? "None" : | |
7511 | sockunion2str (&p->su, buf, SU_ADDRSTRLEN)); | |
7512 | else /* Configured IP address. */ | |
74ef1672 | 7513 | vty_out (vty, "BGP neighbor is %s%s, ", dn_flag, p->host); |
f14e6fdb DS |
7514 | } |
7515 | ||
856ca177 MS |
7516 | if (use_json) |
7517 | { | |
7518 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
7519 | json_object_string_add(json_neigh, "bgpNeighborAddr", "none"); | |
7520 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
7521 | json_object_string_add(json_neigh, "bgpNeighborAddr", sockunion2str (&p->su, buf, SU_ADDRSTRLEN)); | |
7522 | ||
7523 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
7524 | ||
7525 | if (p->change_local_as) | |
7526 | json_object_int_add(json_neigh, "localAs", p->change_local_as); | |
7527 | else | |
7528 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
7529 | ||
7530 | if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
7531 | json_object_boolean_true_add(json_neigh, "localAsNoPrepend"); | |
66b199b2 | 7532 | |
856ca177 MS |
7533 | if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) |
7534 | json_object_boolean_true_add(json_neigh, "localAsReplaceAs"); | |
7535 | } | |
7536 | else | |
7537 | { | |
f8cfafda DS |
7538 | if ((p->as_type == AS_SPECIFIED) || |
7539 | (p->as_type == AS_EXTERNAL) || | |
7540 | (p->as_type == AS_INTERNAL)) | |
7541 | vty_out (vty, "remote AS %u, ", p->as); | |
7542 | else | |
7543 | vty_out (vty, "remote AS Unspecified, "); | |
856ca177 MS |
7544 | vty_out (vty, "local AS %u%s%s, ", |
7545 | p->change_local_as ? p->change_local_as : p->local_as, | |
7546 | CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ? | |
7547 | " no-prepend" : "", | |
7548 | CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) ? | |
7549 | " replace-as" : ""); | |
7550 | } | |
66b199b2 DS |
7551 | /* peer type internal, external, confed-internal or confed-external */ |
7552 | if (p->as == p->local_as) | |
7553 | { | |
856ca177 MS |
7554 | if (use_json) |
7555 | { | |
7556 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
7557 | json_object_boolean_true_add(json_neigh, "nbrConfedInternalLink"); | |
7558 | else | |
7559 | json_object_boolean_true_add(json_neigh, "nbrInternalLink"); | |
7560 | } | |
66b199b2 | 7561 | else |
856ca177 MS |
7562 | { |
7563 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
7564 | vty_out (vty, "confed-internal link%s", VTY_NEWLINE); | |
7565 | else | |
7566 | vty_out (vty, "internal link%s", VTY_NEWLINE); | |
7567 | } | |
66b199b2 DS |
7568 | } |
7569 | else | |
7570 | { | |
856ca177 MS |
7571 | if (use_json) |
7572 | { | |
7573 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
7574 | json_object_boolean_true_add(json_neigh, "nbrConfedExternalLink"); | |
7575 | else | |
7576 | json_object_boolean_true_add(json_neigh, "nbrExternalLink"); | |
7577 | } | |
66b199b2 | 7578 | else |
856ca177 MS |
7579 | { |
7580 | if (bgp_confederation_peers_check(bgp, p->as)) | |
7581 | vty_out (vty, "confed-external link%s", VTY_NEWLINE); | |
7582 | else | |
7583 | vty_out (vty, "external link%s", VTY_NEWLINE); | |
7584 | } | |
66b199b2 | 7585 | } |
718e3744 | 7586 | |
7587 | /* Description. */ | |
7588 | if (p->desc) | |
856ca177 MS |
7589 | { |
7590 | if (use_json) | |
7591 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
7592 | else | |
7593 | vty_out (vty, " Description: %s%s", p->desc, VTY_NEWLINE); | |
7594 | } | |
6410e93a | 7595 | |
04b6bdc0 DW |
7596 | if (p->hostname) |
7597 | { | |
d1570739 DW |
7598 | if (use_json) |
7599 | { | |
7600 | if (p->hostname) | |
7601 | json_object_string_add(json_neigh, "hostname", p->hostname); | |
7602 | ||
7603 | if (p->domainname) | |
7604 | json_object_string_add(json_neigh, "domainname", p->domainname); | |
7605 | } | |
04b6bdc0 | 7606 | else |
d1570739 DW |
7607 | { |
7608 | if (p->domainname && (p->domainname[0] != '\0')) | |
7609 | vty_out(vty, "Hostname: %s.%s%s", p->hostname, p->domainname, | |
7610 | VTY_NEWLINE); | |
7611 | else | |
7612 | vty_out(vty, "Hostname: %s%s", p->hostname, VTY_NEWLINE); | |
7613 | } | |
7614 | ||
04b6bdc0 DW |
7615 | } |
7616 | ||
c744aa9f | 7617 | /* Peer-group */ |
718e3744 | 7618 | if (p->group) |
f14e6fdb | 7619 | { |
856ca177 MS |
7620 | if (use_json) |
7621 | { | |
7622 | json_object_string_add(json_neigh, "peerGroup", p->group->name); | |
7623 | ||
7624 | if (dn_flag[0]) | |
7625 | { | |
40ee54a7 | 7626 | struct prefix prefix, *range = NULL; |
f14e6fdb | 7627 | |
40ee54a7 TT |
7628 | sockunion2hostprefix(&(p->su), &prefix); |
7629 | range = peer_group_lookup_dynamic_neighbor_range (p->group, &prefix); | |
856ca177 MS |
7630 | |
7631 | if (range) | |
7632 | { | |
7633 | prefix2str(range, buf1, sizeof(buf1)); | |
7634 | json_object_string_add(json_neigh, "peerSubnetRangeGroup", buf1); | |
7635 | } | |
7636 | } | |
7637 | } | |
7638 | else | |
f14e6fdb | 7639 | { |
856ca177 MS |
7640 | vty_out (vty, " Member of peer-group %s for session parameters%s", |
7641 | p->group->name, VTY_NEWLINE); | |
f14e6fdb | 7642 | |
856ca177 | 7643 | if (dn_flag[0]) |
f14e6fdb | 7644 | { |
40ee54a7 | 7645 | struct prefix prefix, *range = NULL; |
856ca177 | 7646 | |
40ee54a7 TT |
7647 | sockunion2hostprefix(&(p->su), &prefix); |
7648 | range = peer_group_lookup_dynamic_neighbor_range (p->group, &prefix); | |
856ca177 MS |
7649 | |
7650 | if (range) | |
7651 | { | |
7652 | prefix2str(range, buf1, sizeof(buf1)); | |
7653 | vty_out (vty, " Belongs to the subnet range group: %s%s", buf1, VTY_NEWLINE); | |
7654 | } | |
f14e6fdb DS |
7655 | } |
7656 | } | |
7657 | } | |
718e3744 | 7658 | |
856ca177 MS |
7659 | if (use_json) |
7660 | { | |
7661 | /* Administrative shutdown. */ | |
7662 | if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN)) | |
7663 | json_object_boolean_true_add(json_neigh, "adminShutDown"); | |
718e3744 | 7664 | |
856ca177 MS |
7665 | /* BGP Version. */ |
7666 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
389e3fe0 | 7667 | json_object_string_add(json_neigh, "remoteRouterId", |
44b8cd53 | 7668 | inet_ntop (AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
718e3744 | 7669 | |
856ca177 MS |
7670 | /* Confederation */ |
7671 | if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION) && bgp_confederation_peers_check (bgp, p->as)) | |
7672 | json_object_boolean_true_add(json_neigh, "nbrCommonAdmin"); | |
7673 | ||
7674 | /* Status. */ | |
7675 | json_object_string_add(json_neigh, "bgpState", LOOKUP (bgp_status_msg, p->status)); | |
7676 | ||
7677 | if (p->status == Established) | |
7678 | { | |
7679 | time_t uptime; | |
7680 | struct tm *tm; | |
7681 | ||
7682 | uptime = bgp_clock(); | |
7683 | uptime -= p->uptime; | |
7684 | tm = gmtime(&uptime); | |
7685 | ||
7686 | json_object_int_add(json_neigh, "bgpTimerUp", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); | |
7687 | } | |
7688 | ||
7689 | else if (p->status == Active) | |
7690 | { | |
7691 | if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE)) | |
7692 | json_object_string_add(json_neigh, "bgpStateIs", "passive"); | |
7693 | else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT)) | |
7694 | json_object_string_add(json_neigh, "bgpStateIs", "passiveNSF"); | |
7695 | } | |
7696 | ||
7697 | /* read timer */ | |
7698 | time_t uptime; | |
7699 | struct tm *tm; | |
7700 | ||
7701 | uptime = bgp_clock(); | |
7702 | uptime -= p->readtime; | |
7703 | tm = gmtime(&uptime); | |
7704 | json_object_int_add(json_neigh, "bgpTimerLastRead", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); | |
7705 | ||
7706 | uptime = bgp_clock(); | |
7707 | uptime -= p->last_write; | |
7708 | tm = gmtime(&uptime); | |
39e871e6 ST |
7709 | json_object_int_add(json_neigh, "bgpTimerLastWrite", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); |
7710 | ||
7711 | uptime = bgp_clock(); | |
7712 | uptime -= p->update_time; | |
7713 | tm = gmtime(&uptime); | |
7714 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", | |
7715 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); | |
856ca177 MS |
7716 | |
7717 | /* Configured timer values. */ | |
7718 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", p->v_holdtime * 1000); | |
7719 | json_object_int_add(json_neigh, "bgpTimerKeepAliveIntervalMsecs", p->v_keepalive * 1000); | |
7720 | ||
7721 | if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER)) | |
7722 | { | |
7723 | json_object_int_add(json_neigh, "bgpTimerConfiguredHoldTimeMsecs", p->holdtime * 1000); | |
7724 | json_object_int_add(json_neigh, "bgpTimerConfiguredKeepAliveIntervalMsecs", p->keepalive * 1000); | |
7725 | } | |
93406d87 | 7726 | } |
856ca177 MS |
7727 | else |
7728 | { | |
7729 | /* Administrative shutdown. */ | |
7730 | if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN)) | |
7731 | vty_out (vty, " Administratively shut down%s", VTY_NEWLINE); | |
7732 | ||
7733 | /* BGP Version. */ | |
7734 | vty_out (vty, " BGP version 4"); | |
389e3fe0 | 7735 | vty_out (vty, ", remote router ID %s%s", |
44b8cd53 | 7736 | inet_ntop (AF_INET, &p->remote_id, buf1, sizeof(buf1)), |
856ca177 MS |
7737 | VTY_NEWLINE); |
7738 | ||
7739 | /* Confederation */ | |
7740 | if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION) | |
7741 | && bgp_confederation_peers_check (bgp, p->as)) | |
7742 | vty_out (vty, " Neighbor under common administration%s", VTY_NEWLINE); | |
e52702f2 | 7743 | |
856ca177 MS |
7744 | /* Status. */ |
7745 | vty_out (vty, " BGP state = %s", LOOKUP (bgp_status_msg, p->status)); | |
718e3744 | 7746 | |
856ca177 MS |
7747 | if (p->status == Established) |
7748 | vty_out (vty, ", up for %8s", peer_uptime (p->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL)); | |
7749 | ||
7750 | else if (p->status == Active) | |
7751 | { | |
7752 | if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE)) | |
7753 | vty_out (vty, " (passive)"); | |
7754 | else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT)) | |
7755 | vty_out (vty, " (NSF passive)"); | |
7756 | } | |
7757 | vty_out (vty, "%s", VTY_NEWLINE); | |
93406d87 | 7758 | |
856ca177 MS |
7759 | /* read timer */ |
7760 | vty_out (vty, " Last read %s", peer_uptime (p->readtime, timebuf, BGP_UPTIME_LEN, 0, NULL)); | |
7761 | vty_out (vty, ", Last write %s%s", | |
7762 | peer_uptime (p->last_write, timebuf, BGP_UPTIME_LEN, 0, NULL), VTY_NEWLINE); | |
7763 | ||
7764 | /* Configured timer values. */ | |
7765 | vty_out (vty, " Hold time is %d, keepalive interval is %d seconds%s", | |
7766 | p->v_holdtime, p->v_keepalive, VTY_NEWLINE); | |
7767 | if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER)) | |
7768 | { | |
7769 | vty_out (vty, " Configured hold time is %d", p->holdtime); | |
7770 | vty_out (vty, ", keepalive interval is %d seconds%s", | |
7771 | p->keepalive, VTY_NEWLINE); | |
7772 | } | |
7773 | } | |
718e3744 | 7774 | /* Capability. */ |
e52702f2 | 7775 | if (p->status == Established) |
718e3744 | 7776 | { |
538621f2 | 7777 | if (p->cap |
718e3744 | 7778 | || p->afc_adv[AFI_IP][SAFI_UNICAST] |
7779 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
7780 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
7781 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
718e3744 | 7782 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] |
7783 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
7784 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
7785 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
945c8fe9 LB |
7786 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] |
7787 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
8b1fb8be LB |
7788 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] |
7789 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
8b1fb8be LB |
7790 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
7791 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
718e3744 | 7792 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
7793 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) | |
7794 | { | |
856ca177 MS |
7795 | if (use_json) |
7796 | { | |
7797 | json_object *json_cap = NULL; | |
7798 | ||
7799 | json_cap = json_object_new_object(); | |
7800 | ||
7801 | /* AS4 */ | |
7802 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV) | |
7803 | || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
7804 | { | |
7805 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) && CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)) | |
7806 | json_object_string_add(json_cap, "4byteAs", "advertisedAndReceived"); | |
7807 | else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
7808 | json_object_string_add(json_cap, "4byteAs", "advertised"); | |
7809 | else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)) | |
7810 | json_object_string_add(json_cap, "4byteAs", "received"); | |
7811 | } | |
7812 | ||
7813 | /* AddPath */ | |
7814 | if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV) | |
7815 | || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV)) | |
7816 | { | |
7817 | json_object *json_add = NULL; | |
7818 | const char *print_store; | |
718e3744 | 7819 | |
856ca177 | 7820 | json_add = json_object_new_object(); |
a82478b9 | 7821 | |
856ca177 MS |
7822 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) |
7823 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7824 | { | |
7825 | json_object *json_sub = NULL; | |
7826 | json_sub = json_object_new_object(); | |
7827 | print_store = afi_safi_print (afi, safi); | |
7828 | ||
7829 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) || | |
7830 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) | |
7831 | { | |
7832 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) && CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) | |
7833 | json_object_boolean_true_add(json_sub, "txAdvertisedAndReceived"); | |
7834 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV)) | |
7835 | json_object_boolean_true_add(json_sub, "txAdvertised"); | |
7836 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) | |
7837 | json_object_boolean_true_add(json_sub, "txReceived"); | |
7838 | } | |
7839 | ||
7840 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) || | |
7841 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) | |
7842 | { | |
7843 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) && CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) | |
7844 | json_object_boolean_true_add(json_sub, "rxAdvertisedAndReceived"); | |
7845 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV)) | |
7846 | json_object_boolean_true_add(json_sub, "rxAdvertised"); | |
7847 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) | |
7848 | json_object_boolean_true_add(json_sub, "rxReceived"); | |
7849 | } | |
7850 | ||
7851 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) || | |
7852 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV) || | |
7853 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) || | |
7854 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) | |
7855 | json_object_object_add(json_add, print_store, json_sub); | |
b6df4090 DS |
7856 | else |
7857 | json_object_free(json_sub); | |
856ca177 | 7858 | } |
a82478b9 | 7859 | |
856ca177 MS |
7860 | json_object_object_add(json_cap, "addPath", json_add); |
7861 | } | |
7862 | ||
7863 | /* Dynamic */ | |
7864 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV) | |
7865 | || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
7866 | { | |
7867 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) && CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)) | |
7868 | json_object_string_add(json_cap, "dynamic", "advertisedAndReceived"); | |
7869 | else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
7870 | json_object_string_add(json_cap, "dynamic", "advertised"); | |
7871 | else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)) | |
7872 | json_object_string_add(json_cap, "dynamic", "received"); | |
7873 | } | |
7874 | ||
7875 | /* Extended nexthop */ | |
7876 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV) | |
7877 | || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
7878 | { | |
7879 | json_object *json_nxt = NULL; | |
7880 | const char *print_store; | |
7881 | ||
856ca177 MS |
7882 | |
7883 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) && CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
7884 | json_object_string_add(json_cap, "extendedNexthop", "advertisedAndReceived"); | |
7885 | else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
7886 | json_object_string_add(json_cap, "extendedNexthop", "advertised"); | |
7887 | else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
7888 | json_object_string_add(json_cap, "extendedNexthop", "received"); | |
7889 | ||
7890 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
7891 | { | |
b6df4090 DS |
7892 | json_nxt = json_object_new_object(); |
7893 | ||
856ca177 MS |
7894 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) |
7895 | { | |
7896 | if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV)) | |
7897 | { | |
7898 | print_store = afi_safi_print (AFI_IP, safi); | |
7899 | json_object_string_add(json_nxt, print_store, "recieved"); | |
7900 | } | |
7901 | } | |
7902 | json_object_object_add(json_cap, "extendedNexthopFamililesByPeer", json_nxt); | |
7903 | } | |
7904 | } | |
7905 | ||
7906 | /* Route Refresh */ | |
7907 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) | |
7908 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) | |
7909 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
7910 | { | |
7911 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) && (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))) | |
7912 | { | |
7913 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) | |
7914 | json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOldNew"); | |
7915 | else | |
7916 | { | |
7917 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
7918 | json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOld"); | |
7919 | else | |
7920 | json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedNew"); | |
7921 | } | |
7922 | } | |
7923 | else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)) | |
7924 | json_object_string_add(json_cap, "routeRefresh", "advertised"); | |
7925 | else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
7926 | json_object_string_add(json_cap, "routeRefresh", "received"); | |
7927 | } | |
7928 | ||
7929 | /* Multiprotocol Extensions */ | |
7930 | json_object *json_multi = NULL; | |
7931 | json_multi = json_object_new_object(); | |
7932 | ||
7933 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7934 | { | |
7935 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7936 | { | |
7937 | if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi]) | |
7938 | { | |
7939 | json_object *json_exten = NULL; | |
7940 | json_exten = json_object_new_object(); | |
7941 | ||
7942 | if (p->afc_adv[afi][safi] && p->afc_recv[afi][safi]) | |
7943 | json_object_boolean_true_add(json_exten, "advertisedAndReceived"); | |
7944 | else if (p->afc_adv[afi][safi]) | |
7945 | json_object_boolean_true_add(json_exten, "advertised"); | |
7946 | else if (p->afc_recv[afi][safi]) | |
7947 | json_object_boolean_true_add(json_exten, "received"); | |
7948 | ||
7949 | json_object_object_add(json_multi, afi_safi_print (afi, safi), json_exten); | |
7950 | } | |
7951 | } | |
7952 | } | |
7953 | json_object_object_add(json_cap, "multiprotocolExtensions", json_multi); | |
7954 | ||
7955 | /* Gracefull Restart */ | |
7956 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV) | |
7957 | || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
7958 | { | |
7959 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) && CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) | |
7960 | json_object_string_add(json_cap, "gracefulRestart", "advertisedAndReceived"); | |
7961 | else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
7962 | json_object_string_add(json_cap, "gracefulRestartCapability", "advertised"); | |
7963 | else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) | |
7964 | json_object_string_add(json_cap, "gracefulRestartCapability", "received"); | |
7965 | ||
7966 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) | |
7967 | { | |
7968 | int restart_af_count = 0; | |
7969 | json_object *json_restart = NULL; | |
7970 | json_restart = json_object_new_object(); | |
7971 | ||
7972 | json_object_int_add(json_cap, "gracefulRestartRemoteTimerMsecs", p->v_gr_restart * 1000); | |
7973 | ||
7974 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7975 | { | |
7976 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7977 | { | |
7978 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV)) | |
7979 | { | |
7980 | json_object *json_sub = NULL; | |
7981 | json_sub = json_object_new_object(); | |
7982 | ||
7983 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV)) | |
7984 | json_object_boolean_true_add(json_sub, "preserved"); | |
7985 | restart_af_count++; | |
7986 | json_object_object_add(json_restart, afi_safi_print (afi, safi), json_sub); | |
7987 | } | |
7988 | } | |
7989 | } | |
7990 | if (! restart_af_count) | |
b6df4090 | 7991 | { |
856ca177 | 7992 | json_object_string_add(json_cap, "addressFamiliesByPeer", "none"); |
b6df4090 DS |
7993 | json_object_free(json_restart); |
7994 | } | |
856ca177 MS |
7995 | else |
7996 | json_object_object_add(json_cap, "addressFamiliesByPeer", json_restart); | |
7997 | } | |
7998 | } | |
7999 | json_object_object_add(json_neigh, "neighborCapabilities", json_cap); | |
8000 | } | |
8001 | else | |
8002 | { | |
8003 | vty_out (vty, " Neighbor capabilities:%s", VTY_NEWLINE); | |
8004 | ||
8005 | /* AS4 */ | |
8006 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV) | |
8007 | || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
8008 | { | |
8009 | vty_out (vty, " 4 Byte AS:"); | |
8010 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
8011 | vty_out (vty, " advertised"); | |
8012 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)) | |
8013 | vty_out (vty, " %sreceived", | |
8014 | CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) ? "and " : ""); | |
8015 | vty_out (vty, "%s", VTY_NEWLINE); | |
8016 | } | |
8017 | ||
8018 | /* AddPath */ | |
8019 | if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV) | |
8020 | || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV)) | |
8021 | { | |
8022 | vty_out (vty, " AddPath:%s", VTY_NEWLINE); | |
a82478b9 | 8023 | |
856ca177 MS |
8024 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) |
8025 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
a82478b9 | 8026 | { |
856ca177 MS |
8027 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) || |
8028 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) | |
8029 | { | |
8030 | vty_out (vty, " %s: TX ", afi_safi_print (afi, safi)); | |
a82478b9 | 8031 | |
856ca177 MS |
8032 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV)) |
8033 | vty_out (vty, "advertised %s", afi_safi_print (afi, safi)); | |
a82478b9 | 8034 | |
856ca177 MS |
8035 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) |
8036 | vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ? " and " : "" ); | |
a82478b9 | 8037 | |
856ca177 MS |
8038 | vty_out (vty, "%s", VTY_NEWLINE); |
8039 | } | |
a82478b9 | 8040 | |
856ca177 | 8041 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) || |
a82478b9 | 8042 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) |
856ca177 MS |
8043 | { |
8044 | vty_out (vty, " %s: RX ", afi_safi_print (afi, safi)); | |
a82478b9 | 8045 | |
856ca177 MS |
8046 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV)) |
8047 | vty_out (vty, "advertised %s", afi_safi_print (afi, safi)); | |
a82478b9 | 8048 | |
856ca177 MS |
8049 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) |
8050 | vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ? " and " : "" ); | |
a82478b9 | 8051 | |
856ca177 MS |
8052 | vty_out (vty, "%s", VTY_NEWLINE); |
8053 | } | |
a82478b9 | 8054 | } |
856ca177 | 8055 | } |
a82478b9 | 8056 | |
856ca177 MS |
8057 | /* Dynamic */ |
8058 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV) | |
8059 | || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
8060 | { | |
8061 | vty_out (vty, " Dynamic:"); | |
8062 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
8063 | vty_out (vty, " advertised"); | |
8064 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)) | |
8065 | vty_out (vty, " %sreceived", | |
8066 | CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) ? "and " : ""); | |
8067 | vty_out (vty, "%s", VTY_NEWLINE); | |
8068 | } | |
8069 | ||
8070 | /* Extended nexthop */ | |
8071 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV) | |
8072 | || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
8073 | { | |
8074 | vty_out (vty, " Extended nexthop:"); | |
8075 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
8076 | vty_out (vty, " advertised"); | |
8077 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
8078 | vty_out (vty, " %sreceived", | |
8079 | CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) ? "and " : ""); | |
8080 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 8081 | |
856ca177 MS |
8082 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) |
8083 | { | |
8084 | vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE); | |
8085 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8086 | if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV)) | |
8087 | vty_out (vty, " %s%s", | |
8088 | afi_safi_print (AFI_IP, safi), VTY_NEWLINE); | |
8089 | } | |
8090 | } | |
8a92a8a0 | 8091 | |
856ca177 MS |
8092 | /* Route Refresh */ |
8093 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) | |
8094 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) | |
8095 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
8096 | { | |
8097 | vty_out (vty, " Route refresh:"); | |
8098 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)) | |
8099 | vty_out (vty, " advertised"); | |
8100 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) | |
8101 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
8102 | vty_out (vty, " %sreceived(%s)", | |
8103 | CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) ? "and " : "", | |
8104 | (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) | |
8105 | && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) ? | |
8106 | "old & new" : CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) ? "old" : "new"); | |
8a92a8a0 | 8107 | |
856ca177 MS |
8108 | vty_out (vty, "%s", VTY_NEWLINE); |
8109 | } | |
718e3744 | 8110 | |
856ca177 MS |
8111 | /* Multiprotocol Extensions */ |
8112 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8113 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8114 | if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi]) | |
8115 | { | |
8c3deaae | 8116 | vty_out (vty, " Address Family %s:", afi_safi_print (afi, safi)); |
856ca177 MS |
8117 | if (p->afc_adv[afi][safi]) |
8118 | vty_out (vty, " advertised"); | |
8119 | if (p->afc_recv[afi][safi]) | |
8120 | vty_out (vty, " %sreceived", p->afc_adv[afi][safi] ? "and " : ""); | |
8121 | vty_out (vty, "%s", VTY_NEWLINE); | |
8122 | } | |
538621f2 | 8123 | |
04b6bdc0 DW |
8124 | /* Hostname capability */ |
8125 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV) || | |
8126 | CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) | |
8127 | { | |
8128 | vty_out (vty, " Hostname Capability:"); | |
8129 | if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV)) | |
8130 | vty_out (vty, " advertised"); | |
8131 | if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_RCV)) | |
8132 | vty_out (vty, " %sreceived", | |
8133 | CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV) ? "and " : ""); | |
8134 | vty_out (vty, "%s", VTY_NEWLINE); | |
8135 | } | |
8136 | ||
856ca177 MS |
8137 | /* Gracefull Restart */ |
8138 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV) | |
8139 | || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
8140 | { | |
8141 | vty_out (vty, " Graceful Restart Capabilty:"); | |
8142 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
538621f2 | 8143 | vty_out (vty, " advertised"); |
856ca177 MS |
8144 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) |
8145 | vty_out (vty, " %sreceived", | |
8146 | CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) ? "and " : ""); | |
8147 | vty_out (vty, "%s", VTY_NEWLINE); | |
538621f2 | 8148 | |
856ca177 MS |
8149 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) |
8150 | { | |
8151 | int restart_af_count = 0; | |
8152 | ||
8153 | vty_out (vty, " Remote Restart timer is %d seconds%s", | |
8154 | p->v_gr_restart, VTY_NEWLINE); | |
8155 | vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE); | |
8156 | ||
8157 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8158 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8159 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV)) | |
8160 | { | |
8161 | vty_out (vty, "%s%s(%s)", restart_af_count ? ", " : "", | |
8162 | afi_safi_print (afi, safi), | |
8163 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV) ? | |
8164 | "preserved" : "not preserved"); | |
8165 | restart_af_count++; | |
8166 | } | |
8167 | if (! restart_af_count) | |
8168 | vty_out (vty, "none"); | |
8169 | vty_out (vty, "%s", VTY_NEWLINE); | |
8170 | } | |
8171 | } | |
8172 | } | |
718e3744 | 8173 | } |
8174 | } | |
8175 | ||
93406d87 | 8176 | /* graceful restart information */ |
8177 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV) | |
8178 | || p->t_gr_restart | |
8179 | || p->t_gr_stale) | |
8180 | { | |
856ca177 MS |
8181 | json_object *json_grace = NULL; |
8182 | json_object *json_grace_send = NULL; | |
8183 | json_object *json_grace_recv = NULL; | |
93406d87 | 8184 | int eor_send_af_count = 0; |
8185 | int eor_receive_af_count = 0; | |
8186 | ||
856ca177 MS |
8187 | if (use_json) |
8188 | { | |
8189 | json_grace = json_object_new_object(); | |
8190 | json_grace_send = json_object_new_object(); | |
8191 | json_grace_recv = json_object_new_object(); | |
8192 | ||
8193 | if (p->status == Established) | |
8194 | { | |
8195 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8196 | { | |
8197 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8198 | { | |
8199 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND)) | |
8200 | { | |
8201 | json_object_boolean_true_add(json_grace_send, afi_safi_print (afi, safi)); | |
8202 | eor_send_af_count++; | |
8203 | } | |
8204 | } | |
8205 | } | |
8206 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8207 | { | |
8208 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8209 | { | |
8210 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED)) | |
8211 | { | |
8212 | json_object_boolean_true_add(json_grace_recv, afi_safi_print (afi, safi)); | |
8213 | eor_receive_af_count++; | |
8214 | } | |
8215 | } | |
8216 | } | |
8217 | } | |
8218 | ||
8219 | json_object_object_add(json_grace, "endOfRibSend", json_grace_send); | |
8220 | json_object_object_add(json_grace, "endOfRibRecv", json_grace_recv); | |
8221 | ||
8222 | if (p->t_gr_restart) | |
8223 | json_object_int_add(json_grace, "gracefulRestartTimerMsecs", thread_timer_remain_second (p->t_gr_restart) * 1000); | |
8224 | ||
8225 | if (p->t_gr_stale) | |
8226 | json_object_int_add(json_grace, "gracefulStalepathTimerMsecs", thread_timer_remain_second (p->t_gr_stale) * 1000); | |
8227 | ||
8228 | json_object_object_add(json_neigh, "gracefulRestartInfo", json_grace); | |
8229 | } | |
8230 | else | |
8231 | { | |
8232 | vty_out (vty, " Graceful restart informations:%s", VTY_NEWLINE); | |
8233 | if (p->status == Established) | |
8234 | { | |
8235 | vty_out (vty, " End-of-RIB send: "); | |
8236 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8237 | { | |
8238 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8239 | { | |
8240 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND)) | |
8241 | { | |
8242 | vty_out (vty, "%s%s", eor_send_af_count ? ", " : "", | |
8243 | afi_safi_print (afi, safi)); | |
8244 | eor_send_af_count++; | |
8245 | } | |
8246 | } | |
8247 | } | |
8248 | vty_out (vty, "%s", VTY_NEWLINE); | |
8249 | vty_out (vty, " End-of-RIB received: "); | |
8250 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8251 | { | |
8252 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8253 | { | |
8254 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED)) | |
8255 | { | |
8256 | vty_out (vty, "%s%s", eor_receive_af_count ? ", " : "", | |
8257 | afi_safi_print (afi, safi)); | |
8258 | eor_receive_af_count++; | |
8259 | } | |
8260 | } | |
8261 | } | |
8262 | vty_out (vty, "%s", VTY_NEWLINE); | |
8263 | } | |
93406d87 | 8264 | |
856ca177 MS |
8265 | if (p->t_gr_restart) |
8266 | vty_out (vty, " The remaining time of restart timer is %ld%s", | |
8267 | thread_timer_remain_second (p->t_gr_restart), VTY_NEWLINE); | |
e52702f2 | 8268 | |
856ca177 MS |
8269 | if (p->t_gr_stale) |
8270 | vty_out (vty, " The remaining time of stalepath timer is %ld%s", | |
8271 | thread_timer_remain_second (p->t_gr_stale), VTY_NEWLINE); | |
8272 | } | |
8273 | } | |
8274 | if (use_json) | |
8275 | { | |
8276 | json_object *json_stat = NULL; | |
8277 | json_stat = json_object_new_object(); | |
8278 | /* Packet counts. */ | |
8279 | json_object_int_add(json_stat, "depthInq", 0); | |
8280 | json_object_int_add(json_stat, "depthOutq", (unsigned long) p->obuf->count); | |
8281 | json_object_int_add(json_stat, "opensSent", p->open_out); | |
8282 | json_object_int_add(json_stat, "opensRecv", p->open_in); | |
8283 | json_object_int_add(json_stat, "notificationsSent", p->notify_out); | |
8284 | json_object_int_add(json_stat, "notificationsRecv", p->notify_in); | |
8285 | json_object_int_add(json_stat, "updatesSent", p->update_out); | |
8286 | json_object_int_add(json_stat, "updatesRecv", p->update_in); | |
8287 | json_object_int_add(json_stat, "keepalivesSent", p->keepalive_out); | |
8288 | json_object_int_add(json_stat, "keepalivesRecv", p->keepalive_in); | |
8289 | json_object_int_add(json_stat, "routeRefreshSent", p->refresh_out); | |
8290 | json_object_int_add(json_stat, "routeRefreshRecv", p->refresh_in); | |
8291 | json_object_int_add(json_stat, "capabilitySent", p->dynamic_cap_out); | |
8292 | json_object_int_add(json_stat, "capabilityRecv", p->dynamic_cap_in); | |
8293 | json_object_int_add(json_stat, "totalSent", p->open_out + p->notify_out + p->update_out + p->keepalive_out + p->refresh_out + p->dynamic_cap_out); | |
8294 | json_object_int_add(json_stat, "totalRecv", p->open_in + p->notify_in + p->update_in + p->keepalive_in + p->refresh_in + p->dynamic_cap_in); | |
8295 | json_object_object_add(json_neigh, "messageStats", json_stat); | |
8296 | } | |
8297 | else | |
8298 | { | |
8299 | /* Packet counts. */ | |
8300 | vty_out (vty, " Message statistics:%s", VTY_NEWLINE); | |
8301 | vty_out (vty, " Inq depth is 0%s", VTY_NEWLINE); | |
8302 | vty_out (vty, " Outq depth is %lu%s", (unsigned long) p->obuf->count, VTY_NEWLINE); | |
8303 | vty_out (vty, " Sent Rcvd%s", VTY_NEWLINE); | |
8304 | vty_out (vty, " Opens: %10d %10d%s", p->open_out, p->open_in, VTY_NEWLINE); | |
8305 | vty_out (vty, " Notifications: %10d %10d%s", p->notify_out, p->notify_in, VTY_NEWLINE); | |
8306 | vty_out (vty, " Updates: %10d %10d%s", p->update_out, p->update_in, VTY_NEWLINE); | |
8307 | vty_out (vty, " Keepalives: %10d %10d%s", p->keepalive_out, p->keepalive_in, VTY_NEWLINE); | |
8308 | vty_out (vty, " Route Refresh: %10d %10d%s", p->refresh_out, p->refresh_in, VTY_NEWLINE); | |
8309 | vty_out (vty, " Capability: %10d %10d%s", p->dynamic_cap_out, p->dynamic_cap_in, VTY_NEWLINE); | |
8310 | vty_out (vty, " Total: %10d %10d%s", p->open_out + p->notify_out + | |
8311 | p->update_out + p->keepalive_out + p->refresh_out + p->dynamic_cap_out, | |
8312 | p->open_in + p->notify_in + p->update_in + p->keepalive_in + p->refresh_in + | |
8313 | p->dynamic_cap_in, VTY_NEWLINE); | |
718e3744 | 8314 | } |
8315 | ||
856ca177 MS |
8316 | if (use_json) |
8317 | { | |
8318 | /* advertisement-interval */ | |
8319 | json_object_int_add(json_neigh, "minBtwnAdvertisementRunsTimerMsecs", p->v_routeadv * 1000); | |
718e3744 | 8320 | |
856ca177 MS |
8321 | /* Update-source. */ |
8322 | if (p->update_if || p->update_source) | |
8323 | { | |
8324 | if (p->update_if) | |
8325 | json_object_string_add(json_neigh, "updateSource", p->update_if); | |
8326 | else if (p->update_source) | |
8327 | json_object_string_add(json_neigh, "updateSource", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN)); | |
8328 | } | |
856ca177 MS |
8329 | } |
8330 | else | |
8331 | { | |
8332 | /* advertisement-interval */ | |
8333 | vty_out (vty, " Minimum time between advertisement runs is %d seconds%s", | |
8334 | p->v_routeadv, VTY_NEWLINE); | |
8335 | ||
8336 | /* Update-source. */ | |
8337 | if (p->update_if || p->update_source) | |
8338 | { | |
8339 | vty_out (vty, " Update source is "); | |
8340 | if (p->update_if) | |
8341 | vty_out (vty, "%s", p->update_if); | |
8342 | else if (p->update_source) | |
8343 | vty_out (vty, "%s", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN)); | |
8344 | vty_out (vty, "%s", VTY_NEWLINE); | |
8345 | } | |
8346 | ||
856ca177 MS |
8347 | vty_out (vty, "%s", VTY_NEWLINE); |
8348 | } | |
718e3744 | 8349 | |
8350 | /* Address Family Information */ | |
856ca177 MS |
8351 | json_object *json_hold = NULL; |
8352 | ||
8353 | if (use_json) | |
8354 | json_hold = json_object_new_object(); | |
8355 | ||
538621f2 | 8356 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) |
8357 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8358 | if (p->afc[afi][safi]) | |
856ca177 | 8359 | bgp_show_peer_afi (vty, p, afi, safi, use_json, json_hold); |
718e3744 | 8360 | |
856ca177 MS |
8361 | if (use_json) |
8362 | { | |
58433ae6 | 8363 | json_object_object_add(json_neigh, "addressFamilyInfo", json_hold); |
e08ac8b7 DW |
8364 | json_object_int_add(json_neigh, "connectionsEstablished", p->established); |
8365 | json_object_int_add(json_neigh, "connectionsDropped", p->dropped); | |
856ca177 MS |
8366 | } |
8367 | else | |
8368 | vty_out (vty, " Connections established %d; dropped %d%s", p->established, p->dropped, | |
8369 | VTY_NEWLINE); | |
718e3744 | 8370 | |
d6661008 | 8371 | if (! p->last_reset) |
856ca177 MS |
8372 | { |
8373 | if (use_json) | |
e08ac8b7 | 8374 | json_object_string_add(json_neigh, "lastReset", "never"); |
856ca177 MS |
8375 | else |
8376 | vty_out (vty, " Last reset never%s", VTY_NEWLINE); | |
8377 | } | |
e0701b79 | 8378 | else |
d6661008 | 8379 | { |
856ca177 MS |
8380 | if (use_json) |
8381 | { | |
8382 | time_t uptime; | |
8383 | struct tm *tm; | |
8384 | ||
8385 | uptime = bgp_clock(); | |
8386 | uptime -= p->resettime; | |
8387 | tm = gmtime(&uptime); | |
e08ac8b7 DW |
8388 | json_object_int_add(json_neigh, "lastResetTimerMsecs", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); |
8389 | json_object_string_add(json_neigh, "lastResetDueTo", peer_down_str[(int) p->last_reset]); | |
cca1dda8 DD |
8390 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND || |
8391 | p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) | |
856ca177 | 8392 | { |
39e871e6 | 8393 | char errorcodesubcode_hexstr[5]; |
cca1dda8 DD |
8394 | char errorcodesubcode_str[256]; |
8395 | ||
8396 | code_str = bgp_notify_code_str(p->notify.code); | |
8397 | subcode_str = bgp_notify_subcode_str(p->notify.code, p->notify.subcode); | |
8398 | ||
39e871e6 | 8399 | sprintf(errorcodesubcode_hexstr, "%02X%02X", p->notify.code, p->notify.subcode); |
e08ac8b7 | 8400 | json_object_string_add(json_neigh, "lastErrorCodeSubcode", errorcodesubcode_hexstr); |
cca1dda8 DD |
8401 | snprintf(errorcodesubcode_str, 255, "%s%s", code_str, subcode_str); |
8402 | json_object_string_add(json_neigh, "lastNotificationReason", errorcodesubcode_str); | |
652b9429 DS |
8403 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED |
8404 | && p->notify.code == BGP_NOTIFY_CEASE | |
8405 | && (p->notify.subcode == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
8406 | || p->notify.subcode == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
8407 | && p->notify.length) | |
8408 | { | |
8409 | char msgbuf[1024]; | |
8410 | const char *msg_str; | |
8411 | ||
8412 | msg_str = bgp_notify_admin_message(msgbuf, sizeof(msgbuf), | |
8413 | (u_char*)p->notify.data, p->notify.length); | |
8414 | if (msg_str) | |
8415 | json_object_string_add(json_neigh, "lastShutdownDescription", msg_str); | |
8416 | } | |
856ca177 MS |
8417 | } |
8418 | } | |
8419 | else | |
d6661008 | 8420 | { |
3a8c7ba1 DW |
8421 | vty_out (vty, " Last reset %s, ", |
8422 | peer_uptime (p->resettime, timebuf, BGP_UPTIME_LEN, 0, NULL)); | |
8423 | ||
8424 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND || | |
8425 | p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) | |
8426 | { | |
8427 | code_str = bgp_notify_code_str(p->notify.code); | |
8428 | subcode_str = bgp_notify_subcode_str(p->notify.code, p->notify.subcode); | |
8429 | vty_out (vty, "due to NOTIFICATION %s (%s%s)%s", | |
8430 | p->last_reset == PEER_DOWN_NOTIFY_SEND ? "sent" : "received", | |
8431 | code_str, subcode_str, VTY_NEWLINE); | |
38de8d02 DL |
8432 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED |
8433 | && p->notify.code == BGP_NOTIFY_CEASE | |
8434 | && (p->notify.subcode == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
8435 | || p->notify.subcode == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
8436 | && p->notify.length) | |
8437 | { | |
8438 | char msgbuf[1024]; | |
8439 | const char *msg_str; | |
8440 | ||
8441 | msg_str = bgp_notify_admin_message(msgbuf, sizeof(msgbuf), | |
8442 | (u_char*)p->notify.data, p->notify.length); | |
8443 | if (msg_str) | |
8444 | vty_out (vty, " Message: \"%s\"%s", msg_str, VTY_NEWLINE); | |
8445 | } | |
3a8c7ba1 DW |
8446 | } |
8447 | else | |
8448 | { | |
8449 | vty_out (vty, "due to %s%s", | |
8450 | peer_down_str[(int) p->last_reset], VTY_NEWLINE); | |
8451 | } | |
856ca177 MS |
8452 | |
8453 | if (p->last_reset_cause_size) | |
d6661008 | 8454 | { |
856ca177 MS |
8455 | msg = p->last_reset_cause; |
8456 | vty_out(vty, " Message received that caused BGP to send a NOTIFICATION:%s ", VTY_NEWLINE); | |
8457 | for (i = 1; i <= p->last_reset_cause_size; i++) | |
8458 | { | |
8459 | vty_out(vty, "%02X", *msg++); | |
d6661008 | 8460 | |
856ca177 MS |
8461 | if (i != p->last_reset_cause_size) |
8462 | { | |
8463 | if (i % 16 == 0) | |
8464 | { | |
8465 | vty_out(vty, "%s ", VTY_NEWLINE); | |
8466 | } | |
8467 | else if (i % 4 == 0) | |
8468 | { | |
8469 | vty_out(vty, " "); | |
8470 | } | |
8471 | } | |
8472 | } | |
8473 | vty_out(vty, "%s", VTY_NEWLINE); | |
d6661008 | 8474 | } |
d6661008 DS |
8475 | } |
8476 | } | |
848973c7 | 8477 | |
718e3744 | 8478 | if (CHECK_FLAG (p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) |
8479 | { | |
856ca177 | 8480 | if (use_json) |
e08ac8b7 | 8481 | json_object_boolean_true_add(json_neigh, "prefixesConfigExceedMax"); |
856ca177 MS |
8482 | else |
8483 | vty_out (vty, " Peer had exceeded the max. no. of prefixes configured.%s", VTY_NEWLINE); | |
0a486e5f | 8484 | |
8485 | if (p->t_pmax_restart) | |
856ca177 MS |
8486 | { |
8487 | if (use_json) | |
8488 | { | |
e08ac8b7 DW |
8489 | json_object_boolean_true_add(json_neigh, "reducePrefixNumFrom"); |
8490 | json_object_int_add(json_neigh, "restartInTimerMsec", thread_timer_remain_second (p->t_pmax_restart) * 1000); | |
856ca177 MS |
8491 | } |
8492 | else | |
8493 | vty_out (vty, " Reduce the no. of prefix from %s, will restart in %ld seconds%s", | |
8494 | p->host, thread_timer_remain_second (p->t_pmax_restart), | |
8495 | VTY_NEWLINE); | |
8496 | } | |
0a486e5f | 8497 | else |
856ca177 MS |
8498 | { |
8499 | if (use_json) | |
e08ac8b7 | 8500 | json_object_boolean_true_add(json_neigh, "reducePrefixNumAndClearIpBgp"); |
856ca177 MS |
8501 | else |
8502 | vty_out (vty, " Reduce the no. of prefix and clear ip bgp %s to restore peering%s", | |
8503 | p->host, VTY_NEWLINE); | |
8504 | } | |
718e3744 | 8505 | } |
8506 | ||
f5a4827d | 8507 | /* EBGP Multihop and GTSM */ |
6d85b15b | 8508 | if (p->sort != BGP_PEER_IBGP) |
f5a4827d | 8509 | { |
856ca177 MS |
8510 | if (use_json) |
8511 | { | |
8512 | if (p->gtsm_hops > 0) | |
8513 | json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->gtsm_hops); | |
8514 | else if (p->ttl > 1) | |
8515 | json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->ttl); | |
8516 | } | |
8517 | else | |
8518 | { | |
8519 | if (p->gtsm_hops > 0) | |
8520 | vty_out (vty, " External BGP neighbor may be up to %d hops away.%s", | |
8521 | p->gtsm_hops, VTY_NEWLINE); | |
8522 | else if (p->ttl > 1) | |
8523 | vty_out (vty, " External BGP neighbor may be up to %d hops away.%s", | |
8524 | p->ttl, VTY_NEWLINE); | |
8525 | } | |
f5a4827d | 8526 | } |
5d804b43 PM |
8527 | else |
8528 | { | |
8529 | if (p->gtsm_hops > 0) | |
856ca177 MS |
8530 | { |
8531 | if (use_json) | |
8532 | json_object_int_add(json_neigh, "internalBgpNbrMaxHopsAway", p->gtsm_hops); | |
8533 | else | |
8534 | vty_out (vty, " Internal BGP neighbor may be up to %d hops away.%s", | |
8535 | p->gtsm_hops, VTY_NEWLINE); | |
8536 | } | |
5d804b43 | 8537 | } |
718e3744 | 8538 | |
8539 | /* Local address. */ | |
8540 | if (p->su_local) | |
8541 | { | |
856ca177 MS |
8542 | if (use_json) |
8543 | { | |
8544 | json_object_string_add(json_neigh, "hostLocal", sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN)); | |
8545 | json_object_int_add(json_neigh, "portLocal", ntohs (p->su_local->sin.sin_port)); | |
8546 | } | |
8547 | else | |
8548 | vty_out (vty, "Local host: %s, Local port: %d%s", | |
8549 | sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN), | |
8550 | ntohs (p->su_local->sin.sin_port), | |
8551 | VTY_NEWLINE); | |
718e3744 | 8552 | } |
e52702f2 | 8553 | |
718e3744 | 8554 | /* Remote address. */ |
8555 | if (p->su_remote) | |
8556 | { | |
856ca177 MS |
8557 | if (use_json) |
8558 | { | |
8559 | json_object_string_add(json_neigh, "hostForeign", sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN)); | |
8560 | json_object_int_add(json_neigh, "portForeign", ntohs (p->su_remote->sin.sin_port)); | |
8561 | } | |
8562 | else | |
8563 | vty_out (vty, "Foreign host: %s, Foreign port: %d%s", | |
718e3744 | 8564 | sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN), |
8565 | ntohs (p->su_remote->sin.sin_port), | |
8566 | VTY_NEWLINE); | |
8567 | } | |
8568 | ||
8569 | /* Nexthop display. */ | |
8570 | if (p->su_local) | |
8571 | { | |
856ca177 MS |
8572 | if (use_json) |
8573 | { | |
389e3fe0 | 8574 | json_object_string_add(json_neigh, "nexthop", |
44b8cd53 | 8575 | inet_ntop (AF_INET, &p->nexthop.v4, buf1, sizeof(buf1))); |
389e3fe0 | 8576 | json_object_string_add(json_neigh, "nexthopGlobal", |
44b8cd53 | 8577 | inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, sizeof(buf1))); |
389e3fe0 | 8578 | json_object_string_add(json_neigh, "nexthopLocal", |
44b8cd53 | 8579 | inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, sizeof(buf1))); |
856ca177 MS |
8580 | if (p->shared_network) |
8581 | json_object_string_add(json_neigh, "bgpConnection", "sharedNetwork"); | |
8582 | else | |
8583 | json_object_string_add(json_neigh, "bgpConnection", "nonSharedNetwork"); | |
856ca177 MS |
8584 | } |
8585 | else | |
8586 | { | |
8587 | vty_out (vty, "Nexthop: %s%s", | |
44b8cd53 DL |
8588 | inet_ntop (AF_INET, &p->nexthop.v4, buf1, sizeof(buf1)), |
8589 | VTY_NEWLINE); | |
856ca177 | 8590 | vty_out (vty, "Nexthop global: %s%s", |
44b8cd53 DL |
8591 | inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, sizeof(buf1)), |
8592 | VTY_NEWLINE); | |
856ca177 | 8593 | vty_out (vty, "Nexthop local: %s%s", |
44b8cd53 DL |
8594 | inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, sizeof(buf1)), |
8595 | VTY_NEWLINE); | |
856ca177 | 8596 | vty_out (vty, "BGP connection: %s%s", |
44b8cd53 DL |
8597 | p->shared_network ? "shared network" : "non shared network", |
8598 | VTY_NEWLINE); | |
856ca177 | 8599 | } |
718e3744 | 8600 | } |
8601 | ||
8602 | /* Timer information. */ | |
856ca177 MS |
8603 | if (use_json) |
8604 | { | |
39e871e6 | 8605 | json_object_int_add(json_neigh, "connectRetryTimer", p->v_connect); |
dd9275d6 ST |
8606 | if (p->status == Established && p->rtt) |
8607 | json_object_int_add(json_neigh, "estimatedRttInMsecs", p->rtt); | |
856ca177 MS |
8608 | if (p->t_start) |
8609 | json_object_int_add(json_neigh, "nextStartTimerDueInMsecs", thread_timer_remain_second (p->t_start) * 1000); | |
8610 | if (p->t_connect) | |
8611 | json_object_int_add(json_neigh, "nextConnectTimerDueInMsecs", thread_timer_remain_second (p->t_connect) * 1000); | |
8612 | if (p->t_routeadv) | |
8613 | { | |
8614 | json_object_int_add(json_neigh, "mraiInterval", p->v_routeadv); | |
8615 | json_object_int_add(json_neigh, "mraiTimerExpireInMsecs", thread_timer_remain_second (p->t_routeadv) * 1000); | |
8616 | } | |
cb1faec9 | 8617 | |
856ca177 MS |
8618 | if (p->t_read) |
8619 | json_object_string_add(json_neigh, "readThread", "on"); | |
8620 | else | |
8621 | json_object_string_add(json_neigh, "readThread", "off"); | |
8622 | if (p->t_write) | |
8623 | json_object_string_add(json_neigh, "writeThread", "on"); | |
8624 | else | |
8625 | json_object_string_add(json_neigh, "writeThread", "off"); | |
8626 | } | |
8627 | else | |
8628 | { | |
39e871e6 ST |
8629 | vty_out (vty, "BGP Connect Retry Timer in Seconds: %d%s", |
8630 | p->v_connect, VTY_NEWLINE); | |
dd9275d6 ST |
8631 | if (p->status == Established && p->rtt) |
8632 | vty_out (vty, "Estimated round trip time: %d ms%s", | |
8633 | p->rtt, VTY_NEWLINE); | |
856ca177 MS |
8634 | if (p->t_start) |
8635 | vty_out (vty, "Next start timer due in %ld seconds%s", | |
8636 | thread_timer_remain_second (p->t_start), VTY_NEWLINE); | |
8637 | if (p->t_connect) | |
8638 | vty_out (vty, "Next connect timer due in %ld seconds%s", | |
8639 | thread_timer_remain_second (p->t_connect), VTY_NEWLINE); | |
8640 | if (p->t_routeadv) | |
8641 | vty_out (vty, "MRAI (interval %u) timer expires in %ld seconds%s", | |
8642 | p->v_routeadv, thread_timer_remain_second (p->t_routeadv), | |
8643 | VTY_NEWLINE); | |
8644 | ||
8645 | vty_out (vty, "Read thread: %s Write thread: %s%s", | |
8646 | p->t_read ? "on" : "off", | |
8647 | p->t_write ? "on" : "off", | |
8648 | VTY_NEWLINE); | |
8649 | } | |
718e3744 | 8650 | |
8651 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
8652 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
856ca177 MS |
8653 | bgp_capability_vty_out (vty, p, use_json, json_neigh); |
8654 | ||
8655 | if (!use_json) | |
8656 | vty_out (vty, "%s", VTY_NEWLINE); | |
c43ed2e4 DS |
8657 | |
8658 | /* BFD information. */ | |
856ca177 MS |
8659 | bgp_bfd_show_info(vty, p, use_json, json_neigh); |
8660 | ||
8661 | if (use_json) | |
8662 | { | |
8663 | if (p->conf_if) /* Configured interface name. */ | |
8664 | json_object_object_add(json, p->conf_if, json_neigh); | |
8665 | else /* Configured IP address. */ | |
8666 | json_object_object_add(json, p->host, json_neigh); | |
8667 | } | |
718e3744 | 8668 | } |
8669 | ||
94f2b392 | 8670 | static int |
856ca177 MS |
8671 | bgp_show_neighbor (struct vty *vty, struct bgp *bgp, enum show_type type, |
8672 | union sockunion *su, const char *conf_if, u_char use_json, json_object *json) | |
718e3744 | 8673 | { |
1eb8ef25 | 8674 | struct listnode *node, *nnode; |
718e3744 | 8675 | struct peer *peer; |
8676 | int find = 0; | |
8677 | ||
1eb8ef25 | 8678 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
718e3744 | 8679 | { |
1ff9a340 DS |
8680 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
8681 | continue; | |
8682 | ||
718e3744 | 8683 | switch (type) |
856ca177 MS |
8684 | { |
8685 | case show_all: | |
e8f7da3a | 8686 | bgp_show_peer (vty, peer, use_json, json); |
856ca177 MS |
8687 | break; |
8688 | case show_peer: | |
8689 | if (conf_if) | |
8690 | { | |
4873b3b9 DW |
8691 | if ((peer->conf_if && !strcmp(peer->conf_if, conf_if)) || |
8692 | (peer->hostname && !strcmp(peer->hostname, conf_if))) | |
856ca177 MS |
8693 | { |
8694 | find = 1; | |
e8f7da3a | 8695 | bgp_show_peer (vty, peer, use_json, json); |
856ca177 MS |
8696 | } |
8697 | } | |
8698 | else | |
8699 | { | |
8700 | if (sockunion_same (&peer->su, su)) | |
8701 | { | |
8702 | find = 1; | |
e8f7da3a | 8703 | bgp_show_peer (vty, peer, use_json, json); |
856ca177 MS |
8704 | } |
8705 | } | |
8706 | break; | |
718e3744 | 8707 | } |
8708 | } | |
8709 | ||
8710 | if (type == show_peer && ! find) | |
856ca177 MS |
8711 | { |
8712 | if (use_json) | |
8713 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
8714 | else | |
8715 | vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE); | |
8716 | } | |
8717 | ||
8718 | if (use_json) | |
8719 | { | |
2aac5767 | 8720 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
856ca177 MS |
8721 | json_object_free(json); |
8722 | } | |
8723 | else | |
8724 | { | |
8725 | vty_out (vty, "%s", VTY_NEWLINE); | |
8726 | } | |
8727 | ||
718e3744 | 8728 | return CMD_SUCCESS; |
8729 | } | |
8730 | ||
f186de26 | 8731 | static void |
8732 | bgp_show_all_instances_neighbors_vty (struct vty *vty, u_char use_json) | |
8733 | { | |
8734 | struct listnode *node, *nnode; | |
8735 | struct bgp *bgp; | |
8736 | json_object *json = NULL; | |
9f689658 DD |
8737 | int is_first = 1; |
8738 | ||
8739 | if (use_json) | |
8740 | vty_out (vty, "{%s", VTY_NEWLINE); | |
f186de26 | 8741 | |
8742 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) | |
8743 | { | |
f186de26 | 8744 | if (use_json) |
9f689658 DD |
8745 | { |
8746 | if (!(json = json_object_new_object())) | |
8747 | { | |
8748 | zlog_err("Unable to allocate memory for JSON object"); | |
8749 | vty_out (vty, | |
8750 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}%s", | |
8751 | VTY_NEWLINE); | |
8752 | return; | |
8753 | } | |
8754 | ||
8755 | json_object_int_add(json, "vrfId", | |
8756 | (bgp->vrf_id == VRF_UNKNOWN) | |
8757 | ? -1 : bgp->vrf_id); | |
8758 | json_object_string_add(json, "vrfName", | |
8759 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
8760 | ? "Default" : bgp->name); | |
8761 | ||
8762 | if (! is_first) | |
8763 | vty_out (vty, ",%s", VTY_NEWLINE); | |
8764 | else | |
8765 | is_first = 0; | |
8766 | ||
8767 | vty_out(vty, "\"%s\":", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
8768 | ? "Default" : bgp->name); | |
8769 | } | |
8770 | else | |
8771 | { | |
8772 | vty_out (vty, "%sInstance %s:%s", | |
8773 | VTY_NEWLINE, | |
8774 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
8775 | ? "Default" : bgp->name, | |
8776 | VTY_NEWLINE); | |
8777 | } | |
f186de26 | 8778 | bgp_show_neighbor (vty, bgp, show_all, NULL, NULL, use_json, json); |
8779 | } | |
9f689658 DD |
8780 | |
8781 | if (use_json) | |
8782 | vty_out (vty, "}%s", VTY_NEWLINE); | |
f186de26 | 8783 | } |
8784 | ||
4fb25c53 DW |
8785 | static int |
8786 | bgp_show_neighbor_vty (struct vty *vty, const char *name, | |
8787 | enum show_type type, const char *ip_str, u_char use_json) | |
8788 | { | |
8789 | int ret; | |
8790 | struct bgp *bgp; | |
8791 | union sockunion su; | |
8792 | json_object *json = NULL; | |
8793 | ||
8794 | if (use_json) | |
8795 | json = json_object_new_object(); | |
8796 | ||
8797 | if (name) | |
8798 | { | |
8799 | if (strmatch(name, "all")) | |
8800 | { | |
8801 | bgp_show_all_instances_neighbors_vty (vty, use_json); | |
8802 | return CMD_SUCCESS; | |
8803 | } | |
8804 | else | |
8805 | { | |
8806 | bgp = bgp_lookup_by_name (name); | |
8807 | if (! bgp) | |
8808 | { | |
8809 | if (use_json) | |
8810 | { | |
8811 | json_object_boolean_true_add(json, "bgpNoSuchInstance"); | |
e52702f2 | 8812 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
4fb25c53 DW |
8813 | json_object_free(json); |
8814 | } | |
8815 | else | |
8816 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
8817 | ||
8818 | return CMD_WARNING; | |
8819 | } | |
8820 | } | |
8821 | } | |
8822 | else | |
8823 | { | |
8824 | bgp = bgp_get_default (); | |
8825 | } | |
8826 | ||
8827 | if (bgp) | |
8828 | { | |
8829 | if (ip_str) | |
8830 | { | |
8831 | ret = str2sockunion (ip_str, &su); | |
8832 | if (ret < 0) | |
8833 | bgp_show_neighbor (vty, bgp, type, NULL, ip_str, use_json, json); | |
8834 | else | |
8835 | bgp_show_neighbor (vty, bgp, type, &su, NULL, use_json, json); | |
8836 | } | |
8837 | else | |
8838 | { | |
8839 | bgp_show_neighbor (vty, bgp, type, NULL, NULL, use_json, json); | |
8840 | } | |
8841 | } | |
8842 | ||
8843 | return CMD_SUCCESS; | |
8844 | } | |
8845 | ||
716b2d8a | 8846 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 8847 | DEFUN (show_ip_bgp_neighbors, |
8848 | show_ip_bgp_neighbors_cmd, | |
91d37724 | 8849 | "show [ip] bgp [<view|vrf> WORD] [<ipv4|ipv6|vpnv4 <all|rd ASN:nn_or_IP-address:nn>>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 8850 | SHOW_STR |
8851 | IP_STR | |
8852 | BGP_STR | |
f2a8972b | 8853 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
8854 | "Address Family\n" |
8855 | "Address Family\n" | |
91d37724 QY |
8856 | "Address Family\n" |
8857 | "Display information about all VPNv4 NLRIs\n" | |
8858 | "Display information for a route distinguisher\n" | |
8859 | "VPN Route Distinguisher\n" | |
718e3744 | 8860 | "Detailed information on TCP and BGP neighbor connections\n" |
8861 | "Neighbor to display information about\n" | |
a80beece | 8862 | "Neighbor to display information about\n" |
91d37724 | 8863 | "Neighbor on BGP configured interface\n" |
9973d184 | 8864 | JSON_STR) |
718e3744 | 8865 | { |
5bf15956 DW |
8866 | char *vrf = NULL; |
8867 | char *sh_arg = NULL; | |
8868 | enum show_type sh_type; | |
718e3744 | 8869 | |
5bf15956 | 8870 | u_char uj = use_json(argc, argv); |
718e3744 | 8871 | |
630a298c | 8872 | int idx = 0; |
718e3744 | 8873 | |
46854ac0 DS |
8874 | if (argv_find (argv, argc, "view", &idx) || |
8875 | argv_find (argv, argc, "vrf", &idx)) | |
8876 | vrf = argv[idx+1]->arg; | |
718e3744 | 8877 | |
46854ac0 | 8878 | idx++; |
91d37724 QY |
8879 | if (argv_find (argv, argc, "A.B.C.D", &idx) || |
8880 | argv_find (argv, argc, "X:X::X:X", &idx) || | |
630a298c QY |
8881 | argv_find (argv, argc, "WORD", &idx)) |
8882 | { | |
8883 | sh_type = show_peer; | |
8884 | sh_arg = argv[idx]->arg; | |
8885 | } | |
5bf15956 | 8886 | else |
630a298c | 8887 | sh_type = show_all; |
856ca177 | 8888 | |
5bf15956 | 8889 | return bgp_show_neighbor_vty (vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 8890 | } |
8891 | ||
716b2d8a | 8892 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 8893 | paths' and `show ip mbgp paths'. Those functions results are the |
8894 | same.*/ | |
f412b39a | 8895 | DEFUN (show_ip_bgp_paths, |
718e3744 | 8896 | show_ip_bgp_paths_cmd, |
46f296b4 | 8897 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 8898 | SHOW_STR |
8899 | IP_STR | |
8900 | BGP_STR | |
46f296b4 | 8901 | BGP_SAFI_HELP_STR |
718e3744 | 8902 | "Path information\n") |
8903 | { | |
8904 | vty_out (vty, "Address Refcnt Path%s", VTY_NEWLINE); | |
8905 | aspath_print_all_vty (vty); | |
8906 | return CMD_SUCCESS; | |
8907 | } | |
8908 | ||
718e3744 | 8909 | #include "hash.h" |
8910 | ||
94f2b392 | 8911 | static void |
718e3744 | 8912 | community_show_all_iterator (struct hash_backet *backet, struct vty *vty) |
8913 | { | |
8914 | struct community *com; | |
8915 | ||
8916 | com = (struct community *) backet->data; | |
6c4f4e6e | 8917 | vty_out (vty, "[%p] (%ld) %s%s", (void *)backet, com->refcnt, |
718e3744 | 8918 | community_str (com), VTY_NEWLINE); |
8919 | } | |
8920 | ||
8921 | /* Show BGP's community internal data. */ | |
f412b39a | 8922 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 8923 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 8924 | "show [ip] bgp community-info", |
718e3744 | 8925 | SHOW_STR |
8926 | IP_STR | |
8927 | BGP_STR | |
8928 | "List all bgp community information\n") | |
8929 | { | |
8930 | vty_out (vty, "Address Refcnt Community%s", VTY_NEWLINE); | |
8931 | ||
e52702f2 | 8932 | hash_iterate (community_hash (), |
718e3744 | 8933 | (void (*) (struct hash_backet *, void *)) |
8934 | community_show_all_iterator, | |
8935 | vty); | |
8936 | ||
8937 | return CMD_SUCCESS; | |
8938 | } | |
8939 | ||
57d187bc JS |
8940 | static void |
8941 | lcommunity_show_all_iterator (struct hash_backet *backet, struct vty *vty) | |
8942 | { | |
8943 | struct lcommunity *lcom; | |
8944 | ||
8945 | lcom = (struct lcommunity *) backet->data; | |
8946 | vty_out (vty, "[%p] (%ld) %s%s", (void *)backet, lcom->refcnt, | |
2acb4ac2 | 8947 | lcommunity_str (lcom), VTY_NEWLINE); |
57d187bc JS |
8948 | } |
8949 | ||
8950 | /* Show BGP's community internal data. */ | |
8951 | DEFUN (show_ip_bgp_lcommunity_info, | |
8952 | show_ip_bgp_lcommunity_info_cmd, | |
8953 | "show ip bgp large-community-info", | |
8954 | SHOW_STR | |
8955 | IP_STR | |
8956 | BGP_STR | |
8957 | "List all bgp large-community information\n") | |
8958 | { | |
8959 | vty_out (vty, "Address Refcnt Large-community%s", VTY_NEWLINE); | |
8960 | ||
8961 | hash_iterate (lcommunity_hash (), | |
2acb4ac2 DL |
8962 | (void (*) (struct hash_backet *, void *)) |
8963 | lcommunity_show_all_iterator, | |
8964 | vty); | |
57d187bc JS |
8965 | |
8966 | return CMD_SUCCESS; | |
8967 | } | |
8968 | ||
8969 | ||
f412b39a | 8970 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 8971 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 8972 | "show [ip] bgp attribute-info", |
718e3744 | 8973 | SHOW_STR |
8974 | IP_STR | |
8975 | BGP_STR | |
8976 | "List all bgp attribute information\n") | |
8977 | { | |
8978 | attr_show_all (vty); | |
8979 | return CMD_SUCCESS; | |
8980 | } | |
6b0655a2 | 8981 | |
f186de26 | 8982 | static void |
8983 | bgp_show_all_instances_updgrps_vty (struct vty *vty, afi_t afi, safi_t safi) | |
8984 | { | |
8985 | struct listnode *node, *nnode; | |
8986 | struct bgp *bgp; | |
8987 | ||
8988 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) | |
8989 | { | |
8990 | vty_out (vty, "%sInstance %s:%s", | |
8991 | VTY_NEWLINE, | |
8992 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) ? "Default" : bgp->name, | |
8993 | VTY_NEWLINE); | |
8994 | update_group_show(bgp, afi, safi, vty, 0); | |
8995 | } | |
8996 | } | |
8997 | ||
4fb25c53 DW |
8998 | static int |
8999 | bgp_show_update_groups(struct vty *vty, const char *name, | |
9000 | int afi, int safi, | |
9001 | uint64_t subgrp_id) | |
9002 | { | |
9003 | struct bgp *bgp; | |
9004 | ||
9005 | if (name) | |
9006 | { | |
9007 | if (strmatch (name, "all")) | |
9008 | { | |
9009 | bgp_show_all_instances_updgrps_vty (vty, afi, safi); | |
9010 | return CMD_SUCCESS; | |
9011 | } | |
9012 | else | |
9013 | { | |
9014 | bgp = bgp_lookup_by_name (name); | |
9015 | } | |
9016 | } | |
9017 | else | |
9018 | { | |
9019 | bgp = bgp_get_default (); | |
9020 | } | |
9021 | ||
9022 | if (bgp) | |
9023 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
9024 | return CMD_SUCCESS; | |
9025 | } | |
9026 | ||
8fe8a7f6 DS |
9027 | DEFUN (show_ip_bgp_updgrps, |
9028 | show_ip_bgp_updgrps_cmd, | |
c9e571b4 | 9029 | "show [ip] bgp [<view|vrf> WORD] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 9030 | SHOW_STR |
9031 | IP_STR | |
9032 | BGP_STR | |
9033 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 9034 | BGP_AFI_HELP_STR |
46f296b4 | 9035 | BGP_SAFI_HELP_STR |
5bf15956 DW |
9036 | "Detailed info about dynamic update groups\n" |
9037 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 9038 | { |
5bf15956 | 9039 | char *vrf = NULL; |
ae19d7dd QY |
9040 | afi_t afi = AFI_IP6; |
9041 | safi_t safi = SAFI_UNICAST; | |
5bf15956 DW |
9042 | uint64_t subgrp_id = 0; |
9043 | ||
ae19d7dd QY |
9044 | int idx = 0; |
9045 | ||
9046 | /* show [ip] bgp */ | |
9047 | if (argv_find (argv, argc, "ip", &idx)) | |
9048 | afi = AFI_IP; | |
9049 | /* [<view|vrf> WORD] */ | |
9050 | if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) | |
9051 | vrf = argv[++idx]->arg; | |
c9e571b4 LB |
9052 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
9053 | if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) | |
9054 | { | |
9055 | argv_find_and_parse_safi (argv, argc, &idx, &safi); | |
9056 | } | |
5bf15956 | 9057 | |
ae19d7dd QY |
9058 | /* get subgroup id, if provided */ |
9059 | idx = argc - 1; | |
9060 | if (argv[idx]->type == VARIABLE_TKN) | |
9061 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx]->arg); | |
5bf15956 DW |
9062 | |
9063 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); | |
8fe8a7f6 DS |
9064 | } |
9065 | ||
f186de26 | 9066 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
9067 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 9068 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 9069 | SHOW_STR |
716b2d8a | 9070 | IP_STR |
f186de26 | 9071 | BGP_STR |
9072 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 9073 | "Detailed info about dynamic update groups\n") |
f186de26 | 9074 | { |
9075 | bgp_show_all_instances_updgrps_vty (vty, AFI_IP6, SAFI_UNICAST); | |
9076 | return CMD_SUCCESS; | |
9077 | } | |
9078 | ||
5bf15956 DW |
9079 | DEFUN (show_bgp_updgrps_stats, |
9080 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 9081 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 9082 | SHOW_STR |
716b2d8a | 9083 | IP_STR |
3f9c7369 | 9084 | BGP_STR |
0c7b1b01 | 9085 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
9086 | "Statistics\n") |
9087 | { | |
9088 | struct bgp *bgp; | |
9089 | ||
9090 | bgp = bgp_get_default(); | |
9091 | if (bgp) | |
9092 | update_group_show_stats(bgp, vty); | |
9093 | ||
9094 | return CMD_SUCCESS; | |
9095 | } | |
9096 | ||
8386ac43 | 9097 | DEFUN (show_bgp_instance_updgrps_stats, |
9098 | show_bgp_instance_updgrps_stats_cmd, | |
716b2d8a | 9099 | "show [ip] bgp <view|vrf> WORD update-groups statistics", |
8386ac43 | 9100 | SHOW_STR |
716b2d8a | 9101 | IP_STR |
8386ac43 | 9102 | BGP_STR |
9103 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 9104 | "Detailed info about dynamic update groups\n" |
8386ac43 | 9105 | "Statistics\n") |
9106 | { | |
c500ae40 | 9107 | int idx_word = 3; |
8386ac43 | 9108 | struct bgp *bgp; |
9109 | ||
c500ae40 | 9110 | bgp = bgp_lookup_by_name (argv[idx_word]->arg); |
8386ac43 | 9111 | if (bgp) |
9112 | update_group_show_stats(bgp, vty); | |
9113 | ||
9114 | return CMD_SUCCESS; | |
9115 | } | |
9116 | ||
3f9c7369 | 9117 | static void |
8386ac43 | 9118 | show_bgp_updgrps_adj_info_aux (struct vty *vty, const char *name, |
9119 | afi_t afi, safi_t safi, | |
f43e655e | 9120 | const char *what, uint64_t subgrp_id) |
3f9c7369 DS |
9121 | { |
9122 | struct bgp *bgp; | |
8386ac43 | 9123 | |
9124 | if (name) | |
9125 | bgp = bgp_lookup_by_name (name); | |
9126 | else | |
9127 | bgp = bgp_get_default (); | |
9128 | ||
3f9c7369 DS |
9129 | if (bgp) |
9130 | { | |
9131 | if (!strcmp(what, "advertise-queue")) | |
9132 | update_group_show_adj_queue(bgp, afi, safi, vty, subgrp_id); | |
9133 | else if (!strcmp(what, "advertised-routes")) | |
9134 | update_group_show_advertised(bgp, afi, safi, vty, subgrp_id); | |
9135 | else if (!strcmp(what, "packet-queue")) | |
9136 | update_group_show_packet_queue(bgp, afi, safi, vty, subgrp_id); | |
9137 | } | |
9138 | } | |
9139 | ||
9140 | DEFUN (show_ip_bgp_updgrps_adj, | |
9141 | show_ip_bgp_updgrps_adj_cmd, | |
716b2d8a | 9142 | "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 DS |
9143 | SHOW_STR |
9144 | IP_STR | |
9145 | BGP_STR | |
0c7b1b01 | 9146 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
9147 | "Advertisement queue\n" |
9148 | "Announced routes\n" | |
9149 | "Packet queue\n") | |
8fe8a7f6 | 9150 | |
3f9c7369 | 9151 | { |
c500ae40 DW |
9152 | int idx_type = 4; |
9153 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
8386ac43 | 9154 | return CMD_SUCCESS; |
9155 | } | |
9156 | ||
9157 | DEFUN (show_ip_bgp_instance_updgrps_adj, | |
9158 | show_ip_bgp_instance_updgrps_adj_cmd, | |
716b2d8a | 9159 | "show [ip] bgp <view|vrf> WORD update-groups <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 9160 | SHOW_STR |
9161 | IP_STR | |
9162 | BGP_STR | |
9163 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 9164 | "Detailed info about dynamic update groups\n" |
8386ac43 | 9165 | "Advertisement queue\n" |
9166 | "Announced routes\n" | |
9167 | "Packet queue\n") | |
9168 | ||
9169 | { | |
c500ae40 DW |
9170 | int idx_word = 4; |
9171 | int idx_type = 6; | |
9172 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
3f9c7369 DS |
9173 | return CMD_SUCCESS; |
9174 | } | |
9175 | ||
9176 | DEFUN (show_bgp_updgrps_afi_adj, | |
9177 | show_bgp_updgrps_afi_adj_cmd, | |
46f296b4 | 9178 | "show [ip] bgp "BGP_AFI_SAFI_CMD_STR" update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 9179 | SHOW_STR |
716b2d8a | 9180 | IP_STR |
3f9c7369 | 9181 | BGP_STR |
46f296b4 | 9182 | BGP_AFI_SAFI_HELP_STR |
0c7b1b01 | 9183 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
9184 | "Advertisement queue\n" |
9185 | "Announced routes\n" | |
8fe8a7f6 DS |
9186 | "Packet queue\n" |
9187 | "Specific subgroup info wanted for\n") | |
3f9c7369 | 9188 | { |
c500ae40 DW |
9189 | int idx_afi = 2; |
9190 | int idx_safi = 3; | |
9191 | int idx_type = 5; | |
46f296b4 LB |
9192 | show_bgp_updgrps_adj_info_aux(vty, NULL, |
9193 | bgp_vty_afi_from_arg(argv[idx_afi]->arg), | |
9194 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), | |
9195 | argv[idx_type]->arg, 0); | |
8fe8a7f6 | 9196 | return CMD_SUCCESS; |
3f9c7369 DS |
9197 | } |
9198 | ||
9199 | DEFUN (show_bgp_updgrps_adj, | |
9200 | show_bgp_updgrps_adj_cmd, | |
716b2d8a | 9201 | "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 9202 | SHOW_STR |
716b2d8a | 9203 | IP_STR |
3f9c7369 | 9204 | BGP_STR |
0c7b1b01 | 9205 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
9206 | "Advertisement queue\n" |
9207 | "Announced routes\n" | |
9208 | "Packet queue\n") | |
9209 | { | |
c500ae40 DW |
9210 | int idx_type = 3; |
9211 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
8386ac43 | 9212 | return CMD_SUCCESS; |
9213 | } | |
9214 | ||
9215 | DEFUN (show_bgp_instance_updgrps_adj, | |
9216 | show_bgp_instance_updgrps_adj_cmd, | |
716b2d8a | 9217 | "show [ip] bgp <view|vrf> WORD update-groups <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 9218 | SHOW_STR |
716b2d8a | 9219 | IP_STR |
8386ac43 | 9220 | BGP_STR |
9221 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 9222 | "Detailed info about dynamic update groups\n" |
8386ac43 | 9223 | "Advertisement queue\n" |
9224 | "Announced routes\n" | |
9225 | "Packet queue\n") | |
9226 | { | |
c500ae40 DW |
9227 | int idx_word = 3; |
9228 | int idx_type = 5; | |
9229 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
3f9c7369 DS |
9230 | return CMD_SUCCESS; |
9231 | } | |
9232 | ||
9233 | DEFUN (show_ip_bgp_updgrps_adj_s, | |
8fe8a7f6 | 9234 | show_ip_bgp_updgrps_adj_s_cmd, |
716b2d8a | 9235 | "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 DS |
9236 | SHOW_STR |
9237 | IP_STR | |
9238 | BGP_STR | |
0c7b1b01 | 9239 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 | 9240 | "Specific subgroup to display info for\n" |
3f9c7369 DS |
9241 | "Advertisement queue\n" |
9242 | "Announced routes\n" | |
9243 | "Packet queue\n") | |
3f9c7369 | 9244 | |
3f9c7369 | 9245 | { |
5bf15956 | 9246 | int idx_subgroup_id = 4; |
c500ae40 | 9247 | int idx_type = 5; |
f43e655e | 9248 | uint64_t subgrp_id; |
8fe8a7f6 | 9249 | |
5bf15956 | 9250 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8fe8a7f6 | 9251 | |
5bf15956 | 9252 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
8386ac43 | 9253 | return CMD_SUCCESS; |
9254 | } | |
9255 | ||
9256 | DEFUN (show_ip_bgp_instance_updgrps_adj_s, | |
9257 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
716b2d8a | 9258 | "show [ip] bgp <view|vrf> WORD update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 9259 | SHOW_STR |
9260 | IP_STR | |
9261 | BGP_STR | |
9262 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 9263 | "Detailed info about dynamic update groups\n" |
8386ac43 | 9264 | "Specific subgroup to display info for\n" |
9265 | "Advertisement queue\n" | |
9266 | "Announced routes\n" | |
9267 | "Packet queue\n") | |
9268 | ||
9269 | { | |
5bf15956 DW |
9270 | int idx_vrf = 4; |
9271 | int idx_subgroup_id = 6; | |
c500ae40 | 9272 | int idx_type = 7; |
f43e655e | 9273 | uint64_t subgrp_id; |
8386ac43 | 9274 | |
5bf15956 | 9275 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8386ac43 | 9276 | |
5bf15956 | 9277 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
3f9c7369 DS |
9278 | return CMD_SUCCESS; |
9279 | } | |
9280 | ||
8fe8a7f6 DS |
9281 | DEFUN (show_bgp_updgrps_afi_adj_s, |
9282 | show_bgp_updgrps_afi_adj_s_cmd, | |
46f296b4 | 9283 | "show [ip] bgp "BGP_AFI_SAFI_CMD_STR" update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 9284 | SHOW_STR |
716b2d8a | 9285 | IP_STR |
3f9c7369 | 9286 | BGP_STR |
46f296b4 | 9287 | BGP_AFI_SAFI_HELP_STR |
0c7b1b01 | 9288 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 | 9289 | "Specific subgroup to display info for\n" |
3f9c7369 DS |
9290 | "Advertisement queue\n" |
9291 | "Announced routes\n" | |
8fe8a7f6 DS |
9292 | "Packet queue\n" |
9293 | "Specific subgroup info wanted for\n") | |
3f9c7369 | 9294 | { |
c500ae40 DW |
9295 | int idx_afi = 2; |
9296 | int idx_safi = 3; | |
5bf15956 | 9297 | int idx_subgroup_id = 5; |
c500ae40 | 9298 | int idx_type = 6; |
f43e655e | 9299 | uint64_t subgrp_id; |
3f9c7369 | 9300 | |
5bf15956 | 9301 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8fe8a7f6 | 9302 | |
46f296b4 LB |
9303 | show_bgp_updgrps_adj_info_aux(vty, NULL, |
9304 | bgp_vty_afi_from_arg(argv[idx_afi]->arg), | |
9305 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), | |
9306 | argv[idx_type]->arg, subgrp_id); | |
8fe8a7f6 | 9307 | return CMD_SUCCESS; |
3f9c7369 DS |
9308 | } |
9309 | ||
8fe8a7f6 DS |
9310 | DEFUN (show_bgp_updgrps_adj_s, |
9311 | show_bgp_updgrps_adj_s_cmd, | |
716b2d8a | 9312 | "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8fe8a7f6 | 9313 | SHOW_STR |
716b2d8a | 9314 | IP_STR |
8fe8a7f6 | 9315 | BGP_STR |
0c7b1b01 | 9316 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 DS |
9317 | "Specific subgroup to display info for\n" |
9318 | "Advertisement queue\n" | |
9319 | "Announced routes\n" | |
9320 | "Packet queue\n") | |
9321 | { | |
5bf15956 | 9322 | int idx_subgroup_id = 3; |
c500ae40 | 9323 | int idx_type = 4; |
f43e655e | 9324 | uint64_t subgrp_id; |
8fe8a7f6 | 9325 | |
5bf15956 | 9326 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8fe8a7f6 | 9327 | |
5bf15956 | 9328 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
8fe8a7f6 DS |
9329 | return CMD_SUCCESS; |
9330 | } | |
9331 | ||
8386ac43 | 9332 | DEFUN (show_bgp_instance_updgrps_adj_s, |
9333 | show_bgp_instance_updgrps_adj_s_cmd, | |
716b2d8a | 9334 | "show [ip] bgp <view|vrf> WORD update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 9335 | SHOW_STR |
716b2d8a | 9336 | IP_STR |
8386ac43 | 9337 | BGP_STR |
9338 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 9339 | "Detailed info about dynamic update groups\n" |
8386ac43 | 9340 | "Specific subgroup to display info for\n" |
9341 | "Advertisement queue\n" | |
9342 | "Announced routes\n" | |
9343 | "Packet queue\n") | |
9344 | { | |
5bf15956 DW |
9345 | int idx_vrf = 3; |
9346 | int idx_subgroup_id = 5; | |
c500ae40 | 9347 | int idx_type = 6; |
f43e655e | 9348 | uint64_t subgrp_id; |
8386ac43 | 9349 | |
5bf15956 | 9350 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8386ac43 | 9351 | |
5bf15956 | 9352 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
8386ac43 | 9353 | return CMD_SUCCESS; |
9354 | } | |
9355 | ||
9356 | ||
8fe8a7f6 | 9357 | |
f14e6fdb DS |
9358 | static int |
9359 | bgp_show_one_peer_group (struct vty *vty, struct peer_group *group) | |
9360 | { | |
9361 | struct listnode *node, *nnode; | |
9362 | struct prefix *range; | |
9363 | struct peer *conf; | |
9364 | struct peer *peer; | |
4690c7d7 | 9365 | char buf[PREFIX2STR_BUFFER]; |
f14e6fdb DS |
9366 | afi_t afi; |
9367 | safi_t safi; | |
ffd0c037 DS |
9368 | const char *peer_status; |
9369 | const char *af_str; | |
f14e6fdb DS |
9370 | int lr_count; |
9371 | int dynamic; | |
9372 | int af_cfgd; | |
9373 | ||
9374 | conf = group->conf; | |
9375 | ||
0299c004 DS |
9376 | if (conf->as_type == AS_SPECIFIED || |
9377 | conf->as_type == AS_EXTERNAL) { | |
66b199b2 | 9378 | vty_out (vty, "%sBGP peer-group %s, remote AS %d%s", |
f14e6fdb | 9379 | VTY_NEWLINE, group->name, conf->as, VTY_NEWLINE); |
0299c004 | 9380 | } else if (conf->as_type == AS_INTERNAL) { |
66b199b2 | 9381 | vty_out (vty, "%sBGP peer-group %s, remote AS %d%s", |
0299c004 | 9382 | VTY_NEWLINE, group->name, group->bgp->as, VTY_NEWLINE); |
66b199b2 DS |
9383 | } else { |
9384 | vty_out (vty, "%sBGP peer-group %s%s", | |
9385 | VTY_NEWLINE, group->name, VTY_NEWLINE); | |
0299c004 | 9386 | } |
f14e6fdb | 9387 | |
0299c004 | 9388 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
f14e6fdb DS |
9389 | vty_out (vty, " Peer-group type is internal%s", VTY_NEWLINE); |
9390 | else | |
9391 | vty_out (vty, " Peer-group type is external%s", VTY_NEWLINE); | |
9392 | ||
9393 | /* Display AFs configured. */ | |
9394 | vty_out (vty, " Configured address-families:"); | |
9395 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
9396 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
9397 | { | |
9398 | if (conf->afc[afi][safi]) | |
9399 | { | |
9400 | af_cfgd = 1; | |
9401 | vty_out (vty, " %s;", afi_safi_print(afi, safi)); | |
9402 | } | |
9403 | } | |
9404 | if (!af_cfgd) | |
9405 | vty_out (vty, " none%s", VTY_NEWLINE); | |
9406 | else | |
9407 | vty_out (vty, "%s", VTY_NEWLINE); | |
9408 | ||
9409 | /* Display listen ranges (for dynamic neighbors), if any */ | |
9410 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
9411 | { | |
9412 | if (afi == AFI_IP) | |
9413 | af_str = "IPv4"; | |
9414 | else if (afi == AFI_IP6) | |
9415 | af_str = "IPv6"; | |
45ef4300 DL |
9416 | else |
9417 | af_str = "???"; | |
f14e6fdb DS |
9418 | lr_count = listcount(group->listen_range[afi]); |
9419 | if (lr_count) | |
9420 | { | |
9421 | vty_out(vty, | |
9422 | " %d %s listen range(s)%s", | |
9423 | lr_count, af_str, VTY_NEWLINE); | |
9424 | ||
9425 | ||
9426 | for (ALL_LIST_ELEMENTS (group->listen_range[afi], node, | |
9427 | nnode, range)) | |
9428 | { | |
9429 | prefix2str(range, buf, sizeof(buf)); | |
9430 | vty_out(vty, " %s%s", buf, VTY_NEWLINE); | |
9431 | } | |
9432 | } | |
9433 | } | |
9434 | ||
9435 | /* Display group members and their status */ | |
9436 | if (listcount(group->peer)) | |
9437 | { | |
9438 | vty_out (vty, " Peer-group members:%s", VTY_NEWLINE); | |
9439 | for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) | |
9440 | { | |
9441 | if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) | |
9442 | peer_status = "Idle (Admin)"; | |
9443 | else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) | |
9444 | peer_status = "Idle (PfxCt)"; | |
9445 | else | |
9446 | peer_status = LOOKUP(bgp_status_msg, peer->status); | |
9447 | ||
9448 | dynamic = peer_dynamic_neighbor(peer); | |
9449 | vty_out (vty, " %s %s %s %s", | |
9450 | peer->host, dynamic ? "(dynamic)" : "", | |
9451 | peer_status, VTY_NEWLINE); | |
9452 | } | |
9453 | } | |
9454 | ||
9455 | return CMD_SUCCESS; | |
9456 | } | |
9457 | ||
9458 | /* Show BGP peer group's information. */ | |
9459 | enum show_group_type | |
9460 | { | |
9461 | show_all_groups, | |
9462 | show_peer_group | |
9463 | }; | |
9464 | ||
9465 | static int | |
9466 | bgp_show_peer_group (struct vty *vty, struct bgp *bgp, | |
9467 | enum show_group_type type, const char *group_name) | |
9468 | { | |
9469 | struct listnode *node, *nnode; | |
9470 | struct peer_group *group; | |
9471 | int find = 0; | |
9472 | ||
9473 | for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) | |
9474 | { | |
9475 | switch (type) | |
9476 | { | |
9477 | case show_all_groups: | |
9478 | bgp_show_one_peer_group (vty, group); | |
9479 | break; | |
9480 | case show_peer_group: | |
9481 | if (group_name && (strcmp(group->name, group_name) == 0)) | |
9482 | { | |
9483 | find = 1; | |
9484 | bgp_show_one_peer_group (vty, group); | |
9485 | } | |
9486 | break; | |
9487 | } | |
9488 | } | |
9489 | ||
9490 | if (type == show_peer_group && ! find) | |
6d9e66dc | 9491 | vty_out (vty, "%% No such peer-group%s", VTY_NEWLINE); |
f14e6fdb DS |
9492 | |
9493 | return CMD_SUCCESS; | |
9494 | } | |
9495 | ||
9496 | static int | |
9497 | bgp_show_peer_group_vty (struct vty *vty, const char *name, | |
9498 | enum show_group_type type, const char *group_name) | |
9499 | { | |
9500 | struct bgp *bgp; | |
9501 | int ret = CMD_SUCCESS; | |
9502 | ||
9503 | if (name) | |
8386ac43 | 9504 | bgp = bgp_lookup_by_name (name); |
9505 | else | |
9506 | bgp = bgp_get_default (); | |
f14e6fdb | 9507 | |
8386ac43 | 9508 | if (! bgp) |
9509 | { | |
9510 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
9511 | return CMD_WARNING; | |
f14e6fdb DS |
9512 | } |
9513 | ||
8386ac43 | 9514 | ret = bgp_show_peer_group (vty, bgp, type, group_name); |
f14e6fdb DS |
9515 | |
9516 | return ret; | |
9517 | } | |
9518 | ||
9519 | DEFUN (show_ip_bgp_peer_groups, | |
9520 | show_ip_bgp_peer_groups_cmd, | |
f2a8972b | 9521 | "show [ip] bgp [<view|vrf> WORD] peer-group [PGNAME]", |
f14e6fdb DS |
9522 | SHOW_STR |
9523 | IP_STR | |
9524 | BGP_STR | |
8386ac43 | 9525 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
9526 | "Detailed information on BGP peer groups\n" |
9527 | "Peer group name\n") | |
f14e6fdb | 9528 | { |
d6e3c605 QY |
9529 | char *vrf, *pg; |
9530 | vrf = pg = NULL; | |
9531 | int idx = 0; | |
f14e6fdb | 9532 | |
f2a8972b | 9533 | vrf = argv_find (argv, argc, "WORD", &idx) ? argv[idx]->arg : NULL; |
d6e3c605 | 9534 | pg = argv_find (argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 9535 | |
d6e3c605 | 9536 | return bgp_show_peer_group_vty (vty, vrf, show_all_groups, pg); |
f14e6fdb | 9537 | } |
3f9c7369 | 9538 | |
d6e3c605 | 9539 | |
718e3744 | 9540 | /* Redistribute VTY commands. */ |
9541 | ||
718e3744 | 9542 | DEFUN (bgp_redistribute_ipv4, |
9543 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 9544 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 9545 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9546 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 9547 | { |
cdc2d765 | 9548 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 9549 | int idx_protocol = 1; |
718e3744 | 9550 | int type; |
9551 | ||
6d681bd8 QY |
9552 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9553 | if (type < 0) | |
718e3744 | 9554 | { |
9555 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9556 | return CMD_WARNING; | |
9557 | } | |
cdc2d765 DL |
9558 | bgp_redist_add(bgp, AFI_IP, type, 0); |
9559 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); | |
718e3744 | 9560 | } |
9561 | ||
9562 | DEFUN (bgp_redistribute_ipv4_rmap, | |
9563 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 9564 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 9565 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9566 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 9567 | "Route map reference\n" |
9568 | "Pointer to route-map entries\n") | |
9569 | { | |
cdc2d765 | 9570 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9571 | int idx_protocol = 1; |
9572 | int idx_word = 3; | |
718e3744 | 9573 | int type; |
7c8ff89e | 9574 | struct bgp_redist *red; |
718e3744 | 9575 | |
6d681bd8 QY |
9576 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9577 | if (type < 0) | |
718e3744 | 9578 | { |
9579 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9580 | return CMD_WARNING; | |
9581 | } | |
9582 | ||
cdc2d765 | 9583 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
c500ae40 | 9584 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9585 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); |
718e3744 | 9586 | } |
9587 | ||
9588 | DEFUN (bgp_redistribute_ipv4_metric, | |
9589 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 9590 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 9591 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9592 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 9593 | "Metric for redistributed routes\n" |
9594 | "Default metric\n") | |
9595 | { | |
cdc2d765 | 9596 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9597 | int idx_protocol = 1; |
9598 | int idx_number = 3; | |
718e3744 | 9599 | int type; |
9600 | u_int32_t metric; | |
7c8ff89e | 9601 | struct bgp_redist *red; |
718e3744 | 9602 | |
6d681bd8 QY |
9603 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9604 | if (type < 0) | |
718e3744 | 9605 | { |
9606 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9607 | return CMD_WARNING; | |
9608 | } | |
c500ae40 | 9609 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9610 | |
cdc2d765 DL |
9611 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
9612 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
9613 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); | |
718e3744 | 9614 | } |
9615 | ||
9616 | DEFUN (bgp_redistribute_ipv4_rmap_metric, | |
9617 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 9618 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 9619 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9620 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 9621 | "Route map reference\n" |
9622 | "Pointer to route-map entries\n" | |
9623 | "Metric for redistributed routes\n" | |
9624 | "Default metric\n") | |
9625 | { | |
cdc2d765 | 9626 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9627 | int idx_protocol = 1; |
9628 | int idx_word = 3; | |
9629 | int idx_number = 5; | |
718e3744 | 9630 | int type; |
9631 | u_int32_t metric; | |
7c8ff89e | 9632 | struct bgp_redist *red; |
718e3744 | 9633 | |
6d681bd8 QY |
9634 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9635 | if (type < 0) | |
718e3744 | 9636 | { |
9637 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9638 | return CMD_WARNING; | |
9639 | } | |
c500ae40 | 9640 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9641 | |
cdc2d765 | 9642 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
c500ae40 | 9643 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 DL |
9644 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
9645 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); | |
718e3744 | 9646 | } |
9647 | ||
9648 | DEFUN (bgp_redistribute_ipv4_metric_rmap, | |
9649 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 9650 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 9651 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9652 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 9653 | "Metric for redistributed routes\n" |
9654 | "Default metric\n" | |
9655 | "Route map reference\n" | |
9656 | "Pointer to route-map entries\n") | |
9657 | { | |
cdc2d765 | 9658 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9659 | int idx_protocol = 1; |
9660 | int idx_number = 3; | |
9661 | int idx_word = 5; | |
718e3744 | 9662 | int type; |
9663 | u_int32_t metric; | |
7c8ff89e | 9664 | struct bgp_redist *red; |
718e3744 | 9665 | |
6d681bd8 QY |
9666 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9667 | if (type < 0) | |
718e3744 | 9668 | { |
9669 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9670 | return CMD_WARNING; | |
9671 | } | |
c500ae40 | 9672 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9673 | |
cdc2d765 DL |
9674 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
9675 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
c500ae40 | 9676 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9677 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); |
718e3744 | 9678 | } |
9679 | ||
7c8ff89e DS |
9680 | DEFUN (bgp_redistribute_ipv4_ospf, |
9681 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 9682 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
9683 | "Redistribute information from another routing protocol\n" |
9684 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9685 | "Non-main Kernel Routing Table\n" |
9686 | "Instance ID/Table ID\n") | |
7c8ff89e | 9687 | { |
cdc2d765 | 9688 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9689 | int idx_ospf_table = 1; |
9690 | int idx_number = 2; | |
7c8ff89e | 9691 | u_short instance; |
7a4bb9c5 | 9692 | u_short protocol; |
7c8ff89e | 9693 | |
c500ae40 | 9694 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
7a4bb9c5 | 9695 | |
c500ae40 | 9696 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9697 | protocol = ZEBRA_ROUTE_OSPF; |
9698 | else | |
9699 | protocol = ZEBRA_ROUTE_TABLE; | |
9700 | ||
cdc2d765 DL |
9701 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
9702 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
9703 | } |
9704 | ||
9705 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, | |
9706 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 9707 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
9708 | "Redistribute information from another routing protocol\n" |
9709 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9710 | "Non-main Kernel Routing Table\n" |
9711 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
9712 | "Route map reference\n" |
9713 | "Pointer to route-map entries\n") | |
9714 | { | |
cdc2d765 | 9715 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9716 | int idx_ospf_table = 1; |
9717 | int idx_number = 2; | |
9718 | int idx_word = 4; | |
7c8ff89e DS |
9719 | struct bgp_redist *red; |
9720 | u_short instance; | |
7a4bb9c5 | 9721 | int protocol; |
7c8ff89e | 9722 | |
c500ae40 | 9723 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9724 | protocol = ZEBRA_ROUTE_OSPF; |
9725 | else | |
9726 | protocol = ZEBRA_ROUTE_TABLE; | |
9727 | ||
c500ae40 | 9728 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
cdc2d765 | 9729 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
c500ae40 | 9730 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9731 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); |
7c8ff89e DS |
9732 | } |
9733 | ||
9734 | DEFUN (bgp_redistribute_ipv4_ospf_metric, | |
9735 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 9736 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
9737 | "Redistribute information from another routing protocol\n" |
9738 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9739 | "Non-main Kernel Routing Table\n" |
9740 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
9741 | "Metric for redistributed routes\n" |
9742 | "Default metric\n") | |
9743 | { | |
cdc2d765 | 9744 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9745 | int idx_ospf_table = 1; |
9746 | int idx_number = 2; | |
9747 | int idx_number_2 = 4; | |
7c8ff89e DS |
9748 | u_int32_t metric; |
9749 | struct bgp_redist *red; | |
9750 | u_short instance; | |
7a4bb9c5 | 9751 | int protocol; |
7c8ff89e | 9752 | |
c500ae40 | 9753 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9754 | protocol = ZEBRA_ROUTE_OSPF; |
9755 | else | |
9756 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 9757 | |
c500ae40 DW |
9758 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
9759 | VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); | |
7a4bb9c5 | 9760 | |
cdc2d765 DL |
9761 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
9762 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
9763 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
9764 | } |
9765 | ||
9766 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, | |
9767 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 9768 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
9769 | "Redistribute information from another routing protocol\n" |
9770 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9771 | "Non-main Kernel Routing Table\n" |
9772 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
9773 | "Route map reference\n" |
9774 | "Pointer to route-map entries\n" | |
9775 | "Metric for redistributed routes\n" | |
9776 | "Default metric\n") | |
9777 | { | |
cdc2d765 | 9778 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9779 | int idx_ospf_table = 1; |
9780 | int idx_number = 2; | |
9781 | int idx_word = 4; | |
9782 | int idx_number_2 = 6; | |
7c8ff89e DS |
9783 | u_int32_t metric; |
9784 | struct bgp_redist *red; | |
9785 | u_short instance; | |
7a4bb9c5 | 9786 | int protocol; |
7c8ff89e | 9787 | |
c500ae40 | 9788 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9789 | protocol = ZEBRA_ROUTE_OSPF; |
9790 | else | |
9791 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 9792 | |
c500ae40 DW |
9793 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
9794 | VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); | |
7a4bb9c5 | 9795 | |
cdc2d765 | 9796 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
c500ae40 | 9797 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 DL |
9798 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); |
9799 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
9800 | } |
9801 | ||
9802 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, | |
9803 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 9804 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
9805 | "Redistribute information from another routing protocol\n" |
9806 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9807 | "Non-main Kernel Routing Table\n" |
9808 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
9809 | "Metric for redistributed routes\n" |
9810 | "Default metric\n" | |
9811 | "Route map reference\n" | |
9812 | "Pointer to route-map entries\n") | |
9813 | { | |
cdc2d765 | 9814 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9815 | int idx_ospf_table = 1; |
9816 | int idx_number = 2; | |
9817 | int idx_number_2 = 4; | |
9818 | int idx_word = 6; | |
7c8ff89e DS |
9819 | u_int32_t metric; |
9820 | struct bgp_redist *red; | |
9821 | u_short instance; | |
7a4bb9c5 | 9822 | int protocol; |
7c8ff89e | 9823 | |
c500ae40 | 9824 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9825 | protocol = ZEBRA_ROUTE_OSPF; |
9826 | else | |
9827 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 9828 | |
c500ae40 DW |
9829 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
9830 | VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); | |
7a4bb9c5 | 9831 | |
cdc2d765 DL |
9832 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
9833 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
c500ae40 | 9834 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9835 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); |
7c8ff89e DS |
9836 | } |
9837 | ||
9838 | DEFUN (no_bgp_redistribute_ipv4_ospf, | |
9839 | no_bgp_redistribute_ipv4_ospf_cmd, | |
d04c479d | 9840 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", |
7c8ff89e DS |
9841 | NO_STR |
9842 | "Redistribute information from another routing protocol\n" | |
9843 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 9844 | "Non-main Kernel Routing Table\n" |
31500417 DW |
9845 | "Instance ID/Table ID\n" |
9846 | "Metric for redistributed routes\n" | |
9847 | "Default metric\n" | |
9848 | "Route map reference\n" | |
9849 | "Pointer to route-map entries\n") | |
7c8ff89e | 9850 | { |
cdc2d765 | 9851 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9852 | int idx_ospf_table = 2; |
9853 | int idx_number = 3; | |
7c8ff89e | 9854 | u_short instance; |
7a4bb9c5 DS |
9855 | int protocol; |
9856 | ||
c500ae40 | 9857 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9858 | protocol = ZEBRA_ROUTE_OSPF; |
9859 | else | |
9860 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 9861 | |
c500ae40 | 9862 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
cdc2d765 | 9863 | return bgp_redistribute_unset (bgp, AFI_IP, protocol, instance); |
7c8ff89e DS |
9864 | } |
9865 | ||
718e3744 | 9866 | DEFUN (no_bgp_redistribute_ipv4, |
9867 | no_bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 9868 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 9869 | NO_STR |
9870 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 9871 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
9872 | "Metric for redistributed routes\n" |
9873 | "Default metric\n" | |
9874 | "Route map reference\n" | |
9875 | "Pointer to route-map entries\n") | |
718e3744 | 9876 | { |
cdc2d765 | 9877 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 9878 | int idx_protocol = 2; |
718e3744 | 9879 | int type; |
9880 | ||
6d681bd8 QY |
9881 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9882 | if (type < 0) | |
718e3744 | 9883 | { |
9884 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9885 | return CMD_WARNING; | |
9886 | } | |
cdc2d765 | 9887 | return bgp_redistribute_unset (bgp, AFI_IP, type, 0); |
718e3744 | 9888 | } |
9889 | ||
718e3744 | 9890 | DEFUN (bgp_redistribute_ipv6, |
9891 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 9892 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 9893 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9894 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 9895 | { |
cdc2d765 | 9896 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 9897 | int idx_protocol = 1; |
718e3744 | 9898 | int type; |
9899 | ||
6d681bd8 QY |
9900 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9901 | if (type < 0) | |
718e3744 | 9902 | { |
9903 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9904 | return CMD_WARNING; | |
9905 | } | |
9906 | ||
cdc2d765 DL |
9907 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
9908 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); | |
718e3744 | 9909 | } |
9910 | ||
9911 | DEFUN (bgp_redistribute_ipv6_rmap, | |
9912 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 9913 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 9914 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9915 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 9916 | "Route map reference\n" |
9917 | "Pointer to route-map entries\n") | |
9918 | { | |
cdc2d765 | 9919 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9920 | int idx_protocol = 1; |
9921 | int idx_word = 3; | |
718e3744 | 9922 | int type; |
7c8ff89e | 9923 | struct bgp_redist *red; |
718e3744 | 9924 | |
6d681bd8 QY |
9925 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9926 | if (type < 0) | |
718e3744 | 9927 | { |
9928 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9929 | return CMD_WARNING; | |
9930 | } | |
9931 | ||
cdc2d765 | 9932 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
c500ae40 | 9933 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9934 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); |
718e3744 | 9935 | } |
9936 | ||
9937 | DEFUN (bgp_redistribute_ipv6_metric, | |
9938 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 9939 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 9940 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9941 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 9942 | "Metric for redistributed routes\n" |
9943 | "Default metric\n") | |
9944 | { | |
cdc2d765 | 9945 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9946 | int idx_protocol = 1; |
9947 | int idx_number = 3; | |
718e3744 | 9948 | int type; |
9949 | u_int32_t metric; | |
7c8ff89e | 9950 | struct bgp_redist *red; |
718e3744 | 9951 | |
6d681bd8 QY |
9952 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9953 | if (type < 0) | |
718e3744 | 9954 | { |
9955 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9956 | return CMD_WARNING; | |
9957 | } | |
c500ae40 | 9958 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9959 | |
cdc2d765 DL |
9960 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
9961 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
9962 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); | |
718e3744 | 9963 | } |
9964 | ||
9965 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
9966 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 9967 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 9968 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9969 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 9970 | "Route map reference\n" |
9971 | "Pointer to route-map entries\n" | |
9972 | "Metric for redistributed routes\n" | |
9973 | "Default metric\n") | |
9974 | { | |
cdc2d765 | 9975 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9976 | int idx_protocol = 1; |
9977 | int idx_word = 3; | |
9978 | int idx_number = 5; | |
718e3744 | 9979 | int type; |
9980 | u_int32_t metric; | |
7c8ff89e | 9981 | struct bgp_redist *red; |
718e3744 | 9982 | |
6d681bd8 QY |
9983 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9984 | if (type < 0) | |
718e3744 | 9985 | { |
9986 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9987 | return CMD_WARNING; | |
9988 | } | |
c500ae40 | 9989 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9990 | |
cdc2d765 | 9991 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
c500ae40 | 9992 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 DL |
9993 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); |
9994 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); | |
718e3744 | 9995 | } |
9996 | ||
9997 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
9998 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 9999 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 10000 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10001 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 10002 | "Metric for redistributed routes\n" |
10003 | "Default metric\n" | |
10004 | "Route map reference\n" | |
10005 | "Pointer to route-map entries\n") | |
10006 | { | |
cdc2d765 | 10007 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
10008 | int idx_protocol = 1; |
10009 | int idx_number = 3; | |
10010 | int idx_word = 5; | |
718e3744 | 10011 | int type; |
10012 | u_int32_t metric; | |
7c8ff89e | 10013 | struct bgp_redist *red; |
718e3744 | 10014 | |
6d681bd8 QY |
10015 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
10016 | if (type < 0) | |
718e3744 | 10017 | { |
10018 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
10019 | return CMD_WARNING; | |
10020 | } | |
c500ae40 | 10021 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 10022 | |
cdc2d765 DL |
10023 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
10024 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, metric); | |
c500ae40 | 10025 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 10026 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); |
718e3744 | 10027 | } |
10028 | ||
10029 | DEFUN (no_bgp_redistribute_ipv6, | |
10030 | no_bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 10031 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 10032 | NO_STR |
10033 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 10034 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
10035 | "Metric for redistributed routes\n" |
10036 | "Default metric\n" | |
10037 | "Route map reference\n" | |
10038 | "Pointer to route-map entries\n") | |
718e3744 | 10039 | { |
cdc2d765 | 10040 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 10041 | int idx_protocol = 2; |
718e3744 | 10042 | int type; |
10043 | ||
6d681bd8 QY |
10044 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
10045 | if (type < 0) | |
718e3744 | 10046 | { |
10047 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
10048 | return CMD_WARNING; | |
10049 | } | |
10050 | ||
cdc2d765 | 10051 | return bgp_redistribute_unset (bgp, AFI_IP6, type, 0); |
718e3744 | 10052 | } |
6b0655a2 | 10053 | |
718e3744 | 10054 | int |
10055 | bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi, | |
10056 | safi_t safi, int *write) | |
10057 | { | |
10058 | int i; | |
718e3744 | 10059 | |
10060 | /* Unicast redistribution only. */ | |
10061 | if (safi != SAFI_UNICAST) | |
10062 | return 0; | |
10063 | ||
10064 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) | |
10065 | { | |
10066 | /* Redistribute BGP does not make sense. */ | |
7c8ff89e | 10067 | if (i != ZEBRA_ROUTE_BGP) |
718e3744 | 10068 | { |
7c8ff89e DS |
10069 | struct list *red_list; |
10070 | struct listnode *node; | |
10071 | struct bgp_redist *red; | |
718e3744 | 10072 | |
7c8ff89e DS |
10073 | red_list = bgp->redist[afi][i]; |
10074 | if (!red_list) | |
10075 | continue; | |
718e3744 | 10076 | |
7c8ff89e DS |
10077 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) |
10078 | { | |
10079 | /* Display "address-family" when it is not yet diplayed. */ | |
10080 | bgp_config_write_family_header (vty, afi, safi, write); | |
10081 | ||
10082 | /* "redistribute" configuration. */ | |
0b960b4d | 10083 | vty_out (vty, " redistribute %s", zebra_route_string(i)); |
7c8ff89e DS |
10084 | if (red->instance) |
10085 | vty_out (vty, " %d", red->instance); | |
10086 | if (red->redist_metric_flag) | |
10087 | vty_out (vty, " metric %u", red->redist_metric); | |
10088 | if (red->rmap.name) | |
10089 | vty_out (vty, " route-map %s", red->rmap.name); | |
10090 | vty_out (vty, "%s", VTY_NEWLINE); | |
10091 | } | |
718e3744 | 10092 | } |
10093 | } | |
10094 | return *write; | |
10095 | } | |
6b0655a2 | 10096 | |
718e3744 | 10097 | /* BGP node structure. */ |
7fc626de | 10098 | static struct cmd_node bgp_node = |
718e3744 | 10099 | { |
10100 | BGP_NODE, | |
10101 | "%s(config-router)# ", | |
10102 | 1, | |
10103 | }; | |
10104 | ||
7fc626de | 10105 | static struct cmd_node bgp_ipv4_unicast_node = |
718e3744 | 10106 | { |
10107 | BGP_IPV4_NODE, | |
10108 | "%s(config-router-af)# ", | |
10109 | 1, | |
10110 | }; | |
10111 | ||
7fc626de | 10112 | static struct cmd_node bgp_ipv4_multicast_node = |
718e3744 | 10113 | { |
10114 | BGP_IPV4M_NODE, | |
10115 | "%s(config-router-af)# ", | |
10116 | 1, | |
10117 | }; | |
10118 | ||
f51bae9c DS |
10119 | static struct cmd_node bgp_ipv4_labeled_unicast_node = |
10120 | { | |
10121 | BGP_IPV4L_NODE, | |
10122 | "%s(config-router-af)# ", | |
10123 | 1, | |
10124 | }; | |
10125 | ||
7fc626de | 10126 | static struct cmd_node bgp_ipv6_unicast_node = |
718e3744 | 10127 | { |
10128 | BGP_IPV6_NODE, | |
10129 | "%s(config-router-af)# ", | |
10130 | 1, | |
10131 | }; | |
10132 | ||
7fc626de | 10133 | static struct cmd_node bgp_ipv6_multicast_node = |
25ffbdc1 | 10134 | { |
10135 | BGP_IPV6M_NODE, | |
10136 | "%s(config-router-af)# ", | |
10137 | 1, | |
10138 | }; | |
10139 | ||
f51bae9c DS |
10140 | static struct cmd_node bgp_ipv6_labeled_unicast_node = |
10141 | { | |
10142 | BGP_IPV6L_NODE, | |
10143 | "%s(config-router-af)# ", | |
10144 | 1, | |
10145 | }; | |
10146 | ||
7fc626de | 10147 | static struct cmd_node bgp_vpnv4_node = |
718e3744 | 10148 | { |
10149 | BGP_VPNV4_NODE, | |
10150 | "%s(config-router-af)# ", | |
10151 | 1 | |
10152 | }; | |
6b0655a2 | 10153 | |
8ecd3266 | 10154 | static struct cmd_node bgp_vpnv6_node = |
10155 | { | |
10156 | BGP_VPNV6_NODE, | |
10157 | "%s(config-router-af-vpnv6)# ", | |
10158 | 1 | |
10159 | }; | |
10160 | ||
8b1fb8be LB |
10161 | static struct cmd_node bgp_encap_node = |
10162 | { | |
10163 | BGP_ENCAP_NODE, | |
10164 | "%s(config-router-af-encap)# ", | |
10165 | 1 | |
10166 | }; | |
10167 | ||
10168 | static struct cmd_node bgp_encapv6_node = | |
10169 | { | |
10170 | BGP_ENCAPV6_NODE, | |
10171 | "%s(config-router-af-encapv6)# ", | |
10172 | 1 | |
10173 | }; | |
10174 | ||
4e0b7b6d PG |
10175 | static struct cmd_node bgp_evpn_node = |
10176 | { | |
10177 | BGP_EVPN_NODE, | |
10178 | "%s(config-router-evpn)# ", | |
10179 | 1 | |
10180 | }; | |
10181 | ||
1f8ae70b | 10182 | static void community_list_vty (void); |
10183 | ||
718e3744 | 10184 | void |
94f2b392 | 10185 | bgp_vty_init (void) |
718e3744 | 10186 | { |
718e3744 | 10187 | /* Install bgp top node. */ |
10188 | install_node (&bgp_node, bgp_config_write); | |
10189 | install_node (&bgp_ipv4_unicast_node, NULL); | |
10190 | install_node (&bgp_ipv4_multicast_node, NULL); | |
f51bae9c | 10191 | install_node (&bgp_ipv4_labeled_unicast_node, NULL); |
718e3744 | 10192 | install_node (&bgp_ipv6_unicast_node, NULL); |
25ffbdc1 | 10193 | install_node (&bgp_ipv6_multicast_node, NULL); |
f51bae9c | 10194 | install_node (&bgp_ipv6_labeled_unicast_node, NULL); |
718e3744 | 10195 | install_node (&bgp_vpnv4_node, NULL); |
8ecd3266 | 10196 | install_node (&bgp_vpnv6_node, NULL); |
8b1fb8be LB |
10197 | install_node (&bgp_encap_node, NULL); |
10198 | install_node (&bgp_encapv6_node, NULL); | |
4e0b7b6d | 10199 | install_node (&bgp_evpn_node, NULL); |
718e3744 | 10200 | |
10201 | /* Install default VTY commands to new nodes. */ | |
10202 | install_default (BGP_NODE); | |
10203 | install_default (BGP_IPV4_NODE); | |
10204 | install_default (BGP_IPV4M_NODE); | |
f51bae9c | 10205 | install_default (BGP_IPV4L_NODE); |
718e3744 | 10206 | install_default (BGP_IPV6_NODE); |
25ffbdc1 | 10207 | install_default (BGP_IPV6M_NODE); |
f51bae9c | 10208 | install_default (BGP_IPV6L_NODE); |
718e3744 | 10209 | install_default (BGP_VPNV4_NODE); |
8ecd3266 | 10210 | install_default (BGP_VPNV6_NODE); |
8b1fb8be LB |
10211 | install_default (BGP_ENCAP_NODE); |
10212 | install_default (BGP_ENCAPV6_NODE); | |
4e0b7b6d | 10213 | install_default (BGP_EVPN_NODE); |
e52702f2 | 10214 | |
718e3744 | 10215 | /* "bgp multiple-instance" commands. */ |
10216 | install_element (CONFIG_NODE, &bgp_multiple_instance_cmd); | |
10217 | install_element (CONFIG_NODE, &no_bgp_multiple_instance_cmd); | |
10218 | ||
10219 | /* "bgp config-type" commands. */ | |
10220 | install_element (CONFIG_NODE, &bgp_config_type_cmd); | |
8c3deaae | 10221 | install_element (CONFIG_NODE, &no_bgp_config_type_cmd); |
718e3744 | 10222 | |
5fe9f963 | 10223 | /* bgp route-map delay-timer commands. */ |
10224 | install_element (CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
10225 | install_element (CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
5fe9f963 | 10226 | |
718e3744 | 10227 | /* Dummy commands (Currently not supported) */ |
10228 | install_element (BGP_NODE, &no_synchronization_cmd); | |
10229 | install_element (BGP_NODE, &no_auto_summary_cmd); | |
10230 | ||
10231 | /* "router bgp" commands. */ | |
10232 | install_element (CONFIG_NODE, &router_bgp_cmd); | |
718e3744 | 10233 | |
10234 | /* "no router bgp" commands. */ | |
10235 | install_element (CONFIG_NODE, &no_router_bgp_cmd); | |
718e3744 | 10236 | |
10237 | /* "bgp router-id" commands. */ | |
10238 | install_element (BGP_NODE, &bgp_router_id_cmd); | |
10239 | install_element (BGP_NODE, &no_bgp_router_id_cmd); | |
718e3744 | 10240 | |
10241 | /* "bgp cluster-id" commands. */ | |
10242 | install_element (BGP_NODE, &bgp_cluster_id_cmd); | |
718e3744 | 10243 | install_element (BGP_NODE, &no_bgp_cluster_id_cmd); |
718e3744 | 10244 | |
10245 | /* "bgp confederation" commands. */ | |
10246 | install_element (BGP_NODE, &bgp_confederation_identifier_cmd); | |
10247 | install_element (BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
718e3744 | 10248 | |
10249 | /* "bgp confederation peers" commands. */ | |
10250 | install_element (BGP_NODE, &bgp_confederation_peers_cmd); | |
10251 | install_element (BGP_NODE, &no_bgp_confederation_peers_cmd); | |
10252 | ||
abc920f8 DS |
10253 | /* bgp max-med command */ |
10254 | install_element (BGP_NODE, &bgp_maxmed_admin_cmd); | |
10255 | install_element (BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
10256 | install_element (BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
abc920f8 DS |
10257 | install_element (BGP_NODE, &bgp_maxmed_onstartup_cmd); |
10258 | install_element (BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
abc920f8 | 10259 | install_element (BGP_NODE, &bgp_maxmed_onstartup_medv_cmd); |
abc920f8 | 10260 | |
907f92c8 DS |
10261 | /* bgp disable-ebgp-connected-nh-check */ |
10262 | install_element (BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
10263 | install_element (BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
10264 | ||
f188f2c4 DS |
10265 | /* bgp update-delay command */ |
10266 | install_element (BGP_NODE, &bgp_update_delay_cmd); | |
10267 | install_element (BGP_NODE, &no_bgp_update_delay_cmd); | |
10268 | install_element (BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
f188f2c4 | 10269 | |
cb1faec9 DS |
10270 | install_element (BGP_NODE, &bgp_wpkt_quanta_cmd); |
10271 | install_element (BGP_NODE, &no_bgp_wpkt_quanta_cmd); | |
10272 | ||
3f9c7369 DS |
10273 | install_element (BGP_NODE, &bgp_coalesce_time_cmd); |
10274 | install_element (BGP_NODE, &no_bgp_coalesce_time_cmd); | |
10275 | ||
165b5fff JB |
10276 | /* "maximum-paths" commands. */ |
10277 | install_element (BGP_NODE, &bgp_maxpaths_cmd); | |
10278 | install_element (BGP_NODE, &no_bgp_maxpaths_cmd); | |
165b5fff JB |
10279 | install_element (BGP_IPV4_NODE, &bgp_maxpaths_cmd); |
10280 | install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
431aa9f9 DS |
10281 | install_element (BGP_IPV6_NODE, &bgp_maxpaths_cmd); |
10282 | install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
165b5fff | 10283 | install_element (BGP_NODE, &bgp_maxpaths_ibgp_cmd); |
f51bae9c | 10284 | install_element (BGP_NODE, &bgp_maxpaths_ibgp_cluster_cmd); |
165b5fff | 10285 | install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_cmd); |
165b5fff | 10286 | install_element (BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); |
f51bae9c | 10287 | install_element (BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); |
165b5fff | 10288 | install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); |
431aa9f9 | 10289 | install_element (BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); |
f51bae9c | 10290 | install_element (BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); |
431aa9f9 | 10291 | install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); |
165b5fff | 10292 | |
f51bae9c DS |
10293 | install_element (BGP_IPV4L_NODE, &bgp_maxpaths_cmd); |
10294 | install_element (BGP_IPV4L_NODE, &no_bgp_maxpaths_cmd); | |
10295 | install_element (BGP_IPV6L_NODE, &bgp_maxpaths_cmd); | |
10296 | install_element (BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
10297 | ||
10298 | install_element (BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cmd); | |
10299 | install_element (BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
10300 | install_element (BGP_IPV4L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
10301 | install_element (BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
10302 | install_element (BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
10303 | install_element (BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
10304 | ||
718e3744 | 10305 | /* "timers bgp" commands. */ |
10306 | install_element (BGP_NODE, &bgp_timers_cmd); | |
10307 | install_element (BGP_NODE, &no_bgp_timers_cmd); | |
718e3744 | 10308 | |
5fe9f963 | 10309 | /* route-map delay-timer commands - per instance for backwards compat. */ |
518f0eb1 DS |
10310 | install_element (BGP_NODE, &bgp_set_route_map_delay_timer_cmd); |
10311 | install_element (BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
10312 | ||
718e3744 | 10313 | /* "bgp client-to-client reflection" commands */ |
10314 | install_element (BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
10315 | install_element (BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
10316 | ||
10317 | /* "bgp always-compare-med" commands */ | |
10318 | install_element (BGP_NODE, &bgp_always_compare_med_cmd); | |
10319 | install_element (BGP_NODE, &no_bgp_always_compare_med_cmd); | |
e52702f2 | 10320 | |
718e3744 | 10321 | /* "bgp deterministic-med" commands */ |
10322 | install_element (BGP_NODE, &bgp_deterministic_med_cmd); | |
10323 | install_element (BGP_NODE, &no_bgp_deterministic_med_cmd); | |
538621f2 | 10324 | |
538621f2 | 10325 | /* "bgp graceful-restart" commands */ |
10326 | install_element (BGP_NODE, &bgp_graceful_restart_cmd); | |
10327 | install_element (BGP_NODE, &no_bgp_graceful_restart_cmd); | |
93406d87 | 10328 | install_element (BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
10329 | install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
eb6f1b41 PG |
10330 | install_element (BGP_NODE, &bgp_graceful_restart_restart_time_cmd); |
10331 | install_element (BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
e52702f2 | 10332 | |
43fc21b3 JC |
10333 | install_element (BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
10334 | install_element (BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
10335 | ||
718e3744 | 10336 | /* "bgp fast-external-failover" commands */ |
10337 | install_element (BGP_NODE, &bgp_fast_external_failover_cmd); | |
10338 | install_element (BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
10339 | ||
10340 | /* "bgp enforce-first-as" commands */ | |
10341 | install_element (BGP_NODE, &bgp_enforce_first_as_cmd); | |
10342 | install_element (BGP_NODE, &no_bgp_enforce_first_as_cmd); | |
10343 | ||
10344 | /* "bgp bestpath compare-routerid" commands */ | |
10345 | install_element (BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
10346 | install_element (BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
10347 | ||
10348 | /* "bgp bestpath as-path ignore" commands */ | |
10349 | install_element (BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
10350 | install_element (BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
10351 | ||
6811845b | 10352 | /* "bgp bestpath as-path confed" commands */ |
10353 | install_element (BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
10354 | install_element (BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
10355 | ||
2fdd455c PM |
10356 | /* "bgp bestpath as-path multipath-relax" commands */ |
10357 | install_element (BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
10358 | install_element (BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
10359 | ||
848973c7 | 10360 | /* "bgp log-neighbor-changes" commands */ |
10361 | install_element (BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
10362 | install_element (BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
10363 | ||
718e3744 | 10364 | /* "bgp bestpath med" commands */ |
10365 | install_element (BGP_NODE, &bgp_bestpath_med_cmd); | |
718e3744 | 10366 | install_element (BGP_NODE, &no_bgp_bestpath_med_cmd); |
718e3744 | 10367 | |
10368 | /* "no bgp default ipv4-unicast" commands. */ | |
10369 | install_element (BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
10370 | install_element (BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
e52702f2 | 10371 | |
718e3744 | 10372 | /* "bgp network import-check" commands. */ |
10373 | install_element (BGP_NODE, &bgp_network_import_check_cmd); | |
8233ef81 | 10374 | install_element (BGP_NODE, &bgp_network_import_check_exact_cmd); |
718e3744 | 10375 | install_element (BGP_NODE, &no_bgp_network_import_check_cmd); |
10376 | ||
10377 | /* "bgp default local-preference" commands. */ | |
10378 | install_element (BGP_NODE, &bgp_default_local_preference_cmd); | |
10379 | install_element (BGP_NODE, &no_bgp_default_local_preference_cmd); | |
718e3744 | 10380 | |
04b6bdc0 DW |
10381 | /* bgp default show-hostname */ |
10382 | install_element (BGP_NODE, &bgp_default_show_hostname_cmd); | |
10383 | install_element (BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
10384 | ||
3f9c7369 DS |
10385 | /* "bgp default subgroup-pkt-queue-max" commands. */ |
10386 | install_element (BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
10387 | install_element (BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
10388 | ||
8bd9d948 DS |
10389 | /* bgp ibgp-allow-policy-mods command */ |
10390 | install_element (BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
10391 | install_element (BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
10392 | ||
f14e6fdb DS |
10393 | /* "bgp listen limit" commands. */ |
10394 | install_element (BGP_NODE, &bgp_listen_limit_cmd); | |
10395 | install_element (BGP_NODE, &no_bgp_listen_limit_cmd); | |
10396 | ||
10397 | /* "bgp listen range" commands. */ | |
10398 | install_element (BGP_NODE, &bgp_listen_range_cmd); | |
10399 | install_element (BGP_NODE, &no_bgp_listen_range_cmd); | |
10400 | ||
718e3744 | 10401 | /* "neighbor remote-as" commands. */ |
10402 | install_element (BGP_NODE, &neighbor_remote_as_cmd); | |
a80beece | 10403 | install_element (BGP_NODE, &neighbor_interface_config_cmd); |
4c48cf63 | 10404 | install_element (BGP_NODE, &neighbor_interface_config_v6only_cmd); |
b3a39dc5 DD |
10405 | install_element (BGP_NODE, &neighbor_interface_config_remote_as_cmd); |
10406 | install_element (BGP_NODE, &neighbor_interface_v6only_config_remote_as_cmd); | |
718e3744 | 10407 | install_element (BGP_NODE, &no_neighbor_cmd); |
a80beece | 10408 | install_element (BGP_NODE, &no_neighbor_interface_config_cmd); |
718e3744 | 10409 | |
10410 | /* "neighbor peer-group" commands. */ | |
10411 | install_element (BGP_NODE, &neighbor_peer_group_cmd); | |
10412 | install_element (BGP_NODE, &no_neighbor_peer_group_cmd); | |
a80beece | 10413 | install_element (BGP_NODE, &no_neighbor_interface_peer_group_remote_as_cmd); |
718e3744 | 10414 | |
10415 | /* "neighbor local-as" commands. */ | |
10416 | install_element (BGP_NODE, &neighbor_local_as_cmd); | |
10417 | install_element (BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
9d3f9705 | 10418 | install_element (BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); |
718e3744 | 10419 | install_element (BGP_NODE, &no_neighbor_local_as_cmd); |
718e3744 | 10420 | |
3f9c7369 DS |
10421 | /* "neighbor solo" commands. */ |
10422 | install_element (BGP_NODE, &neighbor_solo_cmd); | |
10423 | install_element (BGP_NODE, &no_neighbor_solo_cmd); | |
10424 | ||
0df7c91f PJ |
10425 | /* "neighbor password" commands. */ |
10426 | install_element (BGP_NODE, &neighbor_password_cmd); | |
10427 | install_element (BGP_NODE, &no_neighbor_password_cmd); | |
10428 | ||
718e3744 | 10429 | /* "neighbor activate" commands. */ |
10430 | install_element (BGP_NODE, &neighbor_activate_cmd); | |
10431 | install_element (BGP_IPV4_NODE, &neighbor_activate_cmd); | |
10432 | install_element (BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
f51bae9c | 10433 | install_element (BGP_IPV4L_NODE, &neighbor_activate_cmd); |
718e3744 | 10434 | install_element (BGP_IPV6_NODE, &neighbor_activate_cmd); |
25ffbdc1 | 10435 | install_element (BGP_IPV6M_NODE, &neighbor_activate_cmd); |
f51bae9c | 10436 | install_element (BGP_IPV6L_NODE, &neighbor_activate_cmd); |
718e3744 | 10437 | install_element (BGP_VPNV4_NODE, &neighbor_activate_cmd); |
8ecd3266 | 10438 | install_element (BGP_VPNV6_NODE, &neighbor_activate_cmd); |
8b1fb8be LB |
10439 | install_element (BGP_ENCAP_NODE, &neighbor_activate_cmd); |
10440 | install_element (BGP_ENCAPV6_NODE, &neighbor_activate_cmd); | |
4e0b7b6d | 10441 | install_element (BGP_EVPN_NODE, &neighbor_activate_cmd); |
718e3744 | 10442 | |
10443 | /* "no neighbor activate" commands. */ | |
10444 | install_element (BGP_NODE, &no_neighbor_activate_cmd); | |
10445 | install_element (BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
10446 | install_element (BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
f51bae9c | 10447 | install_element (BGP_IPV4L_NODE, &no_neighbor_activate_cmd); |
718e3744 | 10448 | install_element (BGP_IPV6_NODE, &no_neighbor_activate_cmd); |
25ffbdc1 | 10449 | install_element (BGP_IPV6M_NODE, &no_neighbor_activate_cmd); |
f51bae9c | 10450 | install_element (BGP_IPV6L_NODE, &no_neighbor_activate_cmd); |
718e3744 | 10451 | install_element (BGP_VPNV4_NODE, &no_neighbor_activate_cmd); |
8ecd3266 | 10452 | install_element (BGP_VPNV6_NODE, &no_neighbor_activate_cmd); |
8b1fb8be LB |
10453 | install_element (BGP_ENCAP_NODE, &no_neighbor_activate_cmd); |
10454 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_activate_cmd); | |
4e0b7b6d | 10455 | install_element (BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
718e3744 | 10456 | |
c8560b44 DW |
10457 | /* "neighbor peer-group" set commands. |
10458 | * Long term we should only accept this command under BGP_NODE and not all of | |
10459 | * the afi/safi sub-contexts. For now though we need to accept it for backwards | |
10460 | * compatibility. This changed when we stopped requiring that peers be assigned | |
10461 | * to their peer-group under each address-family sub-context. | |
10462 | */ | |
718e3744 | 10463 | install_element (BGP_NODE, &neighbor_set_peer_group_cmd); |
10464 | install_element (BGP_IPV4_NODE, &neighbor_set_peer_group_cmd); | |
10465 | install_element (BGP_IPV4M_NODE, &neighbor_set_peer_group_cmd); | |
f51bae9c | 10466 | install_element (BGP_IPV4L_NODE, &neighbor_set_peer_group_cmd); |
718e3744 | 10467 | install_element (BGP_IPV6_NODE, &neighbor_set_peer_group_cmd); |
25ffbdc1 | 10468 | install_element (BGP_IPV6M_NODE, &neighbor_set_peer_group_cmd); |
f51bae9c | 10469 | install_element (BGP_IPV6L_NODE, &neighbor_set_peer_group_cmd); |
a58545bb | 10470 | install_element (BGP_VPNV4_NODE, &neighbor_set_peer_group_cmd); |
8ecd3266 | 10471 | install_element (BGP_VPNV6_NODE, &neighbor_set_peer_group_cmd); |
8b1fb8be LB |
10472 | install_element (BGP_ENCAP_NODE, &neighbor_set_peer_group_cmd); |
10473 | install_element (BGP_ENCAPV6_NODE, &neighbor_set_peer_group_cmd); | |
c8560b44 | 10474 | |
718e3744 | 10475 | /* "no neighbor peer-group unset" commands. */ |
10476 | install_element (BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
10477 | install_element (BGP_IPV4_NODE, &no_neighbor_set_peer_group_cmd); | |
10478 | install_element (BGP_IPV4M_NODE, &no_neighbor_set_peer_group_cmd); | |
f51bae9c | 10479 | install_element (BGP_IPV4L_NODE, &no_neighbor_set_peer_group_cmd); |
718e3744 | 10480 | install_element (BGP_IPV6_NODE, &no_neighbor_set_peer_group_cmd); |
25ffbdc1 | 10481 | install_element (BGP_IPV6M_NODE, &no_neighbor_set_peer_group_cmd); |
f51bae9c | 10482 | install_element (BGP_IPV6L_NODE, &no_neighbor_set_peer_group_cmd); |
a58545bb | 10483 | install_element (BGP_VPNV4_NODE, &no_neighbor_set_peer_group_cmd); |
8ecd3266 | 10484 | install_element (BGP_VPNV6_NODE, &no_neighbor_set_peer_group_cmd); |
8b1fb8be LB |
10485 | install_element (BGP_ENCAP_NODE, &no_neighbor_set_peer_group_cmd); |
10486 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_set_peer_group_cmd); | |
e52702f2 | 10487 | |
718e3744 | 10488 | /* "neighbor softreconfiguration inbound" commands.*/ |
10489 | install_element (BGP_NODE, &neighbor_soft_reconfiguration_cmd); | |
10490 | install_element (BGP_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
10491 | install_element (BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
10492 | install_element (BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
f51bae9c DS |
10493 | install_element (BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); |
10494 | install_element (BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
718e3744 | 10495 | install_element (BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); |
10496 | install_element (BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
10497 | install_element (BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
10498 | install_element (BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
25ffbdc1 | 10499 | install_element (BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); |
10500 | install_element (BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
f51bae9c DS |
10501 | install_element (BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); |
10502 | install_element (BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
a58545bb | 10503 | install_element (BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); |
10504 | install_element (BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
8ecd3266 | 10505 | install_element (BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); |
10506 | install_element (BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
8b1fb8be LB |
10507 | install_element (BGP_ENCAP_NODE, &neighbor_soft_reconfiguration_cmd); |
10508 | install_element (BGP_ENCAP_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
10509 | install_element (BGP_ENCAPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
10510 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
718e3744 | 10511 | |
10512 | /* "neighbor attribute-unchanged" commands. */ | |
10513 | install_element (BGP_NODE, &neighbor_attr_unchanged_cmd); | |
718e3744 | 10514 | install_element (BGP_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10515 | install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 10516 | install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10517 | install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 10518 | install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); |
f51bae9c DS |
10519 | install_element (BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); |
10520 | install_element (BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
718e3744 | 10521 | install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 10522 | install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); |
25ffbdc1 | 10523 | install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); |
25ffbdc1 | 10524 | install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); |
f51bae9c DS |
10525 | install_element (BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); |
10526 | install_element (BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
718e3744 | 10527 | install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 10528 | install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); |
8ecd3266 | 10529 | install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); |
8ecd3266 | 10530 | install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); |
8ecd3266 | 10531 | |
8b1fb8be | 10532 | install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged_cmd); |
8b1fb8be | 10533 | install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged_cmd); |
8b1fb8be LB |
10534 | |
10535 | install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged_cmd); | |
8b1fb8be | 10536 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10537 | |
4e0b7b6d PG |
10538 | install_element (BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); |
10539 | install_element (BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
10540 | ||
fee0f4c6 | 10541 | /* "nexthop-local unchanged" commands */ |
10542 | install_element (BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
10543 | install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_local_unchanged_cmd); | |
10544 | ||
718e3744 | 10545 | /* "neighbor next-hop-self" commands. */ |
10546 | install_element (BGP_NODE, &neighbor_nexthop_self_cmd); | |
10547 | install_element (BGP_NODE, &no_neighbor_nexthop_self_cmd); | |
10548 | install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
10549 | install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
10550 | install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
10551 | install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
f51bae9c DS |
10552 | install_element (BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); |
10553 | install_element (BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
718e3744 | 10554 | install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); |
10555 | install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
25ffbdc1 | 10556 | install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); |
10557 | install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
f51bae9c DS |
10558 | install_element (BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); |
10559 | install_element (BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
718e3744 | 10560 | install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); |
10561 | install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
8ecd3266 | 10562 | install_element (BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); |
10563 | install_element (BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
8b1fb8be LB |
10564 | install_element (BGP_ENCAP_NODE, &neighbor_nexthop_self_cmd); |
10565 | install_element (BGP_ENCAP_NODE, &no_neighbor_nexthop_self_cmd); | |
10566 | install_element (BGP_ENCAPV6_NODE, &neighbor_nexthop_self_cmd); | |
10567 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
718e3744 | 10568 | |
a538debe DS |
10569 | /* "neighbor next-hop-self force" commands. */ |
10570 | install_element (BGP_NODE, &neighbor_nexthop_self_force_cmd); | |
10571 | install_element (BGP_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10572 | install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); | |
10573 | install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10574 | install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); | |
10575 | install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
f51bae9c DS |
10576 | install_element (BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); |
10577 | install_element (BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
a538debe DS |
10578 | install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); |
10579 | install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10580 | install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); | |
10581 | install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
f51bae9c DS |
10582 | install_element (BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); |
10583 | install_element (BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
a538debe DS |
10584 | install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); |
10585 | install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
8ecd3266 | 10586 | install_element (BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
10587 | install_element (BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
a538debe | 10588 | |
c7122e14 DS |
10589 | /* "neighbor as-override" commands. */ |
10590 | install_element (BGP_NODE, &neighbor_as_override_cmd); | |
10591 | install_element (BGP_NODE, &no_neighbor_as_override_cmd); | |
10592 | install_element (BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
10593 | install_element (BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
10594 | install_element (BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
10595 | install_element (BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
f51bae9c DS |
10596 | install_element (BGP_IPV4L_NODE, &neighbor_as_override_cmd); |
10597 | install_element (BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
c7122e14 DS |
10598 | install_element (BGP_IPV6_NODE, &neighbor_as_override_cmd); |
10599 | install_element (BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
10600 | install_element (BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
10601 | install_element (BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
f51bae9c DS |
10602 | install_element (BGP_IPV6L_NODE, &neighbor_as_override_cmd); |
10603 | install_element (BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
c7122e14 DS |
10604 | install_element (BGP_VPNV4_NODE, &neighbor_as_override_cmd); |
10605 | install_element (BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
8ecd3266 | 10606 | install_element (BGP_VPNV6_NODE, &neighbor_as_override_cmd); |
10607 | install_element (BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
c7122e14 | 10608 | |
718e3744 | 10609 | /* "neighbor remove-private-AS" commands. */ |
10610 | install_element (BGP_NODE, &neighbor_remove_private_as_cmd); | |
10611 | install_element (BGP_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10612 | install_element (BGP_NODE, &neighbor_remove_private_as_all_cmd); |
10613 | install_element (BGP_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10614 | install_element (BGP_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10615 | install_element (BGP_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10616 | install_element (BGP_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10617 | install_element (BGP_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 10618 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); |
10619 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10620 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); |
10621 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10622 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10623 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10624 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10625 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 10626 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); |
10627 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10628 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); |
10629 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10630 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10631 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10632 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10633 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
f51bae9c DS |
10634 | install_element (BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); |
10635 | install_element (BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
10636 | install_element (BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
10637 | install_element (BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10638 | install_element (BGP_IPV4L_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10639 | install_element (BGP_IPV4L_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10640 | install_element (BGP_IPV4L_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10641 | install_element (BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 10642 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); |
10643 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10644 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); |
10645 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10646 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10647 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10648 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10649 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
25ffbdc1 | 10650 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); |
10651 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10652 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); |
10653 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10654 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10655 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10656 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10657 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
f51bae9c DS |
10658 | install_element (BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); |
10659 | install_element (BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
10660 | install_element (BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
10661 | install_element (BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10662 | install_element (BGP_IPV6L_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10663 | install_element (BGP_IPV6L_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10664 | install_element (BGP_IPV6L_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10665 | install_element (BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 10666 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); |
10667 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10668 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); |
10669 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10670 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10671 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10672 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10673 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
8ecd3266 | 10674 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); |
10675 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
10676 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
10677 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10678 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10679 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10680 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10681 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
8b1fb8be LB |
10682 | install_element (BGP_ENCAP_NODE, &neighbor_remove_private_as_cmd); |
10683 | install_element (BGP_ENCAP_NODE, &no_neighbor_remove_private_as_cmd); | |
10684 | install_element (BGP_ENCAPV6_NODE, &neighbor_remove_private_as_cmd); | |
10685 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
718e3744 | 10686 | |
10687 | /* "neighbor send-community" commands.*/ | |
10688 | install_element (BGP_NODE, &neighbor_send_community_cmd); | |
10689 | install_element (BGP_NODE, &neighbor_send_community_type_cmd); | |
10690 | install_element (BGP_NODE, &no_neighbor_send_community_cmd); | |
10691 | install_element (BGP_NODE, &no_neighbor_send_community_type_cmd); | |
10692 | install_element (BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
10693 | install_element (BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
10694 | install_element (BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
10695 | install_element (BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
10696 | install_element (BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
10697 | install_element (BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
10698 | install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
10699 | install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
f51bae9c DS |
10700 | install_element (BGP_IPV4L_NODE, &neighbor_send_community_cmd); |
10701 | install_element (BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
10702 | install_element (BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
10703 | install_element (BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
718e3744 | 10704 | install_element (BGP_IPV6_NODE, &neighbor_send_community_cmd); |
10705 | install_element (BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
10706 | install_element (BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
10707 | install_element (BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
25ffbdc1 | 10708 | install_element (BGP_IPV6M_NODE, &neighbor_send_community_cmd); |
10709 | install_element (BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
10710 | install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
10711 | install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
f51bae9c DS |
10712 | install_element (BGP_IPV6L_NODE, &neighbor_send_community_cmd); |
10713 | install_element (BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
10714 | install_element (BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
10715 | install_element (BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
718e3744 | 10716 | install_element (BGP_VPNV4_NODE, &neighbor_send_community_cmd); |
10717 | install_element (BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
10718 | install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
10719 | install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
8ecd3266 | 10720 | install_element (BGP_VPNV6_NODE, &neighbor_send_community_cmd); |
10721 | install_element (BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
10722 | install_element (BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
10723 | install_element (BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
8b1fb8be LB |
10724 | install_element (BGP_ENCAP_NODE, &neighbor_send_community_cmd); |
10725 | install_element (BGP_ENCAP_NODE, &neighbor_send_community_type_cmd); | |
10726 | install_element (BGP_ENCAP_NODE, &no_neighbor_send_community_cmd); | |
10727 | install_element (BGP_ENCAP_NODE, &no_neighbor_send_community_type_cmd); | |
10728 | install_element (BGP_ENCAPV6_NODE, &neighbor_send_community_cmd); | |
10729 | install_element (BGP_ENCAPV6_NODE, &neighbor_send_community_type_cmd); | |
10730 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_send_community_cmd); | |
10731 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_send_community_type_cmd); | |
718e3744 | 10732 | |
10733 | /* "neighbor route-reflector" commands.*/ | |
10734 | install_element (BGP_NODE, &neighbor_route_reflector_client_cmd); | |
10735 | install_element (BGP_NODE, &no_neighbor_route_reflector_client_cmd); | |
10736 | install_element (BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
10737 | install_element (BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
10738 | install_element (BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
10739 | install_element (BGP_IPV4M_NODE, &no_neighbor_route_reflector_client_cmd); | |
f51bae9c DS |
10740 | install_element (BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); |
10741 | install_element (BGP_IPV4L_NODE, &no_neighbor_route_reflector_client_cmd); | |
718e3744 | 10742 | install_element (BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); |
10743 | install_element (BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
25ffbdc1 | 10744 | install_element (BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); |
10745 | install_element (BGP_IPV6M_NODE, &no_neighbor_route_reflector_client_cmd); | |
f51bae9c DS |
10746 | install_element (BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); |
10747 | install_element (BGP_IPV6L_NODE, &no_neighbor_route_reflector_client_cmd); | |
718e3744 | 10748 | install_element (BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); |
10749 | install_element (BGP_VPNV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
8ecd3266 | 10750 | install_element (BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); |
10751 | install_element (BGP_VPNV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
8b1fb8be LB |
10752 | install_element (BGP_ENCAP_NODE, &neighbor_route_reflector_client_cmd); |
10753 | install_element (BGP_ENCAP_NODE, &no_neighbor_route_reflector_client_cmd); | |
10754 | install_element (BGP_ENCAPV6_NODE, &neighbor_route_reflector_client_cmd); | |
10755 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
718e3744 | 10756 | |
10757 | /* "neighbor route-server" commands.*/ | |
10758 | install_element (BGP_NODE, &neighbor_route_server_client_cmd); | |
10759 | install_element (BGP_NODE, &no_neighbor_route_server_client_cmd); | |
10760 | install_element (BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
10761 | install_element (BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
10762 | install_element (BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
10763 | install_element (BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
f51bae9c DS |
10764 | install_element (BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); |
10765 | install_element (BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
718e3744 | 10766 | install_element (BGP_IPV6_NODE, &neighbor_route_server_client_cmd); |
10767 | install_element (BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
25ffbdc1 | 10768 | install_element (BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); |
10769 | install_element (BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
f51bae9c DS |
10770 | install_element (BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); |
10771 | install_element (BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
718e3744 | 10772 | install_element (BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); |
10773 | install_element (BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
8ecd3266 | 10774 | install_element (BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); |
10775 | install_element (BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
8b1fb8be LB |
10776 | install_element (BGP_ENCAP_NODE, &neighbor_route_server_client_cmd); |
10777 | install_element (BGP_ENCAP_NODE, &no_neighbor_route_server_client_cmd); | |
10778 | install_element (BGP_ENCAPV6_NODE, &neighbor_route_server_client_cmd); | |
10779 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_server_client_cmd); | |
718e3744 | 10780 | |
adbac85e DW |
10781 | /* "neighbor addpath-tx-all-paths" commands.*/ |
10782 | install_element (BGP_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10783 | install_element (BGP_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10784 | install_element (BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10785 | install_element (BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10786 | install_element (BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10787 | install_element (BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
f51bae9c DS |
10788 | install_element (BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); |
10789 | install_element (BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
adbac85e DW |
10790 | install_element (BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); |
10791 | install_element (BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10792 | install_element (BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10793 | install_element (BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
f51bae9c DS |
10794 | install_element (BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); |
10795 | install_element (BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
adbac85e DW |
10796 | install_element (BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); |
10797 | install_element (BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
8ecd3266 | 10798 | install_element (BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); |
10799 | install_element (BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
adbac85e | 10800 | |
06370dac DW |
10801 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ |
10802 | install_element (BGP_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10803 | install_element (BGP_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10804 | install_element (BGP_IPV4_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10805 | install_element (BGP_IPV4_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10806 | install_element (BGP_IPV4M_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10807 | install_element (BGP_IPV4M_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
f51bae9c DS |
10808 | install_element (BGP_IPV4L_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); |
10809 | install_element (BGP_IPV4L_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
06370dac DW |
10810 | install_element (BGP_IPV6_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); |
10811 | install_element (BGP_IPV6_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10812 | install_element (BGP_IPV6M_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10813 | install_element (BGP_IPV6M_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
f51bae9c DS |
10814 | install_element (BGP_IPV6L_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); |
10815 | install_element (BGP_IPV6L_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
06370dac DW |
10816 | install_element (BGP_VPNV4_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); |
10817 | install_element (BGP_VPNV4_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
8ecd3266 | 10818 | install_element (BGP_VPNV6_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); |
10819 | install_element (BGP_VPNV6_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
06370dac | 10820 | |
718e3744 | 10821 | /* "neighbor passive" commands. */ |
10822 | install_element (BGP_NODE, &neighbor_passive_cmd); | |
10823 | install_element (BGP_NODE, &no_neighbor_passive_cmd); | |
10824 | ||
d5a5c8f0 | 10825 | |
718e3744 | 10826 | /* "neighbor shutdown" commands. */ |
10827 | install_element (BGP_NODE, &neighbor_shutdown_cmd); | |
10828 | install_element (BGP_NODE, &no_neighbor_shutdown_cmd); | |
73d70fa6 DL |
10829 | install_element (BGP_NODE, &neighbor_shutdown_msg_cmd); |
10830 | install_element (BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
718e3744 | 10831 | |
8a92a8a0 DS |
10832 | /* "neighbor capability extended-nexthop" commands.*/ |
10833 | install_element (BGP_NODE, &neighbor_capability_enhe_cmd); | |
10834 | install_element (BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
10835 | ||
718e3744 | 10836 | /* "neighbor capability orf prefix-list" commands.*/ |
10837 | install_element (BGP_NODE, &neighbor_capability_orf_prefix_cmd); | |
10838 | install_element (BGP_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
10839 | install_element (BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
10840 | install_element (BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
10841 | install_element (BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
10842 | install_element (BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
f51bae9c DS |
10843 | install_element (BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); |
10844 | install_element (BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
718e3744 | 10845 | install_element (BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); |
10846 | install_element (BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
25ffbdc1 | 10847 | install_element (BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); |
10848 | install_element (BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
f51bae9c DS |
10849 | install_element (BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); |
10850 | install_element (BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
718e3744 | 10851 | |
10852 | /* "neighbor capability dynamic" commands.*/ | |
10853 | install_element (BGP_NODE, &neighbor_capability_dynamic_cmd); | |
10854 | install_element (BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
10855 | ||
10856 | /* "neighbor dont-capability-negotiate" commands. */ | |
10857 | install_element (BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
10858 | install_element (BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
10859 | ||
10860 | /* "neighbor ebgp-multihop" commands. */ | |
10861 | install_element (BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
10862 | install_element (BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
10863 | install_element (BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
718e3744 | 10864 | |
6ffd2079 | 10865 | /* "neighbor disable-connected-check" commands. */ |
10866 | install_element (BGP_NODE, &neighbor_disable_connected_check_cmd); | |
10867 | install_element (BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
718e3744 | 10868 | |
10869 | /* "neighbor description" commands. */ | |
10870 | install_element (BGP_NODE, &neighbor_description_cmd); | |
10871 | install_element (BGP_NODE, &no_neighbor_description_cmd); | |
718e3744 | 10872 | |
10873 | /* "neighbor update-source" commands. "*/ | |
10874 | install_element (BGP_NODE, &neighbor_update_source_cmd); | |
10875 | install_element (BGP_NODE, &no_neighbor_update_source_cmd); | |
10876 | ||
10877 | /* "neighbor default-originate" commands. */ | |
10878 | install_element (BGP_NODE, &neighbor_default_originate_cmd); | |
10879 | install_element (BGP_NODE, &neighbor_default_originate_rmap_cmd); | |
10880 | install_element (BGP_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 10881 | install_element (BGP_IPV4_NODE, &neighbor_default_originate_cmd); |
10882 | install_element (BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
10883 | install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 10884 | install_element (BGP_IPV4M_NODE, &neighbor_default_originate_cmd); |
10885 | install_element (BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
10886 | install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
f51bae9c DS |
10887 | install_element (BGP_IPV4L_NODE, &neighbor_default_originate_cmd); |
10888 | install_element (BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
10889 | install_element (BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 10890 | install_element (BGP_IPV6_NODE, &neighbor_default_originate_cmd); |
10891 | install_element (BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
10892 | install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
25ffbdc1 | 10893 | install_element (BGP_IPV6M_NODE, &neighbor_default_originate_cmd); |
10894 | install_element (BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
10895 | install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
f51bae9c DS |
10896 | install_element (BGP_IPV6L_NODE, &neighbor_default_originate_cmd); |
10897 | install_element (BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
10898 | install_element (BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 10899 | |
10900 | /* "neighbor port" commands. */ | |
10901 | install_element (BGP_NODE, &neighbor_port_cmd); | |
10902 | install_element (BGP_NODE, &no_neighbor_port_cmd); | |
718e3744 | 10903 | |
10904 | /* "neighbor weight" commands. */ | |
10905 | install_element (BGP_NODE, &neighbor_weight_cmd); | |
10906 | install_element (BGP_NODE, &no_neighbor_weight_cmd); | |
718e3744 | 10907 | |
d93f7ffc DW |
10908 | install_element (BGP_IPV4_NODE, &neighbor_weight_cmd); |
10909 | install_element (BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10910 | install_element (BGP_IPV4M_NODE, &neighbor_weight_cmd); |
10911 | install_element (BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
f51bae9c DS |
10912 | install_element (BGP_IPV4L_NODE, &neighbor_weight_cmd); |
10913 | install_element (BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10914 | install_element (BGP_IPV6_NODE, &neighbor_weight_cmd); |
10915 | install_element (BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10916 | install_element (BGP_IPV6M_NODE, &neighbor_weight_cmd); |
10917 | install_element (BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
f51bae9c DS |
10918 | install_element (BGP_IPV6L_NODE, &neighbor_weight_cmd); |
10919 | install_element (BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10920 | install_element (BGP_VPNV4_NODE, &neighbor_weight_cmd); |
10921 | install_element (BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10922 | install_element (BGP_VPNV6_NODE, &neighbor_weight_cmd); |
10923 | install_element (BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10924 | install_element (BGP_ENCAP_NODE, &neighbor_weight_cmd); |
10925 | install_element (BGP_ENCAP_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10926 | install_element (BGP_ENCAPV6_NODE, &neighbor_weight_cmd); |
10927 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_weight_cmd); | |
718e3744 | 10928 | |
10929 | /* "neighbor override-capability" commands. */ | |
10930 | install_element (BGP_NODE, &neighbor_override_capability_cmd); | |
10931 | install_element (BGP_NODE, &no_neighbor_override_capability_cmd); | |
10932 | ||
10933 | /* "neighbor strict-capability-match" commands. */ | |
10934 | install_element (BGP_NODE, &neighbor_strict_capability_cmd); | |
10935 | install_element (BGP_NODE, &no_neighbor_strict_capability_cmd); | |
10936 | ||
10937 | /* "neighbor timers" commands. */ | |
10938 | install_element (BGP_NODE, &neighbor_timers_cmd); | |
10939 | install_element (BGP_NODE, &no_neighbor_timers_cmd); | |
10940 | ||
10941 | /* "neighbor timers connect" commands. */ | |
10942 | install_element (BGP_NODE, &neighbor_timers_connect_cmd); | |
10943 | install_element (BGP_NODE, &no_neighbor_timers_connect_cmd); | |
718e3744 | 10944 | |
10945 | /* "neighbor advertisement-interval" commands. */ | |
10946 | install_element (BGP_NODE, &neighbor_advertise_interval_cmd); | |
10947 | install_element (BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
718e3744 | 10948 | |
718e3744 | 10949 | /* "neighbor interface" commands. */ |
10950 | install_element (BGP_NODE, &neighbor_interface_cmd); | |
10951 | install_element (BGP_NODE, &no_neighbor_interface_cmd); | |
10952 | ||
10953 | /* "neighbor distribute" commands. */ | |
10954 | install_element (BGP_NODE, &neighbor_distribute_list_cmd); | |
10955 | install_element (BGP_NODE, &no_neighbor_distribute_list_cmd); | |
10956 | install_element (BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
10957 | install_element (BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
10958 | install_element (BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
10959 | install_element (BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
f51bae9c DS |
10960 | install_element (BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); |
10961 | install_element (BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
718e3744 | 10962 | install_element (BGP_IPV6_NODE, &neighbor_distribute_list_cmd); |
10963 | install_element (BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
25ffbdc1 | 10964 | install_element (BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); |
10965 | install_element (BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
f51bae9c DS |
10966 | install_element (BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); |
10967 | install_element (BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
718e3744 | 10968 | install_element (BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); |
10969 | install_element (BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
8ecd3266 | 10970 | install_element (BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); |
10971 | install_element (BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
8b1fb8be LB |
10972 | install_element (BGP_ENCAP_NODE, &neighbor_distribute_list_cmd); |
10973 | install_element (BGP_ENCAP_NODE, &no_neighbor_distribute_list_cmd); | |
10974 | install_element (BGP_ENCAPV6_NODE, &neighbor_distribute_list_cmd); | |
10975 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_distribute_list_cmd); | |
718e3744 | 10976 | |
10977 | /* "neighbor prefix-list" commands. */ | |
10978 | install_element (BGP_NODE, &neighbor_prefix_list_cmd); | |
10979 | install_element (BGP_NODE, &no_neighbor_prefix_list_cmd); | |
10980 | install_element (BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
10981 | install_element (BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
10982 | install_element (BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
10983 | install_element (BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
f51bae9c DS |
10984 | install_element (BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); |
10985 | install_element (BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
718e3744 | 10986 | install_element (BGP_IPV6_NODE, &neighbor_prefix_list_cmd); |
10987 | install_element (BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
25ffbdc1 | 10988 | install_element (BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); |
10989 | install_element (BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
f51bae9c DS |
10990 | install_element (BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); |
10991 | install_element (BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
718e3744 | 10992 | install_element (BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); |
10993 | install_element (BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
8ecd3266 | 10994 | install_element (BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); |
10995 | install_element (BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
8b1fb8be LB |
10996 | install_element (BGP_ENCAP_NODE, &neighbor_prefix_list_cmd); |
10997 | install_element (BGP_ENCAP_NODE, &no_neighbor_prefix_list_cmd); | |
10998 | install_element (BGP_ENCAPV6_NODE, &neighbor_prefix_list_cmd); | |
10999 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_prefix_list_cmd); | |
718e3744 | 11000 | |
11001 | /* "neighbor filter-list" commands. */ | |
11002 | install_element (BGP_NODE, &neighbor_filter_list_cmd); | |
11003 | install_element (BGP_NODE, &no_neighbor_filter_list_cmd); | |
11004 | install_element (BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
11005 | install_element (BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
11006 | install_element (BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
11007 | install_element (BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
f51bae9c DS |
11008 | install_element (BGP_IPV4L_NODE, &neighbor_filter_list_cmd); |
11009 | install_element (BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
718e3744 | 11010 | install_element (BGP_IPV6_NODE, &neighbor_filter_list_cmd); |
11011 | install_element (BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
25ffbdc1 | 11012 | install_element (BGP_IPV6M_NODE, &neighbor_filter_list_cmd); |
11013 | install_element (BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
f51bae9c DS |
11014 | install_element (BGP_IPV6L_NODE, &neighbor_filter_list_cmd); |
11015 | install_element (BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
718e3744 | 11016 | install_element (BGP_VPNV4_NODE, &neighbor_filter_list_cmd); |
11017 | install_element (BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
8ecd3266 | 11018 | install_element (BGP_VPNV6_NODE, &neighbor_filter_list_cmd); |
11019 | install_element (BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
8b1fb8be LB |
11020 | install_element (BGP_ENCAP_NODE, &neighbor_filter_list_cmd); |
11021 | install_element (BGP_ENCAP_NODE, &no_neighbor_filter_list_cmd); | |
11022 | install_element (BGP_ENCAPV6_NODE, &neighbor_filter_list_cmd); | |
11023 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_filter_list_cmd); | |
718e3744 | 11024 | |
11025 | /* "neighbor route-map" commands. */ | |
11026 | install_element (BGP_NODE, &neighbor_route_map_cmd); | |
11027 | install_element (BGP_NODE, &no_neighbor_route_map_cmd); | |
11028 | install_element (BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
11029 | install_element (BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
11030 | install_element (BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
11031 | install_element (BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
f51bae9c DS |
11032 | install_element (BGP_IPV4L_NODE, &neighbor_route_map_cmd); |
11033 | install_element (BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
718e3744 | 11034 | install_element (BGP_IPV6_NODE, &neighbor_route_map_cmd); |
11035 | install_element (BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
25ffbdc1 | 11036 | install_element (BGP_IPV6M_NODE, &neighbor_route_map_cmd); |
11037 | install_element (BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
f51bae9c DS |
11038 | install_element (BGP_IPV6L_NODE, &neighbor_route_map_cmd); |
11039 | install_element (BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
718e3744 | 11040 | install_element (BGP_VPNV4_NODE, &neighbor_route_map_cmd); |
11041 | install_element (BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
8ecd3266 | 11042 | install_element (BGP_VPNV6_NODE, &neighbor_route_map_cmd); |
11043 | install_element (BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
8b1fb8be LB |
11044 | install_element (BGP_ENCAP_NODE, &neighbor_route_map_cmd); |
11045 | install_element (BGP_ENCAP_NODE, &no_neighbor_route_map_cmd); | |
11046 | install_element (BGP_ENCAPV6_NODE, &neighbor_route_map_cmd); | |
11047 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_map_cmd); | |
718e3744 | 11048 | |
11049 | /* "neighbor unsuppress-map" commands. */ | |
11050 | install_element (BGP_NODE, &neighbor_unsuppress_map_cmd); | |
11051 | install_element (BGP_NODE, &no_neighbor_unsuppress_map_cmd); | |
11052 | install_element (BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
11053 | install_element (BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
11054 | install_element (BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
11055 | install_element (BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
f51bae9c DS |
11056 | install_element (BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); |
11057 | install_element (BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
718e3744 | 11058 | install_element (BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); |
11059 | install_element (BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
25ffbdc1 | 11060 | install_element (BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); |
11061 | install_element (BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
f51bae9c DS |
11062 | install_element (BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); |
11063 | install_element (BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
a58545bb | 11064 | install_element (BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); |
bb86c601 | 11065 | install_element (BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); |
8ecd3266 | 11066 | install_element (BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); |
bb86c601 | 11067 | install_element (BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); |
8b1fb8be LB |
11068 | install_element (BGP_ENCAP_NODE, &neighbor_unsuppress_map_cmd); |
11069 | install_element (BGP_ENCAP_NODE, &no_neighbor_unsuppress_map_cmd); | |
11070 | install_element (BGP_ENCAPV6_NODE, &neighbor_unsuppress_map_cmd); | |
11071 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
718e3744 | 11072 | |
11073 | /* "neighbor maximum-prefix" commands. */ | |
11074 | install_element (BGP_NODE, &neighbor_maximum_prefix_cmd); | |
e0701b79 | 11075 | install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 11076 | install_element (BGP_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 11077 | install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 11078 | install_element (BGP_NODE, &neighbor_maximum_prefix_restart_cmd); |
11079 | install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 11080 | install_element (BGP_NODE, &no_neighbor_maximum_prefix_cmd); |
718e3744 | 11081 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 11082 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 11083 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 11084 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 11085 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); |
11086 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 11087 | install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); |
718e3744 | 11088 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 11089 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 11090 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 11091 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 11092 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); |
11093 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 11094 | install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); |
f51bae9c DS |
11095 | install_element (BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); |
11096 | install_element (BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
11097 | install_element (BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
11098 | install_element (BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
11099 | install_element (BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
11100 | install_element (BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
11101 | install_element (BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
718e3744 | 11102 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 11103 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 11104 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 11105 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 11106 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); |
11107 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 11108 | install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); |
25ffbdc1 | 11109 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); |
11110 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
11111 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
11112 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
11113 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
11114 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
11115 | install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
f51bae9c DS |
11116 | install_element (BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); |
11117 | install_element (BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
11118 | install_element (BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
11119 | install_element (BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
11120 | install_element (BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
11121 | install_element (BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
11122 | install_element (BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
718e3744 | 11123 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 11124 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 11125 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 11126 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 11127 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); |
11128 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 11129 | install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); |
8ecd3266 | 11130 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); |
11131 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
11132 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
11133 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
11134 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
11135 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
11136 | install_element (BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
718e3744 | 11137 | |
8b1fb8be LB |
11138 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_cmd); |
11139 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
11140 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_warning_cmd); | |
11141 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
11142 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_restart_cmd); | |
11143 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
11144 | install_element (BGP_ENCAP_NODE, &no_neighbor_maximum_prefix_cmd); | |
8b1fb8be LB |
11145 | |
11146 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_cmd); | |
11147 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
11148 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
11149 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
11150 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
11151 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
11152 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
8b1fb8be | 11153 | |
718e3744 | 11154 | /* "neighbor allowas-in" */ |
11155 | install_element (BGP_NODE, &neighbor_allowas_in_cmd); | |
718e3744 | 11156 | install_element (BGP_NODE, &no_neighbor_allowas_in_cmd); |
11157 | install_element (BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
718e3744 | 11158 | install_element (BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); |
11159 | install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
718e3744 | 11160 | install_element (BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); |
f51bae9c DS |
11161 | install_element (BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); |
11162 | install_element (BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
718e3744 | 11163 | install_element (BGP_IPV6_NODE, &neighbor_allowas_in_cmd); |
718e3744 | 11164 | install_element (BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); |
25ffbdc1 | 11165 | install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); |
25ffbdc1 | 11166 | install_element (BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); |
f51bae9c DS |
11167 | install_element (BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); |
11168 | install_element (BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
718e3744 | 11169 | install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); |
718e3744 | 11170 | install_element (BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); |
8ecd3266 | 11171 | install_element (BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); |
8ecd3266 | 11172 | install_element (BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); |
8b1fb8be | 11173 | install_element (BGP_ENCAP_NODE, &neighbor_allowas_in_cmd); |
8b1fb8be LB |
11174 | install_element (BGP_ENCAP_NODE, &no_neighbor_allowas_in_cmd); |
11175 | install_element (BGP_ENCAPV6_NODE, &neighbor_allowas_in_cmd); | |
8b1fb8be | 11176 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_allowas_in_cmd); |
718e3744 | 11177 | |
11178 | /* address-family commands. */ | |
718e3744 | 11179 | install_element (BGP_NODE, &address_family_ipv4_safi_cmd); |
25ffbdc1 | 11180 | install_element (BGP_NODE, &address_family_ipv6_safi_cmd); |
d6902373 | 11181 | #ifdef KEEP_OLD_VPN_COMMANDS |
718e3744 | 11182 | install_element (BGP_NODE, &address_family_vpnv4_cmd); |
8b1fb8be | 11183 | install_element (BGP_NODE, &address_family_vpnv6_cmd); |
d6902373 | 11184 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be LB |
11185 | |
11186 | install_element (BGP_NODE, &address_family_encap_cmd); | |
8b1fb8be | 11187 | install_element (BGP_NODE, &address_family_encapv6_cmd); |
8b1fb8be | 11188 | |
4e0b7b6d PG |
11189 | install_element (BGP_NODE, &address_family_evpn_cmd); |
11190 | ||
718e3744 | 11191 | /* "exit-address-family" command. */ |
11192 | install_element (BGP_IPV4_NODE, &exit_address_family_cmd); | |
11193 | install_element (BGP_IPV4M_NODE, &exit_address_family_cmd); | |
f51bae9c | 11194 | install_element (BGP_IPV4L_NODE, &exit_address_family_cmd); |
718e3744 | 11195 | install_element (BGP_IPV6_NODE, &exit_address_family_cmd); |
25ffbdc1 | 11196 | install_element (BGP_IPV6M_NODE, &exit_address_family_cmd); |
f51bae9c | 11197 | install_element (BGP_IPV6L_NODE, &exit_address_family_cmd); |
718e3744 | 11198 | install_element (BGP_VPNV4_NODE, &exit_address_family_cmd); |
8ecd3266 | 11199 | install_element (BGP_VPNV6_NODE, &exit_address_family_cmd); |
8b1fb8be LB |
11200 | install_element (BGP_ENCAP_NODE, &exit_address_family_cmd); |
11201 | install_element (BGP_ENCAPV6_NODE, &exit_address_family_cmd); | |
4e0b7b6d | 11202 | install_element (BGP_EVPN_NODE, &exit_address_family_cmd); |
718e3744 | 11203 | |
11204 | /* "clear ip bgp commands" */ | |
11205 | install_element (ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
718e3744 | 11206 | |
8ad7271d DS |
11207 | /* clear ip bgp prefix */ |
11208 | install_element (ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
11209 | install_element (ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
01080f7c | 11210 | install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); |
8ad7271d | 11211 | |
716b2d8a | 11212 | /* "show [ip] bgp summary" commands. */ |
f186de26 | 11213 | install_element (VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); |
8386ac43 | 11214 | install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_cmd); |
8386ac43 | 11215 | install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_s_cmd); |
271ad8d5 | 11216 | install_element (VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
e52702f2 | 11217 | install_element (VIEW_NODE, &show_bgp_updgrps_adj_cmd); |
e52702f2 | 11218 | install_element (VIEW_NODE, &show_bgp_updgrps_adj_s_cmd); |
271ad8d5 | 11219 | install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_cmd); |
e52702f2 | 11220 | install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_s_cmd); |
8c3deaae | 11221 | install_element (VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
271ad8d5 QY |
11222 | install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_cmd); |
11223 | install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); | |
11224 | install_element (VIEW_NODE, &show_ip_bgp_summary_cmd); | |
11225 | install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_cmd); | |
11226 | install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_s_cmd); | |
11227 | install_element (VIEW_NODE, &show_ip_bgp_updgrps_cmd); | |
e3e29b32 | 11228 | |
716b2d8a | 11229 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 11230 | install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd); |
718e3744 | 11231 | |
716b2d8a | 11232 | /* "show [ip] bgp peer-group" commands. */ |
f14e6fdb | 11233 | install_element (VIEW_NODE, &show_ip_bgp_peer_groups_cmd); |
f14e6fdb | 11234 | |
716b2d8a | 11235 | /* "show [ip] bgp paths" commands. */ |
718e3744 | 11236 | install_element (VIEW_NODE, &show_ip_bgp_paths_cmd); |
718e3744 | 11237 | |
716b2d8a | 11238 | /* "show [ip] bgp community" commands. */ |
718e3744 | 11239 | install_element (VIEW_NODE, &show_ip_bgp_community_info_cmd); |
718e3744 | 11240 | |
57d187bc JS |
11241 | /* "show ip bgp large-community" commands. */ |
11242 | install_element (VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
716b2d8a | 11243 | /* "show [ip] bgp attribute-info" commands. */ |
718e3744 | 11244 | install_element (VIEW_NODE, &show_ip_bgp_attr_info_cmd); |
718e3744 | 11245 | |
11246 | /* "redistribute" commands. */ | |
11247 | install_element (BGP_NODE, &bgp_redistribute_ipv4_cmd); | |
11248 | install_element (BGP_NODE, &no_bgp_redistribute_ipv4_cmd); | |
11249 | install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
718e3744 | 11250 | install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_cmd); |
718e3744 | 11251 | install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); |
11252 | install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
7c8ff89e DS |
11253 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_cmd); |
11254 | install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
11255 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
7c8ff89e | 11256 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); |
7c8ff89e | 11257 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); |
7c8ff89e | 11258 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); |
919e0666 DW |
11259 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); |
11260 | install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
11261 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
919e0666 | 11262 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); |
919e0666 DW |
11263 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); |
11264 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
919e0666 DW |
11265 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); |
11266 | install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
11267 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
919e0666 | 11268 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); |
919e0666 | 11269 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); |
919e0666 | 11270 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); |
718e3744 | 11271 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); |
11272 | install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
11273 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
718e3744 | 11274 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); |
718e3744 | 11275 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); |
11276 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
718e3744 | 11277 | |
fa411a21 NH |
11278 | /* ttl_security commands */ |
11279 | install_element (BGP_NODE, &neighbor_ttl_security_cmd); | |
11280 | install_element (BGP_NODE, &no_neighbor_ttl_security_cmd); | |
11281 | ||
716b2d8a | 11282 | /* "show [ip] bgp memory" commands. */ |
4bf6a362 | 11283 | install_element (VIEW_NODE, &show_bgp_memory_cmd); |
e52702f2 | 11284 | |
716b2d8a | 11285 | /* "show [ip] bgp views" commands. */ |
e0081f70 | 11286 | install_element (VIEW_NODE, &show_bgp_views_cmd); |
e52702f2 | 11287 | |
716b2d8a | 11288 | /* "show [ip] bgp vrfs" commands. */ |
8386ac43 | 11289 | install_element (VIEW_NODE, &show_bgp_vrfs_cmd); |
e52702f2 | 11290 | |
718e3744 | 11291 | /* Community-list. */ |
11292 | community_list_vty (); | |
11293 | } | |
6b0655a2 | 11294 | |
718e3744 | 11295 | #include "memory.h" |
11296 | #include "bgp_regex.h" | |
11297 | #include "bgp_clist.h" | |
11298 | #include "bgp_ecommunity.h" | |
11299 | ||
11300 | /* VTY functions. */ | |
11301 | ||
11302 | /* Direction value to string conversion. */ | |
94f2b392 | 11303 | static const char * |
718e3744 | 11304 | community_direct_str (int direct) |
11305 | { | |
11306 | switch (direct) | |
11307 | { | |
11308 | case COMMUNITY_DENY: | |
11309 | return "deny"; | |
718e3744 | 11310 | case COMMUNITY_PERMIT: |
11311 | return "permit"; | |
718e3744 | 11312 | default: |
11313 | return "unknown"; | |
718e3744 | 11314 | } |
11315 | } | |
11316 | ||
11317 | /* Display error string. */ | |
94f2b392 | 11318 | static void |
718e3744 | 11319 | community_list_perror (struct vty *vty, int ret) |
11320 | { | |
11321 | switch (ret) | |
11322 | { | |
11323 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
b729294c | 11324 | vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE); |
718e3744 | 11325 | break; |
11326 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
11327 | vty_out (vty, "%% Malformed community-list value%s", VTY_NEWLINE); | |
11328 | break; | |
11329 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
11330 | vty_out (vty, "%% Community name conflict, previously defined as standard community%s", VTY_NEWLINE); | |
11331 | break; | |
11332 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
11333 | vty_out (vty, "%% Community name conflict, previously defined as expanded community%s", VTY_NEWLINE); | |
11334 | break; | |
11335 | } | |
11336 | } | |
11337 | ||
5bf15956 DW |
11338 | /* "community-list" keyword help string. */ |
11339 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
11340 | ||
718e3744 | 11341 | |
5bf15956 | 11342 | /* ip community-list standard */ |
718e3744 | 11343 | DEFUN (ip_community_list_standard, |
11344 | ip_community_list_standard_cmd, | |
e961923c | 11345 | "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 11346 | IP_STR |
11347 | COMMUNITY_LIST_STR | |
11348 | "Community list number (standard)\n" | |
5bf15956 | 11349 | "Add an standard community-list entry\n" |
718e3744 | 11350 | "Community list name\n" |
11351 | "Specify community to reject\n" | |
11352 | "Specify community to accept\n" | |
11353 | COMMUNITY_VAL_STR) | |
11354 | { | |
42f914d4 QY |
11355 | char *cl_name_or_number = NULL; |
11356 | int direct = 0; | |
11357 | int style = COMMUNITY_LIST_STANDARD; | |
11358 | ||
11359 | int idx = 0; | |
11360 | argv_find (argv, argc, "(1-99)", &idx); | |
11361 | argv_find (argv, argc, "WORD", &idx); | |
11362 | cl_name_or_number = argv[idx]->arg; | |
11363 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11364 | argv_find (argv, argc, "AA:NN", &idx); | |
11365 | char *str = argv_concat (argv, argc, idx); | |
11366 | ||
11367 | int ret = community_list_set (bgp_clist, cl_name_or_number, str, direct, style); | |
11368 | ||
11369 | XFREE (MTYPE_TMP, str); | |
11370 | ||
11371 | if (ret < 0) | |
11372 | { | |
11373 | /* Display error string. */ | |
11374 | community_list_perror (vty, ret); | |
11375 | return CMD_WARNING; | |
11376 | } | |
11377 | ||
11378 | return CMD_SUCCESS; | |
718e3744 | 11379 | } |
11380 | ||
fee6e4e4 | 11381 | DEFUN (no_ip_community_list_standard_all, |
11382 | no_ip_community_list_standard_all_cmd, | |
e961923c | 11383 | "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 11384 | NO_STR |
11385 | IP_STR | |
11386 | COMMUNITY_LIST_STR | |
11387 | "Community list number (standard)\n" | |
5bf15956 DW |
11388 | "Add an standard community-list entry\n" |
11389 | "Community list name\n" | |
718e3744 | 11390 | "Specify community to reject\n" |
11391 | "Specify community to accept\n" | |
11392 | COMMUNITY_VAL_STR) | |
11393 | { | |
42f914d4 QY |
11394 | int delete_all = 0; |
11395 | ||
11396 | char *cl_name_or_number = NULL; | |
11397 | int direct = 0; | |
11398 | int style = COMMUNITY_LIST_STANDARD; | |
11399 | ||
11400 | int idx = 0; | |
11401 | argv_find (argv, argc, "(1-99)", &idx); | |
11402 | argv_find (argv, argc, "WORD", &idx); | |
11403 | cl_name_or_number = argv[idx]->arg; | |
11404 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11405 | argv_find (argv, argc, "AA:NN", &idx); | |
11406 | char *str = argv_concat (argv, argc, idx); | |
11407 | ||
11408 | int ret = community_list_unset (bgp_clist, cl_name_or_number, str, direct, style, delete_all); | |
11409 | ||
daf9ddbb DS |
11410 | XFREE (MTYPE_TMP, str); |
11411 | ||
42f914d4 QY |
11412 | if (ret < 0) |
11413 | { | |
11414 | community_list_perror (vty, ret); | |
11415 | return CMD_WARNING; | |
11416 | } | |
11417 | ||
11418 | return CMD_SUCCESS; | |
718e3744 | 11419 | } |
11420 | ||
5bf15956 DW |
11421 | /* ip community-list expanded */ |
11422 | DEFUN (ip_community_list_expanded_all, | |
11423 | ip_community_list_expanded_all_cmd, | |
42f914d4 | 11424 | "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 11425 | IP_STR |
11426 | COMMUNITY_LIST_STR | |
11427 | "Community list number (expanded)\n" | |
5bf15956 | 11428 | "Add an expanded community-list entry\n" |
718e3744 | 11429 | "Community list name\n" |
11430 | "Specify community to reject\n" | |
11431 | "Specify community to accept\n" | |
11432 | COMMUNITY_VAL_STR) | |
11433 | { | |
42f914d4 QY |
11434 | char *cl_name_or_number = NULL; |
11435 | int direct = 0; | |
11436 | int style = COMMUNITY_LIST_EXPANDED; | |
11437 | ||
11438 | int idx = 0; | |
11439 | argv_find (argv, argc, "(100-500)", &idx); | |
11440 | argv_find (argv, argc, "WORD", &idx); | |
11441 | cl_name_or_number = argv[idx]->arg; | |
11442 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11443 | argv_find (argv, argc, "AA:NN", &idx); | |
11444 | char *str = argv_concat (argv, argc, idx); | |
11445 | ||
11446 | int ret = community_list_set (bgp_clist, cl_name_or_number, str, direct, style); | |
11447 | ||
11448 | XFREE (MTYPE_TMP, str); | |
11449 | ||
11450 | if (ret < 0) | |
11451 | { | |
11452 | /* Display error string. */ | |
11453 | community_list_perror (vty, ret); | |
11454 | return CMD_WARNING; | |
11455 | } | |
11456 | ||
11457 | return CMD_SUCCESS; | |
718e3744 | 11458 | } |
11459 | ||
5bf15956 DW |
11460 | DEFUN (no_ip_community_list_expanded_all, |
11461 | no_ip_community_list_expanded_all_cmd, | |
42f914d4 | 11462 | "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 11463 | NO_STR |
11464 | IP_STR | |
11465 | COMMUNITY_LIST_STR | |
5bf15956 DW |
11466 | "Community list number (expanded)\n" |
11467 | "Add an expanded community-list entry\n" | |
718e3744 | 11468 | "Community list name\n" |
11469 | "Specify community to reject\n" | |
11470 | "Specify community to accept\n" | |
5bf15956 | 11471 | COMMUNITY_VAL_STR) |
718e3744 | 11472 | { |
42f914d4 QY |
11473 | int delete_all = 0; |
11474 | ||
11475 | char *cl_name_or_number = NULL; | |
11476 | int direct = 0; | |
11477 | int style = COMMUNITY_LIST_EXPANDED; | |
11478 | ||
11479 | int idx = 0; | |
11480 | argv_find (argv, argc, "(100-500)", &idx); | |
11481 | argv_find (argv, argc, "WORD", &idx); | |
11482 | cl_name_or_number = argv[idx]->arg; | |
11483 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11484 | argv_find (argv, argc, "AA:NN", &idx); | |
11485 | char *str = argv_concat (argv, argc, idx); | |
11486 | ||
11487 | int ret = community_list_unset (bgp_clist, cl_name_or_number, str, direct, style, delete_all); | |
11488 | ||
daf9ddbb DS |
11489 | XFREE (MTYPE_TMP, str); |
11490 | ||
42f914d4 QY |
11491 | if (ret < 0) |
11492 | { | |
11493 | community_list_perror (vty, ret); | |
11494 | return CMD_WARNING; | |
11495 | } | |
11496 | ||
11497 | return CMD_SUCCESS; | |
718e3744 | 11498 | } |
11499 | ||
94f2b392 | 11500 | static void |
718e3744 | 11501 | community_list_show (struct vty *vty, struct community_list *list) |
11502 | { | |
11503 | struct community_entry *entry; | |
11504 | ||
11505 | for (entry = list->head; entry; entry = entry->next) | |
11506 | { | |
11507 | if (entry == list->head) | |
11508 | { | |
11509 | if (all_digit (list->name)) | |
11510 | vty_out (vty, "Community %s list %s%s", | |
11511 | entry->style == COMMUNITY_LIST_STANDARD ? | |
11512 | "standard" : "(expanded) access", | |
11513 | list->name, VTY_NEWLINE); | |
11514 | else | |
11515 | vty_out (vty, "Named Community %s list %s%s", | |
11516 | entry->style == COMMUNITY_LIST_STANDARD ? | |
11517 | "standard" : "expanded", | |
11518 | list->name, VTY_NEWLINE); | |
11519 | } | |
11520 | if (entry->any) | |
11521 | vty_out (vty, " %s%s", | |
11522 | community_direct_str (entry->direct), VTY_NEWLINE); | |
11523 | else | |
11524 | vty_out (vty, " %s %s%s", | |
11525 | community_direct_str (entry->direct), | |
11526 | entry->style == COMMUNITY_LIST_STANDARD | |
11527 | ? community_str (entry->u.com) : entry->config, | |
11528 | VTY_NEWLINE); | |
11529 | } | |
11530 | } | |
11531 | ||
11532 | DEFUN (show_ip_community_list, | |
11533 | show_ip_community_list_cmd, | |
11534 | "show ip community-list", | |
11535 | SHOW_STR | |
11536 | IP_STR | |
11537 | "List community-list\n") | |
11538 | { | |
11539 | struct community_list *list; | |
11540 | struct community_list_master *cm; | |
11541 | ||
fee6e4e4 | 11542 | cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER); |
718e3744 | 11543 | if (! cm) |
11544 | return CMD_SUCCESS; | |
11545 | ||
11546 | for (list = cm->num.head; list; list = list->next) | |
11547 | community_list_show (vty, list); | |
11548 | ||
11549 | for (list = cm->str.head; list; list = list->next) | |
11550 | community_list_show (vty, list); | |
11551 | ||
11552 | return CMD_SUCCESS; | |
11553 | } | |
11554 | ||
11555 | DEFUN (show_ip_community_list_arg, | |
11556 | show_ip_community_list_arg_cmd, | |
6147e2c6 | 11557 | "show ip community-list <(1-500)|WORD>", |
718e3744 | 11558 | SHOW_STR |
11559 | IP_STR | |
11560 | "List community-list\n" | |
11561 | "Community-list number\n" | |
11562 | "Community-list name\n") | |
11563 | { | |
c500ae40 | 11564 | int idx_comm_list = 3; |
718e3744 | 11565 | struct community_list *list; |
11566 | ||
c500ae40 | 11567 | list = community_list_lookup (bgp_clist, argv[idx_comm_list]->arg, COMMUNITY_LIST_MASTER); |
718e3744 | 11568 | if (! list) |
11569 | { | |
b729294c | 11570 | vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE); |
718e3744 | 11571 | return CMD_WARNING; |
11572 | } | |
11573 | ||
11574 | community_list_show (vty, list); | |
11575 | ||
11576 | return CMD_SUCCESS; | |
11577 | } | |
6b0655a2 | 11578 | |
57d187bc JS |
11579 | /* |
11580 | * Large Community code. | |
11581 | */ | |
11582 | static int | |
11583 | lcommunity_list_set_vty (struct vty *vty, int argc, struct cmd_token **argv, | |
2acb4ac2 | 11584 | int style, int reject_all_digit_name) |
57d187bc JS |
11585 | { |
11586 | int ret; | |
11587 | int direct; | |
11588 | char *str; | |
11589 | int idx = 0; | |
11590 | char *cl_name; | |
11591 | ||
11592 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11593 | ||
11594 | /* All digit name check. */ | |
11595 | idx = 0; | |
11596 | argv_find (argv, argc, "WORD", &idx); | |
11597 | argv_find (argv, argc, "(1-99)", &idx); | |
11598 | argv_find (argv, argc, "(100-500)", &idx); | |
11599 | cl_name = argv[idx]->arg; | |
11600 | if (reject_all_digit_name && all_digit (cl_name)) | |
11601 | { | |
11602 | vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE); | |
11603 | return CMD_WARNING; | |
11604 | } | |
11605 | ||
11606 | argv_find (argv, argc, "AA:BB:CC", &idx); | |
11607 | argv_find (argv, argc, "LINE", &idx); | |
11608 | /* Concat community string argument. */ | |
11609 | if (idx) | |
11610 | str = argv_concat (argv, argc, idx); | |
11611 | else | |
11612 | str = NULL; | |
11613 | ||
11614 | ret = lcommunity_list_set (bgp_clist, cl_name, str, direct, style); | |
11615 | ||
11616 | /* Free temporary community list string allocated by | |
11617 | argv_concat(). */ | |
11618 | if (str) | |
11619 | XFREE (MTYPE_TMP, str); | |
11620 | ||
11621 | if (ret < 0) | |
11622 | { | |
11623 | community_list_perror (vty, ret); | |
11624 | return CMD_WARNING; | |
11625 | } | |
11626 | return CMD_SUCCESS; | |
11627 | } | |
11628 | ||
11629 | static int | |
11630 | lcommunity_list_unset_vty (struct vty *vty, int argc, struct cmd_token **argv, | |
2acb4ac2 | 11631 | int style) |
57d187bc JS |
11632 | { |
11633 | int ret; | |
11634 | int direct = 0; | |
11635 | char *str = NULL; | |
11636 | int idx = 0; | |
11637 | ||
11638 | argv_find (argv, argc, "permit", &idx); | |
11639 | argv_find (argv, argc, "deny", &idx); | |
11640 | ||
11641 | if (idx) | |
11642 | { | |
11643 | /* Check the list direct. */ | |
11644 | if (strncmp (argv[idx]->arg, "p", 1) == 0) | |
2acb4ac2 | 11645 | direct = COMMUNITY_PERMIT; |
57d187bc | 11646 | else |
2acb4ac2 | 11647 | direct = COMMUNITY_DENY; |
57d187bc JS |
11648 | |
11649 | idx = 0; | |
11650 | argv_find (argv, argc, "LINE", &idx); | |
11651 | argv_find (argv, argc, "AA:AA:NN", &idx); | |
11652 | /* Concat community string argument. */ | |
11653 | str = argv_concat (argv, argc, idx); | |
11654 | } | |
11655 | ||
11656 | idx = 0; | |
11657 | argv_find (argv, argc, "(1-99)", &idx); | |
11658 | argv_find (argv, argc, "(100-500)", &idx); | |
11659 | argv_find (argv, argc, "WORD", &idx); | |
11660 | ||
11661 | /* Unset community list. */ | |
11662 | ret = lcommunity_list_unset (bgp_clist, argv[idx]->arg, str, direct, style); | |
11663 | ||
11664 | /* Free temporary community list string allocated by | |
11665 | argv_concat(). */ | |
11666 | if (str) | |
11667 | XFREE (MTYPE_TMP, str); | |
11668 | ||
11669 | if (ret < 0) | |
11670 | { | |
11671 | community_list_perror (vty, ret); | |
11672 | return CMD_WARNING; | |
11673 | } | |
11674 | ||
11675 | return CMD_SUCCESS; | |
11676 | } | |
11677 | ||
11678 | /* "large-community-list" keyword help string. */ | |
11679 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
11680 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
11681 | ||
11682 | DEFUN (ip_lcommunity_list_standard, | |
11683 | ip_lcommunity_list_standard_cmd, | |
52951b63 DS |
11684 | "ip large-community-list (1-99) <deny|permit>", |
11685 | IP_STR | |
11686 | LCOMMUNITY_LIST_STR | |
11687 | "Large Community list number (standard)\n" | |
11688 | "Specify large community to reject\n" | |
11689 | "Specify large community to accept\n" | |
11690 | LCOMMUNITY_VAL_STR) | |
11691 | { | |
11692 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD, 0); | |
11693 | } | |
11694 | ||
11695 | DEFUN (ip_lcommunity_list_standard1, | |
11696 | ip_lcommunity_list_standard1_cmd, | |
11697 | "ip large-community-list (1-99) <deny|permit> AA:BB:CC...", | |
57d187bc JS |
11698 | IP_STR |
11699 | LCOMMUNITY_LIST_STR | |
11700 | "Large Community list number (standard)\n" | |
11701 | "Specify large community to reject\n" | |
11702 | "Specify large community to accept\n" | |
11703 | LCOMMUNITY_VAL_STR) | |
11704 | { | |
11705 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD, 0); | |
11706 | } | |
11707 | ||
11708 | DEFUN (ip_lcommunity_list_expanded, | |
11709 | ip_lcommunity_list_expanded_cmd, | |
11710 | "ip large-community-list (100-500) <deny|permit> LINE...", | |
11711 | IP_STR | |
11712 | LCOMMUNITY_LIST_STR | |
11713 | "Large Community list number (expanded)\n" | |
11714 | "Specify large community to reject\n" | |
11715 | "Specify large community to accept\n" | |
11716 | "An ordered list as a regular-expression\n") | |
11717 | { | |
11718 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED, 0); | |
11719 | } | |
11720 | ||
11721 | DEFUN (ip_lcommunity_list_name_standard, | |
11722 | ip_lcommunity_list_name_standard_cmd, | |
52951b63 DS |
11723 | "ip large-community-list standard WORD <deny|permit>", |
11724 | IP_STR | |
11725 | LCOMMUNITY_LIST_STR | |
11726 | "Specify standard large-community-list\n" | |
11727 | "Large Community list name\n" | |
11728 | "Specify large community to reject\n" | |
11729 | "Specify large community to accept\n") | |
11730 | { | |
11731 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD, 1); | |
11732 | } | |
11733 | ||
11734 | DEFUN (ip_lcommunity_list_name_standard1, | |
11735 | ip_lcommunity_list_name_standard1_cmd, | |
11736 | "ip large-community-list standard WORD <deny|permit> AA:BB:CC...", | |
57d187bc JS |
11737 | IP_STR |
11738 | LCOMMUNITY_LIST_STR | |
11739 | "Specify standard large-community-list\n" | |
11740 | "Large Community list name\n" | |
11741 | "Specify large community to reject\n" | |
11742 | "Specify large community to accept\n" | |
11743 | LCOMMUNITY_VAL_STR) | |
11744 | { | |
11745 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD, 1); | |
11746 | } | |
11747 | ||
11748 | DEFUN (ip_lcommunity_list_name_expanded, | |
11749 | ip_lcommunity_list_name_expanded_cmd, | |
11750 | "ip large-community-list expanded WORD <deny|permit> LINE...", | |
11751 | IP_STR | |
11752 | LCOMMUNITY_LIST_STR | |
11753 | "Specify expanded large-community-list\n" | |
11754 | "Large Community list name\n" | |
11755 | "Specify large community to reject\n" | |
11756 | "Specify large community to accept\n" | |
11757 | "An ordered list as a regular-expression\n") | |
11758 | { | |
11759 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED, 1); | |
11760 | } | |
11761 | ||
11762 | DEFUN (no_ip_lcommunity_list_standard_all, | |
11763 | no_ip_lcommunity_list_standard_all_cmd, | |
11764 | "no ip large-community-list <(1-99)|(100-500)|WORD>", | |
11765 | NO_STR | |
11766 | IP_STR | |
11767 | LCOMMUNITY_LIST_STR | |
11768 | "Large Community list number (standard)\n" | |
11769 | "Large Community list number (expanded)\n" | |
11770 | "Large Community list name\n") | |
11771 | { | |
11772 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD); | |
11773 | } | |
11774 | ||
11775 | DEFUN (no_ip_lcommunity_list_name_expanded_all, | |
11776 | no_ip_lcommunity_list_name_expanded_all_cmd, | |
11777 | "no ip large-community-list expanded WORD", | |
11778 | NO_STR | |
11779 | IP_STR | |
11780 | LCOMMUNITY_LIST_STR | |
11781 | "Specify expanded large-community-list\n" | |
11782 | "Large Community list name\n") | |
11783 | { | |
11784 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED); | |
11785 | } | |
11786 | ||
11787 | DEFUN (no_ip_lcommunity_list_standard, | |
11788 | no_ip_lcommunity_list_standard_cmd, | |
11789 | "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...", | |
11790 | NO_STR | |
11791 | IP_STR | |
11792 | LCOMMUNITY_LIST_STR | |
11793 | "Large Community list number (standard)\n" | |
11794 | "Specify large community to reject\n" | |
11795 | "Specify large community to accept\n" | |
11796 | LCOMMUNITY_VAL_STR) | |
11797 | { | |
11798 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD); | |
11799 | } | |
11800 | ||
11801 | DEFUN (no_ip_lcommunity_list_expanded, | |
11802 | no_ip_lcommunity_list_expanded_cmd, | |
11803 | "no ip large-community-list (100-500) <deny|permit> LINE...", | |
11804 | NO_STR | |
11805 | IP_STR | |
11806 | LCOMMUNITY_LIST_STR | |
11807 | "Large Community list number (expanded)\n" | |
11808 | "Specify large community to reject\n" | |
11809 | "Specify large community to accept\n" | |
11810 | "An ordered list as a regular-expression\n") | |
11811 | { | |
11812 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED); | |
11813 | } | |
11814 | ||
11815 | DEFUN (no_ip_lcommunity_list_name_standard, | |
11816 | no_ip_lcommunity_list_name_standard_cmd, | |
11817 | "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...", | |
11818 | NO_STR | |
11819 | IP_STR | |
11820 | LCOMMUNITY_LIST_STR | |
11821 | "Specify standard large-community-list\n" | |
11822 | "Large Community list name\n" | |
11823 | "Specify large community to reject\n" | |
11824 | "Specify large community to accept\n" | |
11825 | LCOMMUNITY_VAL_STR) | |
11826 | { | |
11827 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD); | |
11828 | } | |
11829 | ||
11830 | DEFUN (no_ip_lcommunity_list_name_expanded, | |
11831 | no_ip_lcommunity_list_name_expanded_cmd, | |
11832 | "no ip large-community-list expanded WORD <deny|permit> LINE...", | |
11833 | NO_STR | |
11834 | IP_STR | |
11835 | LCOMMUNITY_LIST_STR | |
11836 | "Specify expanded large-community-list\n" | |
11837 | "Large community list name\n" | |
11838 | "Specify large community to reject\n" | |
11839 | "Specify large community to accept\n" | |
11840 | "An ordered list as a regular-expression\n") | |
11841 | { | |
11842 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED); | |
11843 | } | |
11844 | ||
11845 | static void | |
11846 | lcommunity_list_show (struct vty *vty, struct community_list *list) | |
11847 | { | |
11848 | struct community_entry *entry; | |
11849 | ||
11850 | for (entry = list->head; entry; entry = entry->next) | |
11851 | { | |
11852 | if (entry == list->head) | |
2acb4ac2 DL |
11853 | { |
11854 | if (all_digit (list->name)) | |
11855 | vty_out (vty, "Large community %s list %s%s", | |
11856 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
11857 | "standard" : "(expanded) access", | |
11858 | list->name, VTY_NEWLINE); | |
11859 | else | |
11860 | vty_out (vty, "Named large community %s list %s%s", | |
11861 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
11862 | "standard" : "expanded", | |
11863 | list->name, VTY_NEWLINE); | |
11864 | } | |
57d187bc | 11865 | if (entry->any) |
2acb4ac2 DL |
11866 | vty_out (vty, " %s%s", |
11867 | community_direct_str (entry->direct), VTY_NEWLINE); | |
57d187bc | 11868 | else |
2acb4ac2 DL |
11869 | vty_out (vty, " %s %s%s", |
11870 | community_direct_str (entry->direct), | |
11871 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
11872 | entry->u.ecom->str : entry->config, | |
11873 | VTY_NEWLINE); | |
57d187bc JS |
11874 | } |
11875 | } | |
11876 | ||
11877 | DEFUN (show_ip_lcommunity_list, | |
11878 | show_ip_lcommunity_list_cmd, | |
11879 | "show ip large-community-list", | |
11880 | SHOW_STR | |
11881 | IP_STR | |
11882 | "List large-community list\n") | |
11883 | { | |
11884 | struct community_list *list; | |
11885 | struct community_list_master *cm; | |
11886 | ||
11887 | cm = community_list_master_lookup (bgp_clist, LARGE_COMMUNITY_LIST_MASTER); | |
11888 | if (! cm) | |
11889 | return CMD_SUCCESS; | |
11890 | ||
11891 | for (list = cm->num.head; list; list = list->next) | |
11892 | lcommunity_list_show (vty, list); | |
11893 | ||
11894 | for (list = cm->str.head; list; list = list->next) | |
11895 | lcommunity_list_show (vty, list); | |
11896 | ||
11897 | return CMD_SUCCESS; | |
11898 | } | |
11899 | ||
11900 | DEFUN (show_ip_lcommunity_list_arg, | |
11901 | show_ip_lcommunity_list_arg_cmd, | |
11902 | "show ip large-community-list <(1-500)|WORD>", | |
11903 | SHOW_STR | |
11904 | IP_STR | |
11905 | "List large-community list\n" | |
11906 | "large-community-list number\n" | |
11907 | "large-community-list name\n") | |
11908 | { | |
11909 | struct community_list *list; | |
11910 | ||
11911 | list = community_list_lookup (bgp_clist, argv[3]->arg, LARGE_COMMUNITY_LIST_MASTER); | |
11912 | if (! list) | |
11913 | { | |
11914 | vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE); | |
11915 | return CMD_WARNING; | |
11916 | } | |
11917 | ||
11918 | lcommunity_list_show (vty, list); | |
11919 | ||
11920 | return CMD_SUCCESS; | |
11921 | } | |
11922 | ||
718e3744 | 11923 | /* "extcommunity-list" keyword help string. */ |
11924 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
11925 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
11926 | ||
11927 | DEFUN (ip_extcommunity_list_standard, | |
11928 | ip_extcommunity_list_standard_cmd, | |
e961923c | 11929 | "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 11930 | IP_STR |
11931 | EXTCOMMUNITY_LIST_STR | |
11932 | "Extended Community list number (standard)\n" | |
718e3744 | 11933 | "Specify standard extcommunity-list\n" |
5bf15956 | 11934 | "Community list name\n" |
718e3744 | 11935 | "Specify community to reject\n" |
11936 | "Specify community to accept\n" | |
11937 | EXTCOMMUNITY_VAL_STR) | |
11938 | { | |
42f914d4 QY |
11939 | int style = EXTCOMMUNITY_LIST_STANDARD; |
11940 | int direct = 0; | |
11941 | char *cl_number_or_name = NULL; | |
11942 | ||
11943 | int idx = 0; | |
11944 | argv_find (argv, argc, "(1-99)", &idx); | |
11945 | argv_find (argv, argc, "WORD", &idx); | |
11946 | cl_number_or_name = argv[idx]->arg; | |
11947 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11948 | argv_find (argv, argc, "AA:NN", &idx); | |
11949 | char *str = argv_concat (argv, argc, idx); | |
11950 | ||
11951 | int ret = extcommunity_list_set (bgp_clist, cl_number_or_name, str, direct, style); | |
11952 | ||
11953 | XFREE (MTYPE_TMP, str); | |
11954 | ||
11955 | if (ret < 0) | |
11956 | { | |
11957 | community_list_perror (vty, ret); | |
11958 | return CMD_WARNING; | |
11959 | } | |
11960 | ||
11961 | return CMD_SUCCESS; | |
718e3744 | 11962 | } |
11963 | ||
718e3744 | 11964 | DEFUN (ip_extcommunity_list_name_expanded, |
11965 | ip_extcommunity_list_name_expanded_cmd, | |
e961923c | 11966 | "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 11967 | IP_STR |
11968 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 11969 | "Extended Community list number (expanded)\n" |
718e3744 | 11970 | "Specify expanded extcommunity-list\n" |
11971 | "Extended Community list name\n" | |
11972 | "Specify community to reject\n" | |
11973 | "Specify community to accept\n" | |
11974 | "An ordered list as a regular-expression\n") | |
11975 | { | |
42f914d4 QY |
11976 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
11977 | int direct = 0; | |
11978 | char *cl_number_or_name = NULL; | |
11979 | ||
11980 | int idx = 0; | |
11981 | argv_find (argv, argc, "(100-500)", &idx); | |
11982 | argv_find (argv, argc, "WORD", &idx); | |
11983 | cl_number_or_name = argv[idx]->arg; | |
11984 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11985 | argv_find (argv, argc, "LINE", &idx); | |
11986 | char *str = argv_concat (argv, argc, idx); | |
11987 | ||
11988 | int ret = extcommunity_list_set (bgp_clist, cl_number_or_name, str, direct, style); | |
11989 | ||
11990 | XFREE (MTYPE_TMP, str); | |
11991 | ||
11992 | if (ret < 0) | |
11993 | { | |
11994 | community_list_perror (vty, ret); | |
11995 | return CMD_WARNING; | |
11996 | } | |
11997 | ||
11998 | return CMD_SUCCESS; | |
718e3744 | 11999 | } |
12000 | ||
fee6e4e4 | 12001 | DEFUN (no_ip_extcommunity_list_standard_all, |
12002 | no_ip_extcommunity_list_standard_all_cmd, | |
e961923c | 12003 | "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
813d4307 DW |
12004 | NO_STR |
12005 | IP_STR | |
12006 | EXTCOMMUNITY_LIST_STR | |
12007 | "Extended Community list number (standard)\n" | |
718e3744 | 12008 | "Specify standard extcommunity-list\n" |
5bf15956 | 12009 | "Community list name\n" |
718e3744 | 12010 | "Specify community to reject\n" |
12011 | "Specify community to accept\n" | |
12012 | EXTCOMMUNITY_VAL_STR) | |
12013 | { | |
42f914d4 QY |
12014 | int deleteall = 0; |
12015 | ||
12016 | int style = EXTCOMMUNITY_LIST_STANDARD; | |
12017 | int direct = 0; | |
12018 | char *cl_number_or_name = NULL; | |
12019 | ||
12020 | int idx = 0; | |
12021 | argv_find (argv, argc, "(1-99)", &idx); | |
12022 | argv_find (argv, argc, "WORD", &idx); | |
12023 | cl_number_or_name = argv[idx]->arg; | |
12024 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
12025 | argv_find (argv, argc, "AA:NN", &idx); | |
12026 | char *str = argv_concat (argv, argc, idx); | |
12027 | ||
12028 | int ret = extcommunity_list_unset (bgp_clist, cl_number_or_name, str, direct, style, deleteall); | |
12029 | ||
12030 | XFREE (MTYPE_TMP, str); | |
12031 | ||
12032 | if (ret < 0) | |
12033 | { | |
12034 | community_list_perror (vty, ret); | |
12035 | return CMD_WARNING; | |
12036 | } | |
12037 | ||
12038 | return CMD_SUCCESS; | |
718e3744 | 12039 | } |
12040 | ||
5bf15956 DW |
12041 | DEFUN (no_ip_extcommunity_list_expanded_all, |
12042 | no_ip_extcommunity_list_expanded_all_cmd, | |
e961923c | 12043 | "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 12044 | NO_STR |
12045 | IP_STR | |
12046 | EXTCOMMUNITY_LIST_STR | |
12047 | "Extended Community list number (expanded)\n" | |
718e3744 | 12048 | "Specify expanded extcommunity-list\n" |
5bf15956 | 12049 | "Extended Community list name\n" |
718e3744 | 12050 | "Specify community to reject\n" |
12051 | "Specify community to accept\n" | |
12052 | "An ordered list as a regular-expression\n") | |
12053 | { | |
42f914d4 QY |
12054 | int deleteall = 0; |
12055 | ||
12056 | int style = EXTCOMMUNITY_LIST_EXPANDED; | |
12057 | int direct = 0; | |
12058 | char *cl_number_or_name = NULL; | |
12059 | ||
12060 | int idx = 0; | |
12061 | argv_find (argv, argc, "(100-500)", &idx); | |
12062 | argv_find (argv, argc, "WORD", &idx); | |
12063 | cl_number_or_name = argv[idx]->arg; | |
12064 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
12065 | argv_find (argv, argc, "LINE", &idx); | |
12066 | char *str = argv_concat (argv, argc, idx); | |
12067 | ||
12068 | int ret = extcommunity_list_unset (bgp_clist, cl_number_or_name, str, direct, style, deleteall); | |
12069 | ||
12070 | XFREE (MTYPE_TMP, str); | |
12071 | ||
12072 | if (ret < 0) | |
12073 | { | |
12074 | community_list_perror (vty, ret); | |
12075 | return CMD_WARNING; | |
12076 | } | |
12077 | ||
12078 | return CMD_SUCCESS; | |
718e3744 | 12079 | } |
12080 | ||
94f2b392 | 12081 | static void |
718e3744 | 12082 | extcommunity_list_show (struct vty *vty, struct community_list *list) |
12083 | { | |
12084 | struct community_entry *entry; | |
12085 | ||
12086 | for (entry = list->head; entry; entry = entry->next) | |
12087 | { | |
12088 | if (entry == list->head) | |
12089 | { | |
12090 | if (all_digit (list->name)) | |
12091 | vty_out (vty, "Extended community %s list %s%s", | |
12092 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
12093 | "standard" : "(expanded) access", | |
12094 | list->name, VTY_NEWLINE); | |
12095 | else | |
12096 | vty_out (vty, "Named extended community %s list %s%s", | |
12097 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
12098 | "standard" : "expanded", | |
12099 | list->name, VTY_NEWLINE); | |
12100 | } | |
12101 | if (entry->any) | |
12102 | vty_out (vty, " %s%s", | |
12103 | community_direct_str (entry->direct), VTY_NEWLINE); | |
12104 | else | |
12105 | vty_out (vty, " %s %s%s", | |
12106 | community_direct_str (entry->direct), | |
12107 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
12108 | entry->u.ecom->str : entry->config, | |
12109 | VTY_NEWLINE); | |
12110 | } | |
12111 | } | |
12112 | ||
12113 | DEFUN (show_ip_extcommunity_list, | |
12114 | show_ip_extcommunity_list_cmd, | |
12115 | "show ip extcommunity-list", | |
12116 | SHOW_STR | |
12117 | IP_STR | |
12118 | "List extended-community list\n") | |
12119 | { | |
12120 | struct community_list *list; | |
12121 | struct community_list_master *cm; | |
12122 | ||
fee6e4e4 | 12123 | cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
718e3744 | 12124 | if (! cm) |
12125 | return CMD_SUCCESS; | |
12126 | ||
12127 | for (list = cm->num.head; list; list = list->next) | |
12128 | extcommunity_list_show (vty, list); | |
12129 | ||
12130 | for (list = cm->str.head; list; list = list->next) | |
12131 | extcommunity_list_show (vty, list); | |
12132 | ||
12133 | return CMD_SUCCESS; | |
12134 | } | |
12135 | ||
12136 | DEFUN (show_ip_extcommunity_list_arg, | |
12137 | show_ip_extcommunity_list_arg_cmd, | |
6147e2c6 | 12138 | "show ip extcommunity-list <(1-500)|WORD>", |
718e3744 | 12139 | SHOW_STR |
12140 | IP_STR | |
12141 | "List extended-community list\n" | |
12142 | "Extcommunity-list number\n" | |
12143 | "Extcommunity-list name\n") | |
12144 | { | |
c500ae40 | 12145 | int idx_comm_list = 3; |
718e3744 | 12146 | struct community_list *list; |
12147 | ||
c500ae40 | 12148 | list = community_list_lookup (bgp_clist, argv[idx_comm_list]->arg, EXTCOMMUNITY_LIST_MASTER); |
718e3744 | 12149 | if (! list) |
12150 | { | |
b729294c | 12151 | vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE); |
718e3744 | 12152 | return CMD_WARNING; |
12153 | } | |
12154 | ||
12155 | extcommunity_list_show (vty, list); | |
12156 | ||
12157 | return CMD_SUCCESS; | |
12158 | } | |
6b0655a2 | 12159 | |
718e3744 | 12160 | /* Return configuration string of community-list entry. */ |
fd79ac91 | 12161 | static const char * |
718e3744 | 12162 | community_list_config_str (struct community_entry *entry) |
12163 | { | |
fd79ac91 | 12164 | const char *str; |
718e3744 | 12165 | |
12166 | if (entry->any) | |
12167 | str = ""; | |
12168 | else | |
12169 | { | |
12170 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
12171 | str = community_str (entry->u.com); | |
12172 | else | |
12173 | str = entry->config; | |
12174 | } | |
12175 | return str; | |
12176 | } | |
12177 | ||
12178 | /* Display community-list and extcommunity-list configuration. */ | |
94f2b392 | 12179 | static int |
718e3744 | 12180 | community_list_config_write (struct vty *vty) |
12181 | { | |
12182 | struct community_list *list; | |
12183 | struct community_entry *entry; | |
12184 | struct community_list_master *cm; | |
12185 | int write = 0; | |
12186 | ||
12187 | /* Community-list. */ | |
fee6e4e4 | 12188 | cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER); |
718e3744 | 12189 | |
12190 | for (list = cm->num.head; list; list = list->next) | |
12191 | for (entry = list->head; entry; entry = entry->next) | |
12192 | { | |
fee6e4e4 | 12193 | vty_out (vty, "ip community-list %s %s %s%s", |
12194 | list->name, community_direct_str (entry->direct), | |
12195 | community_list_config_str (entry), | |
12196 | VTY_NEWLINE); | |
718e3744 | 12197 | write++; |
12198 | } | |
12199 | for (list = cm->str.head; list; list = list->next) | |
12200 | for (entry = list->head; entry; entry = entry->next) | |
12201 | { | |
12202 | vty_out (vty, "ip community-list %s %s %s %s%s", | |
12203 | entry->style == COMMUNITY_LIST_STANDARD | |
12204 | ? "standard" : "expanded", | |
12205 | list->name, community_direct_str (entry->direct), | |
12206 | community_list_config_str (entry), | |
12207 | VTY_NEWLINE); | |
12208 | write++; | |
12209 | } | |
12210 | ||
12211 | /* Extcommunity-list. */ | |
fee6e4e4 | 12212 | cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
718e3744 | 12213 | |
12214 | for (list = cm->num.head; list; list = list->next) | |
12215 | for (entry = list->head; entry; entry = entry->next) | |
12216 | { | |
fee6e4e4 | 12217 | vty_out (vty, "ip extcommunity-list %s %s %s%s", |
12218 | list->name, community_direct_str (entry->direct), | |
12219 | community_list_config_str (entry), VTY_NEWLINE); | |
718e3744 | 12220 | write++; |
12221 | } | |
12222 | for (list = cm->str.head; list; list = list->next) | |
12223 | for (entry = list->head; entry; entry = entry->next) | |
12224 | { | |
12225 | vty_out (vty, "ip extcommunity-list %s %s %s %s%s", | |
12226 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
12227 | ? "standard" : "expanded", | |
12228 | list->name, community_direct_str (entry->direct), | |
12229 | community_list_config_str (entry), VTY_NEWLINE); | |
12230 | write++; | |
12231 | } | |
57d187bc JS |
12232 | |
12233 | ||
12234 | /* lcommunity-list. */ | |
12235 | cm = community_list_master_lookup (bgp_clist, LARGE_COMMUNITY_LIST_MASTER); | |
12236 | ||
12237 | for (list = cm->num.head; list; list = list->next) | |
12238 | for (entry = list->head; entry; entry = entry->next) | |
12239 | { | |
2acb4ac2 DL |
12240 | vty_out (vty, "ip large-community-list %s %s %s%s", |
12241 | list->name, community_direct_str (entry->direct), | |
12242 | community_list_config_str (entry), VTY_NEWLINE); | |
12243 | write++; | |
57d187bc JS |
12244 | } |
12245 | for (list = cm->str.head; list; list = list->next) | |
12246 | for (entry = list->head; entry; entry = entry->next) | |
12247 | { | |
2acb4ac2 DL |
12248 | vty_out (vty, "ip large-community-list %s %s %s %s%s", |
12249 | entry->style == LARGE_COMMUNITY_LIST_STANDARD | |
12250 | ? "standard" : "expanded", | |
12251 | list->name, community_direct_str (entry->direct), | |
12252 | community_list_config_str (entry), VTY_NEWLINE); | |
12253 | write++; | |
57d187bc JS |
12254 | } |
12255 | ||
718e3744 | 12256 | return write; |
12257 | } | |
12258 | ||
7fc626de | 12259 | static struct cmd_node community_list_node = |
718e3744 | 12260 | { |
12261 | COMMUNITY_LIST_NODE, | |
12262 | "", | |
12263 | 1 /* Export to vtysh. */ | |
12264 | }; | |
12265 | ||
94f2b392 | 12266 | static void |
12267 | community_list_vty (void) | |
718e3744 | 12268 | { |
12269 | install_node (&community_list_node, community_list_config_write); | |
12270 | ||
12271 | /* Community-list. */ | |
718e3744 | 12272 | install_element (CONFIG_NODE, &ip_community_list_standard_cmd); |
d7d73ffc | 12273 | install_element (CONFIG_NODE, &ip_community_list_expanded_all_cmd); |
fee6e4e4 | 12274 | install_element (CONFIG_NODE, &no_ip_community_list_standard_all_cmd); |
12275 | install_element (CONFIG_NODE, &no_ip_community_list_expanded_all_cmd); | |
718e3744 | 12276 | install_element (VIEW_NODE, &show_ip_community_list_cmd); |
12277 | install_element (VIEW_NODE, &show_ip_community_list_arg_cmd); | |
718e3744 | 12278 | |
12279 | /* Extcommunity-list. */ | |
12280 | install_element (CONFIG_NODE, &ip_extcommunity_list_standard_cmd); | |
718e3744 | 12281 | install_element (CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd); |
fee6e4e4 | 12282 | install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd); |
12283 | install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd); | |
718e3744 | 12284 | install_element (VIEW_NODE, &show_ip_extcommunity_list_cmd); |
12285 | install_element (VIEW_NODE, &show_ip_extcommunity_list_arg_cmd); | |
57d187bc JS |
12286 | |
12287 | /* Large Community List */ | |
12288 | install_element (CONFIG_NODE, &ip_lcommunity_list_standard_cmd); | |
52951b63 | 12289 | install_element (CONFIG_NODE, &ip_lcommunity_list_standard1_cmd); |
57d187bc JS |
12290 | install_element (CONFIG_NODE, &ip_lcommunity_list_expanded_cmd); |
12291 | install_element (CONFIG_NODE, &ip_lcommunity_list_name_standard_cmd); | |
52951b63 | 12292 | install_element (CONFIG_NODE, &ip_lcommunity_list_name_standard1_cmd); |
57d187bc JS |
12293 | install_element (CONFIG_NODE, &ip_lcommunity_list_name_expanded_cmd); |
12294 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_standard_all_cmd); | |
12295 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_all_cmd); | |
12296 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_standard_cmd); | |
12297 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_expanded_cmd); | |
12298 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_name_standard_cmd); | |
12299 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_cmd); | |
12300 | install_element (VIEW_NODE, &show_ip_lcommunity_list_cmd); | |
12301 | install_element (VIEW_NODE, &show_ip_lcommunity_list_arg_cmd); | |
5bf15956 | 12302 | } |