]>
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 | 344 | vrf_name = argv[*idx + 1]->arg; |
af462945 | 345 | |
f212a857 DS |
346 | if (strmatch (vrf_name, "all")) |
347 | *bgp = NULL; | |
af462945 | 348 | else |
f212a857 DS |
349 | { |
350 | *bgp = bgp_lookup_by_name (vrf_name); | |
351 | if (!*bgp) | |
352 | { | |
353 | vty_out (vty, "View/Vrf specified is unknown: %s%s", vrf_name, VTY_NEWLINE); | |
354 | *idx = 0; | |
355 | return 0; | |
356 | } | |
357 | } | |
af462945 | 358 | } |
f212a857 | 359 | else |
af462945 | 360 | { |
f212a857 DS |
361 | *bgp = bgp_get_default (); |
362 | if (!*bgp) | |
363 | { | |
364 | vty_out (vty, "Unable to find default BGP instance%s", VTY_NEWLINE); | |
365 | *idx = 0; | |
366 | return 0; | |
367 | } | |
af462945 | 368 | } |
9317e17d | 369 | |
f212a857 DS |
370 | if (argv_find_and_parse_afi (argv, argc, idx, afi)) |
371 | argv_find_and_parse_safi (argv, argc, idx, safi); | |
372 | ||
9317e17d DS |
373 | *idx += 1; |
374 | return *idx; | |
af462945 DS |
375 | } |
376 | ||
94f2b392 | 377 | static int |
6aeb9e78 | 378 | peer_address_self_check (struct bgp *bgp, union sockunion *su) |
718e3744 | 379 | { |
380 | struct interface *ifp = NULL; | |
381 | ||
382 | if (su->sa.sa_family == AF_INET) | |
6aeb9e78 | 383 | ifp = if_lookup_by_ipv4_exact (&su->sin.sin_addr, bgp->vrf_id); |
718e3744 | 384 | else if (su->sa.sa_family == AF_INET6) |
f2345335 | 385 | ifp = if_lookup_by_ipv6_exact (&su->sin6.sin6_addr, |
6aeb9e78 | 386 | su->sin6.sin6_scope_id, bgp->vrf_id); |
718e3744 | 387 | |
388 | if (ifp) | |
389 | return 1; | |
390 | ||
391 | return 0; | |
392 | } | |
393 | ||
394 | /* Utility function for looking up peer from VTY. */ | |
f14e6fdb DS |
395 | /* This is used only for configuration, so disallow if attempted on |
396 | * a dynamic neighbor. | |
397 | */ | |
94f2b392 | 398 | static struct peer * |
fd79ac91 | 399 | peer_lookup_vty (struct vty *vty, const char *ip_str) |
718e3744 | 400 | { |
cdc2d765 | 401 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); |
718e3744 | 402 | int ret; |
718e3744 | 403 | union sockunion su; |
404 | struct peer *peer; | |
405 | ||
cdc2d765 DL |
406 | if (!bgp) { |
407 | return NULL; | |
408 | } | |
718e3744 | 409 | |
410 | ret = str2sockunion (ip_str, &su); | |
411 | if (ret < 0) | |
412 | { | |
a80beece DS |
413 | peer = peer_lookup_by_conf_if (bgp, ip_str); |
414 | if (!peer) | |
415 | { | |
04b6bdc0 DW |
416 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) == NULL) |
417 | { | |
418 | vty_out (vty, "%% Malformed address or name: %s%s", ip_str, VTY_NEWLINE); | |
419 | return NULL; | |
420 | } | |
a80beece | 421 | } |
718e3744 | 422 | } |
a80beece | 423 | else |
718e3744 | 424 | { |
a80beece DS |
425 | peer = peer_lookup (bgp, &su); |
426 | if (! peer) | |
427 | { | |
428 | vty_out (vty, "%% Specify remote-as or peer-group commands first%s", | |
429 | VTY_NEWLINE); | |
430 | return NULL; | |
431 | } | |
f14e6fdb DS |
432 | if (peer_dynamic_neighbor (peer)) |
433 | { | |
434 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
435 | VTY_NEWLINE); | |
436 | return NULL; | |
437 | } | |
438 | ||
718e3744 | 439 | } |
440 | return peer; | |
441 | } | |
442 | ||
443 | /* Utility function for looking up peer or peer group. */ | |
f14e6fdb DS |
444 | /* This is used only for configuration, so disallow if attempted on |
445 | * a dynamic neighbor. | |
446 | */ | |
c43ed2e4 | 447 | struct peer * |
fd79ac91 | 448 | peer_and_group_lookup_vty (struct vty *vty, const char *peer_str) |
718e3744 | 449 | { |
cdc2d765 | 450 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); |
718e3744 | 451 | int ret; |
718e3744 | 452 | union sockunion su; |
f14e6fdb DS |
453 | struct peer *peer = NULL; |
454 | struct peer_group *group = NULL; | |
718e3744 | 455 | |
cdc2d765 DL |
456 | if (!bgp) { |
457 | return NULL; | |
458 | } | |
718e3744 | 459 | |
460 | ret = str2sockunion (peer_str, &su); | |
461 | if (ret == 0) | |
462 | { | |
f14e6fdb | 463 | /* IP address, locate peer. */ |
718e3744 | 464 | peer = peer_lookup (bgp, &su); |
718e3744 | 465 | } |
466 | else | |
467 | { | |
f14e6fdb | 468 | /* Not IP, could match either peer configured on interface or a group. */ |
a80beece | 469 | peer = peer_lookup_by_conf_if (bgp, peer_str); |
f14e6fdb DS |
470 | if (!peer) |
471 | group = peer_group_lookup (bgp, peer_str); | |
472 | } | |
a80beece | 473 | |
f14e6fdb DS |
474 | if (peer) |
475 | { | |
476 | if (peer_dynamic_neighbor (peer)) | |
477 | { | |
478 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
479 | VTY_NEWLINE); | |
480 | return NULL; | |
481 | } | |
482 | ||
483 | return peer; | |
718e3744 | 484 | } |
485 | ||
f14e6fdb DS |
486 | if (group) |
487 | return group->conf; | |
488 | ||
718e3744 | 489 | vty_out (vty, "%% Specify remote-as or peer-group commands first%s", |
490 | VTY_NEWLINE); | |
491 | ||
492 | return NULL; | |
493 | } | |
494 | ||
c43ed2e4 | 495 | int |
718e3744 | 496 | bgp_vty_return (struct vty *vty, int ret) |
497 | { | |
fd79ac91 | 498 | const char *str = NULL; |
718e3744 | 499 | |
500 | switch (ret) | |
501 | { | |
502 | case BGP_ERR_INVALID_VALUE: | |
503 | str = "Invalid value"; | |
504 | break; | |
505 | case BGP_ERR_INVALID_FLAG: | |
506 | str = "Invalid flag"; | |
507 | break; | |
718e3744 | 508 | case BGP_ERR_PEER_GROUP_SHUTDOWN: |
509 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
510 | break; | |
718e3744 | 511 | case BGP_ERR_PEER_FLAG_CONFLICT: |
512 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
513 | break; | |
718e3744 | 514 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: |
515 | str = "Specify remote-as or peer-group remote AS first"; | |
516 | break; | |
517 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
518 | str = "Cannot change the peer-group. Deconfigure first"; | |
519 | break; | |
520 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
4c48cf63 | 521 | str = "Peer is not a member of this peer-group"; |
718e3744 | 522 | break; |
523 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
524 | str = "Prefix/distribute list can not co-exist"; | |
525 | break; | |
526 | case BGP_ERR_NOT_INTERNAL_PEER: | |
527 | str = "Invalid command. Not an internal neighbor"; | |
528 | break; | |
529 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
5000f21c | 530 | str = "remove-private-AS cannot be configured for IBGP peers"; |
718e3744 | 531 | break; |
532 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
533 | str = "Local-AS allowed only for EBGP peers"; | |
534 | break; | |
535 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
536 | str = "Cannot have local-as same as BGP AS number"; | |
537 | break; | |
0df7c91f PJ |
538 | case BGP_ERR_TCPSIG_FAILED: |
539 | str = "Error while applying TCP-Sig to session(s)"; | |
540 | break; | |
fa411a21 NH |
541 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: |
542 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
543 | break; | |
f5a4827d SH |
544 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: |
545 | str = "ttl-security only allowed for EBGP peers"; | |
546 | break; | |
c7122e14 DS |
547 | case BGP_ERR_AS_OVERRIDE: |
548 | str = "as-override cannot be configured for IBGP peers"; | |
549 | break; | |
f14e6fdb DS |
550 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: |
551 | str = "Invalid limit for number of dynamic neighbors"; | |
552 | break; | |
553 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
554 | str = "Dynamic neighbor listen range already exists"; | |
555 | break; | |
556 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
557 | str = "Operation not allowed on a dynamic neighbor"; | |
558 | break; | |
63fa10b5 QY |
559 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: |
560 | str = "Operation not allowed on a directly connected neighbor"; | |
561 | break; | |
718e3744 | 562 | } |
563 | if (str) | |
564 | { | |
565 | vty_out (vty, "%% %s%s", str, VTY_NEWLINE); | |
566 | return CMD_WARNING; | |
567 | } | |
568 | return CMD_SUCCESS; | |
569 | } | |
570 | ||
7aafcaca DS |
571 | /* BGP clear sort. */ |
572 | enum clear_sort | |
573 | { | |
574 | clear_all, | |
575 | clear_peer, | |
576 | clear_group, | |
577 | clear_external, | |
578 | clear_as | |
579 | }; | |
580 | ||
7aafcaca DS |
581 | static void |
582 | bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi, | |
583 | safi_t safi, int error) | |
584 | { | |
585 | switch (error) | |
586 | { | |
587 | case BGP_ERR_AF_UNCONFIGURED: | |
588 | vty_out (vty, | |
46f296b4 LB |
589 | "%%BGP: Enable %s address family for the neighbor %s%s", |
590 | afi_safi_print(afi, safi), peer->host, VTY_NEWLINE); | |
7aafcaca DS |
591 | break; |
592 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
593 | 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); | |
594 | break; | |
595 | default: | |
596 | break; | |
597 | } | |
598 | } | |
599 | ||
600 | /* `clear ip bgp' functions. */ | |
601 | static int | |
602 | bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, | |
603 | enum clear_sort sort,enum bgp_clear_type stype, const char *arg) | |
604 | { | |
605 | int ret; | |
606 | struct peer *peer; | |
607 | struct listnode *node, *nnode; | |
608 | ||
609 | /* Clear all neighbors. */ | |
610 | /* | |
611 | * Pass along pointer to next node to peer_clear() when walking all nodes | |
612 | * on the BGP instance as that may get freed if it is a doppelganger | |
613 | */ | |
614 | if (sort == clear_all) | |
615 | { | |
616 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
617 | { | |
618 | if (stype == BGP_CLEAR_SOFT_NONE) | |
619 | ret = peer_clear (peer, &nnode); | |
620 | else if (peer->afc[afi][safi]) | |
621 | ret = peer_clear_soft (peer, afi, safi, stype); | |
622 | else | |
623 | ret = 0; | |
624 | ||
625 | if (ret < 0) | |
626 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
627 | } | |
628 | ||
629 | /* This is to apply read-only mode on this clear. */ | |
630 | if (stype == BGP_CLEAR_SOFT_NONE) | |
631 | bgp->update_delay_over = 0; | |
632 | ||
633 | return CMD_SUCCESS; | |
634 | } | |
635 | ||
636 | /* Clear specified neighbors. */ | |
637 | if (sort == clear_peer) | |
638 | { | |
639 | union sockunion su; | |
640 | int ret; | |
641 | ||
642 | /* Make sockunion for lookup. */ | |
643 | ret = str2sockunion (arg, &su); | |
644 | if (ret < 0) | |
645 | { | |
646 | peer = peer_lookup_by_conf_if (bgp, arg); | |
647 | if (!peer) | |
648 | { | |
04b6bdc0 DW |
649 | peer = peer_lookup_by_hostname(bgp, arg); |
650 | if (!peer) | |
651 | { | |
652 | vty_out (vty, "Malformed address or name: %s%s", arg, VTY_NEWLINE); | |
653 | return CMD_WARNING; | |
654 | } | |
7aafcaca DS |
655 | } |
656 | } | |
657 | else | |
658 | { | |
659 | peer = peer_lookup (bgp, &su); | |
660 | if (! peer) | |
661 | { | |
662 | vty_out (vty, "%%BGP: Unknown neighbor - \"%s\"%s", arg, VTY_NEWLINE); | |
663 | return CMD_WARNING; | |
664 | } | |
665 | } | |
666 | ||
667 | if (stype == BGP_CLEAR_SOFT_NONE) | |
668 | ret = peer_clear (peer, NULL); | |
669 | else | |
670 | ret = peer_clear_soft (peer, afi, safi, stype); | |
671 | ||
672 | if (ret < 0) | |
673 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
674 | ||
675 | return CMD_SUCCESS; | |
676 | } | |
677 | ||
678 | /* Clear all peer-group members. */ | |
679 | if (sort == clear_group) | |
680 | { | |
681 | struct peer_group *group; | |
682 | ||
683 | group = peer_group_lookup (bgp, arg); | |
684 | if (! group) | |
685 | { | |
686 | vty_out (vty, "%%BGP: No such peer-group %s%s", arg, VTY_NEWLINE); | |
687 | return CMD_WARNING; | |
688 | } | |
689 | ||
690 | for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) | |
691 | { | |
692 | if (stype == BGP_CLEAR_SOFT_NONE) | |
693 | { | |
18f1dc06 | 694 | peer_clear (peer, NULL); |
7aafcaca DS |
695 | continue; |
696 | } | |
697 | ||
c8560b44 | 698 | if (! peer->afc[afi][safi]) |
7aafcaca DS |
699 | continue; |
700 | ||
701 | ret = peer_clear_soft (peer, afi, safi, stype); | |
702 | ||
703 | if (ret < 0) | |
704 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
705 | } | |
706 | return CMD_SUCCESS; | |
707 | } | |
708 | ||
709 | if (sort == clear_external) | |
710 | { | |
711 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
712 | { | |
713 | if (peer->sort == BGP_PEER_IBGP) | |
714 | continue; | |
715 | ||
716 | if (stype == BGP_CLEAR_SOFT_NONE) | |
717 | ret = peer_clear (peer, &nnode); | |
718 | else | |
719 | ret = peer_clear_soft (peer, afi, safi, stype); | |
720 | ||
721 | if (ret < 0) | |
722 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
723 | } | |
724 | return CMD_SUCCESS; | |
725 | } | |
726 | ||
727 | if (sort == clear_as) | |
728 | { | |
729 | as_t as; | |
730 | int find = 0; | |
731 | ||
732 | VTY_GET_INTEGER_RANGE ("AS", as, arg, 1, BGP_AS4_MAX); | |
733 | ||
734 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
735 | { | |
736 | if (peer->as != as) | |
737 | continue; | |
738 | ||
739 | find = 1; | |
740 | if (stype == BGP_CLEAR_SOFT_NONE) | |
741 | ret = peer_clear (peer, &nnode); | |
742 | else | |
743 | ret = peer_clear_soft (peer, afi, safi, stype); | |
744 | ||
745 | if (ret < 0) | |
746 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
747 | } | |
748 | if (! find) | |
749 | vty_out (vty, "%%BGP: No peer is configured with AS %s%s", arg, | |
750 | VTY_NEWLINE); | |
751 | return CMD_SUCCESS; | |
752 | } | |
753 | ||
754 | return CMD_SUCCESS; | |
755 | } | |
756 | ||
757 | static int | |
758 | bgp_clear_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi, | |
759 | enum clear_sort sort, enum bgp_clear_type stype, | |
760 | const char *arg) | |
761 | { | |
762 | struct bgp *bgp; | |
763 | ||
764 | /* BGP structure lookup. */ | |
765 | if (name) | |
766 | { | |
767 | bgp = bgp_lookup_by_name (name); | |
768 | if (bgp == NULL) | |
769 | { | |
6aeb9e78 | 770 | vty_out (vty, "Can't find BGP instance %s%s", name, VTY_NEWLINE); |
7aafcaca DS |
771 | return CMD_WARNING; |
772 | } | |
773 | } | |
774 | else | |
775 | { | |
f31fa004 | 776 | bgp = bgp_get_default (); |
7aafcaca DS |
777 | if (bgp == NULL) |
778 | { | |
779 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
780 | return CMD_WARNING; | |
781 | } | |
782 | } | |
783 | ||
784 | return bgp_clear (vty, bgp, afi, safi, sort, stype, arg); | |
785 | } | |
786 | ||
787 | /* clear soft inbound */ | |
788 | static void | |
f31fa004 | 789 | bgp_clear_star_soft_in (struct vty *vty, const char *name) |
7aafcaca | 790 | { |
b09b5ae0 | 791 | bgp_clear_vty (vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
7aafcaca | 792 | BGP_CLEAR_SOFT_IN, NULL); |
f31fa004 | 793 | bgp_clear_vty (vty, name, AFI_IP6, SAFI_UNICAST, clear_all, |
7aafcaca | 794 | BGP_CLEAR_SOFT_IN, NULL); |
7aafcaca DS |
795 | } |
796 | ||
797 | /* clear soft outbound */ | |
798 | static void | |
f31fa004 | 799 | bgp_clear_star_soft_out (struct vty *vty, const char *name) |
7aafcaca | 800 | { |
f31fa004 | 801 | bgp_clear_vty (vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
7aafcaca | 802 | BGP_CLEAR_SOFT_OUT, NULL); |
f31fa004 | 803 | bgp_clear_vty (vty, name, AFI_IP6, SAFI_UNICAST, clear_all, |
7aafcaca | 804 | BGP_CLEAR_SOFT_OUT, NULL); |
7aafcaca DS |
805 | } |
806 | ||
807 | ||
718e3744 | 808 | /* BGP global configuration. */ |
809 | ||
810 | DEFUN (bgp_multiple_instance_func, | |
811 | bgp_multiple_instance_cmd, | |
812 | "bgp multiple-instance", | |
813 | BGP_STR | |
814 | "Enable bgp multiple instance\n") | |
815 | { | |
816 | bgp_option_set (BGP_OPT_MULTIPLE_INSTANCE); | |
817 | return CMD_SUCCESS; | |
818 | } | |
819 | ||
820 | DEFUN (no_bgp_multiple_instance, | |
821 | no_bgp_multiple_instance_cmd, | |
822 | "no bgp multiple-instance", | |
823 | NO_STR | |
824 | BGP_STR | |
825 | "BGP multiple instance\n") | |
826 | { | |
827 | int ret; | |
828 | ||
829 | ret = bgp_option_unset (BGP_OPT_MULTIPLE_INSTANCE); | |
830 | if (ret < 0) | |
831 | { | |
832 | vty_out (vty, "%% There are more than two BGP instances%s", VTY_NEWLINE); | |
833 | return CMD_WARNING; | |
834 | } | |
835 | return CMD_SUCCESS; | |
836 | } | |
837 | ||
838 | DEFUN (bgp_config_type, | |
839 | bgp_config_type_cmd, | |
6147e2c6 | 840 | "bgp config-type <cisco|zebra>", |
718e3744 | 841 | BGP_STR |
842 | "Configuration type\n" | |
843 | "cisco\n" | |
844 | "zebra\n") | |
845 | { | |
c500ae40 DW |
846 | int idx_vendor = 2; |
847 | if (strncmp (argv[idx_vendor]->arg, "c", 1) == 0) | |
718e3744 | 848 | bgp_option_set (BGP_OPT_CONFIG_CISCO); |
849 | else | |
850 | bgp_option_unset (BGP_OPT_CONFIG_CISCO); | |
851 | ||
852 | return CMD_SUCCESS; | |
853 | } | |
854 | ||
855 | DEFUN (no_bgp_config_type, | |
856 | no_bgp_config_type_cmd, | |
c7178fe7 | 857 | "no bgp config-type [<cisco|zebra>]", |
718e3744 | 858 | NO_STR |
859 | BGP_STR | |
838758ac DW |
860 | "Display configuration type\n" |
861 | "cisco\n" | |
862 | "zebra\n") | |
718e3744 | 863 | { |
864 | bgp_option_unset (BGP_OPT_CONFIG_CISCO); | |
865 | return CMD_SUCCESS; | |
866 | } | |
867 | ||
813d4307 | 868 | |
718e3744 | 869 | DEFUN (no_synchronization, |
870 | no_synchronization_cmd, | |
871 | "no synchronization", | |
872 | NO_STR | |
873 | "Perform IGP synchronization\n") | |
874 | { | |
875 | return CMD_SUCCESS; | |
876 | } | |
877 | ||
878 | DEFUN (no_auto_summary, | |
879 | no_auto_summary_cmd, | |
880 | "no auto-summary", | |
881 | NO_STR | |
882 | "Enable automatic network number summarization\n") | |
883 | { | |
884 | return CMD_SUCCESS; | |
885 | } | |
3d515fd9 | 886 | |
718e3744 | 887 | /* "router bgp" commands. */ |
505e5056 | 888 | DEFUN_NOSH (router_bgp, |
f412b39a | 889 | router_bgp_cmd, |
31500417 | 890 | "router bgp [(1-4294967295) [<view|vrf> WORD]]", |
718e3744 | 891 | ROUTER_STR |
892 | BGP_STR | |
31500417 DW |
893 | AS_STR |
894 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 895 | { |
31500417 DW |
896 | int idx_asn = 2; |
897 | int idx_view_vrf = 3; | |
898 | int idx_vrf = 4; | |
718e3744 | 899 | int ret; |
900 | as_t as; | |
901 | struct bgp *bgp; | |
fd79ac91 | 902 | const char *name = NULL; |
ad4cbda1 | 903 | enum bgp_instance_type inst_type; |
718e3744 | 904 | |
2385a876 | 905 | // "router bgp" without an ASN |
31500417 | 906 | if (argc == 2) |
2385a876 | 907 | { |
6aeb9e78 | 908 | //Pending: Make VRF option available for ASN less config |
2385a876 | 909 | bgp = bgp_get_default(); |
718e3744 | 910 | |
2385a876 DW |
911 | if (bgp == NULL) |
912 | { | |
913 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
914 | return CMD_WARNING; | |
915 | } | |
718e3744 | 916 | |
2385a876 DW |
917 | if (listcount(bm->bgp) > 1) |
918 | { | |
919 | vty_out (vty, "%% Multiple BGP processes are configured%s", VTY_NEWLINE); | |
920 | return CMD_WARNING; | |
921 | } | |
922 | } | |
923 | ||
924 | // "router bgp X" | |
925 | else | |
718e3744 | 926 | { |
31500417 | 927 | VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_asn]->arg, 1, BGP_AS4_MAX); |
2385a876 | 928 | |
ad4cbda1 | 929 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; |
31500417 | 930 | if (argc > 3) |
ad4cbda1 | 931 | { |
31500417 DW |
932 | name = argv[idx_vrf]->arg; |
933 | ||
e52702f2 | 934 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) |
ad4cbda1 | 935 | inst_type = BGP_INSTANCE_TYPE_VRF; |
e52702f2 | 936 | else if (!strcmp(argv[idx_view_vrf]->text, "view")) |
ad4cbda1 | 937 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
938 | } | |
2385a876 | 939 | |
ad4cbda1 | 940 | ret = bgp_get (&bgp, &as, name, inst_type); |
2385a876 DW |
941 | switch (ret) |
942 | { | |
943 | case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET: | |
944 | vty_out (vty, "Please specify 'bgp multiple-instance' first%s", | |
945 | VTY_NEWLINE); | |
946 | return CMD_WARNING; | |
947 | case BGP_ERR_AS_MISMATCH: | |
948 | vty_out (vty, "BGP is already running; AS is %u%s", as, VTY_NEWLINE); | |
949 | return CMD_WARNING; | |
950 | case BGP_ERR_INSTANCE_MISMATCH: | |
6aeb9e78 | 951 | vty_out (vty, "BGP instance name and AS number mismatch%s", VTY_NEWLINE); |
2385a876 DW |
952 | vty_out (vty, "BGP instance is already running; AS is %u%s", |
953 | as, VTY_NEWLINE); | |
954 | return CMD_WARNING; | |
955 | } | |
6aeb9e78 DS |
956 | |
957 | /* Pending: handle when user tries to change a view to vrf n vv. */ | |
718e3744 | 958 | } |
959 | ||
cdc2d765 | 960 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); |
718e3744 | 961 | |
962 | return CMD_SUCCESS; | |
963 | } | |
964 | ||
718e3744 | 965 | /* "no router bgp" commands. */ |
966 | DEFUN (no_router_bgp, | |
967 | no_router_bgp_cmd, | |
31500417 | 968 | "no router bgp [(1-4294967295) [<view|vrf> WORD]]", |
718e3744 | 969 | NO_STR |
970 | ROUTER_STR | |
971 | BGP_STR | |
31500417 DW |
972 | AS_STR |
973 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 974 | { |
31500417 | 975 | int idx_asn = 3; |
31500417 | 976 | int idx_vrf = 5; |
718e3744 | 977 | as_t as; |
978 | struct bgp *bgp; | |
fd79ac91 | 979 | const char *name = NULL; |
718e3744 | 980 | |
7fb21a9f | 981 | // "no router bgp" without an ASN |
31500417 | 982 | if (argc == 3) |
7fb21a9f QY |
983 | { |
984 | //Pending: Make VRF option available for ASN less config | |
985 | bgp = bgp_get_default(); | |
718e3744 | 986 | |
7fb21a9f QY |
987 | if (bgp == NULL) |
988 | { | |
989 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
990 | return CMD_WARNING; | |
991 | } | |
992 | ||
993 | if (listcount(bm->bgp) > 1) | |
994 | { | |
995 | vty_out (vty, "%% Multiple BGP processes are configured%s", VTY_NEWLINE); | |
996 | return CMD_WARNING; | |
997 | } | |
998 | } | |
999 | else | |
718e3744 | 1000 | { |
31500417 | 1001 | VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_asn]->arg, 1, BGP_AS4_MAX); |
7fb21a9f | 1002 | |
31500417 DW |
1003 | if (argc > 4) |
1004 | name = argv[idx_vrf]->arg; | |
7fb21a9f QY |
1005 | |
1006 | /* Lookup bgp structure. */ | |
1007 | bgp = bgp_lookup (as, name); | |
1008 | if (! bgp) | |
1009 | { | |
1010 | vty_out (vty, "%% Can't find BGP instance%s", VTY_NEWLINE); | |
1011 | return CMD_WARNING; | |
1012 | } | |
718e3744 | 1013 | } |
1014 | ||
1015 | bgp_delete (bgp); | |
1016 | ||
1017 | return CMD_SUCCESS; | |
1018 | } | |
1019 | ||
6b0655a2 | 1020 | |
7fb21a9f | 1021 | |
718e3744 | 1022 | /* BGP router-id. */ |
1023 | ||
1024 | DEFUN (bgp_router_id, | |
1025 | bgp_router_id_cmd, | |
1026 | "bgp router-id A.B.C.D", | |
1027 | BGP_STR | |
1028 | "Override configured router identifier\n" | |
1029 | "Manually configured router identifier\n") | |
1030 | { | |
cdc2d765 | 1031 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1032 | int idx_ipv4 = 2; |
718e3744 | 1033 | int ret; |
1034 | struct in_addr id; | |
718e3744 | 1035 | |
c500ae40 | 1036 | ret = inet_aton (argv[idx_ipv4]->arg, &id); |
718e3744 | 1037 | if (! ret) |
1038 | { | |
1039 | vty_out (vty, "%% Malformed bgp router identifier%s", VTY_NEWLINE); | |
1040 | return CMD_WARNING; | |
1041 | } | |
1042 | ||
0e6cb743 | 1043 | bgp_router_id_static_set (bgp, id); |
718e3744 | 1044 | |
1045 | return CMD_SUCCESS; | |
1046 | } | |
1047 | ||
1048 | DEFUN (no_bgp_router_id, | |
1049 | no_bgp_router_id_cmd, | |
31500417 | 1050 | "no bgp router-id [A.B.C.D]", |
718e3744 | 1051 | NO_STR |
1052 | BGP_STR | |
31500417 DW |
1053 | "Override configured router identifier\n" |
1054 | "Manually configured router identifier\n") | |
718e3744 | 1055 | { |
cdc2d765 | 1056 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
31500417 | 1057 | int idx_router_id = 3; |
718e3744 | 1058 | int ret; |
1059 | struct in_addr id; | |
718e3744 | 1060 | |
31500417 | 1061 | if (argc > idx_router_id) |
718e3744 | 1062 | { |
31500417 | 1063 | ret = inet_aton (argv[idx_router_id]->arg, &id); |
718e3744 | 1064 | if (! ret) |
e018c7cc SK |
1065 | { |
1066 | vty_out (vty, "%% Malformed BGP router identifier%s", VTY_NEWLINE); | |
1067 | return CMD_WARNING; | |
1068 | } | |
718e3744 | 1069 | |
18a6dce6 | 1070 | if (! IPV4_ADDR_SAME (&bgp->router_id_static, &id)) |
e018c7cc SK |
1071 | { |
1072 | vty_out (vty, "%% BGP router-id doesn't match%s", VTY_NEWLINE); | |
1073 | return CMD_WARNING; | |
1074 | } | |
718e3744 | 1075 | } |
1076 | ||
0e6cb743 DL |
1077 | id.s_addr = 0; |
1078 | bgp_router_id_static_set (bgp, id); | |
718e3744 | 1079 | |
1080 | return CMD_SUCCESS; | |
1081 | } | |
1082 | ||
6b0655a2 | 1083 | |
718e3744 | 1084 | /* BGP Cluster ID. */ |
718e3744 | 1085 | DEFUN (bgp_cluster_id, |
1086 | bgp_cluster_id_cmd, | |
838758ac | 1087 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", |
718e3744 | 1088 | BGP_STR |
1089 | "Configure Route-Reflector Cluster-id\n" | |
838758ac DW |
1090 | "Route-Reflector Cluster-id in IP address format\n" |
1091 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1092 | { |
cdc2d765 | 1093 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1094 | int idx_ipv4 = 2; |
718e3744 | 1095 | int ret; |
718e3744 | 1096 | struct in_addr cluster; |
1097 | ||
c500ae40 | 1098 | ret = inet_aton (argv[idx_ipv4]->arg, &cluster); |
718e3744 | 1099 | if (! ret) |
1100 | { | |
1101 | vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE); | |
1102 | return CMD_WARNING; | |
1103 | } | |
1104 | ||
1105 | bgp_cluster_id_set (bgp, &cluster); | |
f31fa004 | 1106 | bgp_clear_star_soft_out (vty, bgp->name); |
718e3744 | 1107 | |
1108 | return CMD_SUCCESS; | |
1109 | } | |
1110 | ||
718e3744 | 1111 | DEFUN (no_bgp_cluster_id, |
1112 | no_bgp_cluster_id_cmd, | |
c7178fe7 | 1113 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", |
718e3744 | 1114 | NO_STR |
1115 | BGP_STR | |
838758ac DW |
1116 | "Configure Route-Reflector Cluster-id\n" |
1117 | "Route-Reflector Cluster-id in IP address format\n" | |
1118 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1119 | { |
cdc2d765 | 1120 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1121 | bgp_cluster_id_unset (bgp); |
f31fa004 | 1122 | bgp_clear_star_soft_out (vty, bgp->name); |
718e3744 | 1123 | |
1124 | return CMD_SUCCESS; | |
1125 | } | |
1126 | ||
718e3744 | 1127 | DEFUN (bgp_confederation_identifier, |
1128 | bgp_confederation_identifier_cmd, | |
9ccf14f7 | 1129 | "bgp confederation identifier (1-4294967295)", |
718e3744 | 1130 | "BGP specific commands\n" |
1131 | "AS confederation parameters\n" | |
1132 | "AS number\n" | |
1133 | "Set routing domain confederation AS\n") | |
1134 | { | |
cdc2d765 | 1135 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1136 | int idx_number = 3; |
718e3744 | 1137 | as_t as; |
1138 | ||
c500ae40 | 1139 | VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); |
718e3744 | 1140 | |
1141 | bgp_confederation_id_set (bgp, as); | |
1142 | ||
1143 | return CMD_SUCCESS; | |
1144 | } | |
1145 | ||
1146 | DEFUN (no_bgp_confederation_identifier, | |
1147 | no_bgp_confederation_identifier_cmd, | |
838758ac | 1148 | "no bgp confederation identifier [(1-4294967295)]", |
718e3744 | 1149 | NO_STR |
1150 | "BGP specific commands\n" | |
1151 | "AS confederation parameters\n" | |
3a2d747c QY |
1152 | "AS number\n" |
1153 | "Set routing domain confederation AS\n") | |
718e3744 | 1154 | { |
cdc2d765 | 1155 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1156 | bgp_confederation_id_unset (bgp); |
1157 | ||
1158 | return CMD_SUCCESS; | |
1159 | } | |
1160 | ||
718e3744 | 1161 | DEFUN (bgp_confederation_peers, |
1162 | bgp_confederation_peers_cmd, | |
12dcf78e | 1163 | "bgp confederation peers (1-4294967295)...", |
718e3744 | 1164 | "BGP specific commands\n" |
1165 | "AS confederation parameters\n" | |
1166 | "Peer ASs in BGP confederation\n" | |
1167 | AS_STR) | |
1168 | { | |
cdc2d765 | 1169 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
58749582 | 1170 | int idx_asn = 3; |
718e3744 | 1171 | as_t as; |
1172 | int i; | |
1173 | ||
58749582 | 1174 | for (i = idx_asn; i < argc; i++) |
718e3744 | 1175 | { |
afec25d9 | 1176 | VTY_GET_INTEGER_RANGE ("AS", as, argv[i]->arg, 1, BGP_AS4_MAX); |
718e3744 | 1177 | |
1178 | if (bgp->as == as) | |
1179 | { | |
1180 | vty_out (vty, "%% Local member-AS not allowed in confed peer list%s", | |
1181 | VTY_NEWLINE); | |
1182 | continue; | |
1183 | } | |
1184 | ||
1185 | bgp_confederation_peers_add (bgp, as); | |
1186 | } | |
1187 | return CMD_SUCCESS; | |
1188 | } | |
1189 | ||
1190 | DEFUN (no_bgp_confederation_peers, | |
1191 | no_bgp_confederation_peers_cmd, | |
e83a9414 | 1192 | "no bgp confederation peers (1-4294967295)...", |
718e3744 | 1193 | NO_STR |
1194 | "BGP specific commands\n" | |
1195 | "AS confederation parameters\n" | |
1196 | "Peer ASs in BGP confederation\n" | |
1197 | AS_STR) | |
1198 | { | |
cdc2d765 | 1199 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
58749582 | 1200 | int idx_asn = 4; |
718e3744 | 1201 | as_t as; |
1202 | int i; | |
1203 | ||
58749582 | 1204 | for (i = idx_asn; i < argc; i++) |
718e3744 | 1205 | { |
afec25d9 | 1206 | VTY_GET_INTEGER_RANGE ("AS", as, argv[i]->arg, 1, BGP_AS4_MAX); |
0b2aa3a0 | 1207 | |
718e3744 | 1208 | bgp_confederation_peers_remove (bgp, as); |
1209 | } | |
1210 | return CMD_SUCCESS; | |
1211 | } | |
6b0655a2 | 1212 | |
5e242b0d DS |
1213 | /** |
1214 | * Central routine for maximum-paths configuration. | |
1215 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1216 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1217 | */ | |
ffd0c037 DS |
1218 | static int |
1219 | bgp_maxpaths_config_vty (struct vty *vty, int peer_type, const char *mpaths, | |
5e242b0d | 1220 | u_int16_t options, int set) |
165b5fff | 1221 | { |
cdc2d765 | 1222 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4c9dee98 | 1223 | u_int16_t maxpaths = 0; |
165b5fff | 1224 | int ret; |
5e242b0d DS |
1225 | afi_t afi; |
1226 | safi_t safi; | |
165b5fff | 1227 | |
5e242b0d DS |
1228 | afi = bgp_node_afi (vty); |
1229 | safi = bgp_node_safi (vty); | |
165b5fff | 1230 | |
5e242b0d | 1231 | if (set) |
4c9dee98 | 1232 | { |
c59f2066 | 1233 | maxpaths = strtol(mpaths, NULL, 10); |
37fe7731 DS |
1234 | if (maxpaths > multipath_num) |
1235 | { | |
1236 | vty_out (vty, | |
1237 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", | |
1238 | maxpaths, multipath_num); | |
1239 | return CMD_WARNING; | |
1240 | } | |
dff6764a | 1241 | ret = bgp_maximum_paths_set (bgp, afi, safi, peer_type, maxpaths, options); |
4c9dee98 | 1242 | } |
5e242b0d DS |
1243 | else |
1244 | ret = bgp_maximum_paths_unset (bgp, afi, safi, peer_type); | |
165b5fff | 1245 | |
165b5fff JB |
1246 | if (ret < 0) |
1247 | { | |
1248 | vty_out (vty, | |
5e242b0d DS |
1249 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u%s", |
1250 | (set == 1) ? "" : "un", | |
1251 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1252 | maxpaths, afi, safi, VTY_NEWLINE); | |
165b5fff JB |
1253 | return CMD_WARNING; |
1254 | } | |
1255 | ||
7aafcaca DS |
1256 | bgp_recalculate_all_bestpaths (bgp); |
1257 | ||
165b5fff JB |
1258 | return CMD_SUCCESS; |
1259 | } | |
1260 | ||
abc920f8 DS |
1261 | DEFUN (bgp_maxmed_admin, |
1262 | bgp_maxmed_admin_cmd, | |
1263 | "bgp max-med administrative ", | |
1264 | BGP_STR | |
1265 | "Advertise routes with max-med\n" | |
1266 | "Administratively applied, for an indefinite period\n") | |
1267 | { | |
cdc2d765 | 1268 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 DS |
1269 | |
1270 | bgp->v_maxmed_admin = 1; | |
1271 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1272 | ||
1273 | bgp_maxmed_update(bgp); | |
1274 | ||
1275 | return CMD_SUCCESS; | |
1276 | } | |
1277 | ||
1278 | DEFUN (bgp_maxmed_admin_medv, | |
1279 | bgp_maxmed_admin_medv_cmd, | |
6147e2c6 | 1280 | "bgp max-med administrative (0-4294967294)", |
abc920f8 DS |
1281 | BGP_STR |
1282 | "Advertise routes with max-med\n" | |
1283 | "Administratively applied, for an indefinite period\n" | |
1284 | "Max MED value to be used\n") | |
1285 | { | |
cdc2d765 | 1286 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1287 | int idx_number = 3; |
abc920f8 DS |
1288 | |
1289 | bgp->v_maxmed_admin = 1; | |
c500ae40 | 1290 | VTY_GET_INTEGER ("max-med admin med-value", bgp->maxmed_admin_value, argv[idx_number]->arg); |
abc920f8 DS |
1291 | |
1292 | bgp_maxmed_update(bgp); | |
1293 | ||
1294 | return CMD_SUCCESS; | |
1295 | } | |
1296 | ||
1297 | DEFUN (no_bgp_maxmed_admin, | |
1298 | no_bgp_maxmed_admin_cmd, | |
8334fd5a | 1299 | "no bgp max-med administrative [(0-4294967294)]", |
abc920f8 DS |
1300 | NO_STR |
1301 | BGP_STR | |
1302 | "Advertise routes with max-med\n" | |
838758ac DW |
1303 | "Administratively applied, for an indefinite period\n" |
1304 | "Max MED value to be used\n") | |
abc920f8 | 1305 | { |
cdc2d765 | 1306 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 DS |
1307 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; |
1308 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 DS |
1309 | bgp_maxmed_update(bgp); |
1310 | ||
1311 | return CMD_SUCCESS; | |
1312 | } | |
1313 | ||
abc920f8 DS |
1314 | DEFUN (bgp_maxmed_onstartup, |
1315 | bgp_maxmed_onstartup_cmd, | |
6147e2c6 | 1316 | "bgp max-med on-startup (5-86400)", |
abc920f8 DS |
1317 | BGP_STR |
1318 | "Advertise routes with max-med\n" | |
1319 | "Effective on a startup\n" | |
1320 | "Time (seconds) period for max-med\n") | |
1321 | { | |
cdc2d765 | 1322 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1323 | int idx_number = 3; |
c500ae40 | 1324 | VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[idx_number]->arg); |
abc920f8 | 1325 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; |
abc920f8 DS |
1326 | bgp_maxmed_update(bgp); |
1327 | ||
1328 | return CMD_SUCCESS; | |
1329 | } | |
1330 | ||
1331 | DEFUN (bgp_maxmed_onstartup_medv, | |
1332 | bgp_maxmed_onstartup_medv_cmd, | |
6147e2c6 | 1333 | "bgp max-med on-startup (5-86400) (0-4294967294)", |
abc920f8 DS |
1334 | BGP_STR |
1335 | "Advertise routes with max-med\n" | |
1336 | "Effective on a startup\n" | |
1337 | "Time (seconds) period for max-med\n" | |
1338 | "Max MED value to be used\n") | |
1339 | { | |
cdc2d765 | 1340 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
1341 | int idx_number = 3; |
1342 | int idx_number_2 = 4; | |
c500ae40 DW |
1343 | VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[idx_number]->arg); |
1344 | VTY_GET_INTEGER ("max-med on-startup med-value", bgp->maxmed_onstartup_value, argv[idx_number_2]->arg); | |
abc920f8 DS |
1345 | bgp_maxmed_update(bgp); |
1346 | ||
1347 | return CMD_SUCCESS; | |
1348 | } | |
1349 | ||
1350 | DEFUN (no_bgp_maxmed_onstartup, | |
1351 | no_bgp_maxmed_onstartup_cmd, | |
8334fd5a | 1352 | "no bgp max-med on-startup [(5-86400) [(0-4294967294)]]", |
abc920f8 DS |
1353 | NO_STR |
1354 | BGP_STR | |
1355 | "Advertise routes with max-med\n" | |
838758ac DW |
1356 | "Effective on a startup\n" |
1357 | "Time (seconds) period for max-med\n" | |
1358 | "Max MED value to be used\n") | |
abc920f8 | 1359 | { |
cdc2d765 | 1360 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 DS |
1361 | |
1362 | /* Cancel max-med onstartup if its on */ | |
1363 | if (bgp->t_maxmed_onstartup) | |
1364 | { | |
1365 | THREAD_TIMER_OFF (bgp->t_maxmed_onstartup); | |
1366 | bgp->maxmed_onstartup_over = 1; | |
1367 | } | |
1368 | ||
1369 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; | |
1370 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
1371 | ||
1372 | bgp_maxmed_update(bgp); | |
1373 | ||
1374 | return CMD_SUCCESS; | |
1375 | } | |
1376 | ||
f188f2c4 DS |
1377 | static int |
1378 | bgp_update_delay_config_vty (struct vty *vty, const char *delay, | |
1379 | const char *wait) | |
1380 | { | |
cdc2d765 | 1381 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 DS |
1382 | u_int16_t update_delay; |
1383 | u_int16_t establish_wait; | |
1384 | ||
f188f2c4 DS |
1385 | VTY_GET_INTEGER_RANGE ("update-delay", update_delay, delay, |
1386 | BGP_UPDATE_DELAY_MIN, BGP_UPDATE_DELAY_MAX); | |
1387 | ||
1388 | if (!wait) /* update-delay <delay> */ | |
1389 | { | |
1390 | bgp->v_update_delay = update_delay; | |
1391 | bgp->v_establish_wait = bgp->v_update_delay; | |
1392 | return CMD_SUCCESS; | |
1393 | } | |
1394 | ||
1395 | /* update-delay <delay> <establish-wait> */ | |
1396 | establish_wait = atoi (wait); | |
1397 | if (update_delay < establish_wait) | |
1398 | { | |
1399 | vty_out (vty, "%%Failed: update-delay less than the establish-wait!%s", | |
1400 | VTY_NEWLINE); | |
1401 | return CMD_WARNING; | |
1402 | } | |
1403 | ||
1404 | bgp->v_update_delay = update_delay; | |
1405 | bgp->v_establish_wait = establish_wait; | |
1406 | ||
1407 | return CMD_SUCCESS; | |
1408 | } | |
1409 | ||
1410 | static int | |
1411 | bgp_update_delay_deconfig_vty (struct vty *vty) | |
1412 | { | |
cdc2d765 | 1413 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 DS |
1414 | |
1415 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; | |
1416 | bgp->v_establish_wait = bgp->v_update_delay; | |
1417 | ||
1418 | return CMD_SUCCESS; | |
1419 | } | |
1420 | ||
1421 | int | |
1422 | bgp_config_write_update_delay (struct vty *vty, struct bgp *bgp) | |
1423 | { | |
1424 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) | |
1425 | { | |
1426 | vty_out (vty, " update-delay %d", bgp->v_update_delay); | |
1427 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1428 | vty_out (vty, " %d", bgp->v_establish_wait); | |
1429 | vty_out (vty, "%s", VTY_NEWLINE); | |
1430 | } | |
1431 | ||
1432 | return 0; | |
1433 | } | |
1434 | ||
1435 | ||
1436 | /* Update-delay configuration */ | |
1437 | DEFUN (bgp_update_delay, | |
1438 | bgp_update_delay_cmd, | |
6147e2c6 | 1439 | "update-delay (0-3600)", |
f188f2c4 DS |
1440 | "Force initial delay for best-path and updates\n" |
1441 | "Seconds\n") | |
1442 | { | |
c500ae40 DW |
1443 | int idx_number = 1; |
1444 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); | |
f188f2c4 DS |
1445 | } |
1446 | ||
1447 | DEFUN (bgp_update_delay_establish_wait, | |
1448 | bgp_update_delay_establish_wait_cmd, | |
6147e2c6 | 1449 | "update-delay (0-3600) (1-3600)", |
f188f2c4 DS |
1450 | "Force initial delay for best-path and updates\n" |
1451 | "Seconds\n" | |
1452 | "Wait for peers to be established\n" | |
1453 | "Seconds\n") | |
1454 | { | |
c500ae40 DW |
1455 | int idx_number = 1; |
1456 | int idx_number_2 = 2; | |
1457 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, argv[idx_number_2]->arg); | |
f188f2c4 DS |
1458 | } |
1459 | ||
1460 | /* Update-delay deconfiguration */ | |
1461 | DEFUN (no_bgp_update_delay, | |
1462 | no_bgp_update_delay_cmd, | |
838758ac DW |
1463 | "no update-delay [(0-3600) [(1-3600)]]", |
1464 | NO_STR | |
f188f2c4 | 1465 | "Force initial delay for best-path and updates\n" |
838758ac DW |
1466 | "Seconds\n" |
1467 | "Wait for peers to be established\n") | |
f188f2c4 DS |
1468 | { |
1469 | return bgp_update_delay_deconfig_vty(vty); | |
1470 | } | |
1471 | ||
5e242b0d | 1472 | |
ffd0c037 DS |
1473 | static int |
1474 | bgp_wpkt_quanta_config_vty (struct vty *vty, const char *num, char set) | |
cb1faec9 | 1475 | { |
cdc2d765 | 1476 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
cb1faec9 DS |
1477 | |
1478 | if (set) | |
1479 | VTY_GET_INTEGER_RANGE ("write-quanta", bgp->wpkt_quanta, num, | |
4543bbb4 | 1480 | 1, 10000); |
cb1faec9 DS |
1481 | else |
1482 | bgp->wpkt_quanta = BGP_WRITE_PACKET_MAX; | |
1483 | ||
1484 | return CMD_SUCCESS; | |
1485 | } | |
1486 | ||
1487 | int | |
1488 | bgp_config_write_wpkt_quanta (struct vty *vty, struct bgp *bgp) | |
1489 | { | |
1490 | if (bgp->wpkt_quanta != BGP_WRITE_PACKET_MAX) | |
1491 | vty_out (vty, " write-quanta %d%s", | |
1492 | bgp->wpkt_quanta, VTY_NEWLINE); | |
1493 | ||
1494 | return 0; | |
1495 | } | |
1496 | ||
1497 | ||
1498 | /* Update-delay configuration */ | |
1499 | DEFUN (bgp_wpkt_quanta, | |
1500 | bgp_wpkt_quanta_cmd, | |
6147e2c6 | 1501 | "write-quanta (1-10000)", |
cb1faec9 DS |
1502 | "How many packets to write to peer socket per run\n" |
1503 | "Number of packets\n") | |
1504 | { | |
c500ae40 DW |
1505 | int idx_number = 1; |
1506 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
cb1faec9 DS |
1507 | } |
1508 | ||
1509 | /* Update-delay deconfiguration */ | |
1510 | DEFUN (no_bgp_wpkt_quanta, | |
1511 | no_bgp_wpkt_quanta_cmd, | |
6147e2c6 | 1512 | "no write-quanta (1-10000)", |
d7fa34c1 | 1513 | NO_STR |
cb1faec9 DS |
1514 | "How many packets to write to peer socket per run\n" |
1515 | "Number of packets\n") | |
1516 | { | |
c500ae40 DW |
1517 | int idx_number = 2; |
1518 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
cb1faec9 DS |
1519 | } |
1520 | ||
ffd0c037 | 1521 | static int |
3f9c7369 DS |
1522 | bgp_coalesce_config_vty (struct vty *vty, const char *num, char set) |
1523 | { | |
cdc2d765 | 1524 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3f9c7369 DS |
1525 | |
1526 | if (set) | |
1527 | VTY_GET_INTEGER_RANGE ("coalesce-time", bgp->coalesce_time, num, | |
1528 | 0, 4294967295); | |
1529 | else | |
1530 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; | |
1531 | ||
1532 | return CMD_SUCCESS; | |
1533 | } | |
1534 | ||
1535 | int | |
1536 | bgp_config_write_coalesce_time (struct vty *vty, struct bgp *bgp) | |
1537 | { | |
1538 | if (bgp->coalesce_time != BGP_DEFAULT_SUBGROUP_COALESCE_TIME) | |
1539 | vty_out (vty, " coalesce-time %d%s", | |
1540 | bgp->coalesce_time, VTY_NEWLINE); | |
1541 | ||
1542 | return 0; | |
1543 | } | |
1544 | ||
1545 | ||
1546 | DEFUN (bgp_coalesce_time, | |
1547 | bgp_coalesce_time_cmd, | |
6147e2c6 | 1548 | "coalesce-time (0-4294967295)", |
3f9c7369 DS |
1549 | "Subgroup coalesce timer\n" |
1550 | "Subgroup coalesce timer value (in ms)\n") | |
1551 | { | |
c500ae40 DW |
1552 | int idx_number = 1; |
1553 | return bgp_coalesce_config_vty(vty, argv[idx_number]->arg, 1); | |
3f9c7369 DS |
1554 | } |
1555 | ||
1556 | DEFUN (no_bgp_coalesce_time, | |
1557 | no_bgp_coalesce_time_cmd, | |
6147e2c6 | 1558 | "no coalesce-time (0-4294967295)", |
3a2d747c | 1559 | NO_STR |
3f9c7369 DS |
1560 | "Subgroup coalesce timer\n" |
1561 | "Subgroup coalesce timer value (in ms)\n") | |
1562 | { | |
c500ae40 DW |
1563 | int idx_number = 2; |
1564 | return bgp_coalesce_config_vty(vty, argv[idx_number]->arg, 0); | |
3f9c7369 DS |
1565 | } |
1566 | ||
5e242b0d DS |
1567 | /* Maximum-paths configuration */ |
1568 | DEFUN (bgp_maxpaths, | |
1569 | bgp_maxpaths_cmd, | |
9ccf14f7 | 1570 | "maximum-paths (1-255)", |
5e242b0d DS |
1571 | "Forward packets over multiple paths\n" |
1572 | "Number of paths\n") | |
1573 | { | |
c500ae40 DW |
1574 | int idx_number = 1; |
1575 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
1576 | } |
1577 | ||
165b5fff JB |
1578 | DEFUN (bgp_maxpaths_ibgp, |
1579 | bgp_maxpaths_ibgp_cmd, | |
9ccf14f7 | 1580 | "maximum-paths ibgp (1-255)", |
165b5fff JB |
1581 | "Forward packets over multiple paths\n" |
1582 | "iBGP-multipath\n" | |
1583 | "Number of paths\n") | |
1584 | { | |
c500ae40 DW |
1585 | int idx_number = 2; |
1586 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[idx_number]->arg, 0, 1); | |
5e242b0d | 1587 | } |
165b5fff | 1588 | |
5e242b0d DS |
1589 | DEFUN (bgp_maxpaths_ibgp_cluster, |
1590 | bgp_maxpaths_ibgp_cluster_cmd, | |
9ccf14f7 | 1591 | "maximum-paths ibgp (1-255) equal-cluster-length", |
5e242b0d DS |
1592 | "Forward packets over multiple paths\n" |
1593 | "iBGP-multipath\n" | |
1594 | "Number of paths\n" | |
1595 | "Match the cluster length\n") | |
1596 | { | |
c500ae40 DW |
1597 | int idx_number = 2; |
1598 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
5e242b0d | 1599 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); |
165b5fff JB |
1600 | } |
1601 | ||
1602 | DEFUN (no_bgp_maxpaths, | |
1603 | no_bgp_maxpaths_cmd, | |
9ccf14f7 | 1604 | "no maximum-paths [(1-255)]", |
165b5fff JB |
1605 | NO_STR |
1606 | "Forward packets over multiple paths\n" | |
1607 | "Number of paths\n") | |
1608 | { | |
5e242b0d | 1609 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
1610 | } |
1611 | ||
165b5fff JB |
1612 | DEFUN (no_bgp_maxpaths_ibgp, |
1613 | no_bgp_maxpaths_ibgp_cmd, | |
9ccf14f7 | 1614 | "no maximum-paths ibgp [(1-255) [equal-cluster-length]]", |
165b5fff JB |
1615 | NO_STR |
1616 | "Forward packets over multiple paths\n" | |
1617 | "iBGP-multipath\n" | |
838758ac DW |
1618 | "Number of paths\n" |
1619 | "Match the cluster length\n") | |
165b5fff | 1620 | { |
5e242b0d | 1621 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1622 | } |
1623 | ||
165b5fff JB |
1624 | int |
1625 | bgp_config_write_maxpaths (struct vty *vty, struct bgp *bgp, afi_t afi, | |
1626 | safi_t safi, int *write) | |
1627 | { | |
d5b77cc2 | 1628 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) |
165b5fff JB |
1629 | { |
1630 | bgp_config_write_family_header (vty, afi, safi, write); | |
0b960b4d | 1631 | vty_out (vty, " maximum-paths %d%s", |
165b5fff JB |
1632 | bgp->maxpaths[afi][safi].maxpaths_ebgp, VTY_NEWLINE); |
1633 | } | |
1634 | ||
d5b77cc2 | 1635 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) |
165b5fff JB |
1636 | { |
1637 | bgp_config_write_family_header (vty, afi, safi, write); | |
0b960b4d | 1638 | vty_out (vty, " maximum-paths ibgp %d", |
5e242b0d DS |
1639 | bgp->maxpaths[afi][safi].maxpaths_ibgp); |
1640 | if (CHECK_FLAG (bgp->maxpaths[afi][safi].ibgp_flags, | |
1641 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1642 | vty_out (vty, " equal-cluster-length"); | |
1643 | vty_out (vty, "%s", VTY_NEWLINE); | |
165b5fff JB |
1644 | } |
1645 | ||
1646 | return 0; | |
1647 | } | |
6b0655a2 | 1648 | |
718e3744 | 1649 | /* BGP timers. */ |
1650 | ||
1651 | DEFUN (bgp_timers, | |
1652 | bgp_timers_cmd, | |
6147e2c6 | 1653 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1654 | "Adjust routing timers\n" |
1655 | "BGP timers\n" | |
1656 | "Keepalive interval\n" | |
1657 | "Holdtime\n") | |
1658 | { | |
cdc2d765 | 1659 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
1660 | int idx_number = 2; |
1661 | int idx_number_2 = 3; | |
718e3744 | 1662 | unsigned long keepalive = 0; |
1663 | unsigned long holdtime = 0; | |
1664 | ||
c500ae40 DW |
1665 | VTY_GET_INTEGER ("keepalive", keepalive, argv[idx_number]->arg); |
1666 | VTY_GET_INTEGER ("holdtime", holdtime, argv[idx_number_2]->arg); | |
718e3744 | 1667 | |
1668 | /* Holdtime value check. */ | |
1669 | if (holdtime < 3 && holdtime != 0) | |
1670 | { | |
1671 | vty_out (vty, "%% hold time value must be either 0 or greater than 3%s", | |
1672 | VTY_NEWLINE); | |
1673 | return CMD_WARNING; | |
1674 | } | |
1675 | ||
1676 | bgp_timers_set (bgp, keepalive, holdtime); | |
1677 | ||
1678 | return CMD_SUCCESS; | |
1679 | } | |
1680 | ||
1681 | DEFUN (no_bgp_timers, | |
1682 | no_bgp_timers_cmd, | |
838758ac | 1683 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1684 | NO_STR |
1685 | "Adjust routing timers\n" | |
838758ac DW |
1686 | "BGP timers\n" |
1687 | "Keepalive interval\n" | |
1688 | "Holdtime\n") | |
718e3744 | 1689 | { |
cdc2d765 | 1690 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1691 | bgp_timers_unset (bgp); |
1692 | ||
1693 | return CMD_SUCCESS; | |
1694 | } | |
1695 | ||
6b0655a2 | 1696 | |
718e3744 | 1697 | DEFUN (bgp_client_to_client_reflection, |
1698 | bgp_client_to_client_reflection_cmd, | |
1699 | "bgp client-to-client reflection", | |
1700 | "BGP specific commands\n" | |
1701 | "Configure client to client route reflection\n" | |
1702 | "reflection of routes allowed\n") | |
1703 | { | |
cdc2d765 | 1704 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1705 | bgp_flag_unset (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); |
f31fa004 | 1706 | bgp_clear_star_soft_out (vty, bgp->name); |
7aafcaca | 1707 | |
718e3744 | 1708 | return CMD_SUCCESS; |
1709 | } | |
1710 | ||
1711 | DEFUN (no_bgp_client_to_client_reflection, | |
1712 | no_bgp_client_to_client_reflection_cmd, | |
1713 | "no bgp client-to-client reflection", | |
1714 | NO_STR | |
1715 | "BGP specific commands\n" | |
1716 | "Configure client to client route reflection\n" | |
1717 | "reflection of routes allowed\n") | |
1718 | { | |
cdc2d765 | 1719 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1720 | bgp_flag_set (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); |
f31fa004 | 1721 | bgp_clear_star_soft_out (vty, bgp->name); |
7aafcaca | 1722 | |
718e3744 | 1723 | return CMD_SUCCESS; |
1724 | } | |
1725 | ||
1726 | /* "bgp always-compare-med" configuration. */ | |
1727 | DEFUN (bgp_always_compare_med, | |
1728 | bgp_always_compare_med_cmd, | |
1729 | "bgp always-compare-med", | |
1730 | "BGP specific commands\n" | |
1731 | "Allow comparing MED from different neighbors\n") | |
1732 | { | |
cdc2d765 | 1733 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1734 | bgp_flag_set (bgp, BGP_FLAG_ALWAYS_COMPARE_MED); |
7aafcaca DS |
1735 | bgp_recalculate_all_bestpaths (bgp); |
1736 | ||
718e3744 | 1737 | return CMD_SUCCESS; |
1738 | } | |
1739 | ||
1740 | DEFUN (no_bgp_always_compare_med, | |
1741 | no_bgp_always_compare_med_cmd, | |
1742 | "no bgp always-compare-med", | |
1743 | NO_STR | |
1744 | "BGP specific commands\n" | |
1745 | "Allow comparing MED from different neighbors\n") | |
1746 | { | |
cdc2d765 | 1747 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1748 | bgp_flag_unset (bgp, BGP_FLAG_ALWAYS_COMPARE_MED); |
7aafcaca DS |
1749 | bgp_recalculate_all_bestpaths (bgp); |
1750 | ||
718e3744 | 1751 | return CMD_SUCCESS; |
1752 | } | |
6b0655a2 | 1753 | |
718e3744 | 1754 | /* "bgp deterministic-med" configuration. */ |
1755 | DEFUN (bgp_deterministic_med, | |
1756 | bgp_deterministic_med_cmd, | |
1757 | "bgp deterministic-med", | |
1758 | "BGP specific commands\n" | |
1759 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1760 | { | |
cdc2d765 | 1761 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1475ac87 DW |
1762 | |
1763 | if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) | |
1764 | { | |
1765 | bgp_flag_set (bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1766 | bgp_recalculate_all_bestpaths (bgp); | |
1767 | } | |
7aafcaca | 1768 | |
718e3744 | 1769 | return CMD_SUCCESS; |
1770 | } | |
1771 | ||
1772 | DEFUN (no_bgp_deterministic_med, | |
1773 | no_bgp_deterministic_med_cmd, | |
1774 | "no bgp deterministic-med", | |
1775 | NO_STR | |
1776 | "BGP specific commands\n" | |
1777 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1778 | { | |
cdc2d765 | 1779 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
06370dac DW |
1780 | int bestpath_per_as_used; |
1781 | afi_t afi; | |
1782 | safi_t safi; | |
1783 | struct peer *peer; | |
1784 | struct listnode *node, *nnode; | |
718e3744 | 1785 | |
1475ac87 DW |
1786 | if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) |
1787 | { | |
06370dac DW |
1788 | bestpath_per_as_used = 0; |
1789 | ||
1790 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
1791 | { | |
1792 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
1793 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
1794 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) | |
1795 | { | |
1796 | bestpath_per_as_used = 1; | |
1797 | break; | |
1798 | } | |
1799 | ||
1800 | if (bestpath_per_as_used) | |
1801 | break; | |
1802 | } | |
1803 | ||
1804 | if (bestpath_per_as_used) | |
1805 | { | |
1806 | vty_out (vty, "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use%s", | |
1807 | VTY_NEWLINE); | |
1808 | return CMD_WARNING; | |
1809 | } | |
1810 | else | |
1811 | { | |
1812 | bgp_flag_unset (bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1813 | bgp_recalculate_all_bestpaths (bgp); | |
1814 | } | |
1475ac87 | 1815 | } |
7aafcaca | 1816 | |
718e3744 | 1817 | return CMD_SUCCESS; |
1818 | } | |
538621f2 | 1819 | |
1820 | /* "bgp graceful-restart" configuration. */ | |
1821 | DEFUN (bgp_graceful_restart, | |
1822 | bgp_graceful_restart_cmd, | |
1823 | "bgp graceful-restart", | |
1824 | "BGP specific commands\n" | |
1825 | "Graceful restart capability parameters\n") | |
1826 | { | |
cdc2d765 | 1827 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
538621f2 | 1828 | bgp_flag_set (bgp, BGP_FLAG_GRACEFUL_RESTART); |
1829 | return CMD_SUCCESS; | |
1830 | } | |
1831 | ||
1832 | DEFUN (no_bgp_graceful_restart, | |
1833 | no_bgp_graceful_restart_cmd, | |
1834 | "no bgp graceful-restart", | |
1835 | NO_STR | |
1836 | "BGP specific commands\n" | |
1837 | "Graceful restart capability parameters\n") | |
1838 | { | |
cdc2d765 | 1839 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
538621f2 | 1840 | bgp_flag_unset (bgp, BGP_FLAG_GRACEFUL_RESTART); |
1841 | return CMD_SUCCESS; | |
1842 | } | |
1843 | ||
93406d87 | 1844 | DEFUN (bgp_graceful_restart_stalepath_time, |
1845 | bgp_graceful_restart_stalepath_time_cmd, | |
6147e2c6 | 1846 | "bgp graceful-restart stalepath-time (1-3600)", |
93406d87 | 1847 | "BGP specific commands\n" |
1848 | "Graceful restart capability parameters\n" | |
1849 | "Set the max time to hold onto restarting peer's stale paths\n" | |
1850 | "Delay value (seconds)\n") | |
1851 | { | |
cdc2d765 | 1852 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1853 | int idx_number = 3; |
93406d87 | 1854 | u_int32_t stalepath; |
1855 | ||
c500ae40 | 1856 | VTY_GET_INTEGER_RANGE ("stalepath-time", stalepath, argv[idx_number]->arg, 1, 3600); |
93406d87 | 1857 | bgp->stalepath_time = stalepath; |
1858 | return CMD_SUCCESS; | |
1859 | } | |
1860 | ||
eb6f1b41 PG |
1861 | DEFUN (bgp_graceful_restart_restart_time, |
1862 | bgp_graceful_restart_restart_time_cmd, | |
6147e2c6 | 1863 | "bgp graceful-restart restart-time (1-3600)", |
eb6f1b41 PG |
1864 | "BGP specific commands\n" |
1865 | "Graceful restart capability parameters\n" | |
1866 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
1867 | "Delay value (seconds)\n") | |
1868 | { | |
cdc2d765 | 1869 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1870 | int idx_number = 3; |
eb6f1b41 PG |
1871 | u_int32_t restart; |
1872 | ||
c500ae40 | 1873 | VTY_GET_INTEGER_RANGE ("restart-time", restart, argv[idx_number]->arg, 1, 3600); |
eb6f1b41 PG |
1874 | bgp->restart_time = restart; |
1875 | return CMD_SUCCESS; | |
1876 | } | |
1877 | ||
93406d87 | 1878 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
1879 | no_bgp_graceful_restart_stalepath_time_cmd, | |
838758ac | 1880 | "no bgp graceful-restart stalepath-time [(1-3600)]", |
93406d87 | 1881 | NO_STR |
1882 | "BGP specific commands\n" | |
1883 | "Graceful restart capability parameters\n" | |
838758ac DW |
1884 | "Set the max time to hold onto restarting peer's stale paths\n" |
1885 | "Delay value (seconds)\n") | |
93406d87 | 1886 | { |
cdc2d765 | 1887 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 1888 | |
1889 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; | |
1890 | return CMD_SUCCESS; | |
1891 | } | |
1892 | ||
eb6f1b41 PG |
1893 | DEFUN (no_bgp_graceful_restart_restart_time, |
1894 | no_bgp_graceful_restart_restart_time_cmd, | |
838758ac | 1895 | "no bgp graceful-restart restart-time [(1-3600)]", |
eb6f1b41 PG |
1896 | NO_STR |
1897 | "BGP specific commands\n" | |
1898 | "Graceful restart capability parameters\n" | |
838758ac DW |
1899 | "Set the time to wait to delete stale routes before a BGP open message is received\n" |
1900 | "Delay value (seconds)\n") | |
eb6f1b41 | 1901 | { |
cdc2d765 | 1902 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 PG |
1903 | |
1904 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; | |
1905 | return CMD_SUCCESS; | |
1906 | } | |
1907 | ||
43fc21b3 JC |
1908 | DEFUN (bgp_graceful_restart_preserve_fw, |
1909 | bgp_graceful_restart_preserve_fw_cmd, | |
1910 | "bgp graceful-restart preserve-fw-state", | |
1911 | "BGP specific commands\n" | |
1912 | "Graceful restart capability parameters\n" | |
1913 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1914 | { | |
1915 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1916 | bgp_flag_set(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1917 | return CMD_SUCCESS; | |
1918 | } | |
1919 | ||
1920 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
1921 | no_bgp_graceful_restart_preserve_fw_cmd, | |
1922 | "no bgp graceful-restart preserve-fw-state", | |
1923 | NO_STR | |
1924 | "BGP specific commands\n" | |
1925 | "Graceful restart capability parameters\n" | |
1926 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1927 | { | |
1928 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1929 | bgp_flag_unset(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1930 | return CMD_SUCCESS; | |
1931 | } | |
1932 | ||
718e3744 | 1933 | /* "bgp fast-external-failover" configuration. */ |
1934 | DEFUN (bgp_fast_external_failover, | |
1935 | bgp_fast_external_failover_cmd, | |
1936 | "bgp fast-external-failover", | |
1937 | BGP_STR | |
1938 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
1939 | { | |
cdc2d765 | 1940 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1941 | bgp_flag_unset (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); |
1942 | return CMD_SUCCESS; | |
1943 | } | |
1944 | ||
1945 | DEFUN (no_bgp_fast_external_failover, | |
1946 | no_bgp_fast_external_failover_cmd, | |
1947 | "no bgp fast-external-failover", | |
1948 | NO_STR | |
1949 | BGP_STR | |
1950 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
1951 | { | |
cdc2d765 | 1952 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1953 | bgp_flag_set (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); |
1954 | return CMD_SUCCESS; | |
1955 | } | |
6b0655a2 | 1956 | |
718e3744 | 1957 | /* "bgp enforce-first-as" configuration. */ |
1958 | DEFUN (bgp_enforce_first_as, | |
1959 | bgp_enforce_first_as_cmd, | |
1960 | "bgp enforce-first-as", | |
1961 | BGP_STR | |
1962 | "Enforce the first AS for EBGP routes\n") | |
1963 | { | |
cdc2d765 | 1964 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1965 | bgp_flag_set (bgp, BGP_FLAG_ENFORCE_FIRST_AS); |
f31fa004 | 1966 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 1967 | |
718e3744 | 1968 | return CMD_SUCCESS; |
1969 | } | |
1970 | ||
1971 | DEFUN (no_bgp_enforce_first_as, | |
1972 | no_bgp_enforce_first_as_cmd, | |
1973 | "no bgp enforce-first-as", | |
1974 | NO_STR | |
1975 | BGP_STR | |
1976 | "Enforce the first AS for EBGP routes\n") | |
1977 | { | |
cdc2d765 | 1978 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1979 | bgp_flag_unset (bgp, BGP_FLAG_ENFORCE_FIRST_AS); |
f31fa004 | 1980 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 1981 | |
718e3744 | 1982 | return CMD_SUCCESS; |
1983 | } | |
6b0655a2 | 1984 | |
718e3744 | 1985 | /* "bgp bestpath compare-routerid" configuration. */ |
1986 | DEFUN (bgp_bestpath_compare_router_id, | |
1987 | bgp_bestpath_compare_router_id_cmd, | |
1988 | "bgp bestpath compare-routerid", | |
1989 | "BGP specific commands\n" | |
1990 | "Change the default bestpath selection\n" | |
1991 | "Compare router-id for identical EBGP paths\n") | |
1992 | { | |
cdc2d765 | 1993 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1994 | bgp_flag_set (bgp, BGP_FLAG_COMPARE_ROUTER_ID); |
7aafcaca DS |
1995 | bgp_recalculate_all_bestpaths (bgp); |
1996 | ||
718e3744 | 1997 | return CMD_SUCCESS; |
1998 | } | |
1999 | ||
2000 | DEFUN (no_bgp_bestpath_compare_router_id, | |
2001 | no_bgp_bestpath_compare_router_id_cmd, | |
2002 | "no bgp bestpath compare-routerid", | |
2003 | NO_STR | |
2004 | "BGP specific commands\n" | |
2005 | "Change the default bestpath selection\n" | |
2006 | "Compare router-id for identical EBGP paths\n") | |
2007 | { | |
cdc2d765 | 2008 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2009 | bgp_flag_unset (bgp, BGP_FLAG_COMPARE_ROUTER_ID); |
7aafcaca DS |
2010 | bgp_recalculate_all_bestpaths (bgp); |
2011 | ||
718e3744 | 2012 | return CMD_SUCCESS; |
2013 | } | |
6b0655a2 | 2014 | |
718e3744 | 2015 | /* "bgp bestpath as-path ignore" configuration. */ |
2016 | DEFUN (bgp_bestpath_aspath_ignore, | |
2017 | bgp_bestpath_aspath_ignore_cmd, | |
2018 | "bgp bestpath as-path ignore", | |
2019 | "BGP specific commands\n" | |
2020 | "Change the default bestpath selection\n" | |
2021 | "AS-path attribute\n" | |
2022 | "Ignore as-path length in selecting a route\n") | |
2023 | { | |
cdc2d765 | 2024 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2025 | bgp_flag_set (bgp, BGP_FLAG_ASPATH_IGNORE); |
7aafcaca DS |
2026 | bgp_recalculate_all_bestpaths (bgp); |
2027 | ||
718e3744 | 2028 | return CMD_SUCCESS; |
2029 | } | |
2030 | ||
2031 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
2032 | no_bgp_bestpath_aspath_ignore_cmd, | |
2033 | "no bgp bestpath as-path ignore", | |
2034 | NO_STR | |
2035 | "BGP specific commands\n" | |
2036 | "Change the default bestpath selection\n" | |
2037 | "AS-path attribute\n" | |
2038 | "Ignore as-path length in selecting a route\n") | |
2039 | { | |
cdc2d765 | 2040 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2041 | bgp_flag_unset (bgp, BGP_FLAG_ASPATH_IGNORE); |
7aafcaca DS |
2042 | bgp_recalculate_all_bestpaths (bgp); |
2043 | ||
718e3744 | 2044 | return CMD_SUCCESS; |
2045 | } | |
6b0655a2 | 2046 | |
6811845b | 2047 | /* "bgp bestpath as-path confed" configuration. */ |
2048 | DEFUN (bgp_bestpath_aspath_confed, | |
2049 | bgp_bestpath_aspath_confed_cmd, | |
2050 | "bgp bestpath as-path confed", | |
2051 | "BGP specific commands\n" | |
2052 | "Change the default bestpath selection\n" | |
2053 | "AS-path attribute\n" | |
2054 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2055 | { | |
cdc2d765 | 2056 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6811845b | 2057 | bgp_flag_set (bgp, BGP_FLAG_ASPATH_CONFED); |
7aafcaca DS |
2058 | bgp_recalculate_all_bestpaths (bgp); |
2059 | ||
6811845b | 2060 | return CMD_SUCCESS; |
2061 | } | |
2062 | ||
2063 | DEFUN (no_bgp_bestpath_aspath_confed, | |
2064 | no_bgp_bestpath_aspath_confed_cmd, | |
2065 | "no bgp bestpath as-path confed", | |
2066 | NO_STR | |
2067 | "BGP specific commands\n" | |
2068 | "Change the default bestpath selection\n" | |
2069 | "AS-path attribute\n" | |
2070 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2071 | { | |
cdc2d765 | 2072 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6811845b | 2073 | bgp_flag_unset (bgp, BGP_FLAG_ASPATH_CONFED); |
7aafcaca DS |
2074 | bgp_recalculate_all_bestpaths (bgp); |
2075 | ||
6811845b | 2076 | return CMD_SUCCESS; |
2077 | } | |
6b0655a2 | 2078 | |
2fdd455c PM |
2079 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
2080 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
2081 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2082 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2083 | "BGP specific commands\n" |
2084 | "Change the default bestpath selection\n" | |
2085 | "AS-path attribute\n" | |
2086 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2087 | "Generate an AS_SET\n" |
16fc1eec DS |
2088 | "Do not generate an AS_SET\n") |
2089 | { | |
cdc2d765 | 2090 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4c4ff4c1 | 2091 | int idx = 0; |
16fc1eec | 2092 | bgp_flag_set (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); |
219178b6 DW |
2093 | |
2094 | /* no-as-set is now the default behavior so we can silently | |
2095 | * ignore it */ | |
4c4ff4c1 | 2096 | if (argv_find (argv, argc, "as-set", &idx)) |
219178b6 DW |
2097 | bgp_flag_set (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
2098 | else | |
2099 | bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET) ; | |
2100 | ||
7aafcaca DS |
2101 | bgp_recalculate_all_bestpaths (bgp); |
2102 | ||
16fc1eec DS |
2103 | return CMD_SUCCESS; |
2104 | } | |
2105 | ||
219178b6 DW |
2106 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
2107 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2108 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2109 | NO_STR |
2110 | "BGP specific commands\n" | |
2111 | "Change the default bestpath selection\n" | |
2112 | "AS-path attribute\n" | |
2113 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2114 | "Generate an AS_SET\n" |
16fc1eec DS |
2115 | "Do not generate an AS_SET\n") |
2116 | { | |
cdc2d765 | 2117 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
16fc1eec | 2118 | bgp_flag_unset (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); |
219178b6 | 2119 | bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
7aafcaca DS |
2120 | bgp_recalculate_all_bestpaths (bgp); |
2121 | ||
2fdd455c PM |
2122 | return CMD_SUCCESS; |
2123 | } | |
6b0655a2 | 2124 | |
848973c7 | 2125 | /* "bgp log-neighbor-changes" configuration. */ |
2126 | DEFUN (bgp_log_neighbor_changes, | |
2127 | bgp_log_neighbor_changes_cmd, | |
2128 | "bgp log-neighbor-changes", | |
2129 | "BGP specific commands\n" | |
2130 | "Log neighbor up/down and reset reason\n") | |
2131 | { | |
cdc2d765 | 2132 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
848973c7 | 2133 | bgp_flag_set (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
2134 | return CMD_SUCCESS; | |
2135 | } | |
2136 | ||
2137 | DEFUN (no_bgp_log_neighbor_changes, | |
2138 | no_bgp_log_neighbor_changes_cmd, | |
2139 | "no bgp log-neighbor-changes", | |
2140 | NO_STR | |
2141 | "BGP specific commands\n" | |
2142 | "Log neighbor up/down and reset reason\n") | |
2143 | { | |
cdc2d765 | 2144 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
848973c7 | 2145 | bgp_flag_unset (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
2146 | return CMD_SUCCESS; | |
2147 | } | |
6b0655a2 | 2148 | |
718e3744 | 2149 | /* "bgp bestpath med" configuration. */ |
2150 | DEFUN (bgp_bestpath_med, | |
2151 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 2152 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2153 | "BGP specific commands\n" |
2154 | "Change the default bestpath selection\n" | |
2155 | "MED attribute\n" | |
2156 | "Compare MED among confederation paths\n" | |
838758ac DW |
2157 | "Treat missing MED as the least preferred one\n" |
2158 | "Treat missing MED as the least preferred one\n" | |
2159 | "Compare MED among confederation paths\n") | |
718e3744 | 2160 | { |
cdc2d765 | 2161 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6cbd1915 QY |
2162 | |
2163 | int idx = 0; | |
2164 | if (argv_find (argv, argc, "confed", &idx)) | |
2165 | bgp_flag_set (bgp, BGP_FLAG_MED_CONFED); | |
2166 | idx = 0; | |
2167 | if (argv_find (argv, argc, "missing-as-worst", &idx)) | |
2168 | bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
e52702f2 | 2169 | |
7aafcaca DS |
2170 | bgp_recalculate_all_bestpaths (bgp); |
2171 | ||
718e3744 | 2172 | return CMD_SUCCESS; |
2173 | } | |
2174 | ||
718e3744 | 2175 | DEFUN (no_bgp_bestpath_med, |
2176 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2177 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2178 | NO_STR |
2179 | "BGP specific commands\n" | |
2180 | "Change the default bestpath selection\n" | |
2181 | "MED attribute\n" | |
2182 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2183 | "Treat missing MED as the least preferred one\n" |
2184 | "Treat missing MED as the least preferred one\n" | |
2185 | "Compare MED among confederation paths\n") | |
718e3744 | 2186 | { |
cdc2d765 | 2187 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
e52702f2 | 2188 | |
6cbd1915 QY |
2189 | int idx = 0; |
2190 | if (argv_find (argv, argc, "confed", &idx)) | |
718e3744 | 2191 | bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED); |
6cbd1915 QY |
2192 | idx = 0; |
2193 | if (argv_find (argv, argc, "missing-as-worst", &idx)) | |
718e3744 | 2194 | bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST); |
2195 | ||
7aafcaca DS |
2196 | bgp_recalculate_all_bestpaths (bgp); |
2197 | ||
718e3744 | 2198 | return CMD_SUCCESS; |
2199 | } | |
2200 | ||
718e3744 | 2201 | /* "no bgp default ipv4-unicast". */ |
2202 | DEFUN (no_bgp_default_ipv4_unicast, | |
2203 | no_bgp_default_ipv4_unicast_cmd, | |
2204 | "no bgp default ipv4-unicast", | |
2205 | NO_STR | |
2206 | "BGP specific commands\n" | |
2207 | "Configure BGP defaults\n" | |
2208 | "Activate ipv4-unicast for a peer by default\n") | |
2209 | { | |
cdc2d765 | 2210 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2211 | bgp_flag_set (bgp, BGP_FLAG_NO_DEFAULT_IPV4); |
2212 | return CMD_SUCCESS; | |
2213 | } | |
2214 | ||
2215 | DEFUN (bgp_default_ipv4_unicast, | |
2216 | bgp_default_ipv4_unicast_cmd, | |
2217 | "bgp default ipv4-unicast", | |
2218 | "BGP specific commands\n" | |
2219 | "Configure BGP defaults\n" | |
2220 | "Activate ipv4-unicast for a peer by default\n") | |
2221 | { | |
cdc2d765 | 2222 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2223 | bgp_flag_unset (bgp, BGP_FLAG_NO_DEFAULT_IPV4); |
2224 | return CMD_SUCCESS; | |
2225 | } | |
6b0655a2 | 2226 | |
04b6bdc0 DW |
2227 | /* Display hostname in certain command outputs */ |
2228 | DEFUN (bgp_default_show_hostname, | |
2229 | bgp_default_show_hostname_cmd, | |
2230 | "bgp default show-hostname", | |
2231 | "BGP specific commands\n" | |
2232 | "Configure BGP defaults\n" | |
2233 | "Show hostname in certain command ouputs\n") | |
2234 | { | |
cdc2d765 | 2235 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
04b6bdc0 DW |
2236 | bgp_flag_set (bgp, BGP_FLAG_SHOW_HOSTNAME); |
2237 | return CMD_SUCCESS; | |
2238 | } | |
2239 | ||
2240 | DEFUN (no_bgp_default_show_hostname, | |
2241 | no_bgp_default_show_hostname_cmd, | |
2242 | "no bgp default show-hostname", | |
2243 | NO_STR | |
2244 | "BGP specific commands\n" | |
2245 | "Configure BGP defaults\n" | |
2246 | "Show hostname in certain command ouputs\n") | |
2247 | { | |
cdc2d765 | 2248 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
04b6bdc0 DW |
2249 | bgp_flag_unset (bgp, BGP_FLAG_SHOW_HOSTNAME); |
2250 | return CMD_SUCCESS; | |
2251 | } | |
2252 | ||
8233ef81 | 2253 | /* "bgp network import-check" configuration. */ |
718e3744 | 2254 | DEFUN (bgp_network_import_check, |
2255 | bgp_network_import_check_cmd, | |
5623e905 | 2256 | "bgp network import-check", |
718e3744 | 2257 | "BGP specific commands\n" |
2258 | "BGP network command\n" | |
5623e905 | 2259 | "Check BGP network route exists in IGP\n") |
718e3744 | 2260 | { |
cdc2d765 | 2261 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
078430f6 DS |
2262 | if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) |
2263 | { | |
2264 | bgp_flag_set (bgp, BGP_FLAG_IMPORT_CHECK); | |
5623e905 | 2265 | bgp_static_redo_import_check(bgp); |
078430f6 DS |
2266 | } |
2267 | ||
718e3744 | 2268 | return CMD_SUCCESS; |
2269 | } | |
2270 | ||
8233ef81 DW |
2271 | ALIAS_HIDDEN (bgp_network_import_check, |
2272 | bgp_network_import_check_exact_cmd, | |
2273 | "bgp network import-check exact", | |
2274 | "BGP specific commands\n" | |
2275 | "BGP network command\n" | |
2276 | "Check BGP network route exists in IGP\n" | |
2277 | "Match route precisely\n") | |
2278 | ||
718e3744 | 2279 | DEFUN (no_bgp_network_import_check, |
2280 | no_bgp_network_import_check_cmd, | |
5623e905 | 2281 | "no bgp network import-check", |
718e3744 | 2282 | NO_STR |
2283 | "BGP specific commands\n" | |
2284 | "BGP network command\n" | |
2285 | "Check BGP network route exists in IGP\n") | |
2286 | { | |
cdc2d765 | 2287 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
078430f6 DS |
2288 | if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) |
2289 | { | |
2290 | bgp_flag_unset (bgp, BGP_FLAG_IMPORT_CHECK); | |
078430f6 DS |
2291 | bgp_static_redo_import_check(bgp); |
2292 | } | |
5623e905 | 2293 | |
718e3744 | 2294 | return CMD_SUCCESS; |
2295 | } | |
6b0655a2 | 2296 | |
718e3744 | 2297 | DEFUN (bgp_default_local_preference, |
2298 | bgp_default_local_preference_cmd, | |
6147e2c6 | 2299 | "bgp default local-preference (0-4294967295)", |
718e3744 | 2300 | "BGP specific commands\n" |
2301 | "Configure BGP defaults\n" | |
2302 | "local preference (higher=more preferred)\n" | |
2303 | "Configure default local preference value\n") | |
2304 | { | |
cdc2d765 | 2305 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2306 | int idx_number = 3; |
718e3744 | 2307 | u_int32_t local_pref; |
2308 | ||
c500ae40 | 2309 | VTY_GET_INTEGER ("local preference", local_pref, argv[idx_number]->arg); |
718e3744 | 2310 | |
2311 | bgp_default_local_preference_set (bgp, local_pref); | |
f31fa004 | 2312 | bgp_clear_star_soft_in (vty, bgp->name); |
718e3744 | 2313 | |
2314 | return CMD_SUCCESS; | |
2315 | } | |
2316 | ||
2317 | DEFUN (no_bgp_default_local_preference, | |
2318 | no_bgp_default_local_preference_cmd, | |
838758ac | 2319 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 2320 | NO_STR |
2321 | "BGP specific commands\n" | |
2322 | "Configure BGP defaults\n" | |
838758ac DW |
2323 | "local preference (higher=more preferred)\n" |
2324 | "Configure default local preference value\n") | |
718e3744 | 2325 | { |
cdc2d765 | 2326 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2327 | bgp_default_local_preference_unset (bgp); |
f31fa004 | 2328 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 2329 | |
718e3744 | 2330 | return CMD_SUCCESS; |
2331 | } | |
2332 | ||
6b0655a2 | 2333 | |
3f9c7369 DS |
2334 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
2335 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 2336 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
2337 | "BGP specific commands\n" |
2338 | "Configure BGP defaults\n" | |
2339 | "subgroup-pkt-queue-max\n" | |
2340 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 2341 | { |
cdc2d765 | 2342 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2343 | int idx_number = 3; |
3f9c7369 | 2344 | u_int32_t max_size; |
8bd9d948 | 2345 | |
c500ae40 | 2346 | VTY_GET_INTEGER ("subgroup packet queue max", max_size, argv[idx_number]->arg); |
3f9c7369 DS |
2347 | |
2348 | bgp_default_subgroup_pkt_queue_max_set (bgp, max_size); | |
2349 | ||
2350 | return CMD_SUCCESS; | |
2351 | } | |
2352 | ||
2353 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
2354 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 2355 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
2356 | NO_STR |
2357 | "BGP specific commands\n" | |
2358 | "Configure BGP defaults\n" | |
838758ac DW |
2359 | "subgroup-pkt-queue-max\n" |
2360 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 2361 | { |
cdc2d765 | 2362 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3f9c7369 DS |
2363 | bgp_default_subgroup_pkt_queue_max_unset (bgp); |
2364 | return CMD_SUCCESS; | |
8bd9d948 DS |
2365 | } |
2366 | ||
813d4307 | 2367 | |
8bd9d948 DS |
2368 | DEFUN (bgp_rr_allow_outbound_policy, |
2369 | bgp_rr_allow_outbound_policy_cmd, | |
2370 | "bgp route-reflector allow-outbound-policy", | |
2371 | "BGP specific commands\n" | |
2372 | "Allow modifications made by out route-map\n" | |
2373 | "on ibgp neighbors\n") | |
2374 | { | |
cdc2d765 | 2375 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 DS |
2376 | |
2377 | if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) | |
2378 | { | |
2379 | bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3f9c7369 | 2380 | update_group_announce_rrclients(bgp); |
f31fa004 | 2381 | bgp_clear_star_soft_out (vty, bgp->name); |
8bd9d948 DS |
2382 | } |
2383 | ||
2384 | return CMD_SUCCESS; | |
2385 | } | |
2386 | ||
2387 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
2388 | no_bgp_rr_allow_outbound_policy_cmd, | |
2389 | "no bgp route-reflector allow-outbound-policy", | |
2390 | NO_STR | |
2391 | "BGP specific commands\n" | |
2392 | "Allow modifications made by out route-map\n" | |
2393 | "on ibgp neighbors\n") | |
2394 | { | |
cdc2d765 | 2395 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 DS |
2396 | |
2397 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) | |
2398 | { | |
2399 | bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3f9c7369 | 2400 | update_group_announce_rrclients(bgp); |
f31fa004 | 2401 | bgp_clear_star_soft_out (vty, bgp->name); |
8bd9d948 DS |
2402 | } |
2403 | ||
2404 | return CMD_SUCCESS; | |
2405 | } | |
2406 | ||
f14e6fdb DS |
2407 | DEFUN (bgp_listen_limit, |
2408 | bgp_listen_limit_cmd, | |
9ccf14f7 | 2409 | "bgp listen limit (1-5000)", |
f14e6fdb DS |
2410 | "BGP specific commands\n" |
2411 | "Configure BGP defaults\n" | |
2412 | "maximum number of BGP Dynamic Neighbors that can be created\n" | |
2413 | "Configure Dynamic Neighbors listen limit value\n") | |
2414 | { | |
cdc2d765 | 2415 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2416 | int idx_number = 3; |
f14e6fdb DS |
2417 | int listen_limit; |
2418 | ||
c500ae40 | 2419 | VTY_GET_INTEGER_RANGE ("listen limit", listen_limit, argv[idx_number]->arg, |
f14e6fdb DS |
2420 | BGP_DYNAMIC_NEIGHBORS_LIMIT_MIN, |
2421 | BGP_DYNAMIC_NEIGHBORS_LIMIT_MAX); | |
2422 | ||
2423 | bgp_listen_limit_set (bgp, listen_limit); | |
2424 | ||
2425 | return CMD_SUCCESS; | |
2426 | } | |
2427 | ||
2428 | DEFUN (no_bgp_listen_limit, | |
2429 | no_bgp_listen_limit_cmd, | |
838758ac | 2430 | "no bgp listen limit [(1-5000)]", |
f14e6fdb DS |
2431 | "BGP specific commands\n" |
2432 | "Configure BGP defaults\n" | |
2433 | "unset maximum number of BGP Dynamic Neighbors that can be created\n" | |
838758ac DW |
2434 | "Configure Dynamic Neighbors listen limit value to default\n" |
2435 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 2436 | { |
cdc2d765 | 2437 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f14e6fdb DS |
2438 | bgp_listen_limit_unset (bgp); |
2439 | return CMD_SUCCESS; | |
2440 | } | |
2441 | ||
2442 | ||
20eb8864 | 2443 | /* |
2444 | * Check if this listen range is already configured. Check for exact | |
2445 | * match or overlap based on input. | |
2446 | */ | |
2447 | static struct peer_group * | |
2448 | listen_range_exists (struct bgp *bgp, struct prefix *range, int exact) | |
2449 | { | |
2450 | struct listnode *node, *nnode; | |
2451 | struct listnode *node1, *nnode1; | |
2452 | struct peer_group *group; | |
2453 | struct prefix *lr; | |
2454 | afi_t afi; | |
2455 | int match; | |
2456 | ||
2457 | afi = family2afi(range->family); | |
2458 | for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) | |
2459 | { | |
2460 | for (ALL_LIST_ELEMENTS (group->listen_range[afi], node1, | |
2461 | nnode1, lr)) | |
2462 | { | |
2463 | if (exact) | |
2464 | match = prefix_same (range, lr); | |
2465 | else | |
2466 | match = (prefix_match (range, lr) || prefix_match (lr, range)); | |
2467 | if (match) | |
2468 | return group; | |
2469 | } | |
2470 | } | |
2471 | ||
2472 | return NULL; | |
2473 | } | |
2474 | ||
f14e6fdb DS |
2475 | DEFUN (bgp_listen_range, |
2476 | bgp_listen_range_cmd, | |
9ccf14f7 | 2477 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
f14e6fdb | 2478 | "BGP specific commands\n" |
d7fa34c1 QY |
2479 | "Configure BGP dynamic neighbors listen range\n" |
2480 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
2481 | NEIGHBOR_ADDR_STR |
2482 | "Member of the peer-group\n" | |
2483 | "Peer-group name\n") | |
f14e6fdb | 2484 | { |
cdc2d765 | 2485 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f14e6fdb | 2486 | struct prefix range; |
20eb8864 | 2487 | struct peer_group *group, *existing_group; |
f14e6fdb DS |
2488 | afi_t afi; |
2489 | int ret; | |
d7fa34c1 | 2490 | int idx = 0; |
f14e6fdb | 2491 | |
d7fa34c1 QY |
2492 | argv_find (argv, argc, "A.B.C.D/M", &idx); |
2493 | argv_find (argv, argc, "X:X::X:X/M", &idx); | |
2494 | char *prefix = argv[idx]->arg; | |
2495 | argv_find (argv, argc, "WORD", &idx); | |
2496 | char *peergroup = argv[idx]->arg; | |
f14e6fdb | 2497 | |
f14e6fdb | 2498 | /* Convert IP prefix string to struct prefix. */ |
d7fa34c1 | 2499 | ret = str2prefix (prefix, &range); |
f14e6fdb DS |
2500 | if (! ret) |
2501 | { | |
2502 | vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE); | |
2503 | return CMD_WARNING; | |
2504 | } | |
2505 | ||
2506 | afi = family2afi(range.family); | |
2507 | ||
f14e6fdb DS |
2508 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6)) |
2509 | { | |
2510 | vty_out (vty, "%% Malformed listen range (link-local address)%s", | |
2511 | VTY_NEWLINE); | |
2512 | return CMD_WARNING; | |
2513 | } | |
f14e6fdb DS |
2514 | |
2515 | apply_mask (&range); | |
2516 | ||
20eb8864 | 2517 | /* Check if same listen range is already configured. */ |
2518 | existing_group = listen_range_exists (bgp, &range, 1); | |
2519 | if (existing_group) | |
2520 | { | |
d7fa34c1 | 2521 | if (strcmp (existing_group->name, peergroup) == 0) |
20eb8864 | 2522 | return CMD_SUCCESS; |
2523 | else | |
2524 | { | |
2525 | vty_out (vty, "%% Same listen range is attached to peer-group %s%s", | |
2526 | existing_group->name, VTY_NEWLINE); | |
2527 | return CMD_WARNING; | |
2528 | } | |
2529 | } | |
2530 | ||
2531 | /* Check if an overlapping listen range exists. */ | |
2532 | if (listen_range_exists (bgp, &range, 0)) | |
2533 | { | |
2534 | vty_out (vty, "%% Listen range overlaps with existing listen range%s", | |
2535 | VTY_NEWLINE); | |
2536 | return CMD_WARNING; | |
2537 | } | |
f14e6fdb | 2538 | |
d7fa34c1 | 2539 | group = peer_group_lookup (bgp, peergroup); |
f14e6fdb DS |
2540 | if (! group) |
2541 | { | |
2542 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
2543 | return CMD_WARNING; | |
2544 | } | |
2545 | ||
2546 | ret = peer_group_listen_range_add(group, &range); | |
2547 | return bgp_vty_return (vty, ret); | |
2548 | } | |
2549 | ||
2550 | DEFUN (no_bgp_listen_range, | |
2551 | no_bgp_listen_range_cmd, | |
d7fa34c1 QY |
2552 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
2553 | NO_STR | |
f14e6fdb | 2554 | "BGP specific commands\n" |
d7fa34c1 QY |
2555 | "Unconfigure BGP dynamic neighbors listen range\n" |
2556 | "Unconfigure BGP dynamic neighbors listen range\n" | |
2557 | NEIGHBOR_ADDR_STR | |
2558 | "Member of the peer-group\n" | |
2559 | "Peer-group name\n") | |
f14e6fdb | 2560 | { |
cdc2d765 | 2561 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f14e6fdb DS |
2562 | struct prefix range; |
2563 | struct peer_group *group; | |
2564 | afi_t afi; | |
2565 | int ret; | |
d7fa34c1 QY |
2566 | int idx = 0; |
2567 | ||
2568 | argv_find (argv, argc, "A.B.C.D/M", &idx); | |
2569 | argv_find (argv, argc, "X:X::X:X/M", &idx); | |
2570 | char *prefix = argv[idx]->arg; | |
2571 | argv_find (argv, argc, "WORD", &idx); | |
2572 | char *peergroup = argv[idx]->arg; | |
f14e6fdb | 2573 | |
c500ae40 | 2574 | // VTY_GET_IPV4_PREFIX ("listen range", range, argv[idx_ipv4_prefixlen]->arg); |
f14e6fdb DS |
2575 | |
2576 | /* Convert IP prefix string to struct prefix. */ | |
d7fa34c1 | 2577 | ret = str2prefix (prefix, &range); |
f14e6fdb DS |
2578 | if (! ret) |
2579 | { | |
2580 | vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE); | |
2581 | return CMD_WARNING; | |
2582 | } | |
2583 | ||
2584 | afi = family2afi(range.family); | |
2585 | ||
f14e6fdb DS |
2586 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6)) |
2587 | { | |
2588 | vty_out (vty, "%% Malformed listen range (link-local address)%s", | |
2589 | VTY_NEWLINE); | |
2590 | return CMD_WARNING; | |
2591 | } | |
f14e6fdb DS |
2592 | |
2593 | apply_mask (&range); | |
2594 | ||
d7fa34c1 | 2595 | group = peer_group_lookup (bgp, peergroup); |
f14e6fdb DS |
2596 | if (! group) |
2597 | { | |
2598 | vty_out (vty, "%% Peer-group does not exist%s", VTY_NEWLINE); | |
2599 | return CMD_WARNING; | |
2600 | } | |
2601 | ||
2602 | ret = peer_group_listen_range_del(group, &range); | |
2603 | return bgp_vty_return (vty, ret); | |
2604 | } | |
2605 | ||
2606 | int | |
2607 | bgp_config_write_listen (struct vty *vty, struct bgp *bgp) | |
2608 | { | |
2609 | struct peer_group *group; | |
2610 | struct listnode *node, *nnode, *rnode, *nrnode; | |
2611 | struct prefix *range; | |
2612 | afi_t afi; | |
4690c7d7 | 2613 | char buf[PREFIX2STR_BUFFER]; |
f14e6fdb DS |
2614 | |
2615 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
2616 | vty_out (vty, " bgp listen limit %d%s", | |
2617 | bgp->dynamic_neighbors_limit, VTY_NEWLINE); | |
2618 | ||
2619 | for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) | |
2620 | { | |
2621 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
2622 | { | |
2623 | for (ALL_LIST_ELEMENTS (group->listen_range[afi], rnode, nrnode, range)) | |
2624 | { | |
2625 | prefix2str(range, buf, sizeof(buf)); | |
2626 | vty_out(vty, " bgp listen range %s peer-group %s%s", | |
2627 | buf, group->name, VTY_NEWLINE); | |
2628 | } | |
2629 | } | |
2630 | } | |
2631 | ||
2632 | return 0; | |
2633 | } | |
2634 | ||
2635 | ||
907f92c8 DS |
2636 | DEFUN (bgp_disable_connected_route_check, |
2637 | bgp_disable_connected_route_check_cmd, | |
2638 | "bgp disable-ebgp-connected-route-check", | |
2639 | "BGP specific commands\n" | |
2640 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2641 | { | |
cdc2d765 | 2642 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
907f92c8 | 2643 | bgp_flag_set (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); |
f31fa004 | 2644 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 2645 | |
907f92c8 DS |
2646 | return CMD_SUCCESS; |
2647 | } | |
2648 | ||
2649 | DEFUN (no_bgp_disable_connected_route_check, | |
2650 | no_bgp_disable_connected_route_check_cmd, | |
2651 | "no bgp disable-ebgp-connected-route-check", | |
2652 | NO_STR | |
2653 | "BGP specific commands\n" | |
2654 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2655 | { | |
cdc2d765 | 2656 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
907f92c8 | 2657 | bgp_flag_unset (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); |
f31fa004 | 2658 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 2659 | |
907f92c8 DS |
2660 | return CMD_SUCCESS; |
2661 | } | |
2662 | ||
2663 | ||
718e3744 | 2664 | static int |
e52702f2 | 2665 | peer_remote_as_vty (struct vty *vty, const char *peer_str, |
fd79ac91 | 2666 | const char *as_str, afi_t afi, safi_t safi) |
718e3744 | 2667 | { |
cdc2d765 | 2668 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2669 | int ret; |
718e3744 | 2670 | as_t as; |
0299c004 | 2671 | int as_type = AS_SPECIFIED; |
718e3744 | 2672 | union sockunion su; |
2673 | ||
7ae5fc81 | 2674 | if (as_str[0] == 'i') |
0299c004 DS |
2675 | { |
2676 | as = 0; | |
2677 | as_type = AS_INTERNAL; | |
2678 | } | |
7ae5fc81 | 2679 | else if (as_str[0] == 'e') |
0299c004 DS |
2680 | { |
2681 | as = 0; | |
2682 | as_type = AS_EXTERNAL; | |
2683 | } | |
2684 | else | |
2685 | { | |
2686 | /* Get AS number. */ | |
2687 | VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX); | |
2688 | } | |
718e3744 | 2689 | |
2690 | /* If peer is peer group, call proper function. */ | |
2691 | ret = str2sockunion (peer_str, &su); | |
2692 | if (ret < 0) | |
2693 | { | |
a80beece | 2694 | /* Check for peer by interface */ |
0299c004 | 2695 | ret = peer_remote_as (bgp, NULL, peer_str, &as, as_type, afi, safi); |
718e3744 | 2696 | if (ret < 0) |
a80beece | 2697 | { |
0299c004 | 2698 | ret = peer_group_remote_as (bgp, peer_str, &as, as_type); |
a80beece DS |
2699 | if (ret < 0) |
2700 | { | |
2701 | vty_out (vty, "%% Create the peer-group or interface first%s", | |
2702 | VTY_NEWLINE); | |
2703 | return CMD_WARNING; | |
2704 | } | |
2705 | return CMD_SUCCESS; | |
2706 | } | |
718e3744 | 2707 | } |
a80beece | 2708 | else |
718e3744 | 2709 | { |
6aeb9e78 | 2710 | if (peer_address_self_check (bgp, &su)) |
a80beece DS |
2711 | { |
2712 | vty_out (vty, "%% Can not configure the local system as neighbor%s", | |
2713 | VTY_NEWLINE); | |
2714 | return CMD_WARNING; | |
2715 | } | |
0299c004 | 2716 | ret = peer_remote_as (bgp, &su, NULL, &as, as_type, afi, safi); |
718e3744 | 2717 | } |
2718 | ||
718e3744 | 2719 | /* This peer belongs to peer group. */ |
2720 | switch (ret) | |
2721 | { | |
2722 | case BGP_ERR_PEER_GROUP_MEMBER: | |
aea339f7 | 2723 | vty_out (vty, "%% Peer-group AS %u. Cannot configure remote-as for member%s", as, VTY_NEWLINE); |
718e3744 | 2724 | return CMD_WARNING; |
718e3744 | 2725 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: |
aea339f7 | 2726 | 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 | 2727 | return CMD_WARNING; |
718e3744 | 2728 | } |
2729 | return bgp_vty_return (vty, ret); | |
2730 | } | |
2731 | ||
2732 | DEFUN (neighbor_remote_as, | |
2733 | neighbor_remote_as_cmd, | |
3a2d747c | 2734 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2735 | NEIGHBOR_STR |
2736 | NEIGHBOR_ADDR_STR2 | |
2737 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 2738 | AS_STR |
3a2d747c QY |
2739 | "Internal BGP peer\n" |
2740 | "External BGP peer\n") | |
718e3744 | 2741 | { |
c500ae40 DW |
2742 | int idx_peer = 1; |
2743 | int idx_remote_as = 3; | |
2744 | return peer_remote_as_vty (vty, argv[idx_peer]->arg, argv[idx_remote_as]->arg, AFI_IP, SAFI_UNICAST); | |
718e3744 | 2745 | } |
6b0655a2 | 2746 | |
4c48cf63 DW |
2747 | static int |
2748 | peer_conf_interface_get (struct vty *vty, const char *conf_if, afi_t afi, | |
b3a39dc5 DD |
2749 | safi_t safi, int v6only, const char *peer_group_name, |
2750 | const char *as_str) | |
a80beece | 2751 | { |
cdc2d765 | 2752 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
b3a39dc5 DD |
2753 | as_t as = 0; |
2754 | int as_type = AS_UNSPECIFIED; | |
a80beece DS |
2755 | struct peer *peer; |
2756 | struct peer_group *group; | |
4c48cf63 DW |
2757 | int ret = 0; |
2758 | union sockunion su; | |
a80beece | 2759 | |
4c48cf63 DW |
2760 | group = peer_group_lookup (bgp, conf_if); |
2761 | ||
a80beece DS |
2762 | if (group) |
2763 | { | |
2764 | vty_out (vty, "%% Name conflict with peer-group %s", VTY_NEWLINE); | |
2765 | return CMD_WARNING; | |
2766 | } | |
2767 | ||
b3a39dc5 DD |
2768 | if (as_str) |
2769 | { | |
7ae5fc81 | 2770 | if (as_str[0] == 'i') |
b3a39dc5 DD |
2771 | { |
2772 | as_type = AS_INTERNAL; | |
2773 | } | |
7ae5fc81 | 2774 | else if (as_str[0] == 'e') |
b3a39dc5 DD |
2775 | { |
2776 | as_type = AS_EXTERNAL; | |
2777 | } | |
2778 | else | |
2779 | { | |
2780 | /* Get AS number. */ | |
2781 | VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX); | |
2782 | as_type = AS_SPECIFIED; | |
2783 | } | |
2784 | } | |
2785 | ||
4c48cf63 DW |
2786 | peer = peer_lookup_by_conf_if (bgp, conf_if); |
2787 | if (!peer) | |
2788 | { | |
2789 | if (bgp_flag_check (bgp, BGP_FLAG_NO_DEFAULT_IPV4) | |
2790 | && afi == AFI_IP && safi == SAFI_UNICAST) | |
b3a39dc5 DD |
2791 | peer = peer_create (NULL, conf_if, bgp, bgp->as, as, as_type, 0, 0, |
2792 | NULL); | |
4c48cf63 | 2793 | else |
b3a39dc5 DD |
2794 | peer = peer_create (NULL, conf_if, bgp, bgp->as, as, as_type, afi, safi, |
2795 | NULL); | |
4c48cf63 DW |
2796 | |
2797 | if (peer && v6only) | |
2798 | SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
4a04e5f7 | 2799 | |
2800 | /* Request zebra to initiate IPv6 RAs on this interface. We do this | |
2801 | * any unnumbered peer in order to not worry about run-time transitions | |
2802 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 address | |
2803 | * gets deleted later etc.) | |
2804 | */ | |
2805 | if (peer->ifp) | |
b3a39dc5 DD |
2806 | { |
2807 | bgp_zebra_initiate_radv (bgp, peer); | |
2808 | } | |
2809 | peer_flag_set (peer, PEER_FLAG_CAPABILITY_ENHE); | |
4c48cf63 DW |
2810 | } |
2811 | else if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) || | |
2812 | (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) | |
2813 | { | |
2814 | if (v6only) | |
2815 | SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2816 | else | |
2817 | UNSET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2818 | ||
2819 | /* v6only flag changed. Reset bgp seesion */ | |
2820 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) | |
2821 | { | |
2822 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
2823 | bgp_notify_send (peer, BGP_NOTIFY_CEASE, | |
2824 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2825 | } | |
2826 | else | |
2827 | bgp_session_reset(peer); | |
2828 | } | |
2829 | ||
a80beece DS |
2830 | if (!peer) |
2831 | return CMD_WARNING; | |
2832 | ||
4c48cf63 DW |
2833 | if (peer_group_name) |
2834 | { | |
2835 | group = peer_group_lookup (bgp, peer_group_name); | |
2836 | if (! group) | |
2837 | { | |
2838 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
2839 | return CMD_WARNING; | |
2840 | } | |
2841 | ||
2842 | ret = peer_group_bind (bgp, &su, peer, group, &as); | |
2843 | } | |
2844 | ||
2845 | return bgp_vty_return (vty, ret); | |
a80beece DS |
2846 | } |
2847 | ||
4c48cf63 DW |
2848 | DEFUN (neighbor_interface_config, |
2849 | neighbor_interface_config_cmd, | |
31500417 | 2850 | "neighbor WORD interface [peer-group WORD]", |
4c48cf63 DW |
2851 | NEIGHBOR_STR |
2852 | "Interface name or neighbor tag\n" | |
31500417 DW |
2853 | "Enable BGP on interface\n" |
2854 | "Member of the peer-group\n" | |
16cedbb0 | 2855 | "Peer-group name\n") |
4c48cf63 | 2856 | { |
c500ae40 | 2857 | int idx_word = 1; |
31500417 DW |
2858 | int idx_peer_group_word = 4; |
2859 | ||
2860 | if (argc > idx_peer_group_word) | |
c500ae40 | 2861 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, |
31500417 | 2862 | argv[idx_peer_group_word]->arg, NULL); |
4c48cf63 | 2863 | else |
c500ae40 | 2864 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, |
b3a39dc5 | 2865 | NULL, NULL); |
4c48cf63 DW |
2866 | } |
2867 | ||
4c48cf63 DW |
2868 | DEFUN (neighbor_interface_config_v6only, |
2869 | neighbor_interface_config_v6only_cmd, | |
31500417 | 2870 | "neighbor WORD interface v6only [peer-group WORD]", |
4c48cf63 DW |
2871 | NEIGHBOR_STR |
2872 | "Interface name or neighbor tag\n" | |
2873 | "Enable BGP on interface\n" | |
31500417 DW |
2874 | "Enable BGP with v6 link-local only\n" |
2875 | "Member of the peer-group\n" | |
16cedbb0 | 2876 | "Peer-group name\n") |
4c48cf63 | 2877 | { |
c500ae40 | 2878 | int idx_word = 1; |
31500417 DW |
2879 | int idx_peer_group_word = 5; |
2880 | ||
2881 | if (argc > idx_peer_group_word) | |
2882 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
2883 | argv[idx_peer_group_word]->arg, NULL); | |
2884 | ||
c500ae40 | 2885 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, |
31500417 | 2886 | NULL, NULL); |
4c48cf63 DW |
2887 | } |
2888 | ||
a80beece | 2889 | |
b3a39dc5 DD |
2890 | DEFUN (neighbor_interface_config_remote_as, |
2891 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 2892 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2893 | NEIGHBOR_STR |
2894 | "Interface name or neighbor tag\n" | |
2895 | "Enable BGP on interface\n" | |
3a2d747c | 2896 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2897 | AS_STR |
3a2d747c QY |
2898 | "Internal BGP peer\n" |
2899 | "External BGP peer\n") | |
b3a39dc5 | 2900 | { |
c500ae40 DW |
2901 | int idx_word = 1; |
2902 | int idx_remote_as = 4; | |
2903 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
2904 | NULL, argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2905 | } |
2906 | ||
2907 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
2908 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 2909 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2910 | NEIGHBOR_STR |
2911 | "Interface name or neighbor tag\n" | |
3a2d747c | 2912 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 2913 | "Enable BGP on interface\n" |
3a2d747c | 2914 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2915 | AS_STR |
3a2d747c QY |
2916 | "Internal BGP peer\n" |
2917 | "External BGP peer\n") | |
b3a39dc5 | 2918 | { |
c500ae40 DW |
2919 | int idx_word = 1; |
2920 | int idx_remote_as = 5; | |
2921 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
2922 | NULL, argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2923 | } |
2924 | ||
718e3744 | 2925 | DEFUN (neighbor_peer_group, |
2926 | neighbor_peer_group_cmd, | |
2927 | "neighbor WORD peer-group", | |
2928 | NEIGHBOR_STR | |
a80beece | 2929 | "Interface name or neighbor tag\n" |
718e3744 | 2930 | "Configure peer-group\n") |
2931 | { | |
cdc2d765 | 2932 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2933 | int idx_word = 1; |
a80beece | 2934 | struct peer *peer; |
718e3744 | 2935 | struct peer_group *group; |
2936 | ||
c500ae40 | 2937 | peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg); |
a80beece DS |
2938 | if (peer) |
2939 | { | |
2940 | vty_out (vty, "%% Name conflict with interface: %s", VTY_NEWLINE); | |
2941 | return CMD_WARNING; | |
2942 | } | |
718e3744 | 2943 | |
c500ae40 | 2944 | group = peer_group_get (bgp, argv[idx_word]->arg); |
718e3744 | 2945 | if (! group) |
2946 | return CMD_WARNING; | |
2947 | ||
2948 | return CMD_SUCCESS; | |
2949 | } | |
2950 | ||
2951 | DEFUN (no_neighbor, | |
2952 | no_neighbor_cmd, | |
dab8cd00 | 2953 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 2954 | NO_STR |
2955 | NEIGHBOR_STR | |
3a2d747c QY |
2956 | NEIGHBOR_ADDR_STR2 |
2957 | "Specify a BGP neighbor\n" | |
2958 | AS_STR | |
2959 | "Internal BGP peer\n" | |
2960 | "External BGP peer\n") | |
718e3744 | 2961 | { |
cdc2d765 | 2962 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2963 | int idx_peer = 2; |
718e3744 | 2964 | int ret; |
2965 | union sockunion su; | |
2966 | struct peer_group *group; | |
2967 | struct peer *peer; | |
1ff9a340 | 2968 | struct peer *other; |
718e3744 | 2969 | |
c500ae40 | 2970 | ret = str2sockunion (argv[idx_peer]->arg, &su); |
718e3744 | 2971 | if (ret < 0) |
2972 | { | |
a80beece | 2973 | /* look up for neighbor by interface name config. */ |
cdc2d765 | 2974 | peer = peer_lookup_by_conf_if (bgp, argv[idx_peer]->arg); |
a80beece DS |
2975 | if (peer) |
2976 | { | |
4a04e5f7 | 2977 | /* Request zebra to terminate IPv6 RAs on this interface. */ |
2978 | if (peer->ifp) | |
2979 | bgp_zebra_terminate_radv (peer->bgp, peer); | |
a80beece DS |
2980 | peer_delete (peer); |
2981 | return CMD_SUCCESS; | |
2982 | } | |
2983 | ||
cdc2d765 | 2984 | group = peer_group_lookup (bgp, argv[idx_peer]->arg); |
718e3744 | 2985 | if (group) |
2986 | peer_group_delete (group); | |
2987 | else | |
2988 | { | |
2989 | vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE); | |
2990 | return CMD_WARNING; | |
2991 | } | |
2992 | } | |
2993 | else | |
2994 | { | |
cdc2d765 | 2995 | peer = peer_lookup (bgp, &su); |
718e3744 | 2996 | if (peer) |
1ff9a340 | 2997 | { |
f14e6fdb DS |
2998 | if (peer_dynamic_neighbor (peer)) |
2999 | { | |
3000 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
3001 | VTY_NEWLINE); | |
3002 | return CMD_WARNING; | |
3003 | } | |
3004 | ||
1ff9a340 DS |
3005 | other = peer->doppelganger; |
3006 | peer_delete (peer); | |
3007 | if (other && other->status != Deleted) | |
3008 | peer_delete(other); | |
3009 | } | |
718e3744 | 3010 | } |
3011 | ||
3012 | return CMD_SUCCESS; | |
3013 | } | |
3014 | ||
a80beece DS |
3015 | DEFUN (no_neighbor_interface_config, |
3016 | no_neighbor_interface_config_cmd, | |
31500417 | 3017 | "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
3018 | NO_STR |
3019 | NEIGHBOR_STR | |
3020 | "Interface name\n" | |
31500417 DW |
3021 | "Configure BGP on interface\n" |
3022 | "Enable BGP with v6 link-local only\n" | |
3023 | "Member of the peer-group\n" | |
16cedbb0 | 3024 | "Peer-group name\n" |
3a2d747c QY |
3025 | "Specify a BGP neighbor\n" |
3026 | AS_STR | |
3027 | "Internal BGP peer\n" | |
3028 | "External BGP peer\n") | |
a80beece | 3029 | { |
cdc2d765 | 3030 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 3031 | int idx_word = 2; |
a80beece DS |
3032 | struct peer *peer; |
3033 | ||
3034 | /* look up for neighbor by interface name config. */ | |
cdc2d765 | 3035 | peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg); |
a80beece DS |
3036 | if (peer) |
3037 | { | |
4a04e5f7 | 3038 | /* Request zebra to terminate IPv6 RAs on this interface. */ |
3039 | if (peer->ifp) | |
3040 | bgp_zebra_terminate_radv (peer->bgp, peer); | |
a80beece DS |
3041 | peer_delete (peer); |
3042 | } | |
3043 | else | |
3044 | { | |
3045 | vty_out (vty, "%% Create the bgp interface first%s", VTY_NEWLINE); | |
3046 | return CMD_WARNING; | |
3047 | } | |
3048 | return CMD_SUCCESS; | |
3049 | } | |
3050 | ||
718e3744 | 3051 | DEFUN (no_neighbor_peer_group, |
3052 | no_neighbor_peer_group_cmd, | |
3053 | "no neighbor WORD peer-group", | |
3054 | NO_STR | |
3055 | NEIGHBOR_STR | |
3056 | "Neighbor tag\n" | |
3057 | "Configure peer-group\n") | |
3058 | { | |
cdc2d765 | 3059 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 3060 | int idx_word = 2; |
718e3744 | 3061 | struct peer_group *group; |
3062 | ||
cdc2d765 | 3063 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 3064 | if (group) |
3065 | peer_group_delete (group); | |
3066 | else | |
3067 | { | |
3068 | vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE); | |
3069 | return CMD_WARNING; | |
3070 | } | |
3071 | return CMD_SUCCESS; | |
3072 | } | |
3073 | ||
a80beece DS |
3074 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
3075 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 3076 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3077 | NO_STR |
3078 | NEIGHBOR_STR | |
a80beece | 3079 | "Interface name or neighbor tag\n" |
718e3744 | 3080 | "Specify a BGP neighbor\n" |
3a2d747c QY |
3081 | AS_STR |
3082 | "Internal BGP peer\n" | |
3083 | "External BGP peer\n") | |
718e3744 | 3084 | { |
cdc2d765 | 3085 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 3086 | int idx_word = 2; |
718e3744 | 3087 | struct peer_group *group; |
a80beece DS |
3088 | struct peer *peer; |
3089 | ||
3090 | /* look up for neighbor by interface name config. */ | |
cdc2d765 | 3091 | peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg); |
a80beece DS |
3092 | if (peer) |
3093 | { | |
0299c004 | 3094 | peer_as_change (peer, 0, AS_SPECIFIED); |
a80beece DS |
3095 | return CMD_SUCCESS; |
3096 | } | |
718e3744 | 3097 | |
cdc2d765 | 3098 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 3099 | if (group) |
3100 | peer_group_remote_as_delete (group); | |
3101 | else | |
3102 | { | |
a80beece | 3103 | vty_out (vty, "%% Create the peer-group or interface first%s", VTY_NEWLINE); |
718e3744 | 3104 | return CMD_WARNING; |
3105 | } | |
3106 | return CMD_SUCCESS; | |
3107 | } | |
6b0655a2 | 3108 | |
718e3744 | 3109 | DEFUN (neighbor_local_as, |
3110 | neighbor_local_as_cmd, | |
9ccf14f7 | 3111 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 3112 | NEIGHBOR_STR |
3113 | NEIGHBOR_ADDR_STR2 | |
3114 | "Specify a local-as number\n" | |
3115 | "AS number used as local AS\n") | |
3116 | { | |
c500ae40 DW |
3117 | int idx_peer = 1; |
3118 | int idx_number = 3; | |
718e3744 | 3119 | struct peer *peer; |
3120 | int ret; | |
e14fda0f | 3121 | as_t as; |
718e3744 | 3122 | |
c500ae40 | 3123 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3124 | if (! peer) |
3125 | return CMD_WARNING; | |
3126 | ||
b6f1faf0 | 3127 | VTY_GET_INTEGER_RANGE ("Local AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); |
e14fda0f | 3128 | ret = peer_local_as_set (peer, as, 0, 0); |
718e3744 | 3129 | return bgp_vty_return (vty, ret); |
3130 | } | |
3131 | ||
3132 | DEFUN (neighbor_local_as_no_prepend, | |
3133 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 3134 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 3135 | NEIGHBOR_STR |
3136 | NEIGHBOR_ADDR_STR2 | |
3137 | "Specify a local-as number\n" | |
3138 | "AS number used as local AS\n" | |
3139 | "Do not prepend local-as to updates from ebgp peers\n") | |
3140 | { | |
c500ae40 DW |
3141 | int idx_peer = 1; |
3142 | int idx_number = 3; | |
718e3744 | 3143 | struct peer *peer; |
3144 | int ret; | |
e14fda0f | 3145 | as_t as; |
718e3744 | 3146 | |
c500ae40 | 3147 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3148 | if (! peer) |
3149 | return CMD_WARNING; | |
3150 | ||
b6f1faf0 | 3151 | VTY_GET_INTEGER_RANGE ("Local AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); |
e14fda0f | 3152 | ret = peer_local_as_set (peer, as, 1, 0); |
718e3744 | 3153 | return bgp_vty_return (vty, ret); |
3154 | } | |
3155 | ||
9d3f9705 AC |
3156 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
3157 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 3158 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
3159 | NEIGHBOR_STR |
3160 | NEIGHBOR_ADDR_STR2 | |
3161 | "Specify a local-as number\n" | |
3162 | "AS number used as local AS\n" | |
3163 | "Do not prepend local-as to updates from ebgp peers\n" | |
3164 | "Do not prepend local-as to updates from ibgp peers\n") | |
3165 | { | |
c500ae40 DW |
3166 | int idx_peer = 1; |
3167 | int idx_number = 3; | |
9d3f9705 AC |
3168 | struct peer *peer; |
3169 | int ret; | |
e14fda0f | 3170 | as_t as; |
9d3f9705 | 3171 | |
c500ae40 | 3172 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
9d3f9705 AC |
3173 | if (! peer) |
3174 | return CMD_WARNING; | |
3175 | ||
b6f1faf0 | 3176 | VTY_GET_INTEGER_RANGE ("Local AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); |
e14fda0f | 3177 | ret = peer_local_as_set (peer, as, 1, 1); |
9d3f9705 AC |
3178 | return bgp_vty_return (vty, ret); |
3179 | } | |
3180 | ||
718e3744 | 3181 | DEFUN (no_neighbor_local_as, |
3182 | no_neighbor_local_as_cmd, | |
a636c635 | 3183 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 3184 | NO_STR |
3185 | NEIGHBOR_STR | |
3186 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
3187 | "Specify a local-as number\n" |
3188 | "AS number used as local AS\n" | |
3189 | "Do not prepend local-as to updates from ebgp peers\n" | |
3190 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 3191 | { |
c500ae40 | 3192 | int idx_peer = 2; |
718e3744 | 3193 | struct peer *peer; |
3194 | int ret; | |
3195 | ||
c500ae40 | 3196 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3197 | if (! peer) |
3198 | return CMD_WARNING; | |
3199 | ||
3200 | ret = peer_local_as_unset (peer); | |
3201 | return bgp_vty_return (vty, ret); | |
3202 | } | |
3203 | ||
718e3744 | 3204 | |
9d3f9705 | 3205 | |
6b0655a2 | 3206 | |
3f9c7369 DS |
3207 | DEFUN (neighbor_solo, |
3208 | neighbor_solo_cmd, | |
9ccf14f7 | 3209 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3210 | NEIGHBOR_STR |
3211 | NEIGHBOR_ADDR_STR2 | |
3212 | "Solo peer - part of its own update group\n") | |
3213 | { | |
c500ae40 | 3214 | int idx_peer = 1; |
3f9c7369 DS |
3215 | struct peer *peer; |
3216 | int ret; | |
3217 | ||
c500ae40 | 3218 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
3f9c7369 DS |
3219 | if (! peer) |
3220 | return CMD_WARNING; | |
3221 | ||
3222 | ret = update_group_adjust_soloness(peer, 1); | |
3223 | return bgp_vty_return (vty, ret); | |
3224 | } | |
3225 | ||
3226 | DEFUN (no_neighbor_solo, | |
3227 | no_neighbor_solo_cmd, | |
9ccf14f7 | 3228 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3229 | NO_STR |
3230 | NEIGHBOR_STR | |
3231 | NEIGHBOR_ADDR_STR2 | |
3232 | "Solo peer - part of its own update group\n") | |
3233 | { | |
c500ae40 | 3234 | int idx_peer = 2; |
3f9c7369 DS |
3235 | struct peer *peer; |
3236 | int ret; | |
3237 | ||
c500ae40 | 3238 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
3f9c7369 DS |
3239 | if (! peer) |
3240 | return CMD_WARNING; | |
3241 | ||
3242 | ret = update_group_adjust_soloness(peer, 0); | |
3243 | return bgp_vty_return (vty, ret); | |
3244 | } | |
3245 | ||
0df7c91f PJ |
3246 | DEFUN (neighbor_password, |
3247 | neighbor_password_cmd, | |
9ccf14f7 | 3248 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
3249 | NEIGHBOR_STR |
3250 | NEIGHBOR_ADDR_STR2 | |
3251 | "Set a password\n" | |
3252 | "The password\n") | |
3253 | { | |
c500ae40 DW |
3254 | int idx_peer = 1; |
3255 | int idx_line = 3; | |
0df7c91f PJ |
3256 | struct peer *peer; |
3257 | int ret; | |
3258 | ||
c500ae40 | 3259 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
0df7c91f PJ |
3260 | if (! peer) |
3261 | return CMD_WARNING; | |
3262 | ||
c500ae40 | 3263 | ret = peer_password_set (peer, argv[idx_line]->arg); |
0df7c91f PJ |
3264 | return bgp_vty_return (vty, ret); |
3265 | } | |
3266 | ||
3267 | DEFUN (no_neighbor_password, | |
3268 | no_neighbor_password_cmd, | |
a636c635 | 3269 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
3270 | NO_STR |
3271 | NEIGHBOR_STR | |
3272 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
3273 | "Set a password\n" |
3274 | "The password\n") | |
0df7c91f | 3275 | { |
c500ae40 | 3276 | int idx_peer = 2; |
0df7c91f PJ |
3277 | struct peer *peer; |
3278 | int ret; | |
3279 | ||
c500ae40 | 3280 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
0df7c91f PJ |
3281 | if (! peer) |
3282 | return CMD_WARNING; | |
3283 | ||
3284 | ret = peer_password_unset (peer); | |
3285 | return bgp_vty_return (vty, ret); | |
3286 | } | |
6b0655a2 | 3287 | |
813d4307 | 3288 | |
718e3744 | 3289 | DEFUN (neighbor_activate, |
3290 | neighbor_activate_cmd, | |
9ccf14f7 | 3291 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3292 | NEIGHBOR_STR |
3293 | NEIGHBOR_ADDR_STR2 | |
3294 | "Enable the Address Family for this Neighbor\n") | |
3295 | { | |
c500ae40 | 3296 | int idx_peer = 1; |
c8560b44 | 3297 | int ret; |
718e3744 | 3298 | struct peer *peer; |
3299 | ||
c500ae40 | 3300 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3301 | if (! peer) |
3302 | return CMD_WARNING; | |
3303 | ||
c8560b44 | 3304 | ret = peer_activate (peer, bgp_node_afi (vty), bgp_node_safi (vty)); |
718e3744 | 3305 | |
c8560b44 DW |
3306 | if (ret) |
3307 | return CMD_WARNING; | |
718e3744 | 3308 | return CMD_SUCCESS; |
3309 | } | |
3310 | ||
3311 | DEFUN (no_neighbor_activate, | |
3312 | no_neighbor_activate_cmd, | |
9ccf14f7 | 3313 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3314 | NO_STR |
3315 | NEIGHBOR_STR | |
3316 | NEIGHBOR_ADDR_STR2 | |
3317 | "Enable the Address Family for this Neighbor\n") | |
3318 | { | |
c500ae40 | 3319 | int idx_peer = 2; |
718e3744 | 3320 | int ret; |
3321 | struct peer *peer; | |
3322 | ||
3323 | /* Lookup peer. */ | |
c500ae40 | 3324 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3325 | if (! peer) |
3326 | return CMD_WARNING; | |
3327 | ||
3328 | ret = peer_deactivate (peer, bgp_node_afi (vty), bgp_node_safi (vty)); | |
3329 | ||
c8560b44 DW |
3330 | if (ret) |
3331 | return CMD_WARNING; | |
3332 | return CMD_SUCCESS; | |
718e3744 | 3333 | } |
6b0655a2 | 3334 | |
718e3744 | 3335 | DEFUN (neighbor_set_peer_group, |
3336 | neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3337 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3338 | NEIGHBOR_STR |
a80beece | 3339 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3340 | "Member of the peer-group\n" |
16cedbb0 | 3341 | "Peer-group name\n") |
718e3744 | 3342 | { |
cdc2d765 | 3343 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
3344 | int idx_peer = 1; |
3345 | int idx_word = 3; | |
718e3744 | 3346 | int ret; |
3347 | as_t as; | |
3348 | union sockunion su; | |
a80beece | 3349 | struct peer *peer; |
718e3744 | 3350 | struct peer_group *group; |
3351 | ||
a80beece | 3352 | peer = NULL; |
718e3744 | 3353 | |
c500ae40 | 3354 | ret = str2sockunion (argv[idx_peer]->arg, &su); |
718e3744 | 3355 | if (ret < 0) |
3356 | { | |
c500ae40 | 3357 | peer = peer_lookup_by_conf_if (bgp, argv[idx_peer]->arg); |
a80beece DS |
3358 | if (!peer) |
3359 | { | |
c500ae40 | 3360 | vty_out (vty, "%% Malformed address or name: %s%s", argv[idx_peer]->arg, VTY_NEWLINE); |
a80beece DS |
3361 | return CMD_WARNING; |
3362 | } | |
3363 | } | |
3364 | else | |
3365 | { | |
6aeb9e78 | 3366 | if (peer_address_self_check (bgp, &su)) |
a80beece DS |
3367 | { |
3368 | vty_out (vty, "%% Can not configure the local system as neighbor%s", | |
3369 | VTY_NEWLINE); | |
3370 | return CMD_WARNING; | |
3371 | } | |
f14e6fdb DS |
3372 | |
3373 | /* Disallow for dynamic neighbor. */ | |
3374 | peer = peer_lookup (bgp, &su); | |
3375 | if (peer && peer_dynamic_neighbor (peer)) | |
3376 | { | |
3377 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
3378 | VTY_NEWLINE); | |
3379 | return CMD_WARNING; | |
3380 | } | |
718e3744 | 3381 | } |
3382 | ||
c500ae40 | 3383 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 3384 | if (! group) |
3385 | { | |
3386 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
3387 | return CMD_WARNING; | |
3388 | } | |
3389 | ||
c8560b44 | 3390 | ret = peer_group_bind (bgp, &su, peer, group, &as); |
718e3744 | 3391 | |
3392 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) | |
3393 | { | |
aea339f7 | 3394 | 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 | 3395 | return CMD_WARNING; |
3396 | } | |
3397 | ||
3398 | return bgp_vty_return (vty, ret); | |
3399 | } | |
3400 | ||
3401 | DEFUN (no_neighbor_set_peer_group, | |
3402 | no_neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3403 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3404 | NO_STR |
3405 | NEIGHBOR_STR | |
a80beece | 3406 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3407 | "Member of the peer-group\n" |
16cedbb0 | 3408 | "Peer-group name\n") |
718e3744 | 3409 | { |
cdc2d765 | 3410 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
3411 | int idx_peer = 2; |
3412 | int idx_word = 4; | |
718e3744 | 3413 | int ret; |
718e3744 | 3414 | struct peer *peer; |
3415 | struct peer_group *group; | |
3416 | ||
c500ae40 | 3417 | peer = peer_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3418 | if (! peer) |
3419 | return CMD_WARNING; | |
3420 | ||
c500ae40 | 3421 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 3422 | if (! group) |
3423 | { | |
3424 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
3425 | return CMD_WARNING; | |
3426 | } | |
3427 | ||
c8560b44 | 3428 | ret = peer_group_unbind (bgp, peer, group); |
718e3744 | 3429 | |
3430 | return bgp_vty_return (vty, ret); | |
3431 | } | |
6b0655a2 | 3432 | |
94f2b392 | 3433 | static int |
e52702f2 | 3434 | peer_flag_modify_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 3435 | u_int16_t flag, int set) |
718e3744 | 3436 | { |
3437 | int ret; | |
3438 | struct peer *peer; | |
3439 | ||
3440 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
3441 | if (! peer) | |
3442 | return CMD_WARNING; | |
3443 | ||
8cdabf90 SK |
3444 | /* |
3445 | * If 'neighbor <interface>', then this is for directly connected peers, | |
3446 | * we should not accept disable-connected-check. | |
3447 | */ | |
3448 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
3449 | vty_out (vty, "%s is directly connected peer, cannot accept disable-" | |
3450 | "connected-check%s", ip_str, VTY_NEWLINE); | |
3451 | return CMD_WARNING; | |
3452 | } | |
3453 | ||
ae9b0e11 DS |
3454 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
3455 | peer_tx_shutdown_message_unset (peer); | |
3456 | ||
718e3744 | 3457 | if (set) |
3458 | ret = peer_flag_set (peer, flag); | |
3459 | else | |
3460 | ret = peer_flag_unset (peer, flag); | |
3461 | ||
3462 | return bgp_vty_return (vty, ret); | |
3463 | } | |
3464 | ||
94f2b392 | 3465 | static int |
fd79ac91 | 3466 | peer_flag_set_vty (struct vty *vty, const char *ip_str, u_int16_t flag) |
718e3744 | 3467 | { |
3468 | return peer_flag_modify_vty (vty, ip_str, flag, 1); | |
3469 | } | |
3470 | ||
94f2b392 | 3471 | static int |
fd79ac91 | 3472 | peer_flag_unset_vty (struct vty *vty, const char *ip_str, u_int16_t flag) |
718e3744 | 3473 | { |
3474 | return peer_flag_modify_vty (vty, ip_str, flag, 0); | |
3475 | } | |
3476 | ||
3477 | /* neighbor passive. */ | |
3478 | DEFUN (neighbor_passive, | |
3479 | neighbor_passive_cmd, | |
9ccf14f7 | 3480 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3481 | NEIGHBOR_STR |
3482 | NEIGHBOR_ADDR_STR2 | |
3483 | "Don't send open messages to this neighbor\n") | |
3484 | { | |
c500ae40 DW |
3485 | int idx_peer = 1; |
3486 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3487 | } |
3488 | ||
3489 | DEFUN (no_neighbor_passive, | |
3490 | no_neighbor_passive_cmd, | |
9ccf14f7 | 3491 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3492 | NO_STR |
3493 | NEIGHBOR_STR | |
3494 | NEIGHBOR_ADDR_STR2 | |
3495 | "Don't send open messages to this neighbor\n") | |
3496 | { | |
c500ae40 DW |
3497 | int idx_peer = 2; |
3498 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3499 | } |
6b0655a2 | 3500 | |
718e3744 | 3501 | /* neighbor shutdown. */ |
73d70fa6 DL |
3502 | DEFUN (neighbor_shutdown_msg, |
3503 | neighbor_shutdown_msg_cmd, | |
3504 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
718e3744 | 3505 | NEIGHBOR_STR |
3506 | NEIGHBOR_ADDR_STR2 | |
73d70fa6 DL |
3507 | "Administratively shut down this neighbor\n" |
3508 | "Add a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3509 | "Shutdown message\n") | |
718e3744 | 3510 | { |
c500ae40 | 3511 | int idx_peer = 1; |
73d70fa6 DL |
3512 | |
3513 | if (argc >= 5) | |
3514 | { | |
ae9b0e11 | 3515 | struct peer *peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
73d70fa6 DL |
3516 | char *message; |
3517 | ||
ae9b0e11 DS |
3518 | if (!peer) |
3519 | return CMD_WARNING; | |
73d70fa6 DL |
3520 | message = argv_concat (argv, argc, 4); |
3521 | peer_tx_shutdown_message_set (peer, message); | |
3522 | XFREE (MTYPE_TMP, message); | |
3523 | } | |
3524 | ||
c500ae40 | 3525 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 3526 | } |
3527 | ||
73d70fa6 DL |
3528 | ALIAS (neighbor_shutdown_msg, |
3529 | neighbor_shutdown_cmd, | |
3530 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
718e3744 | 3531 | NEIGHBOR_STR |
3532 | NEIGHBOR_ADDR_STR2 | |
3533 | "Administratively shut down this neighbor\n") | |
73d70fa6 DL |
3534 | |
3535 | DEFUN (no_neighbor_shutdown_msg, | |
3536 | no_neighbor_shutdown_msg_cmd, | |
3537 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
3538 | NO_STR | |
3539 | NEIGHBOR_STR | |
3540 | NEIGHBOR_ADDR_STR2 | |
3541 | "Administratively shut down this neighbor\n" | |
3542 | "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3543 | "Shutdown message\n") | |
718e3744 | 3544 | { |
c500ae40 | 3545 | int idx_peer = 2; |
73d70fa6 | 3546 | |
c500ae40 | 3547 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 3548 | } |
6b0655a2 | 3549 | |
73d70fa6 DL |
3550 | ALIAS (no_neighbor_shutdown_msg, |
3551 | no_neighbor_shutdown_cmd, | |
3552 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3553 | NO_STR | |
3554 | NEIGHBOR_STR | |
3555 | NEIGHBOR_ADDR_STR2 | |
3556 | "Administratively shut down this neighbor\n") | |
3557 | ||
718e3744 | 3558 | /* neighbor capability dynamic. */ |
3559 | DEFUN (neighbor_capability_dynamic, | |
3560 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3561 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3562 | NEIGHBOR_STR |
3563 | NEIGHBOR_ADDR_STR2 | |
3564 | "Advertise capability to the peer\n" | |
3565 | "Advertise dynamic capability to this neighbor\n") | |
3566 | { | |
c500ae40 DW |
3567 | int idx_peer = 1; |
3568 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3569 | } |
3570 | ||
3571 | DEFUN (no_neighbor_capability_dynamic, | |
3572 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3573 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3574 | NO_STR |
3575 | NEIGHBOR_STR | |
3576 | NEIGHBOR_ADDR_STR2 | |
3577 | "Advertise capability to the peer\n" | |
3578 | "Advertise dynamic capability to this neighbor\n") | |
3579 | { | |
c500ae40 DW |
3580 | int idx_peer = 2; |
3581 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3582 | } |
6b0655a2 | 3583 | |
718e3744 | 3584 | /* neighbor dont-capability-negotiate */ |
3585 | DEFUN (neighbor_dont_capability_negotiate, | |
3586 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3587 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3588 | NEIGHBOR_STR |
3589 | NEIGHBOR_ADDR_STR2 | |
3590 | "Do not perform capability negotiation\n") | |
3591 | { | |
c500ae40 DW |
3592 | int idx_peer = 1; |
3593 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3594 | } |
3595 | ||
3596 | DEFUN (no_neighbor_dont_capability_negotiate, | |
3597 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3598 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3599 | NO_STR |
3600 | NEIGHBOR_STR | |
3601 | NEIGHBOR_ADDR_STR2 | |
3602 | "Do not perform capability negotiation\n") | |
3603 | { | |
c500ae40 DW |
3604 | int idx_peer = 2; |
3605 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3606 | } |
6b0655a2 | 3607 | |
8a92a8a0 DS |
3608 | /* neighbor capability extended next hop encoding */ |
3609 | DEFUN (neighbor_capability_enhe, | |
3610 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3611 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3612 | NEIGHBOR_STR |
3613 | NEIGHBOR_ADDR_STR2 | |
3614 | "Advertise capability to the peer\n" | |
3615 | "Advertise extended next-hop capability to the peer\n") | |
3616 | { | |
c500ae40 DW |
3617 | int idx_peer = 1; |
3618 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3619 | } |
3620 | ||
3621 | DEFUN (no_neighbor_capability_enhe, | |
3622 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3623 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3624 | NO_STR |
3625 | NEIGHBOR_STR | |
3626 | NEIGHBOR_ADDR_STR2 | |
3627 | "Advertise capability to the peer\n" | |
3628 | "Advertise extended next-hop capability to the peer\n") | |
3629 | { | |
c500ae40 DW |
3630 | int idx_peer = 2; |
3631 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3632 | } |
3633 | ||
94f2b392 | 3634 | static int |
fd79ac91 | 3635 | peer_af_flag_modify_vty (struct vty *vty, const char *peer_str, afi_t afi, |
fee0f4c6 | 3636 | safi_t safi, u_int32_t flag, int set) |
718e3744 | 3637 | { |
3638 | int ret; | |
3639 | struct peer *peer; | |
3640 | ||
3641 | peer = peer_and_group_lookup_vty (vty, peer_str); | |
3642 | if (! peer) | |
3643 | return CMD_WARNING; | |
3644 | ||
3645 | if (set) | |
3646 | ret = peer_af_flag_set (peer, afi, safi, flag); | |
3647 | else | |
3648 | ret = peer_af_flag_unset (peer, afi, safi, flag); | |
3649 | ||
3650 | return bgp_vty_return (vty, ret); | |
3651 | } | |
3652 | ||
94f2b392 | 3653 | static int |
fd79ac91 | 3654 | peer_af_flag_set_vty (struct vty *vty, const char *peer_str, afi_t afi, |
fee0f4c6 | 3655 | safi_t safi, u_int32_t flag) |
718e3744 | 3656 | { |
3657 | return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 1); | |
3658 | } | |
3659 | ||
94f2b392 | 3660 | static int |
fd79ac91 | 3661 | peer_af_flag_unset_vty (struct vty *vty, const char *peer_str, afi_t afi, |
fee0f4c6 | 3662 | safi_t safi, u_int32_t flag) |
718e3744 | 3663 | { |
3664 | return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 0); | |
3665 | } | |
6b0655a2 | 3666 | |
718e3744 | 3667 | /* neighbor capability orf prefix-list. */ |
3668 | DEFUN (neighbor_capability_orf_prefix, | |
3669 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3670 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3671 | NEIGHBOR_STR |
3672 | NEIGHBOR_ADDR_STR2 | |
3673 | "Advertise capability to the peer\n" | |
3674 | "Advertise ORF capability to the peer\n" | |
3675 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3676 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3677 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3678 | "Capability to SEND the ORF to this neighbor\n") | |
3679 | { | |
c500ae40 DW |
3680 | int idx_peer = 1; |
3681 | int idx_send_recv = 5; | |
718e3744 | 3682 | u_int16_t flag = 0; |
3683 | ||
c500ae40 | 3684 | if (strncmp (argv[idx_send_recv]->arg, "s", 1) == 0) |
718e3744 | 3685 | flag = PEER_FLAG_ORF_PREFIX_SM; |
c500ae40 | 3686 | else if (strncmp (argv[idx_send_recv]->arg, "r", 1) == 0) |
718e3744 | 3687 | flag = PEER_FLAG_ORF_PREFIX_RM; |
c500ae40 | 3688 | else if (strncmp (argv[idx_send_recv]->arg, "b", 1) == 0) |
718e3744 | 3689 | flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM; |
3690 | else | |
3691 | return CMD_WARNING; | |
3692 | ||
c500ae40 | 3693 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 3694 | bgp_node_safi (vty), flag); |
3695 | } | |
3696 | ||
3697 | DEFUN (no_neighbor_capability_orf_prefix, | |
3698 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3699 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3700 | NO_STR |
3701 | NEIGHBOR_STR | |
3702 | NEIGHBOR_ADDR_STR2 | |
3703 | "Advertise capability to the peer\n" | |
3704 | "Advertise ORF capability to the peer\n" | |
3705 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3706 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3707 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3708 | "Capability to SEND the ORF to this neighbor\n") | |
3709 | { | |
c500ae40 DW |
3710 | int idx_peer = 2; |
3711 | int idx_send_recv = 6; | |
718e3744 | 3712 | u_int16_t flag = 0; |
3713 | ||
c500ae40 | 3714 | if (strncmp (argv[idx_send_recv]->arg, "s", 1) == 0) |
718e3744 | 3715 | flag = PEER_FLAG_ORF_PREFIX_SM; |
c500ae40 | 3716 | else if (strncmp (argv[idx_send_recv]->arg, "r", 1) == 0) |
718e3744 | 3717 | flag = PEER_FLAG_ORF_PREFIX_RM; |
c500ae40 | 3718 | else if (strncmp (argv[idx_send_recv]->arg, "b", 1) == 0) |
718e3744 | 3719 | flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM; |
3720 | else | |
3721 | return CMD_WARNING; | |
3722 | ||
c500ae40 | 3723 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 3724 | bgp_node_safi (vty), flag); |
3725 | } | |
6b0655a2 | 3726 | |
718e3744 | 3727 | /* neighbor next-hop-self. */ |
3728 | DEFUN (neighbor_nexthop_self, | |
3729 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3730 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3731 | NEIGHBOR_STR |
3732 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3733 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3734 | { |
c500ae40 DW |
3735 | int idx_peer = 1; |
3736 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
a538debe DS |
3737 | bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF); |
3738 | } | |
9e7a53c1 | 3739 | |
a538debe DS |
3740 | /* neighbor next-hop-self. */ |
3741 | DEFUN (neighbor_nexthop_self_force, | |
3742 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 3743 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3744 | NEIGHBOR_STR |
3745 | NEIGHBOR_ADDR_STR2 | |
3746 | "Disable the next hop calculation for this neighbor\n" | |
3747 | "Set the next hop to self for reflected routes\n") | |
3748 | { | |
c500ae40 DW |
3749 | int idx_peer = 1; |
3750 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
a538debe | 3751 | bgp_node_safi (vty), |
88b8ed8d | 3752 | PEER_FLAG_FORCE_NEXTHOP_SELF); |
718e3744 | 3753 | } |
3754 | ||
3755 | DEFUN (no_neighbor_nexthop_self, | |
3756 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3757 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3758 | NO_STR |
3759 | NEIGHBOR_STR | |
3760 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3761 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3762 | { |
c500ae40 DW |
3763 | int idx_peer = 2; |
3764 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
9e7a53c1 | 3765 | bgp_node_safi (vty), |
88b8ed8d | 3766 | PEER_FLAG_NEXTHOP_SELF); |
718e3744 | 3767 | } |
6b0655a2 | 3768 | |
88b8ed8d | 3769 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 3770 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 3771 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3772 | NO_STR |
3773 | NEIGHBOR_STR | |
3774 | NEIGHBOR_ADDR_STR2 | |
3775 | "Disable the next hop calculation for this neighbor\n" | |
3776 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 3777 | { |
c500ae40 DW |
3778 | int idx_peer = 2; |
3779 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
3780 | bgp_node_safi (vty), |
3781 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
3782 | } | |
a538debe | 3783 | |
c7122e14 DS |
3784 | /* neighbor as-override */ |
3785 | DEFUN (neighbor_as_override, | |
3786 | neighbor_as_override_cmd, | |
9ccf14f7 | 3787 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3788 | NEIGHBOR_STR |
3789 | NEIGHBOR_ADDR_STR2 | |
3790 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3791 | { | |
c500ae40 DW |
3792 | int idx_peer = 1; |
3793 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
c7122e14 DS |
3794 | bgp_node_safi (vty), |
3795 | PEER_FLAG_AS_OVERRIDE); | |
3796 | } | |
3797 | ||
3798 | DEFUN (no_neighbor_as_override, | |
3799 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 3800 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3801 | NO_STR |
3802 | NEIGHBOR_STR | |
3803 | NEIGHBOR_ADDR_STR2 | |
3804 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3805 | { | |
c500ae40 DW |
3806 | int idx_peer = 2; |
3807 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
c7122e14 DS |
3808 | bgp_node_safi (vty), |
3809 | PEER_FLAG_AS_OVERRIDE); | |
3810 | } | |
3811 | ||
718e3744 | 3812 | /* neighbor remove-private-AS. */ |
3813 | DEFUN (neighbor_remove_private_as, | |
3814 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3815 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3816 | NEIGHBOR_STR |
3817 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3818 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3819 | { |
c500ae40 DW |
3820 | int idx_peer = 1; |
3821 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3822 | bgp_node_safi (vty), |
3823 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
3824 | } | |
3825 | ||
5000f21c DS |
3826 | DEFUN (neighbor_remove_private_as_all, |
3827 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 3828 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
3829 | NEIGHBOR_STR |
3830 | NEIGHBOR_ADDR_STR2 | |
3831 | "Remove private ASNs in outbound updates\n" | |
3832 | "Apply to all AS numbers") | |
3833 | { | |
c500ae40 DW |
3834 | int idx_peer = 1; |
3835 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5000f21c | 3836 | bgp_node_safi (vty), |
5000f21c DS |
3837 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); |
3838 | } | |
3839 | ||
3840 | DEFUN (neighbor_remove_private_as_replace_as, | |
3841 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 3842 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
3843 | NEIGHBOR_STR |
3844 | NEIGHBOR_ADDR_STR2 | |
3845 | "Remove private ASNs in outbound updates\n" | |
3846 | "Replace private ASNs with our ASN in outbound updates\n") | |
3847 | { | |
c500ae40 DW |
3848 | int idx_peer = 1; |
3849 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5000f21c | 3850 | bgp_node_safi (vty), |
5000f21c DS |
3851 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); |
3852 | } | |
3853 | ||
3854 | DEFUN (neighbor_remove_private_as_all_replace_as, | |
3855 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 3856 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
3857 | NEIGHBOR_STR |
3858 | NEIGHBOR_ADDR_STR2 | |
3859 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3860 | "Apply to all AS numbers\n" |
5000f21c DS |
3861 | "Replace private ASNs with our ASN in outbound updates\n") |
3862 | { | |
c500ae40 DW |
3863 | int idx_peer = 1; |
3864 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5000f21c | 3865 | bgp_node_safi (vty), |
88b8ed8d | 3866 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); |
5000f21c DS |
3867 | } |
3868 | ||
718e3744 | 3869 | DEFUN (no_neighbor_remove_private_as, |
3870 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3871 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3872 | NO_STR |
3873 | NEIGHBOR_STR | |
3874 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3875 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3876 | { |
c500ae40 DW |
3877 | int idx_peer = 2; |
3878 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3879 | bgp_node_safi (vty), |
88b8ed8d | 3880 | PEER_FLAG_REMOVE_PRIVATE_AS); |
718e3744 | 3881 | } |
6b0655a2 | 3882 | |
88b8ed8d | 3883 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 3884 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 3885 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
3886 | NO_STR |
3887 | NEIGHBOR_STR | |
3888 | NEIGHBOR_ADDR_STR2 | |
3889 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3890 | "Apply to all AS numbers\n") |
88b8ed8d | 3891 | { |
c500ae40 DW |
3892 | int idx_peer = 2; |
3893 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
3894 | bgp_node_safi (vty), |
3895 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
3896 | } | |
5000f21c | 3897 | |
88b8ed8d | 3898 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 3899 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 3900 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
3901 | NO_STR |
3902 | NEIGHBOR_STR | |
3903 | NEIGHBOR_ADDR_STR2 | |
3904 | "Remove private ASNs in outbound updates\n" | |
3905 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 3906 | { |
c500ae40 DW |
3907 | int idx_peer = 2; |
3908 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
3909 | bgp_node_safi (vty), |
3910 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
3911 | } | |
5000f21c | 3912 | |
88b8ed8d | 3913 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 3914 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 3915 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
3916 | NO_STR |
3917 | NEIGHBOR_STR | |
3918 | NEIGHBOR_ADDR_STR2 | |
3919 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3920 | "Apply to all AS numbers\n" |
5000f21c | 3921 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 3922 | { |
c500ae40 DW |
3923 | int idx_peer = 2; |
3924 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
3925 | bgp_node_safi (vty), |
3926 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
3927 | } | |
5000f21c DS |
3928 | |
3929 | ||
718e3744 | 3930 | /* neighbor send-community. */ |
3931 | DEFUN (neighbor_send_community, | |
3932 | neighbor_send_community_cmd, | |
9ccf14f7 | 3933 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 3934 | NEIGHBOR_STR |
3935 | NEIGHBOR_ADDR_STR2 | |
3936 | "Send Community attribute to this neighbor\n") | |
3937 | { | |
c500ae40 DW |
3938 | int idx_peer = 1; |
3939 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3940 | bgp_node_safi (vty), |
3941 | PEER_FLAG_SEND_COMMUNITY); | |
3942 | } | |
3943 | ||
3944 | DEFUN (no_neighbor_send_community, | |
3945 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 3946 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 3947 | NO_STR |
3948 | NEIGHBOR_STR | |
3949 | NEIGHBOR_ADDR_STR2 | |
3950 | "Send Community attribute to this neighbor\n") | |
3951 | { | |
c500ae40 DW |
3952 | int idx_peer = 2; |
3953 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3954 | bgp_node_safi (vty), |
3955 | PEER_FLAG_SEND_COMMUNITY); | |
3956 | } | |
6b0655a2 | 3957 | |
718e3744 | 3958 | /* neighbor send-community extended. */ |
3959 | DEFUN (neighbor_send_community_type, | |
3960 | neighbor_send_community_type_cmd, | |
57d187bc | 3961 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 3962 | NEIGHBOR_STR |
3963 | NEIGHBOR_ADDR_STR2 | |
3964 | "Send Community attribute to this neighbor\n" | |
3965 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 3966 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 3967 | "Send Extended Community attributes\n" |
57d187bc JS |
3968 | "Send Standard Community attributes\n" |
3969 | "Send Large Community attributes\n") | |
718e3744 | 3970 | { |
4c4ff4c1 QY |
3971 | int idx = 0; |
3972 | u_int32_t flag = 0; | |
718e3744 | 3973 | |
4c4ff4c1 QY |
3974 | char *peer = argv[1]->arg; |
3975 | ||
3976 | if (argv_find (argv, argc, "standard", &idx)) | |
3977 | SET_FLAG (flag, PEER_FLAG_SEND_COMMUNITY); | |
3978 | else if (argv_find (argv, argc, "extended", &idx)) | |
3979 | SET_FLAG (flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
57d187bc JS |
3980 | else if (argv_find (argv, argc, "large", &idx)) |
3981 | SET_FLAG (flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
3982 | else if (argv_find (argv, argc, "both", &idx)) | |
3983 | { | |
3984 | SET_FLAG (flag, PEER_FLAG_SEND_COMMUNITY); | |
3985 | SET_FLAG (flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
3986 | } | |
4c4ff4c1 | 3987 | else |
57d187bc JS |
3988 | { |
3989 | SET_FLAG (flag, PEER_FLAG_SEND_COMMUNITY); | |
3990 | SET_FLAG (flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
3991 | SET_FLAG (flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
3992 | } | |
4c4ff4c1 QY |
3993 | |
3994 | return peer_af_flag_set_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flag); | |
718e3744 | 3995 | } |
3996 | ||
3997 | DEFUN (no_neighbor_send_community_type, | |
3998 | no_neighbor_send_community_type_cmd, | |
57d187bc | 3999 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4000 | NO_STR |
4001 | NEIGHBOR_STR | |
4002 | NEIGHBOR_ADDR_STR2 | |
4003 | "Send Community attribute to this neighbor\n" | |
4004 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4005 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4006 | "Send Extended Community attributes\n" |
57d187bc JS |
4007 | "Send Standard Community attributes\n" |
4008 | "Send Large Community attributes\n") | |
718e3744 | 4009 | { |
c500ae40 DW |
4010 | int idx_peer = 2; |
4011 | int idx_type = 4; | |
4012 | if (strncmp (argv[idx_type]->arg, "s", 1) == 0) | |
4013 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4014 | bgp_node_safi (vty), |
4015 | PEER_FLAG_SEND_COMMUNITY); | |
c500ae40 DW |
4016 | if (strncmp (argv[idx_type]->arg, "e", 1) == 0) |
4017 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4018 | bgp_node_safi (vty), |
4019 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
57d187bc JS |
4020 | if (strncmp (argv[idx_type]->arg, "l", 1) == 0) |
4021 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4022 | bgp_node_safi (vty), | |
4023 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4024 | if (strncmp (argv[idx_type]->arg, "b", 1) == 0) | |
4025 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4026 | bgp_node_safi (vty), | |
4027 | PEER_FLAG_SEND_COMMUNITY | | |
4028 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
718e3744 | 4029 | |
c500ae40 | 4030 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 4031 | bgp_node_safi (vty), |
4032 | (PEER_FLAG_SEND_COMMUNITY | | |
57d187bc JS |
4033 | PEER_FLAG_SEND_EXT_COMMUNITY| |
4034 | PEER_FLAG_SEND_LARGE_COMMUNITY)); | |
718e3744 | 4035 | } |
6b0655a2 | 4036 | |
718e3744 | 4037 | /* neighbor soft-reconfig. */ |
4038 | DEFUN (neighbor_soft_reconfiguration, | |
4039 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4040 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4041 | NEIGHBOR_STR |
4042 | NEIGHBOR_ADDR_STR2 | |
4043 | "Per neighbor soft reconfiguration\n" | |
4044 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4045 | { | |
c500ae40 DW |
4046 | int idx_peer = 1; |
4047 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, | |
718e3744 | 4048 | bgp_node_afi (vty), bgp_node_safi (vty), |
4049 | PEER_FLAG_SOFT_RECONFIG); | |
4050 | } | |
4051 | ||
4052 | DEFUN (no_neighbor_soft_reconfiguration, | |
4053 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4054 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4055 | NO_STR |
4056 | NEIGHBOR_STR | |
4057 | NEIGHBOR_ADDR_STR2 | |
4058 | "Per neighbor soft reconfiguration\n" | |
4059 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4060 | { | |
c500ae40 DW |
4061 | int idx_peer = 2; |
4062 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, | |
718e3744 | 4063 | bgp_node_afi (vty), bgp_node_safi (vty), |
4064 | PEER_FLAG_SOFT_RECONFIG); | |
4065 | } | |
6b0655a2 | 4066 | |
718e3744 | 4067 | DEFUN (neighbor_route_reflector_client, |
4068 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4069 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4070 | NEIGHBOR_STR |
4071 | NEIGHBOR_ADDR_STR2 | |
4072 | "Configure a neighbor as Route Reflector client\n") | |
4073 | { | |
c500ae40 | 4074 | int idx_peer = 1; |
718e3744 | 4075 | struct peer *peer; |
4076 | ||
4077 | ||
c500ae40 | 4078 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 4079 | if (! peer) |
4080 | return CMD_WARNING; | |
4081 | ||
c500ae40 | 4082 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 4083 | bgp_node_safi (vty), |
4084 | PEER_FLAG_REFLECTOR_CLIENT); | |
4085 | } | |
4086 | ||
4087 | DEFUN (no_neighbor_route_reflector_client, | |
4088 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4089 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4090 | NO_STR |
4091 | NEIGHBOR_STR | |
4092 | NEIGHBOR_ADDR_STR2 | |
4093 | "Configure a neighbor as Route Reflector client\n") | |
4094 | { | |
c500ae40 DW |
4095 | int idx_peer = 2; |
4096 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4097 | bgp_node_safi (vty), |
4098 | PEER_FLAG_REFLECTOR_CLIENT); | |
4099 | } | |
6b0655a2 | 4100 | |
718e3744 | 4101 | /* neighbor route-server-client. */ |
4102 | DEFUN (neighbor_route_server_client, | |
4103 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 4104 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4105 | NEIGHBOR_STR |
4106 | NEIGHBOR_ADDR_STR2 | |
4107 | "Configure a neighbor as Route Server client\n") | |
4108 | { | |
c500ae40 | 4109 | int idx_peer = 1; |
2a3d5731 DW |
4110 | struct peer *peer; |
4111 | ||
c500ae40 | 4112 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
2a3d5731 DW |
4113 | if (! peer) |
4114 | return CMD_WARNING; | |
c500ae40 | 4115 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
2a3d5731 DW |
4116 | bgp_node_safi (vty), |
4117 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 4118 | } |
4119 | ||
4120 | DEFUN (no_neighbor_route_server_client, | |
4121 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 4122 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4123 | NO_STR |
4124 | NEIGHBOR_STR | |
4125 | NEIGHBOR_ADDR_STR2 | |
4126 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 4127 | { |
c500ae40 DW |
4128 | int idx_peer = 2; |
4129 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
2a3d5731 DW |
4130 | bgp_node_safi (vty), |
4131 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 4132 | } |
6b0655a2 | 4133 | |
fee0f4c6 | 4134 | DEFUN (neighbor_nexthop_local_unchanged, |
4135 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4136 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4137 | NEIGHBOR_STR |
4138 | NEIGHBOR_ADDR_STR2 | |
4139 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
4140 | "Leave link-local nexthop unchanged for this peer\n") | |
4141 | { | |
c500ae40 DW |
4142 | int idx_peer = 1; |
4143 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
fee0f4c6 | 4144 | bgp_node_safi (vty), |
4145 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED ); | |
4146 | } | |
6b0655a2 | 4147 | |
fee0f4c6 | 4148 | DEFUN (no_neighbor_nexthop_local_unchanged, |
4149 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4150 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4151 | NO_STR |
4152 | NEIGHBOR_STR | |
4153 | NEIGHBOR_ADDR_STR2 | |
4154 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
4155 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 4156 | { |
c500ae40 DW |
4157 | int idx_peer = 2; |
4158 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4159 | bgp_node_safi (vty), |
fee0f4c6 | 4160 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED ); |
718e3744 | 4161 | } |
6b0655a2 | 4162 | |
718e3744 | 4163 | DEFUN (neighbor_attr_unchanged, |
4164 | neighbor_attr_unchanged_cmd, | |
1084263f QY |
4165 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged\ |
4166 | [<\ | |
ddbaf941 QY |
4167 | as-path [<next-hop [med]|med [next-hop]>]|\ |
4168 | next-hop [<as-path [med]|med [as-path]>]|\ | |
4169 | med [<as-path [next-hop]|next-hop [as-path]>]\ | |
1084263f | 4170 | >]", |
718e3744 | 4171 | NEIGHBOR_STR |
4172 | NEIGHBOR_ADDR_STR2 | |
4173 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4174 | "As-path attribute\n" | |
4175 | "Nexthop attribute\n" | |
40e718b5 | 4176 | "Med attribute\n" |
1084263f QY |
4177 | "Med attribute\n" |
4178 | "Nexthop attribute\n" | |
4179 | "Nexthop attribute\n" | |
4180 | "As-path attribute\n" | |
4181 | "Med attribute\n" | |
40e718b5 | 4182 | "Med attribute\n" |
718e3744 | 4183 | "As-path attribute\n" |
1084263f QY |
4184 | "Med attribute\n" |
4185 | "As-path attribute\n" | |
4186 | "Nexthop attribute\n" | |
40e718b5 | 4187 | "Nexthop attribute\n" |
1084263f | 4188 | "As-path attribute\n") |
718e3744 | 4189 | { |
40e718b5 QY |
4190 | int idx = 0; |
4191 | char *peer = argv[1]->arg; | |
4192 | u_int16_t flags = 0; | |
718e3744 | 4193 | |
40e718b5 | 4194 | if (argv_find (argv, argc, "as-path", &idx)) |
718e3744 | 4195 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
40e718b5 QY |
4196 | idx = 0; |
4197 | if (argv_find (argv, argc, "next-hop", &idx)) | |
4198 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4199 | idx = 0; | |
4200 | if (argv_find (argv, argc, "med", &idx)) | |
718e3744 | 4201 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
4202 | ||
40e718b5 QY |
4203 | if (!flags) // no flags means all of them! |
4204 | { | |
718e3744 | 4205 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
718e3744 | 4206 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); |
40e718b5 QY |
4207 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
4208 | } | |
718e3744 | 4209 | |
40e718b5 | 4210 | return peer_af_flag_set_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flags); |
718e3744 | 4211 | } |
4212 | ||
718e3744 | 4213 | DEFUN (no_neighbor_attr_unchanged, |
4214 | no_neighbor_attr_unchanged_cmd, | |
1084263f QY |
4215 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged\ |
4216 | [<\ | |
ddbaf941 QY |
4217 | as-path [<next-hop [med]|med [next-hop]>]|\ |
4218 | next-hop [<as-path [med]|med [as-path]>]|\ | |
4219 | med [<as-path [next-hop]|next-hop [as-path]>]\ | |
1084263f | 4220 | >]", |
e52702f2 | 4221 | NO_STR |
718e3744 | 4222 | NEIGHBOR_STR |
4223 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
4224 | "BGP attribute is propagated unchanged to this neighbor\n" |
4225 | "As-path attribute\n" | |
40e718b5 | 4226 | "Nexthop attribute\n" |
31500417 | 4227 | "Med attribute\n" |
1084263f QY |
4228 | "Med attribute\n" |
4229 | "Nexthop attribute\n" | |
4230 | "Nexthop attribute\n" | |
4231 | "As-path attribute\n" | |
4232 | "Med attribute\n" | |
40e718b5 | 4233 | "Med attribute\n" |
718e3744 | 4234 | "As-path attribute\n" |
1084263f QY |
4235 | "Med attribute\n" |
4236 | "As-path attribute\n" | |
4237 | "Nexthop attribute\n" | |
718e3744 | 4238 | "Nexthop attribute\n" |
1084263f | 4239 | "As-path attribute\n") |
718e3744 | 4240 | { |
40e718b5 QY |
4241 | int idx = 0; |
4242 | char *peer = argv[2]->arg; | |
4243 | u_int16_t flags = 0; | |
718e3744 | 4244 | |
40e718b5 | 4245 | if (argv_find (argv, argc, "as-path", &idx)) |
718e3744 | 4246 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
40e718b5 QY |
4247 | idx = 0; |
4248 | if (argv_find (argv, argc, "next-hop", &idx)) | |
4249 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4250 | idx = 0; | |
4251 | if (argv_find (argv, argc, "med", &idx)) | |
718e3744 | 4252 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
4253 | ||
40e718b5 QY |
4254 | if (!flags) // no flags means all of them! |
4255 | { | |
718e3744 | 4256 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
718e3744 | 4257 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); |
40e718b5 QY |
4258 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
4259 | } | |
718e3744 | 4260 | |
40e718b5 | 4261 | return peer_af_flag_unset_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flags); |
718e3744 | 4262 | } |
4263 | ||
718e3744 | 4264 | |
718e3744 | 4265 | /* EBGP multihop configuration. */ |
94f2b392 | 4266 | static int |
e52702f2 | 4267 | peer_ebgp_multihop_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4268 | const char *ttl_str) |
718e3744 | 4269 | { |
4270 | struct peer *peer; | |
fd79ac91 | 4271 | unsigned int ttl; |
718e3744 | 4272 | |
4273 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4274 | if (! peer) | |
4275 | return CMD_WARNING; | |
4276 | ||
63fa10b5 QY |
4277 | if (peer->conf_if) |
4278 | return bgp_vty_return (vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
4279 | ||
718e3744 | 4280 | if (! ttl_str) |
9b1be336 | 4281 | ttl = MAXTTL; |
718e3744 | 4282 | else |
9b1be336 | 4283 | VTY_GET_INTEGER_RANGE ("TTL", ttl, ttl_str, 1, MAXTTL); |
718e3744 | 4284 | |
89b6d1f8 | 4285 | return bgp_vty_return (vty, peer_ebgp_multihop_set (peer, ttl)); |
718e3744 | 4286 | } |
4287 | ||
94f2b392 | 4288 | static int |
e52702f2 | 4289 | peer_ebgp_multihop_unset_vty (struct vty *vty, const char *ip_str) |
718e3744 | 4290 | { |
4291 | struct peer *peer; | |
4292 | ||
4293 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4294 | if (! peer) | |
4295 | return CMD_WARNING; | |
4296 | ||
89b6d1f8 | 4297 | return bgp_vty_return (vty, peer_ebgp_multihop_unset (peer)); |
718e3744 | 4298 | } |
4299 | ||
4300 | /* neighbor ebgp-multihop. */ | |
4301 | DEFUN (neighbor_ebgp_multihop, | |
4302 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 4303 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 4304 | NEIGHBOR_STR |
4305 | NEIGHBOR_ADDR_STR2 | |
4306 | "Allow EBGP neighbors not on directly connected networks\n") | |
4307 | { | |
c500ae40 DW |
4308 | int idx_peer = 1; |
4309 | return peer_ebgp_multihop_set_vty (vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4310 | } |
4311 | ||
4312 | DEFUN (neighbor_ebgp_multihop_ttl, | |
4313 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 4314 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 4315 | NEIGHBOR_STR |
4316 | NEIGHBOR_ADDR_STR2 | |
4317 | "Allow EBGP neighbors not on directly connected networks\n" | |
4318 | "maximum hop count\n") | |
4319 | { | |
c500ae40 DW |
4320 | int idx_peer = 1; |
4321 | int idx_number = 3; | |
4322 | return peer_ebgp_multihop_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg); | |
718e3744 | 4323 | } |
4324 | ||
4325 | DEFUN (no_neighbor_ebgp_multihop, | |
4326 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 4327 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 4328 | NO_STR |
4329 | NEIGHBOR_STR | |
4330 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4331 | "Allow EBGP neighbors not on directly connected networks\n" |
4332 | "maximum hop count\n") | |
718e3744 | 4333 | { |
c500ae40 DW |
4334 | int idx_peer = 2; |
4335 | return peer_ebgp_multihop_unset_vty (vty, argv[idx_peer]->arg); | |
718e3744 | 4336 | } |
4337 | ||
6b0655a2 | 4338 | |
6ffd2079 | 4339 | /* disable-connected-check */ |
4340 | DEFUN (neighbor_disable_connected_check, | |
4341 | neighbor_disable_connected_check_cmd, | |
a636c635 | 4342 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4343 | NEIGHBOR_STR |
4344 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4345 | "one-hop away EBGP peer using loopback address\n" |
4346 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4347 | { |
c500ae40 DW |
4348 | int idx_peer = 1; |
4349 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4350 | } |
4351 | ||
4352 | DEFUN (no_neighbor_disable_connected_check, | |
4353 | no_neighbor_disable_connected_check_cmd, | |
a636c635 | 4354 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4355 | NO_STR |
4356 | NEIGHBOR_STR | |
4357 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4358 | "one-hop away EBGP peer using loopback address\n" |
4359 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4360 | { |
c500ae40 DW |
4361 | int idx_peer = 2; |
4362 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4363 | } |
4364 | ||
718e3744 | 4365 | DEFUN (neighbor_description, |
4366 | neighbor_description_cmd, | |
e961923c | 4367 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 4368 | NEIGHBOR_STR |
4369 | NEIGHBOR_ADDR_STR2 | |
4370 | "Neighbor specific description\n" | |
4371 | "Up to 80 characters describing this neighbor\n") | |
4372 | { | |
c500ae40 | 4373 | int idx_peer = 1; |
58749582 | 4374 | int idx_line = 3; |
718e3744 | 4375 | struct peer *peer; |
718e3744 | 4376 | char *str; |
718e3744 | 4377 | |
c500ae40 | 4378 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 4379 | if (! peer) |
4380 | return CMD_WARNING; | |
4381 | ||
58749582 | 4382 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 4383 | |
4384 | peer_description_set (peer, str); | |
4385 | ||
3b8b1855 | 4386 | XFREE (MTYPE_TMP, str); |
718e3744 | 4387 | |
4388 | return CMD_SUCCESS; | |
4389 | } | |
4390 | ||
4391 | DEFUN (no_neighbor_description, | |
4392 | no_neighbor_description_cmd, | |
a636c635 | 4393 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description [LINE]", |
718e3744 | 4394 | NO_STR |
4395 | NEIGHBOR_STR | |
4396 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4397 | "Neighbor specific description\n" |
4398 | "Up to 80 characters describing this neighbor\n") | |
718e3744 | 4399 | { |
c500ae40 | 4400 | int idx_peer = 2; |
718e3744 | 4401 | struct peer *peer; |
4402 | ||
c500ae40 | 4403 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 4404 | if (! peer) |
4405 | return CMD_WARNING; | |
4406 | ||
4407 | peer_description_unset (peer); | |
4408 | ||
4409 | return CMD_SUCCESS; | |
4410 | } | |
4411 | ||
6b0655a2 | 4412 | |
718e3744 | 4413 | /* Neighbor update-source. */ |
94f2b392 | 4414 | static int |
e52702f2 | 4415 | peer_update_source_vty (struct vty *vty, const char *peer_str, |
fd79ac91 | 4416 | const char *source_str) |
718e3744 | 4417 | { |
4418 | struct peer *peer; | |
3b69fd51 | 4419 | struct prefix p; |
718e3744 | 4420 | |
4421 | peer = peer_and_group_lookup_vty (vty, peer_str); | |
4422 | if (! peer) | |
4423 | return CMD_WARNING; | |
4424 | ||
a80beece DS |
4425 | if (peer->conf_if) |
4426 | return CMD_WARNING; | |
4427 | ||
718e3744 | 4428 | if (source_str) |
4429 | { | |
c63b83fe JBD |
4430 | union sockunion su; |
4431 | int ret = str2sockunion (source_str, &su); | |
4432 | ||
4433 | if (ret == 0) | |
4434 | peer_update_source_addr_set (peer, &su); | |
718e3744 | 4435 | else |
3b69fd51 DS |
4436 | { |
4437 | if (str2prefix (source_str, &p)) | |
4438 | { | |
4439 | vty_out (vty, "%% Invalid update-source, remove prefix length %s", | |
4440 | VTY_NEWLINE); | |
4441 | return CMD_WARNING; | |
4442 | } | |
4443 | else | |
4444 | peer_update_source_if_set (peer, source_str); | |
4445 | } | |
718e3744 | 4446 | } |
4447 | else | |
4448 | peer_update_source_unset (peer); | |
4449 | ||
4450 | return CMD_SUCCESS; | |
4451 | } | |
4452 | ||
369688c0 PJ |
4453 | #define BGP_UPDATE_SOURCE_HELP_STR \ |
4454 | "IPv4 address\n" \ | |
9a1a331d PJ |
4455 | "IPv6 address\n" \ |
4456 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 4457 | |
718e3744 | 4458 | DEFUN (neighbor_update_source, |
4459 | neighbor_update_source_cmd, | |
9ccf14f7 | 4460 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 4461 | NEIGHBOR_STR |
4462 | NEIGHBOR_ADDR_STR2 | |
4463 | "Source of routing updates\n" | |
369688c0 | 4464 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 4465 | { |
c500ae40 DW |
4466 | int idx_peer = 1; |
4467 | int idx_peer_2 = 3; | |
4468 | return peer_update_source_vty (vty, argv[idx_peer]->arg, argv[idx_peer_2]->arg); | |
718e3744 | 4469 | } |
4470 | ||
4471 | DEFUN (no_neighbor_update_source, | |
4472 | no_neighbor_update_source_cmd, | |
c7178fe7 | 4473 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 4474 | NO_STR |
4475 | NEIGHBOR_STR | |
4476 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
4477 | "Source of routing updates\n" |
4478 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 4479 | { |
c500ae40 DW |
4480 | int idx_peer = 2; |
4481 | return peer_update_source_vty (vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4482 | } |
6b0655a2 | 4483 | |
94f2b392 | 4484 | static int |
e52702f2 QY |
4485 | peer_default_originate_set_vty (struct vty *vty, const char *peer_str, |
4486 | afi_t afi, safi_t safi, | |
fd79ac91 | 4487 | const char *rmap, int set) |
718e3744 | 4488 | { |
4489 | int ret; | |
4490 | struct peer *peer; | |
4491 | ||
4492 | peer = peer_and_group_lookup_vty (vty, peer_str); | |
4493 | if (! peer) | |
4494 | return CMD_WARNING; | |
4495 | ||
4496 | if (set) | |
4497 | ret = peer_default_originate_set (peer, afi, safi, rmap); | |
4498 | else | |
4499 | ret = peer_default_originate_unset (peer, afi, safi); | |
4500 | ||
4501 | return bgp_vty_return (vty, ret); | |
4502 | } | |
4503 | ||
4504 | /* neighbor default-originate. */ | |
4505 | DEFUN (neighbor_default_originate, | |
4506 | neighbor_default_originate_cmd, | |
9ccf14f7 | 4507 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 4508 | NEIGHBOR_STR |
4509 | NEIGHBOR_ADDR_STR2 | |
4510 | "Originate default route to this neighbor\n") | |
4511 | { | |
c500ae40 DW |
4512 | int idx_peer = 1; |
4513 | return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4514 | bgp_node_safi (vty), NULL, 1); |
4515 | } | |
4516 | ||
4517 | DEFUN (neighbor_default_originate_rmap, | |
4518 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 4519 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 4520 | NEIGHBOR_STR |
4521 | NEIGHBOR_ADDR_STR2 | |
4522 | "Originate default route to this neighbor\n" | |
4523 | "Route-map to specify criteria to originate default\n" | |
4524 | "route-map name\n") | |
4525 | { | |
c500ae40 DW |
4526 | int idx_peer = 1; |
4527 | int idx_word = 4; | |
4528 | return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4529 | bgp_node_safi (vty), argv[idx_word]->arg, 1); | |
718e3744 | 4530 | } |
4531 | ||
4532 | DEFUN (no_neighbor_default_originate, | |
4533 | no_neighbor_default_originate_cmd, | |
a636c635 | 4534 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 4535 | NO_STR |
4536 | NEIGHBOR_STR | |
4537 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4538 | "Originate default route to this neighbor\n" |
4539 | "Route-map to specify criteria to originate default\n" | |
4540 | "route-map name\n") | |
718e3744 | 4541 | { |
c500ae40 DW |
4542 | int idx_peer = 2; |
4543 | return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4544 | bgp_node_safi (vty), NULL, 0); |
4545 | } | |
4546 | ||
6b0655a2 | 4547 | |
718e3744 | 4548 | /* Set neighbor's BGP port. */ |
94f2b392 | 4549 | static int |
e52702f2 | 4550 | peer_port_vty (struct vty *vty, const char *ip_str, int afi, |
fd79ac91 | 4551 | const char *port_str) |
718e3744 | 4552 | { |
4553 | struct peer *peer; | |
4554 | u_int16_t port; | |
4555 | struct servent *sp; | |
4556 | ||
4557 | peer = peer_lookup_vty (vty, ip_str); | |
4558 | if (! peer) | |
4559 | return CMD_WARNING; | |
4560 | ||
4561 | if (! port_str) | |
e52702f2 | 4562 | { |
718e3744 | 4563 | sp = getservbyname ("bgp", "tcp"); |
4564 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs (sp->s_port); | |
4565 | } | |
4566 | else | |
4567 | { | |
4568 | VTY_GET_INTEGER("port", port, port_str); | |
4569 | } | |
4570 | ||
4571 | peer_port_set (peer, port); | |
4572 | ||
4573 | return CMD_SUCCESS; | |
4574 | } | |
4575 | ||
f418446b | 4576 | /* Set specified peer's BGP port. */ |
718e3744 | 4577 | DEFUN (neighbor_port, |
4578 | neighbor_port_cmd, | |
9ccf14f7 | 4579 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 4580 | NEIGHBOR_STR |
4581 | NEIGHBOR_ADDR_STR | |
4582 | "Neighbor's BGP port\n" | |
4583 | "TCP port number\n") | |
4584 | { | |
c500ae40 DW |
4585 | int idx_ip = 1; |
4586 | int idx_number = 3; | |
4587 | return peer_port_vty (vty, argv[idx_ip]->arg, AFI_IP, argv[idx_number]->arg); | |
718e3744 | 4588 | } |
4589 | ||
4590 | DEFUN (no_neighbor_port, | |
4591 | no_neighbor_port_cmd, | |
9ccf14f7 | 4592 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 4593 | NO_STR |
4594 | NEIGHBOR_STR | |
4595 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
4596 | "Neighbor's BGP port\n" |
4597 | "TCP port number\n") | |
718e3744 | 4598 | { |
c500ae40 DW |
4599 | int idx_ip = 2; |
4600 | return peer_port_vty (vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 4601 | } |
4602 | ||
6b0655a2 | 4603 | |
718e3744 | 4604 | /* neighbor weight. */ |
94f2b392 | 4605 | static int |
e52702f2 | 4606 | peer_weight_set_vty (struct vty *vty, const char *ip_str, |
d93f7ffc | 4607 | afi_t afi, safi_t safi, |
fd79ac91 | 4608 | const char *weight_str) |
718e3744 | 4609 | { |
1f9a9fff | 4610 | int ret; |
718e3744 | 4611 | struct peer *peer; |
4612 | unsigned long weight; | |
4613 | ||
4614 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4615 | if (! peer) | |
4616 | return CMD_WARNING; | |
4617 | ||
4618 | VTY_GET_INTEGER_RANGE("weight", weight, weight_str, 0, 65535); | |
4619 | ||
d93f7ffc | 4620 | ret = peer_weight_set (peer, afi, safi, weight); |
1f9a9fff | 4621 | return bgp_vty_return (vty, ret); |
718e3744 | 4622 | } |
4623 | ||
94f2b392 | 4624 | static int |
d93f7ffc DW |
4625 | peer_weight_unset_vty (struct vty *vty, const char *ip_str, |
4626 | afi_t afi, safi_t safi) | |
718e3744 | 4627 | { |
1f9a9fff | 4628 | int ret; |
718e3744 | 4629 | struct peer *peer; |
4630 | ||
4631 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4632 | if (! peer) | |
4633 | return CMD_WARNING; | |
4634 | ||
d93f7ffc | 4635 | ret = peer_weight_unset (peer, afi, safi); |
1f9a9fff | 4636 | return bgp_vty_return (vty, ret); |
718e3744 | 4637 | } |
4638 | ||
4639 | DEFUN (neighbor_weight, | |
4640 | neighbor_weight_cmd, | |
9ccf14f7 | 4641 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 4642 | NEIGHBOR_STR |
4643 | NEIGHBOR_ADDR_STR2 | |
4644 | "Set default weight for routes from this neighbor\n" | |
4645 | "default weight\n") | |
4646 | { | |
c500ae40 DW |
4647 | int idx_peer = 1; |
4648 | int idx_number = 3; | |
e52702f2 QY |
4649 | return peer_weight_set_vty (vty, |
4650 | argv[idx_peer]->arg, | |
4651 | bgp_node_afi (vty), | |
4652 | bgp_node_safi (vty), | |
4653 | argv[idx_number]->arg); | |
718e3744 | 4654 | } |
4655 | ||
4656 | DEFUN (no_neighbor_weight, | |
4657 | no_neighbor_weight_cmd, | |
9ccf14f7 | 4658 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 4659 | NO_STR |
4660 | NEIGHBOR_STR | |
4661 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
4662 | "Set default weight for routes from this neighbor\n" |
4663 | "default weight\n") | |
718e3744 | 4664 | { |
c500ae40 | 4665 | int idx_peer = 2; |
e52702f2 | 4666 | return peer_weight_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty)); |
718e3744 | 4667 | } |
4668 | ||
6b0655a2 | 4669 | |
718e3744 | 4670 | /* Override capability negotiation. */ |
4671 | DEFUN (neighbor_override_capability, | |
4672 | neighbor_override_capability_cmd, | |
9ccf14f7 | 4673 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 4674 | NEIGHBOR_STR |
4675 | NEIGHBOR_ADDR_STR2 | |
4676 | "Override capability negotiation result\n") | |
4677 | { | |
c500ae40 DW |
4678 | int idx_peer = 1; |
4679 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 4680 | } |
4681 | ||
4682 | DEFUN (no_neighbor_override_capability, | |
4683 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 4684 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 4685 | NO_STR |
4686 | NEIGHBOR_STR | |
4687 | NEIGHBOR_ADDR_STR2 | |
4688 | "Override capability negotiation result\n") | |
4689 | { | |
c500ae40 DW |
4690 | int idx_peer = 2; |
4691 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 4692 | } |
6b0655a2 | 4693 | |
718e3744 | 4694 | DEFUN (neighbor_strict_capability, |
4695 | neighbor_strict_capability_cmd, | |
9ccf14f7 | 4696 | "neighbor <A.B.C.D|X:X::X:X> strict-capability-match", |
718e3744 | 4697 | NEIGHBOR_STR |
4698 | NEIGHBOR_ADDR_STR | |
4699 | "Strict capability negotiation match\n") | |
4700 | { | |
c500ae40 DW |
4701 | int idx_ip = 1; |
4702 | return peer_flag_set_vty (vty, argv[idx_ip]->arg, PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 4703 | } |
4704 | ||
4705 | DEFUN (no_neighbor_strict_capability, | |
4706 | no_neighbor_strict_capability_cmd, | |
9ccf14f7 | 4707 | "no neighbor <A.B.C.D|X:X::X:X> strict-capability-match", |
718e3744 | 4708 | NO_STR |
4709 | NEIGHBOR_STR | |
4710 | NEIGHBOR_ADDR_STR | |
4711 | "Strict capability negotiation match\n") | |
4712 | { | |
c500ae40 DW |
4713 | int idx_ip = 2; |
4714 | return peer_flag_unset_vty (vty, argv[idx_ip]->arg, PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 4715 | } |
6b0655a2 | 4716 | |
94f2b392 | 4717 | static int |
e52702f2 | 4718 | peer_timers_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4719 | const char *keep_str, const char *hold_str) |
718e3744 | 4720 | { |
4721 | int ret; | |
4722 | struct peer *peer; | |
4723 | u_int32_t keepalive; | |
4724 | u_int32_t holdtime; | |
4725 | ||
4726 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4727 | if (! peer) | |
4728 | return CMD_WARNING; | |
4729 | ||
4730 | VTY_GET_INTEGER_RANGE ("Keepalive", keepalive, keep_str, 0, 65535); | |
4731 | VTY_GET_INTEGER_RANGE ("Holdtime", holdtime, hold_str, 0, 65535); | |
4732 | ||
4733 | ret = peer_timers_set (peer, keepalive, holdtime); | |
4734 | ||
4735 | return bgp_vty_return (vty, ret); | |
4736 | } | |
6b0655a2 | 4737 | |
94f2b392 | 4738 | static int |
fd79ac91 | 4739 | peer_timers_unset_vty (struct vty *vty, const char *ip_str) |
718e3744 | 4740 | { |
4741 | int ret; | |
4742 | struct peer *peer; | |
4743 | ||
0c412461 | 4744 | peer = peer_and_group_lookup_vty (vty, ip_str); |
718e3744 | 4745 | if (! peer) |
4746 | return CMD_WARNING; | |
4747 | ||
4748 | ret = peer_timers_unset (peer); | |
4749 | ||
4750 | return bgp_vty_return (vty, ret); | |
4751 | } | |
4752 | ||
4753 | DEFUN (neighbor_timers, | |
4754 | neighbor_timers_cmd, | |
9ccf14f7 | 4755 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 4756 | NEIGHBOR_STR |
4757 | NEIGHBOR_ADDR_STR2 | |
4758 | "BGP per neighbor timers\n" | |
4759 | "Keepalive interval\n" | |
4760 | "Holdtime\n") | |
4761 | { | |
c500ae40 DW |
4762 | int idx_peer = 1; |
4763 | int idx_number = 3; | |
4764 | int idx_number_2 = 4; | |
4765 | return peer_timers_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg); | |
718e3744 | 4766 | } |
4767 | ||
4768 | DEFUN (no_neighbor_timers, | |
4769 | no_neighbor_timers_cmd, | |
9ccf14f7 | 4770 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 4771 | NO_STR |
4772 | NEIGHBOR_STR | |
4773 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
4774 | "BGP per neighbor timers\n" |
4775 | "Keepalive interval\n" | |
4776 | "Holdtime\n") | |
718e3744 | 4777 | { |
c500ae40 DW |
4778 | int idx_peer = 2; |
4779 | return peer_timers_unset_vty (vty, argv[idx_peer]->arg); | |
718e3744 | 4780 | } |
6b0655a2 | 4781 | |
813d4307 | 4782 | |
94f2b392 | 4783 | static int |
e52702f2 | 4784 | peer_timers_connect_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4785 | const char *time_str) |
718e3744 | 4786 | { |
4787 | int ret; | |
4788 | struct peer *peer; | |
4789 | u_int32_t connect; | |
4790 | ||
966f821c | 4791 | peer = peer_and_group_lookup_vty (vty, ip_str); |
718e3744 | 4792 | if (! peer) |
4793 | return CMD_WARNING; | |
4794 | ||
4795 | VTY_GET_INTEGER_RANGE ("Connect time", connect, time_str, 0, 65535); | |
4796 | ||
4797 | ret = peer_timers_connect_set (peer, connect); | |
4798 | ||
966f821c | 4799 | return bgp_vty_return (vty, ret); |
718e3744 | 4800 | } |
4801 | ||
94f2b392 | 4802 | static int |
fd79ac91 | 4803 | peer_timers_connect_unset_vty (struct vty *vty, const char *ip_str) |
718e3744 | 4804 | { |
4805 | int ret; | |
4806 | struct peer *peer; | |
4807 | ||
4808 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4809 | if (! peer) | |
4810 | return CMD_WARNING; | |
4811 | ||
4812 | ret = peer_timers_connect_unset (peer); | |
4813 | ||
966f821c | 4814 | return bgp_vty_return (vty, ret); |
718e3744 | 4815 | } |
4816 | ||
4817 | DEFUN (neighbor_timers_connect, | |
4818 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 4819 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 4820 | NEIGHBOR_STR |
966f821c | 4821 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4822 | "BGP per neighbor timers\n" |
4823 | "BGP connect timer\n" | |
4824 | "Connect timer\n") | |
4825 | { | |
c500ae40 DW |
4826 | int idx_peer = 1; |
4827 | int idx_number = 4; | |
4828 | return peer_timers_connect_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg); | |
718e3744 | 4829 | } |
4830 | ||
4831 | DEFUN (no_neighbor_timers_connect, | |
4832 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 4833 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 4834 | NO_STR |
4835 | NEIGHBOR_STR | |
966f821c | 4836 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4837 | "BGP per neighbor timers\n" |
8334fd5a DW |
4838 | "BGP connect timer\n" |
4839 | "Connect timer\n") | |
718e3744 | 4840 | { |
c500ae40 DW |
4841 | int idx_peer = 2; |
4842 | return peer_timers_connect_unset_vty (vty, argv[idx_peer]->arg); | |
718e3744 | 4843 | } |
4844 | ||
6b0655a2 | 4845 | |
94f2b392 | 4846 | static int |
e52702f2 QY |
4847 | peer_advertise_interval_vty (struct vty *vty, const char *ip_str, |
4848 | const char *time_str, int set) | |
718e3744 | 4849 | { |
4850 | int ret; | |
4851 | struct peer *peer; | |
4852 | u_int32_t routeadv = 0; | |
4853 | ||
966f821c | 4854 | peer = peer_and_group_lookup_vty (vty, ip_str); |
718e3744 | 4855 | if (! peer) |
4856 | return CMD_WARNING; | |
4857 | ||
4858 | if (time_str) | |
4859 | VTY_GET_INTEGER_RANGE ("advertise interval", routeadv, time_str, 0, 600); | |
4860 | ||
4861 | if (set) | |
4862 | ret = peer_advertise_interval_set (peer, routeadv); | |
4863 | else | |
4864 | ret = peer_advertise_interval_unset (peer); | |
4865 | ||
966f821c | 4866 | return bgp_vty_return (vty, ret); |
718e3744 | 4867 | } |
4868 | ||
4869 | DEFUN (neighbor_advertise_interval, | |
4870 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 4871 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 4872 | NEIGHBOR_STR |
966f821c | 4873 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4874 | "Minimum interval between sending BGP routing updates\n" |
4875 | "time in seconds\n") | |
4876 | { | |
c500ae40 DW |
4877 | int idx_peer = 1; |
4878 | int idx_number = 3; | |
4879 | return peer_advertise_interval_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg, 1); | |
718e3744 | 4880 | } |
4881 | ||
4882 | DEFUN (no_neighbor_advertise_interval, | |
4883 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 4884 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 4885 | NO_STR |
4886 | NEIGHBOR_STR | |
966f821c | 4887 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
4888 | "Minimum interval between sending BGP routing updates\n" |
4889 | "time in seconds\n") | |
718e3744 | 4890 | { |
c500ae40 DW |
4891 | int idx_peer = 2; |
4892 | return peer_advertise_interval_vty (vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 4893 | } |
4894 | ||
6b0655a2 | 4895 | |
518f0eb1 DS |
4896 | /* Time to wait before processing route-map updates */ |
4897 | DEFUN (bgp_set_route_map_delay_timer, | |
4898 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 4899 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
4900 | SET_STR |
4901 | "BGP route-map delay timer\n" | |
4902 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 4903 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 4904 | { |
c500ae40 | 4905 | int idx_number = 3; |
518f0eb1 | 4906 | u_int32_t rmap_delay_timer; |
518f0eb1 | 4907 | |
c500ae40 | 4908 | if (argv[idx_number]->arg) |
518f0eb1 | 4909 | { |
c500ae40 | 4910 | VTY_GET_INTEGER_RANGE ("delay-timer", rmap_delay_timer, argv[idx_number]->arg, 0, 600); |
5fe9f963 | 4911 | bm->rmap_update_timer = rmap_delay_timer; |
518f0eb1 DS |
4912 | |
4913 | /* if the dynamic update handling is being disabled, and a timer is | |
4914 | * running, stop the timer and act as if the timer has already fired. | |
4915 | */ | |
5fe9f963 | 4916 | if (!rmap_delay_timer && bm->t_rmap_update ) |
518f0eb1 | 4917 | { |
5fe9f963 | 4918 | BGP_TIMER_OFF(bm->t_rmap_update); |
4919 | thread_execute (bm->master, bgp_route_map_update_timer, NULL, 0); | |
518f0eb1 DS |
4920 | } |
4921 | return CMD_SUCCESS; | |
4922 | } | |
4923 | else | |
ffd0c037 | 4924 | return CMD_WARNING; |
518f0eb1 DS |
4925 | } |
4926 | ||
4927 | DEFUN (no_bgp_set_route_map_delay_timer, | |
4928 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 4929 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 4930 | NO_STR |
3a2d747c | 4931 | BGP_STR |
518f0eb1 | 4932 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
4933 | "Reset to default time to wait for processing route-map changes\n" |
4934 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 4935 | { |
518f0eb1 | 4936 | |
5fe9f963 | 4937 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 DS |
4938 | |
4939 | return CMD_SUCCESS; | |
4940 | } | |
4941 | ||
f414725f | 4942 | |
718e3744 | 4943 | /* neighbor interface */ |
94f2b392 | 4944 | static int |
fd79ac91 | 4945 | peer_interface_vty (struct vty *vty, const char *ip_str, const char *str) |
718e3744 | 4946 | { |
718e3744 | 4947 | struct peer *peer; |
4948 | ||
4949 | peer = peer_lookup_vty (vty, ip_str); | |
a80beece | 4950 | if (! peer || peer->conf_if) |
718e3744 | 4951 | return CMD_WARNING; |
4952 | ||
4953 | if (str) | |
ffd0c037 | 4954 | peer_interface_set (peer, str); |
718e3744 | 4955 | else |
ffd0c037 | 4956 | peer_interface_unset (peer); |
718e3744 | 4957 | |
4958 | return CMD_SUCCESS; | |
4959 | } | |
4960 | ||
4961 | DEFUN (neighbor_interface, | |
4962 | neighbor_interface_cmd, | |
9ccf14f7 | 4963 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 4964 | NEIGHBOR_STR |
4965 | NEIGHBOR_ADDR_STR | |
4966 | "Interface\n" | |
4967 | "Interface name\n") | |
4968 | { | |
c500ae40 DW |
4969 | int idx_ip = 1; |
4970 | int idx_word = 3; | |
00d7d2d3 | 4971 | return peer_interface_vty (vty, argv[idx_ip]->arg, argv[idx_word]->arg); |
718e3744 | 4972 | } |
4973 | ||
4974 | DEFUN (no_neighbor_interface, | |
4975 | no_neighbor_interface_cmd, | |
9ccf14f7 | 4976 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 4977 | NO_STR |
4978 | NEIGHBOR_STR | |
16cedbb0 | 4979 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4980 | "Interface\n" |
4981 | "Interface name\n") | |
4982 | { | |
c500ae40 DW |
4983 | int idx_peer = 2; |
4984 | return peer_interface_vty (vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4985 | } |
6b0655a2 | 4986 | |
718e3744 | 4987 | /* Set distribute list to the peer. */ |
94f2b392 | 4988 | static int |
e52702f2 | 4989 | peer_distribute_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4990 | afi_t afi, safi_t safi, |
4991 | const char *name_str, const char *direct_str) | |
718e3744 | 4992 | { |
4993 | int ret; | |
4994 | struct peer *peer; | |
4995 | int direct = FILTER_IN; | |
4996 | ||
4997 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4998 | if (! peer) | |
4999 | return CMD_WARNING; | |
5000 | ||
5001 | /* Check filter direction. */ | |
5002 | if (strncmp (direct_str, "i", 1) == 0) | |
5003 | direct = FILTER_IN; | |
5004 | else if (strncmp (direct_str, "o", 1) == 0) | |
5005 | direct = FILTER_OUT; | |
5006 | ||
5007 | ret = peer_distribute_set (peer, afi, safi, direct, name_str); | |
5008 | ||
5009 | return bgp_vty_return (vty, ret); | |
5010 | } | |
5011 | ||
94f2b392 | 5012 | static int |
fd79ac91 | 5013 | peer_distribute_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
5014 | safi_t safi, const char *direct_str) | |
718e3744 | 5015 | { |
5016 | int ret; | |
5017 | struct peer *peer; | |
5018 | int direct = FILTER_IN; | |
5019 | ||
5020 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5021 | if (! peer) | |
5022 | return CMD_WARNING; | |
5023 | ||
5024 | /* Check filter direction. */ | |
5025 | if (strncmp (direct_str, "i", 1) == 0) | |
5026 | direct = FILTER_IN; | |
5027 | else if (strncmp (direct_str, "o", 1) == 0) | |
5028 | direct = FILTER_OUT; | |
5029 | ||
5030 | ret = peer_distribute_unset (peer, afi, safi, direct); | |
5031 | ||
5032 | return bgp_vty_return (vty, ret); | |
5033 | } | |
5034 | ||
5035 | DEFUN (neighbor_distribute_list, | |
5036 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 5037 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5038 | NEIGHBOR_STR |
5039 | NEIGHBOR_ADDR_STR2 | |
5040 | "Filter updates to/from this neighbor\n" | |
5041 | "IP access-list number\n" | |
5042 | "IP access-list number (expanded range)\n" | |
5043 | "IP Access-list name\n" | |
5044 | "Filter incoming updates\n" | |
5045 | "Filter outgoing updates\n") | |
5046 | { | |
c500ae40 DW |
5047 | int idx_peer = 1; |
5048 | int idx_acl = 3; | |
5049 | int idx_in_out = 4; | |
5050 | return peer_distribute_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5051 | bgp_node_safi (vty), argv[idx_acl]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5052 | } |
5053 | ||
5054 | DEFUN (no_neighbor_distribute_list, | |
5055 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 5056 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5057 | NO_STR |
5058 | NEIGHBOR_STR | |
5059 | NEIGHBOR_ADDR_STR2 | |
5060 | "Filter updates to/from this neighbor\n" | |
5061 | "IP access-list number\n" | |
5062 | "IP access-list number (expanded range)\n" | |
5063 | "IP Access-list name\n" | |
5064 | "Filter incoming updates\n" | |
5065 | "Filter outgoing updates\n") | |
5066 | { | |
c500ae40 DW |
5067 | int idx_peer = 2; |
5068 | int idx_in_out = 5; | |
5069 | return peer_distribute_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5070 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 5071 | } |
6b0655a2 | 5072 | |
718e3744 | 5073 | /* Set prefix list to the peer. */ |
94f2b392 | 5074 | static int |
fd79ac91 | 5075 | peer_prefix_list_set_vty (struct vty *vty, const char *ip_str, afi_t afi, |
e52702f2 | 5076 | safi_t safi, const char *name_str, |
fd79ac91 | 5077 | const char *direct_str) |
718e3744 | 5078 | { |
5079 | int ret; | |
5080 | struct peer *peer; | |
5081 | int direct = FILTER_IN; | |
5082 | ||
5083 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5084 | if (! peer) | |
5085 | return CMD_WARNING; | |
5086 | ||
5087 | /* Check filter direction. */ | |
5088 | if (strncmp (direct_str, "i", 1) == 0) | |
5089 | direct = FILTER_IN; | |
5090 | else if (strncmp (direct_str, "o", 1) == 0) | |
5091 | direct = FILTER_OUT; | |
5092 | ||
5093 | ret = peer_prefix_list_set (peer, afi, safi, direct, name_str); | |
5094 | ||
5095 | return bgp_vty_return (vty, ret); | |
5096 | } | |
5097 | ||
94f2b392 | 5098 | static int |
fd79ac91 | 5099 | peer_prefix_list_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
5100 | safi_t safi, const char *direct_str) | |
718e3744 | 5101 | { |
5102 | int ret; | |
5103 | struct peer *peer; | |
5104 | int direct = FILTER_IN; | |
5105 | ||
5106 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5107 | if (! peer) | |
5108 | return CMD_WARNING; | |
e52702f2 | 5109 | |
718e3744 | 5110 | /* Check filter direction. */ |
5111 | if (strncmp (direct_str, "i", 1) == 0) | |
5112 | direct = FILTER_IN; | |
5113 | else if (strncmp (direct_str, "o", 1) == 0) | |
5114 | direct = FILTER_OUT; | |
5115 | ||
5116 | ret = peer_prefix_list_unset (peer, afi, safi, direct); | |
5117 | ||
5118 | return bgp_vty_return (vty, ret); | |
5119 | } | |
5120 | ||
5121 | DEFUN (neighbor_prefix_list, | |
5122 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 5123 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5124 | NEIGHBOR_STR |
5125 | NEIGHBOR_ADDR_STR2 | |
5126 | "Filter updates to/from this neighbor\n" | |
5127 | "Name of a prefix list\n" | |
5128 | "Filter incoming updates\n" | |
5129 | "Filter outgoing updates\n") | |
5130 | { | |
c500ae40 DW |
5131 | int idx_peer = 1; |
5132 | int idx_word = 3; | |
5133 | int idx_in_out = 4; | |
5134 | return peer_prefix_list_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5135 | bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5136 | } |
5137 | ||
5138 | DEFUN (no_neighbor_prefix_list, | |
5139 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 5140 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5141 | NO_STR |
5142 | NEIGHBOR_STR | |
5143 | NEIGHBOR_ADDR_STR2 | |
5144 | "Filter updates to/from this neighbor\n" | |
5145 | "Name of a prefix list\n" | |
5146 | "Filter incoming updates\n" | |
5147 | "Filter outgoing updates\n") | |
5148 | { | |
c500ae40 DW |
5149 | int idx_peer = 2; |
5150 | int idx_in_out = 5; | |
5151 | return peer_prefix_list_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5152 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 5153 | } |
6b0655a2 | 5154 | |
94f2b392 | 5155 | static int |
e52702f2 | 5156 | peer_aslist_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 5157 | afi_t afi, safi_t safi, |
5158 | const char *name_str, const char *direct_str) | |
718e3744 | 5159 | { |
5160 | int ret; | |
5161 | struct peer *peer; | |
5162 | int direct = FILTER_IN; | |
5163 | ||
5164 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5165 | if (! peer) | |
5166 | return CMD_WARNING; | |
5167 | ||
5168 | /* Check filter direction. */ | |
5169 | if (strncmp (direct_str, "i", 1) == 0) | |
5170 | direct = FILTER_IN; | |
5171 | else if (strncmp (direct_str, "o", 1) == 0) | |
5172 | direct = FILTER_OUT; | |
5173 | ||
5174 | ret = peer_aslist_set (peer, afi, safi, direct, name_str); | |
5175 | ||
5176 | return bgp_vty_return (vty, ret); | |
5177 | } | |
5178 | ||
94f2b392 | 5179 | static int |
e52702f2 | 5180 | peer_aslist_unset_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 5181 | afi_t afi, safi_t safi, |
5182 | const char *direct_str) | |
718e3744 | 5183 | { |
5184 | int ret; | |
5185 | struct peer *peer; | |
5186 | int direct = FILTER_IN; | |
5187 | ||
5188 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5189 | if (! peer) | |
5190 | return CMD_WARNING; | |
5191 | ||
5192 | /* Check filter direction. */ | |
5193 | if (strncmp (direct_str, "i", 1) == 0) | |
5194 | direct = FILTER_IN; | |
5195 | else if (strncmp (direct_str, "o", 1) == 0) | |
5196 | direct = FILTER_OUT; | |
5197 | ||
5198 | ret = peer_aslist_unset (peer, afi, safi, direct); | |
5199 | ||
5200 | return bgp_vty_return (vty, ret); | |
5201 | } | |
5202 | ||
5203 | DEFUN (neighbor_filter_list, | |
5204 | neighbor_filter_list_cmd, | |
9ccf14f7 | 5205 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5206 | NEIGHBOR_STR |
5207 | NEIGHBOR_ADDR_STR2 | |
5208 | "Establish BGP filters\n" | |
5209 | "AS path access-list name\n" | |
5210 | "Filter incoming routes\n" | |
5211 | "Filter outgoing routes\n") | |
5212 | { | |
c500ae40 DW |
5213 | int idx_peer = 1; |
5214 | int idx_word = 3; | |
5215 | int idx_in_out = 4; | |
5216 | return peer_aslist_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5217 | bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5218 | } |
5219 | ||
5220 | DEFUN (no_neighbor_filter_list, | |
5221 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 5222 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5223 | NO_STR |
5224 | NEIGHBOR_STR | |
5225 | NEIGHBOR_ADDR_STR2 | |
5226 | "Establish BGP filters\n" | |
5227 | "AS path access-list name\n" | |
5228 | "Filter incoming routes\n" | |
5229 | "Filter outgoing routes\n") | |
5230 | { | |
c500ae40 DW |
5231 | int idx_peer = 2; |
5232 | int idx_in_out = 5; | |
5233 | return peer_aslist_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5234 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 5235 | } |
6b0655a2 | 5236 | |
718e3744 | 5237 | /* Set route-map to the peer. */ |
94f2b392 | 5238 | static int |
e52702f2 | 5239 | peer_route_map_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 5240 | afi_t afi, safi_t safi, |
5241 | const char *name_str, const char *direct_str) | |
718e3744 | 5242 | { |
5243 | int ret; | |
5244 | struct peer *peer; | |
fee0f4c6 | 5245 | int direct = RMAP_IN; |
718e3744 | 5246 | |
5247 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5248 | if (! peer) | |
5249 | return CMD_WARNING; | |
5250 | ||
5251 | /* Check filter direction. */ | |
fee0f4c6 | 5252 | if (strncmp (direct_str, "in", 2) == 0) |
5253 | direct = RMAP_IN; | |
718e3744 | 5254 | else if (strncmp (direct_str, "o", 1) == 0) |
fee0f4c6 | 5255 | direct = RMAP_OUT; |
718e3744 | 5256 | |
5257 | ret = peer_route_map_set (peer, afi, safi, direct, name_str); | |
5258 | ||
5259 | return bgp_vty_return (vty, ret); | |
5260 | } | |
5261 | ||
94f2b392 | 5262 | static int |
fd79ac91 | 5263 | peer_route_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
5264 | safi_t safi, const char *direct_str) | |
718e3744 | 5265 | { |
5266 | int ret; | |
5267 | struct peer *peer; | |
fee0f4c6 | 5268 | int direct = RMAP_IN; |
718e3744 | 5269 | |
5270 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5271 | if (! peer) | |
5272 | return CMD_WARNING; | |
5273 | ||
5274 | /* Check filter direction. */ | |
fee0f4c6 | 5275 | if (strncmp (direct_str, "in", 2) == 0) |
5276 | direct = RMAP_IN; | |
718e3744 | 5277 | else if (strncmp (direct_str, "o", 1) == 0) |
fee0f4c6 | 5278 | direct = RMAP_OUT; |
718e3744 | 5279 | |
5280 | ret = peer_route_map_unset (peer, afi, safi, direct); | |
5281 | ||
5282 | return bgp_vty_return (vty, ret); | |
5283 | } | |
5284 | ||
5285 | DEFUN (neighbor_route_map, | |
5286 | neighbor_route_map_cmd, | |
9ccf14f7 | 5287 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5288 | NEIGHBOR_STR |
5289 | NEIGHBOR_ADDR_STR2 | |
5290 | "Apply route map to neighbor\n" | |
5291 | "Name of route map\n" | |
5292 | "Apply map to incoming routes\n" | |
2a3d5731 | 5293 | "Apply map to outbound routes\n") |
718e3744 | 5294 | { |
c500ae40 DW |
5295 | int idx_peer = 1; |
5296 | int idx_word = 3; | |
5297 | int idx_in_out = 4; | |
5298 | return peer_route_map_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5299 | bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5300 | } |
5301 | ||
5302 | DEFUN (no_neighbor_route_map, | |
5303 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 5304 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5305 | NO_STR |
5306 | NEIGHBOR_STR | |
5307 | NEIGHBOR_ADDR_STR2 | |
5308 | "Apply route map to neighbor\n" | |
5309 | "Name of route map\n" | |
5310 | "Apply map to incoming routes\n" | |
2a3d5731 | 5311 | "Apply map to outbound routes\n") |
718e3744 | 5312 | { |
c500ae40 DW |
5313 | int idx_peer = 2; |
5314 | int idx_in_out = 5; | |
5315 | return peer_route_map_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5316 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 5317 | } |
6b0655a2 | 5318 | |
718e3744 | 5319 | /* Set unsuppress-map to the peer. */ |
94f2b392 | 5320 | static int |
fd79ac91 | 5321 | peer_unsuppress_map_set_vty (struct vty *vty, const char *ip_str, afi_t afi, |
5322 | safi_t safi, const char *name_str) | |
718e3744 | 5323 | { |
5324 | int ret; | |
5325 | struct peer *peer; | |
5326 | ||
5327 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5328 | if (! peer) | |
5329 | return CMD_WARNING; | |
5330 | ||
5331 | ret = peer_unsuppress_map_set (peer, afi, safi, name_str); | |
5332 | ||
5333 | return bgp_vty_return (vty, ret); | |
5334 | } | |
5335 | ||
5336 | /* Unset route-map from the peer. */ | |
94f2b392 | 5337 | static int |
fd79ac91 | 5338 | peer_unsuppress_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
718e3744 | 5339 | safi_t safi) |
5340 | { | |
5341 | int ret; | |
5342 | struct peer *peer; | |
5343 | ||
5344 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5345 | if (! peer) | |
5346 | return CMD_WARNING; | |
5347 | ||
5348 | ret = peer_unsuppress_map_unset (peer, afi, safi); | |
5349 | ||
5350 | return bgp_vty_return (vty, ret); | |
5351 | } | |
5352 | ||
5353 | DEFUN (neighbor_unsuppress_map, | |
5354 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5355 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5356 | NEIGHBOR_STR |
5357 | NEIGHBOR_ADDR_STR2 | |
5358 | "Route-map to selectively unsuppress suppressed routes\n" | |
5359 | "Name of route map\n") | |
5360 | { | |
c500ae40 DW |
5361 | int idx_peer = 1; |
5362 | int idx_word = 3; | |
5363 | return peer_unsuppress_map_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5364 | bgp_node_safi (vty), argv[idx_word]->arg); | |
718e3744 | 5365 | } |
5366 | ||
5367 | DEFUN (no_neighbor_unsuppress_map, | |
5368 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5369 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5370 | NO_STR |
5371 | NEIGHBOR_STR | |
5372 | NEIGHBOR_ADDR_STR2 | |
5373 | "Route-map to selectively unsuppress suppressed routes\n" | |
5374 | "Name of route map\n") | |
5375 | { | |
c500ae40 DW |
5376 | int idx_peer = 2; |
5377 | return peer_unsuppress_map_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 5378 | bgp_node_safi (vty)); |
5379 | } | |
6b0655a2 | 5380 | |
94f2b392 | 5381 | static int |
fd79ac91 | 5382 | peer_maximum_prefix_set_vty (struct vty *vty, const char *ip_str, afi_t afi, |
e52702f2 | 5383 | safi_t safi, const char *num_str, |
0a486e5f | 5384 | const char *threshold_str, int warning, |
5385 | const char *restart_str) | |
718e3744 | 5386 | { |
5387 | int ret; | |
5388 | struct peer *peer; | |
5389 | u_int32_t max; | |
e0701b79 | 5390 | u_char threshold; |
0a486e5f | 5391 | u_int16_t restart; |
718e3744 | 5392 | |
5393 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5394 | if (! peer) | |
5395 | return CMD_WARNING; | |
5396 | ||
e6ec1c36 | 5397 | VTY_GET_INTEGER ("maximum number", max, num_str); |
e0701b79 | 5398 | if (threshold_str) |
5399 | threshold = atoi (threshold_str); | |
5400 | else | |
5401 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 5402 | |
0a486e5f | 5403 | if (restart_str) |
5404 | restart = atoi (restart_str); | |
5405 | else | |
5406 | restart = 0; | |
5407 | ||
5408 | ret = peer_maximum_prefix_set (peer, afi, safi, max, threshold, warning, restart); | |
718e3744 | 5409 | |
5410 | return bgp_vty_return (vty, ret); | |
5411 | } | |
5412 | ||
94f2b392 | 5413 | static int |
fd79ac91 | 5414 | peer_maximum_prefix_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
718e3744 | 5415 | safi_t safi) |
5416 | { | |
5417 | int ret; | |
5418 | struct peer *peer; | |
5419 | ||
5420 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5421 | if (! peer) | |
5422 | return CMD_WARNING; | |
5423 | ||
5424 | ret = peer_maximum_prefix_unset (peer, afi, safi); | |
5425 | ||
5426 | return bgp_vty_return (vty, ret); | |
5427 | } | |
5428 | ||
5429 | /* Maximum number of prefix configuration. prefix count is different | |
5430 | for each peer configuration. So this configuration can be set for | |
5431 | each peer configuration. */ | |
5432 | DEFUN (neighbor_maximum_prefix, | |
5433 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 5434 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 5435 | NEIGHBOR_STR |
5436 | NEIGHBOR_ADDR_STR2 | |
5437 | "Maximum number of prefix accept from this peer\n" | |
5438 | "maximum no. of prefix limit\n") | |
5439 | { | |
c500ae40 DW |
5440 | int idx_peer = 1; |
5441 | int idx_number = 3; | |
5442 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5443 | bgp_node_safi (vty), argv[idx_number]->arg, NULL, 0, | |
0a486e5f | 5444 | NULL); |
718e3744 | 5445 | } |
5446 | ||
e0701b79 | 5447 | DEFUN (neighbor_maximum_prefix_threshold, |
5448 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 5449 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 5450 | NEIGHBOR_STR |
5451 | NEIGHBOR_ADDR_STR2 | |
5452 | "Maximum number of prefix accept from this peer\n" | |
5453 | "maximum no. of prefix limit\n" | |
5454 | "Threshold value (%) at which to generate a warning msg\n") | |
5455 | { | |
c500ae40 DW |
5456 | int idx_peer = 1; |
5457 | int idx_number = 3; | |
5458 | int idx_number_2 = 4; | |
5459 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5460 | bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
0a486e5f | 5461 | NULL); |
5462 | } | |
e0701b79 | 5463 | |
718e3744 | 5464 | DEFUN (neighbor_maximum_prefix_warning, |
5465 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 5466 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 5467 | NEIGHBOR_STR |
5468 | NEIGHBOR_ADDR_STR2 | |
5469 | "Maximum number of prefix accept from this peer\n" | |
5470 | "maximum no. of prefix limit\n" | |
5471 | "Only give warning message when limit is exceeded\n") | |
5472 | { | |
c500ae40 DW |
5473 | int idx_peer = 1; |
5474 | int idx_number = 3; | |
5475 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5476 | bgp_node_safi (vty), argv[idx_number]->arg, NULL, 1, | |
0a486e5f | 5477 | NULL); |
718e3744 | 5478 | } |
5479 | ||
e0701b79 | 5480 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
5481 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 5482 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 5483 | NEIGHBOR_STR |
5484 | NEIGHBOR_ADDR_STR2 | |
5485 | "Maximum number of prefix accept from this peer\n" | |
5486 | "maximum no. of prefix limit\n" | |
5487 | "Threshold value (%) at which to generate a warning msg\n" | |
5488 | "Only give warning message when limit is exceeded\n") | |
5489 | { | |
c500ae40 DW |
5490 | int idx_peer = 1; |
5491 | int idx_number = 3; | |
5492 | int idx_number_2 = 4; | |
5493 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5494 | bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 5495 | } |
5496 | ||
5497 | DEFUN (neighbor_maximum_prefix_restart, | |
5498 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 5499 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 5500 | NEIGHBOR_STR |
5501 | NEIGHBOR_ADDR_STR2 | |
5502 | "Maximum number of prefix accept from this peer\n" | |
5503 | "maximum no. of prefix limit\n" | |
5504 | "Restart bgp connection after limit is exceeded\n" | |
5505 | "Restart interval in minutes") | |
5506 | { | |
c500ae40 DW |
5507 | int idx_peer = 1; |
5508 | int idx_number = 3; | |
5509 | int idx_number_2 = 5; | |
5510 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5511 | bgp_node_safi (vty), argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 5512 | } |
5513 | ||
5514 | DEFUN (neighbor_maximum_prefix_threshold_restart, | |
5515 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 5516 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 5517 | NEIGHBOR_STR |
5518 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5519 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 5520 | "maximum no. of prefix limit\n" |
5521 | "Threshold value (%) at which to generate a warning msg\n" | |
5522 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 5523 | "Restart interval in minutes\n") |
0a486e5f | 5524 | { |
c500ae40 DW |
5525 | int idx_peer = 1; |
5526 | int idx_number = 3; | |
5527 | int idx_number_2 = 4; | |
5528 | int idx_number_3 = 6; | |
5529 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5530 | bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 0, argv[idx_number_3]->arg); | |
0a486e5f | 5531 | } |
e0701b79 | 5532 | |
718e3744 | 5533 | DEFUN (no_neighbor_maximum_prefix, |
5534 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 5535 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 5536 | NO_STR |
5537 | NEIGHBOR_STR | |
5538 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5539 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
5540 | "maximum no. of prefix limit\n" |
5541 | "Threshold value (%) at which to generate a warning msg\n" | |
5542 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 5543 | "Restart interval in minutes\n" |
31500417 | 5544 | "Only give warning message when limit is exceeded\n") |
718e3744 | 5545 | { |
c500ae40 DW |
5546 | int idx_peer = 2; |
5547 | return peer_maximum_prefix_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 5548 | bgp_node_safi (vty)); |
5549 | } | |
e52702f2 | 5550 | |
718e3744 | 5551 | |
718e3744 | 5552 | /* "neighbor allowas-in" */ |
5553 | DEFUN (neighbor_allowas_in, | |
5554 | neighbor_allowas_in_cmd, | |
fd8503f5 | 5555 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 5556 | NEIGHBOR_STR |
5557 | NEIGHBOR_ADDR_STR2 | |
31500417 | 5558 | "Accept as-path with my AS present in it\n" |
fd8503f5 QY |
5559 | "Number of occurances of AS number\n" |
5560 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 5561 | { |
c500ae40 | 5562 | int idx_peer = 1; |
fd8503f5 | 5563 | int idx_number_origin = 3; |
718e3744 | 5564 | int ret; |
aac9ef6c | 5565 | int origin = 0; |
718e3744 | 5566 | struct peer *peer; |
aac9ef6c | 5567 | int allow_num = 0; |
718e3744 | 5568 | |
c500ae40 | 5569 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 5570 | if (! peer) |
5571 | return CMD_WARNING; | |
5572 | ||
fd8503f5 | 5573 | if (argc <= idx_number_origin) |
718e3744 | 5574 | allow_num = 3; |
5575 | else | |
aac9ef6c | 5576 | { |
fd8503f5 | 5577 | if (argv[idx_number_origin]->type == WORD_TKN) |
aac9ef6c DW |
5578 | origin = 1; |
5579 | else | |
fd8503f5 | 5580 | allow_num = atoi (argv[idx_number_origin]->arg); |
aac9ef6c | 5581 | } |
718e3744 | 5582 | |
5583 | ret = peer_allowas_in_set (peer, bgp_node_afi (vty), bgp_node_safi (vty), | |
aac9ef6c | 5584 | allow_num, origin); |
718e3744 | 5585 | |
5586 | return bgp_vty_return (vty, ret); | |
5587 | } | |
5588 | ||
718e3744 | 5589 | DEFUN (no_neighbor_allowas_in, |
5590 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 5591 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 5592 | NO_STR |
5593 | NEIGHBOR_STR | |
5594 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 5595 | "allow local ASN appears in aspath attribute\n" |
fd8503f5 QY |
5596 | "Number of occurances of AS number\n" |
5597 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 5598 | { |
c500ae40 | 5599 | int idx_peer = 2; |
718e3744 | 5600 | int ret; |
5601 | struct peer *peer; | |
5602 | ||
c500ae40 | 5603 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 5604 | if (! peer) |
5605 | return CMD_WARNING; | |
5606 | ||
5607 | ret = peer_allowas_in_unset (peer, bgp_node_afi (vty), bgp_node_safi (vty)); | |
5608 | ||
5609 | return bgp_vty_return (vty, ret); | |
5610 | } | |
6b0655a2 | 5611 | |
fa411a21 NH |
5612 | DEFUN (neighbor_ttl_security, |
5613 | neighbor_ttl_security_cmd, | |
9ccf14f7 | 5614 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
5615 | NEIGHBOR_STR |
5616 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5617 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
5618 | "Specify the maximum number of hops to the BGP peer\n" |
5619 | "Number of hops to BGP peer\n") | |
fa411a21 | 5620 | { |
c500ae40 DW |
5621 | int idx_peer = 1; |
5622 | int idx_number = 4; | |
fa411a21 | 5623 | struct peer *peer; |
89b6d1f8 | 5624 | int gtsm_hops; |
fa411a21 | 5625 | |
c500ae40 | 5626 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
fa411a21 NH |
5627 | if (! peer) |
5628 | return CMD_WARNING; | |
e52702f2 | 5629 | |
c500ae40 | 5630 | VTY_GET_INTEGER_RANGE ("", gtsm_hops, argv[idx_number]->arg, 1, 254); |
fa411a21 | 5631 | |
8cdabf90 SK |
5632 | /* |
5633 | * If 'neighbor swpX', then this is for directly connected peers, | |
5634 | * we should not accept a ttl-security hops value greater than 1. | |
5635 | */ | |
5636 | if (peer->conf_if && (gtsm_hops > 1)) { | |
5637 | vty_out (vty, "%s is directly connected peer, hops cannot exceed 1%s", | |
c500ae40 | 5638 | argv[idx_peer]->arg, VTY_NEWLINE); |
8cdabf90 SK |
5639 | return CMD_WARNING; |
5640 | } | |
5641 | ||
89b6d1f8 | 5642 | return bgp_vty_return (vty, peer_ttl_security_hops_set (peer, gtsm_hops)); |
fa411a21 NH |
5643 | } |
5644 | ||
5645 | DEFUN (no_neighbor_ttl_security, | |
5646 | no_neighbor_ttl_security_cmd, | |
9ccf14f7 | 5647 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
5648 | NO_STR |
5649 | NEIGHBOR_STR | |
5650 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5651 | "BGP ttl-security parameters\n" |
3a2d747c QY |
5652 | "Specify the maximum number of hops to the BGP peer\n" |
5653 | "Number of hops to BGP peer\n") | |
fa411a21 | 5654 | { |
c500ae40 | 5655 | int idx_peer = 2; |
fa411a21 | 5656 | struct peer *peer; |
fa411a21 | 5657 | |
c500ae40 | 5658 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
fa411a21 NH |
5659 | if (! peer) |
5660 | return CMD_WARNING; | |
5661 | ||
89b6d1f8 | 5662 | return bgp_vty_return (vty, peer_ttl_security_hops_unset (peer)); |
fa411a21 | 5663 | } |
6b0655a2 | 5664 | |
adbac85e DW |
5665 | DEFUN (neighbor_addpath_tx_all_paths, |
5666 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 5667 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
5668 | NEIGHBOR_STR |
5669 | NEIGHBOR_ADDR_STR2 | |
5670 | "Use addpath to advertise all paths to a neighbor\n") | |
5671 | { | |
c500ae40 | 5672 | int idx_peer = 1; |
adbac85e DW |
5673 | struct peer *peer; |
5674 | ||
c500ae40 | 5675 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
adbac85e DW |
5676 | if (! peer) |
5677 | return CMD_WARNING; | |
5678 | ||
c500ae40 | 5679 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
adbac85e DW |
5680 | bgp_node_safi (vty), |
5681 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
5682 | } | |
5683 | ||
5684 | DEFUN (no_neighbor_addpath_tx_all_paths, | |
5685 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 5686 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
5687 | NO_STR |
5688 | NEIGHBOR_STR | |
5689 | NEIGHBOR_ADDR_STR2 | |
5690 | "Use addpath to advertise all paths to a neighbor\n") | |
5691 | { | |
c500ae40 DW |
5692 | int idx_peer = 2; |
5693 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
adbac85e DW |
5694 | bgp_node_safi (vty), |
5695 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
5696 | } | |
5697 | ||
06370dac DW |
5698 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
5699 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 5700 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
5701 | NEIGHBOR_STR |
5702 | NEIGHBOR_ADDR_STR2 | |
5703 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
5704 | { | |
c500ae40 | 5705 | int idx_peer = 1; |
06370dac DW |
5706 | struct peer *peer; |
5707 | ||
c500ae40 | 5708 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
06370dac DW |
5709 | if (! peer) |
5710 | return CMD_WARNING; | |
5711 | ||
c500ae40 | 5712 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
06370dac DW |
5713 | bgp_node_safi (vty), |
5714 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
5715 | } | |
5716 | ||
5717 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, | |
5718 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 5719 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
5720 | NO_STR |
5721 | NEIGHBOR_STR | |
5722 | NEIGHBOR_ADDR_STR2 | |
5723 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
5724 | { | |
c500ae40 DW |
5725 | int idx_peer = 2; |
5726 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
06370dac DW |
5727 | bgp_node_safi (vty), |
5728 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
5729 | } | |
5730 | ||
505e5056 | 5731 | DEFUN_NOSH (address_family_ipv4_safi, |
718e3744 | 5732 | address_family_ipv4_safi_cmd, |
f51bae9c | 5733 | "address-family ipv4 [<unicast|multicast|vpn|encap|labeled-unicast>]", |
718e3744 | 5734 | "Enter Address Family command mode\n" |
8c3deaae | 5735 | "Address Family\n" |
46f296b4 | 5736 | BGP_SAFI_HELP_STR) |
718e3744 | 5737 | { |
f51bae9c DS |
5738 | |
5739 | if (argc == 3) | |
ccbb332a | 5740 | { |
f51bae9c DS |
5741 | safi_t safi = bgp_vty_safi_from_arg(argv[2]->arg); |
5742 | vty->node = bgp_node_type(AFI_IP, safi); | |
ccbb332a | 5743 | } |
c7f1274b DS |
5744 | else |
5745 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 5746 | |
5747 | return CMD_SUCCESS; | |
5748 | } | |
5749 | ||
505e5056 | 5750 | DEFUN_NOSH (address_family_ipv6_safi, |
25ffbdc1 | 5751 | address_family_ipv6_safi_cmd, |
f51bae9c | 5752 | "address-family ipv6 [<unicast|multicast|vpn|encap|labeled-unicast>]", |
718e3744 | 5753 | "Enter Address Family command mode\n" |
8c3deaae | 5754 | "Address Family\n" |
46f296b4 | 5755 | BGP_SAFI_HELP_STR) |
25ffbdc1 | 5756 | { |
f51bae9c | 5757 | if (argc == 3) |
46f296b4 | 5758 | { |
f51bae9c DS |
5759 | safi_t safi = bgp_vty_safi_from_arg(argv[2]->arg); |
5760 | vty->node = bgp_node_type(AFI_IP6, safi); | |
46f296b4 | 5761 | } |
c7f1274b DS |
5762 | else |
5763 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 5764 | |
5765 | return CMD_SUCCESS; | |
5766 | } | |
718e3744 | 5767 | |
d6902373 | 5768 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 5769 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 5770 | address_family_vpnv4_cmd, |
8334fd5a | 5771 | "address-family vpnv4 [unicast]", |
718e3744 | 5772 | "Enter Address Family command mode\n" |
8c3deaae | 5773 | "Address Family\n" |
3a2d747c | 5774 | "Address Family modifier\n") |
718e3744 | 5775 | { |
5776 | vty->node = BGP_VPNV4_NODE; | |
5777 | return CMD_SUCCESS; | |
5778 | } | |
5779 | ||
505e5056 | 5780 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 5781 | address_family_vpnv6_cmd, |
8334fd5a | 5782 | "address-family vpnv6 [unicast]", |
8ecd3266 | 5783 | "Enter Address Family command mode\n" |
8c3deaae | 5784 | "Address Family\n" |
3a2d747c | 5785 | "Address Family modifier\n") |
8ecd3266 | 5786 | { |
5787 | vty->node = BGP_VPNV6_NODE; | |
5788 | return CMD_SUCCESS; | |
5789 | } | |
c016b6c7 | 5790 | #endif |
d6902373 | 5791 | |
505e5056 | 5792 | DEFUN_NOSH (address_family_encap, |
8b1fb8be | 5793 | address_family_encap_cmd, |
8334fd5a | 5794 | "address-family <encap|encapv4>", |
8b1fb8be | 5795 | "Enter Address Family command mode\n" |
8c3deaae QY |
5796 | "Address Family\n" |
5797 | "Address Family\n") | |
8b1fb8be LB |
5798 | { |
5799 | vty->node = BGP_ENCAP_NODE; | |
5800 | return CMD_SUCCESS; | |
5801 | } | |
5802 | ||
8b1fb8be | 5803 | |
505e5056 | 5804 | DEFUN_NOSH (address_family_encapv6, |
8b1fb8be LB |
5805 | address_family_encapv6_cmd, |
5806 | "address-family encapv6", | |
5807 | "Enter Address Family command mode\n" | |
8c3deaae | 5808 | "Address Family\n") |
8b1fb8be LB |
5809 | { |
5810 | vty->node = BGP_ENCAPV6_NODE; | |
5811 | return CMD_SUCCESS; | |
5812 | } | |
5813 | ||
505e5056 | 5814 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 5815 | address_family_evpn_cmd, |
b194703e | 5816 | "address-family <l2vpn evpn>", |
4e0b7b6d | 5817 | "Enter Address Family command mode\n" |
61a51962 PG |
5818 | "EVPN Address family\n" |
5819 | "Layer2 VPN Address family\n" | |
5820 | "Ethernet Virtual Private Network Subsequent Address Family\n") | |
4e0b7b6d | 5821 | { |
4e0b7b6d | 5822 | vty->node = BGP_EVPN_NODE; |
4e0b7b6d PG |
5823 | return CMD_SUCCESS; |
5824 | } | |
5825 | ||
505e5056 | 5826 | DEFUN_NOSH (exit_address_family, |
718e3744 | 5827 | exit_address_family_cmd, |
5828 | "exit-address-family", | |
5829 | "Exit from Address Family configuration mode\n") | |
5830 | { | |
a8a80d53 | 5831 | if (vty->node == BGP_IPV4_NODE |
5832 | || vty->node == BGP_IPV4M_NODE | |
f51bae9c | 5833 | || vty->node == BGP_IPV4L_NODE |
718e3744 | 5834 | || vty->node == BGP_VPNV4_NODE |
25ffbdc1 | 5835 | || vty->node == BGP_IPV6_NODE |
8ecd3266 | 5836 | || vty->node == BGP_IPV6M_NODE |
f51bae9c | 5837 | || vty->node == BGP_IPV6L_NODE |
8b1fb8be LB |
5838 | || vty->node == BGP_VPNV6_NODE |
5839 | || vty->node == BGP_ENCAP_NODE | |
4e0b7b6d PG |
5840 | || vty->node == BGP_ENCAPV6_NODE |
5841 | || vty->node == BGP_EVPN_NODE) | |
718e3744 | 5842 | vty->node = BGP_NODE; |
5843 | return CMD_SUCCESS; | |
5844 | } | |
6b0655a2 | 5845 | |
8ad7271d DS |
5846 | /* Recalculate bestpath and re-advertise a prefix */ |
5847 | static int | |
01080f7c | 5848 | bgp_clear_prefix (struct vty *vty, const char *view_name, const char *ip_str, |
8ad7271d DS |
5849 | afi_t afi, safi_t safi, struct prefix_rd *prd) |
5850 | { | |
5851 | int ret; | |
5852 | struct prefix match; | |
5853 | struct bgp_node *rn; | |
5854 | struct bgp_node *rm; | |
8ad7271d DS |
5855 | struct bgp *bgp; |
5856 | struct bgp_table *table; | |
5857 | struct bgp_table *rib; | |
5858 | ||
5859 | /* BGP structure lookup. */ | |
5860 | if (view_name) | |
5861 | { | |
5862 | bgp = bgp_lookup_by_name (view_name); | |
5863 | if (bgp == NULL) | |
5864 | { | |
6aeb9e78 | 5865 | vty_out (vty, "%% Can't find BGP instance %s%s", view_name, VTY_NEWLINE); |
8ad7271d DS |
5866 | return CMD_WARNING; |
5867 | } | |
5868 | } | |
5869 | else | |
5870 | { | |
5871 | bgp = bgp_get_default (); | |
5872 | if (bgp == NULL) | |
5873 | { | |
5874 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
5875 | return CMD_WARNING; | |
5876 | } | |
5877 | } | |
5878 | ||
5879 | /* Check IP address argument. */ | |
5880 | ret = str2prefix (ip_str, &match); | |
5881 | if (! ret) | |
5882 | { | |
5883 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); | |
5884 | return CMD_WARNING; | |
5885 | } | |
5886 | ||
5887 | match.family = afi2family (afi); | |
5888 | rib = bgp->rib[afi][safi]; | |
5889 | ||
5890 | if (safi == SAFI_MPLS_VPN) | |
5891 | { | |
5892 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) | |
5893 | { | |
5894 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) | |
5895 | continue; | |
5896 | ||
5897 | if ((table = rn->info) != NULL) | |
5898 | { | |
5899 | if ((rm = bgp_node_match (table, &match)) != NULL) | |
5900 | { | |
5901 | if (rm->p.prefixlen == match.prefixlen) | |
5902 | { | |
5903 | SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR); | |
5904 | bgp_process (bgp, rm, afi, safi); | |
5905 | } | |
5906 | bgp_unlock_node (rm); | |
5907 | } | |
5908 | } | |
5909 | } | |
5910 | } | |
5911 | else | |
5912 | { | |
5913 | if ((rn = bgp_node_match (rib, &match)) != NULL) | |
5914 | { | |
5915 | if (rn->p.prefixlen == match.prefixlen) | |
5916 | { | |
5917 | SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR); | |
5918 | bgp_process (bgp, rn, afi, safi); | |
5919 | } | |
5920 | bgp_unlock_node (rn); | |
5921 | } | |
5922 | } | |
5923 | ||
5924 | return CMD_SUCCESS; | |
5925 | } | |
5926 | ||
b09b5ae0 | 5927 | /* one clear bgp command to rule them all */ |
718e3744 | 5928 | DEFUN (clear_ip_bgp_all, |
5929 | clear_ip_bgp_all_cmd, | |
46f296b4 | 5930 | "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 | 5931 | CLEAR_STR |
5932 | IP_STR | |
5933 | BGP_STR | |
838758ac | 5934 | BGP_INSTANCE_HELP_STR |
b09b5ae0 DW |
5935 | "Clear all peers\n" |
5936 | "BGP neighbor address to clear\n" | |
a80beece | 5937 | "BGP IPv6 neighbor to clear\n" |
838758ac | 5938 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
5939 | "Clear peers with the AS number\n" |
5940 | "Clear all external peers\n" | |
718e3744 | 5941 | "Clear all members of peer-group\n" |
b09b5ae0 | 5942 | "BGP peer-group name\n" |
46f296b4 LB |
5943 | BGP_AFI_HELP_STR |
5944 | BGP_SAFI_HELP_STR | |
b09b5ae0 DW |
5945 | BGP_SOFT_STR |
5946 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
5947 | BGP_SOFT_OUT_STR |
5948 | BGP_SOFT_IN_STR | |
5949 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 5950 | BGP_SOFT_OUT_STR) |
718e3744 | 5951 | { |
8334fd5a | 5952 | char *vrf = NULL; |
630a298c | 5953 | |
ae19d7dd QY |
5954 | afi_t afi = AFI_IP6; |
5955 | safi_t safi = SAFI_UNICAST; | |
5bf15956 | 5956 | enum clear_sort clr_sort = clear_peer; |
b09b5ae0 DW |
5957 | enum bgp_clear_type clr_type; |
5958 | char *clr_arg = NULL; | |
718e3744 | 5959 | |
ae19d7dd | 5960 | int idx = 0; |
01080f7c | 5961 | |
ae19d7dd QY |
5962 | /* clear [ip] bgp */ |
5963 | if (argv_find (argv, argc, "ip", &idx)) | |
5964 | afi = AFI_IP; | |
5965 | /* [<view|vrf> WORD] */ | |
5966 | if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) | |
838758ac | 5967 | { |
ae19d7dd QY |
5968 | vrf = argv[idx + 1]->arg; |
5969 | idx += 2; | |
838758ac | 5970 | } |
ae19d7dd QY |
5971 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */ |
5972 | if (argv_find (argv, argc, "*", &idx)) | |
b09b5ae0 | 5973 | { |
ae19d7dd | 5974 | clr_sort = clear_all; |
b09b5ae0 | 5975 | } |
ae19d7dd | 5976 | else if (argv_find (argv, argc, "A.B.C.D", &idx)) |
b09b5ae0 DW |
5977 | { |
5978 | clr_sort = clear_peer; | |
ae19d7dd | 5979 | clr_arg = argv[idx]->arg; |
b09b5ae0 | 5980 | } |
ae19d7dd | 5981 | else if (argv_find (argv, argc, "X:X::X:X", &idx)) |
b09b5ae0 | 5982 | { |
ae19d7dd QY |
5983 | clr_sort = clear_peer; |
5984 | clr_arg = argv[idx]->arg; | |
838758ac | 5985 | } |
ae19d7dd | 5986 | else if (argv_find (argv, argc, "peer-group", &idx)) |
b09b5ae0 DW |
5987 | { |
5988 | clr_sort = clear_group; | |
ae19d7dd QY |
5989 | idx++; |
5990 | clr_arg = argv[idx]->arg; | |
b09b5ae0 | 5991 | } |
ae19d7dd | 5992 | else if (argv_find (argv, argc, "WORD", &idx)) |
b09b5ae0 | 5993 | { |
f0dac89f RW |
5994 | clr_sort = clear_peer; |
5995 | clr_arg = argv[idx]->arg; | |
b09b5ae0 | 5996 | } |
ae19d7dd QY |
5997 | else if (argv_find (argv, argc, "(1-4294967295)", &idx)) |
5998 | { | |
5999 | clr_sort = clear_as; | |
6000 | clr_arg = argv[idx]->arg; | |
6001 | } | |
6002 | else if (argv_find (argv, argc, "external", &idx)) | |
6003 | { | |
6004 | clr_sort = clear_external; | |
6005 | } | |
46f296b4 LB |
6006 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
6007 | if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) | |
ae19d7dd | 6008 | { |
46f296b4 | 6009 | argv_find_and_parse_safi (argv, argc, &idx, &safi); |
ae19d7dd QY |
6010 | } |
6011 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
6012 | if (argv_find (argv, argc, "soft", &idx)) | |
6013 | { | |
6014 | if (argv_find (argv, argc, "in", &idx) || argv_find (argv, argc, "out", &idx)) | |
6015 | clr_type = strmatch (argv[idx]->text, "in") ? BGP_CLEAR_SOFT_IN : BGP_CLEAR_SOFT_OUT; | |
6016 | else | |
6017 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
6018 | } | |
6019 | else if (argv_find (argv, argc, "in", &idx)) | |
6020 | { | |
6021 | clr_type = argv_find (argv, argc, "prefix-filter", &idx) ? BGP_CLEAR_SOFT_IN_ORF_PREFIX : BGP_CLEAR_SOFT_IN; | |
6022 | } | |
6023 | else if (argv_find (argv, argc, "out", &idx)) | |
6024 | { | |
5daa3e5e | 6025 | clr_type = BGP_CLEAR_SOFT_OUT; |
ae19d7dd QY |
6026 | } |
6027 | else | |
6028 | clr_type = BGP_CLEAR_SOFT_NONE; | |
718e3744 | 6029 | |
b09b5ae0 | 6030 | return bgp_clear_vty (vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); |
838758ac | 6031 | } |
01080f7c | 6032 | |
8ad7271d DS |
6033 | DEFUN (clear_ip_bgp_prefix, |
6034 | clear_ip_bgp_prefix_cmd, | |
838758ac | 6035 | "clear [ip] bgp [<view|vrf> WORD] prefix A.B.C.D/M", |
8ad7271d DS |
6036 | CLEAR_STR |
6037 | IP_STR | |
6038 | BGP_STR | |
838758ac | 6039 | BGP_INSTANCE_HELP_STR |
8ad7271d | 6040 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 6041 | "IPv4 prefix\n") |
8ad7271d | 6042 | { |
8334fd5a | 6043 | char *vrf = NULL; |
630a298c | 6044 | char *prefix = NULL; |
8ad7271d | 6045 | |
630a298c | 6046 | int idx = 0; |
01080f7c | 6047 | |
630a298c QY |
6048 | /* [<view|vrf> WORD] */ |
6049 | if (argv_find (argv, argc, "WORD", &idx)) | |
6050 | vrf = argv[idx]->arg; | |
0c7b1b01 | 6051 | |
630a298c | 6052 | prefix = argv[argc-1]->arg; |
8ad7271d | 6053 | |
630a298c | 6054 | return bgp_clear_prefix (vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 6055 | } |
8ad7271d | 6056 | |
b09b5ae0 DW |
6057 | DEFUN (clear_bgp_ipv6_safi_prefix, |
6058 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 6059 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 6060 | CLEAR_STR |
3a2d747c | 6061 | IP_STR |
718e3744 | 6062 | BGP_STR |
8c3deaae | 6063 | "Address Family\n" |
46f296b4 | 6064 | BGP_SAFI_HELP_STR |
b09b5ae0 | 6065 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 6066 | "IPv6 prefix\n") |
718e3744 | 6067 | { |
b09b5ae0 DW |
6068 | int idx_safi = 3; |
6069 | int idx_ipv6_prefixlen = 5; | |
46f296b4 LB |
6070 | return bgp_clear_prefix (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, |
6071 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), NULL); | |
838758ac | 6072 | } |
01080f7c | 6073 | |
b09b5ae0 DW |
6074 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
6075 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
46f296b4 | 6076 | "clear [ip] bgp <view|vrf> WORD ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 6077 | CLEAR_STR |
3a2d747c | 6078 | IP_STR |
718e3744 | 6079 | BGP_STR |
838758ac | 6080 | BGP_INSTANCE_HELP_STR |
8c3deaae | 6081 | "Address Family\n" |
46f296b4 | 6082 | BGP_SAFI_HELP_STR |
b09b5ae0 | 6083 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 6084 | "IPv6 prefix\n") |
718e3744 | 6085 | { |
b09b5ae0 | 6086 | int idx_word = 3; |
c500ae40 | 6087 | int idx_safi = 5; |
b09b5ae0 | 6088 | int idx_ipv6_prefixlen = 7; |
46f296b4 LB |
6089 | return bgp_clear_prefix (vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, |
6090 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), NULL); | |
718e3744 | 6091 | } |
6092 | ||
b09b5ae0 DW |
6093 | DEFUN (show_bgp_views, |
6094 | show_bgp_views_cmd, | |
d6e3c605 | 6095 | "show [ip] bgp views", |
b09b5ae0 | 6096 | SHOW_STR |
d6e3c605 | 6097 | IP_STR |
01080f7c | 6098 | BGP_STR |
b09b5ae0 | 6099 | "Show the defined BGP views\n") |
01080f7c | 6100 | { |
b09b5ae0 DW |
6101 | struct list *inst = bm->bgp; |
6102 | struct listnode *node; | |
6103 | struct bgp *bgp; | |
01080f7c | 6104 | |
b09b5ae0 DW |
6105 | if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE)) |
6106 | { | |
6107 | vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE); | |
6108 | return CMD_WARNING; | |
6109 | } | |
e52702f2 | 6110 | |
b09b5ae0 DW |
6111 | vty_out (vty, "Defined BGP views:%s", VTY_NEWLINE); |
6112 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) | |
6113 | { | |
6114 | /* Skip VRFs. */ | |
6115 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
6116 | continue; | |
6117 | vty_out (vty, "\t%s (AS%u)%s", | |
6118 | bgp->name ? bgp->name : "(null)", | |
6119 | bgp->as, VTY_NEWLINE); | |
6120 | } | |
e52702f2 | 6121 | |
b09b5ae0 | 6122 | return CMD_SUCCESS; |
e0081f70 ML |
6123 | } |
6124 | ||
8386ac43 | 6125 | DEFUN (show_bgp_vrfs, |
6126 | show_bgp_vrfs_cmd, | |
d6e3c605 | 6127 | "show [ip] bgp vrfs [json]", |
8386ac43 | 6128 | SHOW_STR |
d6e3c605 | 6129 | IP_STR |
8386ac43 | 6130 | BGP_STR |
6131 | "Show BGP VRFs\n" | |
9973d184 | 6132 | JSON_STR) |
8386ac43 | 6133 | { |
6134 | struct list *inst = bm->bgp; | |
6135 | struct listnode *node; | |
6136 | struct bgp *bgp; | |
6137 | u_char uj = use_json(argc, argv); | |
6138 | json_object *json = NULL; | |
6139 | json_object *json_vrfs = NULL; | |
6140 | int count = 0; | |
6141 | static char header[] = "Type Id RouterId #PeersCfg #PeersEstb Name"; | |
6142 | ||
6143 | if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE)) | |
6144 | { | |
6145 | vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE); | |
6146 | return CMD_WARNING; | |
6147 | } | |
6148 | ||
6149 | if (uj) | |
6150 | { | |
6151 | json = json_object_new_object(); | |
6152 | json_vrfs = json_object_new_object(); | |
6153 | } | |
6154 | ||
6155 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) | |
6156 | { | |
6157 | const char *name, *type; | |
6158 | struct peer *peer; | |
6159 | struct listnode *node, *nnode; | |
6160 | int peers_cfg, peers_estb; | |
6161 | json_object *json_vrf = NULL; | |
5c81a5f3 | 6162 | int vrf_id_ui; |
8386ac43 | 6163 | |
6164 | /* Skip Views. */ | |
6165 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
6166 | continue; | |
6167 | ||
6168 | count++; | |
6169 | if (!uj && count == 1) | |
6170 | vty_out (vty, "%s%s", header, VTY_NEWLINE); | |
6171 | ||
6172 | peers_cfg = peers_estb = 0; | |
6173 | if (uj) | |
6174 | json_vrf = json_object_new_object(); | |
6175 | ||
6176 | ||
6177 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
6178 | { | |
6179 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6180 | continue; | |
6181 | peers_cfg++; | |
6182 | if (peer->status == Established) | |
6183 | peers_estb++; | |
6184 | } | |
6185 | ||
6186 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
6187 | { | |
6188 | name = "Default"; | |
6189 | type = "DFLT"; | |
6190 | } | |
6191 | else | |
6192 | { | |
6193 | name = bgp->name; | |
6194 | type = "VRF"; | |
6195 | } | |
6196 | ||
5c81a5f3 | 6197 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id; |
8386ac43 | 6198 | if (uj) |
6199 | { | |
6200 | json_object_string_add(json_vrf, "type", type); | |
5c81a5f3 | 6201 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); |
8386ac43 | 6202 | json_object_string_add(json_vrf, "routerId", inet_ntoa (bgp->router_id)); |
6203 | json_object_int_add(json_vrf, "numConfiguredPeers", peers_cfg); | |
6204 | json_object_int_add(json_vrf, "numEstablishedPeers", peers_estb); | |
6205 | ||
6206 | json_object_object_add(json_vrfs, name, json_vrf); | |
6207 | } | |
6208 | else | |
5c81a5f3 | 6209 | vty_out (vty, "%4s %-5d %-16s %9u %10u %s%s", |
6210 | type, vrf_id_ui, inet_ntoa (bgp->router_id), | |
8386ac43 | 6211 | peers_cfg, peers_estb, name, |
6212 | VTY_NEWLINE); | |
6213 | } | |
6214 | ||
6215 | if (uj) | |
6216 | { | |
6217 | json_object_object_add(json, "vrfs", json_vrfs); | |
6218 | ||
6219 | json_object_int_add(json, "totalVrfs", count); | |
6220 | ||
2aac5767 | 6221 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
8386ac43 | 6222 | json_object_free(json); |
6223 | } | |
6224 | else | |
6225 | { | |
6226 | if (count) | |
6227 | vty_out (vty, "%sTotal number of VRFs (including default): %d%s", | |
6228 | VTY_NEWLINE, count, VTY_NEWLINE); | |
6229 | } | |
6230 | ||
6231 | return CMD_SUCCESS; | |
6232 | } | |
6233 | ||
f412b39a | 6234 | DEFUN (show_bgp_memory, |
4bf6a362 | 6235 | show_bgp_memory_cmd, |
7fa12b13 | 6236 | "show [ip] bgp memory", |
4bf6a362 | 6237 | SHOW_STR |
3a2d747c | 6238 | IP_STR |
4bf6a362 PJ |
6239 | BGP_STR |
6240 | "Global BGP memory statistics\n") | |
6241 | { | |
6242 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
6243 | unsigned long count; | |
e52702f2 | 6244 | |
4bf6a362 PJ |
6245 | /* RIB related usage stats */ |
6246 | count = mtype_stats_alloc (MTYPE_BGP_NODE); | |
6247 | vty_out (vty, "%ld RIB nodes, using %s of memory%s", count, | |
6248 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6249 | count * sizeof (struct bgp_node)), | |
6250 | VTY_NEWLINE); | |
e52702f2 | 6251 | |
4bf6a362 PJ |
6252 | count = mtype_stats_alloc (MTYPE_BGP_ROUTE); |
6253 | vty_out (vty, "%ld BGP routes, using %s of memory%s", count, | |
6254 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6255 | count * sizeof (struct bgp_info)), | |
6256 | VTY_NEWLINE); | |
fb982c25 PJ |
6257 | if ((count = mtype_stats_alloc (MTYPE_BGP_ROUTE_EXTRA))) |
6258 | vty_out (vty, "%ld BGP route ancillaries, using %s of memory%s", count, | |
6259 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6260 | count * sizeof (struct bgp_info_extra)), | |
6261 | VTY_NEWLINE); | |
e52702f2 | 6262 | |
4bf6a362 PJ |
6263 | if ((count = mtype_stats_alloc (MTYPE_BGP_STATIC))) |
6264 | vty_out (vty, "%ld Static routes, using %s of memory%s", count, | |
6265 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6266 | count * sizeof (struct bgp_static)), | |
6267 | VTY_NEWLINE); | |
3f9c7369 DS |
6268 | |
6269 | if ((count = mtype_stats_alloc (MTYPE_BGP_PACKET))) | |
6270 | vty_out (vty, "%ld Packets, using %s of memory%s", count, | |
6271 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6272 | count * sizeof (struct bpacket)), | |
6273 | VTY_NEWLINE); | |
e52702f2 | 6274 | |
4bf6a362 PJ |
6275 | /* Adj-In/Out */ |
6276 | if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_IN))) | |
6277 | vty_out (vty, "%ld Adj-In entries, using %s of memory%s", count, | |
6278 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6279 | count * sizeof (struct bgp_adj_in)), | |
6280 | VTY_NEWLINE); | |
6281 | if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_OUT))) | |
6282 | vty_out (vty, "%ld Adj-Out entries, using %s of memory%s", count, | |
6283 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6284 | count * sizeof (struct bgp_adj_out)), | |
6285 | VTY_NEWLINE); | |
e52702f2 | 6286 | |
4bf6a362 PJ |
6287 | if ((count = mtype_stats_alloc (MTYPE_BGP_NEXTHOP_CACHE))) |
6288 | vty_out (vty, "%ld Nexthop cache entries, using %s of memory%s", count, | |
6289 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6290 | count * sizeof (struct bgp_nexthop_cache)), | |
6291 | VTY_NEWLINE); | |
6292 | ||
6293 | if ((count = mtype_stats_alloc (MTYPE_BGP_DAMP_INFO))) | |
6294 | vty_out (vty, "%ld Dampening entries, using %s of memory%s", count, | |
6295 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6296 | count * sizeof (struct bgp_damp_info)), | |
6297 | VTY_NEWLINE); | |
6298 | ||
6299 | /* Attributes */ | |
6300 | count = attr_count(); | |
e52702f2 QY |
6301 | vty_out (vty, "%ld BGP attributes, using %s of memory%s", count, |
6302 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6303 | count * sizeof(struct attr)), | |
4bf6a362 | 6304 | VTY_NEWLINE); |
fb982c25 | 6305 | if ((count = mtype_stats_alloc (MTYPE_ATTR_EXTRA))) |
e52702f2 QY |
6306 | vty_out (vty, "%ld BGP extra attributes, using %s of memory%s", count, |
6307 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6308 | count * sizeof(struct attr_extra)), | |
fb982c25 | 6309 | VTY_NEWLINE); |
e52702f2 | 6310 | |
4bf6a362 PJ |
6311 | if ((count = attr_unknown_count())) |
6312 | vty_out (vty, "%ld unknown attributes%s", count, VTY_NEWLINE); | |
e52702f2 | 6313 | |
4bf6a362 PJ |
6314 | /* AS_PATH attributes */ |
6315 | count = aspath_count (); | |
6316 | vty_out (vty, "%ld BGP AS-PATH entries, using %s of memory%s", count, | |
6317 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6318 | count * sizeof (struct aspath)), | |
6319 | VTY_NEWLINE); | |
e52702f2 | 6320 | |
4bf6a362 PJ |
6321 | count = mtype_stats_alloc (MTYPE_AS_SEG); |
6322 | vty_out (vty, "%ld BGP AS-PATH segments, using %s of memory%s", count, | |
6323 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6324 | count * sizeof (struct assegment)), | |
6325 | VTY_NEWLINE); | |
e52702f2 | 6326 | |
4bf6a362 PJ |
6327 | /* Other attributes */ |
6328 | if ((count = community_count ())) | |
6329 | vty_out (vty, "%ld BGP community entries, using %s of memory%s", count, | |
6330 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6331 | count * sizeof (struct community)), | |
6332 | VTY_NEWLINE); | |
6333 | if ((count = mtype_stats_alloc (MTYPE_ECOMMUNITY))) | |
6334 | vty_out (vty, "%ld BGP community entries, using %s of memory%s", count, | |
6335 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6336 | count * sizeof (struct ecommunity)), | |
6337 | VTY_NEWLINE); | |
57d187bc JS |
6338 | if ((count = mtype_stats_alloc (MTYPE_LCOMMUNITY))) |
6339 | vty_out (vty, "%ld BGP large-community entries, using %s of memory%s", | |
2acb4ac2 | 6340 | count, |
57d187bc JS |
6341 | mtype_memstr (memstrbuf, sizeof (memstrbuf), |
6342 | count * sizeof (struct lcommunity)), | |
6343 | VTY_NEWLINE); | |
e52702f2 | 6344 | |
4bf6a362 PJ |
6345 | if ((count = mtype_stats_alloc (MTYPE_CLUSTER))) |
6346 | vty_out (vty, "%ld Cluster lists, using %s of memory%s", count, | |
6347 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6348 | count * sizeof (struct cluster_list)), | |
6349 | VTY_NEWLINE); | |
e52702f2 | 6350 | |
4bf6a362 PJ |
6351 | /* Peer related usage */ |
6352 | count = mtype_stats_alloc (MTYPE_BGP_PEER); | |
6353 | vty_out (vty, "%ld peers, using %s of memory%s", count, | |
6354 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6355 | count * sizeof (struct peer)), | |
6356 | VTY_NEWLINE); | |
e52702f2 | 6357 | |
4a1ab8e4 | 6358 | if ((count = mtype_stats_alloc (MTYPE_PEER_GROUP))) |
4bf6a362 PJ |
6359 | vty_out (vty, "%ld peer groups, using %s of memory%s", count, |
6360 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6361 | count * sizeof (struct peer_group)), | |
6362 | VTY_NEWLINE); | |
e52702f2 | 6363 | |
4bf6a362 PJ |
6364 | /* Other */ |
6365 | if ((count = mtype_stats_alloc (MTYPE_HASH))) | |
6366 | vty_out (vty, "%ld hash tables, using %s of memory%s", count, | |
6367 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6368 | count * sizeof (struct hash)), | |
6369 | VTY_NEWLINE); | |
6370 | if ((count = mtype_stats_alloc (MTYPE_HASH_BACKET))) | |
6371 | vty_out (vty, "%ld hash buckets, using %s of memory%s", count, | |
6372 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6373 | count * sizeof (struct hash_backet)), | |
6374 | VTY_NEWLINE); | |
6375 | if ((count = mtype_stats_alloc (MTYPE_BGP_REGEXP))) | |
6376 | vty_out (vty, "%ld compiled regexes, using %s of memory%s", count, | |
6377 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6378 | count * sizeof (regex_t)), | |
6379 | VTY_NEWLINE); | |
6380 | return CMD_SUCCESS; | |
6381 | } | |
fee0f4c6 | 6382 | |
718e3744 | 6383 | /* Show BGP peer's summary information. */ |
94f2b392 | 6384 | static int |
b05a1c8b | 6385 | bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi, |
9f689658 | 6386 | u_char use_json, json_object *json) |
718e3744 | 6387 | { |
6388 | struct peer *peer; | |
1eb8ef25 | 6389 | struct listnode *node, *nnode; |
f14e6fdb DS |
6390 | unsigned int count = 0, dn_count = 0; |
6391 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
f933309e DW |
6392 | char neighbor_buf[VTY_BUFSIZ]; |
6393 | int neighbor_col_default_width = 16; | |
718e3744 | 6394 | int len; |
f933309e | 6395 | int max_neighbor_width = 0; |
ffd0c037 DS |
6396 | json_object *json_peer = NULL; |
6397 | json_object *json_peers = NULL; | |
718e3744 | 6398 | |
b05a1c8b DS |
6399 | if (use_json) |
6400 | { | |
9f689658 DD |
6401 | if (json == NULL) |
6402 | json = json_object_new_object(); | |
6403 | ||
f1aa5d8a | 6404 | json_peers = json_object_new_object(); |
b05a1c8b | 6405 | } |
f933309e DW |
6406 | else |
6407 | { | |
6408 | /* Loop over all neighbors that will be displayed to determine how many | |
6409 | * characters are needed for the Neighbor column | |
6410 | */ | |
6411 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
6412 | { | |
6413 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6414 | continue; | |
6415 | ||
6416 | if (peer->afc[afi][safi]) | |
6417 | { | |
c9d5bd27 DS |
6418 | memset(dn_flag, '\0', sizeof(dn_flag)); |
6419 | if (peer_dynamic_neighbor(peer)) | |
6420 | dn_flag[0] = '*'; | |
6421 | ||
f933309e DW |
6422 | if (peer->hostname && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) |
6423 | sprintf(neighbor_buf, "%s%s(%s) ", dn_flag, peer->hostname, peer->host); | |
6424 | else | |
6425 | sprintf(neighbor_buf, "%s%s ", dn_flag, peer->host); | |
6426 | ||
6427 | len = strlen(neighbor_buf); | |
6428 | ||
6429 | if (len > max_neighbor_width) | |
6430 | max_neighbor_width = len; | |
6431 | } | |
6432 | } | |
6433 | ||
6434 | /* Originally we displayed the Neighbor column as 16 | |
6435 | * characters wide so make that the default | |
6436 | */ | |
6437 | if (max_neighbor_width < neighbor_col_default_width) | |
6438 | max_neighbor_width = neighbor_col_default_width; | |
6439 | } | |
b05a1c8b | 6440 | |
1eb8ef25 | 6441 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
718e3744 | 6442 | { |
1ff9a340 DS |
6443 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
6444 | continue; | |
6445 | ||
718e3744 | 6446 | if (peer->afc[afi][safi]) |
6447 | { | |
b05a1c8b | 6448 | if (!count) |
4bf6a362 PJ |
6449 | { |
6450 | unsigned long ents; | |
6451 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
5c81a5f3 | 6452 | int vrf_id_ui; |
6453 | ||
6454 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id; | |
b05a1c8b | 6455 | |
4bf6a362 | 6456 | /* Usage summary and header */ |
b05a1c8b DS |
6457 | if (use_json) |
6458 | { | |
62d6dca0 | 6459 | json_object_string_add(json, "routerId", inet_ntoa (bgp->router_id)); |
f1aa5d8a | 6460 | json_object_int_add(json, "as", bgp->as); |
9f689658 DD |
6461 | json_object_int_add(json, "vrfId", vrf_id_ui); |
6462 | json_object_string_add(json, "vrfName", | |
6463 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
6464 | ? "Default" : bgp->name); | |
b05a1c8b DS |
6465 | } |
6466 | else | |
6467 | { | |
6468 | vty_out (vty, | |
5c81a5f3 | 6469 | "BGP router identifier %s, local AS number %u vrf-id %d", |
6470 | inet_ntoa (bgp->router_id), bgp->as, vrf_id_ui); | |
6aeb9e78 | 6471 | vty_out (vty, "%s", VTY_NEWLINE); |
b05a1c8b DS |
6472 | } |
6473 | ||
f188f2c4 DS |
6474 | if (bgp_update_delay_configured(bgp)) |
6475 | { | |
b05a1c8b | 6476 | if (use_json) |
f188f2c4 | 6477 | { |
62d6dca0 | 6478 | json_object_int_add(json, "updateDelayLimit", bgp->v_update_delay); |
b05a1c8b DS |
6479 | |
6480 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
62d6dca0 | 6481 | json_object_int_add(json, "updateDelayEstablishWait", bgp->v_establish_wait); |
b05a1c8b DS |
6482 | |
6483 | if (bgp_update_delay_active(bgp)) | |
6484 | { | |
62d6dca0 DS |
6485 | json_object_string_add(json, "updateDelayFirstNeighbor", bgp->update_delay_begin_time); |
6486 | json_object_boolean_true_add(json, "updateDelayInProgress"); | |
b05a1c8b DS |
6487 | } |
6488 | else | |
6489 | { | |
6490 | if (bgp->update_delay_over) | |
6491 | { | |
62d6dca0 | 6492 | json_object_string_add(json, "updateDelayFirstNeighbor", |
f1aa5d8a | 6493 | bgp->update_delay_begin_time); |
62d6dca0 | 6494 | json_object_string_add(json, "updateDelayBestpathResumed", |
f1aa5d8a | 6495 | bgp->update_delay_end_time); |
62d6dca0 | 6496 | json_object_string_add(json, "updateDelayZebraUpdateResume", |
f1aa5d8a | 6497 | bgp->update_delay_zebra_resume_time); |
62d6dca0 | 6498 | json_object_string_add(json, "updateDelayPeerUpdateResume", |
f1aa5d8a | 6499 | bgp->update_delay_peers_resume_time); |
b05a1c8b DS |
6500 | } |
6501 | } | |
f188f2c4 DS |
6502 | } |
6503 | else | |
6504 | { | |
b05a1c8b DS |
6505 | vty_out (vty, "Read-only mode update-delay limit: %d seconds%s", |
6506 | bgp->v_update_delay, VTY_NEWLINE); | |
6507 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
6508 | vty_out (vty, " Establish wait: %d seconds%s", | |
6509 | bgp->v_establish_wait, VTY_NEWLINE); | |
6510 | ||
6511 | if (bgp_update_delay_active(bgp)) | |
f188f2c4 DS |
6512 | { |
6513 | vty_out (vty, " First neighbor established: %s%s", | |
6514 | bgp->update_delay_begin_time, VTY_NEWLINE); | |
b05a1c8b DS |
6515 | vty_out (vty, " Delay in progress%s", VTY_NEWLINE); |
6516 | } | |
6517 | else | |
6518 | { | |
6519 | if (bgp->update_delay_over) | |
6520 | { | |
6521 | vty_out (vty, " First neighbor established: %s%s", | |
6522 | bgp->update_delay_begin_time, VTY_NEWLINE); | |
6523 | vty_out (vty, " Best-paths resumed: %s%s", | |
6524 | bgp->update_delay_end_time, VTY_NEWLINE); | |
6525 | vty_out (vty, " zebra update resumed: %s%s", | |
6526 | bgp->update_delay_zebra_resume_time, VTY_NEWLINE); | |
6527 | vty_out (vty, " peers update resumed: %s%s", | |
6528 | bgp->update_delay_peers_resume_time, VTY_NEWLINE); | |
6529 | } | |
f188f2c4 DS |
6530 | } |
6531 | } | |
6532 | } | |
4bf6a362 | 6533 | |
b05a1c8b DS |
6534 | if (use_json) |
6535 | { | |
6536 | if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active) | |
62d6dca0 | 6537 | json_object_boolean_true_add(json, "maxMedOnStartup"); |
b05a1c8b | 6538 | if (bgp->v_maxmed_admin) |
62d6dca0 | 6539 | json_object_boolean_true_add(json, "maxMedAdministrative"); |
b05a1c8b | 6540 | |
62d6dca0 | 6541 | json_object_int_add(json, "tableVersion", bgp_table_version(bgp->rib[afi][safi])); |
b05a1c8b DS |
6542 | |
6543 | ents = bgp_table_count (bgp->rib[afi][safi]); | |
62d6dca0 DS |
6544 | json_object_int_add(json, "ribCount", ents); |
6545 | json_object_int_add(json, "ribMemory", ents * sizeof (struct bgp_node)); | |
b05a1c8b DS |
6546 | |
6547 | ents = listcount (bgp->peer); | |
62d6dca0 DS |
6548 | json_object_int_add(json, "peerCount", ents); |
6549 | json_object_int_add(json, "peerMemory", ents * sizeof (struct peer)); | |
b05a1c8b | 6550 | |
b05a1c8b DS |
6551 | if ((ents = listcount (bgp->group))) |
6552 | { | |
62d6dca0 DS |
6553 | json_object_int_add(json, "peerGroupCount", ents); |
6554 | json_object_int_add(json, "peerGroupMemory", ents * sizeof (struct peer_group)); | |
b05a1c8b | 6555 | } |
3f9c7369 | 6556 | |
b05a1c8b | 6557 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) |
62d6dca0 | 6558 | json_object_boolean_true_add(json, "dampeningEnabled"); |
b05a1c8b DS |
6559 | } |
6560 | else | |
6561 | { | |
6562 | if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active) | |
6563 | vty_out (vty, "Max-med on-startup active%s", VTY_NEWLINE); | |
6564 | if (bgp->v_maxmed_admin) | |
6565 | vty_out (vty, "Max-med administrative active%s", VTY_NEWLINE); | |
6566 | ||
ffd0c037 | 6567 | vty_out(vty, "BGP table version %" PRIu64 "%s", |
b05a1c8b DS |
6568 | bgp_table_version(bgp->rib[afi][safi]), VTY_NEWLINE); |
6569 | ||
6570 | ents = bgp_table_count (bgp->rib[afi][safi]); | |
6571 | vty_out (vty, "RIB entries %ld, using %s of memory%s", ents, | |
6572 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6573 | ents * sizeof (struct bgp_node)), | |
6574 | VTY_NEWLINE); | |
6575 | ||
6576 | /* Peer related usage */ | |
6577 | ents = listcount (bgp->peer); | |
6578 | vty_out (vty, "Peers %ld, using %s of memory%s", | |
6579 | ents, | |
6580 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6581 | ents * sizeof (struct peer)), | |
6582 | VTY_NEWLINE); | |
6583 | ||
b05a1c8b DS |
6584 | if ((ents = listcount (bgp->group))) |
6585 | vty_out (vty, "Peer groups %ld, using %s of memory%s", ents, | |
6586 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6587 | ents * sizeof (struct peer_group)), | |
6588 | VTY_NEWLINE); | |
6589 | ||
6590 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) | |
6591 | vty_out (vty, "Dampening enabled.%s", VTY_NEWLINE); | |
6592 | vty_out (vty, "%s", VTY_NEWLINE); | |
f933309e DW |
6593 | |
6594 | /* Subtract 8 here because 'Neighbor' is 8 characters */ | |
6595 | vty_out (vty, "Neighbor"); | |
6596 | vty_out (vty, "%*s", max_neighbor_width - 8, " "); | |
6597 | vty_out (vty, "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd%s", VTY_NEWLINE); | |
b05a1c8b | 6598 | } |
4bf6a362 | 6599 | } |
e52702f2 | 6600 | |
b05a1c8b | 6601 | count++; |
718e3744 | 6602 | |
b05a1c8b DS |
6603 | if (use_json) |
6604 | { | |
6605 | json_peer = json_object_new_object(); | |
f14e6fdb | 6606 | |
b05a1c8b | 6607 | if (peer_dynamic_neighbor(peer)) |
62d6dca0 | 6608 | json_object_boolean_true_add(json_peer, "dynamicPeer"); |
b05a1c8b | 6609 | |
04b6bdc0 DW |
6610 | if (peer->hostname) |
6611 | json_object_string_add(json_peer, "hostname", peer->hostname); | |
6612 | ||
6613 | if (peer->domainname) | |
6614 | json_object_string_add(json_peer, "domainname", peer->domainname); | |
6615 | ||
62d6dca0 | 6616 | json_object_int_add(json_peer, "remoteAs", peer->as); |
f1aa5d8a | 6617 | json_object_int_add(json_peer, "version", 4); |
62d6dca0 | 6618 | json_object_int_add(json_peer, "msgRcvd", |
f1aa5d8a DS |
6619 | peer->open_in + peer->update_in + peer->keepalive_in |
6620 | + peer->notify_in + peer->refresh_in | |
6621 | + peer->dynamic_cap_in); | |
62d6dca0 | 6622 | json_object_int_add(json_peer, "msgSent", |
f1aa5d8a DS |
6623 | peer->open_out + peer->update_out + peer->keepalive_out |
6624 | + peer->notify_out + peer->refresh_out | |
6625 | + peer->dynamic_cap_out); | |
6626 | ||
62d6dca0 | 6627 | json_object_int_add(json_peer, "tableVersion", peer->version[afi][safi]); |
f1aa5d8a DS |
6628 | json_object_int_add(json_peer, "outq", peer->obuf->count); |
6629 | json_object_int_add(json_peer, "inq", 0); | |
856ca177 | 6630 | peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, use_json, json_peer); |
62d6dca0 | 6631 | json_object_int_add(json_peer, "prefixReceivedCount", peer->pcount[afi][safi]); |
b05a1c8b DS |
6632 | |
6633 | if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) | |
f1aa5d8a | 6634 | json_object_string_add(json_peer, "state", "Idle (Admin)"); |
b05a1c8b | 6635 | else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) |
f1aa5d8a | 6636 | json_object_string_add(json_peer, "state", "Idle (PfxCt)"); |
b05a1c8b | 6637 | else |
f1aa5d8a | 6638 | json_object_string_add(json_peer, "state", LOOKUP(bgp_status_msg, peer->status)); |
b05a1c8b | 6639 | |
f1aa5d8a | 6640 | if (peer->conf_if) |
62d6dca0 | 6641 | json_object_string_add(json_peer, "idType", "interface"); |
f1aa5d8a | 6642 | else if (peer->su.sa.sa_family == AF_INET) |
62d6dca0 | 6643 | json_object_string_add(json_peer, "idType", "ipv4"); |
f1aa5d8a | 6644 | else if (peer->su.sa.sa_family == AF_INET6) |
62d6dca0 | 6645 | json_object_string_add(json_peer, "idType", "ipv6"); |
b05a1c8b | 6646 | |
f1aa5d8a | 6647 | json_object_object_add(json_peers, peer->host, json_peer); |
b05a1c8b DS |
6648 | } |
6649 | else | |
6650 | { | |
6651 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
6652 | if (peer_dynamic_neighbor(peer)) | |
6653 | { | |
6654 | dn_count++; | |
6655 | dn_flag[0] = '*'; | |
6656 | } | |
6657 | ||
04b6bdc0 DW |
6658 | if (peer->hostname && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) |
6659 | len = vty_out (vty, "%s%s(%s)", dn_flag, peer->hostname, | |
6660 | peer->host); | |
6661 | else | |
6662 | len = vty_out (vty, "%s%s", dn_flag, peer->host); | |
b05a1c8b | 6663 | |
f933309e DW |
6664 | /* pad the neighbor column with spaces */ |
6665 | if (len < max_neighbor_width) | |
6666 | vty_out (vty, "%*s", max_neighbor_width - len, " "); | |
b05a1c8b | 6667 | |
f933309e | 6668 | vty_out (vty, "4 %10u %7d %7d %8" PRIu64 " %4d %4zd %8s", |
b05a1c8b DS |
6669 | peer->as, |
6670 | peer->open_in + peer->update_in + peer->keepalive_in | |
6671 | + peer->notify_in + peer->refresh_in | |
6672 | + peer->dynamic_cap_in, | |
6673 | peer->open_out + peer->update_out + peer->keepalive_out | |
6674 | + peer->notify_out + peer->refresh_out | |
6675 | + peer->dynamic_cap_out, | |
6676 | peer->version[afi][safi], | |
6677 | 0, | |
f933309e | 6678 | peer->obuf->count, |
856ca177 | 6679 | peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL)); |
b05a1c8b DS |
6680 | |
6681 | if (peer->status == Established) | |
46f8c104 | 6682 | vty_out (vty, " %12ld", peer->pcount[afi][safi]); |
b05a1c8b DS |
6683 | else |
6684 | { | |
6685 | if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) | |
6686 | vty_out (vty, " Idle (Admin)"); | |
6687 | else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) | |
6688 | vty_out (vty, " Idle (PfxCt)"); | |
6689 | else | |
f933309e | 6690 | vty_out (vty, " %12s", LOOKUP(bgp_status_msg, peer->status)); |
b05a1c8b DS |
6691 | } |
6692 | vty_out (vty, "%s", VTY_NEWLINE); | |
6693 | } | |
718e3744 | 6694 | } |
6695 | } | |
6696 | ||
b05a1c8b DS |
6697 | if (use_json) |
6698 | { | |
6699 | json_object_object_add(json, "peers", json_peers); | |
14151a32 | 6700 | |
62d6dca0 DS |
6701 | json_object_int_add(json, "totalPeers", count); |
6702 | json_object_int_add(json, "dynamicPeers", dn_count); | |
14151a32 | 6703 | |
2aac5767 | 6704 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
f1aa5d8a | 6705 | json_object_free(json); |
b05a1c8b DS |
6706 | } |
6707 | else | |
f14e6fdb | 6708 | { |
b05a1c8b DS |
6709 | if (count) |
6710 | vty_out (vty, "%sTotal number of neighbors %d%s", VTY_NEWLINE, | |
6711 | count, VTY_NEWLINE); | |
6712 | else | |
9f689658 DD |
6713 | { |
6714 | if (use_json) | |
6715 | vty_out(vty, "{\"error\": {\"message\": \"No %s neighbor configured\"}}%s", | |
46f296b4 | 6716 | afi_safi_print(afi, safi), VTY_NEWLINE); |
9f689658 DD |
6717 | else |
6718 | vty_out (vty, "No %s neighbor is configured%s", | |
46f296b4 | 6719 | afi_safi_print(afi, safi), VTY_NEWLINE); |
9f689658 | 6720 | } |
b05a1c8b | 6721 | |
9f689658 | 6722 | if (dn_count && ! use_json) |
b05a1c8b DS |
6723 | { |
6724 | vty_out(vty, "* - dynamic neighbor%s", VTY_NEWLINE); | |
6725 | vty_out(vty, | |
6726 | "%d dynamic neighbor(s), limit %d%s", | |
6727 | dn_count, bgp->dynamic_neighbors_limit, VTY_NEWLINE); | |
6728 | } | |
f14e6fdb DS |
6729 | } |
6730 | ||
718e3744 | 6731 | return CMD_SUCCESS; |
6732 | } | |
6733 | ||
798c3572 DS |
6734 | /* |
6735 | * Return if we have a peer configured to use this afi/safi | |
6736 | */ | |
6737 | static int | |
6738 | bgp_show_summary_afi_safi_peer_exists (struct bgp *bgp, int afi, int safi) | |
6739 | { | |
6740 | struct listnode *node; | |
6741 | struct peer *peer; | |
6742 | ||
6743 | for (ALL_LIST_ELEMENTS_RO (bgp->peer, node, peer)) | |
6744 | { | |
6745 | if (!CHECK_FLAG (peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6746 | continue; | |
6747 | ||
6748 | if (peer->afc[afi][safi]) | |
6749 | return 1; | |
6750 | } | |
6751 | ||
6752 | return 0; | |
6753 | } | |
6754 | ||
27162734 LB |
6755 | static void |
6756 | bgp_show_summary_afi_safi (struct vty *vty, struct bgp *bgp, int afi, int safi, | |
6757 | u_char use_json, json_object *json) | |
6758 | { | |
6759 | int is_first = 1; | |
6760 | int afi_wildcard = (afi == AFI_MAX); | |
6761 | int safi_wildcard = (safi == SAFI_MAX); | |
6762 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
5ce77b2b | 6763 | bool json_output = false; |
798c3572 | 6764 | |
27162734 LB |
6765 | if (use_json && is_wildcard) |
6766 | vty_out (vty, "{%s", VTY_NEWLINE); | |
6767 | if (afi_wildcard) | |
6768 | afi = 1; /* AFI_IP */ | |
6769 | while (afi < AFI_MAX) | |
6770 | { | |
6771 | if (safi_wildcard) | |
6772 | safi = 1; /* SAFI_UNICAST */ | |
6773 | while (safi < SAFI_MAX) | |
6774 | { | |
798c3572 | 6775 | if (bgp_show_summary_afi_safi_peer_exists (bgp, afi, safi)) |
27162734 | 6776 | { |
5ce77b2b | 6777 | json_output = true; |
798c3572 | 6778 | if (is_wildcard) |
27162734 | 6779 | { |
798c3572 DS |
6780 | /* |
6781 | * So limit output to those afi/safi pairs that | |
6782 | * actualy have something interesting in them | |
6783 | */ | |
6784 | if (use_json) | |
6785 | { | |
6786 | json = json_object_new_object(); | |
27162734 | 6787 | |
798c3572 DS |
6788 | if (! is_first) |
6789 | vty_out (vty, ",%s", VTY_NEWLINE); | |
6790 | else | |
6791 | is_first = 0; | |
27162734 | 6792 | |
798c3572 DS |
6793 | vty_out(vty, "\"%s\":", afi_safi_json(afi, safi)); |
6794 | } | |
6795 | else | |
6796 | { | |
6797 | vty_out (vty, "%s%s Summary:%s", | |
6798 | VTY_NEWLINE, afi_safi_print(afi, safi), VTY_NEWLINE); | |
6799 | } | |
27162734 | 6800 | } |
798c3572 | 6801 | bgp_show_summary (vty, bgp, afi, safi, use_json, json); |
27162734 | 6802 | } |
f62a5c33 LB |
6803 | safi++; |
6804 | if (safi == SAFI_RESERVED_4 || | |
6805 | safi == SAFI_RESERVED_5) /* handle special cases to match zebra.h */ | |
6806 | safi++; | |
27162734 LB |
6807 | if (! safi_wildcard) |
6808 | safi = SAFI_MAX; | |
6809 | } | |
6810 | afi++; | |
6811 | if (! afi_wildcard || | |
5ef6cd69 | 6812 | afi == AFI_L2VPN) /* special case, not handled yet */ |
27162734 LB |
6813 | afi = AFI_MAX; |
6814 | } | |
6815 | ||
6816 | if (use_json && is_wildcard) | |
6817 | vty_out (vty, "}%s", VTY_NEWLINE); | |
5ce77b2b DS |
6818 | else if (use_json && !json_output) |
6819 | vty_out (vty, "{}%s", VTY_NEWLINE); | |
27162734 LB |
6820 | } |
6821 | ||
f186de26 | 6822 | static void |
6823 | bgp_show_all_instances_summary_vty (struct vty *vty, afi_t afi, safi_t safi, | |
6824 | u_char use_json) | |
6825 | { | |
6826 | struct listnode *node, *nnode; | |
6827 | struct bgp *bgp; | |
9f689658 DD |
6828 | json_object *json = NULL; |
6829 | int is_first = 1; | |
6830 | ||
6831 | if (use_json) | |
6832 | vty_out (vty, "{%s", VTY_NEWLINE); | |
f186de26 | 6833 | |
6834 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) | |
6835 | { | |
9f689658 DD |
6836 | if (use_json) |
6837 | { | |
4fb25c53 | 6838 | json = json_object_new_object(); |
9f689658 DD |
6839 | |
6840 | if (! is_first) | |
6841 | vty_out (vty, ",%s", VTY_NEWLINE); | |
6842 | else | |
6843 | is_first = 0; | |
6844 | ||
6845 | vty_out(vty, "\"%s\":", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
6846 | ? "Default" : bgp->name); | |
6847 | } | |
6848 | else | |
6849 | { | |
6850 | vty_out (vty, "%sInstance %s:%s", | |
6851 | VTY_NEWLINE, | |
6852 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
6853 | ? "Default" : bgp->name, VTY_NEWLINE); | |
6854 | } | |
27162734 | 6855 | bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, json); |
f186de26 | 6856 | } |
9f689658 DD |
6857 | |
6858 | if (use_json) | |
6859 | vty_out (vty, "}%s", VTY_NEWLINE); | |
6860 | ||
f186de26 | 6861 | } |
6862 | ||
4fb25c53 DW |
6863 | static int |
6864 | bgp_show_summary_vty (struct vty *vty, const char *name, | |
6865 | afi_t afi, safi_t safi, u_char use_json) | |
6866 | { | |
6867 | struct bgp *bgp; | |
6868 | ||
6869 | if (name) | |
6870 | { | |
6871 | if (strmatch(name, "all")) | |
6872 | { | |
6873 | bgp_show_all_instances_summary_vty (vty, afi, safi, use_json); | |
6874 | return CMD_SUCCESS; | |
6875 | } | |
6876 | else | |
6877 | { | |
6878 | bgp = bgp_lookup_by_name (name); | |
6879 | ||
6880 | if (! bgp) | |
6881 | { | |
6882 | if (use_json) | |
6883 | vty_out (vty, "{}%s", VTY_NEWLINE); | |
6884 | else | |
6885 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
6886 | return CMD_WARNING; | |
6887 | } | |
6888 | ||
27162734 | 6889 | bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, NULL); |
4fb25c53 DW |
6890 | return CMD_SUCCESS; |
6891 | } | |
6892 | } | |
6893 | ||
6894 | bgp = bgp_get_default (); | |
6895 | ||
6896 | if (bgp) | |
27162734 | 6897 | bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, NULL); |
4fb25c53 DW |
6898 | |
6899 | return CMD_SUCCESS; | |
6900 | } | |
6901 | ||
716b2d8a | 6902 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 6903 | DEFUN (show_ip_bgp_summary, |
718e3744 | 6904 | show_ip_bgp_summary_cmd, |
46f296b4 | 6905 | "show [ip] bgp [<view|vrf> WORD] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] summary [json]", |
718e3744 | 6906 | SHOW_STR |
6907 | IP_STR | |
6908 | BGP_STR | |
8386ac43 | 6909 | BGP_INSTANCE_HELP_STR |
46f296b4 LB |
6910 | BGP_AFI_HELP_STR |
6911 | BGP_SAFI_HELP_STR | |
b05a1c8b | 6912 | "Summary of BGP neighbor status\n" |
9973d184 | 6913 | JSON_STR) |
718e3744 | 6914 | { |
74ca3d33 | 6915 | char *vrf = NULL; |
27162734 LB |
6916 | afi_t afi = AFI_MAX; |
6917 | safi_t safi = SAFI_MAX; | |
ae19d7dd QY |
6918 | |
6919 | int idx = 0; | |
6920 | ||
6921 | /* show [ip] bgp */ | |
6922 | if (argv_find (argv, argc, "ip", &idx)) | |
6923 | afi = AFI_IP; | |
6924 | /* [<view|vrf> WORD] */ | |
6925 | if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) | |
6926 | vrf = argv[++idx]->arg; | |
46f296b4 LB |
6927 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
6928 | if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) | |
ae19d7dd | 6929 | { |
46f296b4 | 6930 | argv_find_and_parse_safi (argv, argc, &idx, &safi); |
91d37724 QY |
6931 | } |
6932 | ||
ae19d7dd | 6933 | int uj = use_json (argc, argv); |
74ca3d33 DW |
6934 | |
6935 | return bgp_show_summary_vty (vty, vrf, afi, safi, uj); | |
718e3744 | 6936 | } |
6937 | ||
fd79ac91 | 6938 | const char * |
538621f2 | 6939 | afi_safi_print (afi_t afi, safi_t safi) |
6940 | { | |
6941 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
6942 | return "IPv4 Unicast"; | |
6943 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
6944 | return "IPv4 Multicast"; | |
b60f5275 DS |
6945 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) |
6946 | return "IPv4 labeled-unicast"; | |
538621f2 | 6947 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) |
46f296b4 | 6948 | return "IPv4 VPN"; |
8b1fb8be | 6949 | else if (afi == AFI_IP && safi == SAFI_ENCAP) |
46f296b4 | 6950 | return "IPv4 Encap"; |
538621f2 | 6951 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
6952 | return "IPv6 Unicast"; | |
6953 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
6954 | return "IPv6 Multicast"; | |
b60f5275 DS |
6955 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) |
6956 | return "IPv6 labeled-unicast"; | |
945c8fe9 | 6957 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) |
46f296b4 | 6958 | return "IPv6 VPN"; |
8b1fb8be | 6959 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) |
46f296b4 | 6960 | return "IPv6 Encap"; |
3d6c0dfa PG |
6961 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) |
6962 | return "L2VPN EVPN"; | |
538621f2 | 6963 | else |
6964 | return "Unknown"; | |
6965 | } | |
6966 | ||
b9f77ec8 DS |
6967 | /* |
6968 | * Please note that we have intentionally camelCased | |
6969 | * the return strings here. So if you want | |
6970 | * to use this function, please ensure you | |
6971 | * are doing this within json output | |
6972 | */ | |
27162734 LB |
6973 | const char * |
6974 | afi_safi_json (afi_t afi, safi_t safi) | |
6975 | { | |
6976 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
b9f77ec8 | 6977 | return "ipv4Unicast"; |
27162734 | 6978 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) |
b9f77ec8 | 6979 | return "ipv4Multicast"; |
b60f5275 | 6980 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) |
05ba625a | 6981 | return "ipv4LabeledUnicast"; |
27162734 | 6982 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) |
b9f77ec8 | 6983 | return "ipv4Vpn"; |
27162734 | 6984 | else if (afi == AFI_IP && safi == SAFI_ENCAP) |
b9f77ec8 | 6985 | return "ipv4Encap"; |
27162734 | 6986 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
b9f77ec8 | 6987 | return "ipv6Unicast"; |
27162734 | 6988 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) |
b9f77ec8 | 6989 | return "ipv6Multicast"; |
b60f5275 | 6990 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) |
05ba625a | 6991 | return "ipv6LabeledUnicast"; |
27162734 | 6992 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) |
b9f77ec8 | 6993 | return "ipv6Vpn"; |
27162734 | 6994 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) |
b9f77ec8 | 6995 | return "ipv6Encap"; |
3d6c0dfa | 6996 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) |
b9f77ec8 | 6997 | return "l2VpnEvpn"; |
27162734 LB |
6998 | else |
6999 | return "Unknown"; | |
7000 | } | |
7001 | ||
718e3744 | 7002 | /* Show BGP peer's information. */ |
7003 | enum show_type | |
7004 | { | |
7005 | show_all, | |
7006 | show_peer | |
7007 | }; | |
7008 | ||
94f2b392 | 7009 | static void |
856ca177 MS |
7010 | bgp_show_peer_afi_orf_cap (struct vty *vty, struct peer *p, afi_t afi, safi_t safi, |
7011 | u_int16_t adv_smcap, u_int16_t adv_rmcap, u_int16_t rcv_smcap, | |
7012 | u_int16_t rcv_rmcap, u_char use_json, json_object *json_pref) | |
718e3744 | 7013 | { |
7014 | /* Send-Mode */ | |
7015 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) | |
7016 | || CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
7017 | { | |
856ca177 MS |
7018 | if (use_json) |
7019 | { | |
7020 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
7021 | json_object_string_add(json_pref, "sendMode", "advertisedAndReceived"); | |
7022 | else if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)) | |
7023 | json_object_string_add(json_pref, "sendMode", "advertised"); | |
7024 | else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
7025 | json_object_string_add(json_pref, "sendMode", "received"); | |
7026 | } | |
7027 | else | |
7028 | { | |
7029 | vty_out (vty, " Send-mode: "); | |
7030 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)) | |
7031 | vty_out (vty, "advertised"); | |
7032 | if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
7033 | vty_out (vty, "%sreceived", | |
7034 | CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) ? | |
7035 | ", " : ""); | |
7036 | vty_out (vty, "%s", VTY_NEWLINE); | |
7037 | } | |
718e3744 | 7038 | } |
7039 | ||
7040 | /* Receive-Mode */ | |
7041 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) | |
7042 | || CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
7043 | { | |
856ca177 MS |
7044 | if (use_json) |
7045 | { | |
7046 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
7047 | json_object_string_add(json_pref, "recvMode", "advertisedAndReceived"); | |
7048 | else if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)) | |
7049 | json_object_string_add(json_pref, "recvMode", "advertised"); | |
7050 | else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
7051 | json_object_string_add(json_pref, "recvMode", "received"); | |
7052 | } | |
7053 | else | |
7054 | { | |
7055 | vty_out (vty, " Receive-mode: "); | |
7056 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)) | |
7057 | vty_out (vty, "advertised"); | |
7058 | if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
7059 | vty_out (vty, "%sreceived", | |
7060 | CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) ? | |
7061 | ", " : ""); | |
7062 | vty_out (vty, "%s", VTY_NEWLINE); | |
7063 | } | |
718e3744 | 7064 | } |
7065 | } | |
7066 | ||
94f2b392 | 7067 | static void |
856ca177 MS |
7068 | bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi, |
7069 | u_char use_json, json_object *json_neigh) | |
718e3744 | 7070 | { |
7071 | struct bgp_filter *filter; | |
3f9c7369 | 7072 | struct peer_af *paf; |
718e3744 | 7073 | char orf_pfx_name[BUFSIZ]; |
7074 | int orf_pfx_count; | |
856ca177 MS |
7075 | json_object *json_af = NULL; |
7076 | json_object *json_prefA = NULL; | |
7077 | json_object *json_prefB = NULL; | |
7078 | json_object *json_addr = NULL; | |
718e3744 | 7079 | |
856ca177 MS |
7080 | if (use_json) |
7081 | { | |
7082 | json_addr = json_object_new_object(); | |
7083 | json_af = json_object_new_object(); | |
856ca177 | 7084 | filter = &p->filter[afi][safi]; |
718e3744 | 7085 | |
c8560b44 | 7086 | if (peer_group_active(p)) |
856ca177 | 7087 | json_object_string_add(json_addr, "peerGroupMember", p->group->name); |
538621f2 | 7088 | |
856ca177 MS |
7089 | paf = peer_af_find(p, afi, safi); |
7090 | if (paf && PAF_SUBGRP(paf)) | |
7091 | { | |
7092 | json_object_int_add(json_addr, "updateGroupId", PAF_UPDGRP(paf)->id); | |
7093 | json_object_int_add(json_addr, "subGroupId", PAF_SUBGRP(paf)->id); | |
7094 | json_object_int_add(json_addr, "packetQueueLength", bpacket_queue_virtual_length(paf)); | |
7095 | } | |
7096 | ||
7097 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7098 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
7099 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7100 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)) | |
7101 | { | |
7102 | json_object_int_add(json_af, "orfType", ORF_TYPE_PREFIX); | |
b6df4090 | 7103 | json_prefA = json_object_new_object(); |
856ca177 MS |
7104 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, |
7105 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
7106 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7107 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
7108 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, json_prefA); | |
7109 | json_object_object_add(json_af, "orfPrefixList", json_prefA); | |
7110 | } | |
7111 | ||
7112 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7113 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7114 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7115 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7116 | { | |
7117 | json_object_int_add(json_af, "orfOldType", ORF_TYPE_PREFIX_OLD); | |
b6df4090 | 7118 | json_prefB = json_object_new_object(); |
856ca177 MS |
7119 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, |
7120 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
7121 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7122 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
7123 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, json_prefB); | |
7124 | json_object_object_add(json_af, "orfOldPrefixList", json_prefB); | |
7125 | } | |
7126 | ||
7127 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7128 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
7129 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7130 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7131 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV) | |
7132 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7133 | json_object_object_add(json_addr, "afDependentCap", json_af); | |
b6df4090 DS |
7134 | else |
7135 | json_object_free(json_af); | |
856ca177 MS |
7136 | |
7137 | sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
7138 | orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json); | |
7139 | ||
7140 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND) | |
7141 | || orf_pfx_count) | |
7142 | { | |
7143 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)) | |
7144 | json_object_boolean_true_add(json_neigh, "orfSent"); | |
7145 | if (orf_pfx_count) | |
7146 | json_object_int_add(json_addr, "orfRecvCounter", orf_pfx_count); | |
7147 | } | |
7148 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) | |
7149 | json_object_string_add(json_addr, "orfFirstUpdate", "deferredUntilORFOrRouteRefreshRecvd"); | |
7150 | ||
7151 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) | |
7152 | json_object_boolean_true_add(json_addr, "routeReflectorClient"); | |
7153 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
7154 | json_object_boolean_true_add(json_addr, "routeServerClient"); | |
7155 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
7156 | json_object_boolean_true_add(json_addr, "inboundSoftConfigPermit"); | |
7157 | ||
88b8ed8d DW |
7158 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) |
7159 | json_object_boolean_true_add(json_addr, "privateAsNumsAllReplacedInUpdatesToNbr"); | |
7160 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
856ca177 | 7161 | json_object_boolean_true_add(json_addr, "privateAsNumsReplacedInUpdatesToNbr"); |
88b8ed8d DW |
7162 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) |
7163 | json_object_boolean_true_add(json_addr, "privateAsNumsAllRemovedInUpdatesToNbr"); | |
856ca177 MS |
7164 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS)) |
7165 | json_object_boolean_true_add(json_addr, "privateAsNumsRemovedInUpdatesToNbr"); | |
7166 | ||
adbac85e DW |
7167 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS)) |
7168 | json_object_boolean_true_add(json_addr, "addpathTxAllPaths"); | |
7169 | ||
06370dac DW |
7170 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) |
7171 | json_object_boolean_true_add(json_addr, "addpathTxBestpathPerAS"); | |
7172 | ||
856ca177 MS |
7173 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) |
7174 | json_object_string_add(json_addr, "overrideASNsInOutboundUpdates", "ifAspathEqualRemoteAs"); | |
7175 | ||
7176 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) || | |
7177 | CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
7178 | json_object_boolean_true_add(json_addr, "routerAlwaysNextHop"); | |
7179 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED)) | |
7180 | json_object_boolean_true_add(json_addr, "unchangedAsPathPropogatedToNbr"); | |
7181 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)) | |
7182 | json_object_boolean_true_add(json_addr, "unchangedNextHopPropogatedToNbr"); | |
7183 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
7184 | json_object_boolean_true_add(json_addr, "unchangedMedPropogatedToNbr"); | |
718e3744 | 7185 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) |
856ca177 MS |
7186 | || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) |
7187 | { | |
7188 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
7189 | && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7190 | json_object_string_add(json_addr, "commAttriSentToNbr", "extendedAndStandard"); | |
7191 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7192 | json_object_string_add(json_addr, "commAttriSentToNbr", "extended"); | |
7193 | else | |
7194 | json_object_string_add(json_addr, "commAttriSentToNbr", "standard"); | |
7195 | } | |
7196 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) | |
7197 | { | |
7198 | if (p->default_rmap[afi][safi].name) | |
7199 | json_object_string_add(json_addr, "defaultRouteMap", p->default_rmap[afi][safi].name); | |
7200 | ||
7201 | if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
7202 | json_object_boolean_true_add(json_addr, "defaultSent"); | |
7203 | else | |
7204 | json_object_boolean_true_add(json_addr, "defaultNotSent"); | |
7205 | } | |
7206 | ||
7207 | if (filter->plist[FILTER_IN].name | |
7208 | || filter->dlist[FILTER_IN].name | |
7209 | || filter->aslist[FILTER_IN].name | |
7210 | || filter->map[RMAP_IN].name) | |
7211 | json_object_boolean_true_add(json_addr, "inboundPathPolicyConfig"); | |
7212 | if (filter->plist[FILTER_OUT].name | |
7213 | || filter->dlist[FILTER_OUT].name | |
7214 | || filter->aslist[FILTER_OUT].name | |
7215 | || filter->map[RMAP_OUT].name | |
7216 | || filter->usmap.name) | |
7217 | json_object_boolean_true_add(json_addr, "outboundPathPolicyConfig"); | |
856ca177 MS |
7218 | |
7219 | /* prefix-list */ | |
7220 | if (filter->plist[FILTER_IN].name) | |
7221 | json_object_string_add(json_addr, "incomingUpdatePrefixFilterList", filter->plist[FILTER_IN].name); | |
7222 | if (filter->plist[FILTER_OUT].name) | |
7223 | json_object_string_add(json_addr, "outgoingUpdatePrefixFilterList", filter->plist[FILTER_OUT].name); | |
7224 | ||
7225 | /* distribute-list */ | |
7226 | if (filter->dlist[FILTER_IN].name) | |
7227 | json_object_string_add(json_addr, "incomingUpdateNetworkFilterList", filter->dlist[FILTER_IN].name); | |
7228 | if (filter->dlist[FILTER_OUT].name) | |
7229 | json_object_string_add(json_addr, "outgoingUpdateNetworkFilterList", filter->dlist[FILTER_OUT].name); | |
7230 | ||
7231 | /* filter-list. */ | |
7232 | if (filter->aslist[FILTER_IN].name) | |
7233 | json_object_string_add(json_addr, "incomingUpdateAsPathFilterList", filter->aslist[FILTER_IN].name); | |
7234 | if (filter->aslist[FILTER_OUT].name) | |
7235 | json_object_string_add(json_addr, "outgoingUpdateAsPathFilterList", filter->aslist[FILTER_OUT].name); | |
7236 | ||
7237 | /* route-map. */ | |
7238 | if (filter->map[RMAP_IN].name) | |
7239 | json_object_string_add(json_addr, "routeMapForIncomingAdvertisements", filter->map[RMAP_IN].name); | |
7240 | if (filter->map[RMAP_OUT].name) | |
7241 | json_object_string_add(json_addr, "routeMapForOutgoingAdvertisements", filter->map[RMAP_OUT].name); | |
856ca177 MS |
7242 | |
7243 | /* unsuppress-map */ | |
7244 | if (filter->usmap.name) | |
7245 | json_object_string_add(json_addr, "selectiveUnsuppressRouteMap", filter->usmap.name); | |
7246 | ||
7247 | /* Receive prefix count */ | |
7248 | json_object_int_add(json_addr, "acceptedPrefixCounter", p->pcount[afi][safi]); | |
7249 | ||
7250 | /* Maximum prefix */ | |
7251 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) | |
7252 | { | |
7253 | json_object_int_add(json_addr, "prefixAllowedMax", p->pmax[afi][safi]); | |
7254 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) | |
7255 | json_object_boolean_true_add(json_addr, "prefixAllowedMaxWarning"); | |
7256 | json_object_int_add(json_addr, "prefixAllowedWarningThresh", p->pmax_threshold[afi][safi]); | |
7257 | if (p->pmax_restart[afi][safi]) | |
7258 | json_object_int_add(json_addr, "prefixAllowedRestartIntervalMsecs", p->pmax_restart[afi][safi] * 60000); | |
7259 | } | |
7260 | json_object_object_add(json_neigh, afi_safi_print (afi, safi), json_addr); | |
7261 | ||
7262 | } | |
7263 | else | |
7264 | { | |
7265 | filter = &p->filter[afi][safi]; | |
7266 | ||
7267 | vty_out (vty, " For address family: %s%s", afi_safi_print (afi, safi), | |
7268 | VTY_NEWLINE); | |
7269 | ||
c8560b44 | 7270 | if (peer_group_active(p)) |
856ca177 MS |
7271 | vty_out (vty, " %s peer-group member%s", p->group->name, VTY_NEWLINE); |
7272 | ||
7273 | paf = peer_af_find(p, afi, safi); | |
7274 | if (paf && PAF_SUBGRP(paf)) | |
7275 | { | |
7276 | vty_out (vty, " Update group %" PRIu64 ", subgroup %" PRIu64 "%s", | |
7277 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id, VTY_NEWLINE); | |
7278 | vty_out (vty, " Packet Queue length %d%s", | |
7279 | bpacket_queue_virtual_length(paf), VTY_NEWLINE); | |
7280 | } | |
718e3744 | 7281 | else |
856ca177 MS |
7282 | { |
7283 | vty_out(vty, " Not part of any update group%s", VTY_NEWLINE); | |
7284 | } | |
7285 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7286 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
7287 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7288 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7289 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV) | |
7290 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7291 | vty_out (vty, " AF-dependant capabilities:%s", VTY_NEWLINE); | |
7292 | ||
7293 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7294 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
7295 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7296 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)) | |
7297 | { | |
7298 | vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s", | |
7299 | ORF_TYPE_PREFIX, VTY_NEWLINE); | |
7300 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, | |
7301 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
7302 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7303 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
7304 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
7305 | } | |
7306 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7307 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7308 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7309 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7310 | { | |
7311 | vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s", | |
7312 | ORF_TYPE_PREFIX_OLD, VTY_NEWLINE); | |
7313 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, | |
7314 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
7315 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7316 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
7317 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
7318 | } | |
718e3744 | 7319 | |
856ca177 MS |
7320 | sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi); |
7321 | orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json); | |
718e3744 | 7322 | |
856ca177 MS |
7323 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND) |
7324 | || orf_pfx_count) | |
7325 | { | |
7326 | vty_out (vty, " Outbound Route Filter (ORF):"); | |
7327 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)) | |
7328 | vty_out (vty, " sent;"); | |
7329 | if (orf_pfx_count) | |
7330 | vty_out (vty, " received (%d entries)", orf_pfx_count); | |
7331 | vty_out (vty, "%s", VTY_NEWLINE); | |
7332 | } | |
7333 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) | |
7334 | vty_out (vty, " First update is deferred until ORF or ROUTE-REFRESH is received%s", VTY_NEWLINE); | |
7335 | ||
7336 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) | |
7337 | vty_out (vty, " Route-Reflector Client%s", VTY_NEWLINE); | |
7338 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
7339 | vty_out (vty, " Route-Server Client%s", VTY_NEWLINE); | |
7340 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
7341 | vty_out (vty, " Inbound soft reconfiguration allowed%s", VTY_NEWLINE); | |
7342 | ||
88b8ed8d DW |
7343 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) |
7344 | vty_out (vty, " Private AS numbers (all) replaced in updates to this neighbor%s", VTY_NEWLINE); | |
7345 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
856ca177 | 7346 | vty_out (vty, " Private AS numbers replaced in updates to this neighbor%s", VTY_NEWLINE); |
88b8ed8d DW |
7347 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) |
7348 | vty_out (vty, " Private AS numbers (all) removed in updates to this neighbor%s", VTY_NEWLINE); | |
856ca177 MS |
7349 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS)) |
7350 | vty_out (vty, " Private AS numbers removed in updates to this neighbor%s", VTY_NEWLINE); | |
7351 | ||
adbac85e DW |
7352 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS)) |
7353 | vty_out (vty, " Advertise all paths via addpath%s", VTY_NEWLINE); | |
7354 | ||
06370dac DW |
7355 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) |
7356 | vty_out (vty, " Advertise bestpath per AS via addpath%s", VTY_NEWLINE); | |
7357 | ||
856ca177 MS |
7358 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) |
7359 | vty_out (vty, " Override ASNs in outbound updates if aspath equals remote-as%s", VTY_NEWLINE); | |
7360 | ||
7361 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) || | |
7362 | CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
7363 | vty_out (vty, " NEXT_HOP is always this router%s", VTY_NEWLINE); | |
7364 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED)) | |
7365 | vty_out (vty, " AS_PATH is propagated unchanged to this neighbor%s", VTY_NEWLINE); | |
7366 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)) | |
7367 | vty_out (vty, " NEXT_HOP is propagated unchanged to this neighbor%s", VTY_NEWLINE); | |
7368 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
7369 | vty_out (vty, " MED is propagated unchanged to this neighbor%s", VTY_NEWLINE); | |
7370 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
57d187bc JS |
7371 | || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY) |
7372 | || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
856ca177 MS |
7373 | { |
7374 | vty_out (vty, " Community attribute sent to this neighbor"); | |
7375 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
57d187bc JS |
7376 | && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY) |
7377 | && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
7378 | vty_out (vty, "(all)%s", VTY_NEWLINE); | |
7379 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
7380 | vty_out (vty, "(large)%s", VTY_NEWLINE); | |
856ca177 MS |
7381 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) |
7382 | vty_out (vty, "(extended)%s", VTY_NEWLINE); | |
7383 | else | |
7384 | vty_out (vty, "(standard)%s", VTY_NEWLINE); | |
7385 | } | |
7386 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) | |
7387 | { | |
7388 | vty_out (vty, " Default information originate,"); | |
7389 | ||
7390 | if (p->default_rmap[afi][safi].name) | |
7391 | vty_out (vty, " default route-map %s%s,", | |
7392 | p->default_rmap[afi][safi].map ? "*" : "", | |
7393 | p->default_rmap[afi][safi].name); | |
7394 | if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
7395 | vty_out (vty, " default sent%s", VTY_NEWLINE); | |
7396 | else | |
7397 | vty_out (vty, " default not sent%s", VTY_NEWLINE); | |
7398 | } | |
718e3744 | 7399 | |
856ca177 MS |
7400 | if (filter->plist[FILTER_IN].name |
7401 | || filter->dlist[FILTER_IN].name | |
7402 | || filter->aslist[FILTER_IN].name | |
7403 | || filter->map[RMAP_IN].name) | |
7404 | vty_out (vty, " Inbound path policy configured%s", VTY_NEWLINE); | |
7405 | if (filter->plist[FILTER_OUT].name | |
7406 | || filter->dlist[FILTER_OUT].name | |
7407 | || filter->aslist[FILTER_OUT].name | |
7408 | || filter->map[RMAP_OUT].name | |
7409 | || filter->usmap.name) | |
7410 | vty_out (vty, " Outbound path policy configured%s", VTY_NEWLINE); | |
856ca177 MS |
7411 | |
7412 | /* prefix-list */ | |
7413 | if (filter->plist[FILTER_IN].name) | |
7414 | vty_out (vty, " Incoming update prefix filter list is %s%s%s", | |
7415 | filter->plist[FILTER_IN].plist ? "*" : "", | |
7416 | filter->plist[FILTER_IN].name, | |
7417 | VTY_NEWLINE); | |
7418 | if (filter->plist[FILTER_OUT].name) | |
7419 | vty_out (vty, " Outgoing update prefix filter list is %s%s%s", | |
7420 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
7421 | filter->plist[FILTER_OUT].name, | |
7422 | VTY_NEWLINE); | |
7423 | ||
7424 | /* distribute-list */ | |
7425 | if (filter->dlist[FILTER_IN].name) | |
7426 | vty_out (vty, " Incoming update network filter list is %s%s%s", | |
7427 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
7428 | filter->dlist[FILTER_IN].name, | |
7429 | VTY_NEWLINE); | |
7430 | if (filter->dlist[FILTER_OUT].name) | |
7431 | vty_out (vty, " Outgoing update network filter list is %s%s%s", | |
7432 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
7433 | filter->dlist[FILTER_OUT].name, | |
7434 | VTY_NEWLINE); | |
7435 | ||
7436 | /* filter-list. */ | |
7437 | if (filter->aslist[FILTER_IN].name) | |
7438 | vty_out (vty, " Incoming update AS path filter list is %s%s%s", | |
7439 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
7440 | filter->aslist[FILTER_IN].name, | |
7441 | VTY_NEWLINE); | |
7442 | if (filter->aslist[FILTER_OUT].name) | |
7443 | vty_out (vty, " Outgoing update AS path filter list is %s%s%s", | |
7444 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
7445 | filter->aslist[FILTER_OUT].name, | |
7446 | VTY_NEWLINE); | |
7447 | ||
7448 | /* route-map. */ | |
7449 | if (filter->map[RMAP_IN].name) | |
7450 | vty_out (vty, " Route map for incoming advertisements is %s%s%s", | |
7451 | filter->map[RMAP_IN].map ? "*" : "", | |
7452 | filter->map[RMAP_IN].name, | |
7453 | VTY_NEWLINE); | |
7454 | if (filter->map[RMAP_OUT].name) | |
7455 | vty_out (vty, " Route map for outgoing advertisements is %s%s%s", | |
7456 | filter->map[RMAP_OUT].map ? "*" : "", | |
7457 | filter->map[RMAP_OUT].name, | |
7458 | VTY_NEWLINE); | |
856ca177 MS |
7459 | |
7460 | /* unsuppress-map */ | |
7461 | if (filter->usmap.name) | |
7462 | vty_out (vty, " Route map for selective unsuppress is %s%s%s", | |
7463 | filter->usmap.map ? "*" : "", | |
7464 | filter->usmap.name, VTY_NEWLINE); | |
7465 | ||
7466 | /* Receive prefix count */ | |
7467 | vty_out (vty, " %ld accepted prefixes%s", p->pcount[afi][safi], VTY_NEWLINE); | |
7468 | ||
7469 | /* Maximum prefix */ | |
7470 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) | |
7471 | { | |
7472 | vty_out (vty, " Maximum prefixes allowed %ld%s%s", p->pmax[afi][safi], | |
7473 | CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING) | |
7474 | ? " (warning-only)" : "", VTY_NEWLINE); | |
7475 | vty_out (vty, " Threshold for warning message %d%%", | |
7476 | p->pmax_threshold[afi][safi]); | |
7477 | if (p->pmax_restart[afi][safi]) | |
7478 | vty_out (vty, ", restart interval %d min", p->pmax_restart[afi][safi]); | |
7479 | vty_out (vty, "%s", VTY_NEWLINE); | |
7480 | } | |
718e3744 | 7481 | |
0a486e5f | 7482 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 7483 | } |
718e3744 | 7484 | } |
7485 | ||
94f2b392 | 7486 | static void |
e8f7da3a | 7487 | bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *json) |
718e3744 | 7488 | { |
7489 | struct bgp *bgp; | |
4690c7d7 | 7490 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; |
718e3744 | 7491 | char timebuf[BGP_UPTIME_LEN]; |
f14e6fdb | 7492 | char dn_flag[2]; |
3a8c7ba1 DW |
7493 | const char *subcode_str; |
7494 | const char *code_str; | |
538621f2 | 7495 | afi_t afi; |
7496 | safi_t safi; | |
d6661008 DS |
7497 | u_int16_t i; |
7498 | u_char *msg; | |
e8f7da3a | 7499 | json_object *json_neigh = NULL; |
718e3744 | 7500 | |
7501 | bgp = p->bgp; | |
7502 | ||
e8f7da3a DW |
7503 | if (use_json) |
7504 | json_neigh = json_object_new_object(); | |
7505 | ||
517cd68a DS |
7506 | memset (dn_flag, '\0', sizeof (dn_flag)); |
7507 | if (!p->conf_if && peer_dynamic_neighbor (p)) | |
7508 | dn_flag[0] = '*'; | |
7509 | ||
856ca177 | 7510 | if (!use_json) |
f14e6fdb | 7511 | { |
856ca177 MS |
7512 | if (p->conf_if) /* Configured interface name. */ |
7513 | vty_out (vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
7514 | BGP_PEER_SU_UNSPEC(p) ? "None" : | |
7515 | sockunion2str (&p->su, buf, SU_ADDRSTRLEN)); | |
7516 | else /* Configured IP address. */ | |
74ef1672 | 7517 | vty_out (vty, "BGP neighbor is %s%s, ", dn_flag, p->host); |
f14e6fdb DS |
7518 | } |
7519 | ||
856ca177 MS |
7520 | if (use_json) |
7521 | { | |
7522 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
7523 | json_object_string_add(json_neigh, "bgpNeighborAddr", "none"); | |
7524 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
7525 | json_object_string_add(json_neigh, "bgpNeighborAddr", sockunion2str (&p->su, buf, SU_ADDRSTRLEN)); | |
7526 | ||
7527 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
7528 | ||
7529 | if (p->change_local_as) | |
7530 | json_object_int_add(json_neigh, "localAs", p->change_local_as); | |
7531 | else | |
7532 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
7533 | ||
7534 | if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
7535 | json_object_boolean_true_add(json_neigh, "localAsNoPrepend"); | |
66b199b2 | 7536 | |
856ca177 MS |
7537 | if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) |
7538 | json_object_boolean_true_add(json_neigh, "localAsReplaceAs"); | |
7539 | } | |
7540 | else | |
7541 | { | |
f8cfafda DS |
7542 | if ((p->as_type == AS_SPECIFIED) || |
7543 | (p->as_type == AS_EXTERNAL) || | |
7544 | (p->as_type == AS_INTERNAL)) | |
7545 | vty_out (vty, "remote AS %u, ", p->as); | |
7546 | else | |
7547 | vty_out (vty, "remote AS Unspecified, "); | |
856ca177 MS |
7548 | vty_out (vty, "local AS %u%s%s, ", |
7549 | p->change_local_as ? p->change_local_as : p->local_as, | |
7550 | CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ? | |
7551 | " no-prepend" : "", | |
7552 | CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) ? | |
7553 | " replace-as" : ""); | |
7554 | } | |
66b199b2 DS |
7555 | /* peer type internal, external, confed-internal or confed-external */ |
7556 | if (p->as == p->local_as) | |
7557 | { | |
856ca177 MS |
7558 | if (use_json) |
7559 | { | |
7560 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
7561 | json_object_boolean_true_add(json_neigh, "nbrConfedInternalLink"); | |
7562 | else | |
7563 | json_object_boolean_true_add(json_neigh, "nbrInternalLink"); | |
7564 | } | |
66b199b2 | 7565 | else |
856ca177 MS |
7566 | { |
7567 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
7568 | vty_out (vty, "confed-internal link%s", VTY_NEWLINE); | |
7569 | else | |
7570 | vty_out (vty, "internal link%s", VTY_NEWLINE); | |
7571 | } | |
66b199b2 DS |
7572 | } |
7573 | else | |
7574 | { | |
856ca177 MS |
7575 | if (use_json) |
7576 | { | |
7577 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
7578 | json_object_boolean_true_add(json_neigh, "nbrConfedExternalLink"); | |
7579 | else | |
7580 | json_object_boolean_true_add(json_neigh, "nbrExternalLink"); | |
7581 | } | |
66b199b2 | 7582 | else |
856ca177 MS |
7583 | { |
7584 | if (bgp_confederation_peers_check(bgp, p->as)) | |
7585 | vty_out (vty, "confed-external link%s", VTY_NEWLINE); | |
7586 | else | |
7587 | vty_out (vty, "external link%s", VTY_NEWLINE); | |
7588 | } | |
66b199b2 | 7589 | } |
718e3744 | 7590 | |
7591 | /* Description. */ | |
7592 | if (p->desc) | |
856ca177 MS |
7593 | { |
7594 | if (use_json) | |
7595 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
7596 | else | |
7597 | vty_out (vty, " Description: %s%s", p->desc, VTY_NEWLINE); | |
7598 | } | |
6410e93a | 7599 | |
04b6bdc0 DW |
7600 | if (p->hostname) |
7601 | { | |
d1570739 DW |
7602 | if (use_json) |
7603 | { | |
7604 | if (p->hostname) | |
7605 | json_object_string_add(json_neigh, "hostname", p->hostname); | |
7606 | ||
7607 | if (p->domainname) | |
7608 | json_object_string_add(json_neigh, "domainname", p->domainname); | |
7609 | } | |
04b6bdc0 | 7610 | else |
d1570739 DW |
7611 | { |
7612 | if (p->domainname && (p->domainname[0] != '\0')) | |
7613 | vty_out(vty, "Hostname: %s.%s%s", p->hostname, p->domainname, | |
7614 | VTY_NEWLINE); | |
7615 | else | |
7616 | vty_out(vty, "Hostname: %s%s", p->hostname, VTY_NEWLINE); | |
7617 | } | |
7618 | ||
04b6bdc0 DW |
7619 | } |
7620 | ||
c744aa9f | 7621 | /* Peer-group */ |
718e3744 | 7622 | if (p->group) |
f14e6fdb | 7623 | { |
856ca177 MS |
7624 | if (use_json) |
7625 | { | |
7626 | json_object_string_add(json_neigh, "peerGroup", p->group->name); | |
7627 | ||
7628 | if (dn_flag[0]) | |
7629 | { | |
40ee54a7 | 7630 | struct prefix prefix, *range = NULL; |
f14e6fdb | 7631 | |
40ee54a7 TT |
7632 | sockunion2hostprefix(&(p->su), &prefix); |
7633 | range = peer_group_lookup_dynamic_neighbor_range (p->group, &prefix); | |
856ca177 MS |
7634 | |
7635 | if (range) | |
7636 | { | |
7637 | prefix2str(range, buf1, sizeof(buf1)); | |
7638 | json_object_string_add(json_neigh, "peerSubnetRangeGroup", buf1); | |
7639 | } | |
7640 | } | |
7641 | } | |
7642 | else | |
f14e6fdb | 7643 | { |
856ca177 MS |
7644 | vty_out (vty, " Member of peer-group %s for session parameters%s", |
7645 | p->group->name, VTY_NEWLINE); | |
f14e6fdb | 7646 | |
856ca177 | 7647 | if (dn_flag[0]) |
f14e6fdb | 7648 | { |
40ee54a7 | 7649 | struct prefix prefix, *range = NULL; |
856ca177 | 7650 | |
40ee54a7 TT |
7651 | sockunion2hostprefix(&(p->su), &prefix); |
7652 | range = peer_group_lookup_dynamic_neighbor_range (p->group, &prefix); | |
856ca177 MS |
7653 | |
7654 | if (range) | |
7655 | { | |
7656 | prefix2str(range, buf1, sizeof(buf1)); | |
7657 | vty_out (vty, " Belongs to the subnet range group: %s%s", buf1, VTY_NEWLINE); | |
7658 | } | |
f14e6fdb DS |
7659 | } |
7660 | } | |
7661 | } | |
718e3744 | 7662 | |
856ca177 MS |
7663 | if (use_json) |
7664 | { | |
7665 | /* Administrative shutdown. */ | |
7666 | if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN)) | |
7667 | json_object_boolean_true_add(json_neigh, "adminShutDown"); | |
718e3744 | 7668 | |
856ca177 MS |
7669 | /* BGP Version. */ |
7670 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
389e3fe0 | 7671 | json_object_string_add(json_neigh, "remoteRouterId", |
44b8cd53 | 7672 | inet_ntop (AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
718e3744 | 7673 | |
856ca177 MS |
7674 | /* Confederation */ |
7675 | if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION) && bgp_confederation_peers_check (bgp, p->as)) | |
7676 | json_object_boolean_true_add(json_neigh, "nbrCommonAdmin"); | |
7677 | ||
7678 | /* Status. */ | |
7679 | json_object_string_add(json_neigh, "bgpState", LOOKUP (bgp_status_msg, p->status)); | |
7680 | ||
7681 | if (p->status == Established) | |
7682 | { | |
7683 | time_t uptime; | |
7684 | struct tm *tm; | |
7685 | ||
7686 | uptime = bgp_clock(); | |
7687 | uptime -= p->uptime; | |
7688 | tm = gmtime(&uptime); | |
7689 | ||
7690 | json_object_int_add(json_neigh, "bgpTimerUp", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); | |
7691 | } | |
7692 | ||
7693 | else if (p->status == Active) | |
7694 | { | |
7695 | if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE)) | |
7696 | json_object_string_add(json_neigh, "bgpStateIs", "passive"); | |
7697 | else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT)) | |
7698 | json_object_string_add(json_neigh, "bgpStateIs", "passiveNSF"); | |
7699 | } | |
7700 | ||
7701 | /* read timer */ | |
7702 | time_t uptime; | |
7703 | struct tm *tm; | |
7704 | ||
7705 | uptime = bgp_clock(); | |
7706 | uptime -= p->readtime; | |
7707 | tm = gmtime(&uptime); | |
7708 | json_object_int_add(json_neigh, "bgpTimerLastRead", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); | |
7709 | ||
7710 | uptime = bgp_clock(); | |
7711 | uptime -= p->last_write; | |
7712 | tm = gmtime(&uptime); | |
39e871e6 ST |
7713 | json_object_int_add(json_neigh, "bgpTimerLastWrite", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); |
7714 | ||
7715 | uptime = bgp_clock(); | |
7716 | uptime -= p->update_time; | |
7717 | tm = gmtime(&uptime); | |
7718 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", | |
7719 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); | |
856ca177 MS |
7720 | |
7721 | /* Configured timer values. */ | |
7722 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", p->v_holdtime * 1000); | |
7723 | json_object_int_add(json_neigh, "bgpTimerKeepAliveIntervalMsecs", p->v_keepalive * 1000); | |
7724 | ||
7725 | if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER)) | |
7726 | { | |
7727 | json_object_int_add(json_neigh, "bgpTimerConfiguredHoldTimeMsecs", p->holdtime * 1000); | |
7728 | json_object_int_add(json_neigh, "bgpTimerConfiguredKeepAliveIntervalMsecs", p->keepalive * 1000); | |
7729 | } | |
93406d87 | 7730 | } |
856ca177 MS |
7731 | else |
7732 | { | |
7733 | /* Administrative shutdown. */ | |
7734 | if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN)) | |
7735 | vty_out (vty, " Administratively shut down%s", VTY_NEWLINE); | |
7736 | ||
7737 | /* BGP Version. */ | |
7738 | vty_out (vty, " BGP version 4"); | |
389e3fe0 | 7739 | vty_out (vty, ", remote router ID %s%s", |
44b8cd53 | 7740 | inet_ntop (AF_INET, &p->remote_id, buf1, sizeof(buf1)), |
856ca177 MS |
7741 | VTY_NEWLINE); |
7742 | ||
7743 | /* Confederation */ | |
7744 | if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION) | |
7745 | && bgp_confederation_peers_check (bgp, p->as)) | |
7746 | vty_out (vty, " Neighbor under common administration%s", VTY_NEWLINE); | |
e52702f2 | 7747 | |
856ca177 MS |
7748 | /* Status. */ |
7749 | vty_out (vty, " BGP state = %s", LOOKUP (bgp_status_msg, p->status)); | |
718e3744 | 7750 | |
856ca177 MS |
7751 | if (p->status == Established) |
7752 | vty_out (vty, ", up for %8s", peer_uptime (p->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL)); | |
7753 | ||
7754 | else if (p->status == Active) | |
7755 | { | |
7756 | if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE)) | |
7757 | vty_out (vty, " (passive)"); | |
7758 | else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT)) | |
7759 | vty_out (vty, " (NSF passive)"); | |
7760 | } | |
7761 | vty_out (vty, "%s", VTY_NEWLINE); | |
93406d87 | 7762 | |
856ca177 MS |
7763 | /* read timer */ |
7764 | vty_out (vty, " Last read %s", peer_uptime (p->readtime, timebuf, BGP_UPTIME_LEN, 0, NULL)); | |
7765 | vty_out (vty, ", Last write %s%s", | |
7766 | peer_uptime (p->last_write, timebuf, BGP_UPTIME_LEN, 0, NULL), VTY_NEWLINE); | |
7767 | ||
7768 | /* Configured timer values. */ | |
7769 | vty_out (vty, " Hold time is %d, keepalive interval is %d seconds%s", | |
7770 | p->v_holdtime, p->v_keepalive, VTY_NEWLINE); | |
7771 | if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER)) | |
7772 | { | |
7773 | vty_out (vty, " Configured hold time is %d", p->holdtime); | |
7774 | vty_out (vty, ", keepalive interval is %d seconds%s", | |
7775 | p->keepalive, VTY_NEWLINE); | |
7776 | } | |
7777 | } | |
718e3744 | 7778 | /* Capability. */ |
e52702f2 | 7779 | if (p->status == Established) |
718e3744 | 7780 | { |
538621f2 | 7781 | if (p->cap |
718e3744 | 7782 | || p->afc_adv[AFI_IP][SAFI_UNICAST] |
7783 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
7784 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
7785 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
718e3744 | 7786 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] |
7787 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
7788 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
7789 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
945c8fe9 LB |
7790 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] |
7791 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
8b1fb8be LB |
7792 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] |
7793 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
8b1fb8be LB |
7794 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
7795 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
718e3744 | 7796 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
7797 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) | |
7798 | { | |
856ca177 MS |
7799 | if (use_json) |
7800 | { | |
7801 | json_object *json_cap = NULL; | |
7802 | ||
7803 | json_cap = json_object_new_object(); | |
7804 | ||
7805 | /* AS4 */ | |
7806 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV) | |
7807 | || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
7808 | { | |
7809 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) && CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)) | |
7810 | json_object_string_add(json_cap, "4byteAs", "advertisedAndReceived"); | |
7811 | else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
7812 | json_object_string_add(json_cap, "4byteAs", "advertised"); | |
7813 | else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)) | |
7814 | json_object_string_add(json_cap, "4byteAs", "received"); | |
7815 | } | |
7816 | ||
7817 | /* AddPath */ | |
7818 | if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV) | |
7819 | || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV)) | |
7820 | { | |
7821 | json_object *json_add = NULL; | |
7822 | const char *print_store; | |
718e3744 | 7823 | |
856ca177 | 7824 | json_add = json_object_new_object(); |
a82478b9 | 7825 | |
856ca177 MS |
7826 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) |
7827 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7828 | { | |
7829 | json_object *json_sub = NULL; | |
7830 | json_sub = json_object_new_object(); | |
7831 | print_store = afi_safi_print (afi, safi); | |
7832 | ||
7833 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) || | |
7834 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) | |
7835 | { | |
7836 | 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)) | |
7837 | json_object_boolean_true_add(json_sub, "txAdvertisedAndReceived"); | |
7838 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV)) | |
7839 | json_object_boolean_true_add(json_sub, "txAdvertised"); | |
7840 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) | |
7841 | json_object_boolean_true_add(json_sub, "txReceived"); | |
7842 | } | |
7843 | ||
7844 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) || | |
7845 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) | |
7846 | { | |
7847 | 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)) | |
7848 | json_object_boolean_true_add(json_sub, "rxAdvertisedAndReceived"); | |
7849 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV)) | |
7850 | json_object_boolean_true_add(json_sub, "rxAdvertised"); | |
7851 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) | |
7852 | json_object_boolean_true_add(json_sub, "rxReceived"); | |
7853 | } | |
7854 | ||
7855 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) || | |
7856 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV) || | |
7857 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) || | |
7858 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) | |
7859 | json_object_object_add(json_add, print_store, json_sub); | |
b6df4090 DS |
7860 | else |
7861 | json_object_free(json_sub); | |
856ca177 | 7862 | } |
a82478b9 | 7863 | |
856ca177 MS |
7864 | json_object_object_add(json_cap, "addPath", json_add); |
7865 | } | |
7866 | ||
7867 | /* Dynamic */ | |
7868 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV) | |
7869 | || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
7870 | { | |
7871 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) && CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)) | |
7872 | json_object_string_add(json_cap, "dynamic", "advertisedAndReceived"); | |
7873 | else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
7874 | json_object_string_add(json_cap, "dynamic", "advertised"); | |
7875 | else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)) | |
7876 | json_object_string_add(json_cap, "dynamic", "received"); | |
7877 | } | |
7878 | ||
7879 | /* Extended nexthop */ | |
7880 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV) | |
7881 | || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
7882 | { | |
7883 | json_object *json_nxt = NULL; | |
7884 | const char *print_store; | |
7885 | ||
856ca177 MS |
7886 | |
7887 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) && CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
7888 | json_object_string_add(json_cap, "extendedNexthop", "advertisedAndReceived"); | |
7889 | else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
7890 | json_object_string_add(json_cap, "extendedNexthop", "advertised"); | |
7891 | else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
7892 | json_object_string_add(json_cap, "extendedNexthop", "received"); | |
7893 | ||
7894 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
7895 | { | |
b6df4090 DS |
7896 | json_nxt = json_object_new_object(); |
7897 | ||
856ca177 MS |
7898 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) |
7899 | { | |
7900 | if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV)) | |
7901 | { | |
7902 | print_store = afi_safi_print (AFI_IP, safi); | |
7903 | json_object_string_add(json_nxt, print_store, "recieved"); | |
7904 | } | |
7905 | } | |
7906 | json_object_object_add(json_cap, "extendedNexthopFamililesByPeer", json_nxt); | |
7907 | } | |
7908 | } | |
7909 | ||
7910 | /* Route Refresh */ | |
7911 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) | |
7912 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) | |
7913 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
7914 | { | |
7915 | 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))) | |
7916 | { | |
7917 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) | |
7918 | json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOldNew"); | |
7919 | else | |
7920 | { | |
7921 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
7922 | json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOld"); | |
7923 | else | |
7924 | json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedNew"); | |
7925 | } | |
7926 | } | |
7927 | else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)) | |
7928 | json_object_string_add(json_cap, "routeRefresh", "advertised"); | |
7929 | else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
7930 | json_object_string_add(json_cap, "routeRefresh", "received"); | |
7931 | } | |
7932 | ||
7933 | /* Multiprotocol Extensions */ | |
7934 | json_object *json_multi = NULL; | |
7935 | json_multi = json_object_new_object(); | |
7936 | ||
7937 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7938 | { | |
7939 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7940 | { | |
7941 | if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi]) | |
7942 | { | |
7943 | json_object *json_exten = NULL; | |
7944 | json_exten = json_object_new_object(); | |
7945 | ||
7946 | if (p->afc_adv[afi][safi] && p->afc_recv[afi][safi]) | |
7947 | json_object_boolean_true_add(json_exten, "advertisedAndReceived"); | |
7948 | else if (p->afc_adv[afi][safi]) | |
7949 | json_object_boolean_true_add(json_exten, "advertised"); | |
7950 | else if (p->afc_recv[afi][safi]) | |
7951 | json_object_boolean_true_add(json_exten, "received"); | |
7952 | ||
7953 | json_object_object_add(json_multi, afi_safi_print (afi, safi), json_exten); | |
7954 | } | |
7955 | } | |
7956 | } | |
7957 | json_object_object_add(json_cap, "multiprotocolExtensions", json_multi); | |
7958 | ||
7959 | /* Gracefull Restart */ | |
7960 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV) | |
7961 | || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
7962 | { | |
7963 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) && CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) | |
7964 | json_object_string_add(json_cap, "gracefulRestart", "advertisedAndReceived"); | |
7965 | else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
7966 | json_object_string_add(json_cap, "gracefulRestartCapability", "advertised"); | |
7967 | else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) | |
7968 | json_object_string_add(json_cap, "gracefulRestartCapability", "received"); | |
7969 | ||
7970 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) | |
7971 | { | |
7972 | int restart_af_count = 0; | |
7973 | json_object *json_restart = NULL; | |
7974 | json_restart = json_object_new_object(); | |
7975 | ||
7976 | json_object_int_add(json_cap, "gracefulRestartRemoteTimerMsecs", p->v_gr_restart * 1000); | |
7977 | ||
7978 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7979 | { | |
7980 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7981 | { | |
7982 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV)) | |
7983 | { | |
7984 | json_object *json_sub = NULL; | |
7985 | json_sub = json_object_new_object(); | |
7986 | ||
7987 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV)) | |
7988 | json_object_boolean_true_add(json_sub, "preserved"); | |
7989 | restart_af_count++; | |
7990 | json_object_object_add(json_restart, afi_safi_print (afi, safi), json_sub); | |
7991 | } | |
7992 | } | |
7993 | } | |
7994 | if (! restart_af_count) | |
b6df4090 | 7995 | { |
856ca177 | 7996 | json_object_string_add(json_cap, "addressFamiliesByPeer", "none"); |
b6df4090 DS |
7997 | json_object_free(json_restart); |
7998 | } | |
856ca177 MS |
7999 | else |
8000 | json_object_object_add(json_cap, "addressFamiliesByPeer", json_restart); | |
8001 | } | |
8002 | } | |
8003 | json_object_object_add(json_neigh, "neighborCapabilities", json_cap); | |
8004 | } | |
8005 | else | |
8006 | { | |
8007 | vty_out (vty, " Neighbor capabilities:%s", VTY_NEWLINE); | |
8008 | ||
8009 | /* AS4 */ | |
8010 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV) | |
8011 | || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
8012 | { | |
8013 | vty_out (vty, " 4 Byte AS:"); | |
8014 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
8015 | vty_out (vty, " advertised"); | |
8016 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)) | |
8017 | vty_out (vty, " %sreceived", | |
8018 | CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) ? "and " : ""); | |
8019 | vty_out (vty, "%s", VTY_NEWLINE); | |
8020 | } | |
8021 | ||
8022 | /* AddPath */ | |
8023 | if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV) | |
8024 | || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV)) | |
8025 | { | |
8026 | vty_out (vty, " AddPath:%s", VTY_NEWLINE); | |
a82478b9 | 8027 | |
856ca177 MS |
8028 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) |
8029 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
a82478b9 | 8030 | { |
856ca177 MS |
8031 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) || |
8032 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) | |
8033 | { | |
8034 | vty_out (vty, " %s: TX ", afi_safi_print (afi, safi)); | |
a82478b9 | 8035 | |
856ca177 MS |
8036 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV)) |
8037 | vty_out (vty, "advertised %s", afi_safi_print (afi, safi)); | |
a82478b9 | 8038 | |
856ca177 MS |
8039 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) |
8040 | vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ? " and " : "" ); | |
a82478b9 | 8041 | |
856ca177 MS |
8042 | vty_out (vty, "%s", VTY_NEWLINE); |
8043 | } | |
a82478b9 | 8044 | |
856ca177 | 8045 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) || |
a82478b9 | 8046 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) |
856ca177 MS |
8047 | { |
8048 | vty_out (vty, " %s: RX ", afi_safi_print (afi, safi)); | |
a82478b9 | 8049 | |
856ca177 MS |
8050 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV)) |
8051 | vty_out (vty, "advertised %s", afi_safi_print (afi, safi)); | |
a82478b9 | 8052 | |
856ca177 MS |
8053 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) |
8054 | vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ? " and " : "" ); | |
a82478b9 | 8055 | |
856ca177 MS |
8056 | vty_out (vty, "%s", VTY_NEWLINE); |
8057 | } | |
a82478b9 | 8058 | } |
856ca177 | 8059 | } |
a82478b9 | 8060 | |
856ca177 MS |
8061 | /* Dynamic */ |
8062 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV) | |
8063 | || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
8064 | { | |
8065 | vty_out (vty, " Dynamic:"); | |
8066 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
8067 | vty_out (vty, " advertised"); | |
8068 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)) | |
8069 | vty_out (vty, " %sreceived", | |
8070 | CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) ? "and " : ""); | |
8071 | vty_out (vty, "%s", VTY_NEWLINE); | |
8072 | } | |
8073 | ||
8074 | /* Extended nexthop */ | |
8075 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV) | |
8076 | || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
8077 | { | |
8078 | vty_out (vty, " Extended nexthop:"); | |
8079 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
8080 | vty_out (vty, " advertised"); | |
8081 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
8082 | vty_out (vty, " %sreceived", | |
8083 | CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) ? "and " : ""); | |
8084 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 8085 | |
856ca177 MS |
8086 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) |
8087 | { | |
8088 | vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE); | |
8089 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8090 | if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV)) | |
8091 | vty_out (vty, " %s%s", | |
8092 | afi_safi_print (AFI_IP, safi), VTY_NEWLINE); | |
8093 | } | |
8094 | } | |
8a92a8a0 | 8095 | |
856ca177 MS |
8096 | /* Route Refresh */ |
8097 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) | |
8098 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) | |
8099 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
8100 | { | |
8101 | vty_out (vty, " Route refresh:"); | |
8102 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)) | |
8103 | vty_out (vty, " advertised"); | |
8104 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) | |
8105 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
8106 | vty_out (vty, " %sreceived(%s)", | |
8107 | CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) ? "and " : "", | |
8108 | (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) | |
8109 | && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) ? | |
8110 | "old & new" : CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) ? "old" : "new"); | |
8a92a8a0 | 8111 | |
856ca177 MS |
8112 | vty_out (vty, "%s", VTY_NEWLINE); |
8113 | } | |
718e3744 | 8114 | |
856ca177 MS |
8115 | /* Multiprotocol Extensions */ |
8116 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8117 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8118 | if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi]) | |
8119 | { | |
8c3deaae | 8120 | vty_out (vty, " Address Family %s:", afi_safi_print (afi, safi)); |
856ca177 MS |
8121 | if (p->afc_adv[afi][safi]) |
8122 | vty_out (vty, " advertised"); | |
8123 | if (p->afc_recv[afi][safi]) | |
8124 | vty_out (vty, " %sreceived", p->afc_adv[afi][safi] ? "and " : ""); | |
8125 | vty_out (vty, "%s", VTY_NEWLINE); | |
8126 | } | |
538621f2 | 8127 | |
04b6bdc0 DW |
8128 | /* Hostname capability */ |
8129 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV) || | |
8130 | CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) | |
8131 | { | |
8132 | vty_out (vty, " Hostname Capability:"); | |
8133 | if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV)) | |
8134 | vty_out (vty, " advertised"); | |
8135 | if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_RCV)) | |
8136 | vty_out (vty, " %sreceived", | |
8137 | CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV) ? "and " : ""); | |
8138 | vty_out (vty, "%s", VTY_NEWLINE); | |
8139 | } | |
8140 | ||
856ca177 MS |
8141 | /* Gracefull Restart */ |
8142 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV) | |
8143 | || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
8144 | { | |
8145 | vty_out (vty, " Graceful Restart Capabilty:"); | |
8146 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
538621f2 | 8147 | vty_out (vty, " advertised"); |
856ca177 MS |
8148 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) |
8149 | vty_out (vty, " %sreceived", | |
8150 | CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) ? "and " : ""); | |
8151 | vty_out (vty, "%s", VTY_NEWLINE); | |
538621f2 | 8152 | |
856ca177 MS |
8153 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) |
8154 | { | |
8155 | int restart_af_count = 0; | |
8156 | ||
8157 | vty_out (vty, " Remote Restart timer is %d seconds%s", | |
8158 | p->v_gr_restart, VTY_NEWLINE); | |
8159 | vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE); | |
8160 | ||
8161 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8162 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8163 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV)) | |
8164 | { | |
8165 | vty_out (vty, "%s%s(%s)", restart_af_count ? ", " : "", | |
8166 | afi_safi_print (afi, safi), | |
8167 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV) ? | |
8168 | "preserved" : "not preserved"); | |
8169 | restart_af_count++; | |
8170 | } | |
8171 | if (! restart_af_count) | |
8172 | vty_out (vty, "none"); | |
8173 | vty_out (vty, "%s", VTY_NEWLINE); | |
8174 | } | |
8175 | } | |
8176 | } | |
718e3744 | 8177 | } |
8178 | } | |
8179 | ||
93406d87 | 8180 | /* graceful restart information */ |
8181 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV) | |
8182 | || p->t_gr_restart | |
8183 | || p->t_gr_stale) | |
8184 | { | |
856ca177 MS |
8185 | json_object *json_grace = NULL; |
8186 | json_object *json_grace_send = NULL; | |
8187 | json_object *json_grace_recv = NULL; | |
93406d87 | 8188 | int eor_send_af_count = 0; |
8189 | int eor_receive_af_count = 0; | |
8190 | ||
856ca177 MS |
8191 | if (use_json) |
8192 | { | |
8193 | json_grace = json_object_new_object(); | |
8194 | json_grace_send = json_object_new_object(); | |
8195 | json_grace_recv = json_object_new_object(); | |
8196 | ||
8197 | if (p->status == Established) | |
8198 | { | |
8199 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8200 | { | |
8201 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8202 | { | |
8203 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND)) | |
8204 | { | |
8205 | json_object_boolean_true_add(json_grace_send, afi_safi_print (afi, safi)); | |
8206 | eor_send_af_count++; | |
8207 | } | |
8208 | } | |
8209 | } | |
8210 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8211 | { | |
8212 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8213 | { | |
8214 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED)) | |
8215 | { | |
8216 | json_object_boolean_true_add(json_grace_recv, afi_safi_print (afi, safi)); | |
8217 | eor_receive_af_count++; | |
8218 | } | |
8219 | } | |
8220 | } | |
8221 | } | |
8222 | ||
8223 | json_object_object_add(json_grace, "endOfRibSend", json_grace_send); | |
8224 | json_object_object_add(json_grace, "endOfRibRecv", json_grace_recv); | |
8225 | ||
8226 | if (p->t_gr_restart) | |
8227 | json_object_int_add(json_grace, "gracefulRestartTimerMsecs", thread_timer_remain_second (p->t_gr_restart) * 1000); | |
8228 | ||
8229 | if (p->t_gr_stale) | |
8230 | json_object_int_add(json_grace, "gracefulStalepathTimerMsecs", thread_timer_remain_second (p->t_gr_stale) * 1000); | |
8231 | ||
8232 | json_object_object_add(json_neigh, "gracefulRestartInfo", json_grace); | |
8233 | } | |
8234 | else | |
8235 | { | |
8236 | vty_out (vty, " Graceful restart informations:%s", VTY_NEWLINE); | |
8237 | if (p->status == Established) | |
8238 | { | |
8239 | vty_out (vty, " End-of-RIB send: "); | |
8240 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8241 | { | |
8242 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8243 | { | |
8244 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND)) | |
8245 | { | |
8246 | vty_out (vty, "%s%s", eor_send_af_count ? ", " : "", | |
8247 | afi_safi_print (afi, safi)); | |
8248 | eor_send_af_count++; | |
8249 | } | |
8250 | } | |
8251 | } | |
8252 | vty_out (vty, "%s", VTY_NEWLINE); | |
8253 | vty_out (vty, " End-of-RIB received: "); | |
8254 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8255 | { | |
8256 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8257 | { | |
8258 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED)) | |
8259 | { | |
8260 | vty_out (vty, "%s%s", eor_receive_af_count ? ", " : "", | |
8261 | afi_safi_print (afi, safi)); | |
8262 | eor_receive_af_count++; | |
8263 | } | |
8264 | } | |
8265 | } | |
8266 | vty_out (vty, "%s", VTY_NEWLINE); | |
8267 | } | |
93406d87 | 8268 | |
856ca177 MS |
8269 | if (p->t_gr_restart) |
8270 | vty_out (vty, " The remaining time of restart timer is %ld%s", | |
8271 | thread_timer_remain_second (p->t_gr_restart), VTY_NEWLINE); | |
e52702f2 | 8272 | |
856ca177 MS |
8273 | if (p->t_gr_stale) |
8274 | vty_out (vty, " The remaining time of stalepath timer is %ld%s", | |
8275 | thread_timer_remain_second (p->t_gr_stale), VTY_NEWLINE); | |
8276 | } | |
8277 | } | |
8278 | if (use_json) | |
8279 | { | |
8280 | json_object *json_stat = NULL; | |
8281 | json_stat = json_object_new_object(); | |
8282 | /* Packet counts. */ | |
8283 | json_object_int_add(json_stat, "depthInq", 0); | |
8284 | json_object_int_add(json_stat, "depthOutq", (unsigned long) p->obuf->count); | |
8285 | json_object_int_add(json_stat, "opensSent", p->open_out); | |
8286 | json_object_int_add(json_stat, "opensRecv", p->open_in); | |
8287 | json_object_int_add(json_stat, "notificationsSent", p->notify_out); | |
8288 | json_object_int_add(json_stat, "notificationsRecv", p->notify_in); | |
8289 | json_object_int_add(json_stat, "updatesSent", p->update_out); | |
8290 | json_object_int_add(json_stat, "updatesRecv", p->update_in); | |
8291 | json_object_int_add(json_stat, "keepalivesSent", p->keepalive_out); | |
8292 | json_object_int_add(json_stat, "keepalivesRecv", p->keepalive_in); | |
8293 | json_object_int_add(json_stat, "routeRefreshSent", p->refresh_out); | |
8294 | json_object_int_add(json_stat, "routeRefreshRecv", p->refresh_in); | |
8295 | json_object_int_add(json_stat, "capabilitySent", p->dynamic_cap_out); | |
8296 | json_object_int_add(json_stat, "capabilityRecv", p->dynamic_cap_in); | |
8297 | 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); | |
8298 | 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); | |
8299 | json_object_object_add(json_neigh, "messageStats", json_stat); | |
8300 | } | |
8301 | else | |
8302 | { | |
8303 | /* Packet counts. */ | |
8304 | vty_out (vty, " Message statistics:%s", VTY_NEWLINE); | |
8305 | vty_out (vty, " Inq depth is 0%s", VTY_NEWLINE); | |
8306 | vty_out (vty, " Outq depth is %lu%s", (unsigned long) p->obuf->count, VTY_NEWLINE); | |
8307 | vty_out (vty, " Sent Rcvd%s", VTY_NEWLINE); | |
8308 | vty_out (vty, " Opens: %10d %10d%s", p->open_out, p->open_in, VTY_NEWLINE); | |
8309 | vty_out (vty, " Notifications: %10d %10d%s", p->notify_out, p->notify_in, VTY_NEWLINE); | |
8310 | vty_out (vty, " Updates: %10d %10d%s", p->update_out, p->update_in, VTY_NEWLINE); | |
8311 | vty_out (vty, " Keepalives: %10d %10d%s", p->keepalive_out, p->keepalive_in, VTY_NEWLINE); | |
8312 | vty_out (vty, " Route Refresh: %10d %10d%s", p->refresh_out, p->refresh_in, VTY_NEWLINE); | |
8313 | vty_out (vty, " Capability: %10d %10d%s", p->dynamic_cap_out, p->dynamic_cap_in, VTY_NEWLINE); | |
8314 | vty_out (vty, " Total: %10d %10d%s", p->open_out + p->notify_out + | |
8315 | p->update_out + p->keepalive_out + p->refresh_out + p->dynamic_cap_out, | |
8316 | p->open_in + p->notify_in + p->update_in + p->keepalive_in + p->refresh_in + | |
8317 | p->dynamic_cap_in, VTY_NEWLINE); | |
718e3744 | 8318 | } |
8319 | ||
856ca177 MS |
8320 | if (use_json) |
8321 | { | |
8322 | /* advertisement-interval */ | |
8323 | json_object_int_add(json_neigh, "minBtwnAdvertisementRunsTimerMsecs", p->v_routeadv * 1000); | |
718e3744 | 8324 | |
856ca177 MS |
8325 | /* Update-source. */ |
8326 | if (p->update_if || p->update_source) | |
8327 | { | |
8328 | if (p->update_if) | |
8329 | json_object_string_add(json_neigh, "updateSource", p->update_if); | |
8330 | else if (p->update_source) | |
8331 | json_object_string_add(json_neigh, "updateSource", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN)); | |
8332 | } | |
856ca177 MS |
8333 | } |
8334 | else | |
8335 | { | |
8336 | /* advertisement-interval */ | |
8337 | vty_out (vty, " Minimum time between advertisement runs is %d seconds%s", | |
8338 | p->v_routeadv, VTY_NEWLINE); | |
8339 | ||
8340 | /* Update-source. */ | |
8341 | if (p->update_if || p->update_source) | |
8342 | { | |
8343 | vty_out (vty, " Update source is "); | |
8344 | if (p->update_if) | |
8345 | vty_out (vty, "%s", p->update_if); | |
8346 | else if (p->update_source) | |
8347 | vty_out (vty, "%s", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN)); | |
8348 | vty_out (vty, "%s", VTY_NEWLINE); | |
8349 | } | |
8350 | ||
856ca177 MS |
8351 | vty_out (vty, "%s", VTY_NEWLINE); |
8352 | } | |
718e3744 | 8353 | |
8354 | /* Address Family Information */ | |
856ca177 MS |
8355 | json_object *json_hold = NULL; |
8356 | ||
8357 | if (use_json) | |
8358 | json_hold = json_object_new_object(); | |
8359 | ||
538621f2 | 8360 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) |
8361 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8362 | if (p->afc[afi][safi]) | |
856ca177 | 8363 | bgp_show_peer_afi (vty, p, afi, safi, use_json, json_hold); |
718e3744 | 8364 | |
856ca177 MS |
8365 | if (use_json) |
8366 | { | |
58433ae6 | 8367 | json_object_object_add(json_neigh, "addressFamilyInfo", json_hold); |
e08ac8b7 DW |
8368 | json_object_int_add(json_neigh, "connectionsEstablished", p->established); |
8369 | json_object_int_add(json_neigh, "connectionsDropped", p->dropped); | |
856ca177 MS |
8370 | } |
8371 | else | |
8372 | vty_out (vty, " Connections established %d; dropped %d%s", p->established, p->dropped, | |
8373 | VTY_NEWLINE); | |
718e3744 | 8374 | |
d6661008 | 8375 | if (! p->last_reset) |
856ca177 MS |
8376 | { |
8377 | if (use_json) | |
e08ac8b7 | 8378 | json_object_string_add(json_neigh, "lastReset", "never"); |
856ca177 MS |
8379 | else |
8380 | vty_out (vty, " Last reset never%s", VTY_NEWLINE); | |
8381 | } | |
e0701b79 | 8382 | else |
d6661008 | 8383 | { |
856ca177 MS |
8384 | if (use_json) |
8385 | { | |
8386 | time_t uptime; | |
8387 | struct tm *tm; | |
8388 | ||
8389 | uptime = bgp_clock(); | |
8390 | uptime -= p->resettime; | |
8391 | tm = gmtime(&uptime); | |
e08ac8b7 DW |
8392 | json_object_int_add(json_neigh, "lastResetTimerMsecs", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); |
8393 | json_object_string_add(json_neigh, "lastResetDueTo", peer_down_str[(int) p->last_reset]); | |
cca1dda8 DD |
8394 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND || |
8395 | p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) | |
856ca177 | 8396 | { |
39e871e6 | 8397 | char errorcodesubcode_hexstr[5]; |
cca1dda8 DD |
8398 | char errorcodesubcode_str[256]; |
8399 | ||
8400 | code_str = bgp_notify_code_str(p->notify.code); | |
8401 | subcode_str = bgp_notify_subcode_str(p->notify.code, p->notify.subcode); | |
8402 | ||
39e871e6 | 8403 | sprintf(errorcodesubcode_hexstr, "%02X%02X", p->notify.code, p->notify.subcode); |
e08ac8b7 | 8404 | json_object_string_add(json_neigh, "lastErrorCodeSubcode", errorcodesubcode_hexstr); |
cca1dda8 DD |
8405 | snprintf(errorcodesubcode_str, 255, "%s%s", code_str, subcode_str); |
8406 | json_object_string_add(json_neigh, "lastNotificationReason", errorcodesubcode_str); | |
652b9429 DS |
8407 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED |
8408 | && p->notify.code == BGP_NOTIFY_CEASE | |
8409 | && (p->notify.subcode == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
8410 | || p->notify.subcode == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
8411 | && p->notify.length) | |
8412 | { | |
8413 | char msgbuf[1024]; | |
8414 | const char *msg_str; | |
8415 | ||
8416 | msg_str = bgp_notify_admin_message(msgbuf, sizeof(msgbuf), | |
8417 | (u_char*)p->notify.data, p->notify.length); | |
8418 | if (msg_str) | |
8419 | json_object_string_add(json_neigh, "lastShutdownDescription", msg_str); | |
8420 | } | |
856ca177 MS |
8421 | } |
8422 | } | |
8423 | else | |
d6661008 | 8424 | { |
3a8c7ba1 DW |
8425 | vty_out (vty, " Last reset %s, ", |
8426 | peer_uptime (p->resettime, timebuf, BGP_UPTIME_LEN, 0, NULL)); | |
8427 | ||
8428 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND || | |
8429 | p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) | |
8430 | { | |
8431 | code_str = bgp_notify_code_str(p->notify.code); | |
8432 | subcode_str = bgp_notify_subcode_str(p->notify.code, p->notify.subcode); | |
8433 | vty_out (vty, "due to NOTIFICATION %s (%s%s)%s", | |
8434 | p->last_reset == PEER_DOWN_NOTIFY_SEND ? "sent" : "received", | |
8435 | code_str, subcode_str, VTY_NEWLINE); | |
38de8d02 DL |
8436 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED |
8437 | && p->notify.code == BGP_NOTIFY_CEASE | |
8438 | && (p->notify.subcode == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
8439 | || p->notify.subcode == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
8440 | && p->notify.length) | |
8441 | { | |
8442 | char msgbuf[1024]; | |
8443 | const char *msg_str; | |
8444 | ||
8445 | msg_str = bgp_notify_admin_message(msgbuf, sizeof(msgbuf), | |
8446 | (u_char*)p->notify.data, p->notify.length); | |
8447 | if (msg_str) | |
8448 | vty_out (vty, " Message: \"%s\"%s", msg_str, VTY_NEWLINE); | |
8449 | } | |
3a8c7ba1 DW |
8450 | } |
8451 | else | |
8452 | { | |
8453 | vty_out (vty, "due to %s%s", | |
8454 | peer_down_str[(int) p->last_reset], VTY_NEWLINE); | |
8455 | } | |
856ca177 MS |
8456 | |
8457 | if (p->last_reset_cause_size) | |
d6661008 | 8458 | { |
856ca177 MS |
8459 | msg = p->last_reset_cause; |
8460 | vty_out(vty, " Message received that caused BGP to send a NOTIFICATION:%s ", VTY_NEWLINE); | |
8461 | for (i = 1; i <= p->last_reset_cause_size; i++) | |
8462 | { | |
8463 | vty_out(vty, "%02X", *msg++); | |
d6661008 | 8464 | |
856ca177 MS |
8465 | if (i != p->last_reset_cause_size) |
8466 | { | |
8467 | if (i % 16 == 0) | |
8468 | { | |
8469 | vty_out(vty, "%s ", VTY_NEWLINE); | |
8470 | } | |
8471 | else if (i % 4 == 0) | |
8472 | { | |
8473 | vty_out(vty, " "); | |
8474 | } | |
8475 | } | |
8476 | } | |
8477 | vty_out(vty, "%s", VTY_NEWLINE); | |
d6661008 | 8478 | } |
d6661008 DS |
8479 | } |
8480 | } | |
848973c7 | 8481 | |
718e3744 | 8482 | if (CHECK_FLAG (p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) |
8483 | { | |
856ca177 | 8484 | if (use_json) |
e08ac8b7 | 8485 | json_object_boolean_true_add(json_neigh, "prefixesConfigExceedMax"); |
856ca177 MS |
8486 | else |
8487 | vty_out (vty, " Peer had exceeded the max. no. of prefixes configured.%s", VTY_NEWLINE); | |
0a486e5f | 8488 | |
8489 | if (p->t_pmax_restart) | |
856ca177 MS |
8490 | { |
8491 | if (use_json) | |
8492 | { | |
e08ac8b7 DW |
8493 | json_object_boolean_true_add(json_neigh, "reducePrefixNumFrom"); |
8494 | json_object_int_add(json_neigh, "restartInTimerMsec", thread_timer_remain_second (p->t_pmax_restart) * 1000); | |
856ca177 MS |
8495 | } |
8496 | else | |
8497 | vty_out (vty, " Reduce the no. of prefix from %s, will restart in %ld seconds%s", | |
8498 | p->host, thread_timer_remain_second (p->t_pmax_restart), | |
8499 | VTY_NEWLINE); | |
8500 | } | |
0a486e5f | 8501 | else |
856ca177 MS |
8502 | { |
8503 | if (use_json) | |
e08ac8b7 | 8504 | json_object_boolean_true_add(json_neigh, "reducePrefixNumAndClearIpBgp"); |
856ca177 MS |
8505 | else |
8506 | vty_out (vty, " Reduce the no. of prefix and clear ip bgp %s to restore peering%s", | |
8507 | p->host, VTY_NEWLINE); | |
8508 | } | |
718e3744 | 8509 | } |
8510 | ||
f5a4827d | 8511 | /* EBGP Multihop and GTSM */ |
6d85b15b | 8512 | if (p->sort != BGP_PEER_IBGP) |
f5a4827d | 8513 | { |
856ca177 MS |
8514 | if (use_json) |
8515 | { | |
8516 | if (p->gtsm_hops > 0) | |
8517 | json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->gtsm_hops); | |
8518 | else if (p->ttl > 1) | |
8519 | json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->ttl); | |
8520 | } | |
8521 | else | |
8522 | { | |
8523 | if (p->gtsm_hops > 0) | |
8524 | vty_out (vty, " External BGP neighbor may be up to %d hops away.%s", | |
8525 | p->gtsm_hops, VTY_NEWLINE); | |
8526 | else if (p->ttl > 1) | |
8527 | vty_out (vty, " External BGP neighbor may be up to %d hops away.%s", | |
8528 | p->ttl, VTY_NEWLINE); | |
8529 | } | |
f5a4827d | 8530 | } |
5d804b43 PM |
8531 | else |
8532 | { | |
8533 | if (p->gtsm_hops > 0) | |
856ca177 MS |
8534 | { |
8535 | if (use_json) | |
8536 | json_object_int_add(json_neigh, "internalBgpNbrMaxHopsAway", p->gtsm_hops); | |
8537 | else | |
8538 | vty_out (vty, " Internal BGP neighbor may be up to %d hops away.%s", | |
8539 | p->gtsm_hops, VTY_NEWLINE); | |
8540 | } | |
5d804b43 | 8541 | } |
718e3744 | 8542 | |
8543 | /* Local address. */ | |
8544 | if (p->su_local) | |
8545 | { | |
856ca177 MS |
8546 | if (use_json) |
8547 | { | |
8548 | json_object_string_add(json_neigh, "hostLocal", sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN)); | |
8549 | json_object_int_add(json_neigh, "portLocal", ntohs (p->su_local->sin.sin_port)); | |
8550 | } | |
8551 | else | |
8552 | vty_out (vty, "Local host: %s, Local port: %d%s", | |
8553 | sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN), | |
8554 | ntohs (p->su_local->sin.sin_port), | |
8555 | VTY_NEWLINE); | |
718e3744 | 8556 | } |
e52702f2 | 8557 | |
718e3744 | 8558 | /* Remote address. */ |
8559 | if (p->su_remote) | |
8560 | { | |
856ca177 MS |
8561 | if (use_json) |
8562 | { | |
8563 | json_object_string_add(json_neigh, "hostForeign", sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN)); | |
8564 | json_object_int_add(json_neigh, "portForeign", ntohs (p->su_remote->sin.sin_port)); | |
8565 | } | |
8566 | else | |
8567 | vty_out (vty, "Foreign host: %s, Foreign port: %d%s", | |
718e3744 | 8568 | sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN), |
8569 | ntohs (p->su_remote->sin.sin_port), | |
8570 | VTY_NEWLINE); | |
8571 | } | |
8572 | ||
8573 | /* Nexthop display. */ | |
8574 | if (p->su_local) | |
8575 | { | |
856ca177 MS |
8576 | if (use_json) |
8577 | { | |
389e3fe0 | 8578 | json_object_string_add(json_neigh, "nexthop", |
44b8cd53 | 8579 | inet_ntop (AF_INET, &p->nexthop.v4, buf1, sizeof(buf1))); |
389e3fe0 | 8580 | json_object_string_add(json_neigh, "nexthopGlobal", |
44b8cd53 | 8581 | inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, sizeof(buf1))); |
389e3fe0 | 8582 | json_object_string_add(json_neigh, "nexthopLocal", |
44b8cd53 | 8583 | inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, sizeof(buf1))); |
856ca177 MS |
8584 | if (p->shared_network) |
8585 | json_object_string_add(json_neigh, "bgpConnection", "sharedNetwork"); | |
8586 | else | |
8587 | json_object_string_add(json_neigh, "bgpConnection", "nonSharedNetwork"); | |
856ca177 MS |
8588 | } |
8589 | else | |
8590 | { | |
8591 | vty_out (vty, "Nexthop: %s%s", | |
44b8cd53 DL |
8592 | inet_ntop (AF_INET, &p->nexthop.v4, buf1, sizeof(buf1)), |
8593 | VTY_NEWLINE); | |
856ca177 | 8594 | vty_out (vty, "Nexthop global: %s%s", |
44b8cd53 DL |
8595 | inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, sizeof(buf1)), |
8596 | VTY_NEWLINE); | |
856ca177 | 8597 | vty_out (vty, "Nexthop local: %s%s", |
44b8cd53 DL |
8598 | inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, sizeof(buf1)), |
8599 | VTY_NEWLINE); | |
856ca177 | 8600 | vty_out (vty, "BGP connection: %s%s", |
44b8cd53 DL |
8601 | p->shared_network ? "shared network" : "non shared network", |
8602 | VTY_NEWLINE); | |
856ca177 | 8603 | } |
718e3744 | 8604 | } |
8605 | ||
8606 | /* Timer information. */ | |
856ca177 MS |
8607 | if (use_json) |
8608 | { | |
39e871e6 | 8609 | json_object_int_add(json_neigh, "connectRetryTimer", p->v_connect); |
dd9275d6 ST |
8610 | if (p->status == Established && p->rtt) |
8611 | json_object_int_add(json_neigh, "estimatedRttInMsecs", p->rtt); | |
856ca177 MS |
8612 | if (p->t_start) |
8613 | json_object_int_add(json_neigh, "nextStartTimerDueInMsecs", thread_timer_remain_second (p->t_start) * 1000); | |
8614 | if (p->t_connect) | |
8615 | json_object_int_add(json_neigh, "nextConnectTimerDueInMsecs", thread_timer_remain_second (p->t_connect) * 1000); | |
8616 | if (p->t_routeadv) | |
8617 | { | |
8618 | json_object_int_add(json_neigh, "mraiInterval", p->v_routeadv); | |
8619 | json_object_int_add(json_neigh, "mraiTimerExpireInMsecs", thread_timer_remain_second (p->t_routeadv) * 1000); | |
8620 | } | |
cb1faec9 | 8621 | |
856ca177 MS |
8622 | if (p->t_read) |
8623 | json_object_string_add(json_neigh, "readThread", "on"); | |
8624 | else | |
8625 | json_object_string_add(json_neigh, "readThread", "off"); | |
8626 | if (p->t_write) | |
8627 | json_object_string_add(json_neigh, "writeThread", "on"); | |
8628 | else | |
8629 | json_object_string_add(json_neigh, "writeThread", "off"); | |
8630 | } | |
8631 | else | |
8632 | { | |
39e871e6 ST |
8633 | vty_out (vty, "BGP Connect Retry Timer in Seconds: %d%s", |
8634 | p->v_connect, VTY_NEWLINE); | |
dd9275d6 ST |
8635 | if (p->status == Established && p->rtt) |
8636 | vty_out (vty, "Estimated round trip time: %d ms%s", | |
8637 | p->rtt, VTY_NEWLINE); | |
856ca177 MS |
8638 | if (p->t_start) |
8639 | vty_out (vty, "Next start timer due in %ld seconds%s", | |
8640 | thread_timer_remain_second (p->t_start), VTY_NEWLINE); | |
8641 | if (p->t_connect) | |
8642 | vty_out (vty, "Next connect timer due in %ld seconds%s", | |
8643 | thread_timer_remain_second (p->t_connect), VTY_NEWLINE); | |
8644 | if (p->t_routeadv) | |
8645 | vty_out (vty, "MRAI (interval %u) timer expires in %ld seconds%s", | |
8646 | p->v_routeadv, thread_timer_remain_second (p->t_routeadv), | |
8647 | VTY_NEWLINE); | |
8648 | ||
8649 | vty_out (vty, "Read thread: %s Write thread: %s%s", | |
8650 | p->t_read ? "on" : "off", | |
8651 | p->t_write ? "on" : "off", | |
8652 | VTY_NEWLINE); | |
8653 | } | |
718e3744 | 8654 | |
8655 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
8656 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
856ca177 MS |
8657 | bgp_capability_vty_out (vty, p, use_json, json_neigh); |
8658 | ||
8659 | if (!use_json) | |
8660 | vty_out (vty, "%s", VTY_NEWLINE); | |
c43ed2e4 DS |
8661 | |
8662 | /* BFD information. */ | |
856ca177 MS |
8663 | bgp_bfd_show_info(vty, p, use_json, json_neigh); |
8664 | ||
8665 | if (use_json) | |
8666 | { | |
8667 | if (p->conf_if) /* Configured interface name. */ | |
8668 | json_object_object_add(json, p->conf_if, json_neigh); | |
8669 | else /* Configured IP address. */ | |
8670 | json_object_object_add(json, p->host, json_neigh); | |
8671 | } | |
718e3744 | 8672 | } |
8673 | ||
94f2b392 | 8674 | static int |
856ca177 MS |
8675 | bgp_show_neighbor (struct vty *vty, struct bgp *bgp, enum show_type type, |
8676 | union sockunion *su, const char *conf_if, u_char use_json, json_object *json) | |
718e3744 | 8677 | { |
1eb8ef25 | 8678 | struct listnode *node, *nnode; |
718e3744 | 8679 | struct peer *peer; |
8680 | int find = 0; | |
8681 | ||
1eb8ef25 | 8682 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
718e3744 | 8683 | { |
1ff9a340 DS |
8684 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
8685 | continue; | |
8686 | ||
718e3744 | 8687 | switch (type) |
856ca177 MS |
8688 | { |
8689 | case show_all: | |
e8f7da3a | 8690 | bgp_show_peer (vty, peer, use_json, json); |
856ca177 MS |
8691 | break; |
8692 | case show_peer: | |
8693 | if (conf_if) | |
8694 | { | |
4873b3b9 DW |
8695 | if ((peer->conf_if && !strcmp(peer->conf_if, conf_if)) || |
8696 | (peer->hostname && !strcmp(peer->hostname, conf_if))) | |
856ca177 MS |
8697 | { |
8698 | find = 1; | |
e8f7da3a | 8699 | bgp_show_peer (vty, peer, use_json, json); |
856ca177 MS |
8700 | } |
8701 | } | |
8702 | else | |
8703 | { | |
8704 | if (sockunion_same (&peer->su, su)) | |
8705 | { | |
8706 | find = 1; | |
e8f7da3a | 8707 | bgp_show_peer (vty, peer, use_json, json); |
856ca177 MS |
8708 | } |
8709 | } | |
8710 | break; | |
718e3744 | 8711 | } |
8712 | } | |
8713 | ||
8714 | if (type == show_peer && ! find) | |
856ca177 MS |
8715 | { |
8716 | if (use_json) | |
8717 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
8718 | else | |
8719 | vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE); | |
8720 | } | |
8721 | ||
8722 | if (use_json) | |
8723 | { | |
2aac5767 | 8724 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
856ca177 MS |
8725 | json_object_free(json); |
8726 | } | |
8727 | else | |
8728 | { | |
8729 | vty_out (vty, "%s", VTY_NEWLINE); | |
8730 | } | |
8731 | ||
718e3744 | 8732 | return CMD_SUCCESS; |
8733 | } | |
8734 | ||
f186de26 | 8735 | static void |
8736 | bgp_show_all_instances_neighbors_vty (struct vty *vty, u_char use_json) | |
8737 | { | |
8738 | struct listnode *node, *nnode; | |
8739 | struct bgp *bgp; | |
8740 | json_object *json = NULL; | |
9f689658 DD |
8741 | int is_first = 1; |
8742 | ||
8743 | if (use_json) | |
8744 | vty_out (vty, "{%s", VTY_NEWLINE); | |
f186de26 | 8745 | |
8746 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) | |
8747 | { | |
f186de26 | 8748 | if (use_json) |
9f689658 DD |
8749 | { |
8750 | if (!(json = json_object_new_object())) | |
8751 | { | |
8752 | zlog_err("Unable to allocate memory for JSON object"); | |
8753 | vty_out (vty, | |
8754 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}%s", | |
8755 | VTY_NEWLINE); | |
8756 | return; | |
8757 | } | |
8758 | ||
8759 | json_object_int_add(json, "vrfId", | |
8760 | (bgp->vrf_id == VRF_UNKNOWN) | |
8761 | ? -1 : bgp->vrf_id); | |
8762 | json_object_string_add(json, "vrfName", | |
8763 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
8764 | ? "Default" : bgp->name); | |
8765 | ||
8766 | if (! is_first) | |
8767 | vty_out (vty, ",%s", VTY_NEWLINE); | |
8768 | else | |
8769 | is_first = 0; | |
8770 | ||
8771 | vty_out(vty, "\"%s\":", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
8772 | ? "Default" : bgp->name); | |
8773 | } | |
8774 | else | |
8775 | { | |
8776 | vty_out (vty, "%sInstance %s:%s", | |
8777 | VTY_NEWLINE, | |
8778 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
8779 | ? "Default" : bgp->name, | |
8780 | VTY_NEWLINE); | |
8781 | } | |
f186de26 | 8782 | bgp_show_neighbor (vty, bgp, show_all, NULL, NULL, use_json, json); |
8783 | } | |
9f689658 DD |
8784 | |
8785 | if (use_json) | |
8786 | vty_out (vty, "}%s", VTY_NEWLINE); | |
f186de26 | 8787 | } |
8788 | ||
4fb25c53 DW |
8789 | static int |
8790 | bgp_show_neighbor_vty (struct vty *vty, const char *name, | |
8791 | enum show_type type, const char *ip_str, u_char use_json) | |
8792 | { | |
8793 | int ret; | |
8794 | struct bgp *bgp; | |
8795 | union sockunion su; | |
8796 | json_object *json = NULL; | |
8797 | ||
8798 | if (use_json) | |
8799 | json = json_object_new_object(); | |
8800 | ||
8801 | if (name) | |
8802 | { | |
8803 | if (strmatch(name, "all")) | |
8804 | { | |
8805 | bgp_show_all_instances_neighbors_vty (vty, use_json); | |
8806 | return CMD_SUCCESS; | |
8807 | } | |
8808 | else | |
8809 | { | |
8810 | bgp = bgp_lookup_by_name (name); | |
8811 | if (! bgp) | |
8812 | { | |
8813 | if (use_json) | |
8814 | { | |
8815 | json_object_boolean_true_add(json, "bgpNoSuchInstance"); | |
e52702f2 | 8816 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
4fb25c53 DW |
8817 | json_object_free(json); |
8818 | } | |
8819 | else | |
8820 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
8821 | ||
8822 | return CMD_WARNING; | |
8823 | } | |
8824 | } | |
8825 | } | |
8826 | else | |
8827 | { | |
8828 | bgp = bgp_get_default (); | |
8829 | } | |
8830 | ||
8831 | if (bgp) | |
8832 | { | |
8833 | if (ip_str) | |
8834 | { | |
8835 | ret = str2sockunion (ip_str, &su); | |
8836 | if (ret < 0) | |
8837 | bgp_show_neighbor (vty, bgp, type, NULL, ip_str, use_json, json); | |
8838 | else | |
8839 | bgp_show_neighbor (vty, bgp, type, &su, NULL, use_json, json); | |
8840 | } | |
8841 | else | |
8842 | { | |
8843 | bgp_show_neighbor (vty, bgp, type, NULL, NULL, use_json, json); | |
8844 | } | |
8845 | } | |
8846 | ||
8847 | return CMD_SUCCESS; | |
8848 | } | |
8849 | ||
716b2d8a | 8850 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 8851 | DEFUN (show_ip_bgp_neighbors, |
8852 | show_ip_bgp_neighbors_cmd, | |
91d37724 | 8853 | "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 | 8854 | SHOW_STR |
8855 | IP_STR | |
8856 | BGP_STR | |
f2a8972b | 8857 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
8858 | "Address Family\n" |
8859 | "Address Family\n" | |
91d37724 QY |
8860 | "Address Family\n" |
8861 | "Display information about all VPNv4 NLRIs\n" | |
8862 | "Display information for a route distinguisher\n" | |
8863 | "VPN Route Distinguisher\n" | |
718e3744 | 8864 | "Detailed information on TCP and BGP neighbor connections\n" |
8865 | "Neighbor to display information about\n" | |
a80beece | 8866 | "Neighbor to display information about\n" |
91d37724 | 8867 | "Neighbor on BGP configured interface\n" |
9973d184 | 8868 | JSON_STR) |
718e3744 | 8869 | { |
5bf15956 DW |
8870 | char *vrf = NULL; |
8871 | char *sh_arg = NULL; | |
8872 | enum show_type sh_type; | |
718e3744 | 8873 | |
5bf15956 | 8874 | u_char uj = use_json(argc, argv); |
718e3744 | 8875 | |
630a298c | 8876 | int idx = 0; |
718e3744 | 8877 | |
46854ac0 DS |
8878 | if (argv_find (argv, argc, "view", &idx) || |
8879 | argv_find (argv, argc, "vrf", &idx)) | |
8880 | vrf = argv[idx+1]->arg; | |
718e3744 | 8881 | |
46854ac0 | 8882 | idx++; |
91d37724 QY |
8883 | if (argv_find (argv, argc, "A.B.C.D", &idx) || |
8884 | argv_find (argv, argc, "X:X::X:X", &idx) || | |
630a298c QY |
8885 | argv_find (argv, argc, "WORD", &idx)) |
8886 | { | |
8887 | sh_type = show_peer; | |
8888 | sh_arg = argv[idx]->arg; | |
8889 | } | |
5bf15956 | 8890 | else |
630a298c | 8891 | sh_type = show_all; |
856ca177 | 8892 | |
5bf15956 | 8893 | return bgp_show_neighbor_vty (vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 8894 | } |
8895 | ||
716b2d8a | 8896 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 8897 | paths' and `show ip mbgp paths'. Those functions results are the |
8898 | same.*/ | |
f412b39a | 8899 | DEFUN (show_ip_bgp_paths, |
718e3744 | 8900 | show_ip_bgp_paths_cmd, |
46f296b4 | 8901 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 8902 | SHOW_STR |
8903 | IP_STR | |
8904 | BGP_STR | |
46f296b4 | 8905 | BGP_SAFI_HELP_STR |
718e3744 | 8906 | "Path information\n") |
8907 | { | |
8908 | vty_out (vty, "Address Refcnt Path%s", VTY_NEWLINE); | |
8909 | aspath_print_all_vty (vty); | |
8910 | return CMD_SUCCESS; | |
8911 | } | |
8912 | ||
718e3744 | 8913 | #include "hash.h" |
8914 | ||
94f2b392 | 8915 | static void |
718e3744 | 8916 | community_show_all_iterator (struct hash_backet *backet, struct vty *vty) |
8917 | { | |
8918 | struct community *com; | |
8919 | ||
8920 | com = (struct community *) backet->data; | |
6c4f4e6e | 8921 | vty_out (vty, "[%p] (%ld) %s%s", (void *)backet, com->refcnt, |
718e3744 | 8922 | community_str (com), VTY_NEWLINE); |
8923 | } | |
8924 | ||
8925 | /* Show BGP's community internal data. */ | |
f412b39a | 8926 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 8927 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 8928 | "show [ip] bgp community-info", |
718e3744 | 8929 | SHOW_STR |
8930 | IP_STR | |
8931 | BGP_STR | |
8932 | "List all bgp community information\n") | |
8933 | { | |
8934 | vty_out (vty, "Address Refcnt Community%s", VTY_NEWLINE); | |
8935 | ||
e52702f2 | 8936 | hash_iterate (community_hash (), |
718e3744 | 8937 | (void (*) (struct hash_backet *, void *)) |
8938 | community_show_all_iterator, | |
8939 | vty); | |
8940 | ||
8941 | return CMD_SUCCESS; | |
8942 | } | |
8943 | ||
57d187bc JS |
8944 | static void |
8945 | lcommunity_show_all_iterator (struct hash_backet *backet, struct vty *vty) | |
8946 | { | |
8947 | struct lcommunity *lcom; | |
8948 | ||
8949 | lcom = (struct lcommunity *) backet->data; | |
8950 | vty_out (vty, "[%p] (%ld) %s%s", (void *)backet, lcom->refcnt, | |
2acb4ac2 | 8951 | lcommunity_str (lcom), VTY_NEWLINE); |
57d187bc JS |
8952 | } |
8953 | ||
8954 | /* Show BGP's community internal data. */ | |
8955 | DEFUN (show_ip_bgp_lcommunity_info, | |
8956 | show_ip_bgp_lcommunity_info_cmd, | |
8957 | "show ip bgp large-community-info", | |
8958 | SHOW_STR | |
8959 | IP_STR | |
8960 | BGP_STR | |
8961 | "List all bgp large-community information\n") | |
8962 | { | |
8963 | vty_out (vty, "Address Refcnt Large-community%s", VTY_NEWLINE); | |
8964 | ||
8965 | hash_iterate (lcommunity_hash (), | |
2acb4ac2 DL |
8966 | (void (*) (struct hash_backet *, void *)) |
8967 | lcommunity_show_all_iterator, | |
8968 | vty); | |
57d187bc JS |
8969 | |
8970 | return CMD_SUCCESS; | |
8971 | } | |
8972 | ||
8973 | ||
f412b39a | 8974 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 8975 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 8976 | "show [ip] bgp attribute-info", |
718e3744 | 8977 | SHOW_STR |
8978 | IP_STR | |
8979 | BGP_STR | |
8980 | "List all bgp attribute information\n") | |
8981 | { | |
8982 | attr_show_all (vty); | |
8983 | return CMD_SUCCESS; | |
8984 | } | |
6b0655a2 | 8985 | |
f186de26 | 8986 | static void |
8987 | bgp_show_all_instances_updgrps_vty (struct vty *vty, afi_t afi, safi_t safi) | |
8988 | { | |
8989 | struct listnode *node, *nnode; | |
8990 | struct bgp *bgp; | |
8991 | ||
8992 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) | |
8993 | { | |
8994 | vty_out (vty, "%sInstance %s:%s", | |
8995 | VTY_NEWLINE, | |
8996 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) ? "Default" : bgp->name, | |
8997 | VTY_NEWLINE); | |
8998 | update_group_show(bgp, afi, safi, vty, 0); | |
8999 | } | |
9000 | } | |
9001 | ||
4fb25c53 DW |
9002 | static int |
9003 | bgp_show_update_groups(struct vty *vty, const char *name, | |
9004 | int afi, int safi, | |
9005 | uint64_t subgrp_id) | |
9006 | { | |
9007 | struct bgp *bgp; | |
9008 | ||
9009 | if (name) | |
9010 | { | |
9011 | if (strmatch (name, "all")) | |
9012 | { | |
9013 | bgp_show_all_instances_updgrps_vty (vty, afi, safi); | |
9014 | return CMD_SUCCESS; | |
9015 | } | |
9016 | else | |
9017 | { | |
9018 | bgp = bgp_lookup_by_name (name); | |
9019 | } | |
9020 | } | |
9021 | else | |
9022 | { | |
9023 | bgp = bgp_get_default (); | |
9024 | } | |
9025 | ||
9026 | if (bgp) | |
9027 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
9028 | return CMD_SUCCESS; | |
9029 | } | |
9030 | ||
8fe8a7f6 DS |
9031 | DEFUN (show_ip_bgp_updgrps, |
9032 | show_ip_bgp_updgrps_cmd, | |
c9e571b4 | 9033 | "show [ip] bgp [<view|vrf> WORD] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 9034 | SHOW_STR |
9035 | IP_STR | |
9036 | BGP_STR | |
9037 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 9038 | BGP_AFI_HELP_STR |
46f296b4 | 9039 | BGP_SAFI_HELP_STR |
5bf15956 DW |
9040 | "Detailed info about dynamic update groups\n" |
9041 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 9042 | { |
5bf15956 | 9043 | char *vrf = NULL; |
ae19d7dd QY |
9044 | afi_t afi = AFI_IP6; |
9045 | safi_t safi = SAFI_UNICAST; | |
5bf15956 DW |
9046 | uint64_t subgrp_id = 0; |
9047 | ||
ae19d7dd QY |
9048 | int idx = 0; |
9049 | ||
9050 | /* show [ip] bgp */ | |
9051 | if (argv_find (argv, argc, "ip", &idx)) | |
9052 | afi = AFI_IP; | |
9053 | /* [<view|vrf> WORD] */ | |
9054 | if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) | |
9055 | vrf = argv[++idx]->arg; | |
c9e571b4 LB |
9056 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
9057 | if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) | |
9058 | { | |
9059 | argv_find_and_parse_safi (argv, argc, &idx, &safi); | |
9060 | } | |
5bf15956 | 9061 | |
ae19d7dd QY |
9062 | /* get subgroup id, if provided */ |
9063 | idx = argc - 1; | |
9064 | if (argv[idx]->type == VARIABLE_TKN) | |
9065 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx]->arg); | |
5bf15956 DW |
9066 | |
9067 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); | |
8fe8a7f6 DS |
9068 | } |
9069 | ||
f186de26 | 9070 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
9071 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 9072 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 9073 | SHOW_STR |
716b2d8a | 9074 | IP_STR |
f186de26 | 9075 | BGP_STR |
9076 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 9077 | "Detailed info about dynamic update groups\n") |
f186de26 | 9078 | { |
9079 | bgp_show_all_instances_updgrps_vty (vty, AFI_IP6, SAFI_UNICAST); | |
9080 | return CMD_SUCCESS; | |
9081 | } | |
9082 | ||
5bf15956 DW |
9083 | DEFUN (show_bgp_updgrps_stats, |
9084 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 9085 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 9086 | SHOW_STR |
716b2d8a | 9087 | IP_STR |
3f9c7369 | 9088 | BGP_STR |
0c7b1b01 | 9089 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
9090 | "Statistics\n") |
9091 | { | |
9092 | struct bgp *bgp; | |
9093 | ||
9094 | bgp = bgp_get_default(); | |
9095 | if (bgp) | |
9096 | update_group_show_stats(bgp, vty); | |
9097 | ||
9098 | return CMD_SUCCESS; | |
9099 | } | |
9100 | ||
8386ac43 | 9101 | DEFUN (show_bgp_instance_updgrps_stats, |
9102 | show_bgp_instance_updgrps_stats_cmd, | |
716b2d8a | 9103 | "show [ip] bgp <view|vrf> WORD update-groups statistics", |
8386ac43 | 9104 | SHOW_STR |
716b2d8a | 9105 | IP_STR |
8386ac43 | 9106 | BGP_STR |
9107 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 9108 | "Detailed info about dynamic update groups\n" |
8386ac43 | 9109 | "Statistics\n") |
9110 | { | |
c500ae40 | 9111 | int idx_word = 3; |
8386ac43 | 9112 | struct bgp *bgp; |
9113 | ||
c500ae40 | 9114 | bgp = bgp_lookup_by_name (argv[idx_word]->arg); |
8386ac43 | 9115 | if (bgp) |
9116 | update_group_show_stats(bgp, vty); | |
9117 | ||
9118 | return CMD_SUCCESS; | |
9119 | } | |
9120 | ||
3f9c7369 | 9121 | static void |
8386ac43 | 9122 | show_bgp_updgrps_adj_info_aux (struct vty *vty, const char *name, |
9123 | afi_t afi, safi_t safi, | |
f43e655e | 9124 | const char *what, uint64_t subgrp_id) |
3f9c7369 DS |
9125 | { |
9126 | struct bgp *bgp; | |
8386ac43 | 9127 | |
9128 | if (name) | |
9129 | bgp = bgp_lookup_by_name (name); | |
9130 | else | |
9131 | bgp = bgp_get_default (); | |
9132 | ||
3f9c7369 DS |
9133 | if (bgp) |
9134 | { | |
9135 | if (!strcmp(what, "advertise-queue")) | |
9136 | update_group_show_adj_queue(bgp, afi, safi, vty, subgrp_id); | |
9137 | else if (!strcmp(what, "advertised-routes")) | |
9138 | update_group_show_advertised(bgp, afi, safi, vty, subgrp_id); | |
9139 | else if (!strcmp(what, "packet-queue")) | |
9140 | update_group_show_packet_queue(bgp, afi, safi, vty, subgrp_id); | |
9141 | } | |
9142 | } | |
9143 | ||
9144 | DEFUN (show_ip_bgp_updgrps_adj, | |
9145 | show_ip_bgp_updgrps_adj_cmd, | |
716b2d8a | 9146 | "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 DS |
9147 | SHOW_STR |
9148 | IP_STR | |
9149 | BGP_STR | |
0c7b1b01 | 9150 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
9151 | "Advertisement queue\n" |
9152 | "Announced routes\n" | |
9153 | "Packet queue\n") | |
8fe8a7f6 | 9154 | |
3f9c7369 | 9155 | { |
c500ae40 DW |
9156 | int idx_type = 4; |
9157 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
8386ac43 | 9158 | return CMD_SUCCESS; |
9159 | } | |
9160 | ||
9161 | DEFUN (show_ip_bgp_instance_updgrps_adj, | |
9162 | show_ip_bgp_instance_updgrps_adj_cmd, | |
716b2d8a | 9163 | "show [ip] bgp <view|vrf> WORD update-groups <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 9164 | SHOW_STR |
9165 | IP_STR | |
9166 | BGP_STR | |
9167 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 9168 | "Detailed info about dynamic update groups\n" |
8386ac43 | 9169 | "Advertisement queue\n" |
9170 | "Announced routes\n" | |
9171 | "Packet queue\n") | |
9172 | ||
9173 | { | |
c500ae40 DW |
9174 | int idx_word = 4; |
9175 | int idx_type = 6; | |
9176 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
3f9c7369 DS |
9177 | return CMD_SUCCESS; |
9178 | } | |
9179 | ||
9180 | DEFUN (show_bgp_updgrps_afi_adj, | |
9181 | show_bgp_updgrps_afi_adj_cmd, | |
46f296b4 | 9182 | "show [ip] bgp "BGP_AFI_SAFI_CMD_STR" update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 9183 | SHOW_STR |
716b2d8a | 9184 | IP_STR |
3f9c7369 | 9185 | BGP_STR |
46f296b4 | 9186 | BGP_AFI_SAFI_HELP_STR |
0c7b1b01 | 9187 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
9188 | "Advertisement queue\n" |
9189 | "Announced routes\n" | |
8fe8a7f6 DS |
9190 | "Packet queue\n" |
9191 | "Specific subgroup info wanted for\n") | |
3f9c7369 | 9192 | { |
c500ae40 DW |
9193 | int idx_afi = 2; |
9194 | int idx_safi = 3; | |
9195 | int idx_type = 5; | |
46f296b4 LB |
9196 | show_bgp_updgrps_adj_info_aux(vty, NULL, |
9197 | bgp_vty_afi_from_arg(argv[idx_afi]->arg), | |
9198 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), | |
9199 | argv[idx_type]->arg, 0); | |
8fe8a7f6 | 9200 | return CMD_SUCCESS; |
3f9c7369 DS |
9201 | } |
9202 | ||
9203 | DEFUN (show_bgp_updgrps_adj, | |
9204 | show_bgp_updgrps_adj_cmd, | |
716b2d8a | 9205 | "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 9206 | SHOW_STR |
716b2d8a | 9207 | IP_STR |
3f9c7369 | 9208 | BGP_STR |
0c7b1b01 | 9209 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
9210 | "Advertisement queue\n" |
9211 | "Announced routes\n" | |
9212 | "Packet queue\n") | |
9213 | { | |
c500ae40 DW |
9214 | int idx_type = 3; |
9215 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
8386ac43 | 9216 | return CMD_SUCCESS; |
9217 | } | |
9218 | ||
9219 | DEFUN (show_bgp_instance_updgrps_adj, | |
9220 | show_bgp_instance_updgrps_adj_cmd, | |
716b2d8a | 9221 | "show [ip] bgp <view|vrf> WORD update-groups <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 9222 | SHOW_STR |
716b2d8a | 9223 | IP_STR |
8386ac43 | 9224 | BGP_STR |
9225 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 9226 | "Detailed info about dynamic update groups\n" |
8386ac43 | 9227 | "Advertisement queue\n" |
9228 | "Announced routes\n" | |
9229 | "Packet queue\n") | |
9230 | { | |
c500ae40 DW |
9231 | int idx_word = 3; |
9232 | int idx_type = 5; | |
9233 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
3f9c7369 DS |
9234 | return CMD_SUCCESS; |
9235 | } | |
9236 | ||
9237 | DEFUN (show_ip_bgp_updgrps_adj_s, | |
8fe8a7f6 | 9238 | show_ip_bgp_updgrps_adj_s_cmd, |
716b2d8a | 9239 | "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 DS |
9240 | SHOW_STR |
9241 | IP_STR | |
9242 | BGP_STR | |
0c7b1b01 | 9243 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 | 9244 | "Specific subgroup to display info for\n" |
3f9c7369 DS |
9245 | "Advertisement queue\n" |
9246 | "Announced routes\n" | |
9247 | "Packet queue\n") | |
3f9c7369 | 9248 | |
3f9c7369 | 9249 | { |
5bf15956 | 9250 | int idx_subgroup_id = 4; |
c500ae40 | 9251 | int idx_type = 5; |
f43e655e | 9252 | uint64_t subgrp_id; |
8fe8a7f6 | 9253 | |
5bf15956 | 9254 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8fe8a7f6 | 9255 | |
5bf15956 | 9256 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
8386ac43 | 9257 | return CMD_SUCCESS; |
9258 | } | |
9259 | ||
9260 | DEFUN (show_ip_bgp_instance_updgrps_adj_s, | |
9261 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
716b2d8a | 9262 | "show [ip] bgp <view|vrf> WORD update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 9263 | SHOW_STR |
9264 | IP_STR | |
9265 | BGP_STR | |
9266 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 9267 | "Detailed info about dynamic update groups\n" |
8386ac43 | 9268 | "Specific subgroup to display info for\n" |
9269 | "Advertisement queue\n" | |
9270 | "Announced routes\n" | |
9271 | "Packet queue\n") | |
9272 | ||
9273 | { | |
5bf15956 DW |
9274 | int idx_vrf = 4; |
9275 | int idx_subgroup_id = 6; | |
c500ae40 | 9276 | int idx_type = 7; |
f43e655e | 9277 | uint64_t subgrp_id; |
8386ac43 | 9278 | |
5bf15956 | 9279 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8386ac43 | 9280 | |
5bf15956 | 9281 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
3f9c7369 DS |
9282 | return CMD_SUCCESS; |
9283 | } | |
9284 | ||
8fe8a7f6 DS |
9285 | DEFUN (show_bgp_updgrps_afi_adj_s, |
9286 | show_bgp_updgrps_afi_adj_s_cmd, | |
46f296b4 | 9287 | "show [ip] bgp "BGP_AFI_SAFI_CMD_STR" update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 9288 | SHOW_STR |
716b2d8a | 9289 | IP_STR |
3f9c7369 | 9290 | BGP_STR |
46f296b4 | 9291 | BGP_AFI_SAFI_HELP_STR |
0c7b1b01 | 9292 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 | 9293 | "Specific subgroup to display info for\n" |
3f9c7369 DS |
9294 | "Advertisement queue\n" |
9295 | "Announced routes\n" | |
8fe8a7f6 DS |
9296 | "Packet queue\n" |
9297 | "Specific subgroup info wanted for\n") | |
3f9c7369 | 9298 | { |
c500ae40 DW |
9299 | int idx_afi = 2; |
9300 | int idx_safi = 3; | |
5bf15956 | 9301 | int idx_subgroup_id = 5; |
c500ae40 | 9302 | int idx_type = 6; |
f43e655e | 9303 | uint64_t subgrp_id; |
3f9c7369 | 9304 | |
5bf15956 | 9305 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8fe8a7f6 | 9306 | |
46f296b4 LB |
9307 | show_bgp_updgrps_adj_info_aux(vty, NULL, |
9308 | bgp_vty_afi_from_arg(argv[idx_afi]->arg), | |
9309 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), | |
9310 | argv[idx_type]->arg, subgrp_id); | |
8fe8a7f6 | 9311 | return CMD_SUCCESS; |
3f9c7369 DS |
9312 | } |
9313 | ||
8fe8a7f6 DS |
9314 | DEFUN (show_bgp_updgrps_adj_s, |
9315 | show_bgp_updgrps_adj_s_cmd, | |
716b2d8a | 9316 | "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8fe8a7f6 | 9317 | SHOW_STR |
716b2d8a | 9318 | IP_STR |
8fe8a7f6 | 9319 | BGP_STR |
0c7b1b01 | 9320 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 DS |
9321 | "Specific subgroup to display info for\n" |
9322 | "Advertisement queue\n" | |
9323 | "Announced routes\n" | |
9324 | "Packet queue\n") | |
9325 | { | |
5bf15956 | 9326 | int idx_subgroup_id = 3; |
c500ae40 | 9327 | int idx_type = 4; |
f43e655e | 9328 | uint64_t subgrp_id; |
8fe8a7f6 | 9329 | |
5bf15956 | 9330 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8fe8a7f6 | 9331 | |
5bf15956 | 9332 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
8fe8a7f6 DS |
9333 | return CMD_SUCCESS; |
9334 | } | |
9335 | ||
8386ac43 | 9336 | DEFUN (show_bgp_instance_updgrps_adj_s, |
9337 | show_bgp_instance_updgrps_adj_s_cmd, | |
716b2d8a | 9338 | "show [ip] bgp <view|vrf> WORD update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 9339 | SHOW_STR |
716b2d8a | 9340 | IP_STR |
8386ac43 | 9341 | BGP_STR |
9342 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 9343 | "Detailed info about dynamic update groups\n" |
8386ac43 | 9344 | "Specific subgroup to display info for\n" |
9345 | "Advertisement queue\n" | |
9346 | "Announced routes\n" | |
9347 | "Packet queue\n") | |
9348 | { | |
5bf15956 DW |
9349 | int idx_vrf = 3; |
9350 | int idx_subgroup_id = 5; | |
c500ae40 | 9351 | int idx_type = 6; |
f43e655e | 9352 | uint64_t subgrp_id; |
8386ac43 | 9353 | |
5bf15956 | 9354 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8386ac43 | 9355 | |
5bf15956 | 9356 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
8386ac43 | 9357 | return CMD_SUCCESS; |
9358 | } | |
9359 | ||
9360 | ||
8fe8a7f6 | 9361 | |
f14e6fdb DS |
9362 | static int |
9363 | bgp_show_one_peer_group (struct vty *vty, struct peer_group *group) | |
9364 | { | |
9365 | struct listnode *node, *nnode; | |
9366 | struct prefix *range; | |
9367 | struct peer *conf; | |
9368 | struct peer *peer; | |
4690c7d7 | 9369 | char buf[PREFIX2STR_BUFFER]; |
f14e6fdb DS |
9370 | afi_t afi; |
9371 | safi_t safi; | |
ffd0c037 DS |
9372 | const char *peer_status; |
9373 | const char *af_str; | |
f14e6fdb DS |
9374 | int lr_count; |
9375 | int dynamic; | |
9376 | int af_cfgd; | |
9377 | ||
9378 | conf = group->conf; | |
9379 | ||
0299c004 DS |
9380 | if (conf->as_type == AS_SPECIFIED || |
9381 | conf->as_type == AS_EXTERNAL) { | |
66b199b2 | 9382 | vty_out (vty, "%sBGP peer-group %s, remote AS %d%s", |
f14e6fdb | 9383 | VTY_NEWLINE, group->name, conf->as, VTY_NEWLINE); |
0299c004 | 9384 | } else if (conf->as_type == AS_INTERNAL) { |
66b199b2 | 9385 | vty_out (vty, "%sBGP peer-group %s, remote AS %d%s", |
0299c004 | 9386 | VTY_NEWLINE, group->name, group->bgp->as, VTY_NEWLINE); |
66b199b2 DS |
9387 | } else { |
9388 | vty_out (vty, "%sBGP peer-group %s%s", | |
9389 | VTY_NEWLINE, group->name, VTY_NEWLINE); | |
0299c004 | 9390 | } |
f14e6fdb | 9391 | |
0299c004 | 9392 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
f14e6fdb DS |
9393 | vty_out (vty, " Peer-group type is internal%s", VTY_NEWLINE); |
9394 | else | |
9395 | vty_out (vty, " Peer-group type is external%s", VTY_NEWLINE); | |
9396 | ||
9397 | /* Display AFs configured. */ | |
9398 | vty_out (vty, " Configured address-families:"); | |
9399 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
9400 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
9401 | { | |
9402 | if (conf->afc[afi][safi]) | |
9403 | { | |
9404 | af_cfgd = 1; | |
9405 | vty_out (vty, " %s;", afi_safi_print(afi, safi)); | |
9406 | } | |
9407 | } | |
9408 | if (!af_cfgd) | |
9409 | vty_out (vty, " none%s", VTY_NEWLINE); | |
9410 | else | |
9411 | vty_out (vty, "%s", VTY_NEWLINE); | |
9412 | ||
9413 | /* Display listen ranges (for dynamic neighbors), if any */ | |
9414 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
9415 | { | |
9416 | if (afi == AFI_IP) | |
9417 | af_str = "IPv4"; | |
9418 | else if (afi == AFI_IP6) | |
9419 | af_str = "IPv6"; | |
45ef4300 DL |
9420 | else |
9421 | af_str = "???"; | |
f14e6fdb DS |
9422 | lr_count = listcount(group->listen_range[afi]); |
9423 | if (lr_count) | |
9424 | { | |
9425 | vty_out(vty, | |
9426 | " %d %s listen range(s)%s", | |
9427 | lr_count, af_str, VTY_NEWLINE); | |
9428 | ||
9429 | ||
9430 | for (ALL_LIST_ELEMENTS (group->listen_range[afi], node, | |
9431 | nnode, range)) | |
9432 | { | |
9433 | prefix2str(range, buf, sizeof(buf)); | |
9434 | vty_out(vty, " %s%s", buf, VTY_NEWLINE); | |
9435 | } | |
9436 | } | |
9437 | } | |
9438 | ||
9439 | /* Display group members and their status */ | |
9440 | if (listcount(group->peer)) | |
9441 | { | |
9442 | vty_out (vty, " Peer-group members:%s", VTY_NEWLINE); | |
9443 | for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) | |
9444 | { | |
9445 | if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) | |
9446 | peer_status = "Idle (Admin)"; | |
9447 | else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) | |
9448 | peer_status = "Idle (PfxCt)"; | |
9449 | else | |
9450 | peer_status = LOOKUP(bgp_status_msg, peer->status); | |
9451 | ||
9452 | dynamic = peer_dynamic_neighbor(peer); | |
9453 | vty_out (vty, " %s %s %s %s", | |
9454 | peer->host, dynamic ? "(dynamic)" : "", | |
9455 | peer_status, VTY_NEWLINE); | |
9456 | } | |
9457 | } | |
9458 | ||
9459 | return CMD_SUCCESS; | |
9460 | } | |
9461 | ||
9462 | /* Show BGP peer group's information. */ | |
9463 | enum show_group_type | |
9464 | { | |
9465 | show_all_groups, | |
9466 | show_peer_group | |
9467 | }; | |
9468 | ||
9469 | static int | |
9470 | bgp_show_peer_group (struct vty *vty, struct bgp *bgp, | |
9471 | enum show_group_type type, const char *group_name) | |
9472 | { | |
9473 | struct listnode *node, *nnode; | |
9474 | struct peer_group *group; | |
9475 | int find = 0; | |
9476 | ||
9477 | for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) | |
9478 | { | |
9479 | switch (type) | |
9480 | { | |
9481 | case show_all_groups: | |
9482 | bgp_show_one_peer_group (vty, group); | |
9483 | break; | |
9484 | case show_peer_group: | |
9485 | if (group_name && (strcmp(group->name, group_name) == 0)) | |
9486 | { | |
9487 | find = 1; | |
9488 | bgp_show_one_peer_group (vty, group); | |
9489 | } | |
9490 | break; | |
9491 | } | |
9492 | } | |
9493 | ||
9494 | if (type == show_peer_group && ! find) | |
6d9e66dc | 9495 | vty_out (vty, "%% No such peer-group%s", VTY_NEWLINE); |
f14e6fdb DS |
9496 | |
9497 | return CMD_SUCCESS; | |
9498 | } | |
9499 | ||
9500 | static int | |
9501 | bgp_show_peer_group_vty (struct vty *vty, const char *name, | |
9502 | enum show_group_type type, const char *group_name) | |
9503 | { | |
9504 | struct bgp *bgp; | |
9505 | int ret = CMD_SUCCESS; | |
9506 | ||
9507 | if (name) | |
8386ac43 | 9508 | bgp = bgp_lookup_by_name (name); |
9509 | else | |
9510 | bgp = bgp_get_default (); | |
f14e6fdb | 9511 | |
8386ac43 | 9512 | if (! bgp) |
9513 | { | |
9514 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
9515 | return CMD_WARNING; | |
f14e6fdb DS |
9516 | } |
9517 | ||
8386ac43 | 9518 | ret = bgp_show_peer_group (vty, bgp, type, group_name); |
f14e6fdb DS |
9519 | |
9520 | return ret; | |
9521 | } | |
9522 | ||
9523 | DEFUN (show_ip_bgp_peer_groups, | |
9524 | show_ip_bgp_peer_groups_cmd, | |
f2a8972b | 9525 | "show [ip] bgp [<view|vrf> WORD] peer-group [PGNAME]", |
f14e6fdb DS |
9526 | SHOW_STR |
9527 | IP_STR | |
9528 | BGP_STR | |
8386ac43 | 9529 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
9530 | "Detailed information on BGP peer groups\n" |
9531 | "Peer group name\n") | |
f14e6fdb | 9532 | { |
d6e3c605 QY |
9533 | char *vrf, *pg; |
9534 | vrf = pg = NULL; | |
9535 | int idx = 0; | |
f14e6fdb | 9536 | |
f2a8972b | 9537 | vrf = argv_find (argv, argc, "WORD", &idx) ? argv[idx]->arg : NULL; |
d6e3c605 | 9538 | pg = argv_find (argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 9539 | |
d6e3c605 | 9540 | return bgp_show_peer_group_vty (vty, vrf, show_all_groups, pg); |
f14e6fdb | 9541 | } |
3f9c7369 | 9542 | |
d6e3c605 | 9543 | |
718e3744 | 9544 | /* Redistribute VTY commands. */ |
9545 | ||
718e3744 | 9546 | DEFUN (bgp_redistribute_ipv4, |
9547 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 9548 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 9549 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9550 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 9551 | { |
cdc2d765 | 9552 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 9553 | int idx_protocol = 1; |
718e3744 | 9554 | int type; |
9555 | ||
6d681bd8 QY |
9556 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9557 | if (type < 0) | |
718e3744 | 9558 | { |
9559 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9560 | return CMD_WARNING; | |
9561 | } | |
cdc2d765 DL |
9562 | bgp_redist_add(bgp, AFI_IP, type, 0); |
9563 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); | |
718e3744 | 9564 | } |
9565 | ||
9566 | DEFUN (bgp_redistribute_ipv4_rmap, | |
9567 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 9568 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 9569 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9570 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 9571 | "Route map reference\n" |
9572 | "Pointer to route-map entries\n") | |
9573 | { | |
cdc2d765 | 9574 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9575 | int idx_protocol = 1; |
9576 | int idx_word = 3; | |
718e3744 | 9577 | int type; |
7c8ff89e | 9578 | struct bgp_redist *red; |
718e3744 | 9579 | |
6d681bd8 QY |
9580 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9581 | if (type < 0) | |
718e3744 | 9582 | { |
9583 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9584 | return CMD_WARNING; | |
9585 | } | |
9586 | ||
cdc2d765 | 9587 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
c500ae40 | 9588 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9589 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); |
718e3744 | 9590 | } |
9591 | ||
9592 | DEFUN (bgp_redistribute_ipv4_metric, | |
9593 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 9594 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 9595 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9596 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 9597 | "Metric for redistributed routes\n" |
9598 | "Default metric\n") | |
9599 | { | |
cdc2d765 | 9600 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9601 | int idx_protocol = 1; |
9602 | int idx_number = 3; | |
718e3744 | 9603 | int type; |
9604 | u_int32_t metric; | |
7c8ff89e | 9605 | struct bgp_redist *red; |
718e3744 | 9606 | |
6d681bd8 QY |
9607 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9608 | if (type < 0) | |
718e3744 | 9609 | { |
9610 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9611 | return CMD_WARNING; | |
9612 | } | |
c500ae40 | 9613 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9614 | |
cdc2d765 DL |
9615 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
9616 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
9617 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); | |
718e3744 | 9618 | } |
9619 | ||
9620 | DEFUN (bgp_redistribute_ipv4_rmap_metric, | |
9621 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 9622 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 9623 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9624 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 9625 | "Route map reference\n" |
9626 | "Pointer to route-map entries\n" | |
9627 | "Metric for redistributed routes\n" | |
9628 | "Default metric\n") | |
9629 | { | |
cdc2d765 | 9630 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9631 | int idx_protocol = 1; |
9632 | int idx_word = 3; | |
9633 | int idx_number = 5; | |
718e3744 | 9634 | int type; |
9635 | u_int32_t metric; | |
7c8ff89e | 9636 | struct bgp_redist *red; |
718e3744 | 9637 | |
6d681bd8 QY |
9638 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9639 | if (type < 0) | |
718e3744 | 9640 | { |
9641 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9642 | return CMD_WARNING; | |
9643 | } | |
c500ae40 | 9644 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9645 | |
cdc2d765 | 9646 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
c500ae40 | 9647 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 DL |
9648 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
9649 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); | |
718e3744 | 9650 | } |
9651 | ||
9652 | DEFUN (bgp_redistribute_ipv4_metric_rmap, | |
9653 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 9654 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 9655 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9656 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 9657 | "Metric for redistributed routes\n" |
9658 | "Default metric\n" | |
9659 | "Route map reference\n" | |
9660 | "Pointer to route-map entries\n") | |
9661 | { | |
cdc2d765 | 9662 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9663 | int idx_protocol = 1; |
9664 | int idx_number = 3; | |
9665 | int idx_word = 5; | |
718e3744 | 9666 | int type; |
9667 | u_int32_t metric; | |
7c8ff89e | 9668 | struct bgp_redist *red; |
718e3744 | 9669 | |
6d681bd8 QY |
9670 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9671 | if (type < 0) | |
718e3744 | 9672 | { |
9673 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9674 | return CMD_WARNING; | |
9675 | } | |
c500ae40 | 9676 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9677 | |
cdc2d765 DL |
9678 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
9679 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
c500ae40 | 9680 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9681 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); |
718e3744 | 9682 | } |
9683 | ||
7c8ff89e DS |
9684 | DEFUN (bgp_redistribute_ipv4_ospf, |
9685 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 9686 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
9687 | "Redistribute information from another routing protocol\n" |
9688 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9689 | "Non-main Kernel Routing Table\n" |
9690 | "Instance ID/Table ID\n") | |
7c8ff89e | 9691 | { |
cdc2d765 | 9692 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9693 | int idx_ospf_table = 1; |
9694 | int idx_number = 2; | |
7c8ff89e | 9695 | u_short instance; |
7a4bb9c5 | 9696 | u_short protocol; |
7c8ff89e | 9697 | |
c500ae40 | 9698 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
7a4bb9c5 | 9699 | |
c500ae40 | 9700 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9701 | protocol = ZEBRA_ROUTE_OSPF; |
9702 | else | |
9703 | protocol = ZEBRA_ROUTE_TABLE; | |
9704 | ||
cdc2d765 DL |
9705 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
9706 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
9707 | } |
9708 | ||
9709 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, | |
9710 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 9711 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
9712 | "Redistribute information from another routing protocol\n" |
9713 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9714 | "Non-main Kernel Routing Table\n" |
9715 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
9716 | "Route map reference\n" |
9717 | "Pointer to route-map entries\n") | |
9718 | { | |
cdc2d765 | 9719 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9720 | int idx_ospf_table = 1; |
9721 | int idx_number = 2; | |
9722 | int idx_word = 4; | |
7c8ff89e DS |
9723 | struct bgp_redist *red; |
9724 | u_short instance; | |
7a4bb9c5 | 9725 | int protocol; |
7c8ff89e | 9726 | |
c500ae40 | 9727 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9728 | protocol = ZEBRA_ROUTE_OSPF; |
9729 | else | |
9730 | protocol = ZEBRA_ROUTE_TABLE; | |
9731 | ||
c500ae40 | 9732 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
cdc2d765 | 9733 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
c500ae40 | 9734 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9735 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); |
7c8ff89e DS |
9736 | } |
9737 | ||
9738 | DEFUN (bgp_redistribute_ipv4_ospf_metric, | |
9739 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 9740 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
9741 | "Redistribute information from another routing protocol\n" |
9742 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9743 | "Non-main Kernel Routing Table\n" |
9744 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
9745 | "Metric for redistributed routes\n" |
9746 | "Default metric\n") | |
9747 | { | |
cdc2d765 | 9748 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9749 | int idx_ospf_table = 1; |
9750 | int idx_number = 2; | |
9751 | int idx_number_2 = 4; | |
7c8ff89e DS |
9752 | u_int32_t metric; |
9753 | struct bgp_redist *red; | |
9754 | u_short instance; | |
7a4bb9c5 | 9755 | int protocol; |
7c8ff89e | 9756 | |
c500ae40 | 9757 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9758 | protocol = ZEBRA_ROUTE_OSPF; |
9759 | else | |
9760 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 9761 | |
c500ae40 DW |
9762 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
9763 | VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); | |
7a4bb9c5 | 9764 | |
cdc2d765 DL |
9765 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
9766 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
9767 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
9768 | } |
9769 | ||
9770 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, | |
9771 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 9772 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
9773 | "Redistribute information from another routing protocol\n" |
9774 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9775 | "Non-main Kernel Routing Table\n" |
9776 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
9777 | "Route map reference\n" |
9778 | "Pointer to route-map entries\n" | |
9779 | "Metric for redistributed routes\n" | |
9780 | "Default metric\n") | |
9781 | { | |
cdc2d765 | 9782 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9783 | int idx_ospf_table = 1; |
9784 | int idx_number = 2; | |
9785 | int idx_word = 4; | |
9786 | int idx_number_2 = 6; | |
7c8ff89e DS |
9787 | u_int32_t metric; |
9788 | struct bgp_redist *red; | |
9789 | u_short instance; | |
7a4bb9c5 | 9790 | int protocol; |
7c8ff89e | 9791 | |
c500ae40 | 9792 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9793 | protocol = ZEBRA_ROUTE_OSPF; |
9794 | else | |
9795 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 9796 | |
c500ae40 DW |
9797 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
9798 | VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); | |
7a4bb9c5 | 9799 | |
cdc2d765 | 9800 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
c500ae40 | 9801 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 DL |
9802 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); |
9803 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
9804 | } |
9805 | ||
9806 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, | |
9807 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 9808 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
9809 | "Redistribute information from another routing protocol\n" |
9810 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9811 | "Non-main Kernel Routing Table\n" |
9812 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
9813 | "Metric for redistributed routes\n" |
9814 | "Default metric\n" | |
9815 | "Route map reference\n" | |
9816 | "Pointer to route-map entries\n") | |
9817 | { | |
cdc2d765 | 9818 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9819 | int idx_ospf_table = 1; |
9820 | int idx_number = 2; | |
9821 | int idx_number_2 = 4; | |
9822 | int idx_word = 6; | |
7c8ff89e DS |
9823 | u_int32_t metric; |
9824 | struct bgp_redist *red; | |
9825 | u_short instance; | |
7a4bb9c5 | 9826 | int protocol; |
7c8ff89e | 9827 | |
c500ae40 | 9828 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9829 | protocol = ZEBRA_ROUTE_OSPF; |
9830 | else | |
9831 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 9832 | |
c500ae40 DW |
9833 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
9834 | VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); | |
7a4bb9c5 | 9835 | |
cdc2d765 DL |
9836 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
9837 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
c500ae40 | 9838 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9839 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); |
7c8ff89e DS |
9840 | } |
9841 | ||
9842 | DEFUN (no_bgp_redistribute_ipv4_ospf, | |
9843 | no_bgp_redistribute_ipv4_ospf_cmd, | |
d04c479d | 9844 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", |
7c8ff89e DS |
9845 | NO_STR |
9846 | "Redistribute information from another routing protocol\n" | |
9847 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 9848 | "Non-main Kernel Routing Table\n" |
31500417 DW |
9849 | "Instance ID/Table ID\n" |
9850 | "Metric for redistributed routes\n" | |
9851 | "Default metric\n" | |
9852 | "Route map reference\n" | |
9853 | "Pointer to route-map entries\n") | |
7c8ff89e | 9854 | { |
cdc2d765 | 9855 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9856 | int idx_ospf_table = 2; |
9857 | int idx_number = 3; | |
7c8ff89e | 9858 | u_short instance; |
7a4bb9c5 DS |
9859 | int protocol; |
9860 | ||
c500ae40 | 9861 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9862 | protocol = ZEBRA_ROUTE_OSPF; |
9863 | else | |
9864 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 9865 | |
c500ae40 | 9866 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
cdc2d765 | 9867 | return bgp_redistribute_unset (bgp, AFI_IP, protocol, instance); |
7c8ff89e DS |
9868 | } |
9869 | ||
718e3744 | 9870 | DEFUN (no_bgp_redistribute_ipv4, |
9871 | no_bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 9872 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 9873 | NO_STR |
9874 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 9875 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
9876 | "Metric for redistributed routes\n" |
9877 | "Default metric\n" | |
9878 | "Route map reference\n" | |
9879 | "Pointer to route-map entries\n") | |
718e3744 | 9880 | { |
cdc2d765 | 9881 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 9882 | int idx_protocol = 2; |
718e3744 | 9883 | int type; |
9884 | ||
6d681bd8 QY |
9885 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9886 | if (type < 0) | |
718e3744 | 9887 | { |
9888 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9889 | return CMD_WARNING; | |
9890 | } | |
cdc2d765 | 9891 | return bgp_redistribute_unset (bgp, AFI_IP, type, 0); |
718e3744 | 9892 | } |
9893 | ||
718e3744 | 9894 | DEFUN (bgp_redistribute_ipv6, |
9895 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 9896 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 9897 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9898 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 9899 | { |
cdc2d765 | 9900 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 9901 | int idx_protocol = 1; |
718e3744 | 9902 | int type; |
9903 | ||
6d681bd8 QY |
9904 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9905 | if (type < 0) | |
718e3744 | 9906 | { |
9907 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9908 | return CMD_WARNING; | |
9909 | } | |
9910 | ||
cdc2d765 DL |
9911 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
9912 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); | |
718e3744 | 9913 | } |
9914 | ||
9915 | DEFUN (bgp_redistribute_ipv6_rmap, | |
9916 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 9917 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 9918 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9919 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 9920 | "Route map reference\n" |
9921 | "Pointer to route-map entries\n") | |
9922 | { | |
cdc2d765 | 9923 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9924 | int idx_protocol = 1; |
9925 | int idx_word = 3; | |
718e3744 | 9926 | int type; |
7c8ff89e | 9927 | struct bgp_redist *red; |
718e3744 | 9928 | |
6d681bd8 QY |
9929 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9930 | if (type < 0) | |
718e3744 | 9931 | { |
9932 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9933 | return CMD_WARNING; | |
9934 | } | |
9935 | ||
cdc2d765 | 9936 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
c500ae40 | 9937 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9938 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); |
718e3744 | 9939 | } |
9940 | ||
9941 | DEFUN (bgp_redistribute_ipv6_metric, | |
9942 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 9943 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 9944 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9945 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 9946 | "Metric for redistributed routes\n" |
9947 | "Default metric\n") | |
9948 | { | |
cdc2d765 | 9949 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9950 | int idx_protocol = 1; |
9951 | int idx_number = 3; | |
718e3744 | 9952 | int type; |
9953 | u_int32_t metric; | |
7c8ff89e | 9954 | struct bgp_redist *red; |
718e3744 | 9955 | |
6d681bd8 QY |
9956 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9957 | if (type < 0) | |
718e3744 | 9958 | { |
9959 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9960 | return CMD_WARNING; | |
9961 | } | |
c500ae40 | 9962 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9963 | |
cdc2d765 DL |
9964 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
9965 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
9966 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); | |
718e3744 | 9967 | } |
9968 | ||
9969 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
9970 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 9971 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 9972 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9973 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 9974 | "Route map reference\n" |
9975 | "Pointer to route-map entries\n" | |
9976 | "Metric for redistributed routes\n" | |
9977 | "Default metric\n") | |
9978 | { | |
cdc2d765 | 9979 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9980 | int idx_protocol = 1; |
9981 | int idx_word = 3; | |
9982 | int idx_number = 5; | |
718e3744 | 9983 | int type; |
9984 | u_int32_t metric; | |
7c8ff89e | 9985 | struct bgp_redist *red; |
718e3744 | 9986 | |
6d681bd8 QY |
9987 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9988 | if (type < 0) | |
718e3744 | 9989 | { |
9990 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9991 | return CMD_WARNING; | |
9992 | } | |
c500ae40 | 9993 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9994 | |
cdc2d765 | 9995 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
c500ae40 | 9996 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 DL |
9997 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); |
9998 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); | |
718e3744 | 9999 | } |
10000 | ||
10001 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
10002 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 10003 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 10004 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10005 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 10006 | "Metric for redistributed routes\n" |
10007 | "Default metric\n" | |
10008 | "Route map reference\n" | |
10009 | "Pointer to route-map entries\n") | |
10010 | { | |
cdc2d765 | 10011 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
10012 | int idx_protocol = 1; |
10013 | int idx_number = 3; | |
10014 | int idx_word = 5; | |
718e3744 | 10015 | int type; |
10016 | u_int32_t metric; | |
7c8ff89e | 10017 | struct bgp_redist *red; |
718e3744 | 10018 | |
6d681bd8 QY |
10019 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
10020 | if (type < 0) | |
718e3744 | 10021 | { |
10022 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
10023 | return CMD_WARNING; | |
10024 | } | |
c500ae40 | 10025 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 10026 | |
cdc2d765 DL |
10027 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
10028 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, metric); | |
c500ae40 | 10029 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 10030 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); |
718e3744 | 10031 | } |
10032 | ||
10033 | DEFUN (no_bgp_redistribute_ipv6, | |
10034 | no_bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 10035 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 10036 | NO_STR |
10037 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 10038 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
10039 | "Metric for redistributed routes\n" |
10040 | "Default metric\n" | |
10041 | "Route map reference\n" | |
10042 | "Pointer to route-map entries\n") | |
718e3744 | 10043 | { |
cdc2d765 | 10044 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 10045 | int idx_protocol = 2; |
718e3744 | 10046 | int type; |
10047 | ||
6d681bd8 QY |
10048 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
10049 | if (type < 0) | |
718e3744 | 10050 | { |
10051 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
10052 | return CMD_WARNING; | |
10053 | } | |
10054 | ||
cdc2d765 | 10055 | return bgp_redistribute_unset (bgp, AFI_IP6, type, 0); |
718e3744 | 10056 | } |
6b0655a2 | 10057 | |
718e3744 | 10058 | int |
10059 | bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi, | |
10060 | safi_t safi, int *write) | |
10061 | { | |
10062 | int i; | |
718e3744 | 10063 | |
10064 | /* Unicast redistribution only. */ | |
10065 | if (safi != SAFI_UNICAST) | |
10066 | return 0; | |
10067 | ||
10068 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) | |
10069 | { | |
10070 | /* Redistribute BGP does not make sense. */ | |
7c8ff89e | 10071 | if (i != ZEBRA_ROUTE_BGP) |
718e3744 | 10072 | { |
7c8ff89e DS |
10073 | struct list *red_list; |
10074 | struct listnode *node; | |
10075 | struct bgp_redist *red; | |
718e3744 | 10076 | |
7c8ff89e DS |
10077 | red_list = bgp->redist[afi][i]; |
10078 | if (!red_list) | |
10079 | continue; | |
718e3744 | 10080 | |
7c8ff89e DS |
10081 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) |
10082 | { | |
10083 | /* Display "address-family" when it is not yet diplayed. */ | |
10084 | bgp_config_write_family_header (vty, afi, safi, write); | |
10085 | ||
10086 | /* "redistribute" configuration. */ | |
0b960b4d | 10087 | vty_out (vty, " redistribute %s", zebra_route_string(i)); |
7c8ff89e DS |
10088 | if (red->instance) |
10089 | vty_out (vty, " %d", red->instance); | |
10090 | if (red->redist_metric_flag) | |
10091 | vty_out (vty, " metric %u", red->redist_metric); | |
10092 | if (red->rmap.name) | |
10093 | vty_out (vty, " route-map %s", red->rmap.name); | |
10094 | vty_out (vty, "%s", VTY_NEWLINE); | |
10095 | } | |
718e3744 | 10096 | } |
10097 | } | |
10098 | return *write; | |
10099 | } | |
6b0655a2 | 10100 | |
718e3744 | 10101 | /* BGP node structure. */ |
7fc626de | 10102 | static struct cmd_node bgp_node = |
718e3744 | 10103 | { |
10104 | BGP_NODE, | |
10105 | "%s(config-router)# ", | |
10106 | 1, | |
10107 | }; | |
10108 | ||
7fc626de | 10109 | static struct cmd_node bgp_ipv4_unicast_node = |
718e3744 | 10110 | { |
10111 | BGP_IPV4_NODE, | |
10112 | "%s(config-router-af)# ", | |
10113 | 1, | |
10114 | }; | |
10115 | ||
7fc626de | 10116 | static struct cmd_node bgp_ipv4_multicast_node = |
718e3744 | 10117 | { |
10118 | BGP_IPV4M_NODE, | |
10119 | "%s(config-router-af)# ", | |
10120 | 1, | |
10121 | }; | |
10122 | ||
f51bae9c DS |
10123 | static struct cmd_node bgp_ipv4_labeled_unicast_node = |
10124 | { | |
10125 | BGP_IPV4L_NODE, | |
10126 | "%s(config-router-af)# ", | |
10127 | 1, | |
10128 | }; | |
10129 | ||
7fc626de | 10130 | static struct cmd_node bgp_ipv6_unicast_node = |
718e3744 | 10131 | { |
10132 | BGP_IPV6_NODE, | |
10133 | "%s(config-router-af)# ", | |
10134 | 1, | |
10135 | }; | |
10136 | ||
7fc626de | 10137 | static struct cmd_node bgp_ipv6_multicast_node = |
25ffbdc1 | 10138 | { |
10139 | BGP_IPV6M_NODE, | |
10140 | "%s(config-router-af)# ", | |
10141 | 1, | |
10142 | }; | |
10143 | ||
f51bae9c DS |
10144 | static struct cmd_node bgp_ipv6_labeled_unicast_node = |
10145 | { | |
10146 | BGP_IPV6L_NODE, | |
10147 | "%s(config-router-af)# ", | |
10148 | 1, | |
10149 | }; | |
10150 | ||
7fc626de | 10151 | static struct cmd_node bgp_vpnv4_node = |
718e3744 | 10152 | { |
10153 | BGP_VPNV4_NODE, | |
10154 | "%s(config-router-af)# ", | |
10155 | 1 | |
10156 | }; | |
6b0655a2 | 10157 | |
8ecd3266 | 10158 | static struct cmd_node bgp_vpnv6_node = |
10159 | { | |
10160 | BGP_VPNV6_NODE, | |
10161 | "%s(config-router-af-vpnv6)# ", | |
10162 | 1 | |
10163 | }; | |
10164 | ||
8b1fb8be LB |
10165 | static struct cmd_node bgp_encap_node = |
10166 | { | |
10167 | BGP_ENCAP_NODE, | |
10168 | "%s(config-router-af-encap)# ", | |
10169 | 1 | |
10170 | }; | |
10171 | ||
10172 | static struct cmd_node bgp_encapv6_node = | |
10173 | { | |
10174 | BGP_ENCAPV6_NODE, | |
10175 | "%s(config-router-af-encapv6)# ", | |
10176 | 1 | |
10177 | }; | |
10178 | ||
4e0b7b6d PG |
10179 | static struct cmd_node bgp_evpn_node = |
10180 | { | |
10181 | BGP_EVPN_NODE, | |
10182 | "%s(config-router-evpn)# ", | |
10183 | 1 | |
10184 | }; | |
10185 | ||
1f8ae70b | 10186 | static void community_list_vty (void); |
10187 | ||
718e3744 | 10188 | void |
94f2b392 | 10189 | bgp_vty_init (void) |
718e3744 | 10190 | { |
718e3744 | 10191 | /* Install bgp top node. */ |
10192 | install_node (&bgp_node, bgp_config_write); | |
10193 | install_node (&bgp_ipv4_unicast_node, NULL); | |
10194 | install_node (&bgp_ipv4_multicast_node, NULL); | |
f51bae9c | 10195 | install_node (&bgp_ipv4_labeled_unicast_node, NULL); |
718e3744 | 10196 | install_node (&bgp_ipv6_unicast_node, NULL); |
25ffbdc1 | 10197 | install_node (&bgp_ipv6_multicast_node, NULL); |
f51bae9c | 10198 | install_node (&bgp_ipv6_labeled_unicast_node, NULL); |
718e3744 | 10199 | install_node (&bgp_vpnv4_node, NULL); |
8ecd3266 | 10200 | install_node (&bgp_vpnv6_node, NULL); |
8b1fb8be LB |
10201 | install_node (&bgp_encap_node, NULL); |
10202 | install_node (&bgp_encapv6_node, NULL); | |
4e0b7b6d | 10203 | install_node (&bgp_evpn_node, NULL); |
718e3744 | 10204 | |
10205 | /* Install default VTY commands to new nodes. */ | |
10206 | install_default (BGP_NODE); | |
10207 | install_default (BGP_IPV4_NODE); | |
10208 | install_default (BGP_IPV4M_NODE); | |
f51bae9c | 10209 | install_default (BGP_IPV4L_NODE); |
718e3744 | 10210 | install_default (BGP_IPV6_NODE); |
25ffbdc1 | 10211 | install_default (BGP_IPV6M_NODE); |
f51bae9c | 10212 | install_default (BGP_IPV6L_NODE); |
718e3744 | 10213 | install_default (BGP_VPNV4_NODE); |
8ecd3266 | 10214 | install_default (BGP_VPNV6_NODE); |
8b1fb8be LB |
10215 | install_default (BGP_ENCAP_NODE); |
10216 | install_default (BGP_ENCAPV6_NODE); | |
4e0b7b6d | 10217 | install_default (BGP_EVPN_NODE); |
e52702f2 | 10218 | |
718e3744 | 10219 | /* "bgp multiple-instance" commands. */ |
10220 | install_element (CONFIG_NODE, &bgp_multiple_instance_cmd); | |
10221 | install_element (CONFIG_NODE, &no_bgp_multiple_instance_cmd); | |
10222 | ||
10223 | /* "bgp config-type" commands. */ | |
10224 | install_element (CONFIG_NODE, &bgp_config_type_cmd); | |
8c3deaae | 10225 | install_element (CONFIG_NODE, &no_bgp_config_type_cmd); |
718e3744 | 10226 | |
5fe9f963 | 10227 | /* bgp route-map delay-timer commands. */ |
10228 | install_element (CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
10229 | install_element (CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
5fe9f963 | 10230 | |
718e3744 | 10231 | /* Dummy commands (Currently not supported) */ |
10232 | install_element (BGP_NODE, &no_synchronization_cmd); | |
10233 | install_element (BGP_NODE, &no_auto_summary_cmd); | |
10234 | ||
10235 | /* "router bgp" commands. */ | |
10236 | install_element (CONFIG_NODE, &router_bgp_cmd); | |
718e3744 | 10237 | |
10238 | /* "no router bgp" commands. */ | |
10239 | install_element (CONFIG_NODE, &no_router_bgp_cmd); | |
718e3744 | 10240 | |
10241 | /* "bgp router-id" commands. */ | |
10242 | install_element (BGP_NODE, &bgp_router_id_cmd); | |
10243 | install_element (BGP_NODE, &no_bgp_router_id_cmd); | |
718e3744 | 10244 | |
10245 | /* "bgp cluster-id" commands. */ | |
10246 | install_element (BGP_NODE, &bgp_cluster_id_cmd); | |
718e3744 | 10247 | install_element (BGP_NODE, &no_bgp_cluster_id_cmd); |
718e3744 | 10248 | |
10249 | /* "bgp confederation" commands. */ | |
10250 | install_element (BGP_NODE, &bgp_confederation_identifier_cmd); | |
10251 | install_element (BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
718e3744 | 10252 | |
10253 | /* "bgp confederation peers" commands. */ | |
10254 | install_element (BGP_NODE, &bgp_confederation_peers_cmd); | |
10255 | install_element (BGP_NODE, &no_bgp_confederation_peers_cmd); | |
10256 | ||
abc920f8 DS |
10257 | /* bgp max-med command */ |
10258 | install_element (BGP_NODE, &bgp_maxmed_admin_cmd); | |
10259 | install_element (BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
10260 | install_element (BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
abc920f8 DS |
10261 | install_element (BGP_NODE, &bgp_maxmed_onstartup_cmd); |
10262 | install_element (BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
abc920f8 | 10263 | install_element (BGP_NODE, &bgp_maxmed_onstartup_medv_cmd); |
abc920f8 | 10264 | |
907f92c8 DS |
10265 | /* bgp disable-ebgp-connected-nh-check */ |
10266 | install_element (BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
10267 | install_element (BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
10268 | ||
f188f2c4 DS |
10269 | /* bgp update-delay command */ |
10270 | install_element (BGP_NODE, &bgp_update_delay_cmd); | |
10271 | install_element (BGP_NODE, &no_bgp_update_delay_cmd); | |
10272 | install_element (BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
f188f2c4 | 10273 | |
cb1faec9 DS |
10274 | install_element (BGP_NODE, &bgp_wpkt_quanta_cmd); |
10275 | install_element (BGP_NODE, &no_bgp_wpkt_quanta_cmd); | |
10276 | ||
3f9c7369 DS |
10277 | install_element (BGP_NODE, &bgp_coalesce_time_cmd); |
10278 | install_element (BGP_NODE, &no_bgp_coalesce_time_cmd); | |
10279 | ||
165b5fff JB |
10280 | /* "maximum-paths" commands. */ |
10281 | install_element (BGP_NODE, &bgp_maxpaths_cmd); | |
10282 | install_element (BGP_NODE, &no_bgp_maxpaths_cmd); | |
165b5fff JB |
10283 | install_element (BGP_IPV4_NODE, &bgp_maxpaths_cmd); |
10284 | install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
431aa9f9 DS |
10285 | install_element (BGP_IPV6_NODE, &bgp_maxpaths_cmd); |
10286 | install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
165b5fff | 10287 | install_element (BGP_NODE, &bgp_maxpaths_ibgp_cmd); |
f51bae9c | 10288 | install_element (BGP_NODE, &bgp_maxpaths_ibgp_cluster_cmd); |
165b5fff | 10289 | install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_cmd); |
165b5fff | 10290 | install_element (BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); |
f51bae9c | 10291 | install_element (BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); |
165b5fff | 10292 | install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); |
431aa9f9 | 10293 | install_element (BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); |
f51bae9c | 10294 | install_element (BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); |
431aa9f9 | 10295 | install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); |
165b5fff | 10296 | |
f51bae9c DS |
10297 | install_element (BGP_IPV4L_NODE, &bgp_maxpaths_cmd); |
10298 | install_element (BGP_IPV4L_NODE, &no_bgp_maxpaths_cmd); | |
10299 | install_element (BGP_IPV6L_NODE, &bgp_maxpaths_cmd); | |
10300 | install_element (BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
10301 | ||
10302 | install_element (BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cmd); | |
10303 | install_element (BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
10304 | install_element (BGP_IPV4L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
10305 | install_element (BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
10306 | install_element (BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
10307 | install_element (BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
10308 | ||
718e3744 | 10309 | /* "timers bgp" commands. */ |
10310 | install_element (BGP_NODE, &bgp_timers_cmd); | |
10311 | install_element (BGP_NODE, &no_bgp_timers_cmd); | |
718e3744 | 10312 | |
5fe9f963 | 10313 | /* route-map delay-timer commands - per instance for backwards compat. */ |
518f0eb1 DS |
10314 | install_element (BGP_NODE, &bgp_set_route_map_delay_timer_cmd); |
10315 | install_element (BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
10316 | ||
718e3744 | 10317 | /* "bgp client-to-client reflection" commands */ |
10318 | install_element (BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
10319 | install_element (BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
10320 | ||
10321 | /* "bgp always-compare-med" commands */ | |
10322 | install_element (BGP_NODE, &bgp_always_compare_med_cmd); | |
10323 | install_element (BGP_NODE, &no_bgp_always_compare_med_cmd); | |
e52702f2 | 10324 | |
718e3744 | 10325 | /* "bgp deterministic-med" commands */ |
10326 | install_element (BGP_NODE, &bgp_deterministic_med_cmd); | |
10327 | install_element (BGP_NODE, &no_bgp_deterministic_med_cmd); | |
538621f2 | 10328 | |
538621f2 | 10329 | /* "bgp graceful-restart" commands */ |
10330 | install_element (BGP_NODE, &bgp_graceful_restart_cmd); | |
10331 | install_element (BGP_NODE, &no_bgp_graceful_restart_cmd); | |
93406d87 | 10332 | install_element (BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
10333 | install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
eb6f1b41 PG |
10334 | install_element (BGP_NODE, &bgp_graceful_restart_restart_time_cmd); |
10335 | install_element (BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
e52702f2 | 10336 | |
43fc21b3 JC |
10337 | install_element (BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
10338 | install_element (BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
10339 | ||
718e3744 | 10340 | /* "bgp fast-external-failover" commands */ |
10341 | install_element (BGP_NODE, &bgp_fast_external_failover_cmd); | |
10342 | install_element (BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
10343 | ||
10344 | /* "bgp enforce-first-as" commands */ | |
10345 | install_element (BGP_NODE, &bgp_enforce_first_as_cmd); | |
10346 | install_element (BGP_NODE, &no_bgp_enforce_first_as_cmd); | |
10347 | ||
10348 | /* "bgp bestpath compare-routerid" commands */ | |
10349 | install_element (BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
10350 | install_element (BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
10351 | ||
10352 | /* "bgp bestpath as-path ignore" commands */ | |
10353 | install_element (BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
10354 | install_element (BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
10355 | ||
6811845b | 10356 | /* "bgp bestpath as-path confed" commands */ |
10357 | install_element (BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
10358 | install_element (BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
10359 | ||
2fdd455c PM |
10360 | /* "bgp bestpath as-path multipath-relax" commands */ |
10361 | install_element (BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
10362 | install_element (BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
10363 | ||
848973c7 | 10364 | /* "bgp log-neighbor-changes" commands */ |
10365 | install_element (BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
10366 | install_element (BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
10367 | ||
718e3744 | 10368 | /* "bgp bestpath med" commands */ |
10369 | install_element (BGP_NODE, &bgp_bestpath_med_cmd); | |
718e3744 | 10370 | install_element (BGP_NODE, &no_bgp_bestpath_med_cmd); |
718e3744 | 10371 | |
10372 | /* "no bgp default ipv4-unicast" commands. */ | |
10373 | install_element (BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
10374 | install_element (BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
e52702f2 | 10375 | |
718e3744 | 10376 | /* "bgp network import-check" commands. */ |
10377 | install_element (BGP_NODE, &bgp_network_import_check_cmd); | |
8233ef81 | 10378 | install_element (BGP_NODE, &bgp_network_import_check_exact_cmd); |
718e3744 | 10379 | install_element (BGP_NODE, &no_bgp_network_import_check_cmd); |
10380 | ||
10381 | /* "bgp default local-preference" commands. */ | |
10382 | install_element (BGP_NODE, &bgp_default_local_preference_cmd); | |
10383 | install_element (BGP_NODE, &no_bgp_default_local_preference_cmd); | |
718e3744 | 10384 | |
04b6bdc0 DW |
10385 | /* bgp default show-hostname */ |
10386 | install_element (BGP_NODE, &bgp_default_show_hostname_cmd); | |
10387 | install_element (BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
10388 | ||
3f9c7369 DS |
10389 | /* "bgp default subgroup-pkt-queue-max" commands. */ |
10390 | install_element (BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
10391 | install_element (BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
10392 | ||
8bd9d948 DS |
10393 | /* bgp ibgp-allow-policy-mods command */ |
10394 | install_element (BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
10395 | install_element (BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
10396 | ||
f14e6fdb DS |
10397 | /* "bgp listen limit" commands. */ |
10398 | install_element (BGP_NODE, &bgp_listen_limit_cmd); | |
10399 | install_element (BGP_NODE, &no_bgp_listen_limit_cmd); | |
10400 | ||
10401 | /* "bgp listen range" commands. */ | |
10402 | install_element (BGP_NODE, &bgp_listen_range_cmd); | |
10403 | install_element (BGP_NODE, &no_bgp_listen_range_cmd); | |
10404 | ||
718e3744 | 10405 | /* "neighbor remote-as" commands. */ |
10406 | install_element (BGP_NODE, &neighbor_remote_as_cmd); | |
a80beece | 10407 | install_element (BGP_NODE, &neighbor_interface_config_cmd); |
4c48cf63 | 10408 | install_element (BGP_NODE, &neighbor_interface_config_v6only_cmd); |
b3a39dc5 DD |
10409 | install_element (BGP_NODE, &neighbor_interface_config_remote_as_cmd); |
10410 | install_element (BGP_NODE, &neighbor_interface_v6only_config_remote_as_cmd); | |
718e3744 | 10411 | install_element (BGP_NODE, &no_neighbor_cmd); |
a80beece | 10412 | install_element (BGP_NODE, &no_neighbor_interface_config_cmd); |
718e3744 | 10413 | |
10414 | /* "neighbor peer-group" commands. */ | |
10415 | install_element (BGP_NODE, &neighbor_peer_group_cmd); | |
10416 | install_element (BGP_NODE, &no_neighbor_peer_group_cmd); | |
a80beece | 10417 | install_element (BGP_NODE, &no_neighbor_interface_peer_group_remote_as_cmd); |
718e3744 | 10418 | |
10419 | /* "neighbor local-as" commands. */ | |
10420 | install_element (BGP_NODE, &neighbor_local_as_cmd); | |
10421 | install_element (BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
9d3f9705 | 10422 | install_element (BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); |
718e3744 | 10423 | install_element (BGP_NODE, &no_neighbor_local_as_cmd); |
718e3744 | 10424 | |
3f9c7369 DS |
10425 | /* "neighbor solo" commands. */ |
10426 | install_element (BGP_NODE, &neighbor_solo_cmd); | |
10427 | install_element (BGP_NODE, &no_neighbor_solo_cmd); | |
10428 | ||
0df7c91f PJ |
10429 | /* "neighbor password" commands. */ |
10430 | install_element (BGP_NODE, &neighbor_password_cmd); | |
10431 | install_element (BGP_NODE, &no_neighbor_password_cmd); | |
10432 | ||
718e3744 | 10433 | /* "neighbor activate" commands. */ |
10434 | install_element (BGP_NODE, &neighbor_activate_cmd); | |
10435 | install_element (BGP_IPV4_NODE, &neighbor_activate_cmd); | |
10436 | install_element (BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
f51bae9c | 10437 | install_element (BGP_IPV4L_NODE, &neighbor_activate_cmd); |
718e3744 | 10438 | install_element (BGP_IPV6_NODE, &neighbor_activate_cmd); |
25ffbdc1 | 10439 | install_element (BGP_IPV6M_NODE, &neighbor_activate_cmd); |
f51bae9c | 10440 | install_element (BGP_IPV6L_NODE, &neighbor_activate_cmd); |
718e3744 | 10441 | install_element (BGP_VPNV4_NODE, &neighbor_activate_cmd); |
8ecd3266 | 10442 | install_element (BGP_VPNV6_NODE, &neighbor_activate_cmd); |
8b1fb8be LB |
10443 | install_element (BGP_ENCAP_NODE, &neighbor_activate_cmd); |
10444 | install_element (BGP_ENCAPV6_NODE, &neighbor_activate_cmd); | |
4e0b7b6d | 10445 | install_element (BGP_EVPN_NODE, &neighbor_activate_cmd); |
718e3744 | 10446 | |
10447 | /* "no neighbor activate" commands. */ | |
10448 | install_element (BGP_NODE, &no_neighbor_activate_cmd); | |
10449 | install_element (BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
10450 | install_element (BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
f51bae9c | 10451 | install_element (BGP_IPV4L_NODE, &no_neighbor_activate_cmd); |
718e3744 | 10452 | install_element (BGP_IPV6_NODE, &no_neighbor_activate_cmd); |
25ffbdc1 | 10453 | install_element (BGP_IPV6M_NODE, &no_neighbor_activate_cmd); |
f51bae9c | 10454 | install_element (BGP_IPV6L_NODE, &no_neighbor_activate_cmd); |
718e3744 | 10455 | install_element (BGP_VPNV4_NODE, &no_neighbor_activate_cmd); |
8ecd3266 | 10456 | install_element (BGP_VPNV6_NODE, &no_neighbor_activate_cmd); |
8b1fb8be LB |
10457 | install_element (BGP_ENCAP_NODE, &no_neighbor_activate_cmd); |
10458 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_activate_cmd); | |
4e0b7b6d | 10459 | install_element (BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
718e3744 | 10460 | |
c8560b44 DW |
10461 | /* "neighbor peer-group" set commands. |
10462 | * Long term we should only accept this command under BGP_NODE and not all of | |
10463 | * the afi/safi sub-contexts. For now though we need to accept it for backwards | |
10464 | * compatibility. This changed when we stopped requiring that peers be assigned | |
10465 | * to their peer-group under each address-family sub-context. | |
10466 | */ | |
718e3744 | 10467 | install_element (BGP_NODE, &neighbor_set_peer_group_cmd); |
10468 | install_element (BGP_IPV4_NODE, &neighbor_set_peer_group_cmd); | |
10469 | install_element (BGP_IPV4M_NODE, &neighbor_set_peer_group_cmd); | |
f51bae9c | 10470 | install_element (BGP_IPV4L_NODE, &neighbor_set_peer_group_cmd); |
718e3744 | 10471 | install_element (BGP_IPV6_NODE, &neighbor_set_peer_group_cmd); |
25ffbdc1 | 10472 | install_element (BGP_IPV6M_NODE, &neighbor_set_peer_group_cmd); |
f51bae9c | 10473 | install_element (BGP_IPV6L_NODE, &neighbor_set_peer_group_cmd); |
a58545bb | 10474 | install_element (BGP_VPNV4_NODE, &neighbor_set_peer_group_cmd); |
8ecd3266 | 10475 | install_element (BGP_VPNV6_NODE, &neighbor_set_peer_group_cmd); |
8b1fb8be LB |
10476 | install_element (BGP_ENCAP_NODE, &neighbor_set_peer_group_cmd); |
10477 | install_element (BGP_ENCAPV6_NODE, &neighbor_set_peer_group_cmd); | |
c8560b44 | 10478 | |
718e3744 | 10479 | /* "no neighbor peer-group unset" commands. */ |
10480 | install_element (BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
10481 | install_element (BGP_IPV4_NODE, &no_neighbor_set_peer_group_cmd); | |
10482 | install_element (BGP_IPV4M_NODE, &no_neighbor_set_peer_group_cmd); | |
f51bae9c | 10483 | install_element (BGP_IPV4L_NODE, &no_neighbor_set_peer_group_cmd); |
718e3744 | 10484 | install_element (BGP_IPV6_NODE, &no_neighbor_set_peer_group_cmd); |
25ffbdc1 | 10485 | install_element (BGP_IPV6M_NODE, &no_neighbor_set_peer_group_cmd); |
f51bae9c | 10486 | install_element (BGP_IPV6L_NODE, &no_neighbor_set_peer_group_cmd); |
a58545bb | 10487 | install_element (BGP_VPNV4_NODE, &no_neighbor_set_peer_group_cmd); |
8ecd3266 | 10488 | install_element (BGP_VPNV6_NODE, &no_neighbor_set_peer_group_cmd); |
8b1fb8be LB |
10489 | install_element (BGP_ENCAP_NODE, &no_neighbor_set_peer_group_cmd); |
10490 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_set_peer_group_cmd); | |
e52702f2 | 10491 | |
718e3744 | 10492 | /* "neighbor softreconfiguration inbound" commands.*/ |
10493 | install_element (BGP_NODE, &neighbor_soft_reconfiguration_cmd); | |
10494 | install_element (BGP_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
10495 | install_element (BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
10496 | install_element (BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
f51bae9c DS |
10497 | install_element (BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); |
10498 | install_element (BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
718e3744 | 10499 | install_element (BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); |
10500 | install_element (BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
10501 | install_element (BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
10502 | install_element (BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
25ffbdc1 | 10503 | install_element (BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); |
10504 | install_element (BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
f51bae9c DS |
10505 | install_element (BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); |
10506 | install_element (BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
a58545bb | 10507 | install_element (BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); |
10508 | install_element (BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
8ecd3266 | 10509 | install_element (BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); |
10510 | install_element (BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
8b1fb8be LB |
10511 | install_element (BGP_ENCAP_NODE, &neighbor_soft_reconfiguration_cmd); |
10512 | install_element (BGP_ENCAP_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
10513 | install_element (BGP_ENCAPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
10514 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
718e3744 | 10515 | |
10516 | /* "neighbor attribute-unchanged" commands. */ | |
10517 | install_element (BGP_NODE, &neighbor_attr_unchanged_cmd); | |
718e3744 | 10518 | install_element (BGP_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10519 | install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 10520 | install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10521 | install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 10522 | install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); |
f51bae9c DS |
10523 | install_element (BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); |
10524 | install_element (BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
718e3744 | 10525 | install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 10526 | install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); |
25ffbdc1 | 10527 | install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); |
25ffbdc1 | 10528 | install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); |
f51bae9c DS |
10529 | install_element (BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); |
10530 | install_element (BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
718e3744 | 10531 | install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 10532 | install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); |
8ecd3266 | 10533 | install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); |
8ecd3266 | 10534 | install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); |
8ecd3266 | 10535 | |
8b1fb8be | 10536 | install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged_cmd); |
8b1fb8be | 10537 | install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged_cmd); |
8b1fb8be LB |
10538 | |
10539 | install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged_cmd); | |
8b1fb8be | 10540 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10541 | |
4e0b7b6d PG |
10542 | install_element (BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); |
10543 | install_element (BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
10544 | ||
fee0f4c6 | 10545 | /* "nexthop-local unchanged" commands */ |
10546 | install_element (BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
10547 | install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_local_unchanged_cmd); | |
10548 | ||
718e3744 | 10549 | /* "neighbor next-hop-self" commands. */ |
10550 | install_element (BGP_NODE, &neighbor_nexthop_self_cmd); | |
10551 | install_element (BGP_NODE, &no_neighbor_nexthop_self_cmd); | |
10552 | install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
10553 | install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
10554 | install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
10555 | install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
f51bae9c DS |
10556 | install_element (BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); |
10557 | install_element (BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
718e3744 | 10558 | install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); |
10559 | install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
25ffbdc1 | 10560 | install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); |
10561 | install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
f51bae9c DS |
10562 | install_element (BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); |
10563 | install_element (BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
718e3744 | 10564 | install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); |
10565 | install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
8ecd3266 | 10566 | install_element (BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); |
10567 | install_element (BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
8b1fb8be LB |
10568 | install_element (BGP_ENCAP_NODE, &neighbor_nexthop_self_cmd); |
10569 | install_element (BGP_ENCAP_NODE, &no_neighbor_nexthop_self_cmd); | |
10570 | install_element (BGP_ENCAPV6_NODE, &neighbor_nexthop_self_cmd); | |
10571 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
718e3744 | 10572 | |
a538debe DS |
10573 | /* "neighbor next-hop-self force" commands. */ |
10574 | install_element (BGP_NODE, &neighbor_nexthop_self_force_cmd); | |
10575 | install_element (BGP_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10576 | install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); | |
10577 | install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10578 | install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); | |
10579 | install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
f51bae9c DS |
10580 | install_element (BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); |
10581 | install_element (BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
a538debe DS |
10582 | install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); |
10583 | install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10584 | install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); | |
10585 | install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
f51bae9c DS |
10586 | install_element (BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); |
10587 | install_element (BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
a538debe DS |
10588 | install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); |
10589 | install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
8ecd3266 | 10590 | install_element (BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
10591 | install_element (BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
a538debe | 10592 | |
c7122e14 DS |
10593 | /* "neighbor as-override" commands. */ |
10594 | install_element (BGP_NODE, &neighbor_as_override_cmd); | |
10595 | install_element (BGP_NODE, &no_neighbor_as_override_cmd); | |
10596 | install_element (BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
10597 | install_element (BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
10598 | install_element (BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
10599 | install_element (BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
f51bae9c DS |
10600 | install_element (BGP_IPV4L_NODE, &neighbor_as_override_cmd); |
10601 | install_element (BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
c7122e14 DS |
10602 | install_element (BGP_IPV6_NODE, &neighbor_as_override_cmd); |
10603 | install_element (BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
10604 | install_element (BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
10605 | install_element (BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
f51bae9c DS |
10606 | install_element (BGP_IPV6L_NODE, &neighbor_as_override_cmd); |
10607 | install_element (BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
c7122e14 DS |
10608 | install_element (BGP_VPNV4_NODE, &neighbor_as_override_cmd); |
10609 | install_element (BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
8ecd3266 | 10610 | install_element (BGP_VPNV6_NODE, &neighbor_as_override_cmd); |
10611 | install_element (BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
c7122e14 | 10612 | |
718e3744 | 10613 | /* "neighbor remove-private-AS" commands. */ |
10614 | install_element (BGP_NODE, &neighbor_remove_private_as_cmd); | |
10615 | install_element (BGP_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10616 | install_element (BGP_NODE, &neighbor_remove_private_as_all_cmd); |
10617 | install_element (BGP_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10618 | install_element (BGP_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10619 | install_element (BGP_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10620 | install_element (BGP_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10621 | install_element (BGP_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 10622 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); |
10623 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10624 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); |
10625 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10626 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10627 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10628 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10629 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 10630 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); |
10631 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10632 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); |
10633 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10634 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10635 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10636 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10637 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
f51bae9c DS |
10638 | install_element (BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); |
10639 | install_element (BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
10640 | install_element (BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
10641 | install_element (BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10642 | install_element (BGP_IPV4L_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10643 | install_element (BGP_IPV4L_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10644 | install_element (BGP_IPV4L_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10645 | install_element (BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 10646 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); |
10647 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10648 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); |
10649 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10650 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10651 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10652 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10653 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
25ffbdc1 | 10654 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); |
10655 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10656 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); |
10657 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10658 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10659 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10660 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10661 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
f51bae9c DS |
10662 | install_element (BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); |
10663 | install_element (BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
10664 | install_element (BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
10665 | install_element (BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10666 | install_element (BGP_IPV6L_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10667 | install_element (BGP_IPV6L_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10668 | install_element (BGP_IPV6L_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10669 | install_element (BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 10670 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); |
10671 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10672 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); |
10673 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10674 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10675 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10676 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10677 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
8ecd3266 | 10678 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); |
10679 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
10680 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
10681 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10682 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10683 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10684 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10685 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
8b1fb8be LB |
10686 | install_element (BGP_ENCAP_NODE, &neighbor_remove_private_as_cmd); |
10687 | install_element (BGP_ENCAP_NODE, &no_neighbor_remove_private_as_cmd); | |
10688 | install_element (BGP_ENCAPV6_NODE, &neighbor_remove_private_as_cmd); | |
10689 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
718e3744 | 10690 | |
10691 | /* "neighbor send-community" commands.*/ | |
10692 | install_element (BGP_NODE, &neighbor_send_community_cmd); | |
10693 | install_element (BGP_NODE, &neighbor_send_community_type_cmd); | |
10694 | install_element (BGP_NODE, &no_neighbor_send_community_cmd); | |
10695 | install_element (BGP_NODE, &no_neighbor_send_community_type_cmd); | |
10696 | install_element (BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
10697 | install_element (BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
10698 | install_element (BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
10699 | install_element (BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
10700 | install_element (BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
10701 | install_element (BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
10702 | install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
10703 | install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
f51bae9c DS |
10704 | install_element (BGP_IPV4L_NODE, &neighbor_send_community_cmd); |
10705 | install_element (BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
10706 | install_element (BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
10707 | install_element (BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
718e3744 | 10708 | install_element (BGP_IPV6_NODE, &neighbor_send_community_cmd); |
10709 | install_element (BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
10710 | install_element (BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
10711 | install_element (BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
25ffbdc1 | 10712 | install_element (BGP_IPV6M_NODE, &neighbor_send_community_cmd); |
10713 | install_element (BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
10714 | install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
10715 | install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
f51bae9c DS |
10716 | install_element (BGP_IPV6L_NODE, &neighbor_send_community_cmd); |
10717 | install_element (BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
10718 | install_element (BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
10719 | install_element (BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
718e3744 | 10720 | install_element (BGP_VPNV4_NODE, &neighbor_send_community_cmd); |
10721 | install_element (BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
10722 | install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
10723 | install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
8ecd3266 | 10724 | install_element (BGP_VPNV6_NODE, &neighbor_send_community_cmd); |
10725 | install_element (BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
10726 | install_element (BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
10727 | install_element (BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
8b1fb8be LB |
10728 | install_element (BGP_ENCAP_NODE, &neighbor_send_community_cmd); |
10729 | install_element (BGP_ENCAP_NODE, &neighbor_send_community_type_cmd); | |
10730 | install_element (BGP_ENCAP_NODE, &no_neighbor_send_community_cmd); | |
10731 | install_element (BGP_ENCAP_NODE, &no_neighbor_send_community_type_cmd); | |
10732 | install_element (BGP_ENCAPV6_NODE, &neighbor_send_community_cmd); | |
10733 | install_element (BGP_ENCAPV6_NODE, &neighbor_send_community_type_cmd); | |
10734 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_send_community_cmd); | |
10735 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_send_community_type_cmd); | |
718e3744 | 10736 | |
10737 | /* "neighbor route-reflector" commands.*/ | |
10738 | install_element (BGP_NODE, &neighbor_route_reflector_client_cmd); | |
10739 | install_element (BGP_NODE, &no_neighbor_route_reflector_client_cmd); | |
10740 | install_element (BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
10741 | install_element (BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
10742 | install_element (BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
10743 | install_element (BGP_IPV4M_NODE, &no_neighbor_route_reflector_client_cmd); | |
f51bae9c DS |
10744 | install_element (BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); |
10745 | install_element (BGP_IPV4L_NODE, &no_neighbor_route_reflector_client_cmd); | |
718e3744 | 10746 | install_element (BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); |
10747 | install_element (BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
25ffbdc1 | 10748 | install_element (BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); |
10749 | install_element (BGP_IPV6M_NODE, &no_neighbor_route_reflector_client_cmd); | |
f51bae9c DS |
10750 | install_element (BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); |
10751 | install_element (BGP_IPV6L_NODE, &no_neighbor_route_reflector_client_cmd); | |
718e3744 | 10752 | install_element (BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); |
10753 | install_element (BGP_VPNV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
8ecd3266 | 10754 | install_element (BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); |
10755 | install_element (BGP_VPNV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
8b1fb8be LB |
10756 | install_element (BGP_ENCAP_NODE, &neighbor_route_reflector_client_cmd); |
10757 | install_element (BGP_ENCAP_NODE, &no_neighbor_route_reflector_client_cmd); | |
10758 | install_element (BGP_ENCAPV6_NODE, &neighbor_route_reflector_client_cmd); | |
10759 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
718e3744 | 10760 | |
10761 | /* "neighbor route-server" commands.*/ | |
10762 | install_element (BGP_NODE, &neighbor_route_server_client_cmd); | |
10763 | install_element (BGP_NODE, &no_neighbor_route_server_client_cmd); | |
10764 | install_element (BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
10765 | install_element (BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
10766 | install_element (BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
10767 | install_element (BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
f51bae9c DS |
10768 | install_element (BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); |
10769 | install_element (BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
718e3744 | 10770 | install_element (BGP_IPV6_NODE, &neighbor_route_server_client_cmd); |
10771 | install_element (BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
25ffbdc1 | 10772 | install_element (BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); |
10773 | install_element (BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
f51bae9c DS |
10774 | install_element (BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); |
10775 | install_element (BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
718e3744 | 10776 | install_element (BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); |
10777 | install_element (BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
8ecd3266 | 10778 | install_element (BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); |
10779 | install_element (BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
8b1fb8be LB |
10780 | install_element (BGP_ENCAP_NODE, &neighbor_route_server_client_cmd); |
10781 | install_element (BGP_ENCAP_NODE, &no_neighbor_route_server_client_cmd); | |
10782 | install_element (BGP_ENCAPV6_NODE, &neighbor_route_server_client_cmd); | |
10783 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_server_client_cmd); | |
718e3744 | 10784 | |
adbac85e DW |
10785 | /* "neighbor addpath-tx-all-paths" commands.*/ |
10786 | install_element (BGP_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10787 | install_element (BGP_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10788 | install_element (BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10789 | install_element (BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10790 | install_element (BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10791 | install_element (BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
f51bae9c DS |
10792 | install_element (BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); |
10793 | install_element (BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
adbac85e DW |
10794 | install_element (BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); |
10795 | install_element (BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10796 | install_element (BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10797 | install_element (BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
f51bae9c DS |
10798 | install_element (BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); |
10799 | install_element (BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
adbac85e DW |
10800 | install_element (BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); |
10801 | install_element (BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
8ecd3266 | 10802 | install_element (BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); |
10803 | install_element (BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
adbac85e | 10804 | |
06370dac DW |
10805 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ |
10806 | install_element (BGP_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10807 | install_element (BGP_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10808 | install_element (BGP_IPV4_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10809 | install_element (BGP_IPV4_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10810 | install_element (BGP_IPV4M_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10811 | install_element (BGP_IPV4M_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
f51bae9c DS |
10812 | install_element (BGP_IPV4L_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); |
10813 | install_element (BGP_IPV4L_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
06370dac DW |
10814 | install_element (BGP_IPV6_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); |
10815 | install_element (BGP_IPV6_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10816 | install_element (BGP_IPV6M_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10817 | install_element (BGP_IPV6M_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
f51bae9c DS |
10818 | install_element (BGP_IPV6L_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); |
10819 | install_element (BGP_IPV6L_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
06370dac DW |
10820 | install_element (BGP_VPNV4_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); |
10821 | install_element (BGP_VPNV4_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
8ecd3266 | 10822 | install_element (BGP_VPNV6_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); |
10823 | install_element (BGP_VPNV6_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
06370dac | 10824 | |
718e3744 | 10825 | /* "neighbor passive" commands. */ |
10826 | install_element (BGP_NODE, &neighbor_passive_cmd); | |
10827 | install_element (BGP_NODE, &no_neighbor_passive_cmd); | |
10828 | ||
d5a5c8f0 | 10829 | |
718e3744 | 10830 | /* "neighbor shutdown" commands. */ |
10831 | install_element (BGP_NODE, &neighbor_shutdown_cmd); | |
10832 | install_element (BGP_NODE, &no_neighbor_shutdown_cmd); | |
73d70fa6 DL |
10833 | install_element (BGP_NODE, &neighbor_shutdown_msg_cmd); |
10834 | install_element (BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
718e3744 | 10835 | |
8a92a8a0 DS |
10836 | /* "neighbor capability extended-nexthop" commands.*/ |
10837 | install_element (BGP_NODE, &neighbor_capability_enhe_cmd); | |
10838 | install_element (BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
10839 | ||
718e3744 | 10840 | /* "neighbor capability orf prefix-list" commands.*/ |
10841 | install_element (BGP_NODE, &neighbor_capability_orf_prefix_cmd); | |
10842 | install_element (BGP_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
10843 | install_element (BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
10844 | install_element (BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
10845 | install_element (BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
10846 | install_element (BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
f51bae9c DS |
10847 | install_element (BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); |
10848 | install_element (BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
718e3744 | 10849 | install_element (BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); |
10850 | install_element (BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
25ffbdc1 | 10851 | install_element (BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); |
10852 | install_element (BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
f51bae9c DS |
10853 | install_element (BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); |
10854 | install_element (BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
718e3744 | 10855 | |
10856 | /* "neighbor capability dynamic" commands.*/ | |
10857 | install_element (BGP_NODE, &neighbor_capability_dynamic_cmd); | |
10858 | install_element (BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
10859 | ||
10860 | /* "neighbor dont-capability-negotiate" commands. */ | |
10861 | install_element (BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
10862 | install_element (BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
10863 | ||
10864 | /* "neighbor ebgp-multihop" commands. */ | |
10865 | install_element (BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
10866 | install_element (BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
10867 | install_element (BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
718e3744 | 10868 | |
6ffd2079 | 10869 | /* "neighbor disable-connected-check" commands. */ |
10870 | install_element (BGP_NODE, &neighbor_disable_connected_check_cmd); | |
10871 | install_element (BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
718e3744 | 10872 | |
10873 | /* "neighbor description" commands. */ | |
10874 | install_element (BGP_NODE, &neighbor_description_cmd); | |
10875 | install_element (BGP_NODE, &no_neighbor_description_cmd); | |
718e3744 | 10876 | |
10877 | /* "neighbor update-source" commands. "*/ | |
10878 | install_element (BGP_NODE, &neighbor_update_source_cmd); | |
10879 | install_element (BGP_NODE, &no_neighbor_update_source_cmd); | |
10880 | ||
10881 | /* "neighbor default-originate" commands. */ | |
10882 | install_element (BGP_NODE, &neighbor_default_originate_cmd); | |
10883 | install_element (BGP_NODE, &neighbor_default_originate_rmap_cmd); | |
10884 | install_element (BGP_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 10885 | install_element (BGP_IPV4_NODE, &neighbor_default_originate_cmd); |
10886 | install_element (BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
10887 | install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 10888 | install_element (BGP_IPV4M_NODE, &neighbor_default_originate_cmd); |
10889 | install_element (BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
10890 | install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
f51bae9c DS |
10891 | install_element (BGP_IPV4L_NODE, &neighbor_default_originate_cmd); |
10892 | install_element (BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
10893 | install_element (BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 10894 | install_element (BGP_IPV6_NODE, &neighbor_default_originate_cmd); |
10895 | install_element (BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
10896 | install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
25ffbdc1 | 10897 | install_element (BGP_IPV6M_NODE, &neighbor_default_originate_cmd); |
10898 | install_element (BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
10899 | install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
f51bae9c DS |
10900 | install_element (BGP_IPV6L_NODE, &neighbor_default_originate_cmd); |
10901 | install_element (BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
10902 | install_element (BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 10903 | |
10904 | /* "neighbor port" commands. */ | |
10905 | install_element (BGP_NODE, &neighbor_port_cmd); | |
10906 | install_element (BGP_NODE, &no_neighbor_port_cmd); | |
718e3744 | 10907 | |
10908 | /* "neighbor weight" commands. */ | |
10909 | install_element (BGP_NODE, &neighbor_weight_cmd); | |
10910 | install_element (BGP_NODE, &no_neighbor_weight_cmd); | |
718e3744 | 10911 | |
d93f7ffc DW |
10912 | install_element (BGP_IPV4_NODE, &neighbor_weight_cmd); |
10913 | install_element (BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10914 | install_element (BGP_IPV4M_NODE, &neighbor_weight_cmd); |
10915 | install_element (BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
f51bae9c DS |
10916 | install_element (BGP_IPV4L_NODE, &neighbor_weight_cmd); |
10917 | install_element (BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10918 | install_element (BGP_IPV6_NODE, &neighbor_weight_cmd); |
10919 | install_element (BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10920 | install_element (BGP_IPV6M_NODE, &neighbor_weight_cmd); |
10921 | install_element (BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
f51bae9c DS |
10922 | install_element (BGP_IPV6L_NODE, &neighbor_weight_cmd); |
10923 | install_element (BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10924 | install_element (BGP_VPNV4_NODE, &neighbor_weight_cmd); |
10925 | install_element (BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10926 | install_element (BGP_VPNV6_NODE, &neighbor_weight_cmd); |
10927 | install_element (BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10928 | install_element (BGP_ENCAP_NODE, &neighbor_weight_cmd); |
10929 | install_element (BGP_ENCAP_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10930 | install_element (BGP_ENCAPV6_NODE, &neighbor_weight_cmd); |
10931 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_weight_cmd); | |
718e3744 | 10932 | |
10933 | /* "neighbor override-capability" commands. */ | |
10934 | install_element (BGP_NODE, &neighbor_override_capability_cmd); | |
10935 | install_element (BGP_NODE, &no_neighbor_override_capability_cmd); | |
10936 | ||
10937 | /* "neighbor strict-capability-match" commands. */ | |
10938 | install_element (BGP_NODE, &neighbor_strict_capability_cmd); | |
10939 | install_element (BGP_NODE, &no_neighbor_strict_capability_cmd); | |
10940 | ||
10941 | /* "neighbor timers" commands. */ | |
10942 | install_element (BGP_NODE, &neighbor_timers_cmd); | |
10943 | install_element (BGP_NODE, &no_neighbor_timers_cmd); | |
10944 | ||
10945 | /* "neighbor timers connect" commands. */ | |
10946 | install_element (BGP_NODE, &neighbor_timers_connect_cmd); | |
10947 | install_element (BGP_NODE, &no_neighbor_timers_connect_cmd); | |
718e3744 | 10948 | |
10949 | /* "neighbor advertisement-interval" commands. */ | |
10950 | install_element (BGP_NODE, &neighbor_advertise_interval_cmd); | |
10951 | install_element (BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
718e3744 | 10952 | |
718e3744 | 10953 | /* "neighbor interface" commands. */ |
10954 | install_element (BGP_NODE, &neighbor_interface_cmd); | |
10955 | install_element (BGP_NODE, &no_neighbor_interface_cmd); | |
10956 | ||
10957 | /* "neighbor distribute" commands. */ | |
10958 | install_element (BGP_NODE, &neighbor_distribute_list_cmd); | |
10959 | install_element (BGP_NODE, &no_neighbor_distribute_list_cmd); | |
10960 | install_element (BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
10961 | install_element (BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
10962 | install_element (BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
10963 | install_element (BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
f51bae9c DS |
10964 | install_element (BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); |
10965 | install_element (BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
718e3744 | 10966 | install_element (BGP_IPV6_NODE, &neighbor_distribute_list_cmd); |
10967 | install_element (BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
25ffbdc1 | 10968 | install_element (BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); |
10969 | install_element (BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
f51bae9c DS |
10970 | install_element (BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); |
10971 | install_element (BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
718e3744 | 10972 | install_element (BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); |
10973 | install_element (BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
8ecd3266 | 10974 | install_element (BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); |
10975 | install_element (BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
8b1fb8be LB |
10976 | install_element (BGP_ENCAP_NODE, &neighbor_distribute_list_cmd); |
10977 | install_element (BGP_ENCAP_NODE, &no_neighbor_distribute_list_cmd); | |
10978 | install_element (BGP_ENCAPV6_NODE, &neighbor_distribute_list_cmd); | |
10979 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_distribute_list_cmd); | |
718e3744 | 10980 | |
10981 | /* "neighbor prefix-list" commands. */ | |
10982 | install_element (BGP_NODE, &neighbor_prefix_list_cmd); | |
10983 | install_element (BGP_NODE, &no_neighbor_prefix_list_cmd); | |
10984 | install_element (BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
10985 | install_element (BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
10986 | install_element (BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
10987 | install_element (BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
f51bae9c DS |
10988 | install_element (BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); |
10989 | install_element (BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
718e3744 | 10990 | install_element (BGP_IPV6_NODE, &neighbor_prefix_list_cmd); |
10991 | install_element (BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
25ffbdc1 | 10992 | install_element (BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); |
10993 | install_element (BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
f51bae9c DS |
10994 | install_element (BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); |
10995 | install_element (BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
718e3744 | 10996 | install_element (BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); |
10997 | install_element (BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
8ecd3266 | 10998 | install_element (BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); |
10999 | install_element (BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
8b1fb8be LB |
11000 | install_element (BGP_ENCAP_NODE, &neighbor_prefix_list_cmd); |
11001 | install_element (BGP_ENCAP_NODE, &no_neighbor_prefix_list_cmd); | |
11002 | install_element (BGP_ENCAPV6_NODE, &neighbor_prefix_list_cmd); | |
11003 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_prefix_list_cmd); | |
718e3744 | 11004 | |
11005 | /* "neighbor filter-list" commands. */ | |
11006 | install_element (BGP_NODE, &neighbor_filter_list_cmd); | |
11007 | install_element (BGP_NODE, &no_neighbor_filter_list_cmd); | |
11008 | install_element (BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
11009 | install_element (BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
11010 | install_element (BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
11011 | install_element (BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
f51bae9c DS |
11012 | install_element (BGP_IPV4L_NODE, &neighbor_filter_list_cmd); |
11013 | install_element (BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
718e3744 | 11014 | install_element (BGP_IPV6_NODE, &neighbor_filter_list_cmd); |
11015 | install_element (BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
25ffbdc1 | 11016 | install_element (BGP_IPV6M_NODE, &neighbor_filter_list_cmd); |
11017 | install_element (BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
f51bae9c DS |
11018 | install_element (BGP_IPV6L_NODE, &neighbor_filter_list_cmd); |
11019 | install_element (BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
718e3744 | 11020 | install_element (BGP_VPNV4_NODE, &neighbor_filter_list_cmd); |
11021 | install_element (BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
8ecd3266 | 11022 | install_element (BGP_VPNV6_NODE, &neighbor_filter_list_cmd); |
11023 | install_element (BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
8b1fb8be LB |
11024 | install_element (BGP_ENCAP_NODE, &neighbor_filter_list_cmd); |
11025 | install_element (BGP_ENCAP_NODE, &no_neighbor_filter_list_cmd); | |
11026 | install_element (BGP_ENCAPV6_NODE, &neighbor_filter_list_cmd); | |
11027 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_filter_list_cmd); | |
718e3744 | 11028 | |
11029 | /* "neighbor route-map" commands. */ | |
11030 | install_element (BGP_NODE, &neighbor_route_map_cmd); | |
11031 | install_element (BGP_NODE, &no_neighbor_route_map_cmd); | |
11032 | install_element (BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
11033 | install_element (BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
11034 | install_element (BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
11035 | install_element (BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
f51bae9c DS |
11036 | install_element (BGP_IPV4L_NODE, &neighbor_route_map_cmd); |
11037 | install_element (BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
718e3744 | 11038 | install_element (BGP_IPV6_NODE, &neighbor_route_map_cmd); |
11039 | install_element (BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
25ffbdc1 | 11040 | install_element (BGP_IPV6M_NODE, &neighbor_route_map_cmd); |
11041 | install_element (BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
f51bae9c DS |
11042 | install_element (BGP_IPV6L_NODE, &neighbor_route_map_cmd); |
11043 | install_element (BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
718e3744 | 11044 | install_element (BGP_VPNV4_NODE, &neighbor_route_map_cmd); |
11045 | install_element (BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
8ecd3266 | 11046 | install_element (BGP_VPNV6_NODE, &neighbor_route_map_cmd); |
11047 | install_element (BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
8b1fb8be LB |
11048 | install_element (BGP_ENCAP_NODE, &neighbor_route_map_cmd); |
11049 | install_element (BGP_ENCAP_NODE, &no_neighbor_route_map_cmd); | |
11050 | install_element (BGP_ENCAPV6_NODE, &neighbor_route_map_cmd); | |
11051 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_map_cmd); | |
718e3744 | 11052 | |
11053 | /* "neighbor unsuppress-map" commands. */ | |
11054 | install_element (BGP_NODE, &neighbor_unsuppress_map_cmd); | |
11055 | install_element (BGP_NODE, &no_neighbor_unsuppress_map_cmd); | |
11056 | install_element (BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
11057 | install_element (BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
11058 | install_element (BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
11059 | install_element (BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
f51bae9c DS |
11060 | install_element (BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); |
11061 | install_element (BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
718e3744 | 11062 | install_element (BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); |
11063 | install_element (BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
25ffbdc1 | 11064 | install_element (BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); |
11065 | install_element (BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
f51bae9c DS |
11066 | install_element (BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); |
11067 | install_element (BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
a58545bb | 11068 | install_element (BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); |
bb86c601 | 11069 | install_element (BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); |
8ecd3266 | 11070 | install_element (BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); |
bb86c601 | 11071 | install_element (BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); |
8b1fb8be LB |
11072 | install_element (BGP_ENCAP_NODE, &neighbor_unsuppress_map_cmd); |
11073 | install_element (BGP_ENCAP_NODE, &no_neighbor_unsuppress_map_cmd); | |
11074 | install_element (BGP_ENCAPV6_NODE, &neighbor_unsuppress_map_cmd); | |
11075 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
718e3744 | 11076 | |
11077 | /* "neighbor maximum-prefix" commands. */ | |
11078 | install_element (BGP_NODE, &neighbor_maximum_prefix_cmd); | |
e0701b79 | 11079 | install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 11080 | install_element (BGP_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 11081 | install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 11082 | install_element (BGP_NODE, &neighbor_maximum_prefix_restart_cmd); |
11083 | install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 11084 | install_element (BGP_NODE, &no_neighbor_maximum_prefix_cmd); |
718e3744 | 11085 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 11086 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 11087 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 11088 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 11089 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); |
11090 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 11091 | install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); |
718e3744 | 11092 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 11093 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 11094 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 11095 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 11096 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); |
11097 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 11098 | install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); |
f51bae9c DS |
11099 | install_element (BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); |
11100 | install_element (BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
11101 | install_element (BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
11102 | install_element (BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
11103 | install_element (BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
11104 | install_element (BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
11105 | install_element (BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
718e3744 | 11106 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 11107 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 11108 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 11109 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 11110 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); |
11111 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 11112 | install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); |
25ffbdc1 | 11113 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); |
11114 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
11115 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
11116 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
11117 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
11118 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
11119 | install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
f51bae9c DS |
11120 | install_element (BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); |
11121 | install_element (BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
11122 | install_element (BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
11123 | install_element (BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
11124 | install_element (BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
11125 | install_element (BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
11126 | install_element (BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
718e3744 | 11127 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 11128 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 11129 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 11130 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 11131 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); |
11132 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 11133 | install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); |
8ecd3266 | 11134 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); |
11135 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
11136 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
11137 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
11138 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
11139 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
11140 | install_element (BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
718e3744 | 11141 | |
8b1fb8be LB |
11142 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_cmd); |
11143 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
11144 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_warning_cmd); | |
11145 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
11146 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_restart_cmd); | |
11147 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
11148 | install_element (BGP_ENCAP_NODE, &no_neighbor_maximum_prefix_cmd); | |
8b1fb8be LB |
11149 | |
11150 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_cmd); | |
11151 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
11152 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
11153 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
11154 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
11155 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
11156 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
8b1fb8be | 11157 | |
718e3744 | 11158 | /* "neighbor allowas-in" */ |
11159 | install_element (BGP_NODE, &neighbor_allowas_in_cmd); | |
718e3744 | 11160 | install_element (BGP_NODE, &no_neighbor_allowas_in_cmd); |
11161 | install_element (BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
718e3744 | 11162 | install_element (BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); |
11163 | install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
718e3744 | 11164 | install_element (BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); |
f51bae9c DS |
11165 | install_element (BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); |
11166 | install_element (BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
718e3744 | 11167 | install_element (BGP_IPV6_NODE, &neighbor_allowas_in_cmd); |
718e3744 | 11168 | install_element (BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); |
25ffbdc1 | 11169 | install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); |
25ffbdc1 | 11170 | install_element (BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); |
f51bae9c DS |
11171 | install_element (BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); |
11172 | install_element (BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
718e3744 | 11173 | install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); |
718e3744 | 11174 | install_element (BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); |
8ecd3266 | 11175 | install_element (BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); |
8ecd3266 | 11176 | install_element (BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); |
8b1fb8be | 11177 | install_element (BGP_ENCAP_NODE, &neighbor_allowas_in_cmd); |
8b1fb8be LB |
11178 | install_element (BGP_ENCAP_NODE, &no_neighbor_allowas_in_cmd); |
11179 | install_element (BGP_ENCAPV6_NODE, &neighbor_allowas_in_cmd); | |
8b1fb8be | 11180 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_allowas_in_cmd); |
718e3744 | 11181 | |
11182 | /* address-family commands. */ | |
718e3744 | 11183 | install_element (BGP_NODE, &address_family_ipv4_safi_cmd); |
25ffbdc1 | 11184 | install_element (BGP_NODE, &address_family_ipv6_safi_cmd); |
d6902373 | 11185 | #ifdef KEEP_OLD_VPN_COMMANDS |
718e3744 | 11186 | install_element (BGP_NODE, &address_family_vpnv4_cmd); |
8b1fb8be | 11187 | install_element (BGP_NODE, &address_family_vpnv6_cmd); |
d6902373 | 11188 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be LB |
11189 | |
11190 | install_element (BGP_NODE, &address_family_encap_cmd); | |
8b1fb8be | 11191 | install_element (BGP_NODE, &address_family_encapv6_cmd); |
8b1fb8be | 11192 | |
4e0b7b6d PG |
11193 | install_element (BGP_NODE, &address_family_evpn_cmd); |
11194 | ||
718e3744 | 11195 | /* "exit-address-family" command. */ |
11196 | install_element (BGP_IPV4_NODE, &exit_address_family_cmd); | |
11197 | install_element (BGP_IPV4M_NODE, &exit_address_family_cmd); | |
f51bae9c | 11198 | install_element (BGP_IPV4L_NODE, &exit_address_family_cmd); |
718e3744 | 11199 | install_element (BGP_IPV6_NODE, &exit_address_family_cmd); |
25ffbdc1 | 11200 | install_element (BGP_IPV6M_NODE, &exit_address_family_cmd); |
f51bae9c | 11201 | install_element (BGP_IPV6L_NODE, &exit_address_family_cmd); |
718e3744 | 11202 | install_element (BGP_VPNV4_NODE, &exit_address_family_cmd); |
8ecd3266 | 11203 | install_element (BGP_VPNV6_NODE, &exit_address_family_cmd); |
8b1fb8be LB |
11204 | install_element (BGP_ENCAP_NODE, &exit_address_family_cmd); |
11205 | install_element (BGP_ENCAPV6_NODE, &exit_address_family_cmd); | |
4e0b7b6d | 11206 | install_element (BGP_EVPN_NODE, &exit_address_family_cmd); |
718e3744 | 11207 | |
11208 | /* "clear ip bgp commands" */ | |
11209 | install_element (ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
718e3744 | 11210 | |
8ad7271d DS |
11211 | /* clear ip bgp prefix */ |
11212 | install_element (ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
11213 | install_element (ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
01080f7c | 11214 | install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); |
8ad7271d | 11215 | |
716b2d8a | 11216 | /* "show [ip] bgp summary" commands. */ |
f186de26 | 11217 | install_element (VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); |
8386ac43 | 11218 | install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_cmd); |
8386ac43 | 11219 | install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_s_cmd); |
271ad8d5 | 11220 | install_element (VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
e52702f2 | 11221 | install_element (VIEW_NODE, &show_bgp_updgrps_adj_cmd); |
e52702f2 | 11222 | install_element (VIEW_NODE, &show_bgp_updgrps_adj_s_cmd); |
271ad8d5 | 11223 | install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_cmd); |
e52702f2 | 11224 | install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_s_cmd); |
8c3deaae | 11225 | install_element (VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
271ad8d5 QY |
11226 | install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_cmd); |
11227 | install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); | |
11228 | install_element (VIEW_NODE, &show_ip_bgp_summary_cmd); | |
11229 | install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_cmd); | |
11230 | install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_s_cmd); | |
11231 | install_element (VIEW_NODE, &show_ip_bgp_updgrps_cmd); | |
e3e29b32 | 11232 | |
716b2d8a | 11233 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 11234 | install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd); |
718e3744 | 11235 | |
716b2d8a | 11236 | /* "show [ip] bgp peer-group" commands. */ |
f14e6fdb | 11237 | install_element (VIEW_NODE, &show_ip_bgp_peer_groups_cmd); |
f14e6fdb | 11238 | |
716b2d8a | 11239 | /* "show [ip] bgp paths" commands. */ |
718e3744 | 11240 | install_element (VIEW_NODE, &show_ip_bgp_paths_cmd); |
718e3744 | 11241 | |
716b2d8a | 11242 | /* "show [ip] bgp community" commands. */ |
718e3744 | 11243 | install_element (VIEW_NODE, &show_ip_bgp_community_info_cmd); |
718e3744 | 11244 | |
57d187bc JS |
11245 | /* "show ip bgp large-community" commands. */ |
11246 | install_element (VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
716b2d8a | 11247 | /* "show [ip] bgp attribute-info" commands. */ |
718e3744 | 11248 | install_element (VIEW_NODE, &show_ip_bgp_attr_info_cmd); |
718e3744 | 11249 | |
11250 | /* "redistribute" commands. */ | |
11251 | install_element (BGP_NODE, &bgp_redistribute_ipv4_cmd); | |
11252 | install_element (BGP_NODE, &no_bgp_redistribute_ipv4_cmd); | |
11253 | install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
718e3744 | 11254 | install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_cmd); |
718e3744 | 11255 | install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); |
11256 | install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
7c8ff89e DS |
11257 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_cmd); |
11258 | install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
11259 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
7c8ff89e | 11260 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); |
7c8ff89e | 11261 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); |
7c8ff89e | 11262 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); |
919e0666 DW |
11263 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); |
11264 | install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
11265 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
919e0666 | 11266 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); |
919e0666 DW |
11267 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); |
11268 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
919e0666 DW |
11269 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); |
11270 | install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
11271 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
919e0666 | 11272 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); |
919e0666 | 11273 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); |
919e0666 | 11274 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); |
718e3744 | 11275 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); |
11276 | install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
11277 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
718e3744 | 11278 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); |
718e3744 | 11279 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); |
11280 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
718e3744 | 11281 | |
fa411a21 NH |
11282 | /* ttl_security commands */ |
11283 | install_element (BGP_NODE, &neighbor_ttl_security_cmd); | |
11284 | install_element (BGP_NODE, &no_neighbor_ttl_security_cmd); | |
11285 | ||
716b2d8a | 11286 | /* "show [ip] bgp memory" commands. */ |
4bf6a362 | 11287 | install_element (VIEW_NODE, &show_bgp_memory_cmd); |
e52702f2 | 11288 | |
716b2d8a | 11289 | /* "show [ip] bgp views" commands. */ |
e0081f70 | 11290 | install_element (VIEW_NODE, &show_bgp_views_cmd); |
e52702f2 | 11291 | |
716b2d8a | 11292 | /* "show [ip] bgp vrfs" commands. */ |
8386ac43 | 11293 | install_element (VIEW_NODE, &show_bgp_vrfs_cmd); |
e52702f2 | 11294 | |
718e3744 | 11295 | /* Community-list. */ |
11296 | community_list_vty (); | |
11297 | } | |
6b0655a2 | 11298 | |
718e3744 | 11299 | #include "memory.h" |
11300 | #include "bgp_regex.h" | |
11301 | #include "bgp_clist.h" | |
11302 | #include "bgp_ecommunity.h" | |
11303 | ||
11304 | /* VTY functions. */ | |
11305 | ||
11306 | /* Direction value to string conversion. */ | |
94f2b392 | 11307 | static const char * |
718e3744 | 11308 | community_direct_str (int direct) |
11309 | { | |
11310 | switch (direct) | |
11311 | { | |
11312 | case COMMUNITY_DENY: | |
11313 | return "deny"; | |
718e3744 | 11314 | case COMMUNITY_PERMIT: |
11315 | return "permit"; | |
718e3744 | 11316 | default: |
11317 | return "unknown"; | |
718e3744 | 11318 | } |
11319 | } | |
11320 | ||
11321 | /* Display error string. */ | |
94f2b392 | 11322 | static void |
718e3744 | 11323 | community_list_perror (struct vty *vty, int ret) |
11324 | { | |
11325 | switch (ret) | |
11326 | { | |
11327 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
b729294c | 11328 | vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE); |
718e3744 | 11329 | break; |
11330 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
11331 | vty_out (vty, "%% Malformed community-list value%s", VTY_NEWLINE); | |
11332 | break; | |
11333 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
11334 | vty_out (vty, "%% Community name conflict, previously defined as standard community%s", VTY_NEWLINE); | |
11335 | break; | |
11336 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
11337 | vty_out (vty, "%% Community name conflict, previously defined as expanded community%s", VTY_NEWLINE); | |
11338 | break; | |
11339 | } | |
11340 | } | |
11341 | ||
5bf15956 DW |
11342 | /* "community-list" keyword help string. */ |
11343 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
11344 | ||
718e3744 | 11345 | |
5bf15956 | 11346 | /* ip community-list standard */ |
718e3744 | 11347 | DEFUN (ip_community_list_standard, |
11348 | ip_community_list_standard_cmd, | |
e961923c | 11349 | "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 11350 | IP_STR |
11351 | COMMUNITY_LIST_STR | |
11352 | "Community list number (standard)\n" | |
5bf15956 | 11353 | "Add an standard community-list entry\n" |
718e3744 | 11354 | "Community list name\n" |
11355 | "Specify community to reject\n" | |
11356 | "Specify community to accept\n" | |
11357 | COMMUNITY_VAL_STR) | |
11358 | { | |
42f914d4 QY |
11359 | char *cl_name_or_number = NULL; |
11360 | int direct = 0; | |
11361 | int style = COMMUNITY_LIST_STANDARD; | |
11362 | ||
11363 | int idx = 0; | |
11364 | argv_find (argv, argc, "(1-99)", &idx); | |
11365 | argv_find (argv, argc, "WORD", &idx); | |
11366 | cl_name_or_number = argv[idx]->arg; | |
11367 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11368 | argv_find (argv, argc, "AA:NN", &idx); | |
11369 | char *str = argv_concat (argv, argc, idx); | |
11370 | ||
11371 | int ret = community_list_set (bgp_clist, cl_name_or_number, str, direct, style); | |
11372 | ||
11373 | XFREE (MTYPE_TMP, str); | |
11374 | ||
11375 | if (ret < 0) | |
11376 | { | |
11377 | /* Display error string. */ | |
11378 | community_list_perror (vty, ret); | |
11379 | return CMD_WARNING; | |
11380 | } | |
11381 | ||
11382 | return CMD_SUCCESS; | |
718e3744 | 11383 | } |
11384 | ||
fee6e4e4 | 11385 | DEFUN (no_ip_community_list_standard_all, |
11386 | no_ip_community_list_standard_all_cmd, | |
e961923c | 11387 | "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 11388 | NO_STR |
11389 | IP_STR | |
11390 | COMMUNITY_LIST_STR | |
11391 | "Community list number (standard)\n" | |
5bf15956 DW |
11392 | "Add an standard community-list entry\n" |
11393 | "Community list name\n" | |
718e3744 | 11394 | "Specify community to reject\n" |
11395 | "Specify community to accept\n" | |
11396 | COMMUNITY_VAL_STR) | |
11397 | { | |
42f914d4 QY |
11398 | int delete_all = 0; |
11399 | ||
11400 | char *cl_name_or_number = NULL; | |
11401 | int direct = 0; | |
11402 | int style = COMMUNITY_LIST_STANDARD; | |
11403 | ||
11404 | int idx = 0; | |
11405 | argv_find (argv, argc, "(1-99)", &idx); | |
11406 | argv_find (argv, argc, "WORD", &idx); | |
11407 | cl_name_or_number = argv[idx]->arg; | |
11408 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11409 | argv_find (argv, argc, "AA:NN", &idx); | |
11410 | char *str = argv_concat (argv, argc, idx); | |
11411 | ||
11412 | int ret = community_list_unset (bgp_clist, cl_name_or_number, str, direct, style, delete_all); | |
11413 | ||
daf9ddbb DS |
11414 | XFREE (MTYPE_TMP, str); |
11415 | ||
42f914d4 QY |
11416 | if (ret < 0) |
11417 | { | |
11418 | community_list_perror (vty, ret); | |
11419 | return CMD_WARNING; | |
11420 | } | |
11421 | ||
11422 | return CMD_SUCCESS; | |
718e3744 | 11423 | } |
11424 | ||
5bf15956 DW |
11425 | /* ip community-list expanded */ |
11426 | DEFUN (ip_community_list_expanded_all, | |
11427 | ip_community_list_expanded_all_cmd, | |
42f914d4 | 11428 | "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 11429 | IP_STR |
11430 | COMMUNITY_LIST_STR | |
11431 | "Community list number (expanded)\n" | |
5bf15956 | 11432 | "Add an expanded community-list entry\n" |
718e3744 | 11433 | "Community list name\n" |
11434 | "Specify community to reject\n" | |
11435 | "Specify community to accept\n" | |
11436 | COMMUNITY_VAL_STR) | |
11437 | { | |
42f914d4 QY |
11438 | char *cl_name_or_number = NULL; |
11439 | int direct = 0; | |
11440 | int style = COMMUNITY_LIST_EXPANDED; | |
11441 | ||
11442 | int idx = 0; | |
11443 | argv_find (argv, argc, "(100-500)", &idx); | |
11444 | argv_find (argv, argc, "WORD", &idx); | |
11445 | cl_name_or_number = argv[idx]->arg; | |
11446 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11447 | argv_find (argv, argc, "AA:NN", &idx); | |
11448 | char *str = argv_concat (argv, argc, idx); | |
11449 | ||
11450 | int ret = community_list_set (bgp_clist, cl_name_or_number, str, direct, style); | |
11451 | ||
11452 | XFREE (MTYPE_TMP, str); | |
11453 | ||
11454 | if (ret < 0) | |
11455 | { | |
11456 | /* Display error string. */ | |
11457 | community_list_perror (vty, ret); | |
11458 | return CMD_WARNING; | |
11459 | } | |
11460 | ||
11461 | return CMD_SUCCESS; | |
718e3744 | 11462 | } |
11463 | ||
5bf15956 DW |
11464 | DEFUN (no_ip_community_list_expanded_all, |
11465 | no_ip_community_list_expanded_all_cmd, | |
42f914d4 | 11466 | "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 11467 | NO_STR |
11468 | IP_STR | |
11469 | COMMUNITY_LIST_STR | |
5bf15956 DW |
11470 | "Community list number (expanded)\n" |
11471 | "Add an expanded community-list entry\n" | |
718e3744 | 11472 | "Community list name\n" |
11473 | "Specify community to reject\n" | |
11474 | "Specify community to accept\n" | |
5bf15956 | 11475 | COMMUNITY_VAL_STR) |
718e3744 | 11476 | { |
42f914d4 QY |
11477 | int delete_all = 0; |
11478 | ||
11479 | char *cl_name_or_number = NULL; | |
11480 | int direct = 0; | |
11481 | int style = COMMUNITY_LIST_EXPANDED; | |
11482 | ||
11483 | int idx = 0; | |
11484 | argv_find (argv, argc, "(100-500)", &idx); | |
11485 | argv_find (argv, argc, "WORD", &idx); | |
11486 | cl_name_or_number = argv[idx]->arg; | |
11487 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11488 | argv_find (argv, argc, "AA:NN", &idx); | |
11489 | char *str = argv_concat (argv, argc, idx); | |
11490 | ||
11491 | int ret = community_list_unset (bgp_clist, cl_name_or_number, str, direct, style, delete_all); | |
11492 | ||
daf9ddbb DS |
11493 | XFREE (MTYPE_TMP, str); |
11494 | ||
42f914d4 QY |
11495 | if (ret < 0) |
11496 | { | |
11497 | community_list_perror (vty, ret); | |
11498 | return CMD_WARNING; | |
11499 | } | |
11500 | ||
11501 | return CMD_SUCCESS; | |
718e3744 | 11502 | } |
11503 | ||
94f2b392 | 11504 | static void |
718e3744 | 11505 | community_list_show (struct vty *vty, struct community_list *list) |
11506 | { | |
11507 | struct community_entry *entry; | |
11508 | ||
11509 | for (entry = list->head; entry; entry = entry->next) | |
11510 | { | |
11511 | if (entry == list->head) | |
11512 | { | |
11513 | if (all_digit (list->name)) | |
11514 | vty_out (vty, "Community %s list %s%s", | |
11515 | entry->style == COMMUNITY_LIST_STANDARD ? | |
11516 | "standard" : "(expanded) access", | |
11517 | list->name, VTY_NEWLINE); | |
11518 | else | |
11519 | vty_out (vty, "Named Community %s list %s%s", | |
11520 | entry->style == COMMUNITY_LIST_STANDARD ? | |
11521 | "standard" : "expanded", | |
11522 | list->name, VTY_NEWLINE); | |
11523 | } | |
11524 | if (entry->any) | |
11525 | vty_out (vty, " %s%s", | |
11526 | community_direct_str (entry->direct), VTY_NEWLINE); | |
11527 | else | |
11528 | vty_out (vty, " %s %s%s", | |
11529 | community_direct_str (entry->direct), | |
11530 | entry->style == COMMUNITY_LIST_STANDARD | |
11531 | ? community_str (entry->u.com) : entry->config, | |
11532 | VTY_NEWLINE); | |
11533 | } | |
11534 | } | |
11535 | ||
11536 | DEFUN (show_ip_community_list, | |
11537 | show_ip_community_list_cmd, | |
11538 | "show ip community-list", | |
11539 | SHOW_STR | |
11540 | IP_STR | |
11541 | "List community-list\n") | |
11542 | { | |
11543 | struct community_list *list; | |
11544 | struct community_list_master *cm; | |
11545 | ||
fee6e4e4 | 11546 | cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER); |
718e3744 | 11547 | if (! cm) |
11548 | return CMD_SUCCESS; | |
11549 | ||
11550 | for (list = cm->num.head; list; list = list->next) | |
11551 | community_list_show (vty, list); | |
11552 | ||
11553 | for (list = cm->str.head; list; list = list->next) | |
11554 | community_list_show (vty, list); | |
11555 | ||
11556 | return CMD_SUCCESS; | |
11557 | } | |
11558 | ||
11559 | DEFUN (show_ip_community_list_arg, | |
11560 | show_ip_community_list_arg_cmd, | |
6147e2c6 | 11561 | "show ip community-list <(1-500)|WORD>", |
718e3744 | 11562 | SHOW_STR |
11563 | IP_STR | |
11564 | "List community-list\n" | |
11565 | "Community-list number\n" | |
11566 | "Community-list name\n") | |
11567 | { | |
c500ae40 | 11568 | int idx_comm_list = 3; |
718e3744 | 11569 | struct community_list *list; |
11570 | ||
c500ae40 | 11571 | list = community_list_lookup (bgp_clist, argv[idx_comm_list]->arg, COMMUNITY_LIST_MASTER); |
718e3744 | 11572 | if (! list) |
11573 | { | |
b729294c | 11574 | vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE); |
718e3744 | 11575 | return CMD_WARNING; |
11576 | } | |
11577 | ||
11578 | community_list_show (vty, list); | |
11579 | ||
11580 | return CMD_SUCCESS; | |
11581 | } | |
6b0655a2 | 11582 | |
57d187bc JS |
11583 | /* |
11584 | * Large Community code. | |
11585 | */ | |
11586 | static int | |
11587 | lcommunity_list_set_vty (struct vty *vty, int argc, struct cmd_token **argv, | |
2acb4ac2 | 11588 | int style, int reject_all_digit_name) |
57d187bc JS |
11589 | { |
11590 | int ret; | |
11591 | int direct; | |
11592 | char *str; | |
11593 | int idx = 0; | |
11594 | char *cl_name; | |
11595 | ||
11596 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11597 | ||
11598 | /* All digit name check. */ | |
11599 | idx = 0; | |
11600 | argv_find (argv, argc, "WORD", &idx); | |
11601 | argv_find (argv, argc, "(1-99)", &idx); | |
11602 | argv_find (argv, argc, "(100-500)", &idx); | |
11603 | cl_name = argv[idx]->arg; | |
11604 | if (reject_all_digit_name && all_digit (cl_name)) | |
11605 | { | |
11606 | vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE); | |
11607 | return CMD_WARNING; | |
11608 | } | |
11609 | ||
11610 | argv_find (argv, argc, "AA:BB:CC", &idx); | |
11611 | argv_find (argv, argc, "LINE", &idx); | |
11612 | /* Concat community string argument. */ | |
11613 | if (idx) | |
11614 | str = argv_concat (argv, argc, idx); | |
11615 | else | |
11616 | str = NULL; | |
11617 | ||
11618 | ret = lcommunity_list_set (bgp_clist, cl_name, str, direct, style); | |
11619 | ||
11620 | /* Free temporary community list string allocated by | |
11621 | argv_concat(). */ | |
11622 | if (str) | |
11623 | XFREE (MTYPE_TMP, str); | |
11624 | ||
11625 | if (ret < 0) | |
11626 | { | |
11627 | community_list_perror (vty, ret); | |
11628 | return CMD_WARNING; | |
11629 | } | |
11630 | return CMD_SUCCESS; | |
11631 | } | |
11632 | ||
11633 | static int | |
11634 | lcommunity_list_unset_vty (struct vty *vty, int argc, struct cmd_token **argv, | |
2acb4ac2 | 11635 | int style) |
57d187bc JS |
11636 | { |
11637 | int ret; | |
11638 | int direct = 0; | |
11639 | char *str = NULL; | |
11640 | int idx = 0; | |
11641 | ||
11642 | argv_find (argv, argc, "permit", &idx); | |
11643 | argv_find (argv, argc, "deny", &idx); | |
11644 | ||
11645 | if (idx) | |
11646 | { | |
11647 | /* Check the list direct. */ | |
11648 | if (strncmp (argv[idx]->arg, "p", 1) == 0) | |
2acb4ac2 | 11649 | direct = COMMUNITY_PERMIT; |
57d187bc | 11650 | else |
2acb4ac2 | 11651 | direct = COMMUNITY_DENY; |
57d187bc JS |
11652 | |
11653 | idx = 0; | |
11654 | argv_find (argv, argc, "LINE", &idx); | |
11655 | argv_find (argv, argc, "AA:AA:NN", &idx); | |
11656 | /* Concat community string argument. */ | |
11657 | str = argv_concat (argv, argc, idx); | |
11658 | } | |
11659 | ||
11660 | idx = 0; | |
11661 | argv_find (argv, argc, "(1-99)", &idx); | |
11662 | argv_find (argv, argc, "(100-500)", &idx); | |
11663 | argv_find (argv, argc, "WORD", &idx); | |
11664 | ||
11665 | /* Unset community list. */ | |
11666 | ret = lcommunity_list_unset (bgp_clist, argv[idx]->arg, str, direct, style); | |
11667 | ||
11668 | /* Free temporary community list string allocated by | |
11669 | argv_concat(). */ | |
11670 | if (str) | |
11671 | XFREE (MTYPE_TMP, str); | |
11672 | ||
11673 | if (ret < 0) | |
11674 | { | |
11675 | community_list_perror (vty, ret); | |
11676 | return CMD_WARNING; | |
11677 | } | |
11678 | ||
11679 | return CMD_SUCCESS; | |
11680 | } | |
11681 | ||
11682 | /* "large-community-list" keyword help string. */ | |
11683 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
11684 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
11685 | ||
11686 | DEFUN (ip_lcommunity_list_standard, | |
11687 | ip_lcommunity_list_standard_cmd, | |
52951b63 DS |
11688 | "ip large-community-list (1-99) <deny|permit>", |
11689 | IP_STR | |
11690 | LCOMMUNITY_LIST_STR | |
11691 | "Large Community list number (standard)\n" | |
11692 | "Specify large community to reject\n" | |
11693 | "Specify large community to accept\n" | |
11694 | LCOMMUNITY_VAL_STR) | |
11695 | { | |
11696 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD, 0); | |
11697 | } | |
11698 | ||
11699 | DEFUN (ip_lcommunity_list_standard1, | |
11700 | ip_lcommunity_list_standard1_cmd, | |
11701 | "ip large-community-list (1-99) <deny|permit> AA:BB:CC...", | |
57d187bc JS |
11702 | IP_STR |
11703 | LCOMMUNITY_LIST_STR | |
11704 | "Large Community list number (standard)\n" | |
11705 | "Specify large community to reject\n" | |
11706 | "Specify large community to accept\n" | |
11707 | LCOMMUNITY_VAL_STR) | |
11708 | { | |
11709 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD, 0); | |
11710 | } | |
11711 | ||
11712 | DEFUN (ip_lcommunity_list_expanded, | |
11713 | ip_lcommunity_list_expanded_cmd, | |
11714 | "ip large-community-list (100-500) <deny|permit> LINE...", | |
11715 | IP_STR | |
11716 | LCOMMUNITY_LIST_STR | |
11717 | "Large Community list number (expanded)\n" | |
11718 | "Specify large community to reject\n" | |
11719 | "Specify large community to accept\n" | |
11720 | "An ordered list as a regular-expression\n") | |
11721 | { | |
11722 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED, 0); | |
11723 | } | |
11724 | ||
11725 | DEFUN (ip_lcommunity_list_name_standard, | |
11726 | ip_lcommunity_list_name_standard_cmd, | |
52951b63 DS |
11727 | "ip large-community-list standard WORD <deny|permit>", |
11728 | IP_STR | |
11729 | LCOMMUNITY_LIST_STR | |
11730 | "Specify standard large-community-list\n" | |
11731 | "Large Community list name\n" | |
11732 | "Specify large community to reject\n" | |
11733 | "Specify large community to accept\n") | |
11734 | { | |
11735 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD, 1); | |
11736 | } | |
11737 | ||
11738 | DEFUN (ip_lcommunity_list_name_standard1, | |
11739 | ip_lcommunity_list_name_standard1_cmd, | |
11740 | "ip large-community-list standard WORD <deny|permit> AA:BB:CC...", | |
57d187bc JS |
11741 | IP_STR |
11742 | LCOMMUNITY_LIST_STR | |
11743 | "Specify standard large-community-list\n" | |
11744 | "Large Community list name\n" | |
11745 | "Specify large community to reject\n" | |
11746 | "Specify large community to accept\n" | |
11747 | LCOMMUNITY_VAL_STR) | |
11748 | { | |
11749 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD, 1); | |
11750 | } | |
11751 | ||
11752 | DEFUN (ip_lcommunity_list_name_expanded, | |
11753 | ip_lcommunity_list_name_expanded_cmd, | |
11754 | "ip large-community-list expanded WORD <deny|permit> LINE...", | |
11755 | IP_STR | |
11756 | LCOMMUNITY_LIST_STR | |
11757 | "Specify expanded large-community-list\n" | |
11758 | "Large Community list name\n" | |
11759 | "Specify large community to reject\n" | |
11760 | "Specify large community to accept\n" | |
11761 | "An ordered list as a regular-expression\n") | |
11762 | { | |
11763 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED, 1); | |
11764 | } | |
11765 | ||
11766 | DEFUN (no_ip_lcommunity_list_standard_all, | |
11767 | no_ip_lcommunity_list_standard_all_cmd, | |
11768 | "no ip large-community-list <(1-99)|(100-500)|WORD>", | |
11769 | NO_STR | |
11770 | IP_STR | |
11771 | LCOMMUNITY_LIST_STR | |
11772 | "Large Community list number (standard)\n" | |
11773 | "Large Community list number (expanded)\n" | |
11774 | "Large Community list name\n") | |
11775 | { | |
11776 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD); | |
11777 | } | |
11778 | ||
11779 | DEFUN (no_ip_lcommunity_list_name_expanded_all, | |
11780 | no_ip_lcommunity_list_name_expanded_all_cmd, | |
11781 | "no ip large-community-list expanded WORD", | |
11782 | NO_STR | |
11783 | IP_STR | |
11784 | LCOMMUNITY_LIST_STR | |
11785 | "Specify expanded large-community-list\n" | |
11786 | "Large Community list name\n") | |
11787 | { | |
11788 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED); | |
11789 | } | |
11790 | ||
11791 | DEFUN (no_ip_lcommunity_list_standard, | |
11792 | no_ip_lcommunity_list_standard_cmd, | |
11793 | "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...", | |
11794 | NO_STR | |
11795 | IP_STR | |
11796 | LCOMMUNITY_LIST_STR | |
11797 | "Large Community list number (standard)\n" | |
11798 | "Specify large community to reject\n" | |
11799 | "Specify large community to accept\n" | |
11800 | LCOMMUNITY_VAL_STR) | |
11801 | { | |
11802 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD); | |
11803 | } | |
11804 | ||
11805 | DEFUN (no_ip_lcommunity_list_expanded, | |
11806 | no_ip_lcommunity_list_expanded_cmd, | |
11807 | "no ip large-community-list (100-500) <deny|permit> LINE...", | |
11808 | NO_STR | |
11809 | IP_STR | |
11810 | LCOMMUNITY_LIST_STR | |
11811 | "Large Community list number (expanded)\n" | |
11812 | "Specify large community to reject\n" | |
11813 | "Specify large community to accept\n" | |
11814 | "An ordered list as a regular-expression\n") | |
11815 | { | |
11816 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED); | |
11817 | } | |
11818 | ||
11819 | DEFUN (no_ip_lcommunity_list_name_standard, | |
11820 | no_ip_lcommunity_list_name_standard_cmd, | |
11821 | "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...", | |
11822 | NO_STR | |
11823 | IP_STR | |
11824 | LCOMMUNITY_LIST_STR | |
11825 | "Specify standard large-community-list\n" | |
11826 | "Large Community list name\n" | |
11827 | "Specify large community to reject\n" | |
11828 | "Specify large community to accept\n" | |
11829 | LCOMMUNITY_VAL_STR) | |
11830 | { | |
11831 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD); | |
11832 | } | |
11833 | ||
11834 | DEFUN (no_ip_lcommunity_list_name_expanded, | |
11835 | no_ip_lcommunity_list_name_expanded_cmd, | |
11836 | "no ip large-community-list expanded WORD <deny|permit> LINE...", | |
11837 | NO_STR | |
11838 | IP_STR | |
11839 | LCOMMUNITY_LIST_STR | |
11840 | "Specify expanded large-community-list\n" | |
11841 | "Large community list name\n" | |
11842 | "Specify large community to reject\n" | |
11843 | "Specify large community to accept\n" | |
11844 | "An ordered list as a regular-expression\n") | |
11845 | { | |
11846 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED); | |
11847 | } | |
11848 | ||
11849 | static void | |
11850 | lcommunity_list_show (struct vty *vty, struct community_list *list) | |
11851 | { | |
11852 | struct community_entry *entry; | |
11853 | ||
11854 | for (entry = list->head; entry; entry = entry->next) | |
11855 | { | |
11856 | if (entry == list->head) | |
2acb4ac2 DL |
11857 | { |
11858 | if (all_digit (list->name)) | |
11859 | vty_out (vty, "Large community %s list %s%s", | |
11860 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
11861 | "standard" : "(expanded) access", | |
11862 | list->name, VTY_NEWLINE); | |
11863 | else | |
11864 | vty_out (vty, "Named large community %s list %s%s", | |
11865 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
11866 | "standard" : "expanded", | |
11867 | list->name, VTY_NEWLINE); | |
11868 | } | |
57d187bc | 11869 | if (entry->any) |
2acb4ac2 DL |
11870 | vty_out (vty, " %s%s", |
11871 | community_direct_str (entry->direct), VTY_NEWLINE); | |
57d187bc | 11872 | else |
2acb4ac2 DL |
11873 | vty_out (vty, " %s %s%s", |
11874 | community_direct_str (entry->direct), | |
11875 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
11876 | entry->u.ecom->str : entry->config, | |
11877 | VTY_NEWLINE); | |
57d187bc JS |
11878 | } |
11879 | } | |
11880 | ||
11881 | DEFUN (show_ip_lcommunity_list, | |
11882 | show_ip_lcommunity_list_cmd, | |
11883 | "show ip large-community-list", | |
11884 | SHOW_STR | |
11885 | IP_STR | |
11886 | "List large-community list\n") | |
11887 | { | |
11888 | struct community_list *list; | |
11889 | struct community_list_master *cm; | |
11890 | ||
11891 | cm = community_list_master_lookup (bgp_clist, LARGE_COMMUNITY_LIST_MASTER); | |
11892 | if (! cm) | |
11893 | return CMD_SUCCESS; | |
11894 | ||
11895 | for (list = cm->num.head; list; list = list->next) | |
11896 | lcommunity_list_show (vty, list); | |
11897 | ||
11898 | for (list = cm->str.head; list; list = list->next) | |
11899 | lcommunity_list_show (vty, list); | |
11900 | ||
11901 | return CMD_SUCCESS; | |
11902 | } | |
11903 | ||
11904 | DEFUN (show_ip_lcommunity_list_arg, | |
11905 | show_ip_lcommunity_list_arg_cmd, | |
11906 | "show ip large-community-list <(1-500)|WORD>", | |
11907 | SHOW_STR | |
11908 | IP_STR | |
11909 | "List large-community list\n" | |
11910 | "large-community-list number\n" | |
11911 | "large-community-list name\n") | |
11912 | { | |
11913 | struct community_list *list; | |
11914 | ||
11915 | list = community_list_lookup (bgp_clist, argv[3]->arg, LARGE_COMMUNITY_LIST_MASTER); | |
11916 | if (! list) | |
11917 | { | |
11918 | vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE); | |
11919 | return CMD_WARNING; | |
11920 | } | |
11921 | ||
11922 | lcommunity_list_show (vty, list); | |
11923 | ||
11924 | return CMD_SUCCESS; | |
11925 | } | |
11926 | ||
718e3744 | 11927 | /* "extcommunity-list" keyword help string. */ |
11928 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
11929 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
11930 | ||
11931 | DEFUN (ip_extcommunity_list_standard, | |
11932 | ip_extcommunity_list_standard_cmd, | |
e961923c | 11933 | "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 11934 | IP_STR |
11935 | EXTCOMMUNITY_LIST_STR | |
11936 | "Extended Community list number (standard)\n" | |
718e3744 | 11937 | "Specify standard extcommunity-list\n" |
5bf15956 | 11938 | "Community list name\n" |
718e3744 | 11939 | "Specify community to reject\n" |
11940 | "Specify community to accept\n" | |
11941 | EXTCOMMUNITY_VAL_STR) | |
11942 | { | |
42f914d4 QY |
11943 | int style = EXTCOMMUNITY_LIST_STANDARD; |
11944 | int direct = 0; | |
11945 | char *cl_number_or_name = NULL; | |
11946 | ||
11947 | int idx = 0; | |
11948 | argv_find (argv, argc, "(1-99)", &idx); | |
11949 | argv_find (argv, argc, "WORD", &idx); | |
11950 | cl_number_or_name = argv[idx]->arg; | |
11951 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11952 | argv_find (argv, argc, "AA:NN", &idx); | |
11953 | char *str = argv_concat (argv, argc, idx); | |
11954 | ||
11955 | int ret = extcommunity_list_set (bgp_clist, cl_number_or_name, str, direct, style); | |
11956 | ||
11957 | XFREE (MTYPE_TMP, str); | |
11958 | ||
11959 | if (ret < 0) | |
11960 | { | |
11961 | community_list_perror (vty, ret); | |
11962 | return CMD_WARNING; | |
11963 | } | |
11964 | ||
11965 | return CMD_SUCCESS; | |
718e3744 | 11966 | } |
11967 | ||
718e3744 | 11968 | DEFUN (ip_extcommunity_list_name_expanded, |
11969 | ip_extcommunity_list_name_expanded_cmd, | |
e961923c | 11970 | "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 11971 | IP_STR |
11972 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 11973 | "Extended Community list number (expanded)\n" |
718e3744 | 11974 | "Specify expanded extcommunity-list\n" |
11975 | "Extended Community list name\n" | |
11976 | "Specify community to reject\n" | |
11977 | "Specify community to accept\n" | |
11978 | "An ordered list as a regular-expression\n") | |
11979 | { | |
42f914d4 QY |
11980 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
11981 | int direct = 0; | |
11982 | char *cl_number_or_name = NULL; | |
11983 | ||
11984 | int idx = 0; | |
11985 | argv_find (argv, argc, "(100-500)", &idx); | |
11986 | argv_find (argv, argc, "WORD", &idx); | |
11987 | cl_number_or_name = argv[idx]->arg; | |
11988 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11989 | argv_find (argv, argc, "LINE", &idx); | |
11990 | char *str = argv_concat (argv, argc, idx); | |
11991 | ||
11992 | int ret = extcommunity_list_set (bgp_clist, cl_number_or_name, str, direct, style); | |
11993 | ||
11994 | XFREE (MTYPE_TMP, str); | |
11995 | ||
11996 | if (ret < 0) | |
11997 | { | |
11998 | community_list_perror (vty, ret); | |
11999 | return CMD_WARNING; | |
12000 | } | |
12001 | ||
12002 | return CMD_SUCCESS; | |
718e3744 | 12003 | } |
12004 | ||
fee6e4e4 | 12005 | DEFUN (no_ip_extcommunity_list_standard_all, |
12006 | no_ip_extcommunity_list_standard_all_cmd, | |
e961923c | 12007 | "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
813d4307 DW |
12008 | NO_STR |
12009 | IP_STR | |
12010 | EXTCOMMUNITY_LIST_STR | |
12011 | "Extended Community list number (standard)\n" | |
718e3744 | 12012 | "Specify standard extcommunity-list\n" |
5bf15956 | 12013 | "Community list name\n" |
718e3744 | 12014 | "Specify community to reject\n" |
12015 | "Specify community to accept\n" | |
12016 | EXTCOMMUNITY_VAL_STR) | |
12017 | { | |
42f914d4 QY |
12018 | int deleteall = 0; |
12019 | ||
12020 | int style = EXTCOMMUNITY_LIST_STANDARD; | |
12021 | int direct = 0; | |
12022 | char *cl_number_or_name = NULL; | |
12023 | ||
12024 | int idx = 0; | |
12025 | argv_find (argv, argc, "(1-99)", &idx); | |
12026 | argv_find (argv, argc, "WORD", &idx); | |
12027 | cl_number_or_name = argv[idx]->arg; | |
12028 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
12029 | argv_find (argv, argc, "AA:NN", &idx); | |
12030 | char *str = argv_concat (argv, argc, idx); | |
12031 | ||
12032 | int ret = extcommunity_list_unset (bgp_clist, cl_number_or_name, str, direct, style, deleteall); | |
12033 | ||
12034 | XFREE (MTYPE_TMP, str); | |
12035 | ||
12036 | if (ret < 0) | |
12037 | { | |
12038 | community_list_perror (vty, ret); | |
12039 | return CMD_WARNING; | |
12040 | } | |
12041 | ||
12042 | return CMD_SUCCESS; | |
718e3744 | 12043 | } |
12044 | ||
5bf15956 DW |
12045 | DEFUN (no_ip_extcommunity_list_expanded_all, |
12046 | no_ip_extcommunity_list_expanded_all_cmd, | |
e961923c | 12047 | "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 12048 | NO_STR |
12049 | IP_STR | |
12050 | EXTCOMMUNITY_LIST_STR | |
12051 | "Extended Community list number (expanded)\n" | |
718e3744 | 12052 | "Specify expanded extcommunity-list\n" |
5bf15956 | 12053 | "Extended Community list name\n" |
718e3744 | 12054 | "Specify community to reject\n" |
12055 | "Specify community to accept\n" | |
12056 | "An ordered list as a regular-expression\n") | |
12057 | { | |
42f914d4 QY |
12058 | int deleteall = 0; |
12059 | ||
12060 | int style = EXTCOMMUNITY_LIST_EXPANDED; | |
12061 | int direct = 0; | |
12062 | char *cl_number_or_name = NULL; | |
12063 | ||
12064 | int idx = 0; | |
12065 | argv_find (argv, argc, "(100-500)", &idx); | |
12066 | argv_find (argv, argc, "WORD", &idx); | |
12067 | cl_number_or_name = argv[idx]->arg; | |
12068 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
12069 | argv_find (argv, argc, "LINE", &idx); | |
12070 | char *str = argv_concat (argv, argc, idx); | |
12071 | ||
12072 | int ret = extcommunity_list_unset (bgp_clist, cl_number_or_name, str, direct, style, deleteall); | |
12073 | ||
12074 | XFREE (MTYPE_TMP, str); | |
12075 | ||
12076 | if (ret < 0) | |
12077 | { | |
12078 | community_list_perror (vty, ret); | |
12079 | return CMD_WARNING; | |
12080 | } | |
12081 | ||
12082 | return CMD_SUCCESS; | |
718e3744 | 12083 | } |
12084 | ||
94f2b392 | 12085 | static void |
718e3744 | 12086 | extcommunity_list_show (struct vty *vty, struct community_list *list) |
12087 | { | |
12088 | struct community_entry *entry; | |
12089 | ||
12090 | for (entry = list->head; entry; entry = entry->next) | |
12091 | { | |
12092 | if (entry == list->head) | |
12093 | { | |
12094 | if (all_digit (list->name)) | |
12095 | vty_out (vty, "Extended community %s list %s%s", | |
12096 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
12097 | "standard" : "(expanded) access", | |
12098 | list->name, VTY_NEWLINE); | |
12099 | else | |
12100 | vty_out (vty, "Named extended community %s list %s%s", | |
12101 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
12102 | "standard" : "expanded", | |
12103 | list->name, VTY_NEWLINE); | |
12104 | } | |
12105 | if (entry->any) | |
12106 | vty_out (vty, " %s%s", | |
12107 | community_direct_str (entry->direct), VTY_NEWLINE); | |
12108 | else | |
12109 | vty_out (vty, " %s %s%s", | |
12110 | community_direct_str (entry->direct), | |
12111 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
12112 | entry->u.ecom->str : entry->config, | |
12113 | VTY_NEWLINE); | |
12114 | } | |
12115 | } | |
12116 | ||
12117 | DEFUN (show_ip_extcommunity_list, | |
12118 | show_ip_extcommunity_list_cmd, | |
12119 | "show ip extcommunity-list", | |
12120 | SHOW_STR | |
12121 | IP_STR | |
12122 | "List extended-community list\n") | |
12123 | { | |
12124 | struct community_list *list; | |
12125 | struct community_list_master *cm; | |
12126 | ||
fee6e4e4 | 12127 | cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
718e3744 | 12128 | if (! cm) |
12129 | return CMD_SUCCESS; | |
12130 | ||
12131 | for (list = cm->num.head; list; list = list->next) | |
12132 | extcommunity_list_show (vty, list); | |
12133 | ||
12134 | for (list = cm->str.head; list; list = list->next) | |
12135 | extcommunity_list_show (vty, list); | |
12136 | ||
12137 | return CMD_SUCCESS; | |
12138 | } | |
12139 | ||
12140 | DEFUN (show_ip_extcommunity_list_arg, | |
12141 | show_ip_extcommunity_list_arg_cmd, | |
6147e2c6 | 12142 | "show ip extcommunity-list <(1-500)|WORD>", |
718e3744 | 12143 | SHOW_STR |
12144 | IP_STR | |
12145 | "List extended-community list\n" | |
12146 | "Extcommunity-list number\n" | |
12147 | "Extcommunity-list name\n") | |
12148 | { | |
c500ae40 | 12149 | int idx_comm_list = 3; |
718e3744 | 12150 | struct community_list *list; |
12151 | ||
c500ae40 | 12152 | list = community_list_lookup (bgp_clist, argv[idx_comm_list]->arg, EXTCOMMUNITY_LIST_MASTER); |
718e3744 | 12153 | if (! list) |
12154 | { | |
b729294c | 12155 | vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE); |
718e3744 | 12156 | return CMD_WARNING; |
12157 | } | |
12158 | ||
12159 | extcommunity_list_show (vty, list); | |
12160 | ||
12161 | return CMD_SUCCESS; | |
12162 | } | |
6b0655a2 | 12163 | |
718e3744 | 12164 | /* Return configuration string of community-list entry. */ |
fd79ac91 | 12165 | static const char * |
718e3744 | 12166 | community_list_config_str (struct community_entry *entry) |
12167 | { | |
fd79ac91 | 12168 | const char *str; |
718e3744 | 12169 | |
12170 | if (entry->any) | |
12171 | str = ""; | |
12172 | else | |
12173 | { | |
12174 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
12175 | str = community_str (entry->u.com); | |
12176 | else | |
12177 | str = entry->config; | |
12178 | } | |
12179 | return str; | |
12180 | } | |
12181 | ||
12182 | /* Display community-list and extcommunity-list configuration. */ | |
94f2b392 | 12183 | static int |
718e3744 | 12184 | community_list_config_write (struct vty *vty) |
12185 | { | |
12186 | struct community_list *list; | |
12187 | struct community_entry *entry; | |
12188 | struct community_list_master *cm; | |
12189 | int write = 0; | |
12190 | ||
12191 | /* Community-list. */ | |
fee6e4e4 | 12192 | cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER); |
718e3744 | 12193 | |
12194 | for (list = cm->num.head; list; list = list->next) | |
12195 | for (entry = list->head; entry; entry = entry->next) | |
12196 | { | |
fee6e4e4 | 12197 | vty_out (vty, "ip community-list %s %s %s%s", |
12198 | list->name, community_direct_str (entry->direct), | |
12199 | community_list_config_str (entry), | |
12200 | VTY_NEWLINE); | |
718e3744 | 12201 | write++; |
12202 | } | |
12203 | for (list = cm->str.head; list; list = list->next) | |
12204 | for (entry = list->head; entry; entry = entry->next) | |
12205 | { | |
12206 | vty_out (vty, "ip community-list %s %s %s %s%s", | |
12207 | entry->style == COMMUNITY_LIST_STANDARD | |
12208 | ? "standard" : "expanded", | |
12209 | list->name, community_direct_str (entry->direct), | |
12210 | community_list_config_str (entry), | |
12211 | VTY_NEWLINE); | |
12212 | write++; | |
12213 | } | |
12214 | ||
12215 | /* Extcommunity-list. */ | |
fee6e4e4 | 12216 | cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
718e3744 | 12217 | |
12218 | for (list = cm->num.head; list; list = list->next) | |
12219 | for (entry = list->head; entry; entry = entry->next) | |
12220 | { | |
fee6e4e4 | 12221 | vty_out (vty, "ip extcommunity-list %s %s %s%s", |
12222 | list->name, community_direct_str (entry->direct), | |
12223 | community_list_config_str (entry), VTY_NEWLINE); | |
718e3744 | 12224 | write++; |
12225 | } | |
12226 | for (list = cm->str.head; list; list = list->next) | |
12227 | for (entry = list->head; entry; entry = entry->next) | |
12228 | { | |
12229 | vty_out (vty, "ip extcommunity-list %s %s %s %s%s", | |
12230 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
12231 | ? "standard" : "expanded", | |
12232 | list->name, community_direct_str (entry->direct), | |
12233 | community_list_config_str (entry), VTY_NEWLINE); | |
12234 | write++; | |
12235 | } | |
57d187bc JS |
12236 | |
12237 | ||
12238 | /* lcommunity-list. */ | |
12239 | cm = community_list_master_lookup (bgp_clist, LARGE_COMMUNITY_LIST_MASTER); | |
12240 | ||
12241 | for (list = cm->num.head; list; list = list->next) | |
12242 | for (entry = list->head; entry; entry = entry->next) | |
12243 | { | |
2acb4ac2 DL |
12244 | vty_out (vty, "ip large-community-list %s %s %s%s", |
12245 | list->name, community_direct_str (entry->direct), | |
12246 | community_list_config_str (entry), VTY_NEWLINE); | |
12247 | write++; | |
57d187bc JS |
12248 | } |
12249 | for (list = cm->str.head; list; list = list->next) | |
12250 | for (entry = list->head; entry; entry = entry->next) | |
12251 | { | |
2acb4ac2 DL |
12252 | vty_out (vty, "ip large-community-list %s %s %s %s%s", |
12253 | entry->style == LARGE_COMMUNITY_LIST_STANDARD | |
12254 | ? "standard" : "expanded", | |
12255 | list->name, community_direct_str (entry->direct), | |
12256 | community_list_config_str (entry), VTY_NEWLINE); | |
12257 | write++; | |
57d187bc JS |
12258 | } |
12259 | ||
718e3744 | 12260 | return write; |
12261 | } | |
12262 | ||
7fc626de | 12263 | static struct cmd_node community_list_node = |
718e3744 | 12264 | { |
12265 | COMMUNITY_LIST_NODE, | |
12266 | "", | |
12267 | 1 /* Export to vtysh. */ | |
12268 | }; | |
12269 | ||
94f2b392 | 12270 | static void |
12271 | community_list_vty (void) | |
718e3744 | 12272 | { |
12273 | install_node (&community_list_node, community_list_config_write); | |
12274 | ||
12275 | /* Community-list. */ | |
718e3744 | 12276 | install_element (CONFIG_NODE, &ip_community_list_standard_cmd); |
d7d73ffc | 12277 | install_element (CONFIG_NODE, &ip_community_list_expanded_all_cmd); |
fee6e4e4 | 12278 | install_element (CONFIG_NODE, &no_ip_community_list_standard_all_cmd); |
12279 | install_element (CONFIG_NODE, &no_ip_community_list_expanded_all_cmd); | |
718e3744 | 12280 | install_element (VIEW_NODE, &show_ip_community_list_cmd); |
12281 | install_element (VIEW_NODE, &show_ip_community_list_arg_cmd); | |
718e3744 | 12282 | |
12283 | /* Extcommunity-list. */ | |
12284 | install_element (CONFIG_NODE, &ip_extcommunity_list_standard_cmd); | |
718e3744 | 12285 | install_element (CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd); |
fee6e4e4 | 12286 | install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd); |
12287 | install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd); | |
718e3744 | 12288 | install_element (VIEW_NODE, &show_ip_extcommunity_list_cmd); |
12289 | install_element (VIEW_NODE, &show_ip_extcommunity_list_arg_cmd); | |
57d187bc JS |
12290 | |
12291 | /* Large Community List */ | |
12292 | install_element (CONFIG_NODE, &ip_lcommunity_list_standard_cmd); | |
52951b63 | 12293 | install_element (CONFIG_NODE, &ip_lcommunity_list_standard1_cmd); |
57d187bc JS |
12294 | install_element (CONFIG_NODE, &ip_lcommunity_list_expanded_cmd); |
12295 | install_element (CONFIG_NODE, &ip_lcommunity_list_name_standard_cmd); | |
52951b63 | 12296 | install_element (CONFIG_NODE, &ip_lcommunity_list_name_standard1_cmd); |
57d187bc JS |
12297 | install_element (CONFIG_NODE, &ip_lcommunity_list_name_expanded_cmd); |
12298 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_standard_all_cmd); | |
12299 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_all_cmd); | |
12300 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_standard_cmd); | |
12301 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_expanded_cmd); | |
12302 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_name_standard_cmd); | |
12303 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_cmd); | |
12304 | install_element (VIEW_NODE, &show_ip_lcommunity_list_cmd); | |
12305 | install_element (VIEW_NODE, &show_ip_lcommunity_list_arg_cmd); | |
5bf15956 | 12306 | } |