]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* BGP VTY interface. |
896014f4 DL |
2 | * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro |
3 | * | |
4 | * This file is part of GNU Zebra. | |
5 | * | |
6 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
7 | * under the terms of the GNU General Public License as published by the | |
8 | * Free Software Foundation; either version 2, or (at your option) any | |
9 | * later version. | |
10 | * | |
11 | * GNU Zebra is distributed in the hope that it will be useful, but | |
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License along | |
17 | * with this program; see the file COPYING; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | */ | |
718e3744 | 20 | |
21 | #include <zebra.h> | |
22 | ||
23 | #include "command.h" | |
afec25d9 | 24 | #include "lib/json.h" |
718e3744 | 25 | #include "prefix.h" |
26 | #include "plist.h" | |
27 | #include "buffer.h" | |
28 | #include "linklist.h" | |
29 | #include "stream.h" | |
30 | #include "thread.h" | |
31 | #include "log.h" | |
3b8b1855 | 32 | #include "memory.h" |
fc7948fa | 33 | #include "memory_vty.h" |
4bf6a362 | 34 | #include "hash.h" |
3f9c7369 | 35 | #include "queue.h" |
039f3a34 | 36 | #include "filter.h" |
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); | |
20aeb970 | 63 | |
f51bae9c DS |
64 | static enum node_type |
65 | bgp_node_type (afi_t afi, safi_t safi) | |
66 | { | |
67 | switch (afi) | |
68 | { | |
69 | case AFI_IP: | |
70 | switch (safi) | |
71 | { | |
72 | case SAFI_UNICAST: | |
73 | return BGP_IPV4_NODE; | |
74 | break; | |
75 | case SAFI_MULTICAST: | |
76 | return BGP_IPV4M_NODE; | |
77 | break; | |
78 | case SAFI_LABELED_UNICAST: | |
79 | return BGP_IPV4L_NODE; | |
80 | break; | |
81 | case SAFI_MPLS_VPN: | |
82 | return BGP_VPNV4_NODE; | |
83 | break; | |
84 | case SAFI_ENCAP: | |
85 | return BGP_ENCAP_NODE; | |
86 | break; | |
f51bae9c DS |
87 | } |
88 | break; | |
89 | case AFI_IP6: | |
90 | switch (safi) | |
91 | { | |
92 | case SAFI_UNICAST: | |
93 | return BGP_IPV6_NODE; | |
94 | break; | |
95 | case SAFI_MULTICAST: | |
96 | return BGP_IPV6M_NODE; | |
97 | break; | |
98 | case SAFI_LABELED_UNICAST: | |
99 | return BGP_IPV6L_NODE; | |
100 | break; | |
101 | case SAFI_MPLS_VPN: | |
102 | return BGP_VPNV6_NODE; | |
103 | break; | |
104 | case SAFI_ENCAP: | |
20aeb970 | 105 | return BGP_ENCAPV6_NODE; |
f51bae9c | 106 | break; |
f51bae9c DS |
107 | } |
108 | break; | |
b3b3879c DS |
109 | case AFI_L2VPN: |
110 | return BGP_EVPN_NODE; | |
111 | break; | |
112 | case AFI_MAX: | |
113 | // We should never be here but to clarify the switch statement.. | |
114 | return BGP_IPV4_NODE; | |
f51bae9c DS |
115 | break; |
116 | } | |
b3b3879c DS |
117 | |
118 | // Impossible to happen | |
119 | return BGP_IPV4_NODE; | |
f51bae9c | 120 | } |
20eb8864 | 121 | |
718e3744 | 122 | /* Utility function to get address family from current node. */ |
123 | afi_t | |
124 | bgp_node_afi (struct vty *vty) | |
125 | { | |
4e851f1f LB |
126 | afi_t afi; |
127 | switch (vty->node) | |
128 | { | |
129 | case BGP_IPV6_NODE: | |
130 | case BGP_IPV6M_NODE: | |
f51bae9c | 131 | case BGP_IPV6L_NODE: |
4e851f1f LB |
132 | case BGP_VPNV6_NODE: |
133 | case BGP_ENCAPV6_NODE: | |
134 | afi = AFI_IP6; | |
135 | break; | |
4e0b7b6d PG |
136 | case BGP_EVPN_NODE: |
137 | afi = AFI_L2VPN; | |
138 | break; | |
4e851f1f LB |
139 | default: |
140 | afi = AFI_IP; | |
141 | break; | |
142 | } | |
143 | return afi; | |
718e3744 | 144 | } |
145 | ||
146 | /* Utility function to get subsequent address family from current | |
147 | node. */ | |
148 | safi_t | |
149 | bgp_node_safi (struct vty *vty) | |
150 | { | |
4e851f1f LB |
151 | safi_t safi; |
152 | switch (vty->node) | |
153 | { | |
154 | case BGP_ENCAP_NODE: | |
155 | case BGP_ENCAPV6_NODE: | |
156 | safi = SAFI_ENCAP; | |
157 | break; | |
158 | case BGP_VPNV4_NODE: | |
159 | case BGP_VPNV6_NODE: | |
160 | safi = SAFI_MPLS_VPN; | |
161 | break; | |
162 | case BGP_IPV4M_NODE: | |
163 | case BGP_IPV6M_NODE: | |
164 | safi = SAFI_MULTICAST; | |
165 | break; | |
4e0b7b6d PG |
166 | case BGP_EVPN_NODE: |
167 | safi = SAFI_EVPN; | |
168 | break; | |
f51bae9c DS |
169 | case BGP_IPV4L_NODE: |
170 | case BGP_IPV6L_NODE: | |
171 | safi = SAFI_LABELED_UNICAST; | |
172 | break; | |
4e851f1f LB |
173 | default: |
174 | safi = SAFI_UNICAST; | |
175 | break; | |
176 | } | |
177 | return safi; | |
718e3744 | 178 | } |
179 | ||
46f296b4 LB |
180 | /* supports <ipv4|ipv6> */ |
181 | afi_t | |
182 | bgp_vty_afi_from_arg(const char *afi_str) | |
8b1fb8be | 183 | { |
46f296b4 LB |
184 | afi_t afi = AFI_MAX; /* unknown */ |
185 | if (!strcmp(afi_str, "ipv4")) { | |
186 | afi = AFI_IP; | |
8b1fb8be | 187 | } |
46f296b4 LB |
188 | else if (!strcmp(afi_str, "ipv6")) { |
189 | afi = AFI_IP6; | |
190 | } | |
4e0b7b6d PG |
191 | else if (!strcmp(afi_str, "l2vpn")) { |
192 | afi = AFI_L2VPN; | |
193 | } | |
46f296b4 LB |
194 | return afi; |
195 | } | |
196 | ||
197 | int | |
198 | bgp_parse_afi(const char *str, afi_t *afi) | |
199 | { | |
200 | *afi = bgp_vty_afi_from_arg(str); | |
201 | if (*afi != AFI_MAX) | |
202 | return 0; | |
203 | else | |
8b1fb8be LB |
204 | return -1; |
205 | } | |
206 | ||
46f296b4 LB |
207 | int |
208 | argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, afi_t *afi) | |
209 | { | |
210 | int ret = 0; | |
211 | if (argv_find (argv, argc, "ipv4", index)) | |
212 | { | |
213 | ret = 1; | |
214 | if (afi) | |
215 | *afi = AFI_IP; | |
216 | } | |
217 | else if (argv_find (argv, argc, "ipv6", index)) | |
218 | { | |
219 | ret = 1; | |
220 | if (afi) | |
221 | *afi = AFI_IP6; | |
222 | } | |
223 | return ret; | |
224 | } | |
225 | ||
f51bae9c | 226 | /* supports <unicast|multicast|vpn|encap|labeled-unicast> */ |
ccbb332a | 227 | safi_t |
3b14d86e | 228 | bgp_vty_safi_from_arg(const char *safi_str) |
ccbb332a LB |
229 | { |
230 | safi_t safi = SAFI_MAX; /* unknown */ | |
231 | if (strncmp (safi_str, "m", 1) == 0) | |
232 | safi = SAFI_MULTICAST; | |
233 | else if (strncmp (safi_str, "u", 1) == 0) | |
234 | safi = SAFI_UNICAST; | |
235 | else if (strncmp (safi_str, "e", 1) == 0) | |
236 | safi = SAFI_ENCAP; | |
237 | else if (strncmp (safi_str, "v", 1) == 0) | |
46f296b4 | 238 | safi = SAFI_MPLS_VPN; |
f51bae9c DS |
239 | else if (strncmp (safi_str, "l", 1) == 0) |
240 | safi = SAFI_LABELED_UNICAST; | |
ccbb332a LB |
241 | return safi; |
242 | } | |
243 | ||
8b1fb8be | 244 | int |
3289141f | 245 | argv_find_and_parse_safi (struct cmd_token **argv, int argc, int *index, safi_t *safi) |
46f296b4 LB |
246 | { |
247 | int ret = 0; | |
248 | if (argv_find (argv, argc, "unicast", index)) | |
249 | { | |
250 | ret = 1; | |
251 | if (safi) | |
252 | *safi = SAFI_UNICAST; | |
253 | } | |
254 | else if (argv_find (argv, argc, "multicast", index)) | |
255 | { | |
256 | ret = 1; | |
257 | if (safi) | |
258 | *safi = SAFI_MULTICAST; | |
259 | } | |
b60f5275 DS |
260 | else if (argv_find (argv, argc, "labeled-unicast", index)) |
261 | { | |
262 | ret = 1; | |
263 | if (safi) | |
264 | *safi = SAFI_LABELED_UNICAST; | |
265 | } | |
46f296b4 LB |
266 | else if (argv_find (argv, argc, "vpn", index)) |
267 | { | |
268 | ret = 1; | |
269 | if (safi) | |
270 | *safi = SAFI_MPLS_VPN; | |
271 | } | |
272 | else if (argv_find (argv, argc, "encap", index)) | |
273 | { | |
274 | ret = 1; | |
275 | if (safi) | |
276 | *safi = SAFI_ENCAP; | |
277 | } | |
4e0b7b6d PG |
278 | else if (argv_find (argv, argc, "evpn", index)) |
279 | { | |
280 | ret = 1; | |
281 | if (safi) | |
282 | *safi = SAFI_EVPN; | |
283 | } | |
46f296b4 LB |
284 | return ret; |
285 | } | |
286 | ||
7eeee51e | 287 | /* |
f212a857 | 288 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 289 | * |
f212a857 DS |
290 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
291 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
292 | * to appropriate values for the calling function. This is to allow the |
293 | * calling function to make decisions appropriate for the show command | |
294 | * that is being parsed. | |
295 | * | |
296 | * The show commands are generally of the form: | |
b60f5275 | 297 | * "show [ip] bgp [<view|vrf> WORD] [<ipv4|ipv6> [<unicast|multicast|vpn|encap|labeled-unicast>]] ..." |
7eeee51e DS |
298 | * |
299 | * Since we use argv_find if the show command in particular doesn't have: | |
300 | * [ip] | |
301 | * [<view|vrf> WORD] | |
b60f5275 | 302 | * [<ipv4|ipv6> [<unicast|multicast|vpn|encap|labeled-unicast>]] |
7eeee51e DS |
303 | * The command parsing should still be ok. |
304 | * | |
305 | * vty -> The vty for the command so we can output some useful data in | |
306 | * the event of a parse error in the vrf. | |
307 | * argv -> The command tokens | |
308 | * argc -> How many command tokens we have | |
309 | * idx -> The current place in the command, generally should be 0 for this function | |
310 | * afi -> The parsed afi if it was included in the show command, returned here | |
311 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 312 | * bgp -> Pointer to the bgp data structure we need to fill in. |
7eeee51e DS |
313 | * |
314 | * The function returns the correct location in the parse tree for the | |
315 | * last token found. | |
0e37c258 DS |
316 | * |
317 | * Returns 0 for failure to parse correctly, else the idx position of where | |
318 | * it found the last token. | |
7eeee51e | 319 | */ |
af462945 | 320 | int |
f212a857 DS |
321 | bgp_vty_find_and_parse_afi_safi_bgp (struct vty *vty, struct cmd_token **argv, int argc, int *idx, |
322 | afi_t *afi, safi_t *safi, struct bgp **bgp) | |
af462945 DS |
323 | { |
324 | char *vrf_name = NULL; | |
325 | ||
b4898a38 DS |
326 | assert (afi); |
327 | assert (safi); | |
f212a857 | 328 | assert (bgp); |
b4898a38 | 329 | |
9317e17d | 330 | if (argv_find (argv, argc, "ip", idx)) |
af462945 DS |
331 | *afi = AFI_IP; |
332 | ||
9317e17d | 333 | if (argv_find (argv, argc, "view", idx) || argv_find (argv, argc, "vrf", idx)) |
af462945 | 334 | { |
9317e17d | 335 | vrf_name = argv[*idx + 1]->arg; |
af462945 | 336 | |
f212a857 DS |
337 | if (strmatch (vrf_name, "all")) |
338 | *bgp = NULL; | |
af462945 | 339 | else |
f212a857 DS |
340 | { |
341 | *bgp = bgp_lookup_by_name (vrf_name); | |
342 | if (!*bgp) | |
343 | { | |
344 | vty_out (vty, "View/Vrf specified is unknown: %s%s", vrf_name, VTY_NEWLINE); | |
345 | *idx = 0; | |
346 | return 0; | |
347 | } | |
348 | } | |
af462945 | 349 | } |
f212a857 | 350 | else |
af462945 | 351 | { |
f212a857 DS |
352 | *bgp = bgp_get_default (); |
353 | if (!*bgp) | |
354 | { | |
355 | vty_out (vty, "Unable to find default BGP instance%s", VTY_NEWLINE); | |
356 | *idx = 0; | |
357 | return 0; | |
358 | } | |
af462945 | 359 | } |
9317e17d | 360 | |
f212a857 DS |
361 | if (argv_find_and_parse_afi (argv, argc, idx, afi)) |
362 | argv_find_and_parse_safi (argv, argc, idx, safi); | |
363 | ||
9317e17d DS |
364 | *idx += 1; |
365 | return *idx; | |
af462945 DS |
366 | } |
367 | ||
94f2b392 | 368 | static int |
6aeb9e78 | 369 | peer_address_self_check (struct bgp *bgp, union sockunion *su) |
718e3744 | 370 | { |
371 | struct interface *ifp = NULL; | |
372 | ||
373 | if (su->sa.sa_family == AF_INET) | |
6aeb9e78 | 374 | ifp = if_lookup_by_ipv4_exact (&su->sin.sin_addr, bgp->vrf_id); |
718e3744 | 375 | else if (su->sa.sa_family == AF_INET6) |
f2345335 | 376 | ifp = if_lookup_by_ipv6_exact (&su->sin6.sin6_addr, |
6aeb9e78 | 377 | su->sin6.sin6_scope_id, bgp->vrf_id); |
718e3744 | 378 | |
379 | if (ifp) | |
380 | return 1; | |
381 | ||
382 | return 0; | |
383 | } | |
384 | ||
385 | /* Utility function for looking up peer from VTY. */ | |
f14e6fdb DS |
386 | /* This is used only for configuration, so disallow if attempted on |
387 | * a dynamic neighbor. | |
388 | */ | |
94f2b392 | 389 | static struct peer * |
fd79ac91 | 390 | peer_lookup_vty (struct vty *vty, const char *ip_str) |
718e3744 | 391 | { |
cdc2d765 | 392 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); |
718e3744 | 393 | int ret; |
718e3744 | 394 | union sockunion su; |
395 | struct peer *peer; | |
396 | ||
cdc2d765 DL |
397 | if (!bgp) { |
398 | return NULL; | |
399 | } | |
718e3744 | 400 | |
401 | ret = str2sockunion (ip_str, &su); | |
402 | if (ret < 0) | |
403 | { | |
a80beece DS |
404 | peer = peer_lookup_by_conf_if (bgp, ip_str); |
405 | if (!peer) | |
406 | { | |
04b6bdc0 DW |
407 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) == NULL) |
408 | { | |
409 | vty_out (vty, "%% Malformed address or name: %s%s", ip_str, VTY_NEWLINE); | |
410 | return NULL; | |
411 | } | |
a80beece | 412 | } |
718e3744 | 413 | } |
a80beece | 414 | else |
718e3744 | 415 | { |
a80beece DS |
416 | peer = peer_lookup (bgp, &su); |
417 | if (! peer) | |
418 | { | |
419 | vty_out (vty, "%% Specify remote-as or peer-group commands first%s", | |
420 | VTY_NEWLINE); | |
421 | return NULL; | |
422 | } | |
f14e6fdb DS |
423 | if (peer_dynamic_neighbor (peer)) |
424 | { | |
425 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
426 | VTY_NEWLINE); | |
427 | return NULL; | |
428 | } | |
429 | ||
718e3744 | 430 | } |
431 | return peer; | |
432 | } | |
433 | ||
434 | /* Utility function for looking up peer or peer group. */ | |
f14e6fdb DS |
435 | /* This is used only for configuration, so disallow if attempted on |
436 | * a dynamic neighbor. | |
437 | */ | |
c43ed2e4 | 438 | struct peer * |
fd79ac91 | 439 | peer_and_group_lookup_vty (struct vty *vty, const char *peer_str) |
718e3744 | 440 | { |
cdc2d765 | 441 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); |
718e3744 | 442 | int ret; |
718e3744 | 443 | union sockunion su; |
f14e6fdb DS |
444 | struct peer *peer = NULL; |
445 | struct peer_group *group = NULL; | |
718e3744 | 446 | |
cdc2d765 DL |
447 | if (!bgp) { |
448 | return NULL; | |
449 | } | |
718e3744 | 450 | |
451 | ret = str2sockunion (peer_str, &su); | |
452 | if (ret == 0) | |
453 | { | |
f14e6fdb | 454 | /* IP address, locate peer. */ |
718e3744 | 455 | peer = peer_lookup (bgp, &su); |
718e3744 | 456 | } |
457 | else | |
458 | { | |
f14e6fdb | 459 | /* Not IP, could match either peer configured on interface or a group. */ |
a80beece | 460 | peer = peer_lookup_by_conf_if (bgp, peer_str); |
f14e6fdb DS |
461 | if (!peer) |
462 | group = peer_group_lookup (bgp, peer_str); | |
463 | } | |
a80beece | 464 | |
f14e6fdb DS |
465 | if (peer) |
466 | { | |
467 | if (peer_dynamic_neighbor (peer)) | |
468 | { | |
469 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
470 | VTY_NEWLINE); | |
471 | return NULL; | |
472 | } | |
473 | ||
474 | return peer; | |
718e3744 | 475 | } |
476 | ||
f14e6fdb DS |
477 | if (group) |
478 | return group->conf; | |
479 | ||
718e3744 | 480 | vty_out (vty, "%% Specify remote-as or peer-group commands first%s", |
481 | VTY_NEWLINE); | |
482 | ||
483 | return NULL; | |
484 | } | |
485 | ||
c43ed2e4 | 486 | int |
718e3744 | 487 | bgp_vty_return (struct vty *vty, int ret) |
488 | { | |
fd79ac91 | 489 | const char *str = NULL; |
718e3744 | 490 | |
491 | switch (ret) | |
492 | { | |
493 | case BGP_ERR_INVALID_VALUE: | |
494 | str = "Invalid value"; | |
495 | break; | |
496 | case BGP_ERR_INVALID_FLAG: | |
497 | str = "Invalid flag"; | |
498 | break; | |
718e3744 | 499 | case BGP_ERR_PEER_GROUP_SHUTDOWN: |
500 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
501 | break; | |
718e3744 | 502 | case BGP_ERR_PEER_FLAG_CONFLICT: |
503 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
504 | break; | |
718e3744 | 505 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: |
506 | str = "Specify remote-as or peer-group remote AS first"; | |
507 | break; | |
508 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
509 | str = "Cannot change the peer-group. Deconfigure first"; | |
510 | break; | |
511 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
4c48cf63 | 512 | str = "Peer is not a member of this peer-group"; |
718e3744 | 513 | break; |
514 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
515 | str = "Prefix/distribute list can not co-exist"; | |
516 | break; | |
517 | case BGP_ERR_NOT_INTERNAL_PEER: | |
518 | str = "Invalid command. Not an internal neighbor"; | |
519 | break; | |
520 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
5000f21c | 521 | str = "remove-private-AS cannot be configured for IBGP peers"; |
718e3744 | 522 | break; |
523 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
524 | str = "Local-AS allowed only for EBGP peers"; | |
525 | break; | |
526 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
527 | str = "Cannot have local-as same as BGP AS number"; | |
528 | break; | |
0df7c91f PJ |
529 | case BGP_ERR_TCPSIG_FAILED: |
530 | str = "Error while applying TCP-Sig to session(s)"; | |
531 | break; | |
fa411a21 NH |
532 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: |
533 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
534 | break; | |
f5a4827d SH |
535 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: |
536 | str = "ttl-security only allowed for EBGP peers"; | |
537 | break; | |
c7122e14 DS |
538 | case BGP_ERR_AS_OVERRIDE: |
539 | str = "as-override cannot be configured for IBGP peers"; | |
540 | break; | |
f14e6fdb DS |
541 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: |
542 | str = "Invalid limit for number of dynamic neighbors"; | |
543 | break; | |
544 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
545 | str = "Dynamic neighbor listen range already exists"; | |
546 | break; | |
547 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
548 | str = "Operation not allowed on a dynamic neighbor"; | |
549 | break; | |
63fa10b5 QY |
550 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: |
551 | str = "Operation not allowed on a directly connected neighbor"; | |
552 | break; | |
718e3744 | 553 | } |
554 | if (str) | |
555 | { | |
556 | vty_out (vty, "%% %s%s", str, VTY_NEWLINE); | |
557 | return CMD_WARNING; | |
558 | } | |
559 | return CMD_SUCCESS; | |
560 | } | |
561 | ||
7aafcaca DS |
562 | /* BGP clear sort. */ |
563 | enum clear_sort | |
564 | { | |
565 | clear_all, | |
566 | clear_peer, | |
567 | clear_group, | |
568 | clear_external, | |
569 | clear_as | |
570 | }; | |
571 | ||
7aafcaca DS |
572 | static void |
573 | bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi, | |
574 | safi_t safi, int error) | |
575 | { | |
576 | switch (error) | |
577 | { | |
578 | case BGP_ERR_AF_UNCONFIGURED: | |
579 | vty_out (vty, | |
46f296b4 LB |
580 | "%%BGP: Enable %s address family for the neighbor %s%s", |
581 | afi_safi_print(afi, safi), peer->host, VTY_NEWLINE); | |
7aafcaca DS |
582 | break; |
583 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
584 | 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); | |
585 | break; | |
586 | default: | |
587 | break; | |
588 | } | |
589 | } | |
590 | ||
591 | /* `clear ip bgp' functions. */ | |
592 | static int | |
593 | bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, | |
594 | enum clear_sort sort,enum bgp_clear_type stype, const char *arg) | |
595 | { | |
596 | int ret; | |
597 | struct peer *peer; | |
598 | struct listnode *node, *nnode; | |
599 | ||
600 | /* Clear all neighbors. */ | |
601 | /* | |
602 | * Pass along pointer to next node to peer_clear() when walking all nodes | |
603 | * on the BGP instance as that may get freed if it is a doppelganger | |
604 | */ | |
605 | if (sort == clear_all) | |
606 | { | |
607 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
608 | { | |
609 | if (stype == BGP_CLEAR_SOFT_NONE) | |
610 | ret = peer_clear (peer, &nnode); | |
611 | else if (peer->afc[afi][safi]) | |
612 | ret = peer_clear_soft (peer, afi, safi, stype); | |
613 | else | |
614 | ret = 0; | |
615 | ||
616 | if (ret < 0) | |
617 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
618 | } | |
619 | ||
620 | /* This is to apply read-only mode on this clear. */ | |
621 | if (stype == BGP_CLEAR_SOFT_NONE) | |
622 | bgp->update_delay_over = 0; | |
623 | ||
624 | return CMD_SUCCESS; | |
625 | } | |
626 | ||
627 | /* Clear specified neighbors. */ | |
628 | if (sort == clear_peer) | |
629 | { | |
630 | union sockunion su; | |
631 | int ret; | |
632 | ||
633 | /* Make sockunion for lookup. */ | |
634 | ret = str2sockunion (arg, &su); | |
635 | if (ret < 0) | |
636 | { | |
637 | peer = peer_lookup_by_conf_if (bgp, arg); | |
638 | if (!peer) | |
639 | { | |
04b6bdc0 DW |
640 | peer = peer_lookup_by_hostname(bgp, arg); |
641 | if (!peer) | |
642 | { | |
643 | vty_out (vty, "Malformed address or name: %s%s", arg, VTY_NEWLINE); | |
644 | return CMD_WARNING; | |
645 | } | |
7aafcaca DS |
646 | } |
647 | } | |
648 | else | |
649 | { | |
650 | peer = peer_lookup (bgp, &su); | |
651 | if (! peer) | |
652 | { | |
653 | vty_out (vty, "%%BGP: Unknown neighbor - \"%s\"%s", arg, VTY_NEWLINE); | |
654 | return CMD_WARNING; | |
655 | } | |
656 | } | |
657 | ||
658 | if (stype == BGP_CLEAR_SOFT_NONE) | |
659 | ret = peer_clear (peer, NULL); | |
660 | else | |
661 | ret = peer_clear_soft (peer, afi, safi, stype); | |
662 | ||
663 | if (ret < 0) | |
664 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
665 | ||
666 | return CMD_SUCCESS; | |
667 | } | |
668 | ||
669 | /* Clear all peer-group members. */ | |
670 | if (sort == clear_group) | |
671 | { | |
672 | struct peer_group *group; | |
673 | ||
674 | group = peer_group_lookup (bgp, arg); | |
675 | if (! group) | |
676 | { | |
677 | vty_out (vty, "%%BGP: No such peer-group %s%s", arg, VTY_NEWLINE); | |
678 | return CMD_WARNING; | |
679 | } | |
680 | ||
681 | for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) | |
682 | { | |
683 | if (stype == BGP_CLEAR_SOFT_NONE) | |
684 | { | |
18f1dc06 | 685 | peer_clear (peer, NULL); |
7aafcaca DS |
686 | continue; |
687 | } | |
688 | ||
c8560b44 | 689 | if (! peer->afc[afi][safi]) |
7aafcaca DS |
690 | continue; |
691 | ||
692 | ret = peer_clear_soft (peer, afi, safi, stype); | |
693 | ||
694 | if (ret < 0) | |
695 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
696 | } | |
697 | return CMD_SUCCESS; | |
698 | } | |
699 | ||
700 | if (sort == clear_external) | |
701 | { | |
702 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
703 | { | |
704 | if (peer->sort == BGP_PEER_IBGP) | |
705 | continue; | |
706 | ||
707 | if (stype == BGP_CLEAR_SOFT_NONE) | |
708 | ret = peer_clear (peer, &nnode); | |
709 | else | |
710 | ret = peer_clear_soft (peer, afi, safi, stype); | |
711 | ||
712 | if (ret < 0) | |
713 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
714 | } | |
715 | return CMD_SUCCESS; | |
716 | } | |
717 | ||
718 | if (sort == clear_as) | |
719 | { | |
720 | as_t as; | |
721 | int find = 0; | |
722 | ||
723 | VTY_GET_INTEGER_RANGE ("AS", as, arg, 1, BGP_AS4_MAX); | |
724 | ||
725 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
726 | { | |
727 | if (peer->as != as) | |
728 | continue; | |
729 | ||
730 | find = 1; | |
731 | if (stype == BGP_CLEAR_SOFT_NONE) | |
732 | ret = peer_clear (peer, &nnode); | |
733 | else | |
734 | ret = peer_clear_soft (peer, afi, safi, stype); | |
735 | ||
736 | if (ret < 0) | |
737 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
738 | } | |
739 | if (! find) | |
740 | vty_out (vty, "%%BGP: No peer is configured with AS %s%s", arg, | |
741 | VTY_NEWLINE); | |
742 | return CMD_SUCCESS; | |
743 | } | |
744 | ||
745 | return CMD_SUCCESS; | |
746 | } | |
747 | ||
748 | static int | |
749 | bgp_clear_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi, | |
750 | enum clear_sort sort, enum bgp_clear_type stype, | |
751 | const char *arg) | |
752 | { | |
753 | struct bgp *bgp; | |
754 | ||
755 | /* BGP structure lookup. */ | |
756 | if (name) | |
757 | { | |
758 | bgp = bgp_lookup_by_name (name); | |
759 | if (bgp == NULL) | |
760 | { | |
6aeb9e78 | 761 | vty_out (vty, "Can't find BGP instance %s%s", name, VTY_NEWLINE); |
7aafcaca DS |
762 | return CMD_WARNING; |
763 | } | |
764 | } | |
765 | else | |
766 | { | |
f31fa004 | 767 | bgp = bgp_get_default (); |
7aafcaca DS |
768 | if (bgp == NULL) |
769 | { | |
770 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
771 | return CMD_WARNING; | |
772 | } | |
773 | } | |
774 | ||
775 | return bgp_clear (vty, bgp, afi, safi, sort, stype, arg); | |
776 | } | |
777 | ||
778 | /* clear soft inbound */ | |
779 | static void | |
f31fa004 | 780 | bgp_clear_star_soft_in (struct vty *vty, const char *name) |
7aafcaca | 781 | { |
b09b5ae0 | 782 | bgp_clear_vty (vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
7aafcaca | 783 | BGP_CLEAR_SOFT_IN, NULL); |
f31fa004 | 784 | bgp_clear_vty (vty, name, AFI_IP6, SAFI_UNICAST, clear_all, |
7aafcaca | 785 | BGP_CLEAR_SOFT_IN, NULL); |
7aafcaca DS |
786 | } |
787 | ||
788 | /* clear soft outbound */ | |
789 | static void | |
f31fa004 | 790 | bgp_clear_star_soft_out (struct vty *vty, const char *name) |
7aafcaca | 791 | { |
f31fa004 | 792 | bgp_clear_vty (vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
7aafcaca | 793 | BGP_CLEAR_SOFT_OUT, NULL); |
f31fa004 | 794 | bgp_clear_vty (vty, name, AFI_IP6, SAFI_UNICAST, clear_all, |
7aafcaca | 795 | BGP_CLEAR_SOFT_OUT, NULL); |
7aafcaca DS |
796 | } |
797 | ||
798 | ||
718e3744 | 799 | /* BGP global configuration. */ |
800 | ||
801 | DEFUN (bgp_multiple_instance_func, | |
802 | bgp_multiple_instance_cmd, | |
803 | "bgp multiple-instance", | |
804 | BGP_STR | |
805 | "Enable bgp multiple instance\n") | |
806 | { | |
807 | bgp_option_set (BGP_OPT_MULTIPLE_INSTANCE); | |
808 | return CMD_SUCCESS; | |
809 | } | |
810 | ||
811 | DEFUN (no_bgp_multiple_instance, | |
812 | no_bgp_multiple_instance_cmd, | |
813 | "no bgp multiple-instance", | |
814 | NO_STR | |
815 | BGP_STR | |
816 | "BGP multiple instance\n") | |
817 | { | |
818 | int ret; | |
819 | ||
820 | ret = bgp_option_unset (BGP_OPT_MULTIPLE_INSTANCE); | |
821 | if (ret < 0) | |
822 | { | |
823 | vty_out (vty, "%% There are more than two BGP instances%s", VTY_NEWLINE); | |
824 | return CMD_WARNING; | |
825 | } | |
826 | return CMD_SUCCESS; | |
827 | } | |
828 | ||
829 | DEFUN (bgp_config_type, | |
830 | bgp_config_type_cmd, | |
6147e2c6 | 831 | "bgp config-type <cisco|zebra>", |
718e3744 | 832 | BGP_STR |
833 | "Configuration type\n" | |
834 | "cisco\n" | |
835 | "zebra\n") | |
836 | { | |
c500ae40 DW |
837 | int idx_vendor = 2; |
838 | if (strncmp (argv[idx_vendor]->arg, "c", 1) == 0) | |
718e3744 | 839 | bgp_option_set (BGP_OPT_CONFIG_CISCO); |
840 | else | |
841 | bgp_option_unset (BGP_OPT_CONFIG_CISCO); | |
842 | ||
843 | return CMD_SUCCESS; | |
844 | } | |
845 | ||
846 | DEFUN (no_bgp_config_type, | |
847 | no_bgp_config_type_cmd, | |
c7178fe7 | 848 | "no bgp config-type [<cisco|zebra>]", |
718e3744 | 849 | NO_STR |
850 | BGP_STR | |
838758ac DW |
851 | "Display configuration type\n" |
852 | "cisco\n" | |
853 | "zebra\n") | |
718e3744 | 854 | { |
855 | bgp_option_unset (BGP_OPT_CONFIG_CISCO); | |
856 | return CMD_SUCCESS; | |
857 | } | |
858 | ||
813d4307 | 859 | |
718e3744 | 860 | DEFUN (no_synchronization, |
861 | no_synchronization_cmd, | |
862 | "no synchronization", | |
863 | NO_STR | |
864 | "Perform IGP synchronization\n") | |
865 | { | |
866 | return CMD_SUCCESS; | |
867 | } | |
868 | ||
869 | DEFUN (no_auto_summary, | |
870 | no_auto_summary_cmd, | |
871 | "no auto-summary", | |
872 | NO_STR | |
873 | "Enable automatic network number summarization\n") | |
874 | { | |
875 | return CMD_SUCCESS; | |
876 | } | |
3d515fd9 | 877 | |
718e3744 | 878 | /* "router bgp" commands. */ |
505e5056 | 879 | DEFUN_NOSH (router_bgp, |
f412b39a | 880 | router_bgp_cmd, |
31500417 | 881 | "router bgp [(1-4294967295) [<view|vrf> WORD]]", |
718e3744 | 882 | ROUTER_STR |
883 | BGP_STR | |
31500417 DW |
884 | AS_STR |
885 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 886 | { |
31500417 DW |
887 | int idx_asn = 2; |
888 | int idx_view_vrf = 3; | |
889 | int idx_vrf = 4; | |
718e3744 | 890 | int ret; |
891 | as_t as; | |
892 | struct bgp *bgp; | |
fd79ac91 | 893 | const char *name = NULL; |
ad4cbda1 | 894 | enum bgp_instance_type inst_type; |
718e3744 | 895 | |
2385a876 | 896 | // "router bgp" without an ASN |
31500417 | 897 | if (argc == 2) |
2385a876 | 898 | { |
6aeb9e78 | 899 | //Pending: Make VRF option available for ASN less config |
2385a876 | 900 | bgp = bgp_get_default(); |
718e3744 | 901 | |
2385a876 DW |
902 | if (bgp == NULL) |
903 | { | |
904 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
905 | return CMD_WARNING; | |
906 | } | |
718e3744 | 907 | |
2385a876 DW |
908 | if (listcount(bm->bgp) > 1) |
909 | { | |
910 | vty_out (vty, "%% Multiple BGP processes are configured%s", VTY_NEWLINE); | |
911 | return CMD_WARNING; | |
912 | } | |
913 | } | |
914 | ||
915 | // "router bgp X" | |
916 | else | |
718e3744 | 917 | { |
31500417 | 918 | VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_asn]->arg, 1, BGP_AS4_MAX); |
2385a876 | 919 | |
ad4cbda1 | 920 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; |
31500417 | 921 | if (argc > 3) |
ad4cbda1 | 922 | { |
31500417 DW |
923 | name = argv[idx_vrf]->arg; |
924 | ||
e52702f2 | 925 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) |
ad4cbda1 | 926 | inst_type = BGP_INSTANCE_TYPE_VRF; |
e52702f2 | 927 | else if (!strcmp(argv[idx_view_vrf]->text, "view")) |
ad4cbda1 | 928 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
929 | } | |
2385a876 | 930 | |
ad4cbda1 | 931 | ret = bgp_get (&bgp, &as, name, inst_type); |
2385a876 DW |
932 | switch (ret) |
933 | { | |
934 | case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET: | |
935 | vty_out (vty, "Please specify 'bgp multiple-instance' first%s", | |
936 | VTY_NEWLINE); | |
937 | return CMD_WARNING; | |
938 | case BGP_ERR_AS_MISMATCH: | |
939 | vty_out (vty, "BGP is already running; AS is %u%s", as, VTY_NEWLINE); | |
940 | return CMD_WARNING; | |
941 | case BGP_ERR_INSTANCE_MISMATCH: | |
6aeb9e78 | 942 | vty_out (vty, "BGP instance name and AS number mismatch%s", VTY_NEWLINE); |
2385a876 DW |
943 | vty_out (vty, "BGP instance is already running; AS is %u%s", |
944 | as, VTY_NEWLINE); | |
945 | return CMD_WARNING; | |
946 | } | |
6aeb9e78 DS |
947 | |
948 | /* Pending: handle when user tries to change a view to vrf n vv. */ | |
718e3744 | 949 | } |
950 | ||
cdc2d765 | 951 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); |
718e3744 | 952 | |
953 | return CMD_SUCCESS; | |
954 | } | |
955 | ||
718e3744 | 956 | /* "no router bgp" commands. */ |
957 | DEFUN (no_router_bgp, | |
958 | no_router_bgp_cmd, | |
31500417 | 959 | "no router bgp [(1-4294967295) [<view|vrf> WORD]]", |
718e3744 | 960 | NO_STR |
961 | ROUTER_STR | |
962 | BGP_STR | |
31500417 DW |
963 | AS_STR |
964 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 965 | { |
31500417 | 966 | int idx_asn = 3; |
31500417 | 967 | int idx_vrf = 5; |
718e3744 | 968 | as_t as; |
969 | struct bgp *bgp; | |
fd79ac91 | 970 | const char *name = NULL; |
718e3744 | 971 | |
7fb21a9f | 972 | // "no router bgp" without an ASN |
31500417 | 973 | if (argc == 3) |
7fb21a9f QY |
974 | { |
975 | //Pending: Make VRF option available for ASN less config | |
976 | bgp = bgp_get_default(); | |
718e3744 | 977 | |
7fb21a9f QY |
978 | if (bgp == NULL) |
979 | { | |
980 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
981 | return CMD_WARNING; | |
982 | } | |
983 | ||
984 | if (listcount(bm->bgp) > 1) | |
985 | { | |
986 | vty_out (vty, "%% Multiple BGP processes are configured%s", VTY_NEWLINE); | |
987 | return CMD_WARNING; | |
988 | } | |
989 | } | |
990 | else | |
718e3744 | 991 | { |
31500417 | 992 | VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_asn]->arg, 1, BGP_AS4_MAX); |
7fb21a9f | 993 | |
31500417 DW |
994 | if (argc > 4) |
995 | name = argv[idx_vrf]->arg; | |
7fb21a9f QY |
996 | |
997 | /* Lookup bgp structure. */ | |
998 | bgp = bgp_lookup (as, name); | |
999 | if (! bgp) | |
1000 | { | |
1001 | vty_out (vty, "%% Can't find BGP instance%s", VTY_NEWLINE); | |
1002 | return CMD_WARNING; | |
1003 | } | |
718e3744 | 1004 | } |
1005 | ||
1006 | bgp_delete (bgp); | |
1007 | ||
1008 | return CMD_SUCCESS; | |
1009 | } | |
1010 | ||
6b0655a2 | 1011 | |
7fb21a9f | 1012 | |
718e3744 | 1013 | /* BGP router-id. */ |
1014 | ||
1015 | DEFUN (bgp_router_id, | |
1016 | bgp_router_id_cmd, | |
1017 | "bgp router-id A.B.C.D", | |
1018 | BGP_STR | |
1019 | "Override configured router identifier\n" | |
1020 | "Manually configured router identifier\n") | |
1021 | { | |
cdc2d765 | 1022 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1023 | int idx_ipv4 = 2; |
718e3744 | 1024 | int ret; |
1025 | struct in_addr id; | |
718e3744 | 1026 | |
c500ae40 | 1027 | ret = inet_aton (argv[idx_ipv4]->arg, &id); |
718e3744 | 1028 | if (! ret) |
1029 | { | |
1030 | vty_out (vty, "%% Malformed bgp router identifier%s", VTY_NEWLINE); | |
1031 | return CMD_WARNING; | |
1032 | } | |
1033 | ||
0e6cb743 | 1034 | bgp_router_id_static_set (bgp, id); |
718e3744 | 1035 | |
1036 | return CMD_SUCCESS; | |
1037 | } | |
1038 | ||
1039 | DEFUN (no_bgp_router_id, | |
1040 | no_bgp_router_id_cmd, | |
31500417 | 1041 | "no bgp router-id [A.B.C.D]", |
718e3744 | 1042 | NO_STR |
1043 | BGP_STR | |
31500417 DW |
1044 | "Override configured router identifier\n" |
1045 | "Manually configured router identifier\n") | |
718e3744 | 1046 | { |
cdc2d765 | 1047 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
31500417 | 1048 | int idx_router_id = 3; |
718e3744 | 1049 | int ret; |
1050 | struct in_addr id; | |
718e3744 | 1051 | |
31500417 | 1052 | if (argc > idx_router_id) |
718e3744 | 1053 | { |
31500417 | 1054 | ret = inet_aton (argv[idx_router_id]->arg, &id); |
718e3744 | 1055 | if (! ret) |
e018c7cc SK |
1056 | { |
1057 | vty_out (vty, "%% Malformed BGP router identifier%s", VTY_NEWLINE); | |
1058 | return CMD_WARNING; | |
1059 | } | |
718e3744 | 1060 | |
18a6dce6 | 1061 | if (! IPV4_ADDR_SAME (&bgp->router_id_static, &id)) |
e018c7cc SK |
1062 | { |
1063 | vty_out (vty, "%% BGP router-id doesn't match%s", VTY_NEWLINE); | |
1064 | return CMD_WARNING; | |
1065 | } | |
718e3744 | 1066 | } |
1067 | ||
0e6cb743 DL |
1068 | id.s_addr = 0; |
1069 | bgp_router_id_static_set (bgp, id); | |
718e3744 | 1070 | |
1071 | return CMD_SUCCESS; | |
1072 | } | |
1073 | ||
6b0655a2 | 1074 | |
718e3744 | 1075 | /* BGP Cluster ID. */ |
718e3744 | 1076 | DEFUN (bgp_cluster_id, |
1077 | bgp_cluster_id_cmd, | |
838758ac | 1078 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", |
718e3744 | 1079 | BGP_STR |
1080 | "Configure Route-Reflector Cluster-id\n" | |
838758ac DW |
1081 | "Route-Reflector Cluster-id in IP address format\n" |
1082 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1083 | { |
cdc2d765 | 1084 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1085 | int idx_ipv4 = 2; |
718e3744 | 1086 | int ret; |
718e3744 | 1087 | struct in_addr cluster; |
1088 | ||
c500ae40 | 1089 | ret = inet_aton (argv[idx_ipv4]->arg, &cluster); |
718e3744 | 1090 | if (! ret) |
1091 | { | |
1092 | vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE); | |
1093 | return CMD_WARNING; | |
1094 | } | |
1095 | ||
1096 | bgp_cluster_id_set (bgp, &cluster); | |
f31fa004 | 1097 | bgp_clear_star_soft_out (vty, bgp->name); |
718e3744 | 1098 | |
1099 | return CMD_SUCCESS; | |
1100 | } | |
1101 | ||
718e3744 | 1102 | DEFUN (no_bgp_cluster_id, |
1103 | no_bgp_cluster_id_cmd, | |
c7178fe7 | 1104 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", |
718e3744 | 1105 | NO_STR |
1106 | BGP_STR | |
838758ac DW |
1107 | "Configure Route-Reflector Cluster-id\n" |
1108 | "Route-Reflector Cluster-id in IP address format\n" | |
1109 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1110 | { |
cdc2d765 | 1111 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1112 | bgp_cluster_id_unset (bgp); |
f31fa004 | 1113 | bgp_clear_star_soft_out (vty, bgp->name); |
718e3744 | 1114 | |
1115 | return CMD_SUCCESS; | |
1116 | } | |
1117 | ||
718e3744 | 1118 | DEFUN (bgp_confederation_identifier, |
1119 | bgp_confederation_identifier_cmd, | |
9ccf14f7 | 1120 | "bgp confederation identifier (1-4294967295)", |
718e3744 | 1121 | "BGP specific commands\n" |
1122 | "AS confederation parameters\n" | |
1123 | "AS number\n" | |
1124 | "Set routing domain confederation AS\n") | |
1125 | { | |
cdc2d765 | 1126 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1127 | int idx_number = 3; |
718e3744 | 1128 | as_t as; |
1129 | ||
c500ae40 | 1130 | VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); |
718e3744 | 1131 | |
1132 | bgp_confederation_id_set (bgp, as); | |
1133 | ||
1134 | return CMD_SUCCESS; | |
1135 | } | |
1136 | ||
1137 | DEFUN (no_bgp_confederation_identifier, | |
1138 | no_bgp_confederation_identifier_cmd, | |
838758ac | 1139 | "no bgp confederation identifier [(1-4294967295)]", |
718e3744 | 1140 | NO_STR |
1141 | "BGP specific commands\n" | |
1142 | "AS confederation parameters\n" | |
3a2d747c QY |
1143 | "AS number\n" |
1144 | "Set routing domain confederation AS\n") | |
718e3744 | 1145 | { |
cdc2d765 | 1146 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1147 | bgp_confederation_id_unset (bgp); |
1148 | ||
1149 | return CMD_SUCCESS; | |
1150 | } | |
1151 | ||
718e3744 | 1152 | DEFUN (bgp_confederation_peers, |
1153 | bgp_confederation_peers_cmd, | |
12dcf78e | 1154 | "bgp confederation peers (1-4294967295)...", |
718e3744 | 1155 | "BGP specific commands\n" |
1156 | "AS confederation parameters\n" | |
1157 | "Peer ASs in BGP confederation\n" | |
1158 | AS_STR) | |
1159 | { | |
cdc2d765 | 1160 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
58749582 | 1161 | int idx_asn = 3; |
718e3744 | 1162 | as_t as; |
1163 | int i; | |
1164 | ||
58749582 | 1165 | for (i = idx_asn; i < argc; i++) |
718e3744 | 1166 | { |
afec25d9 | 1167 | VTY_GET_INTEGER_RANGE ("AS", as, argv[i]->arg, 1, BGP_AS4_MAX); |
718e3744 | 1168 | |
1169 | if (bgp->as == as) | |
1170 | { | |
1171 | vty_out (vty, "%% Local member-AS not allowed in confed peer list%s", | |
1172 | VTY_NEWLINE); | |
1173 | continue; | |
1174 | } | |
1175 | ||
1176 | bgp_confederation_peers_add (bgp, as); | |
1177 | } | |
1178 | return CMD_SUCCESS; | |
1179 | } | |
1180 | ||
1181 | DEFUN (no_bgp_confederation_peers, | |
1182 | no_bgp_confederation_peers_cmd, | |
e83a9414 | 1183 | "no bgp confederation peers (1-4294967295)...", |
718e3744 | 1184 | NO_STR |
1185 | "BGP specific commands\n" | |
1186 | "AS confederation parameters\n" | |
1187 | "Peer ASs in BGP confederation\n" | |
1188 | AS_STR) | |
1189 | { | |
cdc2d765 | 1190 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
58749582 | 1191 | int idx_asn = 4; |
718e3744 | 1192 | as_t as; |
1193 | int i; | |
1194 | ||
58749582 | 1195 | for (i = idx_asn; i < argc; i++) |
718e3744 | 1196 | { |
afec25d9 | 1197 | VTY_GET_INTEGER_RANGE ("AS", as, argv[i]->arg, 1, BGP_AS4_MAX); |
0b2aa3a0 | 1198 | |
718e3744 | 1199 | bgp_confederation_peers_remove (bgp, as); |
1200 | } | |
1201 | return CMD_SUCCESS; | |
1202 | } | |
6b0655a2 | 1203 | |
5e242b0d DS |
1204 | /** |
1205 | * Central routine for maximum-paths configuration. | |
1206 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1207 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1208 | */ | |
ffd0c037 DS |
1209 | static int |
1210 | bgp_maxpaths_config_vty (struct vty *vty, int peer_type, const char *mpaths, | |
5e242b0d | 1211 | u_int16_t options, int set) |
165b5fff | 1212 | { |
cdc2d765 | 1213 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4c9dee98 | 1214 | u_int16_t maxpaths = 0; |
165b5fff | 1215 | int ret; |
5e242b0d DS |
1216 | afi_t afi; |
1217 | safi_t safi; | |
165b5fff | 1218 | |
5e242b0d DS |
1219 | afi = bgp_node_afi (vty); |
1220 | safi = bgp_node_safi (vty); | |
165b5fff | 1221 | |
5e242b0d | 1222 | if (set) |
4c9dee98 | 1223 | { |
c59f2066 | 1224 | maxpaths = strtol(mpaths, NULL, 10); |
37fe7731 DS |
1225 | if (maxpaths > multipath_num) |
1226 | { | |
1227 | vty_out (vty, | |
1228 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", | |
1229 | maxpaths, multipath_num); | |
1230 | return CMD_WARNING; | |
1231 | } | |
dff6764a | 1232 | ret = bgp_maximum_paths_set (bgp, afi, safi, peer_type, maxpaths, options); |
4c9dee98 | 1233 | } |
5e242b0d DS |
1234 | else |
1235 | ret = bgp_maximum_paths_unset (bgp, afi, safi, peer_type); | |
165b5fff | 1236 | |
165b5fff JB |
1237 | if (ret < 0) |
1238 | { | |
1239 | vty_out (vty, | |
5e242b0d DS |
1240 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u%s", |
1241 | (set == 1) ? "" : "un", | |
1242 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1243 | maxpaths, afi, safi, VTY_NEWLINE); | |
165b5fff JB |
1244 | return CMD_WARNING; |
1245 | } | |
1246 | ||
7aafcaca DS |
1247 | bgp_recalculate_all_bestpaths (bgp); |
1248 | ||
165b5fff JB |
1249 | return CMD_SUCCESS; |
1250 | } | |
1251 | ||
abc920f8 DS |
1252 | DEFUN (bgp_maxmed_admin, |
1253 | bgp_maxmed_admin_cmd, | |
1254 | "bgp max-med administrative ", | |
1255 | BGP_STR | |
1256 | "Advertise routes with max-med\n" | |
1257 | "Administratively applied, for an indefinite period\n") | |
1258 | { | |
cdc2d765 | 1259 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 DS |
1260 | |
1261 | bgp->v_maxmed_admin = 1; | |
1262 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1263 | ||
1264 | bgp_maxmed_update(bgp); | |
1265 | ||
1266 | return CMD_SUCCESS; | |
1267 | } | |
1268 | ||
1269 | DEFUN (bgp_maxmed_admin_medv, | |
1270 | bgp_maxmed_admin_medv_cmd, | |
6147e2c6 | 1271 | "bgp max-med administrative (0-4294967294)", |
abc920f8 DS |
1272 | BGP_STR |
1273 | "Advertise routes with max-med\n" | |
1274 | "Administratively applied, for an indefinite period\n" | |
1275 | "Max MED value to be used\n") | |
1276 | { | |
cdc2d765 | 1277 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1278 | int idx_number = 3; |
abc920f8 DS |
1279 | |
1280 | bgp->v_maxmed_admin = 1; | |
c500ae40 | 1281 | VTY_GET_INTEGER ("max-med admin med-value", bgp->maxmed_admin_value, argv[idx_number]->arg); |
abc920f8 DS |
1282 | |
1283 | bgp_maxmed_update(bgp); | |
1284 | ||
1285 | return CMD_SUCCESS; | |
1286 | } | |
1287 | ||
1288 | DEFUN (no_bgp_maxmed_admin, | |
1289 | no_bgp_maxmed_admin_cmd, | |
8334fd5a | 1290 | "no bgp max-med administrative [(0-4294967294)]", |
abc920f8 DS |
1291 | NO_STR |
1292 | BGP_STR | |
1293 | "Advertise routes with max-med\n" | |
838758ac DW |
1294 | "Administratively applied, for an indefinite period\n" |
1295 | "Max MED value to be used\n") | |
abc920f8 | 1296 | { |
cdc2d765 | 1297 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 DS |
1298 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; |
1299 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 DS |
1300 | bgp_maxmed_update(bgp); |
1301 | ||
1302 | return CMD_SUCCESS; | |
1303 | } | |
1304 | ||
abc920f8 DS |
1305 | DEFUN (bgp_maxmed_onstartup, |
1306 | bgp_maxmed_onstartup_cmd, | |
6147e2c6 | 1307 | "bgp max-med on-startup (5-86400)", |
abc920f8 DS |
1308 | BGP_STR |
1309 | "Advertise routes with max-med\n" | |
1310 | "Effective on a startup\n" | |
1311 | "Time (seconds) period for max-med\n") | |
1312 | { | |
cdc2d765 | 1313 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1314 | int idx_number = 3; |
c500ae40 | 1315 | VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[idx_number]->arg); |
abc920f8 | 1316 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; |
abc920f8 DS |
1317 | bgp_maxmed_update(bgp); |
1318 | ||
1319 | return CMD_SUCCESS; | |
1320 | } | |
1321 | ||
1322 | DEFUN (bgp_maxmed_onstartup_medv, | |
1323 | bgp_maxmed_onstartup_medv_cmd, | |
6147e2c6 | 1324 | "bgp max-med on-startup (5-86400) (0-4294967294)", |
abc920f8 DS |
1325 | BGP_STR |
1326 | "Advertise routes with max-med\n" | |
1327 | "Effective on a startup\n" | |
1328 | "Time (seconds) period for max-med\n" | |
1329 | "Max MED value to be used\n") | |
1330 | { | |
cdc2d765 | 1331 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
1332 | int idx_number = 3; |
1333 | int idx_number_2 = 4; | |
c500ae40 DW |
1334 | VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[idx_number]->arg); |
1335 | VTY_GET_INTEGER ("max-med on-startup med-value", bgp->maxmed_onstartup_value, argv[idx_number_2]->arg); | |
abc920f8 DS |
1336 | bgp_maxmed_update(bgp); |
1337 | ||
1338 | return CMD_SUCCESS; | |
1339 | } | |
1340 | ||
1341 | DEFUN (no_bgp_maxmed_onstartup, | |
1342 | no_bgp_maxmed_onstartup_cmd, | |
8334fd5a | 1343 | "no bgp max-med on-startup [(5-86400) [(0-4294967294)]]", |
abc920f8 DS |
1344 | NO_STR |
1345 | BGP_STR | |
1346 | "Advertise routes with max-med\n" | |
838758ac DW |
1347 | "Effective on a startup\n" |
1348 | "Time (seconds) period for max-med\n" | |
1349 | "Max MED value to be used\n") | |
abc920f8 | 1350 | { |
cdc2d765 | 1351 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 DS |
1352 | |
1353 | /* Cancel max-med onstartup if its on */ | |
1354 | if (bgp->t_maxmed_onstartup) | |
1355 | { | |
1356 | THREAD_TIMER_OFF (bgp->t_maxmed_onstartup); | |
1357 | bgp->maxmed_onstartup_over = 1; | |
1358 | } | |
1359 | ||
1360 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; | |
1361 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
1362 | ||
1363 | bgp_maxmed_update(bgp); | |
1364 | ||
1365 | return CMD_SUCCESS; | |
1366 | } | |
1367 | ||
f188f2c4 DS |
1368 | static int |
1369 | bgp_update_delay_config_vty (struct vty *vty, const char *delay, | |
1370 | const char *wait) | |
1371 | { | |
cdc2d765 | 1372 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 DS |
1373 | u_int16_t update_delay; |
1374 | u_int16_t establish_wait; | |
1375 | ||
f188f2c4 DS |
1376 | VTY_GET_INTEGER_RANGE ("update-delay", update_delay, delay, |
1377 | BGP_UPDATE_DELAY_MIN, BGP_UPDATE_DELAY_MAX); | |
1378 | ||
1379 | if (!wait) /* update-delay <delay> */ | |
1380 | { | |
1381 | bgp->v_update_delay = update_delay; | |
1382 | bgp->v_establish_wait = bgp->v_update_delay; | |
1383 | return CMD_SUCCESS; | |
1384 | } | |
1385 | ||
1386 | /* update-delay <delay> <establish-wait> */ | |
1387 | establish_wait = atoi (wait); | |
1388 | if (update_delay < establish_wait) | |
1389 | { | |
1390 | vty_out (vty, "%%Failed: update-delay less than the establish-wait!%s", | |
1391 | VTY_NEWLINE); | |
1392 | return CMD_WARNING; | |
1393 | } | |
1394 | ||
1395 | bgp->v_update_delay = update_delay; | |
1396 | bgp->v_establish_wait = establish_wait; | |
1397 | ||
1398 | return CMD_SUCCESS; | |
1399 | } | |
1400 | ||
1401 | static int | |
1402 | bgp_update_delay_deconfig_vty (struct vty *vty) | |
1403 | { | |
cdc2d765 | 1404 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 DS |
1405 | |
1406 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; | |
1407 | bgp->v_establish_wait = bgp->v_update_delay; | |
1408 | ||
1409 | return CMD_SUCCESS; | |
1410 | } | |
1411 | ||
1412 | int | |
1413 | bgp_config_write_update_delay (struct vty *vty, struct bgp *bgp) | |
1414 | { | |
1415 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) | |
1416 | { | |
1417 | vty_out (vty, " update-delay %d", bgp->v_update_delay); | |
1418 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1419 | vty_out (vty, " %d", bgp->v_establish_wait); | |
1420 | vty_out (vty, "%s", VTY_NEWLINE); | |
1421 | } | |
1422 | ||
1423 | return 0; | |
1424 | } | |
1425 | ||
1426 | ||
1427 | /* Update-delay configuration */ | |
1428 | DEFUN (bgp_update_delay, | |
1429 | bgp_update_delay_cmd, | |
6147e2c6 | 1430 | "update-delay (0-3600)", |
f188f2c4 DS |
1431 | "Force initial delay for best-path and updates\n" |
1432 | "Seconds\n") | |
1433 | { | |
c500ae40 DW |
1434 | int idx_number = 1; |
1435 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); | |
f188f2c4 DS |
1436 | } |
1437 | ||
1438 | DEFUN (bgp_update_delay_establish_wait, | |
1439 | bgp_update_delay_establish_wait_cmd, | |
6147e2c6 | 1440 | "update-delay (0-3600) (1-3600)", |
f188f2c4 DS |
1441 | "Force initial delay for best-path and updates\n" |
1442 | "Seconds\n" | |
1443 | "Wait for peers to be established\n" | |
1444 | "Seconds\n") | |
1445 | { | |
c500ae40 DW |
1446 | int idx_number = 1; |
1447 | int idx_number_2 = 2; | |
1448 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, argv[idx_number_2]->arg); | |
f188f2c4 DS |
1449 | } |
1450 | ||
1451 | /* Update-delay deconfiguration */ | |
1452 | DEFUN (no_bgp_update_delay, | |
1453 | no_bgp_update_delay_cmd, | |
838758ac DW |
1454 | "no update-delay [(0-3600) [(1-3600)]]", |
1455 | NO_STR | |
f188f2c4 | 1456 | "Force initial delay for best-path and updates\n" |
838758ac DW |
1457 | "Seconds\n" |
1458 | "Wait for peers to be established\n") | |
f188f2c4 DS |
1459 | { |
1460 | return bgp_update_delay_deconfig_vty(vty); | |
1461 | } | |
1462 | ||
5e242b0d | 1463 | |
ffd0c037 DS |
1464 | static int |
1465 | bgp_wpkt_quanta_config_vty (struct vty *vty, const char *num, char set) | |
cb1faec9 | 1466 | { |
cdc2d765 | 1467 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
cb1faec9 DS |
1468 | |
1469 | if (set) | |
1470 | VTY_GET_INTEGER_RANGE ("write-quanta", bgp->wpkt_quanta, num, | |
4543bbb4 | 1471 | 1, 10000); |
cb1faec9 DS |
1472 | else |
1473 | bgp->wpkt_quanta = BGP_WRITE_PACKET_MAX; | |
1474 | ||
1475 | return CMD_SUCCESS; | |
1476 | } | |
1477 | ||
1478 | int | |
1479 | bgp_config_write_wpkt_quanta (struct vty *vty, struct bgp *bgp) | |
1480 | { | |
1481 | if (bgp->wpkt_quanta != BGP_WRITE_PACKET_MAX) | |
1482 | vty_out (vty, " write-quanta %d%s", | |
1483 | bgp->wpkt_quanta, VTY_NEWLINE); | |
1484 | ||
1485 | return 0; | |
1486 | } | |
1487 | ||
1488 | ||
1489 | /* Update-delay configuration */ | |
1490 | DEFUN (bgp_wpkt_quanta, | |
1491 | bgp_wpkt_quanta_cmd, | |
6147e2c6 | 1492 | "write-quanta (1-10000)", |
cb1faec9 DS |
1493 | "How many packets to write to peer socket per run\n" |
1494 | "Number of packets\n") | |
1495 | { | |
c500ae40 DW |
1496 | int idx_number = 1; |
1497 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
cb1faec9 DS |
1498 | } |
1499 | ||
1500 | /* Update-delay deconfiguration */ | |
1501 | DEFUN (no_bgp_wpkt_quanta, | |
1502 | no_bgp_wpkt_quanta_cmd, | |
6147e2c6 | 1503 | "no write-quanta (1-10000)", |
d7fa34c1 | 1504 | NO_STR |
cb1faec9 DS |
1505 | "How many packets to write to peer socket per run\n" |
1506 | "Number of packets\n") | |
1507 | { | |
c500ae40 DW |
1508 | int idx_number = 2; |
1509 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
cb1faec9 DS |
1510 | } |
1511 | ||
ffd0c037 | 1512 | static int |
3f9c7369 DS |
1513 | bgp_coalesce_config_vty (struct vty *vty, const char *num, char set) |
1514 | { | |
cdc2d765 | 1515 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3f9c7369 DS |
1516 | |
1517 | if (set) | |
1518 | VTY_GET_INTEGER_RANGE ("coalesce-time", bgp->coalesce_time, num, | |
1519 | 0, 4294967295); | |
1520 | else | |
1521 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; | |
1522 | ||
1523 | return CMD_SUCCESS; | |
1524 | } | |
1525 | ||
1526 | int | |
1527 | bgp_config_write_coalesce_time (struct vty *vty, struct bgp *bgp) | |
1528 | { | |
1529 | if (bgp->coalesce_time != BGP_DEFAULT_SUBGROUP_COALESCE_TIME) | |
1530 | vty_out (vty, " coalesce-time %d%s", | |
1531 | bgp->coalesce_time, VTY_NEWLINE); | |
1532 | ||
1533 | return 0; | |
1534 | } | |
1535 | ||
1536 | ||
1537 | DEFUN (bgp_coalesce_time, | |
1538 | bgp_coalesce_time_cmd, | |
6147e2c6 | 1539 | "coalesce-time (0-4294967295)", |
3f9c7369 DS |
1540 | "Subgroup coalesce timer\n" |
1541 | "Subgroup coalesce timer value (in ms)\n") | |
1542 | { | |
c500ae40 DW |
1543 | int idx_number = 1; |
1544 | return bgp_coalesce_config_vty(vty, argv[idx_number]->arg, 1); | |
3f9c7369 DS |
1545 | } |
1546 | ||
1547 | DEFUN (no_bgp_coalesce_time, | |
1548 | no_bgp_coalesce_time_cmd, | |
6147e2c6 | 1549 | "no coalesce-time (0-4294967295)", |
3a2d747c | 1550 | NO_STR |
3f9c7369 DS |
1551 | "Subgroup coalesce timer\n" |
1552 | "Subgroup coalesce timer value (in ms)\n") | |
1553 | { | |
c500ae40 DW |
1554 | int idx_number = 2; |
1555 | return bgp_coalesce_config_vty(vty, argv[idx_number]->arg, 0); | |
3f9c7369 DS |
1556 | } |
1557 | ||
5e242b0d DS |
1558 | /* Maximum-paths configuration */ |
1559 | DEFUN (bgp_maxpaths, | |
1560 | bgp_maxpaths_cmd, | |
9ccf14f7 | 1561 | "maximum-paths (1-255)", |
5e242b0d DS |
1562 | "Forward packets over multiple paths\n" |
1563 | "Number of paths\n") | |
1564 | { | |
c500ae40 DW |
1565 | int idx_number = 1; |
1566 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
1567 | } |
1568 | ||
596c17ba DW |
1569 | ALIAS_HIDDEN (bgp_maxpaths, |
1570 | bgp_maxpaths_hidden_cmd, | |
1571 | "maximum-paths (1-255)", | |
1572 | "Forward packets over multiple paths\n" | |
1573 | "Number of paths\n") | |
1574 | ||
165b5fff JB |
1575 | DEFUN (bgp_maxpaths_ibgp, |
1576 | bgp_maxpaths_ibgp_cmd, | |
9ccf14f7 | 1577 | "maximum-paths ibgp (1-255)", |
165b5fff JB |
1578 | "Forward packets over multiple paths\n" |
1579 | "iBGP-multipath\n" | |
1580 | "Number of paths\n") | |
1581 | { | |
c500ae40 DW |
1582 | int idx_number = 2; |
1583 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[idx_number]->arg, 0, 1); | |
5e242b0d | 1584 | } |
165b5fff | 1585 | |
596c17ba DW |
1586 | ALIAS_HIDDEN (bgp_maxpaths_ibgp, |
1587 | bgp_maxpaths_ibgp_hidden_cmd, | |
1588 | "maximum-paths ibgp (1-255)", | |
1589 | "Forward packets over multiple paths\n" | |
1590 | "iBGP-multipath\n" | |
1591 | "Number of paths\n") | |
1592 | ||
5e242b0d DS |
1593 | DEFUN (bgp_maxpaths_ibgp_cluster, |
1594 | bgp_maxpaths_ibgp_cluster_cmd, | |
9ccf14f7 | 1595 | "maximum-paths ibgp (1-255) equal-cluster-length", |
5e242b0d DS |
1596 | "Forward packets over multiple paths\n" |
1597 | "iBGP-multipath\n" | |
1598 | "Number of paths\n" | |
1599 | "Match the cluster length\n") | |
1600 | { | |
c500ae40 DW |
1601 | int idx_number = 2; |
1602 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
5e242b0d | 1603 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); |
165b5fff JB |
1604 | } |
1605 | ||
596c17ba DW |
1606 | ALIAS_HIDDEN (bgp_maxpaths_ibgp_cluster, |
1607 | bgp_maxpaths_ibgp_cluster_hidden_cmd, | |
1608 | "maximum-paths ibgp (1-255) equal-cluster-length", | |
1609 | "Forward packets over multiple paths\n" | |
1610 | "iBGP-multipath\n" | |
1611 | "Number of paths\n" | |
1612 | "Match the cluster length\n") | |
1613 | ||
165b5fff JB |
1614 | DEFUN (no_bgp_maxpaths, |
1615 | no_bgp_maxpaths_cmd, | |
9ccf14f7 | 1616 | "no maximum-paths [(1-255)]", |
165b5fff JB |
1617 | NO_STR |
1618 | "Forward packets over multiple paths\n" | |
1619 | "Number of paths\n") | |
1620 | { | |
5e242b0d | 1621 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
1622 | } |
1623 | ||
596c17ba DW |
1624 | ALIAS_HIDDEN (no_bgp_maxpaths, |
1625 | no_bgp_maxpaths_hidden_cmd, | |
1626 | "no maximum-paths [(1-255)]", | |
1627 | NO_STR | |
1628 | "Forward packets over multiple paths\n" | |
1629 | "Number of paths\n") | |
1630 | ||
165b5fff JB |
1631 | DEFUN (no_bgp_maxpaths_ibgp, |
1632 | no_bgp_maxpaths_ibgp_cmd, | |
9ccf14f7 | 1633 | "no maximum-paths ibgp [(1-255) [equal-cluster-length]]", |
165b5fff JB |
1634 | NO_STR |
1635 | "Forward packets over multiple paths\n" | |
1636 | "iBGP-multipath\n" | |
838758ac DW |
1637 | "Number of paths\n" |
1638 | "Match the cluster length\n") | |
165b5fff | 1639 | { |
5e242b0d | 1640 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1641 | } |
1642 | ||
596c17ba DW |
1643 | ALIAS_HIDDEN (no_bgp_maxpaths_ibgp, |
1644 | no_bgp_maxpaths_ibgp_hidden_cmd, | |
1645 | "no maximum-paths ibgp [(1-255) [equal-cluster-length]]", | |
1646 | NO_STR | |
1647 | "Forward packets over multiple paths\n" | |
1648 | "iBGP-multipath\n" | |
1649 | "Number of paths\n" | |
1650 | "Match the cluster length\n") | |
1651 | ||
165b5fff JB |
1652 | int |
1653 | bgp_config_write_maxpaths (struct vty *vty, struct bgp *bgp, afi_t afi, | |
1654 | safi_t safi, int *write) | |
1655 | { | |
d5b77cc2 | 1656 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) |
165b5fff JB |
1657 | { |
1658 | bgp_config_write_family_header (vty, afi, safi, write); | |
0b960b4d | 1659 | vty_out (vty, " maximum-paths %d%s", |
165b5fff JB |
1660 | bgp->maxpaths[afi][safi].maxpaths_ebgp, VTY_NEWLINE); |
1661 | } | |
1662 | ||
d5b77cc2 | 1663 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) |
165b5fff JB |
1664 | { |
1665 | bgp_config_write_family_header (vty, afi, safi, write); | |
0b960b4d | 1666 | vty_out (vty, " maximum-paths ibgp %d", |
5e242b0d DS |
1667 | bgp->maxpaths[afi][safi].maxpaths_ibgp); |
1668 | if (CHECK_FLAG (bgp->maxpaths[afi][safi].ibgp_flags, | |
1669 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1670 | vty_out (vty, " equal-cluster-length"); | |
1671 | vty_out (vty, "%s", VTY_NEWLINE); | |
165b5fff JB |
1672 | } |
1673 | ||
1674 | return 0; | |
1675 | } | |
6b0655a2 | 1676 | |
718e3744 | 1677 | /* BGP timers. */ |
1678 | ||
1679 | DEFUN (bgp_timers, | |
1680 | bgp_timers_cmd, | |
6147e2c6 | 1681 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1682 | "Adjust routing timers\n" |
1683 | "BGP timers\n" | |
1684 | "Keepalive interval\n" | |
1685 | "Holdtime\n") | |
1686 | { | |
cdc2d765 | 1687 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
1688 | int idx_number = 2; |
1689 | int idx_number_2 = 3; | |
718e3744 | 1690 | unsigned long keepalive = 0; |
1691 | unsigned long holdtime = 0; | |
1692 | ||
c500ae40 DW |
1693 | VTY_GET_INTEGER ("keepalive", keepalive, argv[idx_number]->arg); |
1694 | VTY_GET_INTEGER ("holdtime", holdtime, argv[idx_number_2]->arg); | |
718e3744 | 1695 | |
1696 | /* Holdtime value check. */ | |
1697 | if (holdtime < 3 && holdtime != 0) | |
1698 | { | |
1699 | vty_out (vty, "%% hold time value must be either 0 or greater than 3%s", | |
1700 | VTY_NEWLINE); | |
1701 | return CMD_WARNING; | |
1702 | } | |
1703 | ||
1704 | bgp_timers_set (bgp, keepalive, holdtime); | |
1705 | ||
1706 | return CMD_SUCCESS; | |
1707 | } | |
1708 | ||
1709 | DEFUN (no_bgp_timers, | |
1710 | no_bgp_timers_cmd, | |
838758ac | 1711 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1712 | NO_STR |
1713 | "Adjust routing timers\n" | |
838758ac DW |
1714 | "BGP timers\n" |
1715 | "Keepalive interval\n" | |
1716 | "Holdtime\n") | |
718e3744 | 1717 | { |
cdc2d765 | 1718 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1719 | bgp_timers_unset (bgp); |
1720 | ||
1721 | return CMD_SUCCESS; | |
1722 | } | |
1723 | ||
6b0655a2 | 1724 | |
718e3744 | 1725 | DEFUN (bgp_client_to_client_reflection, |
1726 | bgp_client_to_client_reflection_cmd, | |
1727 | "bgp client-to-client reflection", | |
1728 | "BGP specific commands\n" | |
1729 | "Configure client to client route reflection\n" | |
1730 | "reflection of routes allowed\n") | |
1731 | { | |
cdc2d765 | 1732 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1733 | bgp_flag_unset (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); |
f31fa004 | 1734 | bgp_clear_star_soft_out (vty, bgp->name); |
7aafcaca | 1735 | |
718e3744 | 1736 | return CMD_SUCCESS; |
1737 | } | |
1738 | ||
1739 | DEFUN (no_bgp_client_to_client_reflection, | |
1740 | no_bgp_client_to_client_reflection_cmd, | |
1741 | "no bgp client-to-client reflection", | |
1742 | NO_STR | |
1743 | "BGP specific commands\n" | |
1744 | "Configure client to client route reflection\n" | |
1745 | "reflection of routes allowed\n") | |
1746 | { | |
cdc2d765 | 1747 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1748 | bgp_flag_set (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); |
f31fa004 | 1749 | bgp_clear_star_soft_out (vty, bgp->name); |
7aafcaca | 1750 | |
718e3744 | 1751 | return CMD_SUCCESS; |
1752 | } | |
1753 | ||
1754 | /* "bgp always-compare-med" configuration. */ | |
1755 | DEFUN (bgp_always_compare_med, | |
1756 | bgp_always_compare_med_cmd, | |
1757 | "bgp always-compare-med", | |
1758 | "BGP specific commands\n" | |
1759 | "Allow comparing MED from different neighbors\n") | |
1760 | { | |
cdc2d765 | 1761 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1762 | bgp_flag_set (bgp, BGP_FLAG_ALWAYS_COMPARE_MED); |
7aafcaca DS |
1763 | bgp_recalculate_all_bestpaths (bgp); |
1764 | ||
718e3744 | 1765 | return CMD_SUCCESS; |
1766 | } | |
1767 | ||
1768 | DEFUN (no_bgp_always_compare_med, | |
1769 | no_bgp_always_compare_med_cmd, | |
1770 | "no bgp always-compare-med", | |
1771 | NO_STR | |
1772 | "BGP specific commands\n" | |
1773 | "Allow comparing MED from different neighbors\n") | |
1774 | { | |
cdc2d765 | 1775 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1776 | bgp_flag_unset (bgp, BGP_FLAG_ALWAYS_COMPARE_MED); |
7aafcaca DS |
1777 | bgp_recalculate_all_bestpaths (bgp); |
1778 | ||
718e3744 | 1779 | return CMD_SUCCESS; |
1780 | } | |
6b0655a2 | 1781 | |
718e3744 | 1782 | /* "bgp deterministic-med" configuration. */ |
1783 | DEFUN (bgp_deterministic_med, | |
1784 | bgp_deterministic_med_cmd, | |
1785 | "bgp deterministic-med", | |
1786 | "BGP specific commands\n" | |
1787 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1788 | { | |
cdc2d765 | 1789 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1475ac87 DW |
1790 | |
1791 | if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) | |
1792 | { | |
1793 | bgp_flag_set (bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1794 | bgp_recalculate_all_bestpaths (bgp); | |
1795 | } | |
7aafcaca | 1796 | |
718e3744 | 1797 | return CMD_SUCCESS; |
1798 | } | |
1799 | ||
1800 | DEFUN (no_bgp_deterministic_med, | |
1801 | no_bgp_deterministic_med_cmd, | |
1802 | "no bgp deterministic-med", | |
1803 | NO_STR | |
1804 | "BGP specific commands\n" | |
1805 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1806 | { | |
cdc2d765 | 1807 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
06370dac DW |
1808 | int bestpath_per_as_used; |
1809 | afi_t afi; | |
1810 | safi_t safi; | |
1811 | struct peer *peer; | |
1812 | struct listnode *node, *nnode; | |
718e3744 | 1813 | |
1475ac87 DW |
1814 | if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) |
1815 | { | |
06370dac DW |
1816 | bestpath_per_as_used = 0; |
1817 | ||
1818 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
1819 | { | |
1820 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
1821 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
1822 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) | |
1823 | { | |
1824 | bestpath_per_as_used = 1; | |
1825 | break; | |
1826 | } | |
1827 | ||
1828 | if (bestpath_per_as_used) | |
1829 | break; | |
1830 | } | |
1831 | ||
1832 | if (bestpath_per_as_used) | |
1833 | { | |
1834 | vty_out (vty, "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use%s", | |
1835 | VTY_NEWLINE); | |
1836 | return CMD_WARNING; | |
1837 | } | |
1838 | else | |
1839 | { | |
1840 | bgp_flag_unset (bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1841 | bgp_recalculate_all_bestpaths (bgp); | |
1842 | } | |
1475ac87 | 1843 | } |
7aafcaca | 1844 | |
718e3744 | 1845 | return CMD_SUCCESS; |
1846 | } | |
538621f2 | 1847 | |
1848 | /* "bgp graceful-restart" configuration. */ | |
1849 | DEFUN (bgp_graceful_restart, | |
1850 | bgp_graceful_restart_cmd, | |
1851 | "bgp graceful-restart", | |
1852 | "BGP specific commands\n" | |
1853 | "Graceful restart capability parameters\n") | |
1854 | { | |
cdc2d765 | 1855 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
538621f2 | 1856 | bgp_flag_set (bgp, BGP_FLAG_GRACEFUL_RESTART); |
1857 | return CMD_SUCCESS; | |
1858 | } | |
1859 | ||
1860 | DEFUN (no_bgp_graceful_restart, | |
1861 | no_bgp_graceful_restart_cmd, | |
1862 | "no bgp graceful-restart", | |
1863 | NO_STR | |
1864 | "BGP specific commands\n" | |
1865 | "Graceful restart capability parameters\n") | |
1866 | { | |
cdc2d765 | 1867 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
538621f2 | 1868 | bgp_flag_unset (bgp, BGP_FLAG_GRACEFUL_RESTART); |
1869 | return CMD_SUCCESS; | |
1870 | } | |
1871 | ||
93406d87 | 1872 | DEFUN (bgp_graceful_restart_stalepath_time, |
1873 | bgp_graceful_restart_stalepath_time_cmd, | |
6147e2c6 | 1874 | "bgp graceful-restart stalepath-time (1-3600)", |
93406d87 | 1875 | "BGP specific commands\n" |
1876 | "Graceful restart capability parameters\n" | |
1877 | "Set the max time to hold onto restarting peer's stale paths\n" | |
1878 | "Delay value (seconds)\n") | |
1879 | { | |
cdc2d765 | 1880 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1881 | int idx_number = 3; |
93406d87 | 1882 | u_int32_t stalepath; |
1883 | ||
c500ae40 | 1884 | VTY_GET_INTEGER_RANGE ("stalepath-time", stalepath, argv[idx_number]->arg, 1, 3600); |
93406d87 | 1885 | bgp->stalepath_time = stalepath; |
1886 | return CMD_SUCCESS; | |
1887 | } | |
1888 | ||
eb6f1b41 PG |
1889 | DEFUN (bgp_graceful_restart_restart_time, |
1890 | bgp_graceful_restart_restart_time_cmd, | |
6147e2c6 | 1891 | "bgp graceful-restart restart-time (1-3600)", |
eb6f1b41 PG |
1892 | "BGP specific commands\n" |
1893 | "Graceful restart capability parameters\n" | |
1894 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
1895 | "Delay value (seconds)\n") | |
1896 | { | |
cdc2d765 | 1897 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1898 | int idx_number = 3; |
eb6f1b41 PG |
1899 | u_int32_t restart; |
1900 | ||
c500ae40 | 1901 | VTY_GET_INTEGER_RANGE ("restart-time", restart, argv[idx_number]->arg, 1, 3600); |
eb6f1b41 PG |
1902 | bgp->restart_time = restart; |
1903 | return CMD_SUCCESS; | |
1904 | } | |
1905 | ||
93406d87 | 1906 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
1907 | no_bgp_graceful_restart_stalepath_time_cmd, | |
838758ac | 1908 | "no bgp graceful-restart stalepath-time [(1-3600)]", |
93406d87 | 1909 | NO_STR |
1910 | "BGP specific commands\n" | |
1911 | "Graceful restart capability parameters\n" | |
838758ac DW |
1912 | "Set the max time to hold onto restarting peer's stale paths\n" |
1913 | "Delay value (seconds)\n") | |
93406d87 | 1914 | { |
cdc2d765 | 1915 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 1916 | |
1917 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; | |
1918 | return CMD_SUCCESS; | |
1919 | } | |
1920 | ||
eb6f1b41 PG |
1921 | DEFUN (no_bgp_graceful_restart_restart_time, |
1922 | no_bgp_graceful_restart_restart_time_cmd, | |
838758ac | 1923 | "no bgp graceful-restart restart-time [(1-3600)]", |
eb6f1b41 PG |
1924 | NO_STR |
1925 | "BGP specific commands\n" | |
1926 | "Graceful restart capability parameters\n" | |
838758ac DW |
1927 | "Set the time to wait to delete stale routes before a BGP open message is received\n" |
1928 | "Delay value (seconds)\n") | |
eb6f1b41 | 1929 | { |
cdc2d765 | 1930 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 PG |
1931 | |
1932 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; | |
1933 | return CMD_SUCCESS; | |
1934 | } | |
1935 | ||
43fc21b3 JC |
1936 | DEFUN (bgp_graceful_restart_preserve_fw, |
1937 | bgp_graceful_restart_preserve_fw_cmd, | |
1938 | "bgp graceful-restart preserve-fw-state", | |
1939 | "BGP specific commands\n" | |
1940 | "Graceful restart capability parameters\n" | |
1941 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1942 | { | |
1943 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1944 | bgp_flag_set(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1945 | return CMD_SUCCESS; | |
1946 | } | |
1947 | ||
1948 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
1949 | no_bgp_graceful_restart_preserve_fw_cmd, | |
1950 | "no bgp graceful-restart preserve-fw-state", | |
1951 | NO_STR | |
1952 | "BGP specific commands\n" | |
1953 | "Graceful restart capability parameters\n" | |
1954 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1955 | { | |
1956 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1957 | bgp_flag_unset(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1958 | return CMD_SUCCESS; | |
1959 | } | |
1960 | ||
718e3744 | 1961 | /* "bgp fast-external-failover" configuration. */ |
1962 | DEFUN (bgp_fast_external_failover, | |
1963 | bgp_fast_external_failover_cmd, | |
1964 | "bgp fast-external-failover", | |
1965 | BGP_STR | |
1966 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
1967 | { | |
cdc2d765 | 1968 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1969 | bgp_flag_unset (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); |
1970 | return CMD_SUCCESS; | |
1971 | } | |
1972 | ||
1973 | DEFUN (no_bgp_fast_external_failover, | |
1974 | no_bgp_fast_external_failover_cmd, | |
1975 | "no bgp fast-external-failover", | |
1976 | NO_STR | |
1977 | BGP_STR | |
1978 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
1979 | { | |
cdc2d765 | 1980 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1981 | bgp_flag_set (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); |
1982 | return CMD_SUCCESS; | |
1983 | } | |
6b0655a2 | 1984 | |
718e3744 | 1985 | /* "bgp enforce-first-as" configuration. */ |
1986 | DEFUN (bgp_enforce_first_as, | |
1987 | bgp_enforce_first_as_cmd, | |
1988 | "bgp enforce-first-as", | |
1989 | BGP_STR | |
1990 | "Enforce the first AS for EBGP routes\n") | |
1991 | { | |
cdc2d765 | 1992 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1993 | bgp_flag_set (bgp, BGP_FLAG_ENFORCE_FIRST_AS); |
f31fa004 | 1994 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 1995 | |
718e3744 | 1996 | return CMD_SUCCESS; |
1997 | } | |
1998 | ||
1999 | DEFUN (no_bgp_enforce_first_as, | |
2000 | no_bgp_enforce_first_as_cmd, | |
2001 | "no bgp enforce-first-as", | |
2002 | NO_STR | |
2003 | BGP_STR | |
2004 | "Enforce the first AS for EBGP routes\n") | |
2005 | { | |
cdc2d765 | 2006 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2007 | bgp_flag_unset (bgp, BGP_FLAG_ENFORCE_FIRST_AS); |
f31fa004 | 2008 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 2009 | |
718e3744 | 2010 | return CMD_SUCCESS; |
2011 | } | |
6b0655a2 | 2012 | |
718e3744 | 2013 | /* "bgp bestpath compare-routerid" configuration. */ |
2014 | DEFUN (bgp_bestpath_compare_router_id, | |
2015 | bgp_bestpath_compare_router_id_cmd, | |
2016 | "bgp bestpath compare-routerid", | |
2017 | "BGP specific commands\n" | |
2018 | "Change the default bestpath selection\n" | |
2019 | "Compare router-id for identical EBGP paths\n") | |
2020 | { | |
cdc2d765 | 2021 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2022 | bgp_flag_set (bgp, BGP_FLAG_COMPARE_ROUTER_ID); |
7aafcaca DS |
2023 | bgp_recalculate_all_bestpaths (bgp); |
2024 | ||
718e3744 | 2025 | return CMD_SUCCESS; |
2026 | } | |
2027 | ||
2028 | DEFUN (no_bgp_bestpath_compare_router_id, | |
2029 | no_bgp_bestpath_compare_router_id_cmd, | |
2030 | "no bgp bestpath compare-routerid", | |
2031 | NO_STR | |
2032 | "BGP specific commands\n" | |
2033 | "Change the default bestpath selection\n" | |
2034 | "Compare router-id for identical EBGP paths\n") | |
2035 | { | |
cdc2d765 | 2036 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2037 | bgp_flag_unset (bgp, BGP_FLAG_COMPARE_ROUTER_ID); |
7aafcaca DS |
2038 | bgp_recalculate_all_bestpaths (bgp); |
2039 | ||
718e3744 | 2040 | return CMD_SUCCESS; |
2041 | } | |
6b0655a2 | 2042 | |
718e3744 | 2043 | /* "bgp bestpath as-path ignore" configuration. */ |
2044 | DEFUN (bgp_bestpath_aspath_ignore, | |
2045 | bgp_bestpath_aspath_ignore_cmd, | |
2046 | "bgp bestpath as-path ignore", | |
2047 | "BGP specific commands\n" | |
2048 | "Change the default bestpath selection\n" | |
2049 | "AS-path attribute\n" | |
2050 | "Ignore as-path length in selecting a route\n") | |
2051 | { | |
cdc2d765 | 2052 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2053 | bgp_flag_set (bgp, BGP_FLAG_ASPATH_IGNORE); |
7aafcaca DS |
2054 | bgp_recalculate_all_bestpaths (bgp); |
2055 | ||
718e3744 | 2056 | return CMD_SUCCESS; |
2057 | } | |
2058 | ||
2059 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
2060 | no_bgp_bestpath_aspath_ignore_cmd, | |
2061 | "no bgp bestpath as-path ignore", | |
2062 | NO_STR | |
2063 | "BGP specific commands\n" | |
2064 | "Change the default bestpath selection\n" | |
2065 | "AS-path attribute\n" | |
2066 | "Ignore as-path length in selecting a route\n") | |
2067 | { | |
cdc2d765 | 2068 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2069 | bgp_flag_unset (bgp, BGP_FLAG_ASPATH_IGNORE); |
7aafcaca DS |
2070 | bgp_recalculate_all_bestpaths (bgp); |
2071 | ||
718e3744 | 2072 | return CMD_SUCCESS; |
2073 | } | |
6b0655a2 | 2074 | |
6811845b | 2075 | /* "bgp bestpath as-path confed" configuration. */ |
2076 | DEFUN (bgp_bestpath_aspath_confed, | |
2077 | bgp_bestpath_aspath_confed_cmd, | |
2078 | "bgp bestpath as-path confed", | |
2079 | "BGP specific commands\n" | |
2080 | "Change the default bestpath selection\n" | |
2081 | "AS-path attribute\n" | |
2082 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2083 | { | |
cdc2d765 | 2084 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6811845b | 2085 | bgp_flag_set (bgp, BGP_FLAG_ASPATH_CONFED); |
7aafcaca DS |
2086 | bgp_recalculate_all_bestpaths (bgp); |
2087 | ||
6811845b | 2088 | return CMD_SUCCESS; |
2089 | } | |
2090 | ||
2091 | DEFUN (no_bgp_bestpath_aspath_confed, | |
2092 | no_bgp_bestpath_aspath_confed_cmd, | |
2093 | "no bgp bestpath as-path confed", | |
2094 | NO_STR | |
2095 | "BGP specific commands\n" | |
2096 | "Change the default bestpath selection\n" | |
2097 | "AS-path attribute\n" | |
2098 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2099 | { | |
cdc2d765 | 2100 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6811845b | 2101 | bgp_flag_unset (bgp, BGP_FLAG_ASPATH_CONFED); |
7aafcaca DS |
2102 | bgp_recalculate_all_bestpaths (bgp); |
2103 | ||
6811845b | 2104 | return CMD_SUCCESS; |
2105 | } | |
6b0655a2 | 2106 | |
2fdd455c PM |
2107 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
2108 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
2109 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2110 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2111 | "BGP specific commands\n" |
2112 | "Change the default bestpath selection\n" | |
2113 | "AS-path attribute\n" | |
2114 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2115 | "Generate an AS_SET\n" |
16fc1eec DS |
2116 | "Do not generate an AS_SET\n") |
2117 | { | |
cdc2d765 | 2118 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4c4ff4c1 | 2119 | int idx = 0; |
16fc1eec | 2120 | bgp_flag_set (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); |
219178b6 DW |
2121 | |
2122 | /* no-as-set is now the default behavior so we can silently | |
2123 | * ignore it */ | |
4c4ff4c1 | 2124 | if (argv_find (argv, argc, "as-set", &idx)) |
219178b6 DW |
2125 | bgp_flag_set (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
2126 | else | |
2127 | bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET) ; | |
2128 | ||
7aafcaca DS |
2129 | bgp_recalculate_all_bestpaths (bgp); |
2130 | ||
16fc1eec DS |
2131 | return CMD_SUCCESS; |
2132 | } | |
2133 | ||
219178b6 DW |
2134 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
2135 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2136 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2137 | NO_STR |
2138 | "BGP specific commands\n" | |
2139 | "Change the default bestpath selection\n" | |
2140 | "AS-path attribute\n" | |
2141 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2142 | "Generate an AS_SET\n" |
16fc1eec DS |
2143 | "Do not generate an AS_SET\n") |
2144 | { | |
cdc2d765 | 2145 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
16fc1eec | 2146 | bgp_flag_unset (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); |
219178b6 | 2147 | bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
7aafcaca DS |
2148 | bgp_recalculate_all_bestpaths (bgp); |
2149 | ||
2fdd455c PM |
2150 | return CMD_SUCCESS; |
2151 | } | |
6b0655a2 | 2152 | |
848973c7 | 2153 | /* "bgp log-neighbor-changes" configuration. */ |
2154 | DEFUN (bgp_log_neighbor_changes, | |
2155 | bgp_log_neighbor_changes_cmd, | |
2156 | "bgp log-neighbor-changes", | |
2157 | "BGP specific commands\n" | |
2158 | "Log neighbor up/down and reset reason\n") | |
2159 | { | |
cdc2d765 | 2160 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
848973c7 | 2161 | bgp_flag_set (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
2162 | return CMD_SUCCESS; | |
2163 | } | |
2164 | ||
2165 | DEFUN (no_bgp_log_neighbor_changes, | |
2166 | no_bgp_log_neighbor_changes_cmd, | |
2167 | "no bgp log-neighbor-changes", | |
2168 | NO_STR | |
2169 | "BGP specific commands\n" | |
2170 | "Log neighbor up/down and reset reason\n") | |
2171 | { | |
cdc2d765 | 2172 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
848973c7 | 2173 | bgp_flag_unset (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
2174 | return CMD_SUCCESS; | |
2175 | } | |
6b0655a2 | 2176 | |
718e3744 | 2177 | /* "bgp bestpath med" configuration. */ |
2178 | DEFUN (bgp_bestpath_med, | |
2179 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 2180 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2181 | "BGP specific commands\n" |
2182 | "Change the default bestpath selection\n" | |
2183 | "MED attribute\n" | |
2184 | "Compare MED among confederation paths\n" | |
838758ac DW |
2185 | "Treat missing MED as the least preferred one\n" |
2186 | "Treat missing MED as the least preferred one\n" | |
2187 | "Compare MED among confederation paths\n") | |
718e3744 | 2188 | { |
cdc2d765 | 2189 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6cbd1915 QY |
2190 | |
2191 | int idx = 0; | |
2192 | if (argv_find (argv, argc, "confed", &idx)) | |
2193 | bgp_flag_set (bgp, BGP_FLAG_MED_CONFED); | |
2194 | idx = 0; | |
2195 | if (argv_find (argv, argc, "missing-as-worst", &idx)) | |
2196 | bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
e52702f2 | 2197 | |
7aafcaca DS |
2198 | bgp_recalculate_all_bestpaths (bgp); |
2199 | ||
718e3744 | 2200 | return CMD_SUCCESS; |
2201 | } | |
2202 | ||
718e3744 | 2203 | DEFUN (no_bgp_bestpath_med, |
2204 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2205 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2206 | NO_STR |
2207 | "BGP specific commands\n" | |
2208 | "Change the default bestpath selection\n" | |
2209 | "MED attribute\n" | |
2210 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2211 | "Treat missing MED as the least preferred one\n" |
2212 | "Treat missing MED as the least preferred one\n" | |
2213 | "Compare MED among confederation paths\n") | |
718e3744 | 2214 | { |
cdc2d765 | 2215 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
e52702f2 | 2216 | |
6cbd1915 QY |
2217 | int idx = 0; |
2218 | if (argv_find (argv, argc, "confed", &idx)) | |
718e3744 | 2219 | bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED); |
6cbd1915 QY |
2220 | idx = 0; |
2221 | if (argv_find (argv, argc, "missing-as-worst", &idx)) | |
718e3744 | 2222 | bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST); |
2223 | ||
7aafcaca DS |
2224 | bgp_recalculate_all_bestpaths (bgp); |
2225 | ||
718e3744 | 2226 | return CMD_SUCCESS; |
2227 | } | |
2228 | ||
718e3744 | 2229 | /* "no bgp default ipv4-unicast". */ |
2230 | DEFUN (no_bgp_default_ipv4_unicast, | |
2231 | no_bgp_default_ipv4_unicast_cmd, | |
2232 | "no bgp default ipv4-unicast", | |
2233 | NO_STR | |
2234 | "BGP specific commands\n" | |
2235 | "Configure BGP defaults\n" | |
2236 | "Activate ipv4-unicast for a peer by default\n") | |
2237 | { | |
cdc2d765 | 2238 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2239 | bgp_flag_set (bgp, BGP_FLAG_NO_DEFAULT_IPV4); |
2240 | return CMD_SUCCESS; | |
2241 | } | |
2242 | ||
2243 | DEFUN (bgp_default_ipv4_unicast, | |
2244 | bgp_default_ipv4_unicast_cmd, | |
2245 | "bgp default ipv4-unicast", | |
2246 | "BGP specific commands\n" | |
2247 | "Configure BGP defaults\n" | |
2248 | "Activate ipv4-unicast for a peer by default\n") | |
2249 | { | |
cdc2d765 | 2250 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2251 | bgp_flag_unset (bgp, BGP_FLAG_NO_DEFAULT_IPV4); |
2252 | return CMD_SUCCESS; | |
2253 | } | |
6b0655a2 | 2254 | |
04b6bdc0 DW |
2255 | /* Display hostname in certain command outputs */ |
2256 | DEFUN (bgp_default_show_hostname, | |
2257 | bgp_default_show_hostname_cmd, | |
2258 | "bgp default show-hostname", | |
2259 | "BGP specific commands\n" | |
2260 | "Configure BGP defaults\n" | |
2261 | "Show hostname in certain command ouputs\n") | |
2262 | { | |
cdc2d765 | 2263 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
04b6bdc0 DW |
2264 | bgp_flag_set (bgp, BGP_FLAG_SHOW_HOSTNAME); |
2265 | return CMD_SUCCESS; | |
2266 | } | |
2267 | ||
2268 | DEFUN (no_bgp_default_show_hostname, | |
2269 | no_bgp_default_show_hostname_cmd, | |
2270 | "no bgp default show-hostname", | |
2271 | NO_STR | |
2272 | "BGP specific commands\n" | |
2273 | "Configure BGP defaults\n" | |
2274 | "Show hostname in certain command ouputs\n") | |
2275 | { | |
cdc2d765 | 2276 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
04b6bdc0 DW |
2277 | bgp_flag_unset (bgp, BGP_FLAG_SHOW_HOSTNAME); |
2278 | return CMD_SUCCESS; | |
2279 | } | |
2280 | ||
8233ef81 | 2281 | /* "bgp network import-check" configuration. */ |
718e3744 | 2282 | DEFUN (bgp_network_import_check, |
2283 | bgp_network_import_check_cmd, | |
5623e905 | 2284 | "bgp network import-check", |
718e3744 | 2285 | "BGP specific commands\n" |
2286 | "BGP network command\n" | |
5623e905 | 2287 | "Check BGP network route exists in IGP\n") |
718e3744 | 2288 | { |
cdc2d765 | 2289 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
078430f6 DS |
2290 | if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) |
2291 | { | |
2292 | bgp_flag_set (bgp, BGP_FLAG_IMPORT_CHECK); | |
5623e905 | 2293 | bgp_static_redo_import_check(bgp); |
078430f6 DS |
2294 | } |
2295 | ||
718e3744 | 2296 | return CMD_SUCCESS; |
2297 | } | |
2298 | ||
8233ef81 DW |
2299 | ALIAS_HIDDEN (bgp_network_import_check, |
2300 | bgp_network_import_check_exact_cmd, | |
2301 | "bgp network import-check exact", | |
2302 | "BGP specific commands\n" | |
2303 | "BGP network command\n" | |
2304 | "Check BGP network route exists in IGP\n" | |
2305 | "Match route precisely\n") | |
2306 | ||
718e3744 | 2307 | DEFUN (no_bgp_network_import_check, |
2308 | no_bgp_network_import_check_cmd, | |
5623e905 | 2309 | "no bgp network import-check", |
718e3744 | 2310 | NO_STR |
2311 | "BGP specific commands\n" | |
2312 | "BGP network command\n" | |
2313 | "Check BGP network route exists in IGP\n") | |
2314 | { | |
cdc2d765 | 2315 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
078430f6 DS |
2316 | if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) |
2317 | { | |
2318 | bgp_flag_unset (bgp, BGP_FLAG_IMPORT_CHECK); | |
078430f6 DS |
2319 | bgp_static_redo_import_check(bgp); |
2320 | } | |
5623e905 | 2321 | |
718e3744 | 2322 | return CMD_SUCCESS; |
2323 | } | |
6b0655a2 | 2324 | |
718e3744 | 2325 | DEFUN (bgp_default_local_preference, |
2326 | bgp_default_local_preference_cmd, | |
6147e2c6 | 2327 | "bgp default local-preference (0-4294967295)", |
718e3744 | 2328 | "BGP specific commands\n" |
2329 | "Configure BGP defaults\n" | |
2330 | "local preference (higher=more preferred)\n" | |
2331 | "Configure default local preference value\n") | |
2332 | { | |
cdc2d765 | 2333 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2334 | int idx_number = 3; |
718e3744 | 2335 | u_int32_t local_pref; |
2336 | ||
c500ae40 | 2337 | VTY_GET_INTEGER ("local preference", local_pref, argv[idx_number]->arg); |
718e3744 | 2338 | |
2339 | bgp_default_local_preference_set (bgp, local_pref); | |
f31fa004 | 2340 | bgp_clear_star_soft_in (vty, bgp->name); |
718e3744 | 2341 | |
2342 | return CMD_SUCCESS; | |
2343 | } | |
2344 | ||
2345 | DEFUN (no_bgp_default_local_preference, | |
2346 | no_bgp_default_local_preference_cmd, | |
838758ac | 2347 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 2348 | NO_STR |
2349 | "BGP specific commands\n" | |
2350 | "Configure BGP defaults\n" | |
838758ac DW |
2351 | "local preference (higher=more preferred)\n" |
2352 | "Configure default local preference value\n") | |
718e3744 | 2353 | { |
cdc2d765 | 2354 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2355 | bgp_default_local_preference_unset (bgp); |
f31fa004 | 2356 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 2357 | |
718e3744 | 2358 | return CMD_SUCCESS; |
2359 | } | |
2360 | ||
6b0655a2 | 2361 | |
3f9c7369 DS |
2362 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
2363 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 2364 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
2365 | "BGP specific commands\n" |
2366 | "Configure BGP defaults\n" | |
2367 | "subgroup-pkt-queue-max\n" | |
2368 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 2369 | { |
cdc2d765 | 2370 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2371 | int idx_number = 3; |
3f9c7369 | 2372 | u_int32_t max_size; |
8bd9d948 | 2373 | |
c500ae40 | 2374 | VTY_GET_INTEGER ("subgroup packet queue max", max_size, argv[idx_number]->arg); |
3f9c7369 DS |
2375 | |
2376 | bgp_default_subgroup_pkt_queue_max_set (bgp, max_size); | |
2377 | ||
2378 | return CMD_SUCCESS; | |
2379 | } | |
2380 | ||
2381 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
2382 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 2383 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
2384 | NO_STR |
2385 | "BGP specific commands\n" | |
2386 | "Configure BGP defaults\n" | |
838758ac DW |
2387 | "subgroup-pkt-queue-max\n" |
2388 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 2389 | { |
cdc2d765 | 2390 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3f9c7369 DS |
2391 | bgp_default_subgroup_pkt_queue_max_unset (bgp); |
2392 | return CMD_SUCCESS; | |
8bd9d948 DS |
2393 | } |
2394 | ||
813d4307 | 2395 | |
8bd9d948 DS |
2396 | DEFUN (bgp_rr_allow_outbound_policy, |
2397 | bgp_rr_allow_outbound_policy_cmd, | |
2398 | "bgp route-reflector allow-outbound-policy", | |
2399 | "BGP specific commands\n" | |
2400 | "Allow modifications made by out route-map\n" | |
2401 | "on ibgp neighbors\n") | |
2402 | { | |
cdc2d765 | 2403 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 DS |
2404 | |
2405 | if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) | |
2406 | { | |
2407 | bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3f9c7369 | 2408 | update_group_announce_rrclients(bgp); |
f31fa004 | 2409 | bgp_clear_star_soft_out (vty, bgp->name); |
8bd9d948 DS |
2410 | } |
2411 | ||
2412 | return CMD_SUCCESS; | |
2413 | } | |
2414 | ||
2415 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
2416 | no_bgp_rr_allow_outbound_policy_cmd, | |
2417 | "no bgp route-reflector allow-outbound-policy", | |
2418 | NO_STR | |
2419 | "BGP specific commands\n" | |
2420 | "Allow modifications made by out route-map\n" | |
2421 | "on ibgp neighbors\n") | |
2422 | { | |
cdc2d765 | 2423 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 DS |
2424 | |
2425 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) | |
2426 | { | |
2427 | bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3f9c7369 | 2428 | update_group_announce_rrclients(bgp); |
f31fa004 | 2429 | bgp_clear_star_soft_out (vty, bgp->name); |
8bd9d948 DS |
2430 | } |
2431 | ||
2432 | return CMD_SUCCESS; | |
2433 | } | |
2434 | ||
f14e6fdb DS |
2435 | DEFUN (bgp_listen_limit, |
2436 | bgp_listen_limit_cmd, | |
9ccf14f7 | 2437 | "bgp listen limit (1-5000)", |
f14e6fdb DS |
2438 | "BGP specific commands\n" |
2439 | "Configure BGP defaults\n" | |
2440 | "maximum number of BGP Dynamic Neighbors that can be created\n" | |
2441 | "Configure Dynamic Neighbors listen limit value\n") | |
2442 | { | |
cdc2d765 | 2443 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2444 | int idx_number = 3; |
f14e6fdb DS |
2445 | int listen_limit; |
2446 | ||
c500ae40 | 2447 | VTY_GET_INTEGER_RANGE ("listen limit", listen_limit, argv[idx_number]->arg, |
f14e6fdb DS |
2448 | BGP_DYNAMIC_NEIGHBORS_LIMIT_MIN, |
2449 | BGP_DYNAMIC_NEIGHBORS_LIMIT_MAX); | |
2450 | ||
2451 | bgp_listen_limit_set (bgp, listen_limit); | |
2452 | ||
2453 | return CMD_SUCCESS; | |
2454 | } | |
2455 | ||
2456 | DEFUN (no_bgp_listen_limit, | |
2457 | no_bgp_listen_limit_cmd, | |
838758ac | 2458 | "no bgp listen limit [(1-5000)]", |
f14e6fdb DS |
2459 | "BGP specific commands\n" |
2460 | "Configure BGP defaults\n" | |
2461 | "unset maximum number of BGP Dynamic Neighbors that can be created\n" | |
838758ac DW |
2462 | "Configure Dynamic Neighbors listen limit value to default\n" |
2463 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 2464 | { |
cdc2d765 | 2465 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f14e6fdb DS |
2466 | bgp_listen_limit_unset (bgp); |
2467 | return CMD_SUCCESS; | |
2468 | } | |
2469 | ||
2470 | ||
20eb8864 | 2471 | /* |
2472 | * Check if this listen range is already configured. Check for exact | |
2473 | * match or overlap based on input. | |
2474 | */ | |
2475 | static struct peer_group * | |
2476 | listen_range_exists (struct bgp *bgp, struct prefix *range, int exact) | |
2477 | { | |
2478 | struct listnode *node, *nnode; | |
2479 | struct listnode *node1, *nnode1; | |
2480 | struct peer_group *group; | |
2481 | struct prefix *lr; | |
2482 | afi_t afi; | |
2483 | int match; | |
2484 | ||
2485 | afi = family2afi(range->family); | |
2486 | for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) | |
2487 | { | |
2488 | for (ALL_LIST_ELEMENTS (group->listen_range[afi], node1, | |
2489 | nnode1, lr)) | |
2490 | { | |
2491 | if (exact) | |
2492 | match = prefix_same (range, lr); | |
2493 | else | |
2494 | match = (prefix_match (range, lr) || prefix_match (lr, range)); | |
2495 | if (match) | |
2496 | return group; | |
2497 | } | |
2498 | } | |
2499 | ||
2500 | return NULL; | |
2501 | } | |
2502 | ||
f14e6fdb DS |
2503 | DEFUN (bgp_listen_range, |
2504 | bgp_listen_range_cmd, | |
9ccf14f7 | 2505 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
f14e6fdb | 2506 | "BGP specific commands\n" |
d7fa34c1 QY |
2507 | "Configure BGP dynamic neighbors listen range\n" |
2508 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
2509 | NEIGHBOR_ADDR_STR |
2510 | "Member of the peer-group\n" | |
2511 | "Peer-group name\n") | |
f14e6fdb | 2512 | { |
cdc2d765 | 2513 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f14e6fdb | 2514 | struct prefix range; |
20eb8864 | 2515 | struct peer_group *group, *existing_group; |
f14e6fdb DS |
2516 | afi_t afi; |
2517 | int ret; | |
d7fa34c1 | 2518 | int idx = 0; |
f14e6fdb | 2519 | |
d7fa34c1 QY |
2520 | argv_find (argv, argc, "A.B.C.D/M", &idx); |
2521 | argv_find (argv, argc, "X:X::X:X/M", &idx); | |
2522 | char *prefix = argv[idx]->arg; | |
2523 | argv_find (argv, argc, "WORD", &idx); | |
2524 | char *peergroup = argv[idx]->arg; | |
f14e6fdb | 2525 | |
f14e6fdb | 2526 | /* Convert IP prefix string to struct prefix. */ |
d7fa34c1 | 2527 | ret = str2prefix (prefix, &range); |
f14e6fdb DS |
2528 | if (! ret) |
2529 | { | |
2530 | vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE); | |
2531 | return CMD_WARNING; | |
2532 | } | |
2533 | ||
2534 | afi = family2afi(range.family); | |
2535 | ||
f14e6fdb DS |
2536 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6)) |
2537 | { | |
2538 | vty_out (vty, "%% Malformed listen range (link-local address)%s", | |
2539 | VTY_NEWLINE); | |
2540 | return CMD_WARNING; | |
2541 | } | |
f14e6fdb DS |
2542 | |
2543 | apply_mask (&range); | |
2544 | ||
20eb8864 | 2545 | /* Check if same listen range is already configured. */ |
2546 | existing_group = listen_range_exists (bgp, &range, 1); | |
2547 | if (existing_group) | |
2548 | { | |
d7fa34c1 | 2549 | if (strcmp (existing_group->name, peergroup) == 0) |
20eb8864 | 2550 | return CMD_SUCCESS; |
2551 | else | |
2552 | { | |
2553 | vty_out (vty, "%% Same listen range is attached to peer-group %s%s", | |
2554 | existing_group->name, VTY_NEWLINE); | |
2555 | return CMD_WARNING; | |
2556 | } | |
2557 | } | |
2558 | ||
2559 | /* Check if an overlapping listen range exists. */ | |
2560 | if (listen_range_exists (bgp, &range, 0)) | |
2561 | { | |
2562 | vty_out (vty, "%% Listen range overlaps with existing listen range%s", | |
2563 | VTY_NEWLINE); | |
2564 | return CMD_WARNING; | |
2565 | } | |
f14e6fdb | 2566 | |
d7fa34c1 | 2567 | group = peer_group_lookup (bgp, peergroup); |
f14e6fdb DS |
2568 | if (! group) |
2569 | { | |
2570 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
2571 | return CMD_WARNING; | |
2572 | } | |
2573 | ||
2574 | ret = peer_group_listen_range_add(group, &range); | |
2575 | return bgp_vty_return (vty, ret); | |
2576 | } | |
2577 | ||
2578 | DEFUN (no_bgp_listen_range, | |
2579 | no_bgp_listen_range_cmd, | |
d7fa34c1 QY |
2580 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
2581 | NO_STR | |
f14e6fdb | 2582 | "BGP specific commands\n" |
d7fa34c1 QY |
2583 | "Unconfigure BGP dynamic neighbors listen range\n" |
2584 | "Unconfigure BGP dynamic neighbors listen range\n" | |
2585 | NEIGHBOR_ADDR_STR | |
2586 | "Member of the peer-group\n" | |
2587 | "Peer-group name\n") | |
f14e6fdb | 2588 | { |
cdc2d765 | 2589 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f14e6fdb DS |
2590 | struct prefix range; |
2591 | struct peer_group *group; | |
2592 | afi_t afi; | |
2593 | int ret; | |
d7fa34c1 QY |
2594 | int idx = 0; |
2595 | ||
2596 | argv_find (argv, argc, "A.B.C.D/M", &idx); | |
2597 | argv_find (argv, argc, "X:X::X:X/M", &idx); | |
2598 | char *prefix = argv[idx]->arg; | |
2599 | argv_find (argv, argc, "WORD", &idx); | |
2600 | char *peergroup = argv[idx]->arg; | |
f14e6fdb | 2601 | |
c500ae40 | 2602 | // VTY_GET_IPV4_PREFIX ("listen range", range, argv[idx_ipv4_prefixlen]->arg); |
f14e6fdb DS |
2603 | |
2604 | /* Convert IP prefix string to struct prefix. */ | |
d7fa34c1 | 2605 | ret = str2prefix (prefix, &range); |
f14e6fdb DS |
2606 | if (! ret) |
2607 | { | |
2608 | vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE); | |
2609 | return CMD_WARNING; | |
2610 | } | |
2611 | ||
2612 | afi = family2afi(range.family); | |
2613 | ||
f14e6fdb DS |
2614 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6)) |
2615 | { | |
2616 | vty_out (vty, "%% Malformed listen range (link-local address)%s", | |
2617 | VTY_NEWLINE); | |
2618 | return CMD_WARNING; | |
2619 | } | |
f14e6fdb DS |
2620 | |
2621 | apply_mask (&range); | |
2622 | ||
d7fa34c1 | 2623 | group = peer_group_lookup (bgp, peergroup); |
f14e6fdb DS |
2624 | if (! group) |
2625 | { | |
2626 | vty_out (vty, "%% Peer-group does not exist%s", VTY_NEWLINE); | |
2627 | return CMD_WARNING; | |
2628 | } | |
2629 | ||
2630 | ret = peer_group_listen_range_del(group, &range); | |
2631 | return bgp_vty_return (vty, ret); | |
2632 | } | |
2633 | ||
2634 | int | |
2635 | bgp_config_write_listen (struct vty *vty, struct bgp *bgp) | |
2636 | { | |
2637 | struct peer_group *group; | |
2638 | struct listnode *node, *nnode, *rnode, *nrnode; | |
2639 | struct prefix *range; | |
2640 | afi_t afi; | |
4690c7d7 | 2641 | char buf[PREFIX2STR_BUFFER]; |
f14e6fdb DS |
2642 | |
2643 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
2644 | vty_out (vty, " bgp listen limit %d%s", | |
2645 | bgp->dynamic_neighbors_limit, VTY_NEWLINE); | |
2646 | ||
2647 | for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) | |
2648 | { | |
2649 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
2650 | { | |
2651 | for (ALL_LIST_ELEMENTS (group->listen_range[afi], rnode, nrnode, range)) | |
2652 | { | |
2653 | prefix2str(range, buf, sizeof(buf)); | |
2654 | vty_out(vty, " bgp listen range %s peer-group %s%s", | |
2655 | buf, group->name, VTY_NEWLINE); | |
2656 | } | |
2657 | } | |
2658 | } | |
2659 | ||
2660 | return 0; | |
2661 | } | |
2662 | ||
2663 | ||
907f92c8 DS |
2664 | DEFUN (bgp_disable_connected_route_check, |
2665 | bgp_disable_connected_route_check_cmd, | |
2666 | "bgp disable-ebgp-connected-route-check", | |
2667 | "BGP specific commands\n" | |
2668 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2669 | { | |
cdc2d765 | 2670 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
907f92c8 | 2671 | bgp_flag_set (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); |
f31fa004 | 2672 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 2673 | |
907f92c8 DS |
2674 | return CMD_SUCCESS; |
2675 | } | |
2676 | ||
2677 | DEFUN (no_bgp_disable_connected_route_check, | |
2678 | no_bgp_disable_connected_route_check_cmd, | |
2679 | "no bgp disable-ebgp-connected-route-check", | |
2680 | NO_STR | |
2681 | "BGP specific commands\n" | |
2682 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2683 | { | |
cdc2d765 | 2684 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
907f92c8 | 2685 | bgp_flag_unset (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); |
f31fa004 | 2686 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 2687 | |
907f92c8 DS |
2688 | return CMD_SUCCESS; |
2689 | } | |
2690 | ||
2691 | ||
718e3744 | 2692 | static int |
e52702f2 | 2693 | peer_remote_as_vty (struct vty *vty, const char *peer_str, |
fd79ac91 | 2694 | const char *as_str, afi_t afi, safi_t safi) |
718e3744 | 2695 | { |
cdc2d765 | 2696 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2697 | int ret; |
718e3744 | 2698 | as_t as; |
0299c004 | 2699 | int as_type = AS_SPECIFIED; |
718e3744 | 2700 | union sockunion su; |
2701 | ||
7ae5fc81 | 2702 | if (as_str[0] == 'i') |
0299c004 DS |
2703 | { |
2704 | as = 0; | |
2705 | as_type = AS_INTERNAL; | |
2706 | } | |
7ae5fc81 | 2707 | else if (as_str[0] == 'e') |
0299c004 DS |
2708 | { |
2709 | as = 0; | |
2710 | as_type = AS_EXTERNAL; | |
2711 | } | |
2712 | else | |
2713 | { | |
2714 | /* Get AS number. */ | |
2715 | VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX); | |
2716 | } | |
718e3744 | 2717 | |
2718 | /* If peer is peer group, call proper function. */ | |
2719 | ret = str2sockunion (peer_str, &su); | |
2720 | if (ret < 0) | |
2721 | { | |
a80beece | 2722 | /* Check for peer by interface */ |
0299c004 | 2723 | ret = peer_remote_as (bgp, NULL, peer_str, &as, as_type, afi, safi); |
718e3744 | 2724 | if (ret < 0) |
a80beece | 2725 | { |
0299c004 | 2726 | ret = peer_group_remote_as (bgp, peer_str, &as, as_type); |
a80beece DS |
2727 | if (ret < 0) |
2728 | { | |
2729 | vty_out (vty, "%% Create the peer-group or interface first%s", | |
2730 | VTY_NEWLINE); | |
2731 | return CMD_WARNING; | |
2732 | } | |
2733 | return CMD_SUCCESS; | |
2734 | } | |
718e3744 | 2735 | } |
a80beece | 2736 | else |
718e3744 | 2737 | { |
6aeb9e78 | 2738 | if (peer_address_self_check (bgp, &su)) |
a80beece DS |
2739 | { |
2740 | vty_out (vty, "%% Can not configure the local system as neighbor%s", | |
2741 | VTY_NEWLINE); | |
2742 | return CMD_WARNING; | |
2743 | } | |
0299c004 | 2744 | ret = peer_remote_as (bgp, &su, NULL, &as, as_type, afi, safi); |
718e3744 | 2745 | } |
2746 | ||
718e3744 | 2747 | /* This peer belongs to peer group. */ |
2748 | switch (ret) | |
2749 | { | |
2750 | case BGP_ERR_PEER_GROUP_MEMBER: | |
aea339f7 | 2751 | vty_out (vty, "%% Peer-group AS %u. Cannot configure remote-as for member%s", as, VTY_NEWLINE); |
718e3744 | 2752 | return CMD_WARNING; |
718e3744 | 2753 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: |
aea339f7 | 2754 | 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 | 2755 | return CMD_WARNING; |
718e3744 | 2756 | } |
2757 | return bgp_vty_return (vty, ret); | |
2758 | } | |
2759 | ||
2760 | DEFUN (neighbor_remote_as, | |
2761 | neighbor_remote_as_cmd, | |
3a2d747c | 2762 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2763 | NEIGHBOR_STR |
2764 | NEIGHBOR_ADDR_STR2 | |
2765 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 2766 | AS_STR |
3a2d747c QY |
2767 | "Internal BGP peer\n" |
2768 | "External BGP peer\n") | |
718e3744 | 2769 | { |
c500ae40 DW |
2770 | int idx_peer = 1; |
2771 | int idx_remote_as = 3; | |
2772 | return peer_remote_as_vty (vty, argv[idx_peer]->arg, argv[idx_remote_as]->arg, AFI_IP, SAFI_UNICAST); | |
718e3744 | 2773 | } |
6b0655a2 | 2774 | |
4c48cf63 DW |
2775 | static int |
2776 | peer_conf_interface_get (struct vty *vty, const char *conf_if, afi_t afi, | |
b3a39dc5 DD |
2777 | safi_t safi, int v6only, const char *peer_group_name, |
2778 | const char *as_str) | |
a80beece | 2779 | { |
cdc2d765 | 2780 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
b3a39dc5 DD |
2781 | as_t as = 0; |
2782 | int as_type = AS_UNSPECIFIED; | |
a80beece DS |
2783 | struct peer *peer; |
2784 | struct peer_group *group; | |
4c48cf63 DW |
2785 | int ret = 0; |
2786 | union sockunion su; | |
a80beece | 2787 | |
4c48cf63 DW |
2788 | group = peer_group_lookup (bgp, conf_if); |
2789 | ||
a80beece DS |
2790 | if (group) |
2791 | { | |
2792 | vty_out (vty, "%% Name conflict with peer-group %s", VTY_NEWLINE); | |
2793 | return CMD_WARNING; | |
2794 | } | |
2795 | ||
b3a39dc5 DD |
2796 | if (as_str) |
2797 | { | |
7ae5fc81 | 2798 | if (as_str[0] == 'i') |
b3a39dc5 DD |
2799 | { |
2800 | as_type = AS_INTERNAL; | |
2801 | } | |
7ae5fc81 | 2802 | else if (as_str[0] == 'e') |
b3a39dc5 DD |
2803 | { |
2804 | as_type = AS_EXTERNAL; | |
2805 | } | |
2806 | else | |
2807 | { | |
2808 | /* Get AS number. */ | |
2809 | VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX); | |
2810 | as_type = AS_SPECIFIED; | |
2811 | } | |
2812 | } | |
2813 | ||
4c48cf63 DW |
2814 | peer = peer_lookup_by_conf_if (bgp, conf_if); |
2815 | if (!peer) | |
2816 | { | |
2817 | if (bgp_flag_check (bgp, BGP_FLAG_NO_DEFAULT_IPV4) | |
2818 | && afi == AFI_IP && safi == SAFI_UNICAST) | |
b3a39dc5 DD |
2819 | peer = peer_create (NULL, conf_if, bgp, bgp->as, as, as_type, 0, 0, |
2820 | NULL); | |
4c48cf63 | 2821 | else |
b3a39dc5 DD |
2822 | peer = peer_create (NULL, conf_if, bgp, bgp->as, as, as_type, afi, safi, |
2823 | NULL); | |
4c48cf63 DW |
2824 | |
2825 | if (peer && v6only) | |
2826 | SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
4a04e5f7 | 2827 | |
2828 | /* Request zebra to initiate IPv6 RAs on this interface. We do this | |
2829 | * any unnumbered peer in order to not worry about run-time transitions | |
2830 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 address | |
2831 | * gets deleted later etc.) | |
2832 | */ | |
2833 | if (peer->ifp) | |
b3a39dc5 DD |
2834 | { |
2835 | bgp_zebra_initiate_radv (bgp, peer); | |
2836 | } | |
2837 | peer_flag_set (peer, PEER_FLAG_CAPABILITY_ENHE); | |
4c48cf63 DW |
2838 | } |
2839 | else if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) || | |
2840 | (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) | |
2841 | { | |
2842 | if (v6only) | |
2843 | SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2844 | else | |
2845 | UNSET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2846 | ||
2847 | /* v6only flag changed. Reset bgp seesion */ | |
2848 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) | |
2849 | { | |
2850 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
2851 | bgp_notify_send (peer, BGP_NOTIFY_CEASE, | |
2852 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2853 | } | |
2854 | else | |
2855 | bgp_session_reset(peer); | |
2856 | } | |
2857 | ||
a80beece DS |
2858 | if (!peer) |
2859 | return CMD_WARNING; | |
2860 | ||
4c48cf63 DW |
2861 | if (peer_group_name) |
2862 | { | |
2863 | group = peer_group_lookup (bgp, peer_group_name); | |
2864 | if (! group) | |
2865 | { | |
2866 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
2867 | return CMD_WARNING; | |
2868 | } | |
2869 | ||
2870 | ret = peer_group_bind (bgp, &su, peer, group, &as); | |
2871 | } | |
2872 | ||
2873 | return bgp_vty_return (vty, ret); | |
a80beece DS |
2874 | } |
2875 | ||
4c48cf63 DW |
2876 | DEFUN (neighbor_interface_config, |
2877 | neighbor_interface_config_cmd, | |
31500417 | 2878 | "neighbor WORD interface [peer-group WORD]", |
4c48cf63 DW |
2879 | NEIGHBOR_STR |
2880 | "Interface name or neighbor tag\n" | |
31500417 DW |
2881 | "Enable BGP on interface\n" |
2882 | "Member of the peer-group\n" | |
16cedbb0 | 2883 | "Peer-group name\n") |
4c48cf63 | 2884 | { |
c500ae40 | 2885 | int idx_word = 1; |
31500417 DW |
2886 | int idx_peer_group_word = 4; |
2887 | ||
2888 | if (argc > idx_peer_group_word) | |
c500ae40 | 2889 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, |
31500417 | 2890 | argv[idx_peer_group_word]->arg, NULL); |
4c48cf63 | 2891 | else |
c500ae40 | 2892 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, |
b3a39dc5 | 2893 | NULL, NULL); |
4c48cf63 DW |
2894 | } |
2895 | ||
4c48cf63 DW |
2896 | DEFUN (neighbor_interface_config_v6only, |
2897 | neighbor_interface_config_v6only_cmd, | |
31500417 | 2898 | "neighbor WORD interface v6only [peer-group WORD]", |
4c48cf63 DW |
2899 | NEIGHBOR_STR |
2900 | "Interface name or neighbor tag\n" | |
2901 | "Enable BGP on interface\n" | |
31500417 DW |
2902 | "Enable BGP with v6 link-local only\n" |
2903 | "Member of the peer-group\n" | |
16cedbb0 | 2904 | "Peer-group name\n") |
4c48cf63 | 2905 | { |
c500ae40 | 2906 | int idx_word = 1; |
31500417 DW |
2907 | int idx_peer_group_word = 5; |
2908 | ||
2909 | if (argc > idx_peer_group_word) | |
2910 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
2911 | argv[idx_peer_group_word]->arg, NULL); | |
2912 | ||
c500ae40 | 2913 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, |
31500417 | 2914 | NULL, NULL); |
4c48cf63 DW |
2915 | } |
2916 | ||
a80beece | 2917 | |
b3a39dc5 DD |
2918 | DEFUN (neighbor_interface_config_remote_as, |
2919 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 2920 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2921 | NEIGHBOR_STR |
2922 | "Interface name or neighbor tag\n" | |
2923 | "Enable BGP on interface\n" | |
3a2d747c | 2924 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2925 | AS_STR |
3a2d747c QY |
2926 | "Internal BGP peer\n" |
2927 | "External BGP peer\n") | |
b3a39dc5 | 2928 | { |
c500ae40 DW |
2929 | int idx_word = 1; |
2930 | int idx_remote_as = 4; | |
2931 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
2932 | NULL, argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2933 | } |
2934 | ||
2935 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
2936 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 2937 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2938 | NEIGHBOR_STR |
2939 | "Interface name or neighbor tag\n" | |
3a2d747c | 2940 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 2941 | "Enable BGP on interface\n" |
3a2d747c | 2942 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2943 | AS_STR |
3a2d747c QY |
2944 | "Internal BGP peer\n" |
2945 | "External BGP peer\n") | |
b3a39dc5 | 2946 | { |
c500ae40 DW |
2947 | int idx_word = 1; |
2948 | int idx_remote_as = 5; | |
2949 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
2950 | NULL, argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2951 | } |
2952 | ||
718e3744 | 2953 | DEFUN (neighbor_peer_group, |
2954 | neighbor_peer_group_cmd, | |
2955 | "neighbor WORD peer-group", | |
2956 | NEIGHBOR_STR | |
a80beece | 2957 | "Interface name or neighbor tag\n" |
718e3744 | 2958 | "Configure peer-group\n") |
2959 | { | |
cdc2d765 | 2960 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2961 | int idx_word = 1; |
a80beece | 2962 | struct peer *peer; |
718e3744 | 2963 | struct peer_group *group; |
2964 | ||
c500ae40 | 2965 | peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg); |
a80beece DS |
2966 | if (peer) |
2967 | { | |
2968 | vty_out (vty, "%% Name conflict with interface: %s", VTY_NEWLINE); | |
2969 | return CMD_WARNING; | |
2970 | } | |
718e3744 | 2971 | |
c500ae40 | 2972 | group = peer_group_get (bgp, argv[idx_word]->arg); |
718e3744 | 2973 | if (! group) |
2974 | return CMD_WARNING; | |
2975 | ||
2976 | return CMD_SUCCESS; | |
2977 | } | |
2978 | ||
2979 | DEFUN (no_neighbor, | |
2980 | no_neighbor_cmd, | |
dab8cd00 | 2981 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 2982 | NO_STR |
2983 | NEIGHBOR_STR | |
3a2d747c QY |
2984 | NEIGHBOR_ADDR_STR2 |
2985 | "Specify a BGP neighbor\n" | |
2986 | AS_STR | |
2987 | "Internal BGP peer\n" | |
2988 | "External BGP peer\n") | |
718e3744 | 2989 | { |
cdc2d765 | 2990 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2991 | int idx_peer = 2; |
718e3744 | 2992 | int ret; |
2993 | union sockunion su; | |
2994 | struct peer_group *group; | |
2995 | struct peer *peer; | |
1ff9a340 | 2996 | struct peer *other; |
718e3744 | 2997 | |
c500ae40 | 2998 | ret = str2sockunion (argv[idx_peer]->arg, &su); |
718e3744 | 2999 | if (ret < 0) |
3000 | { | |
a80beece | 3001 | /* look up for neighbor by interface name config. */ |
cdc2d765 | 3002 | peer = peer_lookup_by_conf_if (bgp, argv[idx_peer]->arg); |
a80beece DS |
3003 | if (peer) |
3004 | { | |
4a04e5f7 | 3005 | /* Request zebra to terminate IPv6 RAs on this interface. */ |
3006 | if (peer->ifp) | |
3007 | bgp_zebra_terminate_radv (peer->bgp, peer); | |
a80beece DS |
3008 | peer_delete (peer); |
3009 | return CMD_SUCCESS; | |
3010 | } | |
3011 | ||
cdc2d765 | 3012 | group = peer_group_lookup (bgp, argv[idx_peer]->arg); |
718e3744 | 3013 | if (group) |
3014 | peer_group_delete (group); | |
3015 | else | |
3016 | { | |
3017 | vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE); | |
3018 | return CMD_WARNING; | |
3019 | } | |
3020 | } | |
3021 | else | |
3022 | { | |
cdc2d765 | 3023 | peer = peer_lookup (bgp, &su); |
718e3744 | 3024 | if (peer) |
1ff9a340 | 3025 | { |
f14e6fdb DS |
3026 | if (peer_dynamic_neighbor (peer)) |
3027 | { | |
3028 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
3029 | VTY_NEWLINE); | |
3030 | return CMD_WARNING; | |
3031 | } | |
3032 | ||
1ff9a340 DS |
3033 | other = peer->doppelganger; |
3034 | peer_delete (peer); | |
3035 | if (other && other->status != Deleted) | |
3036 | peer_delete(other); | |
3037 | } | |
718e3744 | 3038 | } |
3039 | ||
3040 | return CMD_SUCCESS; | |
3041 | } | |
3042 | ||
a80beece DS |
3043 | DEFUN (no_neighbor_interface_config, |
3044 | no_neighbor_interface_config_cmd, | |
31500417 | 3045 | "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
3046 | NO_STR |
3047 | NEIGHBOR_STR | |
3048 | "Interface name\n" | |
31500417 DW |
3049 | "Configure BGP on interface\n" |
3050 | "Enable BGP with v6 link-local only\n" | |
3051 | "Member of the peer-group\n" | |
16cedbb0 | 3052 | "Peer-group name\n" |
3a2d747c QY |
3053 | "Specify a BGP neighbor\n" |
3054 | AS_STR | |
3055 | "Internal BGP peer\n" | |
3056 | "External BGP peer\n") | |
a80beece | 3057 | { |
cdc2d765 | 3058 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 3059 | int idx_word = 2; |
a80beece DS |
3060 | struct peer *peer; |
3061 | ||
3062 | /* look up for neighbor by interface name config. */ | |
cdc2d765 | 3063 | peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg); |
a80beece DS |
3064 | if (peer) |
3065 | { | |
4a04e5f7 | 3066 | /* Request zebra to terminate IPv6 RAs on this interface. */ |
3067 | if (peer->ifp) | |
3068 | bgp_zebra_terminate_radv (peer->bgp, peer); | |
a80beece DS |
3069 | peer_delete (peer); |
3070 | } | |
3071 | else | |
3072 | { | |
3073 | vty_out (vty, "%% Create the bgp interface first%s", VTY_NEWLINE); | |
3074 | return CMD_WARNING; | |
3075 | } | |
3076 | return CMD_SUCCESS; | |
3077 | } | |
3078 | ||
718e3744 | 3079 | DEFUN (no_neighbor_peer_group, |
3080 | no_neighbor_peer_group_cmd, | |
3081 | "no neighbor WORD peer-group", | |
3082 | NO_STR | |
3083 | NEIGHBOR_STR | |
3084 | "Neighbor tag\n" | |
3085 | "Configure peer-group\n") | |
3086 | { | |
cdc2d765 | 3087 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 3088 | int idx_word = 2; |
718e3744 | 3089 | struct peer_group *group; |
3090 | ||
cdc2d765 | 3091 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 3092 | if (group) |
3093 | peer_group_delete (group); | |
3094 | else | |
3095 | { | |
3096 | vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE); | |
3097 | return CMD_WARNING; | |
3098 | } | |
3099 | return CMD_SUCCESS; | |
3100 | } | |
3101 | ||
a80beece DS |
3102 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
3103 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 3104 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3105 | NO_STR |
3106 | NEIGHBOR_STR | |
a80beece | 3107 | "Interface name or neighbor tag\n" |
718e3744 | 3108 | "Specify a BGP neighbor\n" |
3a2d747c QY |
3109 | AS_STR |
3110 | "Internal BGP peer\n" | |
3111 | "External BGP peer\n") | |
718e3744 | 3112 | { |
cdc2d765 | 3113 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 3114 | int idx_word = 2; |
718e3744 | 3115 | struct peer_group *group; |
a80beece DS |
3116 | struct peer *peer; |
3117 | ||
3118 | /* look up for neighbor by interface name config. */ | |
cdc2d765 | 3119 | peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg); |
a80beece DS |
3120 | if (peer) |
3121 | { | |
0299c004 | 3122 | peer_as_change (peer, 0, AS_SPECIFIED); |
a80beece DS |
3123 | return CMD_SUCCESS; |
3124 | } | |
718e3744 | 3125 | |
cdc2d765 | 3126 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 3127 | if (group) |
3128 | peer_group_remote_as_delete (group); | |
3129 | else | |
3130 | { | |
a80beece | 3131 | vty_out (vty, "%% Create the peer-group or interface first%s", VTY_NEWLINE); |
718e3744 | 3132 | return CMD_WARNING; |
3133 | } | |
3134 | return CMD_SUCCESS; | |
3135 | } | |
6b0655a2 | 3136 | |
718e3744 | 3137 | DEFUN (neighbor_local_as, |
3138 | neighbor_local_as_cmd, | |
9ccf14f7 | 3139 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 3140 | NEIGHBOR_STR |
3141 | NEIGHBOR_ADDR_STR2 | |
3142 | "Specify a local-as number\n" | |
3143 | "AS number used as local AS\n") | |
3144 | { | |
c500ae40 DW |
3145 | int idx_peer = 1; |
3146 | int idx_number = 3; | |
718e3744 | 3147 | struct peer *peer; |
3148 | int ret; | |
e14fda0f | 3149 | as_t as; |
718e3744 | 3150 | |
c500ae40 | 3151 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3152 | if (! peer) |
3153 | return CMD_WARNING; | |
3154 | ||
b6f1faf0 | 3155 | VTY_GET_INTEGER_RANGE ("Local AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); |
e14fda0f | 3156 | ret = peer_local_as_set (peer, as, 0, 0); |
718e3744 | 3157 | return bgp_vty_return (vty, ret); |
3158 | } | |
3159 | ||
3160 | DEFUN (neighbor_local_as_no_prepend, | |
3161 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 3162 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 3163 | NEIGHBOR_STR |
3164 | NEIGHBOR_ADDR_STR2 | |
3165 | "Specify a local-as number\n" | |
3166 | "AS number used as local AS\n" | |
3167 | "Do not prepend local-as to updates from ebgp peers\n") | |
3168 | { | |
c500ae40 DW |
3169 | int idx_peer = 1; |
3170 | int idx_number = 3; | |
718e3744 | 3171 | struct peer *peer; |
3172 | int ret; | |
e14fda0f | 3173 | as_t as; |
718e3744 | 3174 | |
c500ae40 | 3175 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3176 | if (! peer) |
3177 | return CMD_WARNING; | |
3178 | ||
b6f1faf0 | 3179 | VTY_GET_INTEGER_RANGE ("Local AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); |
e14fda0f | 3180 | ret = peer_local_as_set (peer, as, 1, 0); |
718e3744 | 3181 | return bgp_vty_return (vty, ret); |
3182 | } | |
3183 | ||
9d3f9705 AC |
3184 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
3185 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 3186 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
3187 | NEIGHBOR_STR |
3188 | NEIGHBOR_ADDR_STR2 | |
3189 | "Specify a local-as number\n" | |
3190 | "AS number used as local AS\n" | |
3191 | "Do not prepend local-as to updates from ebgp peers\n" | |
3192 | "Do not prepend local-as to updates from ibgp peers\n") | |
3193 | { | |
c500ae40 DW |
3194 | int idx_peer = 1; |
3195 | int idx_number = 3; | |
9d3f9705 AC |
3196 | struct peer *peer; |
3197 | int ret; | |
e14fda0f | 3198 | as_t as; |
9d3f9705 | 3199 | |
c500ae40 | 3200 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
9d3f9705 AC |
3201 | if (! peer) |
3202 | return CMD_WARNING; | |
3203 | ||
b6f1faf0 | 3204 | VTY_GET_INTEGER_RANGE ("Local AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); |
e14fda0f | 3205 | ret = peer_local_as_set (peer, as, 1, 1); |
9d3f9705 AC |
3206 | return bgp_vty_return (vty, ret); |
3207 | } | |
3208 | ||
718e3744 | 3209 | DEFUN (no_neighbor_local_as, |
3210 | no_neighbor_local_as_cmd, | |
a636c635 | 3211 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 3212 | NO_STR |
3213 | NEIGHBOR_STR | |
3214 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
3215 | "Specify a local-as number\n" |
3216 | "AS number used as local AS\n" | |
3217 | "Do not prepend local-as to updates from ebgp peers\n" | |
3218 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 3219 | { |
c500ae40 | 3220 | int idx_peer = 2; |
718e3744 | 3221 | struct peer *peer; |
3222 | int ret; | |
3223 | ||
c500ae40 | 3224 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3225 | if (! peer) |
3226 | return CMD_WARNING; | |
3227 | ||
3228 | ret = peer_local_as_unset (peer); | |
3229 | return bgp_vty_return (vty, ret); | |
3230 | } | |
3231 | ||
718e3744 | 3232 | |
9d3f9705 | 3233 | |
6b0655a2 | 3234 | |
3f9c7369 DS |
3235 | DEFUN (neighbor_solo, |
3236 | neighbor_solo_cmd, | |
9ccf14f7 | 3237 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3238 | NEIGHBOR_STR |
3239 | NEIGHBOR_ADDR_STR2 | |
3240 | "Solo peer - part of its own update group\n") | |
3241 | { | |
c500ae40 | 3242 | int idx_peer = 1; |
3f9c7369 DS |
3243 | struct peer *peer; |
3244 | int ret; | |
3245 | ||
c500ae40 | 3246 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
3f9c7369 DS |
3247 | if (! peer) |
3248 | return CMD_WARNING; | |
3249 | ||
3250 | ret = update_group_adjust_soloness(peer, 1); | |
3251 | return bgp_vty_return (vty, ret); | |
3252 | } | |
3253 | ||
3254 | DEFUN (no_neighbor_solo, | |
3255 | no_neighbor_solo_cmd, | |
9ccf14f7 | 3256 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3257 | NO_STR |
3258 | NEIGHBOR_STR | |
3259 | NEIGHBOR_ADDR_STR2 | |
3260 | "Solo peer - part of its own update group\n") | |
3261 | { | |
c500ae40 | 3262 | int idx_peer = 2; |
3f9c7369 DS |
3263 | struct peer *peer; |
3264 | int ret; | |
3265 | ||
c500ae40 | 3266 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
3f9c7369 DS |
3267 | if (! peer) |
3268 | return CMD_WARNING; | |
3269 | ||
3270 | ret = update_group_adjust_soloness(peer, 0); | |
3271 | return bgp_vty_return (vty, ret); | |
3272 | } | |
3273 | ||
0df7c91f PJ |
3274 | DEFUN (neighbor_password, |
3275 | neighbor_password_cmd, | |
9ccf14f7 | 3276 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
3277 | NEIGHBOR_STR |
3278 | NEIGHBOR_ADDR_STR2 | |
3279 | "Set a password\n" | |
3280 | "The password\n") | |
3281 | { | |
c500ae40 DW |
3282 | int idx_peer = 1; |
3283 | int idx_line = 3; | |
0df7c91f PJ |
3284 | struct peer *peer; |
3285 | int ret; | |
3286 | ||
c500ae40 | 3287 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
0df7c91f PJ |
3288 | if (! peer) |
3289 | return CMD_WARNING; | |
3290 | ||
c500ae40 | 3291 | ret = peer_password_set (peer, argv[idx_line]->arg); |
0df7c91f PJ |
3292 | return bgp_vty_return (vty, ret); |
3293 | } | |
3294 | ||
3295 | DEFUN (no_neighbor_password, | |
3296 | no_neighbor_password_cmd, | |
a636c635 | 3297 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
3298 | NO_STR |
3299 | NEIGHBOR_STR | |
3300 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
3301 | "Set a password\n" |
3302 | "The password\n") | |
0df7c91f | 3303 | { |
c500ae40 | 3304 | int idx_peer = 2; |
0df7c91f PJ |
3305 | struct peer *peer; |
3306 | int ret; | |
3307 | ||
c500ae40 | 3308 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
0df7c91f PJ |
3309 | if (! peer) |
3310 | return CMD_WARNING; | |
3311 | ||
3312 | ret = peer_password_unset (peer); | |
3313 | return bgp_vty_return (vty, ret); | |
3314 | } | |
6b0655a2 | 3315 | |
813d4307 | 3316 | |
718e3744 | 3317 | DEFUN (neighbor_activate, |
3318 | neighbor_activate_cmd, | |
9ccf14f7 | 3319 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3320 | NEIGHBOR_STR |
3321 | NEIGHBOR_ADDR_STR2 | |
3322 | "Enable the Address Family for this Neighbor\n") | |
3323 | { | |
c500ae40 | 3324 | int idx_peer = 1; |
c8560b44 | 3325 | int ret; |
718e3744 | 3326 | struct peer *peer; |
3327 | ||
c500ae40 | 3328 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3329 | if (! peer) |
3330 | return CMD_WARNING; | |
3331 | ||
c8560b44 | 3332 | ret = peer_activate (peer, bgp_node_afi (vty), bgp_node_safi (vty)); |
718e3744 | 3333 | |
c8560b44 DW |
3334 | if (ret) |
3335 | return CMD_WARNING; | |
718e3744 | 3336 | return CMD_SUCCESS; |
3337 | } | |
3338 | ||
596c17ba DW |
3339 | ALIAS_HIDDEN (neighbor_activate, |
3340 | neighbor_activate_hidden_cmd, | |
3341 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3342 | NEIGHBOR_STR | |
3343 | NEIGHBOR_ADDR_STR2 | |
3344 | "Enable the Address Family for this Neighbor\n") | |
3345 | ||
718e3744 | 3346 | DEFUN (no_neighbor_activate, |
3347 | no_neighbor_activate_cmd, | |
9ccf14f7 | 3348 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3349 | NO_STR |
3350 | NEIGHBOR_STR | |
3351 | NEIGHBOR_ADDR_STR2 | |
3352 | "Enable the Address Family for this Neighbor\n") | |
3353 | { | |
c500ae40 | 3354 | int idx_peer = 2; |
718e3744 | 3355 | int ret; |
3356 | struct peer *peer; | |
3357 | ||
3358 | /* Lookup peer. */ | |
c500ae40 | 3359 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3360 | if (! peer) |
3361 | return CMD_WARNING; | |
3362 | ||
3363 | ret = peer_deactivate (peer, bgp_node_afi (vty), bgp_node_safi (vty)); | |
3364 | ||
c8560b44 DW |
3365 | if (ret) |
3366 | return CMD_WARNING; | |
3367 | return CMD_SUCCESS; | |
718e3744 | 3368 | } |
6b0655a2 | 3369 | |
596c17ba DW |
3370 | ALIAS_HIDDEN (no_neighbor_activate, |
3371 | no_neighbor_activate_hidden_cmd, | |
3372 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3373 | NO_STR | |
3374 | NEIGHBOR_STR | |
3375 | NEIGHBOR_ADDR_STR2 | |
3376 | "Enable the Address Family for this Neighbor\n") | |
3377 | ||
718e3744 | 3378 | DEFUN (neighbor_set_peer_group, |
3379 | neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3380 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3381 | NEIGHBOR_STR |
a80beece | 3382 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3383 | "Member of the peer-group\n" |
16cedbb0 | 3384 | "Peer-group name\n") |
718e3744 | 3385 | { |
cdc2d765 | 3386 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
3387 | int idx_peer = 1; |
3388 | int idx_word = 3; | |
718e3744 | 3389 | int ret; |
3390 | as_t as; | |
3391 | union sockunion su; | |
a80beece | 3392 | struct peer *peer; |
718e3744 | 3393 | struct peer_group *group; |
3394 | ||
a80beece | 3395 | peer = NULL; |
718e3744 | 3396 | |
c500ae40 | 3397 | ret = str2sockunion (argv[idx_peer]->arg, &su); |
718e3744 | 3398 | if (ret < 0) |
3399 | { | |
c500ae40 | 3400 | peer = peer_lookup_by_conf_if (bgp, argv[idx_peer]->arg); |
a80beece DS |
3401 | if (!peer) |
3402 | { | |
c500ae40 | 3403 | vty_out (vty, "%% Malformed address or name: %s%s", argv[idx_peer]->arg, VTY_NEWLINE); |
a80beece DS |
3404 | return CMD_WARNING; |
3405 | } | |
3406 | } | |
3407 | else | |
3408 | { | |
6aeb9e78 | 3409 | if (peer_address_self_check (bgp, &su)) |
a80beece DS |
3410 | { |
3411 | vty_out (vty, "%% Can not configure the local system as neighbor%s", | |
3412 | VTY_NEWLINE); | |
3413 | return CMD_WARNING; | |
3414 | } | |
f14e6fdb DS |
3415 | |
3416 | /* Disallow for dynamic neighbor. */ | |
3417 | peer = peer_lookup (bgp, &su); | |
3418 | if (peer && peer_dynamic_neighbor (peer)) | |
3419 | { | |
3420 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
3421 | VTY_NEWLINE); | |
3422 | return CMD_WARNING; | |
3423 | } | |
718e3744 | 3424 | } |
3425 | ||
c500ae40 | 3426 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 3427 | if (! group) |
3428 | { | |
3429 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
3430 | return CMD_WARNING; | |
3431 | } | |
3432 | ||
c8560b44 | 3433 | ret = peer_group_bind (bgp, &su, peer, group, &as); |
718e3744 | 3434 | |
3435 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) | |
3436 | { | |
aea339f7 | 3437 | 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 | 3438 | return CMD_WARNING; |
3439 | } | |
3440 | ||
3441 | return bgp_vty_return (vty, ret); | |
3442 | } | |
3443 | ||
596c17ba DW |
3444 | ALIAS_HIDDEN (neighbor_set_peer_group, |
3445 | neighbor_set_peer_group_hidden_cmd, | |
3446 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", | |
3447 | NEIGHBOR_STR | |
3448 | NEIGHBOR_ADDR_STR2 | |
3449 | "Member of the peer-group\n" | |
3450 | "Peer-group name\n") | |
3451 | ||
718e3744 | 3452 | DEFUN (no_neighbor_set_peer_group, |
3453 | no_neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3454 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3455 | NO_STR |
3456 | NEIGHBOR_STR | |
a80beece | 3457 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3458 | "Member of the peer-group\n" |
16cedbb0 | 3459 | "Peer-group name\n") |
718e3744 | 3460 | { |
cdc2d765 | 3461 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
3462 | int idx_peer = 2; |
3463 | int idx_word = 4; | |
718e3744 | 3464 | int ret; |
718e3744 | 3465 | struct peer *peer; |
3466 | struct peer_group *group; | |
3467 | ||
c500ae40 | 3468 | peer = peer_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3469 | if (! peer) |
3470 | return CMD_WARNING; | |
3471 | ||
c500ae40 | 3472 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 3473 | if (! group) |
3474 | { | |
3475 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
3476 | return CMD_WARNING; | |
3477 | } | |
3478 | ||
c8560b44 | 3479 | ret = peer_group_unbind (bgp, peer, group); |
718e3744 | 3480 | |
3481 | return bgp_vty_return (vty, ret); | |
3482 | } | |
6b0655a2 | 3483 | |
596c17ba DW |
3484 | ALIAS_HIDDEN (no_neighbor_set_peer_group, |
3485 | no_neighbor_set_peer_group_hidden_cmd, | |
3486 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", | |
3487 | NO_STR | |
3488 | NEIGHBOR_STR | |
3489 | NEIGHBOR_ADDR_STR2 | |
3490 | "Member of the peer-group\n" | |
3491 | "Peer-group name\n") | |
3492 | ||
94f2b392 | 3493 | static int |
e52702f2 | 3494 | peer_flag_modify_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 3495 | u_int16_t flag, int set) |
718e3744 | 3496 | { |
3497 | int ret; | |
3498 | struct peer *peer; | |
3499 | ||
3500 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
3501 | if (! peer) | |
3502 | return CMD_WARNING; | |
3503 | ||
8cdabf90 SK |
3504 | /* |
3505 | * If 'neighbor <interface>', then this is for directly connected peers, | |
3506 | * we should not accept disable-connected-check. | |
3507 | */ | |
3508 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
3509 | vty_out (vty, "%s is directly connected peer, cannot accept disable-" | |
3510 | "connected-check%s", ip_str, VTY_NEWLINE); | |
3511 | return CMD_WARNING; | |
3512 | } | |
3513 | ||
ae9b0e11 DS |
3514 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
3515 | peer_tx_shutdown_message_unset (peer); | |
3516 | ||
718e3744 | 3517 | if (set) |
3518 | ret = peer_flag_set (peer, flag); | |
3519 | else | |
3520 | ret = peer_flag_unset (peer, flag); | |
3521 | ||
3522 | return bgp_vty_return (vty, ret); | |
3523 | } | |
3524 | ||
94f2b392 | 3525 | static int |
fd79ac91 | 3526 | peer_flag_set_vty (struct vty *vty, const char *ip_str, u_int16_t flag) |
718e3744 | 3527 | { |
3528 | return peer_flag_modify_vty (vty, ip_str, flag, 1); | |
3529 | } | |
3530 | ||
94f2b392 | 3531 | static int |
fd79ac91 | 3532 | peer_flag_unset_vty (struct vty *vty, const char *ip_str, u_int16_t flag) |
718e3744 | 3533 | { |
3534 | return peer_flag_modify_vty (vty, ip_str, flag, 0); | |
3535 | } | |
3536 | ||
3537 | /* neighbor passive. */ | |
3538 | DEFUN (neighbor_passive, | |
3539 | neighbor_passive_cmd, | |
9ccf14f7 | 3540 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3541 | NEIGHBOR_STR |
3542 | NEIGHBOR_ADDR_STR2 | |
3543 | "Don't send open messages to this neighbor\n") | |
3544 | { | |
c500ae40 DW |
3545 | int idx_peer = 1; |
3546 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3547 | } |
3548 | ||
3549 | DEFUN (no_neighbor_passive, | |
3550 | no_neighbor_passive_cmd, | |
9ccf14f7 | 3551 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3552 | NO_STR |
3553 | NEIGHBOR_STR | |
3554 | NEIGHBOR_ADDR_STR2 | |
3555 | "Don't send open messages to this neighbor\n") | |
3556 | { | |
c500ae40 DW |
3557 | int idx_peer = 2; |
3558 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3559 | } |
6b0655a2 | 3560 | |
718e3744 | 3561 | /* neighbor shutdown. */ |
73d70fa6 DL |
3562 | DEFUN (neighbor_shutdown_msg, |
3563 | neighbor_shutdown_msg_cmd, | |
3564 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
718e3744 | 3565 | NEIGHBOR_STR |
3566 | NEIGHBOR_ADDR_STR2 | |
73d70fa6 DL |
3567 | "Administratively shut down this neighbor\n" |
3568 | "Add a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3569 | "Shutdown message\n") | |
718e3744 | 3570 | { |
c500ae40 | 3571 | int idx_peer = 1; |
73d70fa6 DL |
3572 | |
3573 | if (argc >= 5) | |
3574 | { | |
ae9b0e11 | 3575 | struct peer *peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
73d70fa6 DL |
3576 | char *message; |
3577 | ||
ae9b0e11 DS |
3578 | if (!peer) |
3579 | return CMD_WARNING; | |
73d70fa6 DL |
3580 | message = argv_concat (argv, argc, 4); |
3581 | peer_tx_shutdown_message_set (peer, message); | |
3582 | XFREE (MTYPE_TMP, message); | |
3583 | } | |
3584 | ||
c500ae40 | 3585 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 3586 | } |
3587 | ||
73d70fa6 DL |
3588 | ALIAS (neighbor_shutdown_msg, |
3589 | neighbor_shutdown_cmd, | |
3590 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
718e3744 | 3591 | NEIGHBOR_STR |
3592 | NEIGHBOR_ADDR_STR2 | |
3593 | "Administratively shut down this neighbor\n") | |
73d70fa6 DL |
3594 | |
3595 | DEFUN (no_neighbor_shutdown_msg, | |
3596 | no_neighbor_shutdown_msg_cmd, | |
3597 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
3598 | NO_STR | |
3599 | NEIGHBOR_STR | |
3600 | NEIGHBOR_ADDR_STR2 | |
3601 | "Administratively shut down this neighbor\n" | |
3602 | "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3603 | "Shutdown message\n") | |
718e3744 | 3604 | { |
c500ae40 | 3605 | int idx_peer = 2; |
73d70fa6 | 3606 | |
c500ae40 | 3607 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 3608 | } |
6b0655a2 | 3609 | |
73d70fa6 DL |
3610 | ALIAS (no_neighbor_shutdown_msg, |
3611 | no_neighbor_shutdown_cmd, | |
3612 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3613 | NO_STR | |
3614 | NEIGHBOR_STR | |
3615 | NEIGHBOR_ADDR_STR2 | |
3616 | "Administratively shut down this neighbor\n") | |
3617 | ||
718e3744 | 3618 | /* neighbor capability dynamic. */ |
3619 | DEFUN (neighbor_capability_dynamic, | |
3620 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3621 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3622 | NEIGHBOR_STR |
3623 | NEIGHBOR_ADDR_STR2 | |
3624 | "Advertise capability to the peer\n" | |
3625 | "Advertise dynamic capability to this neighbor\n") | |
3626 | { | |
c500ae40 DW |
3627 | int idx_peer = 1; |
3628 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3629 | } |
3630 | ||
3631 | DEFUN (no_neighbor_capability_dynamic, | |
3632 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3633 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3634 | NO_STR |
3635 | NEIGHBOR_STR | |
3636 | NEIGHBOR_ADDR_STR2 | |
3637 | "Advertise capability to the peer\n" | |
3638 | "Advertise dynamic capability to this neighbor\n") | |
3639 | { | |
c500ae40 DW |
3640 | int idx_peer = 2; |
3641 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3642 | } |
6b0655a2 | 3643 | |
718e3744 | 3644 | /* neighbor dont-capability-negotiate */ |
3645 | DEFUN (neighbor_dont_capability_negotiate, | |
3646 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3647 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3648 | NEIGHBOR_STR |
3649 | NEIGHBOR_ADDR_STR2 | |
3650 | "Do not perform capability negotiation\n") | |
3651 | { | |
c500ae40 DW |
3652 | int idx_peer = 1; |
3653 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3654 | } |
3655 | ||
3656 | DEFUN (no_neighbor_dont_capability_negotiate, | |
3657 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3658 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3659 | NO_STR |
3660 | NEIGHBOR_STR | |
3661 | NEIGHBOR_ADDR_STR2 | |
3662 | "Do not perform capability negotiation\n") | |
3663 | { | |
c500ae40 DW |
3664 | int idx_peer = 2; |
3665 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3666 | } |
6b0655a2 | 3667 | |
8a92a8a0 DS |
3668 | /* neighbor capability extended next hop encoding */ |
3669 | DEFUN (neighbor_capability_enhe, | |
3670 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3671 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3672 | NEIGHBOR_STR |
3673 | NEIGHBOR_ADDR_STR2 | |
3674 | "Advertise capability to the peer\n" | |
3675 | "Advertise extended next-hop capability to the peer\n") | |
3676 | { | |
c500ae40 DW |
3677 | int idx_peer = 1; |
3678 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3679 | } |
3680 | ||
3681 | DEFUN (no_neighbor_capability_enhe, | |
3682 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3683 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3684 | NO_STR |
3685 | NEIGHBOR_STR | |
3686 | NEIGHBOR_ADDR_STR2 | |
3687 | "Advertise capability to the peer\n" | |
3688 | "Advertise extended next-hop capability to the peer\n") | |
3689 | { | |
c500ae40 DW |
3690 | int idx_peer = 2; |
3691 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3692 | } |
3693 | ||
94f2b392 | 3694 | static int |
fd79ac91 | 3695 | peer_af_flag_modify_vty (struct vty *vty, const char *peer_str, afi_t afi, |
fee0f4c6 | 3696 | safi_t safi, u_int32_t flag, int set) |
718e3744 | 3697 | { |
3698 | int ret; | |
3699 | struct peer *peer; | |
3700 | ||
3701 | peer = peer_and_group_lookup_vty (vty, peer_str); | |
3702 | if (! peer) | |
3703 | return CMD_WARNING; | |
3704 | ||
3705 | if (set) | |
3706 | ret = peer_af_flag_set (peer, afi, safi, flag); | |
3707 | else | |
3708 | ret = peer_af_flag_unset (peer, afi, safi, flag); | |
3709 | ||
3710 | return bgp_vty_return (vty, ret); | |
3711 | } | |
3712 | ||
94f2b392 | 3713 | static int |
fd79ac91 | 3714 | peer_af_flag_set_vty (struct vty *vty, const char *peer_str, afi_t afi, |
fee0f4c6 | 3715 | safi_t safi, u_int32_t flag) |
718e3744 | 3716 | { |
3717 | return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 1); | |
3718 | } | |
3719 | ||
94f2b392 | 3720 | static int |
fd79ac91 | 3721 | peer_af_flag_unset_vty (struct vty *vty, const char *peer_str, afi_t afi, |
fee0f4c6 | 3722 | safi_t safi, u_int32_t flag) |
718e3744 | 3723 | { |
3724 | return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 0); | |
3725 | } | |
6b0655a2 | 3726 | |
718e3744 | 3727 | /* neighbor capability orf prefix-list. */ |
3728 | DEFUN (neighbor_capability_orf_prefix, | |
3729 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3730 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3731 | NEIGHBOR_STR |
3732 | NEIGHBOR_ADDR_STR2 | |
3733 | "Advertise capability to the peer\n" | |
3734 | "Advertise ORF capability to the peer\n" | |
3735 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3736 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3737 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3738 | "Capability to SEND the ORF to this neighbor\n") | |
3739 | { | |
c500ae40 DW |
3740 | int idx_peer = 1; |
3741 | int idx_send_recv = 5; | |
718e3744 | 3742 | u_int16_t flag = 0; |
3743 | ||
c500ae40 | 3744 | if (strncmp (argv[idx_send_recv]->arg, "s", 1) == 0) |
718e3744 | 3745 | flag = PEER_FLAG_ORF_PREFIX_SM; |
c500ae40 | 3746 | else if (strncmp (argv[idx_send_recv]->arg, "r", 1) == 0) |
718e3744 | 3747 | flag = PEER_FLAG_ORF_PREFIX_RM; |
c500ae40 | 3748 | else if (strncmp (argv[idx_send_recv]->arg, "b", 1) == 0) |
718e3744 | 3749 | flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM; |
3750 | else | |
3751 | return CMD_WARNING; | |
3752 | ||
c500ae40 | 3753 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 3754 | bgp_node_safi (vty), flag); |
3755 | } | |
3756 | ||
596c17ba DW |
3757 | ALIAS_HIDDEN (neighbor_capability_orf_prefix, |
3758 | neighbor_capability_orf_prefix_hidden_cmd, | |
3759 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3760 | NEIGHBOR_STR | |
3761 | NEIGHBOR_ADDR_STR2 | |
3762 | "Advertise capability to the peer\n" | |
3763 | "Advertise ORF capability to the peer\n" | |
3764 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3765 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3766 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3767 | "Capability to SEND the ORF to this neighbor\n") | |
3768 | ||
718e3744 | 3769 | DEFUN (no_neighbor_capability_orf_prefix, |
3770 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3771 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3772 | NO_STR |
3773 | NEIGHBOR_STR | |
3774 | NEIGHBOR_ADDR_STR2 | |
3775 | "Advertise capability to the peer\n" | |
3776 | "Advertise ORF capability to the peer\n" | |
3777 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3778 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3779 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3780 | "Capability to SEND the ORF to this neighbor\n") | |
3781 | { | |
c500ae40 DW |
3782 | int idx_peer = 2; |
3783 | int idx_send_recv = 6; | |
718e3744 | 3784 | u_int16_t flag = 0; |
3785 | ||
c500ae40 | 3786 | if (strncmp (argv[idx_send_recv]->arg, "s", 1) == 0) |
718e3744 | 3787 | flag = PEER_FLAG_ORF_PREFIX_SM; |
c500ae40 | 3788 | else if (strncmp (argv[idx_send_recv]->arg, "r", 1) == 0) |
718e3744 | 3789 | flag = PEER_FLAG_ORF_PREFIX_RM; |
c500ae40 | 3790 | else if (strncmp (argv[idx_send_recv]->arg, "b", 1) == 0) |
718e3744 | 3791 | flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM; |
3792 | else | |
3793 | return CMD_WARNING; | |
3794 | ||
c500ae40 | 3795 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 3796 | bgp_node_safi (vty), flag); |
3797 | } | |
6b0655a2 | 3798 | |
596c17ba DW |
3799 | ALIAS_HIDDEN (no_neighbor_capability_orf_prefix, |
3800 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
3801 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3802 | NO_STR | |
3803 | NEIGHBOR_STR | |
3804 | NEIGHBOR_ADDR_STR2 | |
3805 | "Advertise capability to the peer\n" | |
3806 | "Advertise ORF capability to the peer\n" | |
3807 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3808 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3809 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3810 | "Capability to SEND the ORF to this neighbor\n") | |
3811 | ||
718e3744 | 3812 | /* neighbor next-hop-self. */ |
3813 | DEFUN (neighbor_nexthop_self, | |
3814 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3815 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3816 | NEIGHBOR_STR |
3817 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3818 | "Disable the next hop calculation for this neighbor\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), | |
a538debe DS |
3822 | bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF); |
3823 | } | |
9e7a53c1 | 3824 | |
596c17ba DW |
3825 | ALIAS_HIDDEN (neighbor_nexthop_self, |
3826 | neighbor_nexthop_self_hidden_cmd, | |
3827 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3828 | NEIGHBOR_STR | |
3829 | NEIGHBOR_ADDR_STR2 | |
3830 | "Disable the next hop calculation for this neighbor\n") | |
3831 | ||
a538debe DS |
3832 | /* neighbor next-hop-self. */ |
3833 | DEFUN (neighbor_nexthop_self_force, | |
3834 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 3835 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3836 | NEIGHBOR_STR |
3837 | NEIGHBOR_ADDR_STR2 | |
3838 | "Disable the next hop calculation for this neighbor\n" | |
3839 | "Set the next hop to self for reflected routes\n") | |
3840 | { | |
c500ae40 DW |
3841 | int idx_peer = 1; |
3842 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
a538debe | 3843 | bgp_node_safi (vty), |
88b8ed8d | 3844 | PEER_FLAG_FORCE_NEXTHOP_SELF); |
718e3744 | 3845 | } |
3846 | ||
596c17ba DW |
3847 | ALIAS_HIDDEN (neighbor_nexthop_self_force, |
3848 | neighbor_nexthop_self_force_hidden_cmd, | |
3849 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3850 | NEIGHBOR_STR | |
3851 | NEIGHBOR_ADDR_STR2 | |
3852 | "Disable the next hop calculation for this neighbor\n" | |
3853 | "Set the next hop to self for reflected routes\n") | |
3854 | ||
718e3744 | 3855 | DEFUN (no_neighbor_nexthop_self, |
3856 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3857 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3858 | NO_STR |
3859 | NEIGHBOR_STR | |
3860 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3861 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3862 | { |
c500ae40 DW |
3863 | int idx_peer = 2; |
3864 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
9e7a53c1 | 3865 | bgp_node_safi (vty), |
88b8ed8d | 3866 | PEER_FLAG_NEXTHOP_SELF); |
718e3744 | 3867 | } |
6b0655a2 | 3868 | |
596c17ba DW |
3869 | ALIAS_HIDDEN (no_neighbor_nexthop_self, |
3870 | no_neighbor_nexthop_self_hidden_cmd, | |
3871 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3872 | NO_STR | |
3873 | NEIGHBOR_STR | |
3874 | NEIGHBOR_ADDR_STR2 | |
3875 | "Disable the next hop calculation for this neighbor\n") | |
3876 | ||
88b8ed8d | 3877 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 3878 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 3879 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3880 | NO_STR |
3881 | NEIGHBOR_STR | |
3882 | NEIGHBOR_ADDR_STR2 | |
3883 | "Disable the next hop calculation for this neighbor\n" | |
3884 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 3885 | { |
c500ae40 DW |
3886 | int idx_peer = 2; |
3887 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
3888 | bgp_node_safi (vty), |
3889 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
3890 | } | |
a538debe | 3891 | |
596c17ba DW |
3892 | ALIAS_HIDDEN (no_neighbor_nexthop_self_force, |
3893 | no_neighbor_nexthop_self_force_hidden_cmd, | |
3894 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3895 | NO_STR | |
3896 | NEIGHBOR_STR | |
3897 | NEIGHBOR_ADDR_STR2 | |
3898 | "Disable the next hop calculation for this neighbor\n" | |
3899 | "Set the next hop to self for reflected routes\n") | |
3900 | ||
c7122e14 DS |
3901 | /* neighbor as-override */ |
3902 | DEFUN (neighbor_as_override, | |
3903 | neighbor_as_override_cmd, | |
9ccf14f7 | 3904 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3905 | NEIGHBOR_STR |
3906 | NEIGHBOR_ADDR_STR2 | |
3907 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3908 | { | |
c500ae40 DW |
3909 | int idx_peer = 1; |
3910 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
c7122e14 DS |
3911 | bgp_node_safi (vty), |
3912 | PEER_FLAG_AS_OVERRIDE); | |
3913 | } | |
3914 | ||
596c17ba DW |
3915 | ALIAS_HIDDEN (neighbor_as_override, |
3916 | neighbor_as_override_hidden_cmd, | |
3917 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
3918 | NEIGHBOR_STR | |
3919 | NEIGHBOR_ADDR_STR2 | |
3920 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3921 | ||
c7122e14 DS |
3922 | DEFUN (no_neighbor_as_override, |
3923 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 3924 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3925 | NO_STR |
3926 | NEIGHBOR_STR | |
3927 | NEIGHBOR_ADDR_STR2 | |
3928 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3929 | { | |
c500ae40 DW |
3930 | int idx_peer = 2; |
3931 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
c7122e14 DS |
3932 | bgp_node_safi (vty), |
3933 | PEER_FLAG_AS_OVERRIDE); | |
3934 | } | |
3935 | ||
596c17ba DW |
3936 | ALIAS_HIDDEN (no_neighbor_as_override, |
3937 | no_neighbor_as_override_hidden_cmd, | |
3938 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
3939 | NO_STR | |
3940 | NEIGHBOR_STR | |
3941 | NEIGHBOR_ADDR_STR2 | |
3942 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3943 | ||
718e3744 | 3944 | /* neighbor remove-private-AS. */ |
3945 | DEFUN (neighbor_remove_private_as, | |
3946 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3947 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3948 | NEIGHBOR_STR |
3949 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3950 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3951 | { |
c500ae40 DW |
3952 | int idx_peer = 1; |
3953 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3954 | bgp_node_safi (vty), |
3955 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
3956 | } | |
3957 | ||
596c17ba DW |
3958 | ALIAS_HIDDEN (neighbor_remove_private_as, |
3959 | neighbor_remove_private_as_hidden_cmd, | |
3960 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
3961 | NEIGHBOR_STR | |
3962 | NEIGHBOR_ADDR_STR2 | |
3963 | "Remove private ASNs in outbound updates\n") | |
3964 | ||
5000f21c DS |
3965 | DEFUN (neighbor_remove_private_as_all, |
3966 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 3967 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
3968 | NEIGHBOR_STR |
3969 | NEIGHBOR_ADDR_STR2 | |
3970 | "Remove private ASNs in outbound updates\n" | |
3971 | "Apply to all AS numbers") | |
3972 | { | |
c500ae40 DW |
3973 | int idx_peer = 1; |
3974 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5000f21c | 3975 | bgp_node_safi (vty), |
5000f21c DS |
3976 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); |
3977 | } | |
3978 | ||
596c17ba DW |
3979 | ALIAS_HIDDEN (neighbor_remove_private_as_all, |
3980 | neighbor_remove_private_as_all_hidden_cmd, | |
3981 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
3982 | NEIGHBOR_STR | |
3983 | NEIGHBOR_ADDR_STR2 | |
3984 | "Remove private ASNs in outbound updates\n" | |
3985 | "Apply to all AS numbers") | |
3986 | ||
5000f21c DS |
3987 | DEFUN (neighbor_remove_private_as_replace_as, |
3988 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 3989 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
3990 | NEIGHBOR_STR |
3991 | NEIGHBOR_ADDR_STR2 | |
3992 | "Remove private ASNs in outbound updates\n" | |
3993 | "Replace private ASNs with our ASN in outbound updates\n") | |
3994 | { | |
c500ae40 DW |
3995 | int idx_peer = 1; |
3996 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5000f21c | 3997 | bgp_node_safi (vty), |
5000f21c DS |
3998 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); |
3999 | } | |
4000 | ||
596c17ba DW |
4001 | ALIAS_HIDDEN (neighbor_remove_private_as_replace_as, |
4002 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
4003 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4004 | NEIGHBOR_STR | |
4005 | NEIGHBOR_ADDR_STR2 | |
4006 | "Remove private ASNs in outbound updates\n" | |
4007 | "Replace private ASNs with our ASN in outbound updates\n") | |
4008 | ||
5000f21c DS |
4009 | DEFUN (neighbor_remove_private_as_all_replace_as, |
4010 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 4011 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4012 | NEIGHBOR_STR |
4013 | NEIGHBOR_ADDR_STR2 | |
4014 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4015 | "Apply to all AS numbers\n" |
5000f21c DS |
4016 | "Replace private ASNs with our ASN in outbound updates\n") |
4017 | { | |
c500ae40 DW |
4018 | int idx_peer = 1; |
4019 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5000f21c | 4020 | bgp_node_safi (vty), |
88b8ed8d | 4021 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); |
5000f21c DS |
4022 | } |
4023 | ||
596c17ba DW |
4024 | ALIAS_HIDDEN (neighbor_remove_private_as_all_replace_as, |
4025 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4026 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4027 | NEIGHBOR_STR | |
4028 | NEIGHBOR_ADDR_STR2 | |
4029 | "Remove private ASNs in outbound updates\n" | |
4030 | "Apply to all AS numbers\n" | |
4031 | "Replace private ASNs with our ASN in outbound updates\n") | |
4032 | ||
718e3744 | 4033 | DEFUN (no_neighbor_remove_private_as, |
4034 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4035 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4036 | NO_STR |
4037 | NEIGHBOR_STR | |
4038 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4039 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4040 | { |
c500ae40 DW |
4041 | int idx_peer = 2; |
4042 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4043 | bgp_node_safi (vty), |
88b8ed8d | 4044 | PEER_FLAG_REMOVE_PRIVATE_AS); |
718e3744 | 4045 | } |
6b0655a2 | 4046 | |
596c17ba DW |
4047 | ALIAS_HIDDEN (no_neighbor_remove_private_as, |
4048 | no_neighbor_remove_private_as_hidden_cmd, | |
4049 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4050 | NO_STR | |
4051 | NEIGHBOR_STR | |
4052 | NEIGHBOR_ADDR_STR2 | |
4053 | "Remove private ASNs in outbound updates\n") | |
4054 | ||
88b8ed8d | 4055 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 4056 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 4057 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4058 | NO_STR |
4059 | NEIGHBOR_STR | |
4060 | NEIGHBOR_ADDR_STR2 | |
4061 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4062 | "Apply to all AS numbers\n") |
88b8ed8d | 4063 | { |
c500ae40 DW |
4064 | int idx_peer = 2; |
4065 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
4066 | bgp_node_safi (vty), |
4067 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
4068 | } | |
5000f21c | 4069 | |
596c17ba DW |
4070 | ALIAS_HIDDEN (no_neighbor_remove_private_as_all, |
4071 | no_neighbor_remove_private_as_all_hidden_cmd, | |
4072 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4073 | NO_STR | |
4074 | NEIGHBOR_STR | |
4075 | NEIGHBOR_ADDR_STR2 | |
4076 | "Remove private ASNs in outbound updates\n" | |
4077 | "Apply to all AS numbers\n") | |
4078 | ||
88b8ed8d | 4079 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 4080 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 4081 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4082 | NO_STR |
4083 | NEIGHBOR_STR | |
4084 | NEIGHBOR_ADDR_STR2 | |
4085 | "Remove private ASNs in outbound updates\n" | |
4086 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 4087 | { |
c500ae40 DW |
4088 | int idx_peer = 2; |
4089 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
4090 | bgp_node_safi (vty), |
4091 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
4092 | } | |
5000f21c | 4093 | |
596c17ba DW |
4094 | ALIAS_HIDDEN (no_neighbor_remove_private_as_replace_as, |
4095 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
4096 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4097 | NO_STR | |
4098 | NEIGHBOR_STR | |
4099 | NEIGHBOR_ADDR_STR2 | |
4100 | "Remove private ASNs in outbound updates\n" | |
4101 | "Replace private ASNs with our ASN in outbound updates\n") | |
4102 | ||
88b8ed8d | 4103 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 4104 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 4105 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4106 | NO_STR |
4107 | NEIGHBOR_STR | |
4108 | NEIGHBOR_ADDR_STR2 | |
4109 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4110 | "Apply to all AS numbers\n" |
5000f21c | 4111 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 4112 | { |
c500ae40 DW |
4113 | int idx_peer = 2; |
4114 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
4115 | bgp_node_safi (vty), |
4116 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
4117 | } | |
5000f21c | 4118 | |
596c17ba DW |
4119 | ALIAS_HIDDEN (no_neighbor_remove_private_as_all_replace_as, |
4120 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4121 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4122 | NO_STR | |
4123 | NEIGHBOR_STR | |
4124 | NEIGHBOR_ADDR_STR2 | |
4125 | "Remove private ASNs in outbound updates\n" | |
4126 | "Apply to all AS numbers\n" | |
4127 | "Replace private ASNs with our ASN in outbound updates\n") | |
4128 | ||
5000f21c | 4129 | |
718e3744 | 4130 | /* neighbor send-community. */ |
4131 | DEFUN (neighbor_send_community, | |
4132 | neighbor_send_community_cmd, | |
9ccf14f7 | 4133 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4134 | NEIGHBOR_STR |
4135 | NEIGHBOR_ADDR_STR2 | |
4136 | "Send Community attribute to this neighbor\n") | |
4137 | { | |
c500ae40 DW |
4138 | int idx_peer = 1; |
4139 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4140 | bgp_node_safi (vty), |
4141 | PEER_FLAG_SEND_COMMUNITY); | |
4142 | } | |
4143 | ||
596c17ba DW |
4144 | ALIAS_HIDDEN (neighbor_send_community, |
4145 | neighbor_send_community_hidden_cmd, | |
4146 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4147 | NEIGHBOR_STR | |
4148 | NEIGHBOR_ADDR_STR2 | |
4149 | "Send Community attribute to this neighbor\n") | |
4150 | ||
718e3744 | 4151 | DEFUN (no_neighbor_send_community, |
4152 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 4153 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4154 | NO_STR |
4155 | NEIGHBOR_STR | |
4156 | NEIGHBOR_ADDR_STR2 | |
4157 | "Send Community attribute to this neighbor\n") | |
4158 | { | |
c500ae40 DW |
4159 | int idx_peer = 2; |
4160 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4161 | bgp_node_safi (vty), |
4162 | PEER_FLAG_SEND_COMMUNITY); | |
4163 | } | |
6b0655a2 | 4164 | |
596c17ba DW |
4165 | ALIAS_HIDDEN (no_neighbor_send_community, |
4166 | no_neighbor_send_community_hidden_cmd, | |
4167 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4168 | NO_STR | |
4169 | NEIGHBOR_STR | |
4170 | NEIGHBOR_ADDR_STR2 | |
4171 | "Send Community attribute to this neighbor\n") | |
4172 | ||
718e3744 | 4173 | /* neighbor send-community extended. */ |
4174 | DEFUN (neighbor_send_community_type, | |
4175 | neighbor_send_community_type_cmd, | |
57d187bc | 4176 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4177 | NEIGHBOR_STR |
4178 | NEIGHBOR_ADDR_STR2 | |
4179 | "Send Community attribute to this neighbor\n" | |
4180 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4181 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4182 | "Send Extended Community attributes\n" |
57d187bc JS |
4183 | "Send Standard Community attributes\n" |
4184 | "Send Large Community attributes\n") | |
718e3744 | 4185 | { |
4c4ff4c1 QY |
4186 | int idx = 0; |
4187 | u_int32_t flag = 0; | |
718e3744 | 4188 | |
4c4ff4c1 QY |
4189 | char *peer = argv[1]->arg; |
4190 | ||
4191 | if (argv_find (argv, argc, "standard", &idx)) | |
4192 | SET_FLAG (flag, PEER_FLAG_SEND_COMMUNITY); | |
4193 | else if (argv_find (argv, argc, "extended", &idx)) | |
4194 | SET_FLAG (flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
57d187bc JS |
4195 | else if (argv_find (argv, argc, "large", &idx)) |
4196 | SET_FLAG (flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4197 | else if (argv_find (argv, argc, "both", &idx)) | |
4198 | { | |
4199 | SET_FLAG (flag, PEER_FLAG_SEND_COMMUNITY); | |
4200 | SET_FLAG (flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4201 | } | |
4c4ff4c1 | 4202 | else |
57d187bc JS |
4203 | { |
4204 | SET_FLAG (flag, PEER_FLAG_SEND_COMMUNITY); | |
4205 | SET_FLAG (flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4206 | SET_FLAG (flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4207 | } | |
4c4ff4c1 QY |
4208 | |
4209 | return peer_af_flag_set_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flag); | |
718e3744 | 4210 | } |
4211 | ||
596c17ba DW |
4212 | ALIAS_HIDDEN (neighbor_send_community_type, |
4213 | neighbor_send_community_type_hidden_cmd, | |
4214 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4215 | NEIGHBOR_STR | |
4216 | NEIGHBOR_ADDR_STR2 | |
4217 | "Send Community attribute to this neighbor\n" | |
4218 | "Send Standard and Extended Community attributes\n" | |
4219 | "Send Standard, Large and Extended Community attributes\n" | |
4220 | "Send Extended Community attributes\n" | |
4221 | "Send Standard Community attributes\n" | |
4222 | "Send Large Community attributes\n") | |
4223 | ||
718e3744 | 4224 | DEFUN (no_neighbor_send_community_type, |
4225 | no_neighbor_send_community_type_cmd, | |
57d187bc | 4226 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4227 | NO_STR |
4228 | NEIGHBOR_STR | |
4229 | NEIGHBOR_ADDR_STR2 | |
4230 | "Send Community attribute to this neighbor\n" | |
4231 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4232 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4233 | "Send Extended Community attributes\n" |
57d187bc JS |
4234 | "Send Standard Community attributes\n" |
4235 | "Send Large Community attributes\n") | |
718e3744 | 4236 | { |
c500ae40 DW |
4237 | int idx_peer = 2; |
4238 | int idx_type = 4; | |
4239 | if (strncmp (argv[idx_type]->arg, "s", 1) == 0) | |
4240 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4241 | bgp_node_safi (vty), |
4242 | PEER_FLAG_SEND_COMMUNITY); | |
c500ae40 DW |
4243 | if (strncmp (argv[idx_type]->arg, "e", 1) == 0) |
4244 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4245 | bgp_node_safi (vty), |
4246 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
57d187bc JS |
4247 | if (strncmp (argv[idx_type]->arg, "l", 1) == 0) |
4248 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4249 | bgp_node_safi (vty), | |
4250 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4251 | if (strncmp (argv[idx_type]->arg, "b", 1) == 0) | |
4252 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4253 | bgp_node_safi (vty), | |
4254 | PEER_FLAG_SEND_COMMUNITY | | |
4255 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
718e3744 | 4256 | |
c500ae40 | 4257 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 4258 | bgp_node_safi (vty), |
4259 | (PEER_FLAG_SEND_COMMUNITY | | |
57d187bc JS |
4260 | PEER_FLAG_SEND_EXT_COMMUNITY| |
4261 | PEER_FLAG_SEND_LARGE_COMMUNITY)); | |
718e3744 | 4262 | } |
6b0655a2 | 4263 | |
596c17ba DW |
4264 | ALIAS_HIDDEN (no_neighbor_send_community_type, |
4265 | no_neighbor_send_community_type_hidden_cmd, | |
4266 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4267 | NO_STR | |
4268 | NEIGHBOR_STR | |
4269 | NEIGHBOR_ADDR_STR2 | |
4270 | "Send Community attribute to this neighbor\n" | |
4271 | "Send Standard and Extended Community attributes\n" | |
4272 | "Send Standard, Large and Extended Community attributes\n" | |
4273 | "Send Extended Community attributes\n" | |
4274 | "Send Standard Community attributes\n" | |
4275 | "Send Large Community attributes\n") | |
4276 | ||
718e3744 | 4277 | /* neighbor soft-reconfig. */ |
4278 | DEFUN (neighbor_soft_reconfiguration, | |
4279 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4280 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4281 | NEIGHBOR_STR |
4282 | NEIGHBOR_ADDR_STR2 | |
4283 | "Per neighbor soft reconfiguration\n" | |
4284 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4285 | { | |
c500ae40 DW |
4286 | int idx_peer = 1; |
4287 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, | |
718e3744 | 4288 | bgp_node_afi (vty), bgp_node_safi (vty), |
4289 | PEER_FLAG_SOFT_RECONFIG); | |
4290 | } | |
4291 | ||
596c17ba DW |
4292 | ALIAS_HIDDEN (neighbor_soft_reconfiguration, |
4293 | neighbor_soft_reconfiguration_hidden_cmd, | |
4294 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4295 | NEIGHBOR_STR | |
4296 | NEIGHBOR_ADDR_STR2 | |
4297 | "Per neighbor soft reconfiguration\n" | |
4298 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4299 | ||
718e3744 | 4300 | DEFUN (no_neighbor_soft_reconfiguration, |
4301 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4302 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4303 | NO_STR |
4304 | NEIGHBOR_STR | |
4305 | NEIGHBOR_ADDR_STR2 | |
4306 | "Per neighbor soft reconfiguration\n" | |
4307 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4308 | { | |
c500ae40 DW |
4309 | int idx_peer = 2; |
4310 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, | |
718e3744 | 4311 | bgp_node_afi (vty), bgp_node_safi (vty), |
4312 | PEER_FLAG_SOFT_RECONFIG); | |
4313 | } | |
6b0655a2 | 4314 | |
596c17ba DW |
4315 | ALIAS_HIDDEN (no_neighbor_soft_reconfiguration, |
4316 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
4317 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4318 | NO_STR | |
4319 | NEIGHBOR_STR | |
4320 | NEIGHBOR_ADDR_STR2 | |
4321 | "Per neighbor soft reconfiguration\n" | |
4322 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4323 | ||
718e3744 | 4324 | DEFUN (neighbor_route_reflector_client, |
4325 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4326 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4327 | NEIGHBOR_STR |
4328 | NEIGHBOR_ADDR_STR2 | |
4329 | "Configure a neighbor as Route Reflector client\n") | |
4330 | { | |
c500ae40 | 4331 | int idx_peer = 1; |
718e3744 | 4332 | struct peer *peer; |
4333 | ||
4334 | ||
c500ae40 | 4335 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 4336 | if (! peer) |
4337 | return CMD_WARNING; | |
4338 | ||
c500ae40 | 4339 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 4340 | bgp_node_safi (vty), |
4341 | PEER_FLAG_REFLECTOR_CLIENT); | |
4342 | } | |
4343 | ||
596c17ba DW |
4344 | ALIAS_HIDDEN (neighbor_route_reflector_client, |
4345 | neighbor_route_reflector_client_hidden_cmd, | |
4346 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4347 | NEIGHBOR_STR | |
4348 | NEIGHBOR_ADDR_STR2 | |
4349 | "Configure a neighbor as Route Reflector client\n") | |
4350 | ||
718e3744 | 4351 | DEFUN (no_neighbor_route_reflector_client, |
4352 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4353 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4354 | NO_STR |
4355 | NEIGHBOR_STR | |
4356 | NEIGHBOR_ADDR_STR2 | |
4357 | "Configure a neighbor as Route Reflector client\n") | |
4358 | { | |
c500ae40 DW |
4359 | int idx_peer = 2; |
4360 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4361 | bgp_node_safi (vty), |
4362 | PEER_FLAG_REFLECTOR_CLIENT); | |
4363 | } | |
6b0655a2 | 4364 | |
596c17ba DW |
4365 | ALIAS_HIDDEN (no_neighbor_route_reflector_client, |
4366 | no_neighbor_route_reflector_client_hidden_cmd, | |
4367 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4368 | NO_STR | |
4369 | NEIGHBOR_STR | |
4370 | NEIGHBOR_ADDR_STR2 | |
4371 | "Configure a neighbor as Route Reflector client\n") | |
4372 | ||
718e3744 | 4373 | /* neighbor route-server-client. */ |
4374 | DEFUN (neighbor_route_server_client, | |
4375 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 4376 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4377 | NEIGHBOR_STR |
4378 | NEIGHBOR_ADDR_STR2 | |
4379 | "Configure a neighbor as Route Server client\n") | |
4380 | { | |
c500ae40 | 4381 | int idx_peer = 1; |
2a3d5731 DW |
4382 | struct peer *peer; |
4383 | ||
c500ae40 | 4384 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
2a3d5731 DW |
4385 | if (! peer) |
4386 | return CMD_WARNING; | |
c500ae40 | 4387 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
2a3d5731 DW |
4388 | bgp_node_safi (vty), |
4389 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 4390 | } |
4391 | ||
596c17ba DW |
4392 | ALIAS_HIDDEN (neighbor_route_server_client, |
4393 | neighbor_route_server_client_hidden_cmd, | |
4394 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4395 | NEIGHBOR_STR | |
4396 | NEIGHBOR_ADDR_STR2 | |
4397 | "Configure a neighbor as Route Server client\n") | |
4398 | ||
718e3744 | 4399 | DEFUN (no_neighbor_route_server_client, |
4400 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 4401 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4402 | NO_STR |
4403 | NEIGHBOR_STR | |
4404 | NEIGHBOR_ADDR_STR2 | |
4405 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 4406 | { |
c500ae40 DW |
4407 | int idx_peer = 2; |
4408 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
2a3d5731 DW |
4409 | bgp_node_safi (vty), |
4410 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 4411 | } |
6b0655a2 | 4412 | |
596c17ba DW |
4413 | ALIAS_HIDDEN (no_neighbor_route_server_client, |
4414 | no_neighbor_route_server_client_hidden_cmd, | |
4415 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4416 | NO_STR | |
4417 | NEIGHBOR_STR | |
4418 | NEIGHBOR_ADDR_STR2 | |
4419 | "Configure a neighbor as Route Server client\n") | |
4420 | ||
fee0f4c6 | 4421 | DEFUN (neighbor_nexthop_local_unchanged, |
4422 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4423 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4424 | NEIGHBOR_STR |
4425 | NEIGHBOR_ADDR_STR2 | |
4426 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
4427 | "Leave link-local nexthop unchanged for this peer\n") | |
4428 | { | |
c500ae40 DW |
4429 | int idx_peer = 1; |
4430 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
fee0f4c6 | 4431 | bgp_node_safi (vty), |
4432 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED ); | |
4433 | } | |
6b0655a2 | 4434 | |
fee0f4c6 | 4435 | DEFUN (no_neighbor_nexthop_local_unchanged, |
4436 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4437 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4438 | NO_STR |
4439 | NEIGHBOR_STR | |
4440 | NEIGHBOR_ADDR_STR2 | |
4441 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
4442 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 4443 | { |
c500ae40 DW |
4444 | int idx_peer = 2; |
4445 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4446 | bgp_node_safi (vty), |
fee0f4c6 | 4447 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED ); |
718e3744 | 4448 | } |
6b0655a2 | 4449 | |
718e3744 | 4450 | DEFUN (neighbor_attr_unchanged, |
4451 | neighbor_attr_unchanged_cmd, | |
1084263f QY |
4452 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged\ |
4453 | [<\ | |
ddbaf941 QY |
4454 | as-path [<next-hop [med]|med [next-hop]>]|\ |
4455 | next-hop [<as-path [med]|med [as-path]>]|\ | |
4456 | med [<as-path [next-hop]|next-hop [as-path]>]\ | |
1084263f | 4457 | >]", |
718e3744 | 4458 | NEIGHBOR_STR |
4459 | NEIGHBOR_ADDR_STR2 | |
4460 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4461 | "As-path attribute\n" | |
4462 | "Nexthop attribute\n" | |
40e718b5 | 4463 | "Med attribute\n" |
1084263f QY |
4464 | "Med attribute\n" |
4465 | "Nexthop attribute\n" | |
4466 | "Nexthop attribute\n" | |
4467 | "As-path attribute\n" | |
4468 | "Med attribute\n" | |
40e718b5 | 4469 | "Med attribute\n" |
718e3744 | 4470 | "As-path attribute\n" |
1084263f QY |
4471 | "Med attribute\n" |
4472 | "As-path attribute\n" | |
4473 | "Nexthop attribute\n" | |
40e718b5 | 4474 | "Nexthop attribute\n" |
1084263f | 4475 | "As-path attribute\n") |
718e3744 | 4476 | { |
40e718b5 QY |
4477 | int idx = 0; |
4478 | char *peer = argv[1]->arg; | |
4479 | u_int16_t flags = 0; | |
718e3744 | 4480 | |
40e718b5 | 4481 | if (argv_find (argv, argc, "as-path", &idx)) |
718e3744 | 4482 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
40e718b5 QY |
4483 | idx = 0; |
4484 | if (argv_find (argv, argc, "next-hop", &idx)) | |
4485 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4486 | idx = 0; | |
4487 | if (argv_find (argv, argc, "med", &idx)) | |
718e3744 | 4488 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
4489 | ||
40e718b5 QY |
4490 | if (!flags) // no flags means all of them! |
4491 | { | |
718e3744 | 4492 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
718e3744 | 4493 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); |
40e718b5 QY |
4494 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
4495 | } | |
718e3744 | 4496 | |
40e718b5 | 4497 | return peer_af_flag_set_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flags); |
718e3744 | 4498 | } |
4499 | ||
596c17ba DW |
4500 | ALIAS_HIDDEN (neighbor_attr_unchanged, |
4501 | neighbor_attr_unchanged_hidden_cmd, | |
4502 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged\ | |
4503 | [<\ | |
4504 | as-path [<next-hop [med]|med [next-hop]>]|\ | |
4505 | next-hop [<as-path [med]|med [as-path]>]|\ | |
4506 | med [<as-path [next-hop]|next-hop [as-path]>]\ | |
4507 | >]", | |
4508 | NEIGHBOR_STR | |
4509 | NEIGHBOR_ADDR_STR2 | |
4510 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4511 | "As-path attribute\n" | |
4512 | "Nexthop attribute\n" | |
4513 | "Med attribute\n" | |
4514 | "Med attribute\n" | |
4515 | "Nexthop attribute\n" | |
4516 | "Nexthop attribute\n" | |
4517 | "As-path attribute\n" | |
4518 | "Med attribute\n" | |
4519 | "Med attribute\n" | |
4520 | "As-path attribute\n" | |
4521 | "Med attribute\n" | |
4522 | "As-path attribute\n" | |
4523 | "Nexthop attribute\n" | |
4524 | "Nexthop attribute\n" | |
4525 | "As-path attribute\n") | |
4526 | ||
718e3744 | 4527 | DEFUN (no_neighbor_attr_unchanged, |
4528 | no_neighbor_attr_unchanged_cmd, | |
1084263f QY |
4529 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged\ |
4530 | [<\ | |
ddbaf941 QY |
4531 | as-path [<next-hop [med]|med [next-hop]>]|\ |
4532 | next-hop [<as-path [med]|med [as-path]>]|\ | |
4533 | med [<as-path [next-hop]|next-hop [as-path]>]\ | |
1084263f | 4534 | >]", |
e52702f2 | 4535 | NO_STR |
718e3744 | 4536 | NEIGHBOR_STR |
4537 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
4538 | "BGP attribute is propagated unchanged to this neighbor\n" |
4539 | "As-path attribute\n" | |
40e718b5 | 4540 | "Nexthop attribute\n" |
31500417 | 4541 | "Med attribute\n" |
1084263f QY |
4542 | "Med attribute\n" |
4543 | "Nexthop attribute\n" | |
4544 | "Nexthop attribute\n" | |
4545 | "As-path attribute\n" | |
4546 | "Med attribute\n" | |
40e718b5 | 4547 | "Med attribute\n" |
718e3744 | 4548 | "As-path attribute\n" |
1084263f QY |
4549 | "Med attribute\n" |
4550 | "As-path attribute\n" | |
4551 | "Nexthop attribute\n" | |
718e3744 | 4552 | "Nexthop attribute\n" |
1084263f | 4553 | "As-path attribute\n") |
718e3744 | 4554 | { |
40e718b5 QY |
4555 | int idx = 0; |
4556 | char *peer = argv[2]->arg; | |
4557 | u_int16_t flags = 0; | |
718e3744 | 4558 | |
40e718b5 | 4559 | if (argv_find (argv, argc, "as-path", &idx)) |
718e3744 | 4560 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
40e718b5 QY |
4561 | idx = 0; |
4562 | if (argv_find (argv, argc, "next-hop", &idx)) | |
4563 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4564 | idx = 0; | |
4565 | if (argv_find (argv, argc, "med", &idx)) | |
718e3744 | 4566 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
4567 | ||
40e718b5 QY |
4568 | if (!flags) // no flags means all of them! |
4569 | { | |
718e3744 | 4570 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
718e3744 | 4571 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); |
40e718b5 QY |
4572 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
4573 | } | |
718e3744 | 4574 | |
40e718b5 | 4575 | return peer_af_flag_unset_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flags); |
718e3744 | 4576 | } |
4577 | ||
596c17ba DW |
4578 | ALIAS_HIDDEN (no_neighbor_attr_unchanged, |
4579 | no_neighbor_attr_unchanged_hidden_cmd, | |
4580 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged\ | |
4581 | [<\ | |
4582 | as-path [<next-hop [med]|med [next-hop]>]|\ | |
4583 | next-hop [<as-path [med]|med [as-path]>]|\ | |
4584 | med [<as-path [next-hop]|next-hop [as-path]>]\ | |
4585 | >]", | |
4586 | NO_STR | |
4587 | NEIGHBOR_STR | |
4588 | NEIGHBOR_ADDR_STR2 | |
4589 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4590 | "As-path attribute\n" | |
4591 | "Nexthop attribute\n" | |
4592 | "Med attribute\n" | |
4593 | "Med attribute\n" | |
4594 | "Nexthop attribute\n" | |
4595 | "Nexthop attribute\n" | |
4596 | "As-path attribute\n" | |
4597 | "Med attribute\n" | |
4598 | "Med attribute\n" | |
4599 | "As-path attribute\n" | |
4600 | "Med attribute\n" | |
4601 | "As-path attribute\n" | |
4602 | "Nexthop attribute\n" | |
4603 | "Nexthop attribute\n" | |
4604 | "As-path attribute\n") | |
4605 | ||
718e3744 | 4606 | |
718e3744 | 4607 | /* EBGP multihop configuration. */ |
94f2b392 | 4608 | static int |
e52702f2 | 4609 | peer_ebgp_multihop_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4610 | const char *ttl_str) |
718e3744 | 4611 | { |
4612 | struct peer *peer; | |
fd79ac91 | 4613 | unsigned int ttl; |
718e3744 | 4614 | |
4615 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4616 | if (! peer) | |
4617 | return CMD_WARNING; | |
4618 | ||
63fa10b5 QY |
4619 | if (peer->conf_if) |
4620 | return bgp_vty_return (vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
4621 | ||
718e3744 | 4622 | if (! ttl_str) |
9b1be336 | 4623 | ttl = MAXTTL; |
718e3744 | 4624 | else |
9b1be336 | 4625 | VTY_GET_INTEGER_RANGE ("TTL", ttl, ttl_str, 1, MAXTTL); |
718e3744 | 4626 | |
89b6d1f8 | 4627 | return bgp_vty_return (vty, peer_ebgp_multihop_set (peer, ttl)); |
718e3744 | 4628 | } |
4629 | ||
94f2b392 | 4630 | static int |
e52702f2 | 4631 | peer_ebgp_multihop_unset_vty (struct vty *vty, const char *ip_str) |
718e3744 | 4632 | { |
4633 | struct peer *peer; | |
4634 | ||
4635 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4636 | if (! peer) | |
4637 | return CMD_WARNING; | |
4638 | ||
89b6d1f8 | 4639 | return bgp_vty_return (vty, peer_ebgp_multihop_unset (peer)); |
718e3744 | 4640 | } |
4641 | ||
4642 | /* neighbor ebgp-multihop. */ | |
4643 | DEFUN (neighbor_ebgp_multihop, | |
4644 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 4645 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 4646 | NEIGHBOR_STR |
4647 | NEIGHBOR_ADDR_STR2 | |
4648 | "Allow EBGP neighbors not on directly connected networks\n") | |
4649 | { | |
c500ae40 DW |
4650 | int idx_peer = 1; |
4651 | return peer_ebgp_multihop_set_vty (vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4652 | } |
4653 | ||
4654 | DEFUN (neighbor_ebgp_multihop_ttl, | |
4655 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 4656 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 4657 | NEIGHBOR_STR |
4658 | NEIGHBOR_ADDR_STR2 | |
4659 | "Allow EBGP neighbors not on directly connected networks\n" | |
4660 | "maximum hop count\n") | |
4661 | { | |
c500ae40 DW |
4662 | int idx_peer = 1; |
4663 | int idx_number = 3; | |
4664 | return peer_ebgp_multihop_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg); | |
718e3744 | 4665 | } |
4666 | ||
4667 | DEFUN (no_neighbor_ebgp_multihop, | |
4668 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 4669 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 4670 | NO_STR |
4671 | NEIGHBOR_STR | |
4672 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4673 | "Allow EBGP neighbors not on directly connected networks\n" |
4674 | "maximum hop count\n") | |
718e3744 | 4675 | { |
c500ae40 DW |
4676 | int idx_peer = 2; |
4677 | return peer_ebgp_multihop_unset_vty (vty, argv[idx_peer]->arg); | |
718e3744 | 4678 | } |
4679 | ||
6b0655a2 | 4680 | |
6ffd2079 | 4681 | /* disable-connected-check */ |
4682 | DEFUN (neighbor_disable_connected_check, | |
4683 | neighbor_disable_connected_check_cmd, | |
a636c635 | 4684 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4685 | NEIGHBOR_STR |
4686 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4687 | "one-hop away EBGP peer using loopback address\n" |
4688 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4689 | { |
c500ae40 DW |
4690 | int idx_peer = 1; |
4691 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4692 | } |
4693 | ||
4694 | DEFUN (no_neighbor_disable_connected_check, | |
4695 | no_neighbor_disable_connected_check_cmd, | |
a636c635 | 4696 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4697 | NO_STR |
4698 | NEIGHBOR_STR | |
4699 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4700 | "one-hop away EBGP peer using loopback address\n" |
4701 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4702 | { |
c500ae40 DW |
4703 | int idx_peer = 2; |
4704 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4705 | } |
4706 | ||
718e3744 | 4707 | DEFUN (neighbor_description, |
4708 | neighbor_description_cmd, | |
e961923c | 4709 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 4710 | NEIGHBOR_STR |
4711 | NEIGHBOR_ADDR_STR2 | |
4712 | "Neighbor specific description\n" | |
4713 | "Up to 80 characters describing this neighbor\n") | |
4714 | { | |
c500ae40 | 4715 | int idx_peer = 1; |
58749582 | 4716 | int idx_line = 3; |
718e3744 | 4717 | struct peer *peer; |
718e3744 | 4718 | char *str; |
718e3744 | 4719 | |
c500ae40 | 4720 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 4721 | if (! peer) |
4722 | return CMD_WARNING; | |
4723 | ||
58749582 | 4724 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 4725 | |
4726 | peer_description_set (peer, str); | |
4727 | ||
3b8b1855 | 4728 | XFREE (MTYPE_TMP, str); |
718e3744 | 4729 | |
4730 | return CMD_SUCCESS; | |
4731 | } | |
4732 | ||
4733 | DEFUN (no_neighbor_description, | |
4734 | no_neighbor_description_cmd, | |
a636c635 | 4735 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description [LINE]", |
718e3744 | 4736 | NO_STR |
4737 | NEIGHBOR_STR | |
4738 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4739 | "Neighbor specific description\n" |
4740 | "Up to 80 characters describing this neighbor\n") | |
718e3744 | 4741 | { |
c500ae40 | 4742 | int idx_peer = 2; |
718e3744 | 4743 | struct peer *peer; |
4744 | ||
c500ae40 | 4745 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 4746 | if (! peer) |
4747 | return CMD_WARNING; | |
4748 | ||
4749 | peer_description_unset (peer); | |
4750 | ||
4751 | return CMD_SUCCESS; | |
4752 | } | |
4753 | ||
6b0655a2 | 4754 | |
718e3744 | 4755 | /* Neighbor update-source. */ |
94f2b392 | 4756 | static int |
e52702f2 | 4757 | peer_update_source_vty (struct vty *vty, const char *peer_str, |
fd79ac91 | 4758 | const char *source_str) |
718e3744 | 4759 | { |
4760 | struct peer *peer; | |
3b69fd51 | 4761 | struct prefix p; |
718e3744 | 4762 | |
4763 | peer = peer_and_group_lookup_vty (vty, peer_str); | |
4764 | if (! peer) | |
4765 | return CMD_WARNING; | |
4766 | ||
a80beece DS |
4767 | if (peer->conf_if) |
4768 | return CMD_WARNING; | |
4769 | ||
718e3744 | 4770 | if (source_str) |
4771 | { | |
c63b83fe JBD |
4772 | union sockunion su; |
4773 | int ret = str2sockunion (source_str, &su); | |
4774 | ||
4775 | if (ret == 0) | |
4776 | peer_update_source_addr_set (peer, &su); | |
718e3744 | 4777 | else |
3b69fd51 DS |
4778 | { |
4779 | if (str2prefix (source_str, &p)) | |
4780 | { | |
4781 | vty_out (vty, "%% Invalid update-source, remove prefix length %s", | |
4782 | VTY_NEWLINE); | |
4783 | return CMD_WARNING; | |
4784 | } | |
4785 | else | |
4786 | peer_update_source_if_set (peer, source_str); | |
4787 | } | |
718e3744 | 4788 | } |
4789 | else | |
4790 | peer_update_source_unset (peer); | |
4791 | ||
4792 | return CMD_SUCCESS; | |
4793 | } | |
4794 | ||
369688c0 PJ |
4795 | #define BGP_UPDATE_SOURCE_HELP_STR \ |
4796 | "IPv4 address\n" \ | |
9a1a331d PJ |
4797 | "IPv6 address\n" \ |
4798 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 4799 | |
718e3744 | 4800 | DEFUN (neighbor_update_source, |
4801 | neighbor_update_source_cmd, | |
9ccf14f7 | 4802 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 4803 | NEIGHBOR_STR |
4804 | NEIGHBOR_ADDR_STR2 | |
4805 | "Source of routing updates\n" | |
369688c0 | 4806 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 4807 | { |
c500ae40 DW |
4808 | int idx_peer = 1; |
4809 | int idx_peer_2 = 3; | |
4810 | return peer_update_source_vty (vty, argv[idx_peer]->arg, argv[idx_peer_2]->arg); | |
718e3744 | 4811 | } |
4812 | ||
4813 | DEFUN (no_neighbor_update_source, | |
4814 | no_neighbor_update_source_cmd, | |
c7178fe7 | 4815 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 4816 | NO_STR |
4817 | NEIGHBOR_STR | |
4818 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
4819 | "Source of routing updates\n" |
4820 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 4821 | { |
c500ae40 DW |
4822 | int idx_peer = 2; |
4823 | return peer_update_source_vty (vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4824 | } |
6b0655a2 | 4825 | |
94f2b392 | 4826 | static int |
e52702f2 QY |
4827 | peer_default_originate_set_vty (struct vty *vty, const char *peer_str, |
4828 | afi_t afi, safi_t safi, | |
fd79ac91 | 4829 | const char *rmap, int set) |
718e3744 | 4830 | { |
4831 | int ret; | |
4832 | struct peer *peer; | |
4833 | ||
4834 | peer = peer_and_group_lookup_vty (vty, peer_str); | |
4835 | if (! peer) | |
4836 | return CMD_WARNING; | |
4837 | ||
4838 | if (set) | |
4839 | ret = peer_default_originate_set (peer, afi, safi, rmap); | |
4840 | else | |
4841 | ret = peer_default_originate_unset (peer, afi, safi); | |
4842 | ||
4843 | return bgp_vty_return (vty, ret); | |
4844 | } | |
4845 | ||
4846 | /* neighbor default-originate. */ | |
4847 | DEFUN (neighbor_default_originate, | |
4848 | neighbor_default_originate_cmd, | |
9ccf14f7 | 4849 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 4850 | NEIGHBOR_STR |
4851 | NEIGHBOR_ADDR_STR2 | |
4852 | "Originate default route to this neighbor\n") | |
4853 | { | |
c500ae40 DW |
4854 | int idx_peer = 1; |
4855 | return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4856 | bgp_node_safi (vty), NULL, 1); |
4857 | } | |
4858 | ||
596c17ba DW |
4859 | ALIAS_HIDDEN (neighbor_default_originate, |
4860 | neighbor_default_originate_hidden_cmd, | |
4861 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
4862 | NEIGHBOR_STR | |
4863 | NEIGHBOR_ADDR_STR2 | |
4864 | "Originate default route to this neighbor\n") | |
4865 | ||
718e3744 | 4866 | DEFUN (neighbor_default_originate_rmap, |
4867 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 4868 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 4869 | NEIGHBOR_STR |
4870 | NEIGHBOR_ADDR_STR2 | |
4871 | "Originate default route to this neighbor\n" | |
4872 | "Route-map to specify criteria to originate default\n" | |
4873 | "route-map name\n") | |
4874 | { | |
c500ae40 DW |
4875 | int idx_peer = 1; |
4876 | int idx_word = 4; | |
4877 | return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4878 | bgp_node_safi (vty), argv[idx_word]->arg, 1); | |
718e3744 | 4879 | } |
4880 | ||
596c17ba DW |
4881 | ALIAS_HIDDEN (neighbor_default_originate_rmap, |
4882 | neighbor_default_originate_rmap_hidden_cmd, | |
4883 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
4884 | NEIGHBOR_STR | |
4885 | NEIGHBOR_ADDR_STR2 | |
4886 | "Originate default route to this neighbor\n" | |
4887 | "Route-map to specify criteria to originate default\n" | |
4888 | "route-map name\n") | |
4889 | ||
718e3744 | 4890 | DEFUN (no_neighbor_default_originate, |
4891 | no_neighbor_default_originate_cmd, | |
a636c635 | 4892 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 4893 | NO_STR |
4894 | NEIGHBOR_STR | |
4895 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4896 | "Originate default route to this neighbor\n" |
4897 | "Route-map to specify criteria to originate default\n" | |
4898 | "route-map name\n") | |
718e3744 | 4899 | { |
c500ae40 DW |
4900 | int idx_peer = 2; |
4901 | return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4902 | bgp_node_safi (vty), NULL, 0); |
4903 | } | |
4904 | ||
596c17ba DW |
4905 | ALIAS_HIDDEN (no_neighbor_default_originate, |
4906 | no_neighbor_default_originate_hidden_cmd, | |
4907 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
4908 | NO_STR | |
4909 | NEIGHBOR_STR | |
4910 | NEIGHBOR_ADDR_STR2 | |
4911 | "Originate default route to this neighbor\n" | |
4912 | "Route-map to specify criteria to originate default\n" | |
4913 | "route-map name\n") | |
4914 | ||
6b0655a2 | 4915 | |
718e3744 | 4916 | /* Set neighbor's BGP port. */ |
94f2b392 | 4917 | static int |
e52702f2 | 4918 | peer_port_vty (struct vty *vty, const char *ip_str, int afi, |
fd79ac91 | 4919 | const char *port_str) |
718e3744 | 4920 | { |
4921 | struct peer *peer; | |
4922 | u_int16_t port; | |
4923 | struct servent *sp; | |
4924 | ||
4925 | peer = peer_lookup_vty (vty, ip_str); | |
4926 | if (! peer) | |
4927 | return CMD_WARNING; | |
4928 | ||
4929 | if (! port_str) | |
e52702f2 | 4930 | { |
718e3744 | 4931 | sp = getservbyname ("bgp", "tcp"); |
4932 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs (sp->s_port); | |
4933 | } | |
4934 | else | |
4935 | { | |
4936 | VTY_GET_INTEGER("port", port, port_str); | |
4937 | } | |
4938 | ||
4939 | peer_port_set (peer, port); | |
4940 | ||
4941 | return CMD_SUCCESS; | |
4942 | } | |
4943 | ||
f418446b | 4944 | /* Set specified peer's BGP port. */ |
718e3744 | 4945 | DEFUN (neighbor_port, |
4946 | neighbor_port_cmd, | |
9ccf14f7 | 4947 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 4948 | NEIGHBOR_STR |
4949 | NEIGHBOR_ADDR_STR | |
4950 | "Neighbor's BGP port\n" | |
4951 | "TCP port number\n") | |
4952 | { | |
c500ae40 DW |
4953 | int idx_ip = 1; |
4954 | int idx_number = 3; | |
4955 | return peer_port_vty (vty, argv[idx_ip]->arg, AFI_IP, argv[idx_number]->arg); | |
718e3744 | 4956 | } |
4957 | ||
4958 | DEFUN (no_neighbor_port, | |
4959 | no_neighbor_port_cmd, | |
9ccf14f7 | 4960 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 4961 | NO_STR |
4962 | NEIGHBOR_STR | |
4963 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
4964 | "Neighbor's BGP port\n" |
4965 | "TCP port number\n") | |
718e3744 | 4966 | { |
c500ae40 DW |
4967 | int idx_ip = 2; |
4968 | return peer_port_vty (vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 4969 | } |
4970 | ||
6b0655a2 | 4971 | |
718e3744 | 4972 | /* neighbor weight. */ |
94f2b392 | 4973 | static int |
e52702f2 | 4974 | peer_weight_set_vty (struct vty *vty, const char *ip_str, |
d93f7ffc | 4975 | afi_t afi, safi_t safi, |
fd79ac91 | 4976 | const char *weight_str) |
718e3744 | 4977 | { |
1f9a9fff | 4978 | int ret; |
718e3744 | 4979 | struct peer *peer; |
4980 | unsigned long weight; | |
4981 | ||
4982 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4983 | if (! peer) | |
4984 | return CMD_WARNING; | |
4985 | ||
4986 | VTY_GET_INTEGER_RANGE("weight", weight, weight_str, 0, 65535); | |
4987 | ||
d93f7ffc | 4988 | ret = peer_weight_set (peer, afi, safi, weight); |
1f9a9fff | 4989 | return bgp_vty_return (vty, ret); |
718e3744 | 4990 | } |
4991 | ||
94f2b392 | 4992 | static int |
d93f7ffc DW |
4993 | peer_weight_unset_vty (struct vty *vty, const char *ip_str, |
4994 | afi_t afi, safi_t safi) | |
718e3744 | 4995 | { |
1f9a9fff | 4996 | int ret; |
718e3744 | 4997 | struct peer *peer; |
4998 | ||
4999 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5000 | if (! peer) | |
5001 | return CMD_WARNING; | |
5002 | ||
d93f7ffc | 5003 | ret = peer_weight_unset (peer, afi, safi); |
1f9a9fff | 5004 | return bgp_vty_return (vty, ret); |
718e3744 | 5005 | } |
5006 | ||
5007 | DEFUN (neighbor_weight, | |
5008 | neighbor_weight_cmd, | |
9ccf14f7 | 5009 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 5010 | NEIGHBOR_STR |
5011 | NEIGHBOR_ADDR_STR2 | |
5012 | "Set default weight for routes from this neighbor\n" | |
5013 | "default weight\n") | |
5014 | { | |
c500ae40 DW |
5015 | int idx_peer = 1; |
5016 | int idx_number = 3; | |
e52702f2 QY |
5017 | return peer_weight_set_vty (vty, |
5018 | argv[idx_peer]->arg, | |
5019 | bgp_node_afi (vty), | |
5020 | bgp_node_safi (vty), | |
5021 | argv[idx_number]->arg); | |
718e3744 | 5022 | } |
5023 | ||
596c17ba DW |
5024 | ALIAS_HIDDEN (neighbor_weight, |
5025 | neighbor_weight_hidden_cmd, | |
5026 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
5027 | NEIGHBOR_STR | |
5028 | NEIGHBOR_ADDR_STR2 | |
5029 | "Set default weight for routes from this neighbor\n" | |
5030 | "default weight\n") | |
5031 | ||
718e3744 | 5032 | DEFUN (no_neighbor_weight, |
5033 | no_neighbor_weight_cmd, | |
9ccf14f7 | 5034 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 5035 | NO_STR |
5036 | NEIGHBOR_STR | |
5037 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5038 | "Set default weight for routes from this neighbor\n" |
5039 | "default weight\n") | |
718e3744 | 5040 | { |
c500ae40 | 5041 | int idx_peer = 2; |
e52702f2 | 5042 | return peer_weight_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty)); |
718e3744 | 5043 | } |
5044 | ||
596c17ba DW |
5045 | ALIAS_HIDDEN (no_neighbor_weight, |
5046 | no_neighbor_weight_hidden_cmd, | |
5047 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
5048 | NO_STR | |
5049 | NEIGHBOR_STR | |
5050 | NEIGHBOR_ADDR_STR2 | |
5051 | "Set default weight for routes from this neighbor\n" | |
5052 | "default weight\n") | |
5053 | ||
6b0655a2 | 5054 | |
718e3744 | 5055 | /* Override capability negotiation. */ |
5056 | DEFUN (neighbor_override_capability, | |
5057 | neighbor_override_capability_cmd, | |
9ccf14f7 | 5058 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5059 | NEIGHBOR_STR |
5060 | NEIGHBOR_ADDR_STR2 | |
5061 | "Override capability negotiation result\n") | |
5062 | { | |
c500ae40 DW |
5063 | int idx_peer = 1; |
5064 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5065 | } |
5066 | ||
5067 | DEFUN (no_neighbor_override_capability, | |
5068 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 5069 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5070 | NO_STR |
5071 | NEIGHBOR_STR | |
5072 | NEIGHBOR_ADDR_STR2 | |
5073 | "Override capability negotiation result\n") | |
5074 | { | |
c500ae40 DW |
5075 | int idx_peer = 2; |
5076 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5077 | } |
6b0655a2 | 5078 | |
718e3744 | 5079 | DEFUN (neighbor_strict_capability, |
5080 | neighbor_strict_capability_cmd, | |
9ccf14f7 | 5081 | "neighbor <A.B.C.D|X:X::X:X> strict-capability-match", |
718e3744 | 5082 | NEIGHBOR_STR |
5083 | NEIGHBOR_ADDR_STR | |
5084 | "Strict capability negotiation match\n") | |
5085 | { | |
c500ae40 DW |
5086 | int idx_ip = 1; |
5087 | return peer_flag_set_vty (vty, argv[idx_ip]->arg, PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 5088 | } |
5089 | ||
5090 | DEFUN (no_neighbor_strict_capability, | |
5091 | no_neighbor_strict_capability_cmd, | |
9ccf14f7 | 5092 | "no neighbor <A.B.C.D|X:X::X:X> strict-capability-match", |
718e3744 | 5093 | NO_STR |
5094 | NEIGHBOR_STR | |
5095 | NEIGHBOR_ADDR_STR | |
5096 | "Strict capability negotiation match\n") | |
5097 | { | |
c500ae40 DW |
5098 | int idx_ip = 2; |
5099 | return peer_flag_unset_vty (vty, argv[idx_ip]->arg, PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 5100 | } |
6b0655a2 | 5101 | |
94f2b392 | 5102 | static int |
e52702f2 | 5103 | peer_timers_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 5104 | const char *keep_str, const char *hold_str) |
718e3744 | 5105 | { |
5106 | int ret; | |
5107 | struct peer *peer; | |
5108 | u_int32_t keepalive; | |
5109 | u_int32_t holdtime; | |
5110 | ||
5111 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5112 | if (! peer) | |
5113 | return CMD_WARNING; | |
5114 | ||
5115 | VTY_GET_INTEGER_RANGE ("Keepalive", keepalive, keep_str, 0, 65535); | |
5116 | VTY_GET_INTEGER_RANGE ("Holdtime", holdtime, hold_str, 0, 65535); | |
5117 | ||
5118 | ret = peer_timers_set (peer, keepalive, holdtime); | |
5119 | ||
5120 | return bgp_vty_return (vty, ret); | |
5121 | } | |
6b0655a2 | 5122 | |
94f2b392 | 5123 | static int |
fd79ac91 | 5124 | peer_timers_unset_vty (struct vty *vty, const char *ip_str) |
718e3744 | 5125 | { |
5126 | int ret; | |
5127 | struct peer *peer; | |
5128 | ||
0c412461 | 5129 | peer = peer_and_group_lookup_vty (vty, ip_str); |
718e3744 | 5130 | if (! peer) |
5131 | return CMD_WARNING; | |
5132 | ||
5133 | ret = peer_timers_unset (peer); | |
5134 | ||
5135 | return bgp_vty_return (vty, ret); | |
5136 | } | |
5137 | ||
5138 | DEFUN (neighbor_timers, | |
5139 | neighbor_timers_cmd, | |
9ccf14f7 | 5140 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 5141 | NEIGHBOR_STR |
5142 | NEIGHBOR_ADDR_STR2 | |
5143 | "BGP per neighbor timers\n" | |
5144 | "Keepalive interval\n" | |
5145 | "Holdtime\n") | |
5146 | { | |
c500ae40 DW |
5147 | int idx_peer = 1; |
5148 | int idx_number = 3; | |
5149 | int idx_number_2 = 4; | |
5150 | return peer_timers_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg); | |
718e3744 | 5151 | } |
5152 | ||
5153 | DEFUN (no_neighbor_timers, | |
5154 | no_neighbor_timers_cmd, | |
9ccf14f7 | 5155 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 5156 | NO_STR |
5157 | NEIGHBOR_STR | |
5158 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5159 | "BGP per neighbor timers\n" |
5160 | "Keepalive interval\n" | |
5161 | "Holdtime\n") | |
718e3744 | 5162 | { |
c500ae40 DW |
5163 | int idx_peer = 2; |
5164 | return peer_timers_unset_vty (vty, argv[idx_peer]->arg); | |
718e3744 | 5165 | } |
6b0655a2 | 5166 | |
813d4307 | 5167 | |
94f2b392 | 5168 | static int |
e52702f2 | 5169 | peer_timers_connect_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 5170 | const char *time_str) |
718e3744 | 5171 | { |
5172 | int ret; | |
5173 | struct peer *peer; | |
5174 | u_int32_t connect; | |
5175 | ||
966f821c | 5176 | peer = peer_and_group_lookup_vty (vty, ip_str); |
718e3744 | 5177 | if (! peer) |
5178 | return CMD_WARNING; | |
5179 | ||
5180 | VTY_GET_INTEGER_RANGE ("Connect time", connect, time_str, 0, 65535); | |
5181 | ||
5182 | ret = peer_timers_connect_set (peer, connect); | |
5183 | ||
966f821c | 5184 | return bgp_vty_return (vty, ret); |
718e3744 | 5185 | } |
5186 | ||
94f2b392 | 5187 | static int |
fd79ac91 | 5188 | peer_timers_connect_unset_vty (struct vty *vty, const char *ip_str) |
718e3744 | 5189 | { |
5190 | int ret; | |
5191 | struct peer *peer; | |
5192 | ||
5193 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5194 | if (! peer) | |
5195 | return CMD_WARNING; | |
5196 | ||
5197 | ret = peer_timers_connect_unset (peer); | |
5198 | ||
966f821c | 5199 | return bgp_vty_return (vty, ret); |
718e3744 | 5200 | } |
5201 | ||
5202 | DEFUN (neighbor_timers_connect, | |
5203 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 5204 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 5205 | NEIGHBOR_STR |
966f821c | 5206 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5207 | "BGP per neighbor timers\n" |
5208 | "BGP connect timer\n" | |
5209 | "Connect timer\n") | |
5210 | { | |
c500ae40 DW |
5211 | int idx_peer = 1; |
5212 | int idx_number = 4; | |
5213 | return peer_timers_connect_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg); | |
718e3744 | 5214 | } |
5215 | ||
5216 | DEFUN (no_neighbor_timers_connect, | |
5217 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 5218 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 5219 | NO_STR |
5220 | NEIGHBOR_STR | |
966f821c | 5221 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5222 | "BGP per neighbor timers\n" |
8334fd5a DW |
5223 | "BGP connect timer\n" |
5224 | "Connect timer\n") | |
718e3744 | 5225 | { |
c500ae40 DW |
5226 | int idx_peer = 2; |
5227 | return peer_timers_connect_unset_vty (vty, argv[idx_peer]->arg); | |
718e3744 | 5228 | } |
5229 | ||
6b0655a2 | 5230 | |
94f2b392 | 5231 | static int |
e52702f2 QY |
5232 | peer_advertise_interval_vty (struct vty *vty, const char *ip_str, |
5233 | const char *time_str, int set) | |
718e3744 | 5234 | { |
5235 | int ret; | |
5236 | struct peer *peer; | |
5237 | u_int32_t routeadv = 0; | |
5238 | ||
966f821c | 5239 | peer = peer_and_group_lookup_vty (vty, ip_str); |
718e3744 | 5240 | if (! peer) |
5241 | return CMD_WARNING; | |
5242 | ||
5243 | if (time_str) | |
5244 | VTY_GET_INTEGER_RANGE ("advertise interval", routeadv, time_str, 0, 600); | |
5245 | ||
5246 | if (set) | |
5247 | ret = peer_advertise_interval_set (peer, routeadv); | |
5248 | else | |
5249 | ret = peer_advertise_interval_unset (peer); | |
5250 | ||
966f821c | 5251 | return bgp_vty_return (vty, ret); |
718e3744 | 5252 | } |
5253 | ||
5254 | DEFUN (neighbor_advertise_interval, | |
5255 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5256 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 5257 | NEIGHBOR_STR |
966f821c | 5258 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5259 | "Minimum interval between sending BGP routing updates\n" |
5260 | "time in seconds\n") | |
5261 | { | |
c500ae40 DW |
5262 | int idx_peer = 1; |
5263 | int idx_number = 3; | |
5264 | return peer_advertise_interval_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg, 1); | |
718e3744 | 5265 | } |
5266 | ||
5267 | DEFUN (no_neighbor_advertise_interval, | |
5268 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5269 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 5270 | NO_STR |
5271 | NEIGHBOR_STR | |
966f821c | 5272 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
5273 | "Minimum interval between sending BGP routing updates\n" |
5274 | "time in seconds\n") | |
718e3744 | 5275 | { |
c500ae40 DW |
5276 | int idx_peer = 2; |
5277 | return peer_advertise_interval_vty (vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 5278 | } |
5279 | ||
6b0655a2 | 5280 | |
518f0eb1 DS |
5281 | /* Time to wait before processing route-map updates */ |
5282 | DEFUN (bgp_set_route_map_delay_timer, | |
5283 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 5284 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
5285 | SET_STR |
5286 | "BGP route-map delay timer\n" | |
5287 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 5288 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 5289 | { |
c500ae40 | 5290 | int idx_number = 3; |
518f0eb1 | 5291 | u_int32_t rmap_delay_timer; |
518f0eb1 | 5292 | |
c500ae40 | 5293 | if (argv[idx_number]->arg) |
518f0eb1 | 5294 | { |
c500ae40 | 5295 | VTY_GET_INTEGER_RANGE ("delay-timer", rmap_delay_timer, argv[idx_number]->arg, 0, 600); |
5fe9f963 | 5296 | bm->rmap_update_timer = rmap_delay_timer; |
518f0eb1 DS |
5297 | |
5298 | /* if the dynamic update handling is being disabled, and a timer is | |
5299 | * running, stop the timer and act as if the timer has already fired. | |
5300 | */ | |
5fe9f963 | 5301 | if (!rmap_delay_timer && bm->t_rmap_update ) |
518f0eb1 | 5302 | { |
5fe9f963 | 5303 | BGP_TIMER_OFF(bm->t_rmap_update); |
5304 | thread_execute (bm->master, bgp_route_map_update_timer, NULL, 0); | |
518f0eb1 DS |
5305 | } |
5306 | return CMD_SUCCESS; | |
5307 | } | |
5308 | else | |
ffd0c037 | 5309 | return CMD_WARNING; |
518f0eb1 DS |
5310 | } |
5311 | ||
5312 | DEFUN (no_bgp_set_route_map_delay_timer, | |
5313 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 5314 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 5315 | NO_STR |
3a2d747c | 5316 | BGP_STR |
518f0eb1 | 5317 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
5318 | "Reset to default time to wait for processing route-map changes\n" |
5319 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 5320 | { |
518f0eb1 | 5321 | |
5fe9f963 | 5322 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 DS |
5323 | |
5324 | return CMD_SUCCESS; | |
5325 | } | |
5326 | ||
f414725f | 5327 | |
718e3744 | 5328 | /* neighbor interface */ |
94f2b392 | 5329 | static int |
fd79ac91 | 5330 | peer_interface_vty (struct vty *vty, const char *ip_str, const char *str) |
718e3744 | 5331 | { |
718e3744 | 5332 | struct peer *peer; |
5333 | ||
5334 | peer = peer_lookup_vty (vty, ip_str); | |
a80beece | 5335 | if (! peer || peer->conf_if) |
718e3744 | 5336 | return CMD_WARNING; |
5337 | ||
5338 | if (str) | |
ffd0c037 | 5339 | peer_interface_set (peer, str); |
718e3744 | 5340 | else |
ffd0c037 | 5341 | peer_interface_unset (peer); |
718e3744 | 5342 | |
5343 | return CMD_SUCCESS; | |
5344 | } | |
5345 | ||
5346 | DEFUN (neighbor_interface, | |
5347 | neighbor_interface_cmd, | |
9ccf14f7 | 5348 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 5349 | NEIGHBOR_STR |
5350 | NEIGHBOR_ADDR_STR | |
5351 | "Interface\n" | |
5352 | "Interface name\n") | |
5353 | { | |
c500ae40 DW |
5354 | int idx_ip = 1; |
5355 | int idx_word = 3; | |
00d7d2d3 | 5356 | return peer_interface_vty (vty, argv[idx_ip]->arg, argv[idx_word]->arg); |
718e3744 | 5357 | } |
5358 | ||
5359 | DEFUN (no_neighbor_interface, | |
5360 | no_neighbor_interface_cmd, | |
9ccf14f7 | 5361 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 5362 | NO_STR |
5363 | NEIGHBOR_STR | |
16cedbb0 | 5364 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5365 | "Interface\n" |
5366 | "Interface name\n") | |
5367 | { | |
c500ae40 DW |
5368 | int idx_peer = 2; |
5369 | return peer_interface_vty (vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5370 | } |
6b0655a2 | 5371 | |
718e3744 | 5372 | /* Set distribute list to the peer. */ |
94f2b392 | 5373 | static int |
e52702f2 | 5374 | peer_distribute_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 5375 | afi_t afi, safi_t safi, |
5376 | const char *name_str, const char *direct_str) | |
718e3744 | 5377 | { |
5378 | int ret; | |
5379 | struct peer *peer; | |
5380 | int direct = FILTER_IN; | |
5381 | ||
5382 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5383 | if (! peer) | |
5384 | return CMD_WARNING; | |
5385 | ||
5386 | /* Check filter direction. */ | |
5387 | if (strncmp (direct_str, "i", 1) == 0) | |
5388 | direct = FILTER_IN; | |
5389 | else if (strncmp (direct_str, "o", 1) == 0) | |
5390 | direct = FILTER_OUT; | |
5391 | ||
5392 | ret = peer_distribute_set (peer, afi, safi, direct, name_str); | |
5393 | ||
5394 | return bgp_vty_return (vty, ret); | |
5395 | } | |
5396 | ||
94f2b392 | 5397 | static int |
fd79ac91 | 5398 | peer_distribute_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
5399 | safi_t safi, const char *direct_str) | |
718e3744 | 5400 | { |
5401 | int ret; | |
5402 | struct peer *peer; | |
5403 | int direct = FILTER_IN; | |
5404 | ||
5405 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5406 | if (! peer) | |
5407 | return CMD_WARNING; | |
5408 | ||
5409 | /* Check filter direction. */ | |
5410 | if (strncmp (direct_str, "i", 1) == 0) | |
5411 | direct = FILTER_IN; | |
5412 | else if (strncmp (direct_str, "o", 1) == 0) | |
5413 | direct = FILTER_OUT; | |
5414 | ||
5415 | ret = peer_distribute_unset (peer, afi, safi, direct); | |
5416 | ||
5417 | return bgp_vty_return (vty, ret); | |
5418 | } | |
5419 | ||
5420 | DEFUN (neighbor_distribute_list, | |
5421 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 5422 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5423 | NEIGHBOR_STR |
5424 | NEIGHBOR_ADDR_STR2 | |
5425 | "Filter updates to/from this neighbor\n" | |
5426 | "IP access-list number\n" | |
5427 | "IP access-list number (expanded range)\n" | |
5428 | "IP Access-list name\n" | |
5429 | "Filter incoming updates\n" | |
5430 | "Filter outgoing updates\n") | |
5431 | { | |
c500ae40 DW |
5432 | int idx_peer = 1; |
5433 | int idx_acl = 3; | |
5434 | int idx_in_out = 4; | |
5435 | return peer_distribute_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5436 | bgp_node_safi (vty), argv[idx_acl]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5437 | } |
5438 | ||
596c17ba DW |
5439 | ALIAS_HIDDEN (neighbor_distribute_list, |
5440 | neighbor_distribute_list_hidden_cmd, | |
5441 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5442 | NEIGHBOR_STR | |
5443 | NEIGHBOR_ADDR_STR2 | |
5444 | "Filter updates to/from this neighbor\n" | |
5445 | "IP access-list number\n" | |
5446 | "IP access-list number (expanded range)\n" | |
5447 | "IP Access-list name\n" | |
5448 | "Filter incoming updates\n" | |
5449 | "Filter outgoing updates\n") | |
5450 | ||
718e3744 | 5451 | DEFUN (no_neighbor_distribute_list, |
5452 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 5453 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5454 | NO_STR |
5455 | NEIGHBOR_STR | |
5456 | NEIGHBOR_ADDR_STR2 | |
5457 | "Filter updates to/from this neighbor\n" | |
5458 | "IP access-list number\n" | |
5459 | "IP access-list number (expanded range)\n" | |
5460 | "IP Access-list name\n" | |
5461 | "Filter incoming updates\n" | |
5462 | "Filter outgoing updates\n") | |
5463 | { | |
c500ae40 DW |
5464 | int idx_peer = 2; |
5465 | int idx_in_out = 5; | |
5466 | return peer_distribute_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5467 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 5468 | } |
6b0655a2 | 5469 | |
596c17ba DW |
5470 | ALIAS_HIDDEN (no_neighbor_distribute_list, |
5471 | no_neighbor_distribute_list_hidden_cmd, | |
5472 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5473 | NO_STR | |
5474 | NEIGHBOR_STR | |
5475 | NEIGHBOR_ADDR_STR2 | |
5476 | "Filter updates to/from this neighbor\n" | |
5477 | "IP access-list number\n" | |
5478 | "IP access-list number (expanded range)\n" | |
5479 | "IP Access-list name\n" | |
5480 | "Filter incoming updates\n" | |
5481 | "Filter outgoing updates\n") | |
5482 | ||
718e3744 | 5483 | /* Set prefix list to the peer. */ |
94f2b392 | 5484 | static int |
fd79ac91 | 5485 | peer_prefix_list_set_vty (struct vty *vty, const char *ip_str, afi_t afi, |
e52702f2 | 5486 | safi_t safi, const char *name_str, |
fd79ac91 | 5487 | const char *direct_str) |
718e3744 | 5488 | { |
5489 | int ret; | |
5490 | struct peer *peer; | |
5491 | int direct = FILTER_IN; | |
5492 | ||
5493 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5494 | if (! peer) | |
5495 | return CMD_WARNING; | |
5496 | ||
5497 | /* Check filter direction. */ | |
5498 | if (strncmp (direct_str, "i", 1) == 0) | |
5499 | direct = FILTER_IN; | |
5500 | else if (strncmp (direct_str, "o", 1) == 0) | |
5501 | direct = FILTER_OUT; | |
5502 | ||
5503 | ret = peer_prefix_list_set (peer, afi, safi, direct, name_str); | |
5504 | ||
5505 | return bgp_vty_return (vty, ret); | |
5506 | } | |
5507 | ||
94f2b392 | 5508 | static int |
fd79ac91 | 5509 | peer_prefix_list_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
5510 | safi_t safi, const char *direct_str) | |
718e3744 | 5511 | { |
5512 | int ret; | |
5513 | struct peer *peer; | |
5514 | int direct = FILTER_IN; | |
5515 | ||
5516 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5517 | if (! peer) | |
5518 | return CMD_WARNING; | |
e52702f2 | 5519 | |
718e3744 | 5520 | /* Check filter direction. */ |
5521 | if (strncmp (direct_str, "i", 1) == 0) | |
5522 | direct = FILTER_IN; | |
5523 | else if (strncmp (direct_str, "o", 1) == 0) | |
5524 | direct = FILTER_OUT; | |
5525 | ||
5526 | ret = peer_prefix_list_unset (peer, afi, safi, direct); | |
5527 | ||
5528 | return bgp_vty_return (vty, ret); | |
5529 | } | |
5530 | ||
5531 | DEFUN (neighbor_prefix_list, | |
5532 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 5533 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5534 | NEIGHBOR_STR |
5535 | NEIGHBOR_ADDR_STR2 | |
5536 | "Filter updates to/from this neighbor\n" | |
5537 | "Name of a prefix list\n" | |
5538 | "Filter incoming updates\n" | |
5539 | "Filter outgoing updates\n") | |
5540 | { | |
c500ae40 DW |
5541 | int idx_peer = 1; |
5542 | int idx_word = 3; | |
5543 | int idx_in_out = 4; | |
5544 | return peer_prefix_list_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5545 | bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5546 | } |
5547 | ||
596c17ba DW |
5548 | ALIAS_HIDDEN (neighbor_prefix_list, |
5549 | neighbor_prefix_list_hidden_cmd, | |
5550 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5551 | NEIGHBOR_STR | |
5552 | NEIGHBOR_ADDR_STR2 | |
5553 | "Filter updates to/from this neighbor\n" | |
5554 | "Name of a prefix list\n" | |
5555 | "Filter incoming updates\n" | |
5556 | "Filter outgoing updates\n") | |
5557 | ||
718e3744 | 5558 | DEFUN (no_neighbor_prefix_list, |
5559 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 5560 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5561 | NO_STR |
5562 | NEIGHBOR_STR | |
5563 | NEIGHBOR_ADDR_STR2 | |
5564 | "Filter updates to/from this neighbor\n" | |
5565 | "Name of a prefix list\n" | |
5566 | "Filter incoming updates\n" | |
5567 | "Filter outgoing updates\n") | |
5568 | { | |
c500ae40 DW |
5569 | int idx_peer = 2; |
5570 | int idx_in_out = 5; | |
5571 | return peer_prefix_list_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5572 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 5573 | } |
6b0655a2 | 5574 | |
596c17ba DW |
5575 | ALIAS_HIDDEN (no_neighbor_prefix_list, |
5576 | no_neighbor_prefix_list_hidden_cmd, | |
5577 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5578 | NO_STR | |
5579 | NEIGHBOR_STR | |
5580 | NEIGHBOR_ADDR_STR2 | |
5581 | "Filter updates to/from this neighbor\n" | |
5582 | "Name of a prefix list\n" | |
5583 | "Filter incoming updates\n" | |
5584 | "Filter outgoing updates\n") | |
5585 | ||
94f2b392 | 5586 | static int |
e52702f2 | 5587 | peer_aslist_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 5588 | afi_t afi, safi_t safi, |
5589 | const char *name_str, const char *direct_str) | |
718e3744 | 5590 | { |
5591 | int ret; | |
5592 | struct peer *peer; | |
5593 | int direct = FILTER_IN; | |
5594 | ||
5595 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5596 | if (! peer) | |
5597 | return CMD_WARNING; | |
5598 | ||
5599 | /* Check filter direction. */ | |
5600 | if (strncmp (direct_str, "i", 1) == 0) | |
5601 | direct = FILTER_IN; | |
5602 | else if (strncmp (direct_str, "o", 1) == 0) | |
5603 | direct = FILTER_OUT; | |
5604 | ||
5605 | ret = peer_aslist_set (peer, afi, safi, direct, name_str); | |
5606 | ||
5607 | return bgp_vty_return (vty, ret); | |
5608 | } | |
5609 | ||
94f2b392 | 5610 | static int |
e52702f2 | 5611 | peer_aslist_unset_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 5612 | afi_t afi, safi_t safi, |
5613 | const char *direct_str) | |
718e3744 | 5614 | { |
5615 | int ret; | |
5616 | struct peer *peer; | |
5617 | int direct = FILTER_IN; | |
5618 | ||
5619 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5620 | if (! peer) | |
5621 | return CMD_WARNING; | |
5622 | ||
5623 | /* Check filter direction. */ | |
5624 | if (strncmp (direct_str, "i", 1) == 0) | |
5625 | direct = FILTER_IN; | |
5626 | else if (strncmp (direct_str, "o", 1) == 0) | |
5627 | direct = FILTER_OUT; | |
5628 | ||
5629 | ret = peer_aslist_unset (peer, afi, safi, direct); | |
5630 | ||
5631 | return bgp_vty_return (vty, ret); | |
5632 | } | |
5633 | ||
5634 | DEFUN (neighbor_filter_list, | |
5635 | neighbor_filter_list_cmd, | |
9ccf14f7 | 5636 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5637 | NEIGHBOR_STR |
5638 | NEIGHBOR_ADDR_STR2 | |
5639 | "Establish BGP filters\n" | |
5640 | "AS path access-list name\n" | |
5641 | "Filter incoming routes\n" | |
5642 | "Filter outgoing routes\n") | |
5643 | { | |
c500ae40 DW |
5644 | int idx_peer = 1; |
5645 | int idx_word = 3; | |
5646 | int idx_in_out = 4; | |
5647 | return peer_aslist_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5648 | bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5649 | } |
5650 | ||
596c17ba DW |
5651 | ALIAS_HIDDEN (neighbor_filter_list, |
5652 | neighbor_filter_list_hidden_cmd, | |
5653 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5654 | NEIGHBOR_STR | |
5655 | NEIGHBOR_ADDR_STR2 | |
5656 | "Establish BGP filters\n" | |
5657 | "AS path access-list name\n" | |
5658 | "Filter incoming routes\n" | |
5659 | "Filter outgoing routes\n") | |
5660 | ||
718e3744 | 5661 | DEFUN (no_neighbor_filter_list, |
5662 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 5663 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5664 | NO_STR |
5665 | NEIGHBOR_STR | |
5666 | NEIGHBOR_ADDR_STR2 | |
5667 | "Establish BGP filters\n" | |
5668 | "AS path access-list name\n" | |
5669 | "Filter incoming routes\n" | |
5670 | "Filter outgoing routes\n") | |
5671 | { | |
c500ae40 DW |
5672 | int idx_peer = 2; |
5673 | int idx_in_out = 5; | |
5674 | return peer_aslist_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5675 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 5676 | } |
6b0655a2 | 5677 | |
596c17ba DW |
5678 | ALIAS_HIDDEN (no_neighbor_filter_list, |
5679 | no_neighbor_filter_list_hidden_cmd, | |
5680 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5681 | NO_STR | |
5682 | NEIGHBOR_STR | |
5683 | NEIGHBOR_ADDR_STR2 | |
5684 | "Establish BGP filters\n" | |
5685 | "AS path access-list name\n" | |
5686 | "Filter incoming routes\n" | |
5687 | "Filter outgoing routes\n") | |
5688 | ||
718e3744 | 5689 | /* Set route-map to the peer. */ |
94f2b392 | 5690 | static int |
e52702f2 | 5691 | peer_route_map_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 5692 | afi_t afi, safi_t safi, |
5693 | const char *name_str, const char *direct_str) | |
718e3744 | 5694 | { |
5695 | int ret; | |
5696 | struct peer *peer; | |
fee0f4c6 | 5697 | int direct = RMAP_IN; |
718e3744 | 5698 | |
5699 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5700 | if (! peer) | |
5701 | return CMD_WARNING; | |
5702 | ||
5703 | /* Check filter direction. */ | |
fee0f4c6 | 5704 | if (strncmp (direct_str, "in", 2) == 0) |
5705 | direct = RMAP_IN; | |
718e3744 | 5706 | else if (strncmp (direct_str, "o", 1) == 0) |
fee0f4c6 | 5707 | direct = RMAP_OUT; |
718e3744 | 5708 | |
5709 | ret = peer_route_map_set (peer, afi, safi, direct, name_str); | |
5710 | ||
5711 | return bgp_vty_return (vty, ret); | |
5712 | } | |
5713 | ||
94f2b392 | 5714 | static int |
fd79ac91 | 5715 | peer_route_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
5716 | safi_t safi, const char *direct_str) | |
718e3744 | 5717 | { |
5718 | int ret; | |
5719 | struct peer *peer; | |
fee0f4c6 | 5720 | int direct = RMAP_IN; |
718e3744 | 5721 | |
5722 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5723 | if (! peer) | |
5724 | return CMD_WARNING; | |
5725 | ||
5726 | /* Check filter direction. */ | |
fee0f4c6 | 5727 | if (strncmp (direct_str, "in", 2) == 0) |
5728 | direct = RMAP_IN; | |
718e3744 | 5729 | else if (strncmp (direct_str, "o", 1) == 0) |
fee0f4c6 | 5730 | direct = RMAP_OUT; |
718e3744 | 5731 | |
5732 | ret = peer_route_map_unset (peer, afi, safi, direct); | |
5733 | ||
5734 | return bgp_vty_return (vty, ret); | |
5735 | } | |
5736 | ||
5737 | DEFUN (neighbor_route_map, | |
5738 | neighbor_route_map_cmd, | |
9ccf14f7 | 5739 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5740 | NEIGHBOR_STR |
5741 | NEIGHBOR_ADDR_STR2 | |
5742 | "Apply route map to neighbor\n" | |
5743 | "Name of route map\n" | |
5744 | "Apply map to incoming routes\n" | |
2a3d5731 | 5745 | "Apply map to outbound routes\n") |
718e3744 | 5746 | { |
c500ae40 DW |
5747 | int idx_peer = 1; |
5748 | int idx_word = 3; | |
5749 | int idx_in_out = 4; | |
5750 | return peer_route_map_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5751 | bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5752 | } |
5753 | ||
596c17ba DW |
5754 | ALIAS_HIDDEN (neighbor_route_map, |
5755 | neighbor_route_map_hidden_cmd, | |
5756 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5757 | NEIGHBOR_STR | |
5758 | NEIGHBOR_ADDR_STR2 | |
5759 | "Apply route map to neighbor\n" | |
5760 | "Name of route map\n" | |
5761 | "Apply map to incoming routes\n" | |
5762 | "Apply map to outbound routes\n") | |
5763 | ||
718e3744 | 5764 | DEFUN (no_neighbor_route_map, |
5765 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 5766 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5767 | NO_STR |
5768 | NEIGHBOR_STR | |
5769 | NEIGHBOR_ADDR_STR2 | |
5770 | "Apply route map to neighbor\n" | |
5771 | "Name of route map\n" | |
5772 | "Apply map to incoming routes\n" | |
2a3d5731 | 5773 | "Apply map to outbound routes\n") |
718e3744 | 5774 | { |
c500ae40 DW |
5775 | int idx_peer = 2; |
5776 | int idx_in_out = 5; | |
5777 | return peer_route_map_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5778 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 5779 | } |
6b0655a2 | 5780 | |
596c17ba DW |
5781 | ALIAS_HIDDEN (no_neighbor_route_map, |
5782 | no_neighbor_route_map_hidden_cmd, | |
5783 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5784 | NO_STR | |
5785 | NEIGHBOR_STR | |
5786 | NEIGHBOR_ADDR_STR2 | |
5787 | "Apply route map to neighbor\n" | |
5788 | "Name of route map\n" | |
5789 | "Apply map to incoming routes\n" | |
5790 | "Apply map to outbound routes\n") | |
5791 | ||
718e3744 | 5792 | /* Set unsuppress-map to the peer. */ |
94f2b392 | 5793 | static int |
fd79ac91 | 5794 | peer_unsuppress_map_set_vty (struct vty *vty, const char *ip_str, afi_t afi, |
5795 | safi_t safi, const char *name_str) | |
718e3744 | 5796 | { |
5797 | int ret; | |
5798 | struct peer *peer; | |
5799 | ||
5800 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5801 | if (! peer) | |
5802 | return CMD_WARNING; | |
5803 | ||
5804 | ret = peer_unsuppress_map_set (peer, afi, safi, name_str); | |
5805 | ||
5806 | return bgp_vty_return (vty, ret); | |
5807 | } | |
5808 | ||
5809 | /* Unset route-map from the peer. */ | |
94f2b392 | 5810 | static int |
fd79ac91 | 5811 | peer_unsuppress_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
718e3744 | 5812 | safi_t safi) |
5813 | { | |
5814 | int ret; | |
5815 | struct peer *peer; | |
5816 | ||
5817 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5818 | if (! peer) | |
5819 | return CMD_WARNING; | |
5820 | ||
5821 | ret = peer_unsuppress_map_unset (peer, afi, safi); | |
5822 | ||
5823 | return bgp_vty_return (vty, ret); | |
5824 | } | |
5825 | ||
5826 | DEFUN (neighbor_unsuppress_map, | |
5827 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5828 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5829 | NEIGHBOR_STR |
5830 | NEIGHBOR_ADDR_STR2 | |
5831 | "Route-map to selectively unsuppress suppressed routes\n" | |
5832 | "Name of route map\n") | |
5833 | { | |
c500ae40 DW |
5834 | int idx_peer = 1; |
5835 | int idx_word = 3; | |
5836 | return peer_unsuppress_map_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5837 | bgp_node_safi (vty), argv[idx_word]->arg); | |
718e3744 | 5838 | } |
5839 | ||
596c17ba DW |
5840 | ALIAS_HIDDEN (neighbor_unsuppress_map, |
5841 | neighbor_unsuppress_map_hidden_cmd, | |
5842 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5843 | NEIGHBOR_STR | |
5844 | NEIGHBOR_ADDR_STR2 | |
5845 | "Route-map to selectively unsuppress suppressed routes\n" | |
5846 | "Name of route map\n") | |
5847 | ||
718e3744 | 5848 | DEFUN (no_neighbor_unsuppress_map, |
5849 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5850 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5851 | NO_STR |
5852 | NEIGHBOR_STR | |
5853 | NEIGHBOR_ADDR_STR2 | |
5854 | "Route-map to selectively unsuppress suppressed routes\n" | |
5855 | "Name of route map\n") | |
5856 | { | |
c500ae40 DW |
5857 | int idx_peer = 2; |
5858 | return peer_unsuppress_map_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 5859 | bgp_node_safi (vty)); |
5860 | } | |
6b0655a2 | 5861 | |
596c17ba DW |
5862 | ALIAS_HIDDEN (no_neighbor_unsuppress_map, |
5863 | no_neighbor_unsuppress_map_hidden_cmd, | |
5864 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5865 | NO_STR | |
5866 | NEIGHBOR_STR | |
5867 | NEIGHBOR_ADDR_STR2 | |
5868 | "Route-map to selectively unsuppress suppressed routes\n" | |
5869 | "Name of route map\n") | |
5870 | ||
94f2b392 | 5871 | static int |
fd79ac91 | 5872 | peer_maximum_prefix_set_vty (struct vty *vty, const char *ip_str, afi_t afi, |
e52702f2 | 5873 | safi_t safi, const char *num_str, |
0a486e5f | 5874 | const char *threshold_str, int warning, |
5875 | const char *restart_str) | |
718e3744 | 5876 | { |
5877 | int ret; | |
5878 | struct peer *peer; | |
5879 | u_int32_t max; | |
e0701b79 | 5880 | u_char threshold; |
0a486e5f | 5881 | u_int16_t restart; |
718e3744 | 5882 | |
5883 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5884 | if (! peer) | |
5885 | return CMD_WARNING; | |
5886 | ||
e6ec1c36 | 5887 | VTY_GET_INTEGER ("maximum number", max, num_str); |
e0701b79 | 5888 | if (threshold_str) |
5889 | threshold = atoi (threshold_str); | |
5890 | else | |
5891 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 5892 | |
0a486e5f | 5893 | if (restart_str) |
5894 | restart = atoi (restart_str); | |
5895 | else | |
5896 | restart = 0; | |
5897 | ||
5898 | ret = peer_maximum_prefix_set (peer, afi, safi, max, threshold, warning, restart); | |
718e3744 | 5899 | |
5900 | return bgp_vty_return (vty, ret); | |
5901 | } | |
5902 | ||
94f2b392 | 5903 | static int |
fd79ac91 | 5904 | peer_maximum_prefix_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
718e3744 | 5905 | safi_t safi) |
5906 | { | |
5907 | int ret; | |
5908 | struct peer *peer; | |
5909 | ||
5910 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5911 | if (! peer) | |
5912 | return CMD_WARNING; | |
5913 | ||
5914 | ret = peer_maximum_prefix_unset (peer, afi, safi); | |
5915 | ||
5916 | return bgp_vty_return (vty, ret); | |
5917 | } | |
5918 | ||
5919 | /* Maximum number of prefix configuration. prefix count is different | |
5920 | for each peer configuration. So this configuration can be set for | |
5921 | each peer configuration. */ | |
5922 | DEFUN (neighbor_maximum_prefix, | |
5923 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 5924 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 5925 | NEIGHBOR_STR |
5926 | NEIGHBOR_ADDR_STR2 | |
5927 | "Maximum number of prefix accept from this peer\n" | |
5928 | "maximum no. of prefix limit\n") | |
5929 | { | |
c500ae40 DW |
5930 | int idx_peer = 1; |
5931 | int idx_number = 3; | |
5932 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5933 | bgp_node_safi (vty), argv[idx_number]->arg, NULL, 0, | |
0a486e5f | 5934 | NULL); |
718e3744 | 5935 | } |
5936 | ||
596c17ba DW |
5937 | ALIAS_HIDDEN (neighbor_maximum_prefix, |
5938 | neighbor_maximum_prefix_hidden_cmd, | |
5939 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", | |
5940 | NEIGHBOR_STR | |
5941 | NEIGHBOR_ADDR_STR2 | |
5942 | "Maximum number of prefix accept from this peer\n" | |
5943 | "maximum no. of prefix limit\n") | |
5944 | ||
e0701b79 | 5945 | DEFUN (neighbor_maximum_prefix_threshold, |
5946 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 5947 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 5948 | NEIGHBOR_STR |
5949 | NEIGHBOR_ADDR_STR2 | |
5950 | "Maximum number of prefix accept from this peer\n" | |
5951 | "maximum no. of prefix limit\n" | |
5952 | "Threshold value (%) at which to generate a warning msg\n") | |
5953 | { | |
c500ae40 DW |
5954 | int idx_peer = 1; |
5955 | int idx_number = 3; | |
5956 | int idx_number_2 = 4; | |
5957 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5958 | bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
0a486e5f | 5959 | NULL); |
5960 | } | |
e0701b79 | 5961 | |
596c17ba DW |
5962 | ALIAS_HIDDEN (neighbor_maximum_prefix_threshold, |
5963 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
5964 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", | |
5965 | NEIGHBOR_STR | |
5966 | NEIGHBOR_ADDR_STR2 | |
5967 | "Maximum number of prefix accept from this peer\n" | |
5968 | "maximum no. of prefix limit\n" | |
5969 | "Threshold value (%) at which to generate a warning msg\n") | |
5970 | ||
718e3744 | 5971 | DEFUN (neighbor_maximum_prefix_warning, |
5972 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 5973 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 5974 | NEIGHBOR_STR |
5975 | NEIGHBOR_ADDR_STR2 | |
5976 | "Maximum number of prefix accept from this peer\n" | |
5977 | "maximum no. of prefix limit\n" | |
5978 | "Only give warning message when limit is exceeded\n") | |
5979 | { | |
c500ae40 DW |
5980 | int idx_peer = 1; |
5981 | int idx_number = 3; | |
5982 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5983 | bgp_node_safi (vty), argv[idx_number]->arg, NULL, 1, | |
0a486e5f | 5984 | NULL); |
718e3744 | 5985 | } |
5986 | ||
596c17ba DW |
5987 | ALIAS_HIDDEN (neighbor_maximum_prefix_warning, |
5988 | neighbor_maximum_prefix_warning_hidden_cmd, | |
5989 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", | |
5990 | NEIGHBOR_STR | |
5991 | NEIGHBOR_ADDR_STR2 | |
5992 | "Maximum number of prefix accept from this peer\n" | |
5993 | "maximum no. of prefix limit\n" | |
5994 | "Only give warning message when limit is exceeded\n") | |
5995 | ||
e0701b79 | 5996 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
5997 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 5998 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 5999 | NEIGHBOR_STR |
6000 | NEIGHBOR_ADDR_STR2 | |
6001 | "Maximum number of prefix accept from this peer\n" | |
6002 | "maximum no. of prefix limit\n" | |
6003 | "Threshold value (%) at which to generate a warning msg\n" | |
6004 | "Only give warning message when limit is exceeded\n") | |
6005 | { | |
c500ae40 DW |
6006 | int idx_peer = 1; |
6007 | int idx_number = 3; | |
6008 | int idx_number_2 = 4; | |
6009 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
6010 | bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 6011 | } |
6012 | ||
596c17ba DW |
6013 | ALIAS_HIDDEN (neighbor_maximum_prefix_threshold_warning, |
6014 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
6015 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", | |
6016 | NEIGHBOR_STR | |
6017 | NEIGHBOR_ADDR_STR2 | |
6018 | "Maximum number of prefix accept from this peer\n" | |
6019 | "maximum no. of prefix limit\n" | |
6020 | "Threshold value (%) at which to generate a warning msg\n" | |
6021 | "Only give warning message when limit is exceeded\n") | |
6022 | ||
0a486e5f | 6023 | DEFUN (neighbor_maximum_prefix_restart, |
6024 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 6025 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 6026 | NEIGHBOR_STR |
6027 | NEIGHBOR_ADDR_STR2 | |
6028 | "Maximum number of prefix accept from this peer\n" | |
6029 | "maximum no. of prefix limit\n" | |
6030 | "Restart bgp connection after limit is exceeded\n" | |
6031 | "Restart interval in minutes") | |
6032 | { | |
c500ae40 DW |
6033 | int idx_peer = 1; |
6034 | int idx_number = 3; | |
6035 | int idx_number_2 = 5; | |
6036 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
6037 | bgp_node_safi (vty), argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 6038 | } |
6039 | ||
596c17ba DW |
6040 | ALIAS_HIDDEN (neighbor_maximum_prefix_restart, |
6041 | neighbor_maximum_prefix_restart_hidden_cmd, | |
6042 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", | |
6043 | NEIGHBOR_STR | |
6044 | NEIGHBOR_ADDR_STR2 | |
6045 | "Maximum number of prefix accept from this peer\n" | |
6046 | "maximum no. of prefix limit\n" | |
6047 | "Restart bgp connection after limit is exceeded\n" | |
6048 | "Restart interval in minutes") | |
6049 | ||
0a486e5f | 6050 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
6051 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 6052 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 6053 | NEIGHBOR_STR |
6054 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6055 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 6056 | "maximum no. of prefix limit\n" |
6057 | "Threshold value (%) at which to generate a warning msg\n" | |
6058 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6059 | "Restart interval in minutes\n") |
0a486e5f | 6060 | { |
c500ae40 DW |
6061 | int idx_peer = 1; |
6062 | int idx_number = 3; | |
6063 | int idx_number_2 = 4; | |
6064 | int idx_number_3 = 6; | |
6065 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
6066 | bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 0, argv[idx_number_3]->arg); | |
0a486e5f | 6067 | } |
e0701b79 | 6068 | |
596c17ba DW |
6069 | ALIAS_HIDDEN (neighbor_maximum_prefix_threshold_restart, |
6070 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
6071 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", | |
6072 | NEIGHBOR_STR | |
6073 | NEIGHBOR_ADDR_STR2 | |
6074 | "Maximum number of prefixes to accept from this peer\n" | |
6075 | "maximum no. of prefix limit\n" | |
6076 | "Threshold value (%) at which to generate a warning msg\n" | |
6077 | "Restart bgp connection after limit is exceeded\n" | |
6078 | "Restart interval in minutes\n") | |
6079 | ||
718e3744 | 6080 | DEFUN (no_neighbor_maximum_prefix, |
6081 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 6082 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 6083 | NO_STR |
6084 | NEIGHBOR_STR | |
6085 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6086 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
6087 | "maximum no. of prefix limit\n" |
6088 | "Threshold value (%) at which to generate a warning msg\n" | |
6089 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6090 | "Restart interval in minutes\n" |
31500417 | 6091 | "Only give warning message when limit is exceeded\n") |
718e3744 | 6092 | { |
c500ae40 DW |
6093 | int idx_peer = 2; |
6094 | return peer_maximum_prefix_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 6095 | bgp_node_safi (vty)); |
6096 | } | |
e52702f2 | 6097 | |
596c17ba DW |
6098 | ALIAS_HIDDEN (no_neighbor_maximum_prefix, |
6099 | no_neighbor_maximum_prefix_hidden_cmd, | |
6100 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", | |
6101 | NO_STR | |
6102 | NEIGHBOR_STR | |
6103 | NEIGHBOR_ADDR_STR2 | |
6104 | "Maximum number of prefixes to accept from this peer\n" | |
6105 | "maximum no. of prefix limit\n" | |
6106 | "Threshold value (%) at which to generate a warning msg\n" | |
6107 | "Restart bgp connection after limit is exceeded\n" | |
6108 | "Restart interval in minutes\n" | |
6109 | "Only give warning message when limit is exceeded\n") | |
6110 | ||
718e3744 | 6111 | |
718e3744 | 6112 | /* "neighbor allowas-in" */ |
6113 | DEFUN (neighbor_allowas_in, | |
6114 | neighbor_allowas_in_cmd, | |
fd8503f5 | 6115 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6116 | NEIGHBOR_STR |
6117 | NEIGHBOR_ADDR_STR2 | |
31500417 | 6118 | "Accept as-path with my AS present in it\n" |
fd8503f5 QY |
6119 | "Number of occurances of AS number\n" |
6120 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 6121 | { |
c500ae40 | 6122 | int idx_peer = 1; |
fd8503f5 | 6123 | int idx_number_origin = 3; |
718e3744 | 6124 | int ret; |
aac9ef6c | 6125 | int origin = 0; |
718e3744 | 6126 | struct peer *peer; |
aac9ef6c | 6127 | int allow_num = 0; |
718e3744 | 6128 | |
c500ae40 | 6129 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 6130 | if (! peer) |
6131 | return CMD_WARNING; | |
6132 | ||
fd8503f5 | 6133 | if (argc <= idx_number_origin) |
718e3744 | 6134 | allow_num = 3; |
6135 | else | |
aac9ef6c | 6136 | { |
fd8503f5 | 6137 | if (argv[idx_number_origin]->type == WORD_TKN) |
aac9ef6c DW |
6138 | origin = 1; |
6139 | else | |
fd8503f5 | 6140 | allow_num = atoi (argv[idx_number_origin]->arg); |
aac9ef6c | 6141 | } |
718e3744 | 6142 | |
6143 | ret = peer_allowas_in_set (peer, bgp_node_afi (vty), bgp_node_safi (vty), | |
aac9ef6c | 6144 | allow_num, origin); |
718e3744 | 6145 | |
6146 | return bgp_vty_return (vty, ret); | |
6147 | } | |
6148 | ||
596c17ba DW |
6149 | ALIAS_HIDDEN (neighbor_allowas_in, |
6150 | neighbor_allowas_in_hidden_cmd, | |
6151 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6152 | NEIGHBOR_STR | |
6153 | NEIGHBOR_ADDR_STR2 | |
6154 | "Accept as-path with my AS present in it\n" | |
6155 | "Number of occurances of AS number\n" | |
6156 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
6157 | ||
718e3744 | 6158 | DEFUN (no_neighbor_allowas_in, |
6159 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 6160 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6161 | NO_STR |
6162 | NEIGHBOR_STR | |
6163 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 6164 | "allow local ASN appears in aspath attribute\n" |
fd8503f5 QY |
6165 | "Number of occurances of AS number\n" |
6166 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 6167 | { |
c500ae40 | 6168 | int idx_peer = 2; |
718e3744 | 6169 | int ret; |
6170 | struct peer *peer; | |
6171 | ||
c500ae40 | 6172 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 6173 | if (! peer) |
6174 | return CMD_WARNING; | |
6175 | ||
6176 | ret = peer_allowas_in_unset (peer, bgp_node_afi (vty), bgp_node_safi (vty)); | |
6177 | ||
6178 | return bgp_vty_return (vty, ret); | |
6179 | } | |
6b0655a2 | 6180 | |
596c17ba DW |
6181 | ALIAS_HIDDEN (no_neighbor_allowas_in, |
6182 | no_neighbor_allowas_in_hidden_cmd, | |
6183 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6184 | NO_STR | |
6185 | NEIGHBOR_STR | |
6186 | NEIGHBOR_ADDR_STR2 | |
6187 | "allow local ASN appears in aspath attribute\n" | |
6188 | "Number of occurances of AS number\n" | |
6189 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
6190 | ||
fa411a21 NH |
6191 | DEFUN (neighbor_ttl_security, |
6192 | neighbor_ttl_security_cmd, | |
9ccf14f7 | 6193 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
6194 | NEIGHBOR_STR |
6195 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6196 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
6197 | "Specify the maximum number of hops to the BGP peer\n" |
6198 | "Number of hops to BGP peer\n") | |
fa411a21 | 6199 | { |
c500ae40 DW |
6200 | int idx_peer = 1; |
6201 | int idx_number = 4; | |
fa411a21 | 6202 | struct peer *peer; |
89b6d1f8 | 6203 | int gtsm_hops; |
fa411a21 | 6204 | |
c500ae40 | 6205 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
fa411a21 NH |
6206 | if (! peer) |
6207 | return CMD_WARNING; | |
e52702f2 | 6208 | |
c500ae40 | 6209 | VTY_GET_INTEGER_RANGE ("", gtsm_hops, argv[idx_number]->arg, 1, 254); |
fa411a21 | 6210 | |
8cdabf90 SK |
6211 | /* |
6212 | * If 'neighbor swpX', then this is for directly connected peers, | |
6213 | * we should not accept a ttl-security hops value greater than 1. | |
6214 | */ | |
6215 | if (peer->conf_if && (gtsm_hops > 1)) { | |
6216 | vty_out (vty, "%s is directly connected peer, hops cannot exceed 1%s", | |
c500ae40 | 6217 | argv[idx_peer]->arg, VTY_NEWLINE); |
8cdabf90 SK |
6218 | return CMD_WARNING; |
6219 | } | |
6220 | ||
89b6d1f8 | 6221 | return bgp_vty_return (vty, peer_ttl_security_hops_set (peer, gtsm_hops)); |
fa411a21 NH |
6222 | } |
6223 | ||
6224 | DEFUN (no_neighbor_ttl_security, | |
6225 | no_neighbor_ttl_security_cmd, | |
9ccf14f7 | 6226 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
6227 | NO_STR |
6228 | NEIGHBOR_STR | |
6229 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6230 | "BGP ttl-security parameters\n" |
3a2d747c QY |
6231 | "Specify the maximum number of hops to the BGP peer\n" |
6232 | "Number of hops to BGP peer\n") | |
fa411a21 | 6233 | { |
c500ae40 | 6234 | int idx_peer = 2; |
fa411a21 | 6235 | struct peer *peer; |
fa411a21 | 6236 | |
c500ae40 | 6237 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
fa411a21 NH |
6238 | if (! peer) |
6239 | return CMD_WARNING; | |
6240 | ||
89b6d1f8 | 6241 | return bgp_vty_return (vty, peer_ttl_security_hops_unset (peer)); |
fa411a21 | 6242 | } |
6b0655a2 | 6243 | |
adbac85e DW |
6244 | DEFUN (neighbor_addpath_tx_all_paths, |
6245 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6246 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6247 | NEIGHBOR_STR |
6248 | NEIGHBOR_ADDR_STR2 | |
6249 | "Use addpath to advertise all paths to a neighbor\n") | |
6250 | { | |
c500ae40 | 6251 | int idx_peer = 1; |
adbac85e DW |
6252 | struct peer *peer; |
6253 | ||
c500ae40 | 6254 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
adbac85e DW |
6255 | if (! peer) |
6256 | return CMD_WARNING; | |
6257 | ||
c500ae40 | 6258 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
adbac85e DW |
6259 | bgp_node_safi (vty), |
6260 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
6261 | } | |
6262 | ||
596c17ba DW |
6263 | ALIAS_HIDDEN (neighbor_addpath_tx_all_paths, |
6264 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
6265 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6266 | NEIGHBOR_STR | |
6267 | NEIGHBOR_ADDR_STR2 | |
6268 | "Use addpath to advertise all paths to a neighbor\n") | |
6269 | ||
adbac85e DW |
6270 | DEFUN (no_neighbor_addpath_tx_all_paths, |
6271 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6272 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6273 | NO_STR |
6274 | NEIGHBOR_STR | |
6275 | NEIGHBOR_ADDR_STR2 | |
6276 | "Use addpath to advertise all paths to a neighbor\n") | |
6277 | { | |
c500ae40 DW |
6278 | int idx_peer = 2; |
6279 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
adbac85e DW |
6280 | bgp_node_safi (vty), |
6281 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
6282 | } | |
6283 | ||
596c17ba DW |
6284 | ALIAS_HIDDEN (no_neighbor_addpath_tx_all_paths, |
6285 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
6286 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6287 | NO_STR | |
6288 | NEIGHBOR_STR | |
6289 | NEIGHBOR_ADDR_STR2 | |
6290 | "Use addpath to advertise all paths to a neighbor\n") | |
6291 | ||
06370dac DW |
6292 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
6293 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6294 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6295 | NEIGHBOR_STR |
6296 | NEIGHBOR_ADDR_STR2 | |
6297 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6298 | { | |
c500ae40 | 6299 | int idx_peer = 1; |
06370dac DW |
6300 | struct peer *peer; |
6301 | ||
c500ae40 | 6302 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
06370dac DW |
6303 | if (! peer) |
6304 | return CMD_WARNING; | |
6305 | ||
c500ae40 | 6306 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
06370dac DW |
6307 | bgp_node_safi (vty), |
6308 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
6309 | } | |
6310 | ||
596c17ba DW |
6311 | ALIAS_HIDDEN (neighbor_addpath_tx_bestpath_per_as, |
6312 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6313 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6314 | NEIGHBOR_STR | |
6315 | NEIGHBOR_ADDR_STR2 | |
6316 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6317 | ||
06370dac DW |
6318 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
6319 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6320 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6321 | NO_STR |
6322 | NEIGHBOR_STR | |
6323 | NEIGHBOR_ADDR_STR2 | |
6324 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6325 | { | |
c500ae40 DW |
6326 | int idx_peer = 2; |
6327 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
06370dac DW |
6328 | bgp_node_safi (vty), |
6329 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
6330 | } | |
6331 | ||
596c17ba DW |
6332 | ALIAS_HIDDEN (no_neighbor_addpath_tx_bestpath_per_as, |
6333 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6334 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6335 | NO_STR | |
6336 | NEIGHBOR_STR | |
6337 | NEIGHBOR_ADDR_STR2 | |
6338 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6339 | ||
505e5056 | 6340 | DEFUN_NOSH (address_family_ipv4_safi, |
718e3744 | 6341 | address_family_ipv4_safi_cmd, |
f51bae9c | 6342 | "address-family ipv4 [<unicast|multicast|vpn|encap|labeled-unicast>]", |
718e3744 | 6343 | "Enter Address Family command mode\n" |
8c3deaae | 6344 | "Address Family\n" |
46f296b4 | 6345 | BGP_SAFI_HELP_STR) |
718e3744 | 6346 | { |
f51bae9c DS |
6347 | |
6348 | if (argc == 3) | |
ccbb332a | 6349 | { |
f51bae9c DS |
6350 | safi_t safi = bgp_vty_safi_from_arg(argv[2]->arg); |
6351 | vty->node = bgp_node_type(AFI_IP, safi); | |
ccbb332a | 6352 | } |
c7f1274b DS |
6353 | else |
6354 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 6355 | |
6356 | return CMD_SUCCESS; | |
6357 | } | |
6358 | ||
505e5056 | 6359 | DEFUN_NOSH (address_family_ipv6_safi, |
25ffbdc1 | 6360 | address_family_ipv6_safi_cmd, |
f51bae9c | 6361 | "address-family ipv6 [<unicast|multicast|vpn|encap|labeled-unicast>]", |
718e3744 | 6362 | "Enter Address Family command mode\n" |
8c3deaae | 6363 | "Address Family\n" |
46f296b4 | 6364 | BGP_SAFI_HELP_STR) |
25ffbdc1 | 6365 | { |
f51bae9c | 6366 | if (argc == 3) |
46f296b4 | 6367 | { |
f51bae9c DS |
6368 | safi_t safi = bgp_vty_safi_from_arg(argv[2]->arg); |
6369 | vty->node = bgp_node_type(AFI_IP6, safi); | |
46f296b4 | 6370 | } |
c7f1274b DS |
6371 | else |
6372 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 6373 | |
6374 | return CMD_SUCCESS; | |
6375 | } | |
718e3744 | 6376 | |
d6902373 | 6377 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 6378 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 6379 | address_family_vpnv4_cmd, |
8334fd5a | 6380 | "address-family vpnv4 [unicast]", |
718e3744 | 6381 | "Enter Address Family command mode\n" |
8c3deaae | 6382 | "Address Family\n" |
3a2d747c | 6383 | "Address Family modifier\n") |
718e3744 | 6384 | { |
6385 | vty->node = BGP_VPNV4_NODE; | |
6386 | return CMD_SUCCESS; | |
6387 | } | |
6388 | ||
505e5056 | 6389 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 6390 | address_family_vpnv6_cmd, |
8334fd5a | 6391 | "address-family vpnv6 [unicast]", |
8ecd3266 | 6392 | "Enter Address Family command mode\n" |
8c3deaae | 6393 | "Address Family\n" |
3a2d747c | 6394 | "Address Family modifier\n") |
8ecd3266 | 6395 | { |
6396 | vty->node = BGP_VPNV6_NODE; | |
6397 | return CMD_SUCCESS; | |
6398 | } | |
c016b6c7 | 6399 | #endif |
d6902373 | 6400 | |
505e5056 | 6401 | DEFUN_NOSH (address_family_encap, |
8b1fb8be | 6402 | address_family_encap_cmd, |
8334fd5a | 6403 | "address-family <encap|encapv4>", |
8b1fb8be | 6404 | "Enter Address Family command mode\n" |
8c3deaae QY |
6405 | "Address Family\n" |
6406 | "Address Family\n") | |
8b1fb8be LB |
6407 | { |
6408 | vty->node = BGP_ENCAP_NODE; | |
6409 | return CMD_SUCCESS; | |
6410 | } | |
6411 | ||
8b1fb8be | 6412 | |
505e5056 | 6413 | DEFUN_NOSH (address_family_encapv6, |
8b1fb8be LB |
6414 | address_family_encapv6_cmd, |
6415 | "address-family encapv6", | |
6416 | "Enter Address Family command mode\n" | |
8c3deaae | 6417 | "Address Family\n") |
8b1fb8be LB |
6418 | { |
6419 | vty->node = BGP_ENCAPV6_NODE; | |
6420 | return CMD_SUCCESS; | |
6421 | } | |
6422 | ||
505e5056 | 6423 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 6424 | address_family_evpn_cmd, |
b194703e | 6425 | "address-family <l2vpn evpn>", |
4e0b7b6d | 6426 | "Enter Address Family command mode\n" |
61a51962 PG |
6427 | "EVPN Address family\n" |
6428 | "Layer2 VPN Address family\n" | |
6429 | "Ethernet Virtual Private Network Subsequent Address Family\n") | |
4e0b7b6d | 6430 | { |
4e0b7b6d | 6431 | vty->node = BGP_EVPN_NODE; |
4e0b7b6d PG |
6432 | return CMD_SUCCESS; |
6433 | } | |
6434 | ||
505e5056 | 6435 | DEFUN_NOSH (exit_address_family, |
718e3744 | 6436 | exit_address_family_cmd, |
6437 | "exit-address-family", | |
6438 | "Exit from Address Family configuration mode\n") | |
6439 | { | |
a8a80d53 | 6440 | if (vty->node == BGP_IPV4_NODE |
6441 | || vty->node == BGP_IPV4M_NODE | |
f51bae9c | 6442 | || vty->node == BGP_IPV4L_NODE |
718e3744 | 6443 | || vty->node == BGP_VPNV4_NODE |
25ffbdc1 | 6444 | || vty->node == BGP_IPV6_NODE |
8ecd3266 | 6445 | || vty->node == BGP_IPV6M_NODE |
f51bae9c | 6446 | || vty->node == BGP_IPV6L_NODE |
8b1fb8be LB |
6447 | || vty->node == BGP_VPNV6_NODE |
6448 | || vty->node == BGP_ENCAP_NODE | |
4e0b7b6d PG |
6449 | || vty->node == BGP_ENCAPV6_NODE |
6450 | || vty->node == BGP_EVPN_NODE) | |
718e3744 | 6451 | vty->node = BGP_NODE; |
6452 | return CMD_SUCCESS; | |
6453 | } | |
6b0655a2 | 6454 | |
8ad7271d DS |
6455 | /* Recalculate bestpath and re-advertise a prefix */ |
6456 | static int | |
01080f7c | 6457 | bgp_clear_prefix (struct vty *vty, const char *view_name, const char *ip_str, |
8ad7271d DS |
6458 | afi_t afi, safi_t safi, struct prefix_rd *prd) |
6459 | { | |
6460 | int ret; | |
6461 | struct prefix match; | |
6462 | struct bgp_node *rn; | |
6463 | struct bgp_node *rm; | |
8ad7271d DS |
6464 | struct bgp *bgp; |
6465 | struct bgp_table *table; | |
6466 | struct bgp_table *rib; | |
6467 | ||
6468 | /* BGP structure lookup. */ | |
6469 | if (view_name) | |
6470 | { | |
6471 | bgp = bgp_lookup_by_name (view_name); | |
6472 | if (bgp == NULL) | |
6473 | { | |
6aeb9e78 | 6474 | vty_out (vty, "%% Can't find BGP instance %s%s", view_name, VTY_NEWLINE); |
8ad7271d DS |
6475 | return CMD_WARNING; |
6476 | } | |
6477 | } | |
6478 | else | |
6479 | { | |
6480 | bgp = bgp_get_default (); | |
6481 | if (bgp == NULL) | |
6482 | { | |
6483 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
6484 | return CMD_WARNING; | |
6485 | } | |
6486 | } | |
6487 | ||
6488 | /* Check IP address argument. */ | |
6489 | ret = str2prefix (ip_str, &match); | |
6490 | if (! ret) | |
6491 | { | |
6492 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); | |
6493 | return CMD_WARNING; | |
6494 | } | |
6495 | ||
6496 | match.family = afi2family (afi); | |
6497 | rib = bgp->rib[afi][safi]; | |
6498 | ||
6499 | if (safi == SAFI_MPLS_VPN) | |
6500 | { | |
6501 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) | |
6502 | { | |
6503 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) | |
6504 | continue; | |
6505 | ||
6506 | if ((table = rn->info) != NULL) | |
6507 | { | |
6508 | if ((rm = bgp_node_match (table, &match)) != NULL) | |
6509 | { | |
6510 | if (rm->p.prefixlen == match.prefixlen) | |
6511 | { | |
6512 | SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR); | |
6513 | bgp_process (bgp, rm, afi, safi); | |
6514 | } | |
6515 | bgp_unlock_node (rm); | |
6516 | } | |
6517 | } | |
6518 | } | |
6519 | } | |
6520 | else | |
6521 | { | |
6522 | if ((rn = bgp_node_match (rib, &match)) != NULL) | |
6523 | { | |
6524 | if (rn->p.prefixlen == match.prefixlen) | |
6525 | { | |
6526 | SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR); | |
6527 | bgp_process (bgp, rn, afi, safi); | |
6528 | } | |
6529 | bgp_unlock_node (rn); | |
6530 | } | |
6531 | } | |
6532 | ||
6533 | return CMD_SUCCESS; | |
6534 | } | |
6535 | ||
b09b5ae0 | 6536 | /* one clear bgp command to rule them all */ |
718e3744 | 6537 | DEFUN (clear_ip_bgp_all, |
6538 | clear_ip_bgp_all_cmd, | |
46f296b4 | 6539 | "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 | 6540 | CLEAR_STR |
6541 | IP_STR | |
6542 | BGP_STR | |
838758ac | 6543 | BGP_INSTANCE_HELP_STR |
b09b5ae0 DW |
6544 | "Clear all peers\n" |
6545 | "BGP neighbor address to clear\n" | |
a80beece | 6546 | "BGP IPv6 neighbor to clear\n" |
838758ac | 6547 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
6548 | "Clear peers with the AS number\n" |
6549 | "Clear all external peers\n" | |
718e3744 | 6550 | "Clear all members of peer-group\n" |
b09b5ae0 | 6551 | "BGP peer-group name\n" |
46f296b4 LB |
6552 | BGP_AFI_HELP_STR |
6553 | BGP_SAFI_HELP_STR | |
b09b5ae0 DW |
6554 | BGP_SOFT_STR |
6555 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
6556 | BGP_SOFT_OUT_STR |
6557 | BGP_SOFT_IN_STR | |
6558 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 6559 | BGP_SOFT_OUT_STR) |
718e3744 | 6560 | { |
8334fd5a | 6561 | char *vrf = NULL; |
630a298c | 6562 | |
ae19d7dd QY |
6563 | afi_t afi = AFI_IP6; |
6564 | safi_t safi = SAFI_UNICAST; | |
5bf15956 | 6565 | enum clear_sort clr_sort = clear_peer; |
b09b5ae0 DW |
6566 | enum bgp_clear_type clr_type; |
6567 | char *clr_arg = NULL; | |
718e3744 | 6568 | |
ae19d7dd | 6569 | int idx = 0; |
01080f7c | 6570 | |
ae19d7dd QY |
6571 | /* clear [ip] bgp */ |
6572 | if (argv_find (argv, argc, "ip", &idx)) | |
6573 | afi = AFI_IP; | |
6574 | /* [<view|vrf> WORD] */ | |
6575 | if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) | |
838758ac | 6576 | { |
ae19d7dd QY |
6577 | vrf = argv[idx + 1]->arg; |
6578 | idx += 2; | |
838758ac | 6579 | } |
ae19d7dd QY |
6580 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */ |
6581 | if (argv_find (argv, argc, "*", &idx)) | |
b09b5ae0 | 6582 | { |
ae19d7dd | 6583 | clr_sort = clear_all; |
b09b5ae0 | 6584 | } |
ae19d7dd | 6585 | else if (argv_find (argv, argc, "A.B.C.D", &idx)) |
b09b5ae0 DW |
6586 | { |
6587 | clr_sort = clear_peer; | |
ae19d7dd | 6588 | clr_arg = argv[idx]->arg; |
b09b5ae0 | 6589 | } |
ae19d7dd | 6590 | else if (argv_find (argv, argc, "X:X::X:X", &idx)) |
b09b5ae0 | 6591 | { |
ae19d7dd QY |
6592 | clr_sort = clear_peer; |
6593 | clr_arg = argv[idx]->arg; | |
838758ac | 6594 | } |
ae19d7dd | 6595 | else if (argv_find (argv, argc, "peer-group", &idx)) |
b09b5ae0 DW |
6596 | { |
6597 | clr_sort = clear_group; | |
ae19d7dd QY |
6598 | idx++; |
6599 | clr_arg = argv[idx]->arg; | |
b09b5ae0 | 6600 | } |
ae19d7dd | 6601 | else if (argv_find (argv, argc, "WORD", &idx)) |
b09b5ae0 | 6602 | { |
f0dac89f RW |
6603 | clr_sort = clear_peer; |
6604 | clr_arg = argv[idx]->arg; | |
b09b5ae0 | 6605 | } |
ae19d7dd QY |
6606 | else if (argv_find (argv, argc, "(1-4294967295)", &idx)) |
6607 | { | |
6608 | clr_sort = clear_as; | |
6609 | clr_arg = argv[idx]->arg; | |
6610 | } | |
6611 | else if (argv_find (argv, argc, "external", &idx)) | |
6612 | { | |
6613 | clr_sort = clear_external; | |
6614 | } | |
46f296b4 LB |
6615 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
6616 | if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) | |
ae19d7dd | 6617 | { |
46f296b4 | 6618 | argv_find_and_parse_safi (argv, argc, &idx, &safi); |
ae19d7dd QY |
6619 | } |
6620 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
6621 | if (argv_find (argv, argc, "soft", &idx)) | |
6622 | { | |
6623 | if (argv_find (argv, argc, "in", &idx) || argv_find (argv, argc, "out", &idx)) | |
6624 | clr_type = strmatch (argv[idx]->text, "in") ? BGP_CLEAR_SOFT_IN : BGP_CLEAR_SOFT_OUT; | |
6625 | else | |
6626 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
6627 | } | |
6628 | else if (argv_find (argv, argc, "in", &idx)) | |
6629 | { | |
6630 | clr_type = argv_find (argv, argc, "prefix-filter", &idx) ? BGP_CLEAR_SOFT_IN_ORF_PREFIX : BGP_CLEAR_SOFT_IN; | |
6631 | } | |
6632 | else if (argv_find (argv, argc, "out", &idx)) | |
6633 | { | |
5daa3e5e | 6634 | clr_type = BGP_CLEAR_SOFT_OUT; |
ae19d7dd QY |
6635 | } |
6636 | else | |
6637 | clr_type = BGP_CLEAR_SOFT_NONE; | |
718e3744 | 6638 | |
b09b5ae0 | 6639 | return bgp_clear_vty (vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); |
838758ac | 6640 | } |
01080f7c | 6641 | |
8ad7271d DS |
6642 | DEFUN (clear_ip_bgp_prefix, |
6643 | clear_ip_bgp_prefix_cmd, | |
838758ac | 6644 | "clear [ip] bgp [<view|vrf> WORD] prefix A.B.C.D/M", |
8ad7271d DS |
6645 | CLEAR_STR |
6646 | IP_STR | |
6647 | BGP_STR | |
838758ac | 6648 | BGP_INSTANCE_HELP_STR |
8ad7271d | 6649 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 6650 | "IPv4 prefix\n") |
8ad7271d | 6651 | { |
8334fd5a | 6652 | char *vrf = NULL; |
630a298c | 6653 | char *prefix = NULL; |
8ad7271d | 6654 | |
630a298c | 6655 | int idx = 0; |
01080f7c | 6656 | |
630a298c QY |
6657 | /* [<view|vrf> WORD] */ |
6658 | if (argv_find (argv, argc, "WORD", &idx)) | |
6659 | vrf = argv[idx]->arg; | |
0c7b1b01 | 6660 | |
630a298c | 6661 | prefix = argv[argc-1]->arg; |
8ad7271d | 6662 | |
630a298c | 6663 | return bgp_clear_prefix (vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 6664 | } |
8ad7271d | 6665 | |
b09b5ae0 DW |
6666 | DEFUN (clear_bgp_ipv6_safi_prefix, |
6667 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 6668 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 6669 | CLEAR_STR |
3a2d747c | 6670 | IP_STR |
718e3744 | 6671 | BGP_STR |
8c3deaae | 6672 | "Address Family\n" |
46f296b4 | 6673 | BGP_SAFI_HELP_STR |
b09b5ae0 | 6674 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 6675 | "IPv6 prefix\n") |
718e3744 | 6676 | { |
b09b5ae0 DW |
6677 | int idx_safi = 3; |
6678 | int idx_ipv6_prefixlen = 5; | |
46f296b4 LB |
6679 | return bgp_clear_prefix (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, |
6680 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), NULL); | |
838758ac | 6681 | } |
01080f7c | 6682 | |
b09b5ae0 DW |
6683 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
6684 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
46f296b4 | 6685 | "clear [ip] bgp <view|vrf> WORD ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 6686 | CLEAR_STR |
3a2d747c | 6687 | IP_STR |
718e3744 | 6688 | BGP_STR |
838758ac | 6689 | BGP_INSTANCE_HELP_STR |
8c3deaae | 6690 | "Address Family\n" |
46f296b4 | 6691 | BGP_SAFI_HELP_STR |
b09b5ae0 | 6692 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 6693 | "IPv6 prefix\n") |
718e3744 | 6694 | { |
b09b5ae0 | 6695 | int idx_word = 3; |
c500ae40 | 6696 | int idx_safi = 5; |
b09b5ae0 | 6697 | int idx_ipv6_prefixlen = 7; |
46f296b4 LB |
6698 | return bgp_clear_prefix (vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, |
6699 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), NULL); | |
718e3744 | 6700 | } |
6701 | ||
b09b5ae0 DW |
6702 | DEFUN (show_bgp_views, |
6703 | show_bgp_views_cmd, | |
d6e3c605 | 6704 | "show [ip] bgp views", |
b09b5ae0 | 6705 | SHOW_STR |
d6e3c605 | 6706 | IP_STR |
01080f7c | 6707 | BGP_STR |
b09b5ae0 | 6708 | "Show the defined BGP views\n") |
01080f7c | 6709 | { |
b09b5ae0 DW |
6710 | struct list *inst = bm->bgp; |
6711 | struct listnode *node; | |
6712 | struct bgp *bgp; | |
01080f7c | 6713 | |
b09b5ae0 DW |
6714 | if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE)) |
6715 | { | |
6716 | vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE); | |
6717 | return CMD_WARNING; | |
6718 | } | |
e52702f2 | 6719 | |
b09b5ae0 DW |
6720 | vty_out (vty, "Defined BGP views:%s", VTY_NEWLINE); |
6721 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) | |
6722 | { | |
6723 | /* Skip VRFs. */ | |
6724 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
6725 | continue; | |
6726 | vty_out (vty, "\t%s (AS%u)%s", | |
6727 | bgp->name ? bgp->name : "(null)", | |
6728 | bgp->as, VTY_NEWLINE); | |
6729 | } | |
e52702f2 | 6730 | |
b09b5ae0 | 6731 | return CMD_SUCCESS; |
e0081f70 ML |
6732 | } |
6733 | ||
8386ac43 | 6734 | DEFUN (show_bgp_vrfs, |
6735 | show_bgp_vrfs_cmd, | |
d6e3c605 | 6736 | "show [ip] bgp vrfs [json]", |
8386ac43 | 6737 | SHOW_STR |
d6e3c605 | 6738 | IP_STR |
8386ac43 | 6739 | BGP_STR |
6740 | "Show BGP VRFs\n" | |
9973d184 | 6741 | JSON_STR) |
8386ac43 | 6742 | { |
6743 | struct list *inst = bm->bgp; | |
6744 | struct listnode *node; | |
6745 | struct bgp *bgp; | |
6746 | u_char uj = use_json(argc, argv); | |
6747 | json_object *json = NULL; | |
6748 | json_object *json_vrfs = NULL; | |
6749 | int count = 0; | |
6750 | static char header[] = "Type Id RouterId #PeersCfg #PeersEstb Name"; | |
6751 | ||
6752 | if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE)) | |
6753 | { | |
6754 | vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE); | |
6755 | return CMD_WARNING; | |
6756 | } | |
6757 | ||
6758 | if (uj) | |
6759 | { | |
6760 | json = json_object_new_object(); | |
6761 | json_vrfs = json_object_new_object(); | |
6762 | } | |
6763 | ||
6764 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) | |
6765 | { | |
6766 | const char *name, *type; | |
6767 | struct peer *peer; | |
6768 | struct listnode *node, *nnode; | |
6769 | int peers_cfg, peers_estb; | |
6770 | json_object *json_vrf = NULL; | |
5c81a5f3 | 6771 | int vrf_id_ui; |
8386ac43 | 6772 | |
6773 | /* Skip Views. */ | |
6774 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
6775 | continue; | |
6776 | ||
6777 | count++; | |
6778 | if (!uj && count == 1) | |
6779 | vty_out (vty, "%s%s", header, VTY_NEWLINE); | |
6780 | ||
6781 | peers_cfg = peers_estb = 0; | |
6782 | if (uj) | |
6783 | json_vrf = json_object_new_object(); | |
6784 | ||
6785 | ||
6786 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
6787 | { | |
6788 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6789 | continue; | |
6790 | peers_cfg++; | |
6791 | if (peer->status == Established) | |
6792 | peers_estb++; | |
6793 | } | |
6794 | ||
6795 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
6796 | { | |
6797 | name = "Default"; | |
6798 | type = "DFLT"; | |
6799 | } | |
6800 | else | |
6801 | { | |
6802 | name = bgp->name; | |
6803 | type = "VRF"; | |
6804 | } | |
6805 | ||
5c81a5f3 | 6806 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id; |
8386ac43 | 6807 | if (uj) |
6808 | { | |
6809 | json_object_string_add(json_vrf, "type", type); | |
5c81a5f3 | 6810 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); |
8386ac43 | 6811 | json_object_string_add(json_vrf, "routerId", inet_ntoa (bgp->router_id)); |
6812 | json_object_int_add(json_vrf, "numConfiguredPeers", peers_cfg); | |
6813 | json_object_int_add(json_vrf, "numEstablishedPeers", peers_estb); | |
6814 | ||
6815 | json_object_object_add(json_vrfs, name, json_vrf); | |
6816 | } | |
6817 | else | |
5c81a5f3 | 6818 | vty_out (vty, "%4s %-5d %-16s %9u %10u %s%s", |
6819 | type, vrf_id_ui, inet_ntoa (bgp->router_id), | |
8386ac43 | 6820 | peers_cfg, peers_estb, name, |
6821 | VTY_NEWLINE); | |
6822 | } | |
6823 | ||
6824 | if (uj) | |
6825 | { | |
6826 | json_object_object_add(json, "vrfs", json_vrfs); | |
6827 | ||
6828 | json_object_int_add(json, "totalVrfs", count); | |
6829 | ||
2aac5767 | 6830 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
8386ac43 | 6831 | json_object_free(json); |
6832 | } | |
6833 | else | |
6834 | { | |
6835 | if (count) | |
6836 | vty_out (vty, "%sTotal number of VRFs (including default): %d%s", | |
6837 | VTY_NEWLINE, count, VTY_NEWLINE); | |
6838 | } | |
6839 | ||
6840 | return CMD_SUCCESS; | |
6841 | } | |
6842 | ||
f412b39a | 6843 | DEFUN (show_bgp_memory, |
4bf6a362 | 6844 | show_bgp_memory_cmd, |
7fa12b13 | 6845 | "show [ip] bgp memory", |
4bf6a362 | 6846 | SHOW_STR |
3a2d747c | 6847 | IP_STR |
4bf6a362 PJ |
6848 | BGP_STR |
6849 | "Global BGP memory statistics\n") | |
6850 | { | |
6851 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
6852 | unsigned long count; | |
e52702f2 | 6853 | |
4bf6a362 PJ |
6854 | /* RIB related usage stats */ |
6855 | count = mtype_stats_alloc (MTYPE_BGP_NODE); | |
6856 | vty_out (vty, "%ld RIB nodes, using %s of memory%s", count, | |
6857 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6858 | count * sizeof (struct bgp_node)), | |
6859 | VTY_NEWLINE); | |
e52702f2 | 6860 | |
4bf6a362 PJ |
6861 | count = mtype_stats_alloc (MTYPE_BGP_ROUTE); |
6862 | vty_out (vty, "%ld BGP routes, using %s of memory%s", count, | |
6863 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6864 | count * sizeof (struct bgp_info)), | |
6865 | VTY_NEWLINE); | |
fb982c25 PJ |
6866 | if ((count = mtype_stats_alloc (MTYPE_BGP_ROUTE_EXTRA))) |
6867 | vty_out (vty, "%ld BGP route ancillaries, using %s of memory%s", count, | |
6868 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6869 | count * sizeof (struct bgp_info_extra)), | |
6870 | VTY_NEWLINE); | |
e52702f2 | 6871 | |
4bf6a362 PJ |
6872 | if ((count = mtype_stats_alloc (MTYPE_BGP_STATIC))) |
6873 | vty_out (vty, "%ld Static routes, using %s of memory%s", count, | |
6874 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6875 | count * sizeof (struct bgp_static)), | |
6876 | VTY_NEWLINE); | |
3f9c7369 DS |
6877 | |
6878 | if ((count = mtype_stats_alloc (MTYPE_BGP_PACKET))) | |
6879 | vty_out (vty, "%ld Packets, using %s of memory%s", count, | |
6880 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6881 | count * sizeof (struct bpacket)), | |
6882 | VTY_NEWLINE); | |
e52702f2 | 6883 | |
4bf6a362 PJ |
6884 | /* Adj-In/Out */ |
6885 | if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_IN))) | |
6886 | vty_out (vty, "%ld Adj-In entries, using %s of memory%s", count, | |
6887 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6888 | count * sizeof (struct bgp_adj_in)), | |
6889 | VTY_NEWLINE); | |
6890 | if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_OUT))) | |
6891 | vty_out (vty, "%ld Adj-Out entries, using %s of memory%s", count, | |
6892 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6893 | count * sizeof (struct bgp_adj_out)), | |
6894 | VTY_NEWLINE); | |
e52702f2 | 6895 | |
4bf6a362 PJ |
6896 | if ((count = mtype_stats_alloc (MTYPE_BGP_NEXTHOP_CACHE))) |
6897 | vty_out (vty, "%ld Nexthop cache entries, using %s of memory%s", count, | |
6898 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6899 | count * sizeof (struct bgp_nexthop_cache)), | |
6900 | VTY_NEWLINE); | |
6901 | ||
6902 | if ((count = mtype_stats_alloc (MTYPE_BGP_DAMP_INFO))) | |
6903 | vty_out (vty, "%ld Dampening entries, using %s of memory%s", count, | |
6904 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6905 | count * sizeof (struct bgp_damp_info)), | |
6906 | VTY_NEWLINE); | |
6907 | ||
6908 | /* Attributes */ | |
6909 | count = attr_count(); | |
e52702f2 QY |
6910 | vty_out (vty, "%ld BGP attributes, using %s of memory%s", count, |
6911 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6912 | count * sizeof(struct attr)), | |
4bf6a362 | 6913 | VTY_NEWLINE); |
fb982c25 | 6914 | if ((count = mtype_stats_alloc (MTYPE_ATTR_EXTRA))) |
e52702f2 QY |
6915 | vty_out (vty, "%ld BGP extra attributes, using %s of memory%s", count, |
6916 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6917 | count * sizeof(struct attr_extra)), | |
fb982c25 | 6918 | VTY_NEWLINE); |
e52702f2 | 6919 | |
4bf6a362 PJ |
6920 | if ((count = attr_unknown_count())) |
6921 | vty_out (vty, "%ld unknown attributes%s", count, VTY_NEWLINE); | |
e52702f2 | 6922 | |
4bf6a362 PJ |
6923 | /* AS_PATH attributes */ |
6924 | count = aspath_count (); | |
6925 | vty_out (vty, "%ld BGP AS-PATH entries, using %s of memory%s", count, | |
6926 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6927 | count * sizeof (struct aspath)), | |
6928 | VTY_NEWLINE); | |
e52702f2 | 6929 | |
4bf6a362 PJ |
6930 | count = mtype_stats_alloc (MTYPE_AS_SEG); |
6931 | vty_out (vty, "%ld BGP AS-PATH segments, using %s of memory%s", count, | |
6932 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6933 | count * sizeof (struct assegment)), | |
6934 | VTY_NEWLINE); | |
e52702f2 | 6935 | |
4bf6a362 PJ |
6936 | /* Other attributes */ |
6937 | if ((count = community_count ())) | |
6938 | vty_out (vty, "%ld BGP community entries, using %s of memory%s", count, | |
6939 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6940 | count * sizeof (struct community)), | |
6941 | VTY_NEWLINE); | |
6942 | if ((count = mtype_stats_alloc (MTYPE_ECOMMUNITY))) | |
6943 | vty_out (vty, "%ld BGP community entries, using %s of memory%s", count, | |
6944 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6945 | count * sizeof (struct ecommunity)), | |
6946 | VTY_NEWLINE); | |
57d187bc JS |
6947 | if ((count = mtype_stats_alloc (MTYPE_LCOMMUNITY))) |
6948 | vty_out (vty, "%ld BGP large-community entries, using %s of memory%s", | |
2acb4ac2 | 6949 | count, |
57d187bc JS |
6950 | mtype_memstr (memstrbuf, sizeof (memstrbuf), |
6951 | count * sizeof (struct lcommunity)), | |
6952 | VTY_NEWLINE); | |
e52702f2 | 6953 | |
4bf6a362 PJ |
6954 | if ((count = mtype_stats_alloc (MTYPE_CLUSTER))) |
6955 | vty_out (vty, "%ld Cluster lists, using %s of memory%s", count, | |
6956 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6957 | count * sizeof (struct cluster_list)), | |
6958 | VTY_NEWLINE); | |
e52702f2 | 6959 | |
4bf6a362 PJ |
6960 | /* Peer related usage */ |
6961 | count = mtype_stats_alloc (MTYPE_BGP_PEER); | |
6962 | vty_out (vty, "%ld peers, using %s of memory%s", count, | |
6963 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6964 | count * sizeof (struct peer)), | |
6965 | VTY_NEWLINE); | |
e52702f2 | 6966 | |
4a1ab8e4 | 6967 | if ((count = mtype_stats_alloc (MTYPE_PEER_GROUP))) |
4bf6a362 PJ |
6968 | vty_out (vty, "%ld peer groups, using %s of memory%s", count, |
6969 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6970 | count * sizeof (struct peer_group)), | |
6971 | VTY_NEWLINE); | |
e52702f2 | 6972 | |
4bf6a362 PJ |
6973 | /* Other */ |
6974 | if ((count = mtype_stats_alloc (MTYPE_HASH))) | |
6975 | vty_out (vty, "%ld hash tables, using %s of memory%s", count, | |
6976 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6977 | count * sizeof (struct hash)), | |
6978 | VTY_NEWLINE); | |
6979 | if ((count = mtype_stats_alloc (MTYPE_HASH_BACKET))) | |
6980 | vty_out (vty, "%ld hash buckets, using %s of memory%s", count, | |
6981 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6982 | count * sizeof (struct hash_backet)), | |
6983 | VTY_NEWLINE); | |
6984 | if ((count = mtype_stats_alloc (MTYPE_BGP_REGEXP))) | |
6985 | vty_out (vty, "%ld compiled regexes, using %s of memory%s", count, | |
6986 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6987 | count * sizeof (regex_t)), | |
6988 | VTY_NEWLINE); | |
6989 | return CMD_SUCCESS; | |
6990 | } | |
fee0f4c6 | 6991 | |
718e3744 | 6992 | /* Show BGP peer's summary information. */ |
94f2b392 | 6993 | static int |
b05a1c8b | 6994 | bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi, |
9f689658 | 6995 | u_char use_json, json_object *json) |
718e3744 | 6996 | { |
6997 | struct peer *peer; | |
1eb8ef25 | 6998 | struct listnode *node, *nnode; |
f14e6fdb DS |
6999 | unsigned int count = 0, dn_count = 0; |
7000 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
f933309e DW |
7001 | char neighbor_buf[VTY_BUFSIZ]; |
7002 | int neighbor_col_default_width = 16; | |
718e3744 | 7003 | int len; |
f933309e | 7004 | int max_neighbor_width = 0; |
ffd0c037 DS |
7005 | json_object *json_peer = NULL; |
7006 | json_object *json_peers = NULL; | |
718e3744 | 7007 | |
b05a1c8b DS |
7008 | if (use_json) |
7009 | { | |
9f689658 DD |
7010 | if (json == NULL) |
7011 | json = json_object_new_object(); | |
7012 | ||
f1aa5d8a | 7013 | json_peers = json_object_new_object(); |
b05a1c8b | 7014 | } |
f933309e DW |
7015 | else |
7016 | { | |
7017 | /* Loop over all neighbors that will be displayed to determine how many | |
7018 | * characters are needed for the Neighbor column | |
7019 | */ | |
7020 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
7021 | { | |
7022 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
7023 | continue; | |
7024 | ||
7025 | if (peer->afc[afi][safi]) | |
7026 | { | |
c9d5bd27 DS |
7027 | memset(dn_flag, '\0', sizeof(dn_flag)); |
7028 | if (peer_dynamic_neighbor(peer)) | |
7029 | dn_flag[0] = '*'; | |
7030 | ||
f933309e DW |
7031 | if (peer->hostname && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) |
7032 | sprintf(neighbor_buf, "%s%s(%s) ", dn_flag, peer->hostname, peer->host); | |
7033 | else | |
7034 | sprintf(neighbor_buf, "%s%s ", dn_flag, peer->host); | |
7035 | ||
7036 | len = strlen(neighbor_buf); | |
7037 | ||
7038 | if (len > max_neighbor_width) | |
7039 | max_neighbor_width = len; | |
7040 | } | |
7041 | } | |
7042 | ||
7043 | /* Originally we displayed the Neighbor column as 16 | |
7044 | * characters wide so make that the default | |
7045 | */ | |
7046 | if (max_neighbor_width < neighbor_col_default_width) | |
7047 | max_neighbor_width = neighbor_col_default_width; | |
7048 | } | |
b05a1c8b | 7049 | |
1eb8ef25 | 7050 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
718e3744 | 7051 | { |
1ff9a340 DS |
7052 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
7053 | continue; | |
7054 | ||
718e3744 | 7055 | if (peer->afc[afi][safi]) |
7056 | { | |
b05a1c8b | 7057 | if (!count) |
4bf6a362 PJ |
7058 | { |
7059 | unsigned long ents; | |
7060 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
5c81a5f3 | 7061 | int vrf_id_ui; |
7062 | ||
7063 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id; | |
b05a1c8b | 7064 | |
4bf6a362 | 7065 | /* Usage summary and header */ |
b05a1c8b DS |
7066 | if (use_json) |
7067 | { | |
62d6dca0 | 7068 | json_object_string_add(json, "routerId", inet_ntoa (bgp->router_id)); |
f1aa5d8a | 7069 | json_object_int_add(json, "as", bgp->as); |
9f689658 DD |
7070 | json_object_int_add(json, "vrfId", vrf_id_ui); |
7071 | json_object_string_add(json, "vrfName", | |
7072 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
7073 | ? "Default" : bgp->name); | |
b05a1c8b DS |
7074 | } |
7075 | else | |
7076 | { | |
7077 | vty_out (vty, | |
5c81a5f3 | 7078 | "BGP router identifier %s, local AS number %u vrf-id %d", |
7079 | inet_ntoa (bgp->router_id), bgp->as, vrf_id_ui); | |
6aeb9e78 | 7080 | vty_out (vty, "%s", VTY_NEWLINE); |
b05a1c8b DS |
7081 | } |
7082 | ||
f188f2c4 DS |
7083 | if (bgp_update_delay_configured(bgp)) |
7084 | { | |
b05a1c8b | 7085 | if (use_json) |
f188f2c4 | 7086 | { |
62d6dca0 | 7087 | json_object_int_add(json, "updateDelayLimit", bgp->v_update_delay); |
b05a1c8b DS |
7088 | |
7089 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
62d6dca0 | 7090 | json_object_int_add(json, "updateDelayEstablishWait", bgp->v_establish_wait); |
b05a1c8b DS |
7091 | |
7092 | if (bgp_update_delay_active(bgp)) | |
7093 | { | |
62d6dca0 DS |
7094 | json_object_string_add(json, "updateDelayFirstNeighbor", bgp->update_delay_begin_time); |
7095 | json_object_boolean_true_add(json, "updateDelayInProgress"); | |
b05a1c8b DS |
7096 | } |
7097 | else | |
7098 | { | |
7099 | if (bgp->update_delay_over) | |
7100 | { | |
62d6dca0 | 7101 | json_object_string_add(json, "updateDelayFirstNeighbor", |
f1aa5d8a | 7102 | bgp->update_delay_begin_time); |
62d6dca0 | 7103 | json_object_string_add(json, "updateDelayBestpathResumed", |
f1aa5d8a | 7104 | bgp->update_delay_end_time); |
62d6dca0 | 7105 | json_object_string_add(json, "updateDelayZebraUpdateResume", |
f1aa5d8a | 7106 | bgp->update_delay_zebra_resume_time); |
62d6dca0 | 7107 | json_object_string_add(json, "updateDelayPeerUpdateResume", |
f1aa5d8a | 7108 | bgp->update_delay_peers_resume_time); |
b05a1c8b DS |
7109 | } |
7110 | } | |
f188f2c4 DS |
7111 | } |
7112 | else | |
7113 | { | |
b05a1c8b DS |
7114 | vty_out (vty, "Read-only mode update-delay limit: %d seconds%s", |
7115 | bgp->v_update_delay, VTY_NEWLINE); | |
7116 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
7117 | vty_out (vty, " Establish wait: %d seconds%s", | |
7118 | bgp->v_establish_wait, VTY_NEWLINE); | |
7119 | ||
7120 | if (bgp_update_delay_active(bgp)) | |
f188f2c4 DS |
7121 | { |
7122 | vty_out (vty, " First neighbor established: %s%s", | |
7123 | bgp->update_delay_begin_time, VTY_NEWLINE); | |
b05a1c8b DS |
7124 | vty_out (vty, " Delay in progress%s", VTY_NEWLINE); |
7125 | } | |
7126 | else | |
7127 | { | |
7128 | if (bgp->update_delay_over) | |
7129 | { | |
7130 | vty_out (vty, " First neighbor established: %s%s", | |
7131 | bgp->update_delay_begin_time, VTY_NEWLINE); | |
7132 | vty_out (vty, " Best-paths resumed: %s%s", | |
7133 | bgp->update_delay_end_time, VTY_NEWLINE); | |
7134 | vty_out (vty, " zebra update resumed: %s%s", | |
7135 | bgp->update_delay_zebra_resume_time, VTY_NEWLINE); | |
7136 | vty_out (vty, " peers update resumed: %s%s", | |
7137 | bgp->update_delay_peers_resume_time, VTY_NEWLINE); | |
7138 | } | |
f188f2c4 DS |
7139 | } |
7140 | } | |
7141 | } | |
4bf6a362 | 7142 | |
b05a1c8b DS |
7143 | if (use_json) |
7144 | { | |
7145 | if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active) | |
62d6dca0 | 7146 | json_object_boolean_true_add(json, "maxMedOnStartup"); |
b05a1c8b | 7147 | if (bgp->v_maxmed_admin) |
62d6dca0 | 7148 | json_object_boolean_true_add(json, "maxMedAdministrative"); |
b05a1c8b | 7149 | |
62d6dca0 | 7150 | json_object_int_add(json, "tableVersion", bgp_table_version(bgp->rib[afi][safi])); |
b05a1c8b DS |
7151 | |
7152 | ents = bgp_table_count (bgp->rib[afi][safi]); | |
62d6dca0 DS |
7153 | json_object_int_add(json, "ribCount", ents); |
7154 | json_object_int_add(json, "ribMemory", ents * sizeof (struct bgp_node)); | |
b05a1c8b DS |
7155 | |
7156 | ents = listcount (bgp->peer); | |
62d6dca0 DS |
7157 | json_object_int_add(json, "peerCount", ents); |
7158 | json_object_int_add(json, "peerMemory", ents * sizeof (struct peer)); | |
b05a1c8b | 7159 | |
b05a1c8b DS |
7160 | if ((ents = listcount (bgp->group))) |
7161 | { | |
62d6dca0 DS |
7162 | json_object_int_add(json, "peerGroupCount", ents); |
7163 | json_object_int_add(json, "peerGroupMemory", ents * sizeof (struct peer_group)); | |
b05a1c8b | 7164 | } |
3f9c7369 | 7165 | |
b05a1c8b | 7166 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) |
62d6dca0 | 7167 | json_object_boolean_true_add(json, "dampeningEnabled"); |
b05a1c8b DS |
7168 | } |
7169 | else | |
7170 | { | |
7171 | if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active) | |
7172 | vty_out (vty, "Max-med on-startup active%s", VTY_NEWLINE); | |
7173 | if (bgp->v_maxmed_admin) | |
7174 | vty_out (vty, "Max-med administrative active%s", VTY_NEWLINE); | |
7175 | ||
ffd0c037 | 7176 | vty_out(vty, "BGP table version %" PRIu64 "%s", |
b05a1c8b DS |
7177 | bgp_table_version(bgp->rib[afi][safi]), VTY_NEWLINE); |
7178 | ||
7179 | ents = bgp_table_count (bgp->rib[afi][safi]); | |
7180 | vty_out (vty, "RIB entries %ld, using %s of memory%s", ents, | |
7181 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
7182 | ents * sizeof (struct bgp_node)), | |
7183 | VTY_NEWLINE); | |
7184 | ||
7185 | /* Peer related usage */ | |
7186 | ents = listcount (bgp->peer); | |
7187 | vty_out (vty, "Peers %ld, using %s of memory%s", | |
7188 | ents, | |
7189 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
7190 | ents * sizeof (struct peer)), | |
7191 | VTY_NEWLINE); | |
7192 | ||
b05a1c8b DS |
7193 | if ((ents = listcount (bgp->group))) |
7194 | vty_out (vty, "Peer groups %ld, using %s of memory%s", ents, | |
7195 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
7196 | ents * sizeof (struct peer_group)), | |
7197 | VTY_NEWLINE); | |
7198 | ||
7199 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) | |
7200 | vty_out (vty, "Dampening enabled.%s", VTY_NEWLINE); | |
7201 | vty_out (vty, "%s", VTY_NEWLINE); | |
f933309e DW |
7202 | |
7203 | /* Subtract 8 here because 'Neighbor' is 8 characters */ | |
7204 | vty_out (vty, "Neighbor"); | |
7205 | vty_out (vty, "%*s", max_neighbor_width - 8, " "); | |
7206 | vty_out (vty, "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd%s", VTY_NEWLINE); | |
b05a1c8b | 7207 | } |
4bf6a362 | 7208 | } |
e52702f2 | 7209 | |
b05a1c8b | 7210 | count++; |
718e3744 | 7211 | |
b05a1c8b DS |
7212 | if (use_json) |
7213 | { | |
7214 | json_peer = json_object_new_object(); | |
f14e6fdb | 7215 | |
b05a1c8b | 7216 | if (peer_dynamic_neighbor(peer)) |
62d6dca0 | 7217 | json_object_boolean_true_add(json_peer, "dynamicPeer"); |
b05a1c8b | 7218 | |
04b6bdc0 DW |
7219 | if (peer->hostname) |
7220 | json_object_string_add(json_peer, "hostname", peer->hostname); | |
7221 | ||
7222 | if (peer->domainname) | |
7223 | json_object_string_add(json_peer, "domainname", peer->domainname); | |
7224 | ||
62d6dca0 | 7225 | json_object_int_add(json_peer, "remoteAs", peer->as); |
f1aa5d8a | 7226 | json_object_int_add(json_peer, "version", 4); |
62d6dca0 | 7227 | json_object_int_add(json_peer, "msgRcvd", |
f1aa5d8a DS |
7228 | peer->open_in + peer->update_in + peer->keepalive_in |
7229 | + peer->notify_in + peer->refresh_in | |
7230 | + peer->dynamic_cap_in); | |
62d6dca0 | 7231 | json_object_int_add(json_peer, "msgSent", |
f1aa5d8a DS |
7232 | peer->open_out + peer->update_out + peer->keepalive_out |
7233 | + peer->notify_out + peer->refresh_out | |
7234 | + peer->dynamic_cap_out); | |
7235 | ||
62d6dca0 | 7236 | json_object_int_add(json_peer, "tableVersion", peer->version[afi][safi]); |
f1aa5d8a DS |
7237 | json_object_int_add(json_peer, "outq", peer->obuf->count); |
7238 | json_object_int_add(json_peer, "inq", 0); | |
856ca177 | 7239 | peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, use_json, json_peer); |
62d6dca0 | 7240 | json_object_int_add(json_peer, "prefixReceivedCount", peer->pcount[afi][safi]); |
b05a1c8b DS |
7241 | |
7242 | if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) | |
f1aa5d8a | 7243 | json_object_string_add(json_peer, "state", "Idle (Admin)"); |
b05a1c8b | 7244 | else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) |
f1aa5d8a | 7245 | json_object_string_add(json_peer, "state", "Idle (PfxCt)"); |
b05a1c8b | 7246 | else |
f1aa5d8a | 7247 | json_object_string_add(json_peer, "state", LOOKUP(bgp_status_msg, peer->status)); |
b05a1c8b | 7248 | |
f1aa5d8a | 7249 | if (peer->conf_if) |
62d6dca0 | 7250 | json_object_string_add(json_peer, "idType", "interface"); |
f1aa5d8a | 7251 | else if (peer->su.sa.sa_family == AF_INET) |
62d6dca0 | 7252 | json_object_string_add(json_peer, "idType", "ipv4"); |
f1aa5d8a | 7253 | else if (peer->su.sa.sa_family == AF_INET6) |
62d6dca0 | 7254 | json_object_string_add(json_peer, "idType", "ipv6"); |
b05a1c8b | 7255 | |
f1aa5d8a | 7256 | json_object_object_add(json_peers, peer->host, json_peer); |
b05a1c8b DS |
7257 | } |
7258 | else | |
7259 | { | |
7260 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
7261 | if (peer_dynamic_neighbor(peer)) | |
7262 | { | |
7263 | dn_count++; | |
7264 | dn_flag[0] = '*'; | |
7265 | } | |
7266 | ||
04b6bdc0 DW |
7267 | if (peer->hostname && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) |
7268 | len = vty_out (vty, "%s%s(%s)", dn_flag, peer->hostname, | |
7269 | peer->host); | |
7270 | else | |
7271 | len = vty_out (vty, "%s%s", dn_flag, peer->host); | |
b05a1c8b | 7272 | |
f933309e DW |
7273 | /* pad the neighbor column with spaces */ |
7274 | if (len < max_neighbor_width) | |
7275 | vty_out (vty, "%*s", max_neighbor_width - len, " "); | |
b05a1c8b | 7276 | |
f933309e | 7277 | vty_out (vty, "4 %10u %7d %7d %8" PRIu64 " %4d %4zd %8s", |
b05a1c8b DS |
7278 | peer->as, |
7279 | peer->open_in + peer->update_in + peer->keepalive_in | |
7280 | + peer->notify_in + peer->refresh_in | |
7281 | + peer->dynamic_cap_in, | |
7282 | peer->open_out + peer->update_out + peer->keepalive_out | |
7283 | + peer->notify_out + peer->refresh_out | |
7284 | + peer->dynamic_cap_out, | |
7285 | peer->version[afi][safi], | |
7286 | 0, | |
f933309e | 7287 | peer->obuf->count, |
856ca177 | 7288 | peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL)); |
b05a1c8b DS |
7289 | |
7290 | if (peer->status == Established) | |
46f8c104 | 7291 | vty_out (vty, " %12ld", peer->pcount[afi][safi]); |
b05a1c8b DS |
7292 | else |
7293 | { | |
7294 | if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) | |
7295 | vty_out (vty, " Idle (Admin)"); | |
7296 | else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) | |
7297 | vty_out (vty, " Idle (PfxCt)"); | |
7298 | else | |
f933309e | 7299 | vty_out (vty, " %12s", LOOKUP(bgp_status_msg, peer->status)); |
b05a1c8b DS |
7300 | } |
7301 | vty_out (vty, "%s", VTY_NEWLINE); | |
7302 | } | |
718e3744 | 7303 | } |
7304 | } | |
7305 | ||
b05a1c8b DS |
7306 | if (use_json) |
7307 | { | |
7308 | json_object_object_add(json, "peers", json_peers); | |
14151a32 | 7309 | |
62d6dca0 DS |
7310 | json_object_int_add(json, "totalPeers", count); |
7311 | json_object_int_add(json, "dynamicPeers", dn_count); | |
14151a32 | 7312 | |
2aac5767 | 7313 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
f1aa5d8a | 7314 | json_object_free(json); |
b05a1c8b DS |
7315 | } |
7316 | else | |
f14e6fdb | 7317 | { |
b05a1c8b DS |
7318 | if (count) |
7319 | vty_out (vty, "%sTotal number of neighbors %d%s", VTY_NEWLINE, | |
7320 | count, VTY_NEWLINE); | |
7321 | else | |
9f689658 DD |
7322 | { |
7323 | if (use_json) | |
7324 | vty_out(vty, "{\"error\": {\"message\": \"No %s neighbor configured\"}}%s", | |
46f296b4 | 7325 | afi_safi_print(afi, safi), VTY_NEWLINE); |
9f689658 DD |
7326 | else |
7327 | vty_out (vty, "No %s neighbor is configured%s", | |
46f296b4 | 7328 | afi_safi_print(afi, safi), VTY_NEWLINE); |
9f689658 | 7329 | } |
b05a1c8b | 7330 | |
9f689658 | 7331 | if (dn_count && ! use_json) |
b05a1c8b DS |
7332 | { |
7333 | vty_out(vty, "* - dynamic neighbor%s", VTY_NEWLINE); | |
7334 | vty_out(vty, | |
7335 | "%d dynamic neighbor(s), limit %d%s", | |
7336 | dn_count, bgp->dynamic_neighbors_limit, VTY_NEWLINE); | |
7337 | } | |
f14e6fdb DS |
7338 | } |
7339 | ||
718e3744 | 7340 | return CMD_SUCCESS; |
7341 | } | |
7342 | ||
798c3572 DS |
7343 | /* |
7344 | * Return if we have a peer configured to use this afi/safi | |
7345 | */ | |
7346 | static int | |
7347 | bgp_show_summary_afi_safi_peer_exists (struct bgp *bgp, int afi, int safi) | |
7348 | { | |
7349 | struct listnode *node; | |
7350 | struct peer *peer; | |
7351 | ||
7352 | for (ALL_LIST_ELEMENTS_RO (bgp->peer, node, peer)) | |
7353 | { | |
7354 | if (!CHECK_FLAG (peer->flags, PEER_FLAG_CONFIG_NODE)) | |
7355 | continue; | |
7356 | ||
7357 | if (peer->afc[afi][safi]) | |
7358 | return 1; | |
7359 | } | |
7360 | ||
7361 | return 0; | |
7362 | } | |
7363 | ||
27162734 LB |
7364 | static void |
7365 | bgp_show_summary_afi_safi (struct vty *vty, struct bgp *bgp, int afi, int safi, | |
7366 | u_char use_json, json_object *json) | |
7367 | { | |
7368 | int is_first = 1; | |
7369 | int afi_wildcard = (afi == AFI_MAX); | |
7370 | int safi_wildcard = (safi == SAFI_MAX); | |
7371 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
5ce77b2b | 7372 | bool json_output = false; |
798c3572 | 7373 | |
27162734 LB |
7374 | if (use_json && is_wildcard) |
7375 | vty_out (vty, "{%s", VTY_NEWLINE); | |
7376 | if (afi_wildcard) | |
7377 | afi = 1; /* AFI_IP */ | |
7378 | while (afi < AFI_MAX) | |
7379 | { | |
7380 | if (safi_wildcard) | |
7381 | safi = 1; /* SAFI_UNICAST */ | |
7382 | while (safi < SAFI_MAX) | |
7383 | { | |
798c3572 | 7384 | if (bgp_show_summary_afi_safi_peer_exists (bgp, afi, safi)) |
27162734 | 7385 | { |
5ce77b2b | 7386 | json_output = true; |
798c3572 | 7387 | if (is_wildcard) |
27162734 | 7388 | { |
798c3572 DS |
7389 | /* |
7390 | * So limit output to those afi/safi pairs that | |
7391 | * actualy have something interesting in them | |
7392 | */ | |
7393 | if (use_json) | |
7394 | { | |
7395 | json = json_object_new_object(); | |
27162734 | 7396 | |
798c3572 DS |
7397 | if (! is_first) |
7398 | vty_out (vty, ",%s", VTY_NEWLINE); | |
7399 | else | |
7400 | is_first = 0; | |
27162734 | 7401 | |
798c3572 DS |
7402 | vty_out(vty, "\"%s\":", afi_safi_json(afi, safi)); |
7403 | } | |
7404 | else | |
7405 | { | |
7406 | vty_out (vty, "%s%s Summary:%s", | |
7407 | VTY_NEWLINE, afi_safi_print(afi, safi), VTY_NEWLINE); | |
7408 | } | |
27162734 | 7409 | } |
798c3572 | 7410 | bgp_show_summary (vty, bgp, afi, safi, use_json, json); |
27162734 | 7411 | } |
f62a5c33 LB |
7412 | safi++; |
7413 | if (safi == SAFI_RESERVED_4 || | |
7414 | safi == SAFI_RESERVED_5) /* handle special cases to match zebra.h */ | |
7415 | safi++; | |
27162734 LB |
7416 | if (! safi_wildcard) |
7417 | safi = SAFI_MAX; | |
7418 | } | |
7419 | afi++; | |
7420 | if (! afi_wildcard || | |
5ef6cd69 | 7421 | afi == AFI_L2VPN) /* special case, not handled yet */ |
27162734 LB |
7422 | afi = AFI_MAX; |
7423 | } | |
7424 | ||
7425 | if (use_json && is_wildcard) | |
7426 | vty_out (vty, "}%s", VTY_NEWLINE); | |
5ce77b2b DS |
7427 | else if (use_json && !json_output) |
7428 | vty_out (vty, "{}%s", VTY_NEWLINE); | |
27162734 LB |
7429 | } |
7430 | ||
f186de26 | 7431 | static void |
7432 | bgp_show_all_instances_summary_vty (struct vty *vty, afi_t afi, safi_t safi, | |
7433 | u_char use_json) | |
7434 | { | |
7435 | struct listnode *node, *nnode; | |
7436 | struct bgp *bgp; | |
9f689658 DD |
7437 | json_object *json = NULL; |
7438 | int is_first = 1; | |
7439 | ||
7440 | if (use_json) | |
7441 | vty_out (vty, "{%s", VTY_NEWLINE); | |
f186de26 | 7442 | |
7443 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) | |
7444 | { | |
9f689658 DD |
7445 | if (use_json) |
7446 | { | |
4fb25c53 | 7447 | json = json_object_new_object(); |
9f689658 DD |
7448 | |
7449 | if (! is_first) | |
7450 | vty_out (vty, ",%s", VTY_NEWLINE); | |
7451 | else | |
7452 | is_first = 0; | |
7453 | ||
7454 | vty_out(vty, "\"%s\":", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
7455 | ? "Default" : bgp->name); | |
7456 | } | |
7457 | else | |
7458 | { | |
7459 | vty_out (vty, "%sInstance %s:%s", | |
7460 | VTY_NEWLINE, | |
7461 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
7462 | ? "Default" : bgp->name, VTY_NEWLINE); | |
7463 | } | |
27162734 | 7464 | bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, json); |
f186de26 | 7465 | } |
9f689658 DD |
7466 | |
7467 | if (use_json) | |
7468 | vty_out (vty, "}%s", VTY_NEWLINE); | |
7469 | ||
f186de26 | 7470 | } |
7471 | ||
4fb25c53 DW |
7472 | static int |
7473 | bgp_show_summary_vty (struct vty *vty, const char *name, | |
7474 | afi_t afi, safi_t safi, u_char use_json) | |
7475 | { | |
7476 | struct bgp *bgp; | |
7477 | ||
7478 | if (name) | |
7479 | { | |
7480 | if (strmatch(name, "all")) | |
7481 | { | |
7482 | bgp_show_all_instances_summary_vty (vty, afi, safi, use_json); | |
7483 | return CMD_SUCCESS; | |
7484 | } | |
7485 | else | |
7486 | { | |
7487 | bgp = bgp_lookup_by_name (name); | |
7488 | ||
7489 | if (! bgp) | |
7490 | { | |
7491 | if (use_json) | |
7492 | vty_out (vty, "{}%s", VTY_NEWLINE); | |
7493 | else | |
7494 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
7495 | return CMD_WARNING; | |
7496 | } | |
7497 | ||
27162734 | 7498 | bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, NULL); |
4fb25c53 DW |
7499 | return CMD_SUCCESS; |
7500 | } | |
7501 | } | |
7502 | ||
7503 | bgp = bgp_get_default (); | |
7504 | ||
7505 | if (bgp) | |
27162734 | 7506 | bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, NULL); |
4fb25c53 DW |
7507 | |
7508 | return CMD_SUCCESS; | |
7509 | } | |
7510 | ||
716b2d8a | 7511 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 7512 | DEFUN (show_ip_bgp_summary, |
718e3744 | 7513 | show_ip_bgp_summary_cmd, |
46f296b4 | 7514 | "show [ip] bgp [<view|vrf> WORD] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] summary [json]", |
718e3744 | 7515 | SHOW_STR |
7516 | IP_STR | |
7517 | BGP_STR | |
8386ac43 | 7518 | BGP_INSTANCE_HELP_STR |
46f296b4 LB |
7519 | BGP_AFI_HELP_STR |
7520 | BGP_SAFI_HELP_STR | |
b05a1c8b | 7521 | "Summary of BGP neighbor status\n" |
9973d184 | 7522 | JSON_STR) |
718e3744 | 7523 | { |
74ca3d33 | 7524 | char *vrf = NULL; |
27162734 LB |
7525 | afi_t afi = AFI_MAX; |
7526 | safi_t safi = SAFI_MAX; | |
ae19d7dd QY |
7527 | |
7528 | int idx = 0; | |
7529 | ||
7530 | /* show [ip] bgp */ | |
7531 | if (argv_find (argv, argc, "ip", &idx)) | |
7532 | afi = AFI_IP; | |
7533 | /* [<view|vrf> WORD] */ | |
7534 | if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) | |
7535 | vrf = argv[++idx]->arg; | |
46f296b4 LB |
7536 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
7537 | if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) | |
ae19d7dd | 7538 | { |
46f296b4 | 7539 | argv_find_and_parse_safi (argv, argc, &idx, &safi); |
91d37724 QY |
7540 | } |
7541 | ||
ae19d7dd | 7542 | int uj = use_json (argc, argv); |
74ca3d33 DW |
7543 | |
7544 | return bgp_show_summary_vty (vty, vrf, afi, safi, uj); | |
718e3744 | 7545 | } |
7546 | ||
fd79ac91 | 7547 | const char * |
538621f2 | 7548 | afi_safi_print (afi_t afi, safi_t safi) |
7549 | { | |
7550 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
7551 | return "IPv4 Unicast"; | |
7552 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
7553 | return "IPv4 Multicast"; | |
b60f5275 DS |
7554 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) |
7555 | return "IPv4 labeled-unicast"; | |
538621f2 | 7556 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) |
46f296b4 | 7557 | return "IPv4 VPN"; |
8b1fb8be | 7558 | else if (afi == AFI_IP && safi == SAFI_ENCAP) |
46f296b4 | 7559 | return "IPv4 Encap"; |
538621f2 | 7560 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
7561 | return "IPv6 Unicast"; | |
7562 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
7563 | return "IPv6 Multicast"; | |
b60f5275 DS |
7564 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) |
7565 | return "IPv6 labeled-unicast"; | |
945c8fe9 | 7566 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) |
46f296b4 | 7567 | return "IPv6 VPN"; |
8b1fb8be | 7568 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) |
46f296b4 | 7569 | return "IPv6 Encap"; |
3d6c0dfa PG |
7570 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) |
7571 | return "L2VPN EVPN"; | |
538621f2 | 7572 | else |
7573 | return "Unknown"; | |
7574 | } | |
7575 | ||
b9f77ec8 DS |
7576 | /* |
7577 | * Please note that we have intentionally camelCased | |
7578 | * the return strings here. So if you want | |
7579 | * to use this function, please ensure you | |
7580 | * are doing this within json output | |
7581 | */ | |
27162734 LB |
7582 | const char * |
7583 | afi_safi_json (afi_t afi, safi_t safi) | |
7584 | { | |
7585 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
b9f77ec8 | 7586 | return "ipv4Unicast"; |
27162734 | 7587 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) |
b9f77ec8 | 7588 | return "ipv4Multicast"; |
b60f5275 | 7589 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) |
05ba625a | 7590 | return "ipv4LabeledUnicast"; |
27162734 | 7591 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) |
b9f77ec8 | 7592 | return "ipv4Vpn"; |
27162734 | 7593 | else if (afi == AFI_IP && safi == SAFI_ENCAP) |
b9f77ec8 | 7594 | return "ipv4Encap"; |
27162734 | 7595 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
b9f77ec8 | 7596 | return "ipv6Unicast"; |
27162734 | 7597 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) |
b9f77ec8 | 7598 | return "ipv6Multicast"; |
b60f5275 | 7599 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) |
05ba625a | 7600 | return "ipv6LabeledUnicast"; |
27162734 | 7601 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) |
b9f77ec8 | 7602 | return "ipv6Vpn"; |
27162734 | 7603 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) |
b9f77ec8 | 7604 | return "ipv6Encap"; |
3d6c0dfa | 7605 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) |
b9f77ec8 | 7606 | return "l2VpnEvpn"; |
27162734 LB |
7607 | else |
7608 | return "Unknown"; | |
7609 | } | |
7610 | ||
718e3744 | 7611 | /* Show BGP peer's information. */ |
7612 | enum show_type | |
7613 | { | |
7614 | show_all, | |
7615 | show_peer | |
7616 | }; | |
7617 | ||
94f2b392 | 7618 | static void |
856ca177 MS |
7619 | bgp_show_peer_afi_orf_cap (struct vty *vty, struct peer *p, afi_t afi, safi_t safi, |
7620 | u_int16_t adv_smcap, u_int16_t adv_rmcap, u_int16_t rcv_smcap, | |
7621 | u_int16_t rcv_rmcap, u_char use_json, json_object *json_pref) | |
718e3744 | 7622 | { |
7623 | /* Send-Mode */ | |
7624 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) | |
7625 | || CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
7626 | { | |
856ca177 MS |
7627 | if (use_json) |
7628 | { | |
7629 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
7630 | json_object_string_add(json_pref, "sendMode", "advertisedAndReceived"); | |
7631 | else if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)) | |
7632 | json_object_string_add(json_pref, "sendMode", "advertised"); | |
7633 | else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
7634 | json_object_string_add(json_pref, "sendMode", "received"); | |
7635 | } | |
7636 | else | |
7637 | { | |
7638 | vty_out (vty, " Send-mode: "); | |
7639 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)) | |
7640 | vty_out (vty, "advertised"); | |
7641 | if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
7642 | vty_out (vty, "%sreceived", | |
7643 | CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) ? | |
7644 | ", " : ""); | |
7645 | vty_out (vty, "%s", VTY_NEWLINE); | |
7646 | } | |
718e3744 | 7647 | } |
7648 | ||
7649 | /* Receive-Mode */ | |
7650 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) | |
7651 | || CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
7652 | { | |
856ca177 MS |
7653 | if (use_json) |
7654 | { | |
7655 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
7656 | json_object_string_add(json_pref, "recvMode", "advertisedAndReceived"); | |
7657 | else if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)) | |
7658 | json_object_string_add(json_pref, "recvMode", "advertised"); | |
7659 | else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
7660 | json_object_string_add(json_pref, "recvMode", "received"); | |
7661 | } | |
7662 | else | |
7663 | { | |
7664 | vty_out (vty, " Receive-mode: "); | |
7665 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)) | |
7666 | vty_out (vty, "advertised"); | |
7667 | if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
7668 | vty_out (vty, "%sreceived", | |
7669 | CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) ? | |
7670 | ", " : ""); | |
7671 | vty_out (vty, "%s", VTY_NEWLINE); | |
7672 | } | |
718e3744 | 7673 | } |
7674 | } | |
7675 | ||
94f2b392 | 7676 | static void |
856ca177 MS |
7677 | bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi, |
7678 | u_char use_json, json_object *json_neigh) | |
718e3744 | 7679 | { |
7680 | struct bgp_filter *filter; | |
3f9c7369 | 7681 | struct peer_af *paf; |
718e3744 | 7682 | char orf_pfx_name[BUFSIZ]; |
7683 | int orf_pfx_count; | |
856ca177 MS |
7684 | json_object *json_af = NULL; |
7685 | json_object *json_prefA = NULL; | |
7686 | json_object *json_prefB = NULL; | |
7687 | json_object *json_addr = NULL; | |
718e3744 | 7688 | |
856ca177 MS |
7689 | if (use_json) |
7690 | { | |
7691 | json_addr = json_object_new_object(); | |
7692 | json_af = json_object_new_object(); | |
856ca177 | 7693 | filter = &p->filter[afi][safi]; |
718e3744 | 7694 | |
c8560b44 | 7695 | if (peer_group_active(p)) |
856ca177 | 7696 | json_object_string_add(json_addr, "peerGroupMember", p->group->name); |
538621f2 | 7697 | |
856ca177 MS |
7698 | paf = peer_af_find(p, afi, safi); |
7699 | if (paf && PAF_SUBGRP(paf)) | |
7700 | { | |
7701 | json_object_int_add(json_addr, "updateGroupId", PAF_UPDGRP(paf)->id); | |
7702 | json_object_int_add(json_addr, "subGroupId", PAF_SUBGRP(paf)->id); | |
7703 | json_object_int_add(json_addr, "packetQueueLength", bpacket_queue_virtual_length(paf)); | |
7704 | } | |
7705 | ||
7706 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7707 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
7708 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7709 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)) | |
7710 | { | |
7711 | json_object_int_add(json_af, "orfType", ORF_TYPE_PREFIX); | |
b6df4090 | 7712 | json_prefA = json_object_new_object(); |
856ca177 MS |
7713 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, |
7714 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
7715 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7716 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
7717 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, json_prefA); | |
7718 | json_object_object_add(json_af, "orfPrefixList", json_prefA); | |
7719 | } | |
7720 | ||
7721 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7722 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7723 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7724 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7725 | { | |
7726 | json_object_int_add(json_af, "orfOldType", ORF_TYPE_PREFIX_OLD); | |
b6df4090 | 7727 | json_prefB = json_object_new_object(); |
856ca177 MS |
7728 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, |
7729 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
7730 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7731 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
7732 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, json_prefB); | |
7733 | json_object_object_add(json_af, "orfOldPrefixList", json_prefB); | |
7734 | } | |
7735 | ||
7736 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7737 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
7738 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7739 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7740 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV) | |
7741 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7742 | json_object_object_add(json_addr, "afDependentCap", json_af); | |
b6df4090 DS |
7743 | else |
7744 | json_object_free(json_af); | |
856ca177 MS |
7745 | |
7746 | sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
7747 | orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json); | |
7748 | ||
7749 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND) | |
7750 | || orf_pfx_count) | |
7751 | { | |
7752 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)) | |
7753 | json_object_boolean_true_add(json_neigh, "orfSent"); | |
7754 | if (orf_pfx_count) | |
7755 | json_object_int_add(json_addr, "orfRecvCounter", orf_pfx_count); | |
7756 | } | |
7757 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) | |
7758 | json_object_string_add(json_addr, "orfFirstUpdate", "deferredUntilORFOrRouteRefreshRecvd"); | |
7759 | ||
7760 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) | |
7761 | json_object_boolean_true_add(json_addr, "routeReflectorClient"); | |
7762 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
7763 | json_object_boolean_true_add(json_addr, "routeServerClient"); | |
7764 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
7765 | json_object_boolean_true_add(json_addr, "inboundSoftConfigPermit"); | |
7766 | ||
88b8ed8d DW |
7767 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) |
7768 | json_object_boolean_true_add(json_addr, "privateAsNumsAllReplacedInUpdatesToNbr"); | |
7769 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
856ca177 | 7770 | json_object_boolean_true_add(json_addr, "privateAsNumsReplacedInUpdatesToNbr"); |
88b8ed8d DW |
7771 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) |
7772 | json_object_boolean_true_add(json_addr, "privateAsNumsAllRemovedInUpdatesToNbr"); | |
856ca177 MS |
7773 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS)) |
7774 | json_object_boolean_true_add(json_addr, "privateAsNumsRemovedInUpdatesToNbr"); | |
7775 | ||
adbac85e DW |
7776 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS)) |
7777 | json_object_boolean_true_add(json_addr, "addpathTxAllPaths"); | |
7778 | ||
06370dac DW |
7779 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) |
7780 | json_object_boolean_true_add(json_addr, "addpathTxBestpathPerAS"); | |
7781 | ||
856ca177 MS |
7782 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) |
7783 | json_object_string_add(json_addr, "overrideASNsInOutboundUpdates", "ifAspathEqualRemoteAs"); | |
7784 | ||
7785 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) || | |
7786 | CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
7787 | json_object_boolean_true_add(json_addr, "routerAlwaysNextHop"); | |
7788 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED)) | |
7789 | json_object_boolean_true_add(json_addr, "unchangedAsPathPropogatedToNbr"); | |
7790 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)) | |
7791 | json_object_boolean_true_add(json_addr, "unchangedNextHopPropogatedToNbr"); | |
7792 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
7793 | json_object_boolean_true_add(json_addr, "unchangedMedPropogatedToNbr"); | |
718e3744 | 7794 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) |
856ca177 MS |
7795 | || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) |
7796 | { | |
7797 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
7798 | && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7799 | json_object_string_add(json_addr, "commAttriSentToNbr", "extendedAndStandard"); | |
7800 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7801 | json_object_string_add(json_addr, "commAttriSentToNbr", "extended"); | |
7802 | else | |
7803 | json_object_string_add(json_addr, "commAttriSentToNbr", "standard"); | |
7804 | } | |
7805 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) | |
7806 | { | |
7807 | if (p->default_rmap[afi][safi].name) | |
7808 | json_object_string_add(json_addr, "defaultRouteMap", p->default_rmap[afi][safi].name); | |
7809 | ||
7810 | if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
7811 | json_object_boolean_true_add(json_addr, "defaultSent"); | |
7812 | else | |
7813 | json_object_boolean_true_add(json_addr, "defaultNotSent"); | |
7814 | } | |
7815 | ||
7816 | if (filter->plist[FILTER_IN].name | |
7817 | || filter->dlist[FILTER_IN].name | |
7818 | || filter->aslist[FILTER_IN].name | |
7819 | || filter->map[RMAP_IN].name) | |
7820 | json_object_boolean_true_add(json_addr, "inboundPathPolicyConfig"); | |
7821 | if (filter->plist[FILTER_OUT].name | |
7822 | || filter->dlist[FILTER_OUT].name | |
7823 | || filter->aslist[FILTER_OUT].name | |
7824 | || filter->map[RMAP_OUT].name | |
7825 | || filter->usmap.name) | |
7826 | json_object_boolean_true_add(json_addr, "outboundPathPolicyConfig"); | |
856ca177 MS |
7827 | |
7828 | /* prefix-list */ | |
7829 | if (filter->plist[FILTER_IN].name) | |
7830 | json_object_string_add(json_addr, "incomingUpdatePrefixFilterList", filter->plist[FILTER_IN].name); | |
7831 | if (filter->plist[FILTER_OUT].name) | |
7832 | json_object_string_add(json_addr, "outgoingUpdatePrefixFilterList", filter->plist[FILTER_OUT].name); | |
7833 | ||
7834 | /* distribute-list */ | |
7835 | if (filter->dlist[FILTER_IN].name) | |
7836 | json_object_string_add(json_addr, "incomingUpdateNetworkFilterList", filter->dlist[FILTER_IN].name); | |
7837 | if (filter->dlist[FILTER_OUT].name) | |
7838 | json_object_string_add(json_addr, "outgoingUpdateNetworkFilterList", filter->dlist[FILTER_OUT].name); | |
7839 | ||
7840 | /* filter-list. */ | |
7841 | if (filter->aslist[FILTER_IN].name) | |
7842 | json_object_string_add(json_addr, "incomingUpdateAsPathFilterList", filter->aslist[FILTER_IN].name); | |
7843 | if (filter->aslist[FILTER_OUT].name) | |
7844 | json_object_string_add(json_addr, "outgoingUpdateAsPathFilterList", filter->aslist[FILTER_OUT].name); | |
7845 | ||
7846 | /* route-map. */ | |
7847 | if (filter->map[RMAP_IN].name) | |
7848 | json_object_string_add(json_addr, "routeMapForIncomingAdvertisements", filter->map[RMAP_IN].name); | |
7849 | if (filter->map[RMAP_OUT].name) | |
7850 | json_object_string_add(json_addr, "routeMapForOutgoingAdvertisements", filter->map[RMAP_OUT].name); | |
856ca177 MS |
7851 | |
7852 | /* unsuppress-map */ | |
7853 | if (filter->usmap.name) | |
7854 | json_object_string_add(json_addr, "selectiveUnsuppressRouteMap", filter->usmap.name); | |
7855 | ||
7856 | /* Receive prefix count */ | |
7857 | json_object_int_add(json_addr, "acceptedPrefixCounter", p->pcount[afi][safi]); | |
7858 | ||
7859 | /* Maximum prefix */ | |
7860 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) | |
7861 | { | |
7862 | json_object_int_add(json_addr, "prefixAllowedMax", p->pmax[afi][safi]); | |
7863 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) | |
7864 | json_object_boolean_true_add(json_addr, "prefixAllowedMaxWarning"); | |
7865 | json_object_int_add(json_addr, "prefixAllowedWarningThresh", p->pmax_threshold[afi][safi]); | |
7866 | if (p->pmax_restart[afi][safi]) | |
7867 | json_object_int_add(json_addr, "prefixAllowedRestartIntervalMsecs", p->pmax_restart[afi][safi] * 60000); | |
7868 | } | |
7869 | json_object_object_add(json_neigh, afi_safi_print (afi, safi), json_addr); | |
7870 | ||
7871 | } | |
7872 | else | |
7873 | { | |
7874 | filter = &p->filter[afi][safi]; | |
7875 | ||
7876 | vty_out (vty, " For address family: %s%s", afi_safi_print (afi, safi), | |
7877 | VTY_NEWLINE); | |
7878 | ||
c8560b44 | 7879 | if (peer_group_active(p)) |
856ca177 MS |
7880 | vty_out (vty, " %s peer-group member%s", p->group->name, VTY_NEWLINE); |
7881 | ||
7882 | paf = peer_af_find(p, afi, safi); | |
7883 | if (paf && PAF_SUBGRP(paf)) | |
7884 | { | |
7885 | vty_out (vty, " Update group %" PRIu64 ", subgroup %" PRIu64 "%s", | |
7886 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id, VTY_NEWLINE); | |
7887 | vty_out (vty, " Packet Queue length %d%s", | |
7888 | bpacket_queue_virtual_length(paf), VTY_NEWLINE); | |
7889 | } | |
718e3744 | 7890 | else |
856ca177 MS |
7891 | { |
7892 | vty_out(vty, " Not part of any update group%s", VTY_NEWLINE); | |
7893 | } | |
7894 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7895 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
7896 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7897 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7898 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV) | |
7899 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7900 | vty_out (vty, " AF-dependant capabilities:%s", VTY_NEWLINE); | |
7901 | ||
7902 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7903 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
7904 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7905 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)) | |
7906 | { | |
7907 | vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s", | |
7908 | ORF_TYPE_PREFIX, VTY_NEWLINE); | |
7909 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, | |
7910 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
7911 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7912 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
7913 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
7914 | } | |
7915 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7916 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7917 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7918 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7919 | { | |
7920 | vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s", | |
7921 | ORF_TYPE_PREFIX_OLD, VTY_NEWLINE); | |
7922 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, | |
7923 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
7924 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7925 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
7926 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
7927 | } | |
718e3744 | 7928 | |
856ca177 MS |
7929 | sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi); |
7930 | orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json); | |
718e3744 | 7931 | |
856ca177 MS |
7932 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND) |
7933 | || orf_pfx_count) | |
7934 | { | |
7935 | vty_out (vty, " Outbound Route Filter (ORF):"); | |
7936 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)) | |
7937 | vty_out (vty, " sent;"); | |
7938 | if (orf_pfx_count) | |
7939 | vty_out (vty, " received (%d entries)", orf_pfx_count); | |
7940 | vty_out (vty, "%s", VTY_NEWLINE); | |
7941 | } | |
7942 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) | |
7943 | vty_out (vty, " First update is deferred until ORF or ROUTE-REFRESH is received%s", VTY_NEWLINE); | |
7944 | ||
7945 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) | |
7946 | vty_out (vty, " Route-Reflector Client%s", VTY_NEWLINE); | |
7947 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
7948 | vty_out (vty, " Route-Server Client%s", VTY_NEWLINE); | |
7949 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
7950 | vty_out (vty, " Inbound soft reconfiguration allowed%s", VTY_NEWLINE); | |
7951 | ||
88b8ed8d DW |
7952 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) |
7953 | vty_out (vty, " Private AS numbers (all) replaced in updates to this neighbor%s", VTY_NEWLINE); | |
7954 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
856ca177 | 7955 | vty_out (vty, " Private AS numbers replaced in updates to this neighbor%s", VTY_NEWLINE); |
88b8ed8d DW |
7956 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) |
7957 | vty_out (vty, " Private AS numbers (all) removed in updates to this neighbor%s", VTY_NEWLINE); | |
856ca177 MS |
7958 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS)) |
7959 | vty_out (vty, " Private AS numbers removed in updates to this neighbor%s", VTY_NEWLINE); | |
7960 | ||
adbac85e DW |
7961 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS)) |
7962 | vty_out (vty, " Advertise all paths via addpath%s", VTY_NEWLINE); | |
7963 | ||
06370dac DW |
7964 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) |
7965 | vty_out (vty, " Advertise bestpath per AS via addpath%s", VTY_NEWLINE); | |
7966 | ||
856ca177 MS |
7967 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) |
7968 | vty_out (vty, " Override ASNs in outbound updates if aspath equals remote-as%s", VTY_NEWLINE); | |
7969 | ||
7970 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) || | |
7971 | CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
7972 | vty_out (vty, " NEXT_HOP is always this router%s", VTY_NEWLINE); | |
7973 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED)) | |
7974 | vty_out (vty, " AS_PATH is propagated unchanged to this neighbor%s", VTY_NEWLINE); | |
7975 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)) | |
7976 | vty_out (vty, " NEXT_HOP is propagated unchanged to this neighbor%s", VTY_NEWLINE); | |
7977 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
7978 | vty_out (vty, " MED is propagated unchanged to this neighbor%s", VTY_NEWLINE); | |
7979 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
57d187bc JS |
7980 | || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY) |
7981 | || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
856ca177 MS |
7982 | { |
7983 | vty_out (vty, " Community attribute sent to this neighbor"); | |
7984 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
57d187bc JS |
7985 | && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY) |
7986 | && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
7987 | vty_out (vty, "(all)%s", VTY_NEWLINE); | |
7988 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
7989 | vty_out (vty, "(large)%s", VTY_NEWLINE); | |
856ca177 MS |
7990 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) |
7991 | vty_out (vty, "(extended)%s", VTY_NEWLINE); | |
7992 | else | |
7993 | vty_out (vty, "(standard)%s", VTY_NEWLINE); | |
7994 | } | |
7995 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) | |
7996 | { | |
7997 | vty_out (vty, " Default information originate,"); | |
7998 | ||
7999 | if (p->default_rmap[afi][safi].name) | |
8000 | vty_out (vty, " default route-map %s%s,", | |
8001 | p->default_rmap[afi][safi].map ? "*" : "", | |
8002 | p->default_rmap[afi][safi].name); | |
8003 | if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
8004 | vty_out (vty, " default sent%s", VTY_NEWLINE); | |
8005 | else | |
8006 | vty_out (vty, " default not sent%s", VTY_NEWLINE); | |
8007 | } | |
718e3744 | 8008 | |
856ca177 MS |
8009 | if (filter->plist[FILTER_IN].name |
8010 | || filter->dlist[FILTER_IN].name | |
8011 | || filter->aslist[FILTER_IN].name | |
8012 | || filter->map[RMAP_IN].name) | |
8013 | vty_out (vty, " Inbound path policy configured%s", VTY_NEWLINE); | |
8014 | if (filter->plist[FILTER_OUT].name | |
8015 | || filter->dlist[FILTER_OUT].name | |
8016 | || filter->aslist[FILTER_OUT].name | |
8017 | || filter->map[RMAP_OUT].name | |
8018 | || filter->usmap.name) | |
8019 | vty_out (vty, " Outbound path policy configured%s", VTY_NEWLINE); | |
856ca177 MS |
8020 | |
8021 | /* prefix-list */ | |
8022 | if (filter->plist[FILTER_IN].name) | |
8023 | vty_out (vty, " Incoming update prefix filter list is %s%s%s", | |
8024 | filter->plist[FILTER_IN].plist ? "*" : "", | |
8025 | filter->plist[FILTER_IN].name, | |
8026 | VTY_NEWLINE); | |
8027 | if (filter->plist[FILTER_OUT].name) | |
8028 | vty_out (vty, " Outgoing update prefix filter list is %s%s%s", | |
8029 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
8030 | filter->plist[FILTER_OUT].name, | |
8031 | VTY_NEWLINE); | |
8032 | ||
8033 | /* distribute-list */ | |
8034 | if (filter->dlist[FILTER_IN].name) | |
8035 | vty_out (vty, " Incoming update network filter list is %s%s%s", | |
8036 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
8037 | filter->dlist[FILTER_IN].name, | |
8038 | VTY_NEWLINE); | |
8039 | if (filter->dlist[FILTER_OUT].name) | |
8040 | vty_out (vty, " Outgoing update network filter list is %s%s%s", | |
8041 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
8042 | filter->dlist[FILTER_OUT].name, | |
8043 | VTY_NEWLINE); | |
8044 | ||
8045 | /* filter-list. */ | |
8046 | if (filter->aslist[FILTER_IN].name) | |
8047 | vty_out (vty, " Incoming update AS path filter list is %s%s%s", | |
8048 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
8049 | filter->aslist[FILTER_IN].name, | |
8050 | VTY_NEWLINE); | |
8051 | if (filter->aslist[FILTER_OUT].name) | |
8052 | vty_out (vty, " Outgoing update AS path filter list is %s%s%s", | |
8053 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
8054 | filter->aslist[FILTER_OUT].name, | |
8055 | VTY_NEWLINE); | |
8056 | ||
8057 | /* route-map. */ | |
8058 | if (filter->map[RMAP_IN].name) | |
8059 | vty_out (vty, " Route map for incoming advertisements is %s%s%s", | |
8060 | filter->map[RMAP_IN].map ? "*" : "", | |
8061 | filter->map[RMAP_IN].name, | |
8062 | VTY_NEWLINE); | |
8063 | if (filter->map[RMAP_OUT].name) | |
8064 | vty_out (vty, " Route map for outgoing advertisements is %s%s%s", | |
8065 | filter->map[RMAP_OUT].map ? "*" : "", | |
8066 | filter->map[RMAP_OUT].name, | |
8067 | VTY_NEWLINE); | |
856ca177 MS |
8068 | |
8069 | /* unsuppress-map */ | |
8070 | if (filter->usmap.name) | |
8071 | vty_out (vty, " Route map for selective unsuppress is %s%s%s", | |
8072 | filter->usmap.map ? "*" : "", | |
8073 | filter->usmap.name, VTY_NEWLINE); | |
8074 | ||
8075 | /* Receive prefix count */ | |
8076 | vty_out (vty, " %ld accepted prefixes%s", p->pcount[afi][safi], VTY_NEWLINE); | |
8077 | ||
8078 | /* Maximum prefix */ | |
8079 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) | |
8080 | { | |
8081 | vty_out (vty, " Maximum prefixes allowed %ld%s%s", p->pmax[afi][safi], | |
8082 | CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING) | |
8083 | ? " (warning-only)" : "", VTY_NEWLINE); | |
8084 | vty_out (vty, " Threshold for warning message %d%%", | |
8085 | p->pmax_threshold[afi][safi]); | |
8086 | if (p->pmax_restart[afi][safi]) | |
8087 | vty_out (vty, ", restart interval %d min", p->pmax_restart[afi][safi]); | |
8088 | vty_out (vty, "%s", VTY_NEWLINE); | |
8089 | } | |
718e3744 | 8090 | |
0a486e5f | 8091 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 8092 | } |
718e3744 | 8093 | } |
8094 | ||
94f2b392 | 8095 | static void |
e8f7da3a | 8096 | bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *json) |
718e3744 | 8097 | { |
8098 | struct bgp *bgp; | |
4690c7d7 | 8099 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; |
718e3744 | 8100 | char timebuf[BGP_UPTIME_LEN]; |
f14e6fdb | 8101 | char dn_flag[2]; |
3a8c7ba1 DW |
8102 | const char *subcode_str; |
8103 | const char *code_str; | |
538621f2 | 8104 | afi_t afi; |
8105 | safi_t safi; | |
d6661008 DS |
8106 | u_int16_t i; |
8107 | u_char *msg; | |
e8f7da3a | 8108 | json_object *json_neigh = NULL; |
718e3744 | 8109 | |
8110 | bgp = p->bgp; | |
8111 | ||
e8f7da3a DW |
8112 | if (use_json) |
8113 | json_neigh = json_object_new_object(); | |
8114 | ||
517cd68a DS |
8115 | memset (dn_flag, '\0', sizeof (dn_flag)); |
8116 | if (!p->conf_if && peer_dynamic_neighbor (p)) | |
8117 | dn_flag[0] = '*'; | |
8118 | ||
856ca177 | 8119 | if (!use_json) |
f14e6fdb | 8120 | { |
856ca177 MS |
8121 | if (p->conf_if) /* Configured interface name. */ |
8122 | vty_out (vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
8123 | BGP_PEER_SU_UNSPEC(p) ? "None" : | |
8124 | sockunion2str (&p->su, buf, SU_ADDRSTRLEN)); | |
8125 | else /* Configured IP address. */ | |
74ef1672 | 8126 | vty_out (vty, "BGP neighbor is %s%s, ", dn_flag, p->host); |
f14e6fdb DS |
8127 | } |
8128 | ||
856ca177 MS |
8129 | if (use_json) |
8130 | { | |
8131 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
8132 | json_object_string_add(json_neigh, "bgpNeighborAddr", "none"); | |
8133 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
8134 | json_object_string_add(json_neigh, "bgpNeighborAddr", sockunion2str (&p->su, buf, SU_ADDRSTRLEN)); | |
8135 | ||
8136 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
8137 | ||
8138 | if (p->change_local_as) | |
8139 | json_object_int_add(json_neigh, "localAs", p->change_local_as); | |
8140 | else | |
8141 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
8142 | ||
8143 | if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
8144 | json_object_boolean_true_add(json_neigh, "localAsNoPrepend"); | |
66b199b2 | 8145 | |
856ca177 MS |
8146 | if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) |
8147 | json_object_boolean_true_add(json_neigh, "localAsReplaceAs"); | |
8148 | } | |
8149 | else | |
8150 | { | |
f8cfafda DS |
8151 | if ((p->as_type == AS_SPECIFIED) || |
8152 | (p->as_type == AS_EXTERNAL) || | |
8153 | (p->as_type == AS_INTERNAL)) | |
8154 | vty_out (vty, "remote AS %u, ", p->as); | |
8155 | else | |
8156 | vty_out (vty, "remote AS Unspecified, "); | |
856ca177 MS |
8157 | vty_out (vty, "local AS %u%s%s, ", |
8158 | p->change_local_as ? p->change_local_as : p->local_as, | |
8159 | CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ? | |
8160 | " no-prepend" : "", | |
8161 | CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) ? | |
8162 | " replace-as" : ""); | |
8163 | } | |
66b199b2 DS |
8164 | /* peer type internal, external, confed-internal or confed-external */ |
8165 | if (p->as == p->local_as) | |
8166 | { | |
856ca177 MS |
8167 | if (use_json) |
8168 | { | |
8169 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
8170 | json_object_boolean_true_add(json_neigh, "nbrConfedInternalLink"); | |
8171 | else | |
8172 | json_object_boolean_true_add(json_neigh, "nbrInternalLink"); | |
8173 | } | |
66b199b2 | 8174 | else |
856ca177 MS |
8175 | { |
8176 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
8177 | vty_out (vty, "confed-internal link%s", VTY_NEWLINE); | |
8178 | else | |
8179 | vty_out (vty, "internal link%s", VTY_NEWLINE); | |
8180 | } | |
66b199b2 DS |
8181 | } |
8182 | else | |
8183 | { | |
856ca177 MS |
8184 | if (use_json) |
8185 | { | |
8186 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
8187 | json_object_boolean_true_add(json_neigh, "nbrConfedExternalLink"); | |
8188 | else | |
8189 | json_object_boolean_true_add(json_neigh, "nbrExternalLink"); | |
8190 | } | |
66b199b2 | 8191 | else |
856ca177 MS |
8192 | { |
8193 | if (bgp_confederation_peers_check(bgp, p->as)) | |
8194 | vty_out (vty, "confed-external link%s", VTY_NEWLINE); | |
8195 | else | |
8196 | vty_out (vty, "external link%s", VTY_NEWLINE); | |
8197 | } | |
66b199b2 | 8198 | } |
718e3744 | 8199 | |
8200 | /* Description. */ | |
8201 | if (p->desc) | |
856ca177 MS |
8202 | { |
8203 | if (use_json) | |
8204 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
8205 | else | |
8206 | vty_out (vty, " Description: %s%s", p->desc, VTY_NEWLINE); | |
8207 | } | |
6410e93a | 8208 | |
04b6bdc0 DW |
8209 | if (p->hostname) |
8210 | { | |
d1570739 DW |
8211 | if (use_json) |
8212 | { | |
8213 | if (p->hostname) | |
8214 | json_object_string_add(json_neigh, "hostname", p->hostname); | |
8215 | ||
8216 | if (p->domainname) | |
8217 | json_object_string_add(json_neigh, "domainname", p->domainname); | |
8218 | } | |
04b6bdc0 | 8219 | else |
d1570739 DW |
8220 | { |
8221 | if (p->domainname && (p->domainname[0] != '\0')) | |
8222 | vty_out(vty, "Hostname: %s.%s%s", p->hostname, p->domainname, | |
8223 | VTY_NEWLINE); | |
8224 | else | |
8225 | vty_out(vty, "Hostname: %s%s", p->hostname, VTY_NEWLINE); | |
8226 | } | |
8227 | ||
04b6bdc0 DW |
8228 | } |
8229 | ||
c744aa9f | 8230 | /* Peer-group */ |
718e3744 | 8231 | if (p->group) |
f14e6fdb | 8232 | { |
856ca177 MS |
8233 | if (use_json) |
8234 | { | |
8235 | json_object_string_add(json_neigh, "peerGroup", p->group->name); | |
8236 | ||
8237 | if (dn_flag[0]) | |
8238 | { | |
40ee54a7 | 8239 | struct prefix prefix, *range = NULL; |
f14e6fdb | 8240 | |
40ee54a7 TT |
8241 | sockunion2hostprefix(&(p->su), &prefix); |
8242 | range = peer_group_lookup_dynamic_neighbor_range (p->group, &prefix); | |
856ca177 MS |
8243 | |
8244 | if (range) | |
8245 | { | |
8246 | prefix2str(range, buf1, sizeof(buf1)); | |
8247 | json_object_string_add(json_neigh, "peerSubnetRangeGroup", buf1); | |
8248 | } | |
8249 | } | |
8250 | } | |
8251 | else | |
f14e6fdb | 8252 | { |
856ca177 MS |
8253 | vty_out (vty, " Member of peer-group %s for session parameters%s", |
8254 | p->group->name, VTY_NEWLINE); | |
f14e6fdb | 8255 | |
856ca177 | 8256 | if (dn_flag[0]) |
f14e6fdb | 8257 | { |
40ee54a7 | 8258 | struct prefix prefix, *range = NULL; |
856ca177 | 8259 | |
40ee54a7 TT |
8260 | sockunion2hostprefix(&(p->su), &prefix); |
8261 | range = peer_group_lookup_dynamic_neighbor_range (p->group, &prefix); | |
856ca177 MS |
8262 | |
8263 | if (range) | |
8264 | { | |
8265 | prefix2str(range, buf1, sizeof(buf1)); | |
8266 | vty_out (vty, " Belongs to the subnet range group: %s%s", buf1, VTY_NEWLINE); | |
8267 | } | |
f14e6fdb DS |
8268 | } |
8269 | } | |
8270 | } | |
718e3744 | 8271 | |
856ca177 MS |
8272 | if (use_json) |
8273 | { | |
8274 | /* Administrative shutdown. */ | |
8275 | if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN)) | |
8276 | json_object_boolean_true_add(json_neigh, "adminShutDown"); | |
718e3744 | 8277 | |
856ca177 MS |
8278 | /* BGP Version. */ |
8279 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
389e3fe0 | 8280 | json_object_string_add(json_neigh, "remoteRouterId", |
44b8cd53 | 8281 | inet_ntop (AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
718e3744 | 8282 | |
856ca177 MS |
8283 | /* Confederation */ |
8284 | if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION) && bgp_confederation_peers_check (bgp, p->as)) | |
8285 | json_object_boolean_true_add(json_neigh, "nbrCommonAdmin"); | |
8286 | ||
8287 | /* Status. */ | |
8288 | json_object_string_add(json_neigh, "bgpState", LOOKUP (bgp_status_msg, p->status)); | |
8289 | ||
8290 | if (p->status == Established) | |
8291 | { | |
8292 | time_t uptime; | |
8293 | struct tm *tm; | |
8294 | ||
8295 | uptime = bgp_clock(); | |
8296 | uptime -= p->uptime; | |
8297 | tm = gmtime(&uptime); | |
8298 | ||
8299 | json_object_int_add(json_neigh, "bgpTimerUp", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); | |
8300 | } | |
8301 | ||
8302 | else if (p->status == Active) | |
8303 | { | |
8304 | if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE)) | |
8305 | json_object_string_add(json_neigh, "bgpStateIs", "passive"); | |
8306 | else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT)) | |
8307 | json_object_string_add(json_neigh, "bgpStateIs", "passiveNSF"); | |
8308 | } | |
8309 | ||
8310 | /* read timer */ | |
8311 | time_t uptime; | |
8312 | struct tm *tm; | |
8313 | ||
8314 | uptime = bgp_clock(); | |
8315 | uptime -= p->readtime; | |
8316 | tm = gmtime(&uptime); | |
8317 | json_object_int_add(json_neigh, "bgpTimerLastRead", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); | |
8318 | ||
8319 | uptime = bgp_clock(); | |
8320 | uptime -= p->last_write; | |
8321 | tm = gmtime(&uptime); | |
39e871e6 ST |
8322 | json_object_int_add(json_neigh, "bgpTimerLastWrite", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); |
8323 | ||
8324 | uptime = bgp_clock(); | |
8325 | uptime -= p->update_time; | |
8326 | tm = gmtime(&uptime); | |
8327 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", | |
8328 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); | |
856ca177 MS |
8329 | |
8330 | /* Configured timer values. */ | |
8331 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", p->v_holdtime * 1000); | |
8332 | json_object_int_add(json_neigh, "bgpTimerKeepAliveIntervalMsecs", p->v_keepalive * 1000); | |
8333 | ||
8334 | if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER)) | |
8335 | { | |
8336 | json_object_int_add(json_neigh, "bgpTimerConfiguredHoldTimeMsecs", p->holdtime * 1000); | |
8337 | json_object_int_add(json_neigh, "bgpTimerConfiguredKeepAliveIntervalMsecs", p->keepalive * 1000); | |
8338 | } | |
93406d87 | 8339 | } |
856ca177 MS |
8340 | else |
8341 | { | |
8342 | /* Administrative shutdown. */ | |
8343 | if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN)) | |
8344 | vty_out (vty, " Administratively shut down%s", VTY_NEWLINE); | |
8345 | ||
8346 | /* BGP Version. */ | |
8347 | vty_out (vty, " BGP version 4"); | |
389e3fe0 | 8348 | vty_out (vty, ", remote router ID %s%s", |
44b8cd53 | 8349 | inet_ntop (AF_INET, &p->remote_id, buf1, sizeof(buf1)), |
856ca177 MS |
8350 | VTY_NEWLINE); |
8351 | ||
8352 | /* Confederation */ | |
8353 | if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION) | |
8354 | && bgp_confederation_peers_check (bgp, p->as)) | |
8355 | vty_out (vty, " Neighbor under common administration%s", VTY_NEWLINE); | |
e52702f2 | 8356 | |
856ca177 MS |
8357 | /* Status. */ |
8358 | vty_out (vty, " BGP state = %s", LOOKUP (bgp_status_msg, p->status)); | |
718e3744 | 8359 | |
856ca177 MS |
8360 | if (p->status == Established) |
8361 | vty_out (vty, ", up for %8s", peer_uptime (p->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL)); | |
8362 | ||
8363 | else if (p->status == Active) | |
8364 | { | |
8365 | if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE)) | |
8366 | vty_out (vty, " (passive)"); | |
8367 | else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT)) | |
8368 | vty_out (vty, " (NSF passive)"); | |
8369 | } | |
8370 | vty_out (vty, "%s", VTY_NEWLINE); | |
93406d87 | 8371 | |
856ca177 MS |
8372 | /* read timer */ |
8373 | vty_out (vty, " Last read %s", peer_uptime (p->readtime, timebuf, BGP_UPTIME_LEN, 0, NULL)); | |
8374 | vty_out (vty, ", Last write %s%s", | |
8375 | peer_uptime (p->last_write, timebuf, BGP_UPTIME_LEN, 0, NULL), VTY_NEWLINE); | |
8376 | ||
8377 | /* Configured timer values. */ | |
8378 | vty_out (vty, " Hold time is %d, keepalive interval is %d seconds%s", | |
8379 | p->v_holdtime, p->v_keepalive, VTY_NEWLINE); | |
8380 | if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER)) | |
8381 | { | |
8382 | vty_out (vty, " Configured hold time is %d", p->holdtime); | |
8383 | vty_out (vty, ", keepalive interval is %d seconds%s", | |
8384 | p->keepalive, VTY_NEWLINE); | |
8385 | } | |
8386 | } | |
718e3744 | 8387 | /* Capability. */ |
e52702f2 | 8388 | if (p->status == Established) |
718e3744 | 8389 | { |
538621f2 | 8390 | if (p->cap |
718e3744 | 8391 | || p->afc_adv[AFI_IP][SAFI_UNICAST] |
8392 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
8393 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
8394 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
718e3744 | 8395 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] |
8396 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
8397 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
8398 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
945c8fe9 LB |
8399 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] |
8400 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
8b1fb8be LB |
8401 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] |
8402 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
8b1fb8be LB |
8403 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
8404 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
718e3744 | 8405 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
8406 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) | |
8407 | { | |
856ca177 MS |
8408 | if (use_json) |
8409 | { | |
8410 | json_object *json_cap = NULL; | |
8411 | ||
8412 | json_cap = json_object_new_object(); | |
8413 | ||
8414 | /* AS4 */ | |
8415 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV) | |
8416 | || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
8417 | { | |
8418 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) && CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)) | |
8419 | json_object_string_add(json_cap, "4byteAs", "advertisedAndReceived"); | |
8420 | else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
8421 | json_object_string_add(json_cap, "4byteAs", "advertised"); | |
8422 | else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)) | |
8423 | json_object_string_add(json_cap, "4byteAs", "received"); | |
8424 | } | |
8425 | ||
8426 | /* AddPath */ | |
8427 | if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV) | |
8428 | || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV)) | |
8429 | { | |
8430 | json_object *json_add = NULL; | |
8431 | const char *print_store; | |
718e3744 | 8432 | |
856ca177 | 8433 | json_add = json_object_new_object(); |
a82478b9 | 8434 | |
856ca177 MS |
8435 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) |
8436 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8437 | { | |
8438 | json_object *json_sub = NULL; | |
8439 | json_sub = json_object_new_object(); | |
8440 | print_store = afi_safi_print (afi, safi); | |
8441 | ||
8442 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) || | |
8443 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) | |
8444 | { | |
8445 | 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)) | |
8446 | json_object_boolean_true_add(json_sub, "txAdvertisedAndReceived"); | |
8447 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV)) | |
8448 | json_object_boolean_true_add(json_sub, "txAdvertised"); | |
8449 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) | |
8450 | json_object_boolean_true_add(json_sub, "txReceived"); | |
8451 | } | |
8452 | ||
8453 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) || | |
8454 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) | |
8455 | { | |
8456 | 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)) | |
8457 | json_object_boolean_true_add(json_sub, "rxAdvertisedAndReceived"); | |
8458 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV)) | |
8459 | json_object_boolean_true_add(json_sub, "rxAdvertised"); | |
8460 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) | |
8461 | json_object_boolean_true_add(json_sub, "rxReceived"); | |
8462 | } | |
8463 | ||
8464 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) || | |
8465 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV) || | |
8466 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) || | |
8467 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) | |
8468 | json_object_object_add(json_add, print_store, json_sub); | |
b6df4090 DS |
8469 | else |
8470 | json_object_free(json_sub); | |
856ca177 | 8471 | } |
a82478b9 | 8472 | |
856ca177 MS |
8473 | json_object_object_add(json_cap, "addPath", json_add); |
8474 | } | |
8475 | ||
8476 | /* Dynamic */ | |
8477 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV) | |
8478 | || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
8479 | { | |
8480 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) && CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)) | |
8481 | json_object_string_add(json_cap, "dynamic", "advertisedAndReceived"); | |
8482 | else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
8483 | json_object_string_add(json_cap, "dynamic", "advertised"); | |
8484 | else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)) | |
8485 | json_object_string_add(json_cap, "dynamic", "received"); | |
8486 | } | |
8487 | ||
8488 | /* Extended nexthop */ | |
8489 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV) | |
8490 | || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
8491 | { | |
8492 | json_object *json_nxt = NULL; | |
8493 | const char *print_store; | |
8494 | ||
856ca177 MS |
8495 | |
8496 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) && CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
8497 | json_object_string_add(json_cap, "extendedNexthop", "advertisedAndReceived"); | |
8498 | else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
8499 | json_object_string_add(json_cap, "extendedNexthop", "advertised"); | |
8500 | else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
8501 | json_object_string_add(json_cap, "extendedNexthop", "received"); | |
8502 | ||
8503 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
8504 | { | |
b6df4090 DS |
8505 | json_nxt = json_object_new_object(); |
8506 | ||
856ca177 MS |
8507 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) |
8508 | { | |
8509 | if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV)) | |
8510 | { | |
8511 | print_store = afi_safi_print (AFI_IP, safi); | |
8512 | json_object_string_add(json_nxt, print_store, "recieved"); | |
8513 | } | |
8514 | } | |
8515 | json_object_object_add(json_cap, "extendedNexthopFamililesByPeer", json_nxt); | |
8516 | } | |
8517 | } | |
8518 | ||
8519 | /* Route Refresh */ | |
8520 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) | |
8521 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) | |
8522 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
8523 | { | |
8524 | 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))) | |
8525 | { | |
8526 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) | |
8527 | json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOldNew"); | |
8528 | else | |
8529 | { | |
8530 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
8531 | json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOld"); | |
8532 | else | |
8533 | json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedNew"); | |
8534 | } | |
8535 | } | |
8536 | else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)) | |
8537 | json_object_string_add(json_cap, "routeRefresh", "advertised"); | |
8538 | else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
8539 | json_object_string_add(json_cap, "routeRefresh", "received"); | |
8540 | } | |
8541 | ||
8542 | /* Multiprotocol Extensions */ | |
8543 | json_object *json_multi = NULL; | |
8544 | json_multi = json_object_new_object(); | |
8545 | ||
8546 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8547 | { | |
8548 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8549 | { | |
8550 | if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi]) | |
8551 | { | |
8552 | json_object *json_exten = NULL; | |
8553 | json_exten = json_object_new_object(); | |
8554 | ||
8555 | if (p->afc_adv[afi][safi] && p->afc_recv[afi][safi]) | |
8556 | json_object_boolean_true_add(json_exten, "advertisedAndReceived"); | |
8557 | else if (p->afc_adv[afi][safi]) | |
8558 | json_object_boolean_true_add(json_exten, "advertised"); | |
8559 | else if (p->afc_recv[afi][safi]) | |
8560 | json_object_boolean_true_add(json_exten, "received"); | |
8561 | ||
8562 | json_object_object_add(json_multi, afi_safi_print (afi, safi), json_exten); | |
8563 | } | |
8564 | } | |
8565 | } | |
8566 | json_object_object_add(json_cap, "multiprotocolExtensions", json_multi); | |
8567 | ||
8568 | /* Gracefull Restart */ | |
8569 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV) | |
8570 | || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
8571 | { | |
8572 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) && CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) | |
8573 | json_object_string_add(json_cap, "gracefulRestart", "advertisedAndReceived"); | |
8574 | else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
8575 | json_object_string_add(json_cap, "gracefulRestartCapability", "advertised"); | |
8576 | else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) | |
8577 | json_object_string_add(json_cap, "gracefulRestartCapability", "received"); | |
8578 | ||
8579 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) | |
8580 | { | |
8581 | int restart_af_count = 0; | |
8582 | json_object *json_restart = NULL; | |
8583 | json_restart = json_object_new_object(); | |
8584 | ||
8585 | json_object_int_add(json_cap, "gracefulRestartRemoteTimerMsecs", p->v_gr_restart * 1000); | |
8586 | ||
8587 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8588 | { | |
8589 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8590 | { | |
8591 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV)) | |
8592 | { | |
8593 | json_object *json_sub = NULL; | |
8594 | json_sub = json_object_new_object(); | |
8595 | ||
8596 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV)) | |
8597 | json_object_boolean_true_add(json_sub, "preserved"); | |
8598 | restart_af_count++; | |
8599 | json_object_object_add(json_restart, afi_safi_print (afi, safi), json_sub); | |
8600 | } | |
8601 | } | |
8602 | } | |
8603 | if (! restart_af_count) | |
b6df4090 | 8604 | { |
856ca177 | 8605 | json_object_string_add(json_cap, "addressFamiliesByPeer", "none"); |
b6df4090 DS |
8606 | json_object_free(json_restart); |
8607 | } | |
856ca177 MS |
8608 | else |
8609 | json_object_object_add(json_cap, "addressFamiliesByPeer", json_restart); | |
8610 | } | |
8611 | } | |
8612 | json_object_object_add(json_neigh, "neighborCapabilities", json_cap); | |
8613 | } | |
8614 | else | |
8615 | { | |
8616 | vty_out (vty, " Neighbor capabilities:%s", VTY_NEWLINE); | |
8617 | ||
8618 | /* AS4 */ | |
8619 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV) | |
8620 | || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
8621 | { | |
8622 | vty_out (vty, " 4 Byte AS:"); | |
8623 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
8624 | vty_out (vty, " advertised"); | |
8625 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)) | |
8626 | vty_out (vty, " %sreceived", | |
8627 | CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) ? "and " : ""); | |
8628 | vty_out (vty, "%s", VTY_NEWLINE); | |
8629 | } | |
8630 | ||
8631 | /* AddPath */ | |
8632 | if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV) | |
8633 | || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV)) | |
8634 | { | |
8635 | vty_out (vty, " AddPath:%s", VTY_NEWLINE); | |
a82478b9 | 8636 | |
856ca177 MS |
8637 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) |
8638 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
a82478b9 | 8639 | { |
856ca177 MS |
8640 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) || |
8641 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) | |
8642 | { | |
8643 | vty_out (vty, " %s: TX ", afi_safi_print (afi, safi)); | |
a82478b9 | 8644 | |
856ca177 MS |
8645 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV)) |
8646 | vty_out (vty, "advertised %s", afi_safi_print (afi, safi)); | |
a82478b9 | 8647 | |
856ca177 MS |
8648 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) |
8649 | vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ? " and " : "" ); | |
a82478b9 | 8650 | |
856ca177 MS |
8651 | vty_out (vty, "%s", VTY_NEWLINE); |
8652 | } | |
a82478b9 | 8653 | |
856ca177 | 8654 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) || |
a82478b9 | 8655 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) |
856ca177 MS |
8656 | { |
8657 | vty_out (vty, " %s: RX ", afi_safi_print (afi, safi)); | |
a82478b9 | 8658 | |
856ca177 MS |
8659 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV)) |
8660 | vty_out (vty, "advertised %s", afi_safi_print (afi, safi)); | |
a82478b9 | 8661 | |
856ca177 MS |
8662 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) |
8663 | vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ? " and " : "" ); | |
a82478b9 | 8664 | |
856ca177 MS |
8665 | vty_out (vty, "%s", VTY_NEWLINE); |
8666 | } | |
a82478b9 | 8667 | } |
856ca177 | 8668 | } |
a82478b9 | 8669 | |
856ca177 MS |
8670 | /* Dynamic */ |
8671 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV) | |
8672 | || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
8673 | { | |
8674 | vty_out (vty, " Dynamic:"); | |
8675 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
8676 | vty_out (vty, " advertised"); | |
8677 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)) | |
8678 | vty_out (vty, " %sreceived", | |
8679 | CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) ? "and " : ""); | |
8680 | vty_out (vty, "%s", VTY_NEWLINE); | |
8681 | } | |
8682 | ||
8683 | /* Extended nexthop */ | |
8684 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV) | |
8685 | || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
8686 | { | |
8687 | vty_out (vty, " Extended nexthop:"); | |
8688 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
8689 | vty_out (vty, " advertised"); | |
8690 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
8691 | vty_out (vty, " %sreceived", | |
8692 | CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) ? "and " : ""); | |
8693 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 8694 | |
856ca177 MS |
8695 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) |
8696 | { | |
8697 | vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE); | |
8698 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8699 | if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV)) | |
8700 | vty_out (vty, " %s%s", | |
8701 | afi_safi_print (AFI_IP, safi), VTY_NEWLINE); | |
8702 | } | |
8703 | } | |
8a92a8a0 | 8704 | |
856ca177 MS |
8705 | /* Route Refresh */ |
8706 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) | |
8707 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) | |
8708 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
8709 | { | |
8710 | vty_out (vty, " Route refresh:"); | |
8711 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)) | |
8712 | vty_out (vty, " advertised"); | |
8713 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) | |
8714 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
8715 | vty_out (vty, " %sreceived(%s)", | |
8716 | CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) ? "and " : "", | |
8717 | (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) | |
8718 | && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) ? | |
8719 | "old & new" : CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) ? "old" : "new"); | |
8a92a8a0 | 8720 | |
856ca177 MS |
8721 | vty_out (vty, "%s", VTY_NEWLINE); |
8722 | } | |
718e3744 | 8723 | |
856ca177 MS |
8724 | /* Multiprotocol Extensions */ |
8725 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8726 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8727 | if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi]) | |
8728 | { | |
8c3deaae | 8729 | vty_out (vty, " Address Family %s:", afi_safi_print (afi, safi)); |
856ca177 MS |
8730 | if (p->afc_adv[afi][safi]) |
8731 | vty_out (vty, " advertised"); | |
8732 | if (p->afc_recv[afi][safi]) | |
8733 | vty_out (vty, " %sreceived", p->afc_adv[afi][safi] ? "and " : ""); | |
8734 | vty_out (vty, "%s", VTY_NEWLINE); | |
8735 | } | |
538621f2 | 8736 | |
04b6bdc0 DW |
8737 | /* Hostname capability */ |
8738 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV) || | |
8739 | CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) | |
8740 | { | |
8741 | vty_out (vty, " Hostname Capability:"); | |
8742 | if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV)) | |
8743 | vty_out (vty, " advertised"); | |
8744 | if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_RCV)) | |
8745 | vty_out (vty, " %sreceived", | |
8746 | CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV) ? "and " : ""); | |
8747 | vty_out (vty, "%s", VTY_NEWLINE); | |
8748 | } | |
8749 | ||
856ca177 MS |
8750 | /* Gracefull Restart */ |
8751 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV) | |
8752 | || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
8753 | { | |
8754 | vty_out (vty, " Graceful Restart Capabilty:"); | |
8755 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
538621f2 | 8756 | vty_out (vty, " advertised"); |
856ca177 MS |
8757 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) |
8758 | vty_out (vty, " %sreceived", | |
8759 | CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) ? "and " : ""); | |
8760 | vty_out (vty, "%s", VTY_NEWLINE); | |
538621f2 | 8761 | |
856ca177 MS |
8762 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) |
8763 | { | |
8764 | int restart_af_count = 0; | |
8765 | ||
8766 | vty_out (vty, " Remote Restart timer is %d seconds%s", | |
8767 | p->v_gr_restart, VTY_NEWLINE); | |
8768 | vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE); | |
8769 | ||
8770 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8771 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8772 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV)) | |
8773 | { | |
8774 | vty_out (vty, "%s%s(%s)", restart_af_count ? ", " : "", | |
8775 | afi_safi_print (afi, safi), | |
8776 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV) ? | |
8777 | "preserved" : "not preserved"); | |
8778 | restart_af_count++; | |
8779 | } | |
8780 | if (! restart_af_count) | |
8781 | vty_out (vty, "none"); | |
8782 | vty_out (vty, "%s", VTY_NEWLINE); | |
8783 | } | |
8784 | } | |
8785 | } | |
718e3744 | 8786 | } |
8787 | } | |
8788 | ||
93406d87 | 8789 | /* graceful restart information */ |
8790 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV) | |
8791 | || p->t_gr_restart | |
8792 | || p->t_gr_stale) | |
8793 | { | |
856ca177 MS |
8794 | json_object *json_grace = NULL; |
8795 | json_object *json_grace_send = NULL; | |
8796 | json_object *json_grace_recv = NULL; | |
93406d87 | 8797 | int eor_send_af_count = 0; |
8798 | int eor_receive_af_count = 0; | |
8799 | ||
856ca177 MS |
8800 | if (use_json) |
8801 | { | |
8802 | json_grace = json_object_new_object(); | |
8803 | json_grace_send = json_object_new_object(); | |
8804 | json_grace_recv = json_object_new_object(); | |
8805 | ||
8806 | if (p->status == Established) | |
8807 | { | |
8808 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8809 | { | |
8810 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8811 | { | |
8812 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND)) | |
8813 | { | |
8814 | json_object_boolean_true_add(json_grace_send, afi_safi_print (afi, safi)); | |
8815 | eor_send_af_count++; | |
8816 | } | |
8817 | } | |
8818 | } | |
8819 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8820 | { | |
8821 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8822 | { | |
8823 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED)) | |
8824 | { | |
8825 | json_object_boolean_true_add(json_grace_recv, afi_safi_print (afi, safi)); | |
8826 | eor_receive_af_count++; | |
8827 | } | |
8828 | } | |
8829 | } | |
8830 | } | |
8831 | ||
8832 | json_object_object_add(json_grace, "endOfRibSend", json_grace_send); | |
8833 | json_object_object_add(json_grace, "endOfRibRecv", json_grace_recv); | |
8834 | ||
8835 | if (p->t_gr_restart) | |
8836 | json_object_int_add(json_grace, "gracefulRestartTimerMsecs", thread_timer_remain_second (p->t_gr_restart) * 1000); | |
8837 | ||
8838 | if (p->t_gr_stale) | |
8839 | json_object_int_add(json_grace, "gracefulStalepathTimerMsecs", thread_timer_remain_second (p->t_gr_stale) * 1000); | |
8840 | ||
8841 | json_object_object_add(json_neigh, "gracefulRestartInfo", json_grace); | |
8842 | } | |
8843 | else | |
8844 | { | |
8845 | vty_out (vty, " Graceful restart informations:%s", VTY_NEWLINE); | |
8846 | if (p->status == Established) | |
8847 | { | |
8848 | vty_out (vty, " End-of-RIB send: "); | |
8849 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8850 | { | |
8851 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8852 | { | |
8853 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND)) | |
8854 | { | |
8855 | vty_out (vty, "%s%s", eor_send_af_count ? ", " : "", | |
8856 | afi_safi_print (afi, safi)); | |
8857 | eor_send_af_count++; | |
8858 | } | |
8859 | } | |
8860 | } | |
8861 | vty_out (vty, "%s", VTY_NEWLINE); | |
8862 | vty_out (vty, " End-of-RIB received: "); | |
8863 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8864 | { | |
8865 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8866 | { | |
8867 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED)) | |
8868 | { | |
8869 | vty_out (vty, "%s%s", eor_receive_af_count ? ", " : "", | |
8870 | afi_safi_print (afi, safi)); | |
8871 | eor_receive_af_count++; | |
8872 | } | |
8873 | } | |
8874 | } | |
8875 | vty_out (vty, "%s", VTY_NEWLINE); | |
8876 | } | |
93406d87 | 8877 | |
856ca177 MS |
8878 | if (p->t_gr_restart) |
8879 | vty_out (vty, " The remaining time of restart timer is %ld%s", | |
8880 | thread_timer_remain_second (p->t_gr_restart), VTY_NEWLINE); | |
e52702f2 | 8881 | |
856ca177 MS |
8882 | if (p->t_gr_stale) |
8883 | vty_out (vty, " The remaining time of stalepath timer is %ld%s", | |
8884 | thread_timer_remain_second (p->t_gr_stale), VTY_NEWLINE); | |
8885 | } | |
8886 | } | |
8887 | if (use_json) | |
8888 | { | |
8889 | json_object *json_stat = NULL; | |
8890 | json_stat = json_object_new_object(); | |
8891 | /* Packet counts. */ | |
8892 | json_object_int_add(json_stat, "depthInq", 0); | |
8893 | json_object_int_add(json_stat, "depthOutq", (unsigned long) p->obuf->count); | |
8894 | json_object_int_add(json_stat, "opensSent", p->open_out); | |
8895 | json_object_int_add(json_stat, "opensRecv", p->open_in); | |
8896 | json_object_int_add(json_stat, "notificationsSent", p->notify_out); | |
8897 | json_object_int_add(json_stat, "notificationsRecv", p->notify_in); | |
8898 | json_object_int_add(json_stat, "updatesSent", p->update_out); | |
8899 | json_object_int_add(json_stat, "updatesRecv", p->update_in); | |
8900 | json_object_int_add(json_stat, "keepalivesSent", p->keepalive_out); | |
8901 | json_object_int_add(json_stat, "keepalivesRecv", p->keepalive_in); | |
8902 | json_object_int_add(json_stat, "routeRefreshSent", p->refresh_out); | |
8903 | json_object_int_add(json_stat, "routeRefreshRecv", p->refresh_in); | |
8904 | json_object_int_add(json_stat, "capabilitySent", p->dynamic_cap_out); | |
8905 | json_object_int_add(json_stat, "capabilityRecv", p->dynamic_cap_in); | |
8906 | 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); | |
8907 | 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); | |
8908 | json_object_object_add(json_neigh, "messageStats", json_stat); | |
8909 | } | |
8910 | else | |
8911 | { | |
8912 | /* Packet counts. */ | |
8913 | vty_out (vty, " Message statistics:%s", VTY_NEWLINE); | |
8914 | vty_out (vty, " Inq depth is 0%s", VTY_NEWLINE); | |
8915 | vty_out (vty, " Outq depth is %lu%s", (unsigned long) p->obuf->count, VTY_NEWLINE); | |
8916 | vty_out (vty, " Sent Rcvd%s", VTY_NEWLINE); | |
8917 | vty_out (vty, " Opens: %10d %10d%s", p->open_out, p->open_in, VTY_NEWLINE); | |
8918 | vty_out (vty, " Notifications: %10d %10d%s", p->notify_out, p->notify_in, VTY_NEWLINE); | |
8919 | vty_out (vty, " Updates: %10d %10d%s", p->update_out, p->update_in, VTY_NEWLINE); | |
8920 | vty_out (vty, " Keepalives: %10d %10d%s", p->keepalive_out, p->keepalive_in, VTY_NEWLINE); | |
8921 | vty_out (vty, " Route Refresh: %10d %10d%s", p->refresh_out, p->refresh_in, VTY_NEWLINE); | |
8922 | vty_out (vty, " Capability: %10d %10d%s", p->dynamic_cap_out, p->dynamic_cap_in, VTY_NEWLINE); | |
8923 | vty_out (vty, " Total: %10d %10d%s", p->open_out + p->notify_out + | |
8924 | p->update_out + p->keepalive_out + p->refresh_out + p->dynamic_cap_out, | |
8925 | p->open_in + p->notify_in + p->update_in + p->keepalive_in + p->refresh_in + | |
8926 | p->dynamic_cap_in, VTY_NEWLINE); | |
718e3744 | 8927 | } |
8928 | ||
856ca177 MS |
8929 | if (use_json) |
8930 | { | |
8931 | /* advertisement-interval */ | |
8932 | json_object_int_add(json_neigh, "minBtwnAdvertisementRunsTimerMsecs", p->v_routeadv * 1000); | |
718e3744 | 8933 | |
856ca177 MS |
8934 | /* Update-source. */ |
8935 | if (p->update_if || p->update_source) | |
8936 | { | |
8937 | if (p->update_if) | |
8938 | json_object_string_add(json_neigh, "updateSource", p->update_if); | |
8939 | else if (p->update_source) | |
8940 | json_object_string_add(json_neigh, "updateSource", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN)); | |
8941 | } | |
856ca177 MS |
8942 | } |
8943 | else | |
8944 | { | |
8945 | /* advertisement-interval */ | |
8946 | vty_out (vty, " Minimum time between advertisement runs is %d seconds%s", | |
8947 | p->v_routeadv, VTY_NEWLINE); | |
8948 | ||
8949 | /* Update-source. */ | |
8950 | if (p->update_if || p->update_source) | |
8951 | { | |
8952 | vty_out (vty, " Update source is "); | |
8953 | if (p->update_if) | |
8954 | vty_out (vty, "%s", p->update_if); | |
8955 | else if (p->update_source) | |
8956 | vty_out (vty, "%s", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN)); | |
8957 | vty_out (vty, "%s", VTY_NEWLINE); | |
8958 | } | |
8959 | ||
856ca177 MS |
8960 | vty_out (vty, "%s", VTY_NEWLINE); |
8961 | } | |
718e3744 | 8962 | |
8963 | /* Address Family Information */ | |
856ca177 MS |
8964 | json_object *json_hold = NULL; |
8965 | ||
8966 | if (use_json) | |
8967 | json_hold = json_object_new_object(); | |
8968 | ||
538621f2 | 8969 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) |
8970 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8971 | if (p->afc[afi][safi]) | |
856ca177 | 8972 | bgp_show_peer_afi (vty, p, afi, safi, use_json, json_hold); |
718e3744 | 8973 | |
856ca177 MS |
8974 | if (use_json) |
8975 | { | |
58433ae6 | 8976 | json_object_object_add(json_neigh, "addressFamilyInfo", json_hold); |
e08ac8b7 DW |
8977 | json_object_int_add(json_neigh, "connectionsEstablished", p->established); |
8978 | json_object_int_add(json_neigh, "connectionsDropped", p->dropped); | |
856ca177 MS |
8979 | } |
8980 | else | |
8981 | vty_out (vty, " Connections established %d; dropped %d%s", p->established, p->dropped, | |
8982 | VTY_NEWLINE); | |
718e3744 | 8983 | |
d6661008 | 8984 | if (! p->last_reset) |
856ca177 MS |
8985 | { |
8986 | if (use_json) | |
e08ac8b7 | 8987 | json_object_string_add(json_neigh, "lastReset", "never"); |
856ca177 MS |
8988 | else |
8989 | vty_out (vty, " Last reset never%s", VTY_NEWLINE); | |
8990 | } | |
e0701b79 | 8991 | else |
d6661008 | 8992 | { |
856ca177 MS |
8993 | if (use_json) |
8994 | { | |
8995 | time_t uptime; | |
8996 | struct tm *tm; | |
8997 | ||
8998 | uptime = bgp_clock(); | |
8999 | uptime -= p->resettime; | |
9000 | tm = gmtime(&uptime); | |
e08ac8b7 DW |
9001 | json_object_int_add(json_neigh, "lastResetTimerMsecs", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); |
9002 | json_object_string_add(json_neigh, "lastResetDueTo", peer_down_str[(int) p->last_reset]); | |
cca1dda8 DD |
9003 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND || |
9004 | p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) | |
856ca177 | 9005 | { |
39e871e6 | 9006 | char errorcodesubcode_hexstr[5]; |
cca1dda8 DD |
9007 | char errorcodesubcode_str[256]; |
9008 | ||
9009 | code_str = bgp_notify_code_str(p->notify.code); | |
9010 | subcode_str = bgp_notify_subcode_str(p->notify.code, p->notify.subcode); | |
9011 | ||
39e871e6 | 9012 | sprintf(errorcodesubcode_hexstr, "%02X%02X", p->notify.code, p->notify.subcode); |
e08ac8b7 | 9013 | json_object_string_add(json_neigh, "lastErrorCodeSubcode", errorcodesubcode_hexstr); |
cca1dda8 DD |
9014 | snprintf(errorcodesubcode_str, 255, "%s%s", code_str, subcode_str); |
9015 | json_object_string_add(json_neigh, "lastNotificationReason", errorcodesubcode_str); | |
652b9429 DS |
9016 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED |
9017 | && p->notify.code == BGP_NOTIFY_CEASE | |
9018 | && (p->notify.subcode == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
9019 | || p->notify.subcode == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
9020 | && p->notify.length) | |
9021 | { | |
9022 | char msgbuf[1024]; | |
9023 | const char *msg_str; | |
9024 | ||
9025 | msg_str = bgp_notify_admin_message(msgbuf, sizeof(msgbuf), | |
9026 | (u_char*)p->notify.data, p->notify.length); | |
9027 | if (msg_str) | |
9028 | json_object_string_add(json_neigh, "lastShutdownDescription", msg_str); | |
9029 | } | |
856ca177 MS |
9030 | } |
9031 | } | |
9032 | else | |
d6661008 | 9033 | { |
3a8c7ba1 DW |
9034 | vty_out (vty, " Last reset %s, ", |
9035 | peer_uptime (p->resettime, timebuf, BGP_UPTIME_LEN, 0, NULL)); | |
9036 | ||
9037 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND || | |
9038 | p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) | |
9039 | { | |
9040 | code_str = bgp_notify_code_str(p->notify.code); | |
9041 | subcode_str = bgp_notify_subcode_str(p->notify.code, p->notify.subcode); | |
9042 | vty_out (vty, "due to NOTIFICATION %s (%s%s)%s", | |
9043 | p->last_reset == PEER_DOWN_NOTIFY_SEND ? "sent" : "received", | |
9044 | code_str, subcode_str, VTY_NEWLINE); | |
38de8d02 DL |
9045 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED |
9046 | && p->notify.code == BGP_NOTIFY_CEASE | |
9047 | && (p->notify.subcode == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
9048 | || p->notify.subcode == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
9049 | && p->notify.length) | |
9050 | { | |
9051 | char msgbuf[1024]; | |
9052 | const char *msg_str; | |
9053 | ||
9054 | msg_str = bgp_notify_admin_message(msgbuf, sizeof(msgbuf), | |
9055 | (u_char*)p->notify.data, p->notify.length); | |
9056 | if (msg_str) | |
9057 | vty_out (vty, " Message: \"%s\"%s", msg_str, VTY_NEWLINE); | |
9058 | } | |
3a8c7ba1 DW |
9059 | } |
9060 | else | |
9061 | { | |
9062 | vty_out (vty, "due to %s%s", | |
9063 | peer_down_str[(int) p->last_reset], VTY_NEWLINE); | |
9064 | } | |
856ca177 MS |
9065 | |
9066 | if (p->last_reset_cause_size) | |
d6661008 | 9067 | { |
856ca177 MS |
9068 | msg = p->last_reset_cause; |
9069 | vty_out(vty, " Message received that caused BGP to send a NOTIFICATION:%s ", VTY_NEWLINE); | |
9070 | for (i = 1; i <= p->last_reset_cause_size; i++) | |
9071 | { | |
9072 | vty_out(vty, "%02X", *msg++); | |
d6661008 | 9073 | |
856ca177 MS |
9074 | if (i != p->last_reset_cause_size) |
9075 | { | |
9076 | if (i % 16 == 0) | |
9077 | { | |
9078 | vty_out(vty, "%s ", VTY_NEWLINE); | |
9079 | } | |
9080 | else if (i % 4 == 0) | |
9081 | { | |
9082 | vty_out(vty, " "); | |
9083 | } | |
9084 | } | |
9085 | } | |
9086 | vty_out(vty, "%s", VTY_NEWLINE); | |
d6661008 | 9087 | } |
d6661008 DS |
9088 | } |
9089 | } | |
848973c7 | 9090 | |
718e3744 | 9091 | if (CHECK_FLAG (p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) |
9092 | { | |
856ca177 | 9093 | if (use_json) |
e08ac8b7 | 9094 | json_object_boolean_true_add(json_neigh, "prefixesConfigExceedMax"); |
856ca177 MS |
9095 | else |
9096 | vty_out (vty, " Peer had exceeded the max. no. of prefixes configured.%s", VTY_NEWLINE); | |
0a486e5f | 9097 | |
9098 | if (p->t_pmax_restart) | |
856ca177 MS |
9099 | { |
9100 | if (use_json) | |
9101 | { | |
e08ac8b7 DW |
9102 | json_object_boolean_true_add(json_neigh, "reducePrefixNumFrom"); |
9103 | json_object_int_add(json_neigh, "restartInTimerMsec", thread_timer_remain_second (p->t_pmax_restart) * 1000); | |
856ca177 MS |
9104 | } |
9105 | else | |
9106 | vty_out (vty, " Reduce the no. of prefix from %s, will restart in %ld seconds%s", | |
9107 | p->host, thread_timer_remain_second (p->t_pmax_restart), | |
9108 | VTY_NEWLINE); | |
9109 | } | |
0a486e5f | 9110 | else |
856ca177 MS |
9111 | { |
9112 | if (use_json) | |
e08ac8b7 | 9113 | json_object_boolean_true_add(json_neigh, "reducePrefixNumAndClearIpBgp"); |
856ca177 MS |
9114 | else |
9115 | vty_out (vty, " Reduce the no. of prefix and clear ip bgp %s to restore peering%s", | |
9116 | p->host, VTY_NEWLINE); | |
9117 | } | |
718e3744 | 9118 | } |
9119 | ||
f5a4827d | 9120 | /* EBGP Multihop and GTSM */ |
6d85b15b | 9121 | if (p->sort != BGP_PEER_IBGP) |
f5a4827d | 9122 | { |
856ca177 MS |
9123 | if (use_json) |
9124 | { | |
9125 | if (p->gtsm_hops > 0) | |
9126 | json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->gtsm_hops); | |
9127 | else if (p->ttl > 1) | |
9128 | json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->ttl); | |
9129 | } | |
9130 | else | |
9131 | { | |
9132 | if (p->gtsm_hops > 0) | |
9133 | vty_out (vty, " External BGP neighbor may be up to %d hops away.%s", | |
9134 | p->gtsm_hops, VTY_NEWLINE); | |
9135 | else if (p->ttl > 1) | |
9136 | vty_out (vty, " External BGP neighbor may be up to %d hops away.%s", | |
9137 | p->ttl, VTY_NEWLINE); | |
9138 | } | |
f5a4827d | 9139 | } |
5d804b43 PM |
9140 | else |
9141 | { | |
9142 | if (p->gtsm_hops > 0) | |
856ca177 MS |
9143 | { |
9144 | if (use_json) | |
9145 | json_object_int_add(json_neigh, "internalBgpNbrMaxHopsAway", p->gtsm_hops); | |
9146 | else | |
9147 | vty_out (vty, " Internal BGP neighbor may be up to %d hops away.%s", | |
9148 | p->gtsm_hops, VTY_NEWLINE); | |
9149 | } | |
5d804b43 | 9150 | } |
718e3744 | 9151 | |
9152 | /* Local address. */ | |
9153 | if (p->su_local) | |
9154 | { | |
856ca177 MS |
9155 | if (use_json) |
9156 | { | |
9157 | json_object_string_add(json_neigh, "hostLocal", sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN)); | |
9158 | json_object_int_add(json_neigh, "portLocal", ntohs (p->su_local->sin.sin_port)); | |
9159 | } | |
9160 | else | |
9161 | vty_out (vty, "Local host: %s, Local port: %d%s", | |
9162 | sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN), | |
9163 | ntohs (p->su_local->sin.sin_port), | |
9164 | VTY_NEWLINE); | |
718e3744 | 9165 | } |
e52702f2 | 9166 | |
718e3744 | 9167 | /* Remote address. */ |
9168 | if (p->su_remote) | |
9169 | { | |
856ca177 MS |
9170 | if (use_json) |
9171 | { | |
9172 | json_object_string_add(json_neigh, "hostForeign", sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN)); | |
9173 | json_object_int_add(json_neigh, "portForeign", ntohs (p->su_remote->sin.sin_port)); | |
9174 | } | |
9175 | else | |
9176 | vty_out (vty, "Foreign host: %s, Foreign port: %d%s", | |
718e3744 | 9177 | sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN), |
9178 | ntohs (p->su_remote->sin.sin_port), | |
9179 | VTY_NEWLINE); | |
9180 | } | |
9181 | ||
9182 | /* Nexthop display. */ | |
9183 | if (p->su_local) | |
9184 | { | |
856ca177 MS |
9185 | if (use_json) |
9186 | { | |
389e3fe0 | 9187 | json_object_string_add(json_neigh, "nexthop", |
44b8cd53 | 9188 | inet_ntop (AF_INET, &p->nexthop.v4, buf1, sizeof(buf1))); |
389e3fe0 | 9189 | json_object_string_add(json_neigh, "nexthopGlobal", |
44b8cd53 | 9190 | inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, sizeof(buf1))); |
389e3fe0 | 9191 | json_object_string_add(json_neigh, "nexthopLocal", |
44b8cd53 | 9192 | inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, sizeof(buf1))); |
856ca177 MS |
9193 | if (p->shared_network) |
9194 | json_object_string_add(json_neigh, "bgpConnection", "sharedNetwork"); | |
9195 | else | |
9196 | json_object_string_add(json_neigh, "bgpConnection", "nonSharedNetwork"); | |
856ca177 MS |
9197 | } |
9198 | else | |
9199 | { | |
9200 | vty_out (vty, "Nexthop: %s%s", | |
44b8cd53 DL |
9201 | inet_ntop (AF_INET, &p->nexthop.v4, buf1, sizeof(buf1)), |
9202 | VTY_NEWLINE); | |
856ca177 | 9203 | vty_out (vty, "Nexthop global: %s%s", |
44b8cd53 DL |
9204 | inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, sizeof(buf1)), |
9205 | VTY_NEWLINE); | |
856ca177 | 9206 | vty_out (vty, "Nexthop local: %s%s", |
44b8cd53 DL |
9207 | inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, sizeof(buf1)), |
9208 | VTY_NEWLINE); | |
856ca177 | 9209 | vty_out (vty, "BGP connection: %s%s", |
44b8cd53 DL |
9210 | p->shared_network ? "shared network" : "non shared network", |
9211 | VTY_NEWLINE); | |
856ca177 | 9212 | } |
718e3744 | 9213 | } |
9214 | ||
9215 | /* Timer information. */ | |
856ca177 MS |
9216 | if (use_json) |
9217 | { | |
39e871e6 | 9218 | json_object_int_add(json_neigh, "connectRetryTimer", p->v_connect); |
dd9275d6 ST |
9219 | if (p->status == Established && p->rtt) |
9220 | json_object_int_add(json_neigh, "estimatedRttInMsecs", p->rtt); | |
856ca177 MS |
9221 | if (p->t_start) |
9222 | json_object_int_add(json_neigh, "nextStartTimerDueInMsecs", thread_timer_remain_second (p->t_start) * 1000); | |
9223 | if (p->t_connect) | |
9224 | json_object_int_add(json_neigh, "nextConnectTimerDueInMsecs", thread_timer_remain_second (p->t_connect) * 1000); | |
9225 | if (p->t_routeadv) | |
9226 | { | |
9227 | json_object_int_add(json_neigh, "mraiInterval", p->v_routeadv); | |
9228 | json_object_int_add(json_neigh, "mraiTimerExpireInMsecs", thread_timer_remain_second (p->t_routeadv) * 1000); | |
9229 | } | |
cb1faec9 | 9230 | |
856ca177 MS |
9231 | if (p->t_read) |
9232 | json_object_string_add(json_neigh, "readThread", "on"); | |
9233 | else | |
9234 | json_object_string_add(json_neigh, "readThread", "off"); | |
9235 | if (p->t_write) | |
9236 | json_object_string_add(json_neigh, "writeThread", "on"); | |
9237 | else | |
9238 | json_object_string_add(json_neigh, "writeThread", "off"); | |
9239 | } | |
9240 | else | |
9241 | { | |
39e871e6 ST |
9242 | vty_out (vty, "BGP Connect Retry Timer in Seconds: %d%s", |
9243 | p->v_connect, VTY_NEWLINE); | |
dd9275d6 ST |
9244 | if (p->status == Established && p->rtt) |
9245 | vty_out (vty, "Estimated round trip time: %d ms%s", | |
9246 | p->rtt, VTY_NEWLINE); | |
856ca177 MS |
9247 | if (p->t_start) |
9248 | vty_out (vty, "Next start timer due in %ld seconds%s", | |
9249 | thread_timer_remain_second (p->t_start), VTY_NEWLINE); | |
9250 | if (p->t_connect) | |
9251 | vty_out (vty, "Next connect timer due in %ld seconds%s", | |
9252 | thread_timer_remain_second (p->t_connect), VTY_NEWLINE); | |
9253 | if (p->t_routeadv) | |
9254 | vty_out (vty, "MRAI (interval %u) timer expires in %ld seconds%s", | |
9255 | p->v_routeadv, thread_timer_remain_second (p->t_routeadv), | |
9256 | VTY_NEWLINE); | |
9257 | ||
9258 | vty_out (vty, "Read thread: %s Write thread: %s%s", | |
9259 | p->t_read ? "on" : "off", | |
9260 | p->t_write ? "on" : "off", | |
9261 | VTY_NEWLINE); | |
9262 | } | |
718e3744 | 9263 | |
9264 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
9265 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
856ca177 MS |
9266 | bgp_capability_vty_out (vty, p, use_json, json_neigh); |
9267 | ||
9268 | if (!use_json) | |
9269 | vty_out (vty, "%s", VTY_NEWLINE); | |
c43ed2e4 DS |
9270 | |
9271 | /* BFD information. */ | |
856ca177 MS |
9272 | bgp_bfd_show_info(vty, p, use_json, json_neigh); |
9273 | ||
9274 | if (use_json) | |
9275 | { | |
9276 | if (p->conf_if) /* Configured interface name. */ | |
9277 | json_object_object_add(json, p->conf_if, json_neigh); | |
9278 | else /* Configured IP address. */ | |
9279 | json_object_object_add(json, p->host, json_neigh); | |
9280 | } | |
718e3744 | 9281 | } |
9282 | ||
94f2b392 | 9283 | static int |
856ca177 MS |
9284 | bgp_show_neighbor (struct vty *vty, struct bgp *bgp, enum show_type type, |
9285 | union sockunion *su, const char *conf_if, u_char use_json, json_object *json) | |
718e3744 | 9286 | { |
1eb8ef25 | 9287 | struct listnode *node, *nnode; |
718e3744 | 9288 | struct peer *peer; |
9289 | int find = 0; | |
9290 | ||
1eb8ef25 | 9291 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
718e3744 | 9292 | { |
1ff9a340 DS |
9293 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
9294 | continue; | |
9295 | ||
718e3744 | 9296 | switch (type) |
856ca177 MS |
9297 | { |
9298 | case show_all: | |
e8f7da3a | 9299 | bgp_show_peer (vty, peer, use_json, json); |
856ca177 MS |
9300 | break; |
9301 | case show_peer: | |
9302 | if (conf_if) | |
9303 | { | |
4873b3b9 DW |
9304 | if ((peer->conf_if && !strcmp(peer->conf_if, conf_if)) || |
9305 | (peer->hostname && !strcmp(peer->hostname, conf_if))) | |
856ca177 MS |
9306 | { |
9307 | find = 1; | |
e8f7da3a | 9308 | bgp_show_peer (vty, peer, use_json, json); |
856ca177 MS |
9309 | } |
9310 | } | |
9311 | else | |
9312 | { | |
9313 | if (sockunion_same (&peer->su, su)) | |
9314 | { | |
9315 | find = 1; | |
e8f7da3a | 9316 | bgp_show_peer (vty, peer, use_json, json); |
856ca177 MS |
9317 | } |
9318 | } | |
9319 | break; | |
718e3744 | 9320 | } |
9321 | } | |
9322 | ||
9323 | if (type == show_peer && ! find) | |
856ca177 MS |
9324 | { |
9325 | if (use_json) | |
9326 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
9327 | else | |
9328 | vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE); | |
9329 | } | |
9330 | ||
9331 | if (use_json) | |
9332 | { | |
2aac5767 | 9333 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
856ca177 MS |
9334 | json_object_free(json); |
9335 | } | |
9336 | else | |
9337 | { | |
9338 | vty_out (vty, "%s", VTY_NEWLINE); | |
9339 | } | |
9340 | ||
718e3744 | 9341 | return CMD_SUCCESS; |
9342 | } | |
9343 | ||
f186de26 | 9344 | static void |
9345 | bgp_show_all_instances_neighbors_vty (struct vty *vty, u_char use_json) | |
9346 | { | |
9347 | struct listnode *node, *nnode; | |
9348 | struct bgp *bgp; | |
9349 | json_object *json = NULL; | |
9f689658 DD |
9350 | int is_first = 1; |
9351 | ||
9352 | if (use_json) | |
9353 | vty_out (vty, "{%s", VTY_NEWLINE); | |
f186de26 | 9354 | |
9355 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) | |
9356 | { | |
f186de26 | 9357 | if (use_json) |
9f689658 DD |
9358 | { |
9359 | if (!(json = json_object_new_object())) | |
9360 | { | |
9361 | zlog_err("Unable to allocate memory for JSON object"); | |
9362 | vty_out (vty, | |
9363 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}%s", | |
9364 | VTY_NEWLINE); | |
9365 | return; | |
9366 | } | |
9367 | ||
9368 | json_object_int_add(json, "vrfId", | |
9369 | (bgp->vrf_id == VRF_UNKNOWN) | |
9370 | ? -1 : bgp->vrf_id); | |
9371 | json_object_string_add(json, "vrfName", | |
9372 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
9373 | ? "Default" : bgp->name); | |
9374 | ||
9375 | if (! is_first) | |
9376 | vty_out (vty, ",%s", VTY_NEWLINE); | |
9377 | else | |
9378 | is_first = 0; | |
9379 | ||
9380 | vty_out(vty, "\"%s\":", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
9381 | ? "Default" : bgp->name); | |
9382 | } | |
9383 | else | |
9384 | { | |
9385 | vty_out (vty, "%sInstance %s:%s", | |
9386 | VTY_NEWLINE, | |
9387 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
9388 | ? "Default" : bgp->name, | |
9389 | VTY_NEWLINE); | |
9390 | } | |
f186de26 | 9391 | bgp_show_neighbor (vty, bgp, show_all, NULL, NULL, use_json, json); |
9392 | } | |
9f689658 DD |
9393 | |
9394 | if (use_json) | |
9395 | vty_out (vty, "}%s", VTY_NEWLINE); | |
f186de26 | 9396 | } |
9397 | ||
4fb25c53 DW |
9398 | static int |
9399 | bgp_show_neighbor_vty (struct vty *vty, const char *name, | |
9400 | enum show_type type, const char *ip_str, u_char use_json) | |
9401 | { | |
9402 | int ret; | |
9403 | struct bgp *bgp; | |
9404 | union sockunion su; | |
9405 | json_object *json = NULL; | |
9406 | ||
9407 | if (use_json) | |
9408 | json = json_object_new_object(); | |
9409 | ||
9410 | if (name) | |
9411 | { | |
9412 | if (strmatch(name, "all")) | |
9413 | { | |
9414 | bgp_show_all_instances_neighbors_vty (vty, use_json); | |
9415 | return CMD_SUCCESS; | |
9416 | } | |
9417 | else | |
9418 | { | |
9419 | bgp = bgp_lookup_by_name (name); | |
9420 | if (! bgp) | |
9421 | { | |
9422 | if (use_json) | |
9423 | { | |
9424 | json_object_boolean_true_add(json, "bgpNoSuchInstance"); | |
e52702f2 | 9425 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
4fb25c53 DW |
9426 | json_object_free(json); |
9427 | } | |
9428 | else | |
9429 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
9430 | ||
9431 | return CMD_WARNING; | |
9432 | } | |
9433 | } | |
9434 | } | |
9435 | else | |
9436 | { | |
9437 | bgp = bgp_get_default (); | |
9438 | } | |
9439 | ||
9440 | if (bgp) | |
9441 | { | |
9442 | if (ip_str) | |
9443 | { | |
9444 | ret = str2sockunion (ip_str, &su); | |
9445 | if (ret < 0) | |
9446 | bgp_show_neighbor (vty, bgp, type, NULL, ip_str, use_json, json); | |
9447 | else | |
9448 | bgp_show_neighbor (vty, bgp, type, &su, NULL, use_json, json); | |
9449 | } | |
9450 | else | |
9451 | { | |
9452 | bgp_show_neighbor (vty, bgp, type, NULL, NULL, use_json, json); | |
9453 | } | |
9454 | } | |
9455 | ||
9456 | return CMD_SUCCESS; | |
9457 | } | |
9458 | ||
716b2d8a | 9459 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 9460 | DEFUN (show_ip_bgp_neighbors, |
9461 | show_ip_bgp_neighbors_cmd, | |
91d37724 | 9462 | "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 | 9463 | SHOW_STR |
9464 | IP_STR | |
9465 | BGP_STR | |
f2a8972b | 9466 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
9467 | "Address Family\n" |
9468 | "Address Family\n" | |
91d37724 QY |
9469 | "Address Family\n" |
9470 | "Display information about all VPNv4 NLRIs\n" | |
9471 | "Display information for a route distinguisher\n" | |
9472 | "VPN Route Distinguisher\n" | |
718e3744 | 9473 | "Detailed information on TCP and BGP neighbor connections\n" |
9474 | "Neighbor to display information about\n" | |
a80beece | 9475 | "Neighbor to display information about\n" |
91d37724 | 9476 | "Neighbor on BGP configured interface\n" |
9973d184 | 9477 | JSON_STR) |
718e3744 | 9478 | { |
5bf15956 DW |
9479 | char *vrf = NULL; |
9480 | char *sh_arg = NULL; | |
9481 | enum show_type sh_type; | |
718e3744 | 9482 | |
5bf15956 | 9483 | u_char uj = use_json(argc, argv); |
718e3744 | 9484 | |
630a298c | 9485 | int idx = 0; |
718e3744 | 9486 | |
46854ac0 DS |
9487 | if (argv_find (argv, argc, "view", &idx) || |
9488 | argv_find (argv, argc, "vrf", &idx)) | |
9489 | vrf = argv[idx+1]->arg; | |
718e3744 | 9490 | |
46854ac0 | 9491 | idx++; |
91d37724 QY |
9492 | if (argv_find (argv, argc, "A.B.C.D", &idx) || |
9493 | argv_find (argv, argc, "X:X::X:X", &idx) || | |
630a298c QY |
9494 | argv_find (argv, argc, "WORD", &idx)) |
9495 | { | |
9496 | sh_type = show_peer; | |
9497 | sh_arg = argv[idx]->arg; | |
9498 | } | |
5bf15956 | 9499 | else |
630a298c | 9500 | sh_type = show_all; |
856ca177 | 9501 | |
5bf15956 | 9502 | return bgp_show_neighbor_vty (vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 9503 | } |
9504 | ||
716b2d8a | 9505 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 9506 | paths' and `show ip mbgp paths'. Those functions results are the |
9507 | same.*/ | |
f412b39a | 9508 | DEFUN (show_ip_bgp_paths, |
718e3744 | 9509 | show_ip_bgp_paths_cmd, |
46f296b4 | 9510 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 9511 | SHOW_STR |
9512 | IP_STR | |
9513 | BGP_STR | |
46f296b4 | 9514 | BGP_SAFI_HELP_STR |
718e3744 | 9515 | "Path information\n") |
9516 | { | |
9517 | vty_out (vty, "Address Refcnt Path%s", VTY_NEWLINE); | |
9518 | aspath_print_all_vty (vty); | |
9519 | return CMD_SUCCESS; | |
9520 | } | |
9521 | ||
718e3744 | 9522 | #include "hash.h" |
9523 | ||
94f2b392 | 9524 | static void |
718e3744 | 9525 | community_show_all_iterator (struct hash_backet *backet, struct vty *vty) |
9526 | { | |
9527 | struct community *com; | |
9528 | ||
9529 | com = (struct community *) backet->data; | |
6c4f4e6e | 9530 | vty_out (vty, "[%p] (%ld) %s%s", (void *)backet, com->refcnt, |
718e3744 | 9531 | community_str (com), VTY_NEWLINE); |
9532 | } | |
9533 | ||
9534 | /* Show BGP's community internal data. */ | |
f412b39a | 9535 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 9536 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 9537 | "show [ip] bgp community-info", |
718e3744 | 9538 | SHOW_STR |
9539 | IP_STR | |
9540 | BGP_STR | |
9541 | "List all bgp community information\n") | |
9542 | { | |
9543 | vty_out (vty, "Address Refcnt Community%s", VTY_NEWLINE); | |
9544 | ||
e52702f2 | 9545 | hash_iterate (community_hash (), |
718e3744 | 9546 | (void (*) (struct hash_backet *, void *)) |
9547 | community_show_all_iterator, | |
9548 | vty); | |
9549 | ||
9550 | return CMD_SUCCESS; | |
9551 | } | |
9552 | ||
57d187bc JS |
9553 | static void |
9554 | lcommunity_show_all_iterator (struct hash_backet *backet, struct vty *vty) | |
9555 | { | |
9556 | struct lcommunity *lcom; | |
9557 | ||
9558 | lcom = (struct lcommunity *) backet->data; | |
9559 | vty_out (vty, "[%p] (%ld) %s%s", (void *)backet, lcom->refcnt, | |
2acb4ac2 | 9560 | lcommunity_str (lcom), VTY_NEWLINE); |
57d187bc JS |
9561 | } |
9562 | ||
9563 | /* Show BGP's community internal data. */ | |
9564 | DEFUN (show_ip_bgp_lcommunity_info, | |
9565 | show_ip_bgp_lcommunity_info_cmd, | |
9566 | "show ip bgp large-community-info", | |
9567 | SHOW_STR | |
9568 | IP_STR | |
9569 | BGP_STR | |
9570 | "List all bgp large-community information\n") | |
9571 | { | |
9572 | vty_out (vty, "Address Refcnt Large-community%s", VTY_NEWLINE); | |
9573 | ||
9574 | hash_iterate (lcommunity_hash (), | |
2acb4ac2 DL |
9575 | (void (*) (struct hash_backet *, void *)) |
9576 | lcommunity_show_all_iterator, | |
9577 | vty); | |
57d187bc JS |
9578 | |
9579 | return CMD_SUCCESS; | |
9580 | } | |
9581 | ||
9582 | ||
f412b39a | 9583 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 9584 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 9585 | "show [ip] bgp attribute-info", |
718e3744 | 9586 | SHOW_STR |
9587 | IP_STR | |
9588 | BGP_STR | |
9589 | "List all bgp attribute information\n") | |
9590 | { | |
9591 | attr_show_all (vty); | |
9592 | return CMD_SUCCESS; | |
9593 | } | |
6b0655a2 | 9594 | |
f186de26 | 9595 | static void |
9596 | bgp_show_all_instances_updgrps_vty (struct vty *vty, afi_t afi, safi_t safi) | |
9597 | { | |
9598 | struct listnode *node, *nnode; | |
9599 | struct bgp *bgp; | |
9600 | ||
9601 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) | |
9602 | { | |
9603 | vty_out (vty, "%sInstance %s:%s", | |
9604 | VTY_NEWLINE, | |
9605 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) ? "Default" : bgp->name, | |
9606 | VTY_NEWLINE); | |
9607 | update_group_show(bgp, afi, safi, vty, 0); | |
9608 | } | |
9609 | } | |
9610 | ||
4fb25c53 DW |
9611 | static int |
9612 | bgp_show_update_groups(struct vty *vty, const char *name, | |
9613 | int afi, int safi, | |
9614 | uint64_t subgrp_id) | |
9615 | { | |
9616 | struct bgp *bgp; | |
9617 | ||
9618 | if (name) | |
9619 | { | |
9620 | if (strmatch (name, "all")) | |
9621 | { | |
9622 | bgp_show_all_instances_updgrps_vty (vty, afi, safi); | |
9623 | return CMD_SUCCESS; | |
9624 | } | |
9625 | else | |
9626 | { | |
9627 | bgp = bgp_lookup_by_name (name); | |
9628 | } | |
9629 | } | |
9630 | else | |
9631 | { | |
9632 | bgp = bgp_get_default (); | |
9633 | } | |
9634 | ||
9635 | if (bgp) | |
9636 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
9637 | return CMD_SUCCESS; | |
9638 | } | |
9639 | ||
8fe8a7f6 DS |
9640 | DEFUN (show_ip_bgp_updgrps, |
9641 | show_ip_bgp_updgrps_cmd, | |
c9e571b4 | 9642 | "show [ip] bgp [<view|vrf> WORD] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 9643 | SHOW_STR |
9644 | IP_STR | |
9645 | BGP_STR | |
9646 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 9647 | BGP_AFI_HELP_STR |
46f296b4 | 9648 | BGP_SAFI_HELP_STR |
5bf15956 DW |
9649 | "Detailed info about dynamic update groups\n" |
9650 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 9651 | { |
5bf15956 | 9652 | char *vrf = NULL; |
ae19d7dd QY |
9653 | afi_t afi = AFI_IP6; |
9654 | safi_t safi = SAFI_UNICAST; | |
5bf15956 DW |
9655 | uint64_t subgrp_id = 0; |
9656 | ||
ae19d7dd QY |
9657 | int idx = 0; |
9658 | ||
9659 | /* show [ip] bgp */ | |
9660 | if (argv_find (argv, argc, "ip", &idx)) | |
9661 | afi = AFI_IP; | |
9662 | /* [<view|vrf> WORD] */ | |
9663 | if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) | |
9664 | vrf = argv[++idx]->arg; | |
c9e571b4 LB |
9665 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
9666 | if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) | |
9667 | { | |
9668 | argv_find_and_parse_safi (argv, argc, &idx, &safi); | |
9669 | } | |
5bf15956 | 9670 | |
ae19d7dd QY |
9671 | /* get subgroup id, if provided */ |
9672 | idx = argc - 1; | |
9673 | if (argv[idx]->type == VARIABLE_TKN) | |
9674 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx]->arg); | |
5bf15956 DW |
9675 | |
9676 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); | |
8fe8a7f6 DS |
9677 | } |
9678 | ||
f186de26 | 9679 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
9680 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 9681 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 9682 | SHOW_STR |
716b2d8a | 9683 | IP_STR |
f186de26 | 9684 | BGP_STR |
9685 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 9686 | "Detailed info about dynamic update groups\n") |
f186de26 | 9687 | { |
9688 | bgp_show_all_instances_updgrps_vty (vty, AFI_IP6, SAFI_UNICAST); | |
9689 | return CMD_SUCCESS; | |
9690 | } | |
9691 | ||
5bf15956 DW |
9692 | DEFUN (show_bgp_updgrps_stats, |
9693 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 9694 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 9695 | SHOW_STR |
716b2d8a | 9696 | IP_STR |
3f9c7369 | 9697 | BGP_STR |
0c7b1b01 | 9698 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
9699 | "Statistics\n") |
9700 | { | |
9701 | struct bgp *bgp; | |
9702 | ||
9703 | bgp = bgp_get_default(); | |
9704 | if (bgp) | |
9705 | update_group_show_stats(bgp, vty); | |
9706 | ||
9707 | return CMD_SUCCESS; | |
9708 | } | |
9709 | ||
8386ac43 | 9710 | DEFUN (show_bgp_instance_updgrps_stats, |
9711 | show_bgp_instance_updgrps_stats_cmd, | |
716b2d8a | 9712 | "show [ip] bgp <view|vrf> WORD update-groups statistics", |
8386ac43 | 9713 | SHOW_STR |
716b2d8a | 9714 | IP_STR |
8386ac43 | 9715 | BGP_STR |
9716 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 9717 | "Detailed info about dynamic update groups\n" |
8386ac43 | 9718 | "Statistics\n") |
9719 | { | |
c500ae40 | 9720 | int idx_word = 3; |
8386ac43 | 9721 | struct bgp *bgp; |
9722 | ||
c500ae40 | 9723 | bgp = bgp_lookup_by_name (argv[idx_word]->arg); |
8386ac43 | 9724 | if (bgp) |
9725 | update_group_show_stats(bgp, vty); | |
9726 | ||
9727 | return CMD_SUCCESS; | |
9728 | } | |
9729 | ||
3f9c7369 | 9730 | static void |
8386ac43 | 9731 | show_bgp_updgrps_adj_info_aux (struct vty *vty, const char *name, |
9732 | afi_t afi, safi_t safi, | |
f43e655e | 9733 | const char *what, uint64_t subgrp_id) |
3f9c7369 DS |
9734 | { |
9735 | struct bgp *bgp; | |
8386ac43 | 9736 | |
9737 | if (name) | |
9738 | bgp = bgp_lookup_by_name (name); | |
9739 | else | |
9740 | bgp = bgp_get_default (); | |
9741 | ||
3f9c7369 DS |
9742 | if (bgp) |
9743 | { | |
9744 | if (!strcmp(what, "advertise-queue")) | |
9745 | update_group_show_adj_queue(bgp, afi, safi, vty, subgrp_id); | |
9746 | else if (!strcmp(what, "advertised-routes")) | |
9747 | update_group_show_advertised(bgp, afi, safi, vty, subgrp_id); | |
9748 | else if (!strcmp(what, "packet-queue")) | |
9749 | update_group_show_packet_queue(bgp, afi, safi, vty, subgrp_id); | |
9750 | } | |
9751 | } | |
9752 | ||
9753 | DEFUN (show_ip_bgp_updgrps_adj, | |
9754 | show_ip_bgp_updgrps_adj_cmd, | |
716b2d8a | 9755 | "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 DS |
9756 | SHOW_STR |
9757 | IP_STR | |
9758 | BGP_STR | |
0c7b1b01 | 9759 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
9760 | "Advertisement queue\n" |
9761 | "Announced routes\n" | |
9762 | "Packet queue\n") | |
8fe8a7f6 | 9763 | |
3f9c7369 | 9764 | { |
c500ae40 DW |
9765 | int idx_type = 4; |
9766 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
8386ac43 | 9767 | return CMD_SUCCESS; |
9768 | } | |
9769 | ||
9770 | DEFUN (show_ip_bgp_instance_updgrps_adj, | |
9771 | show_ip_bgp_instance_updgrps_adj_cmd, | |
716b2d8a | 9772 | "show [ip] bgp <view|vrf> WORD update-groups <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 9773 | SHOW_STR |
9774 | IP_STR | |
9775 | BGP_STR | |
9776 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 9777 | "Detailed info about dynamic update groups\n" |
8386ac43 | 9778 | "Advertisement queue\n" |
9779 | "Announced routes\n" | |
9780 | "Packet queue\n") | |
9781 | ||
9782 | { | |
c500ae40 DW |
9783 | int idx_word = 4; |
9784 | int idx_type = 6; | |
9785 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
3f9c7369 DS |
9786 | return CMD_SUCCESS; |
9787 | } | |
9788 | ||
9789 | DEFUN (show_bgp_updgrps_afi_adj, | |
9790 | show_bgp_updgrps_afi_adj_cmd, | |
46f296b4 | 9791 | "show [ip] bgp "BGP_AFI_SAFI_CMD_STR" update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 9792 | SHOW_STR |
716b2d8a | 9793 | IP_STR |
3f9c7369 | 9794 | BGP_STR |
46f296b4 | 9795 | BGP_AFI_SAFI_HELP_STR |
0c7b1b01 | 9796 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
9797 | "Advertisement queue\n" |
9798 | "Announced routes\n" | |
8fe8a7f6 DS |
9799 | "Packet queue\n" |
9800 | "Specific subgroup info wanted for\n") | |
3f9c7369 | 9801 | { |
c500ae40 DW |
9802 | int idx_afi = 2; |
9803 | int idx_safi = 3; | |
9804 | int idx_type = 5; | |
46f296b4 LB |
9805 | show_bgp_updgrps_adj_info_aux(vty, NULL, |
9806 | bgp_vty_afi_from_arg(argv[idx_afi]->arg), | |
9807 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), | |
9808 | argv[idx_type]->arg, 0); | |
8fe8a7f6 | 9809 | return CMD_SUCCESS; |
3f9c7369 DS |
9810 | } |
9811 | ||
9812 | DEFUN (show_bgp_updgrps_adj, | |
9813 | show_bgp_updgrps_adj_cmd, | |
716b2d8a | 9814 | "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 9815 | SHOW_STR |
716b2d8a | 9816 | IP_STR |
3f9c7369 | 9817 | BGP_STR |
0c7b1b01 | 9818 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
9819 | "Advertisement queue\n" |
9820 | "Announced routes\n" | |
9821 | "Packet queue\n") | |
9822 | { | |
c500ae40 DW |
9823 | int idx_type = 3; |
9824 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
8386ac43 | 9825 | return CMD_SUCCESS; |
9826 | } | |
9827 | ||
9828 | DEFUN (show_bgp_instance_updgrps_adj, | |
9829 | show_bgp_instance_updgrps_adj_cmd, | |
716b2d8a | 9830 | "show [ip] bgp <view|vrf> WORD update-groups <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 9831 | SHOW_STR |
716b2d8a | 9832 | IP_STR |
8386ac43 | 9833 | BGP_STR |
9834 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 9835 | "Detailed info about dynamic update groups\n" |
8386ac43 | 9836 | "Advertisement queue\n" |
9837 | "Announced routes\n" | |
9838 | "Packet queue\n") | |
9839 | { | |
c500ae40 DW |
9840 | int idx_word = 3; |
9841 | int idx_type = 5; | |
9842 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
3f9c7369 DS |
9843 | return CMD_SUCCESS; |
9844 | } | |
9845 | ||
9846 | DEFUN (show_ip_bgp_updgrps_adj_s, | |
8fe8a7f6 | 9847 | show_ip_bgp_updgrps_adj_s_cmd, |
716b2d8a | 9848 | "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 DS |
9849 | SHOW_STR |
9850 | IP_STR | |
9851 | BGP_STR | |
0c7b1b01 | 9852 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 | 9853 | "Specific subgroup to display info for\n" |
3f9c7369 DS |
9854 | "Advertisement queue\n" |
9855 | "Announced routes\n" | |
9856 | "Packet queue\n") | |
3f9c7369 | 9857 | |
3f9c7369 | 9858 | { |
5bf15956 | 9859 | int idx_subgroup_id = 4; |
c500ae40 | 9860 | int idx_type = 5; |
f43e655e | 9861 | uint64_t subgrp_id; |
8fe8a7f6 | 9862 | |
5bf15956 | 9863 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8fe8a7f6 | 9864 | |
5bf15956 | 9865 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
8386ac43 | 9866 | return CMD_SUCCESS; |
9867 | } | |
9868 | ||
9869 | DEFUN (show_ip_bgp_instance_updgrps_adj_s, | |
9870 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
716b2d8a | 9871 | "show [ip] bgp <view|vrf> WORD update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 9872 | SHOW_STR |
9873 | IP_STR | |
9874 | BGP_STR | |
9875 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 9876 | "Detailed info about dynamic update groups\n" |
8386ac43 | 9877 | "Specific subgroup to display info for\n" |
9878 | "Advertisement queue\n" | |
9879 | "Announced routes\n" | |
9880 | "Packet queue\n") | |
9881 | ||
9882 | { | |
5bf15956 DW |
9883 | int idx_vrf = 4; |
9884 | int idx_subgroup_id = 6; | |
c500ae40 | 9885 | int idx_type = 7; |
f43e655e | 9886 | uint64_t subgrp_id; |
8386ac43 | 9887 | |
5bf15956 | 9888 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8386ac43 | 9889 | |
5bf15956 | 9890 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
3f9c7369 DS |
9891 | return CMD_SUCCESS; |
9892 | } | |
9893 | ||
8fe8a7f6 DS |
9894 | DEFUN (show_bgp_updgrps_afi_adj_s, |
9895 | show_bgp_updgrps_afi_adj_s_cmd, | |
46f296b4 | 9896 | "show [ip] bgp "BGP_AFI_SAFI_CMD_STR" update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 9897 | SHOW_STR |
716b2d8a | 9898 | IP_STR |
3f9c7369 | 9899 | BGP_STR |
46f296b4 | 9900 | BGP_AFI_SAFI_HELP_STR |
0c7b1b01 | 9901 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 | 9902 | "Specific subgroup to display info for\n" |
3f9c7369 DS |
9903 | "Advertisement queue\n" |
9904 | "Announced routes\n" | |
8fe8a7f6 DS |
9905 | "Packet queue\n" |
9906 | "Specific subgroup info wanted for\n") | |
3f9c7369 | 9907 | { |
c500ae40 DW |
9908 | int idx_afi = 2; |
9909 | int idx_safi = 3; | |
5bf15956 | 9910 | int idx_subgroup_id = 5; |
c500ae40 | 9911 | int idx_type = 6; |
f43e655e | 9912 | uint64_t subgrp_id; |
3f9c7369 | 9913 | |
5bf15956 | 9914 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8fe8a7f6 | 9915 | |
46f296b4 LB |
9916 | show_bgp_updgrps_adj_info_aux(vty, NULL, |
9917 | bgp_vty_afi_from_arg(argv[idx_afi]->arg), | |
9918 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), | |
9919 | argv[idx_type]->arg, subgrp_id); | |
8fe8a7f6 | 9920 | return CMD_SUCCESS; |
3f9c7369 DS |
9921 | } |
9922 | ||
8fe8a7f6 DS |
9923 | DEFUN (show_bgp_updgrps_adj_s, |
9924 | show_bgp_updgrps_adj_s_cmd, | |
716b2d8a | 9925 | "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8fe8a7f6 | 9926 | SHOW_STR |
716b2d8a | 9927 | IP_STR |
8fe8a7f6 | 9928 | BGP_STR |
0c7b1b01 | 9929 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 DS |
9930 | "Specific subgroup to display info for\n" |
9931 | "Advertisement queue\n" | |
9932 | "Announced routes\n" | |
9933 | "Packet queue\n") | |
9934 | { | |
5bf15956 | 9935 | int idx_subgroup_id = 3; |
c500ae40 | 9936 | int idx_type = 4; |
f43e655e | 9937 | uint64_t subgrp_id; |
8fe8a7f6 | 9938 | |
5bf15956 | 9939 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8fe8a7f6 | 9940 | |
5bf15956 | 9941 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
8fe8a7f6 DS |
9942 | return CMD_SUCCESS; |
9943 | } | |
9944 | ||
8386ac43 | 9945 | DEFUN (show_bgp_instance_updgrps_adj_s, |
9946 | show_bgp_instance_updgrps_adj_s_cmd, | |
716b2d8a | 9947 | "show [ip] bgp <view|vrf> WORD update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 9948 | SHOW_STR |
716b2d8a | 9949 | IP_STR |
8386ac43 | 9950 | BGP_STR |
9951 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 9952 | "Detailed info about dynamic update groups\n" |
8386ac43 | 9953 | "Specific subgroup to display info for\n" |
9954 | "Advertisement queue\n" | |
9955 | "Announced routes\n" | |
9956 | "Packet queue\n") | |
9957 | { | |
5bf15956 DW |
9958 | int idx_vrf = 3; |
9959 | int idx_subgroup_id = 5; | |
c500ae40 | 9960 | int idx_type = 6; |
f43e655e | 9961 | uint64_t subgrp_id; |
8386ac43 | 9962 | |
5bf15956 | 9963 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8386ac43 | 9964 | |
5bf15956 | 9965 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
8386ac43 | 9966 | return CMD_SUCCESS; |
9967 | } | |
9968 | ||
9969 | ||
8fe8a7f6 | 9970 | |
f14e6fdb DS |
9971 | static int |
9972 | bgp_show_one_peer_group (struct vty *vty, struct peer_group *group) | |
9973 | { | |
9974 | struct listnode *node, *nnode; | |
9975 | struct prefix *range; | |
9976 | struct peer *conf; | |
9977 | struct peer *peer; | |
4690c7d7 | 9978 | char buf[PREFIX2STR_BUFFER]; |
f14e6fdb DS |
9979 | afi_t afi; |
9980 | safi_t safi; | |
ffd0c037 DS |
9981 | const char *peer_status; |
9982 | const char *af_str; | |
f14e6fdb DS |
9983 | int lr_count; |
9984 | int dynamic; | |
9985 | int af_cfgd; | |
9986 | ||
9987 | conf = group->conf; | |
9988 | ||
0299c004 DS |
9989 | if (conf->as_type == AS_SPECIFIED || |
9990 | conf->as_type == AS_EXTERNAL) { | |
66b199b2 | 9991 | vty_out (vty, "%sBGP peer-group %s, remote AS %d%s", |
f14e6fdb | 9992 | VTY_NEWLINE, group->name, conf->as, VTY_NEWLINE); |
0299c004 | 9993 | } else if (conf->as_type == AS_INTERNAL) { |
66b199b2 | 9994 | vty_out (vty, "%sBGP peer-group %s, remote AS %d%s", |
0299c004 | 9995 | VTY_NEWLINE, group->name, group->bgp->as, VTY_NEWLINE); |
66b199b2 DS |
9996 | } else { |
9997 | vty_out (vty, "%sBGP peer-group %s%s", | |
9998 | VTY_NEWLINE, group->name, VTY_NEWLINE); | |
0299c004 | 9999 | } |
f14e6fdb | 10000 | |
0299c004 | 10001 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
f14e6fdb DS |
10002 | vty_out (vty, " Peer-group type is internal%s", VTY_NEWLINE); |
10003 | else | |
10004 | vty_out (vty, " Peer-group type is external%s", VTY_NEWLINE); | |
10005 | ||
10006 | /* Display AFs configured. */ | |
10007 | vty_out (vty, " Configured address-families:"); | |
10008 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
10009 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
10010 | { | |
10011 | if (conf->afc[afi][safi]) | |
10012 | { | |
10013 | af_cfgd = 1; | |
10014 | vty_out (vty, " %s;", afi_safi_print(afi, safi)); | |
10015 | } | |
10016 | } | |
10017 | if (!af_cfgd) | |
10018 | vty_out (vty, " none%s", VTY_NEWLINE); | |
10019 | else | |
10020 | vty_out (vty, "%s", VTY_NEWLINE); | |
10021 | ||
10022 | /* Display listen ranges (for dynamic neighbors), if any */ | |
10023 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
10024 | { | |
10025 | if (afi == AFI_IP) | |
10026 | af_str = "IPv4"; | |
10027 | else if (afi == AFI_IP6) | |
10028 | af_str = "IPv6"; | |
45ef4300 DL |
10029 | else |
10030 | af_str = "???"; | |
f14e6fdb DS |
10031 | lr_count = listcount(group->listen_range[afi]); |
10032 | if (lr_count) | |
10033 | { | |
10034 | vty_out(vty, | |
10035 | " %d %s listen range(s)%s", | |
10036 | lr_count, af_str, VTY_NEWLINE); | |
10037 | ||
10038 | ||
10039 | for (ALL_LIST_ELEMENTS (group->listen_range[afi], node, | |
10040 | nnode, range)) | |
10041 | { | |
10042 | prefix2str(range, buf, sizeof(buf)); | |
10043 | vty_out(vty, " %s%s", buf, VTY_NEWLINE); | |
10044 | } | |
10045 | } | |
10046 | } | |
10047 | ||
10048 | /* Display group members and their status */ | |
10049 | if (listcount(group->peer)) | |
10050 | { | |
10051 | vty_out (vty, " Peer-group members:%s", VTY_NEWLINE); | |
10052 | for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) | |
10053 | { | |
10054 | if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) | |
10055 | peer_status = "Idle (Admin)"; | |
10056 | else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) | |
10057 | peer_status = "Idle (PfxCt)"; | |
10058 | else | |
10059 | peer_status = LOOKUP(bgp_status_msg, peer->status); | |
10060 | ||
10061 | dynamic = peer_dynamic_neighbor(peer); | |
10062 | vty_out (vty, " %s %s %s %s", | |
10063 | peer->host, dynamic ? "(dynamic)" : "", | |
10064 | peer_status, VTY_NEWLINE); | |
10065 | } | |
10066 | } | |
10067 | ||
10068 | return CMD_SUCCESS; | |
10069 | } | |
10070 | ||
10071 | /* Show BGP peer group's information. */ | |
10072 | enum show_group_type | |
10073 | { | |
10074 | show_all_groups, | |
10075 | show_peer_group | |
10076 | }; | |
10077 | ||
10078 | static int | |
10079 | bgp_show_peer_group (struct vty *vty, struct bgp *bgp, | |
10080 | enum show_group_type type, const char *group_name) | |
10081 | { | |
10082 | struct listnode *node, *nnode; | |
10083 | struct peer_group *group; | |
10084 | int find = 0; | |
10085 | ||
10086 | for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) | |
10087 | { | |
10088 | switch (type) | |
10089 | { | |
10090 | case show_all_groups: | |
10091 | bgp_show_one_peer_group (vty, group); | |
10092 | break; | |
10093 | case show_peer_group: | |
10094 | if (group_name && (strcmp(group->name, group_name) == 0)) | |
10095 | { | |
10096 | find = 1; | |
10097 | bgp_show_one_peer_group (vty, group); | |
10098 | } | |
10099 | break; | |
10100 | } | |
10101 | } | |
10102 | ||
10103 | if (type == show_peer_group && ! find) | |
6d9e66dc | 10104 | vty_out (vty, "%% No such peer-group%s", VTY_NEWLINE); |
f14e6fdb DS |
10105 | |
10106 | return CMD_SUCCESS; | |
10107 | } | |
10108 | ||
10109 | static int | |
10110 | bgp_show_peer_group_vty (struct vty *vty, const char *name, | |
10111 | enum show_group_type type, const char *group_name) | |
10112 | { | |
10113 | struct bgp *bgp; | |
10114 | int ret = CMD_SUCCESS; | |
10115 | ||
10116 | if (name) | |
8386ac43 | 10117 | bgp = bgp_lookup_by_name (name); |
10118 | else | |
10119 | bgp = bgp_get_default (); | |
f14e6fdb | 10120 | |
8386ac43 | 10121 | if (! bgp) |
10122 | { | |
10123 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
10124 | return CMD_WARNING; | |
f14e6fdb DS |
10125 | } |
10126 | ||
8386ac43 | 10127 | ret = bgp_show_peer_group (vty, bgp, type, group_name); |
f14e6fdb DS |
10128 | |
10129 | return ret; | |
10130 | } | |
10131 | ||
10132 | DEFUN (show_ip_bgp_peer_groups, | |
10133 | show_ip_bgp_peer_groups_cmd, | |
f2a8972b | 10134 | "show [ip] bgp [<view|vrf> WORD] peer-group [PGNAME]", |
f14e6fdb DS |
10135 | SHOW_STR |
10136 | IP_STR | |
10137 | BGP_STR | |
8386ac43 | 10138 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
10139 | "Detailed information on BGP peer groups\n" |
10140 | "Peer group name\n") | |
f14e6fdb | 10141 | { |
d6e3c605 QY |
10142 | char *vrf, *pg; |
10143 | vrf = pg = NULL; | |
10144 | int idx = 0; | |
f14e6fdb | 10145 | |
f2a8972b | 10146 | vrf = argv_find (argv, argc, "WORD", &idx) ? argv[idx]->arg : NULL; |
d6e3c605 | 10147 | pg = argv_find (argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 10148 | |
d6e3c605 | 10149 | return bgp_show_peer_group_vty (vty, vrf, show_all_groups, pg); |
f14e6fdb | 10150 | } |
3f9c7369 | 10151 | |
d6e3c605 | 10152 | |
718e3744 | 10153 | /* Redistribute VTY commands. */ |
10154 | ||
718e3744 | 10155 | DEFUN (bgp_redistribute_ipv4, |
10156 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 10157 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 10158 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10159 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 10160 | { |
cdc2d765 | 10161 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 10162 | int idx_protocol = 1; |
718e3744 | 10163 | int type; |
10164 | ||
6d681bd8 QY |
10165 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
10166 | if (type < 0) | |
718e3744 | 10167 | { |
10168 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
10169 | return CMD_WARNING; | |
10170 | } | |
cdc2d765 DL |
10171 | bgp_redist_add(bgp, AFI_IP, type, 0); |
10172 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); | |
718e3744 | 10173 | } |
10174 | ||
596c17ba DW |
10175 | ALIAS_HIDDEN (bgp_redistribute_ipv4, |
10176 | bgp_redistribute_ipv4_hidden_cmd, | |
10177 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
10178 | "Redistribute information from another routing protocol\n" | |
10179 | FRR_IP_REDIST_HELP_STR_BGPD) | |
10180 | ||
718e3744 | 10181 | DEFUN (bgp_redistribute_ipv4_rmap, |
10182 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 10183 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 10184 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10185 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 10186 | "Route map reference\n" |
10187 | "Pointer to route-map entries\n") | |
10188 | { | |
cdc2d765 | 10189 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
10190 | int idx_protocol = 1; |
10191 | int idx_word = 3; | |
718e3744 | 10192 | int type; |
7c8ff89e | 10193 | struct bgp_redist *red; |
718e3744 | 10194 | |
6d681bd8 QY |
10195 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
10196 | if (type < 0) | |
718e3744 | 10197 | { |
10198 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
10199 | return CMD_WARNING; | |
10200 | } | |
10201 | ||
cdc2d765 | 10202 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
c500ae40 | 10203 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 10204 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); |
718e3744 | 10205 | } |
10206 | ||
596c17ba DW |
10207 | ALIAS_HIDDEN (bgp_redistribute_ipv4_rmap, |
10208 | bgp_redistribute_ipv4_rmap_hidden_cmd, | |
10209 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
10210 | "Redistribute information from another routing protocol\n" | |
10211 | FRR_IP_REDIST_HELP_STR_BGPD | |
10212 | "Route map reference\n" | |
10213 | "Pointer to route-map entries\n") | |
10214 | ||
718e3744 | 10215 | DEFUN (bgp_redistribute_ipv4_metric, |
10216 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 10217 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 10218 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10219 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 10220 | "Metric for redistributed routes\n" |
10221 | "Default metric\n") | |
10222 | { | |
cdc2d765 | 10223 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
10224 | int idx_protocol = 1; |
10225 | int idx_number = 3; | |
718e3744 | 10226 | int type; |
10227 | u_int32_t metric; | |
7c8ff89e | 10228 | struct bgp_redist *red; |
718e3744 | 10229 | |
6d681bd8 QY |
10230 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
10231 | if (type < 0) | |
718e3744 | 10232 | { |
10233 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
10234 | return CMD_WARNING; | |
10235 | } | |
c500ae40 | 10236 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 10237 | |
cdc2d765 DL |
10238 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
10239 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
10240 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); | |
718e3744 | 10241 | } |
10242 | ||
596c17ba DW |
10243 | ALIAS_HIDDEN (bgp_redistribute_ipv4_metric, |
10244 | bgp_redistribute_ipv4_metric_hidden_cmd, | |
10245 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
10246 | "Redistribute information from another routing protocol\n" | |
10247 | FRR_IP_REDIST_HELP_STR_BGPD | |
10248 | "Metric for redistributed routes\n" | |
10249 | "Default metric\n") | |
10250 | ||
718e3744 | 10251 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
10252 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 10253 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 10254 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10255 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 10256 | "Route map reference\n" |
10257 | "Pointer to route-map entries\n" | |
10258 | "Metric for redistributed routes\n" | |
10259 | "Default metric\n") | |
10260 | { | |
cdc2d765 | 10261 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
10262 | int idx_protocol = 1; |
10263 | int idx_word = 3; | |
10264 | int idx_number = 5; | |
718e3744 | 10265 | int type; |
10266 | u_int32_t metric; | |
7c8ff89e | 10267 | struct bgp_redist *red; |
718e3744 | 10268 | |
6d681bd8 QY |
10269 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
10270 | if (type < 0) | |
718e3744 | 10271 | { |
10272 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
10273 | return CMD_WARNING; | |
10274 | } | |
c500ae40 | 10275 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 10276 | |
cdc2d765 | 10277 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
c500ae40 | 10278 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 DL |
10279 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
10280 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); | |
718e3744 | 10281 | } |
10282 | ||
596c17ba DW |
10283 | ALIAS_HIDDEN (bgp_redistribute_ipv4_rmap_metric, |
10284 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
10285 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", | |
10286 | "Redistribute information from another routing protocol\n" | |
10287 | FRR_IP_REDIST_HELP_STR_BGPD | |
10288 | "Route map reference\n" | |
10289 | "Pointer to route-map entries\n" | |
10290 | "Metric for redistributed routes\n" | |
10291 | "Default metric\n") | |
10292 | ||
718e3744 | 10293 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
10294 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 10295 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 10296 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10297 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 10298 | "Metric for redistributed routes\n" |
10299 | "Default metric\n" | |
10300 | "Route map reference\n" | |
10301 | "Pointer to route-map entries\n") | |
10302 | { | |
cdc2d765 | 10303 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
10304 | int idx_protocol = 1; |
10305 | int idx_number = 3; | |
10306 | int idx_word = 5; | |
718e3744 | 10307 | int type; |
10308 | u_int32_t metric; | |
7c8ff89e | 10309 | struct bgp_redist *red; |
718e3744 | 10310 | |
6d681bd8 QY |
10311 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
10312 | if (type < 0) | |
718e3744 | 10313 | { |
10314 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
10315 | return CMD_WARNING; | |
10316 | } | |
c500ae40 | 10317 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 10318 | |
cdc2d765 DL |
10319 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
10320 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
c500ae40 | 10321 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 10322 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); |
718e3744 | 10323 | } |
10324 | ||
596c17ba DW |
10325 | ALIAS_HIDDEN (bgp_redistribute_ipv4_metric_rmap, |
10326 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
10327 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", | |
10328 | "Redistribute information from another routing protocol\n" | |
10329 | FRR_IP_REDIST_HELP_STR_BGPD | |
10330 | "Metric for redistributed routes\n" | |
10331 | "Default metric\n" | |
10332 | "Route map reference\n" | |
10333 | "Pointer to route-map entries\n") | |
10334 | ||
7c8ff89e DS |
10335 | DEFUN (bgp_redistribute_ipv4_ospf, |
10336 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 10337 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
10338 | "Redistribute information from another routing protocol\n" |
10339 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
10340 | "Non-main Kernel Routing Table\n" |
10341 | "Instance ID/Table ID\n") | |
7c8ff89e | 10342 | { |
cdc2d765 | 10343 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
10344 | int idx_ospf_table = 1; |
10345 | int idx_number = 2; | |
7c8ff89e | 10346 | u_short instance; |
7a4bb9c5 | 10347 | u_short protocol; |
7c8ff89e | 10348 | |
c500ae40 | 10349 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
7a4bb9c5 | 10350 | |
c500ae40 | 10351 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
10352 | protocol = ZEBRA_ROUTE_OSPF; |
10353 | else | |
10354 | protocol = ZEBRA_ROUTE_TABLE; | |
10355 | ||
cdc2d765 DL |
10356 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
10357 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
10358 | } |
10359 | ||
596c17ba DW |
10360 | ALIAS_HIDDEN (bgp_redistribute_ipv4_ospf, |
10361 | bgp_redistribute_ipv4_ospf_hidden_cmd, | |
10362 | "redistribute <ospf|table> (1-65535)", | |
10363 | "Redistribute information from another routing protocol\n" | |
10364 | "Open Shortest Path First (OSPFv2)\n" | |
10365 | "Non-main Kernel Routing Table\n" | |
10366 | "Instance ID/Table ID\n") | |
10367 | ||
7c8ff89e DS |
10368 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
10369 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 10370 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
10371 | "Redistribute information from another routing protocol\n" |
10372 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
10373 | "Non-main Kernel Routing Table\n" |
10374 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
10375 | "Route map reference\n" |
10376 | "Pointer to route-map entries\n") | |
10377 | { | |
cdc2d765 | 10378 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
10379 | int idx_ospf_table = 1; |
10380 | int idx_number = 2; | |
10381 | int idx_word = 4; | |
7c8ff89e DS |
10382 | struct bgp_redist *red; |
10383 | u_short instance; | |
7a4bb9c5 | 10384 | int protocol; |
7c8ff89e | 10385 | |
c500ae40 | 10386 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
10387 | protocol = ZEBRA_ROUTE_OSPF; |
10388 | else | |
10389 | protocol = ZEBRA_ROUTE_TABLE; | |
10390 | ||
c500ae40 | 10391 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
cdc2d765 | 10392 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
c500ae40 | 10393 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 10394 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); |
7c8ff89e DS |
10395 | } |
10396 | ||
596c17ba DW |
10397 | ALIAS_HIDDEN (bgp_redistribute_ipv4_ospf_rmap, |
10398 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
10399 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
10400 | "Redistribute information from another routing protocol\n" | |
10401 | "Open Shortest Path First (OSPFv2)\n" | |
10402 | "Non-main Kernel Routing Table\n" | |
10403 | "Instance ID/Table ID\n" | |
10404 | "Route map reference\n" | |
10405 | "Pointer to route-map entries\n") | |
10406 | ||
7c8ff89e DS |
10407 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
10408 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 10409 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
10410 | "Redistribute information from another routing protocol\n" |
10411 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
10412 | "Non-main Kernel Routing Table\n" |
10413 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
10414 | "Metric for redistributed routes\n" |
10415 | "Default metric\n") | |
10416 | { | |
cdc2d765 | 10417 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
10418 | int idx_ospf_table = 1; |
10419 | int idx_number = 2; | |
10420 | int idx_number_2 = 4; | |
7c8ff89e DS |
10421 | u_int32_t metric; |
10422 | struct bgp_redist *red; | |
10423 | u_short instance; | |
7a4bb9c5 | 10424 | int protocol; |
7c8ff89e | 10425 | |
c500ae40 | 10426 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
10427 | protocol = ZEBRA_ROUTE_OSPF; |
10428 | else | |
10429 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 10430 | |
c500ae40 DW |
10431 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
10432 | VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); | |
7a4bb9c5 | 10433 | |
cdc2d765 DL |
10434 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
10435 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
10436 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
10437 | } |
10438 | ||
596c17ba DW |
10439 | ALIAS_HIDDEN (bgp_redistribute_ipv4_ospf_metric, |
10440 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
10441 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
10442 | "Redistribute information from another routing protocol\n" | |
10443 | "Open Shortest Path First (OSPFv2)\n" | |
10444 | "Non-main Kernel Routing Table\n" | |
10445 | "Instance ID/Table ID\n" | |
10446 | "Metric for redistributed routes\n" | |
10447 | "Default metric\n") | |
10448 | ||
7c8ff89e DS |
10449 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
10450 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 10451 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
10452 | "Redistribute information from another routing protocol\n" |
10453 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
10454 | "Non-main Kernel Routing Table\n" |
10455 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
10456 | "Route map reference\n" |
10457 | "Pointer to route-map entries\n" | |
10458 | "Metric for redistributed routes\n" | |
10459 | "Default metric\n") | |
10460 | { | |
cdc2d765 | 10461 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
10462 | int idx_ospf_table = 1; |
10463 | int idx_number = 2; | |
10464 | int idx_word = 4; | |
10465 | int idx_number_2 = 6; | |
7c8ff89e DS |
10466 | u_int32_t metric; |
10467 | struct bgp_redist *red; | |
10468 | u_short instance; | |
7a4bb9c5 | 10469 | int protocol; |
7c8ff89e | 10470 | |
c500ae40 | 10471 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
10472 | protocol = ZEBRA_ROUTE_OSPF; |
10473 | else | |
10474 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 10475 | |
c500ae40 DW |
10476 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
10477 | VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); | |
7a4bb9c5 | 10478 | |
cdc2d765 | 10479 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
c500ae40 | 10480 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 DL |
10481 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); |
10482 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
10483 | } |
10484 | ||
596c17ba DW |
10485 | ALIAS_HIDDEN (bgp_redistribute_ipv4_ospf_rmap_metric, |
10486 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
10487 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
10488 | "Redistribute information from another routing protocol\n" | |
10489 | "Open Shortest Path First (OSPFv2)\n" | |
10490 | "Non-main Kernel Routing Table\n" | |
10491 | "Instance ID/Table ID\n" | |
10492 | "Route map reference\n" | |
10493 | "Pointer to route-map entries\n" | |
10494 | "Metric for redistributed routes\n" | |
10495 | "Default metric\n") | |
10496 | ||
7c8ff89e DS |
10497 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
10498 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 10499 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
10500 | "Redistribute information from another routing protocol\n" |
10501 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
10502 | "Non-main Kernel Routing Table\n" |
10503 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
10504 | "Metric for redistributed routes\n" |
10505 | "Default metric\n" | |
10506 | "Route map reference\n" | |
10507 | "Pointer to route-map entries\n") | |
10508 | { | |
cdc2d765 | 10509 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
10510 | int idx_ospf_table = 1; |
10511 | int idx_number = 2; | |
10512 | int idx_number_2 = 4; | |
10513 | int idx_word = 6; | |
7c8ff89e DS |
10514 | u_int32_t metric; |
10515 | struct bgp_redist *red; | |
10516 | u_short instance; | |
7a4bb9c5 | 10517 | int protocol; |
7c8ff89e | 10518 | |
c500ae40 | 10519 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
10520 | protocol = ZEBRA_ROUTE_OSPF; |
10521 | else | |
10522 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 10523 | |
c500ae40 DW |
10524 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
10525 | VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); | |
7a4bb9c5 | 10526 | |
cdc2d765 DL |
10527 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
10528 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
c500ae40 | 10529 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 10530 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); |
7c8ff89e DS |
10531 | } |
10532 | ||
596c17ba DW |
10533 | ALIAS_HIDDEN (bgp_redistribute_ipv4_ospf_metric_rmap, |
10534 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
10535 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
10536 | "Redistribute information from another routing protocol\n" | |
10537 | "Open Shortest Path First (OSPFv2)\n" | |
10538 | "Non-main Kernel Routing Table\n" | |
10539 | "Instance ID/Table ID\n" | |
10540 | "Metric for redistributed routes\n" | |
10541 | "Default metric\n" | |
10542 | "Route map reference\n" | |
10543 | "Pointer to route-map entries\n") | |
10544 | ||
7c8ff89e DS |
10545 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
10546 | no_bgp_redistribute_ipv4_ospf_cmd, | |
d04c479d | 10547 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", |
7c8ff89e DS |
10548 | NO_STR |
10549 | "Redistribute information from another routing protocol\n" | |
10550 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 10551 | "Non-main Kernel Routing Table\n" |
31500417 DW |
10552 | "Instance ID/Table ID\n" |
10553 | "Metric for redistributed routes\n" | |
10554 | "Default metric\n" | |
10555 | "Route map reference\n" | |
10556 | "Pointer to route-map entries\n") | |
7c8ff89e | 10557 | { |
cdc2d765 | 10558 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
10559 | int idx_ospf_table = 2; |
10560 | int idx_number = 3; | |
7c8ff89e | 10561 | u_short instance; |
7a4bb9c5 DS |
10562 | int protocol; |
10563 | ||
c500ae40 | 10564 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
10565 | protocol = ZEBRA_ROUTE_OSPF; |
10566 | else | |
10567 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 10568 | |
c500ae40 | 10569 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
cdc2d765 | 10570 | return bgp_redistribute_unset (bgp, AFI_IP, protocol, instance); |
7c8ff89e DS |
10571 | } |
10572 | ||
596c17ba DW |
10573 | ALIAS_HIDDEN (no_bgp_redistribute_ipv4_ospf, |
10574 | no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
10575 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", | |
10576 | NO_STR | |
10577 | "Redistribute information from another routing protocol\n" | |
10578 | "Open Shortest Path First (OSPFv2)\n" | |
10579 | "Non-main Kernel Routing Table\n" | |
10580 | "Instance ID/Table ID\n" | |
10581 | "Metric for redistributed routes\n" | |
10582 | "Default metric\n" | |
10583 | "Route map reference\n" | |
10584 | "Pointer to route-map entries\n") | |
10585 | ||
718e3744 | 10586 | DEFUN (no_bgp_redistribute_ipv4, |
10587 | no_bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 10588 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 10589 | NO_STR |
10590 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 10591 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
10592 | "Metric for redistributed routes\n" |
10593 | "Default metric\n" | |
10594 | "Route map reference\n" | |
10595 | "Pointer to route-map entries\n") | |
718e3744 | 10596 | { |
cdc2d765 | 10597 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 10598 | int idx_protocol = 2; |
718e3744 | 10599 | int type; |
10600 | ||
6d681bd8 QY |
10601 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
10602 | if (type < 0) | |
718e3744 | 10603 | { |
10604 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
10605 | return CMD_WARNING; | |
10606 | } | |
cdc2d765 | 10607 | return bgp_redistribute_unset (bgp, AFI_IP, type, 0); |
718e3744 | 10608 | } |
10609 | ||
596c17ba DW |
10610 | ALIAS_HIDDEN (no_bgp_redistribute_ipv4, |
10611 | no_bgp_redistribute_ipv4_hidden_cmd, | |
10612 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", | |
10613 | NO_STR | |
10614 | "Redistribute information from another routing protocol\n" | |
10615 | FRR_IP_REDIST_HELP_STR_BGPD | |
10616 | "Metric for redistributed routes\n" | |
10617 | "Default metric\n" | |
10618 | "Route map reference\n" | |
10619 | "Pointer to route-map entries\n") | |
10620 | ||
718e3744 | 10621 | DEFUN (bgp_redistribute_ipv6, |
10622 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 10623 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 10624 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10625 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 10626 | { |
cdc2d765 | 10627 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 10628 | int idx_protocol = 1; |
718e3744 | 10629 | int type; |
10630 | ||
6d681bd8 QY |
10631 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
10632 | if (type < 0) | |
718e3744 | 10633 | { |
10634 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
10635 | return CMD_WARNING; | |
10636 | } | |
10637 | ||
cdc2d765 DL |
10638 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
10639 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); | |
718e3744 | 10640 | } |
10641 | ||
10642 | DEFUN (bgp_redistribute_ipv6_rmap, | |
10643 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 10644 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 10645 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10646 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 10647 | "Route map reference\n" |
10648 | "Pointer to route-map entries\n") | |
10649 | { | |
cdc2d765 | 10650 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
10651 | int idx_protocol = 1; |
10652 | int idx_word = 3; | |
718e3744 | 10653 | int type; |
7c8ff89e | 10654 | struct bgp_redist *red; |
718e3744 | 10655 | |
6d681bd8 QY |
10656 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
10657 | if (type < 0) | |
718e3744 | 10658 | { |
10659 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
10660 | return CMD_WARNING; | |
10661 | } | |
10662 | ||
cdc2d765 | 10663 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
c500ae40 | 10664 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 10665 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); |
718e3744 | 10666 | } |
10667 | ||
10668 | DEFUN (bgp_redistribute_ipv6_metric, | |
10669 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 10670 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 10671 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10672 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 10673 | "Metric for redistributed routes\n" |
10674 | "Default metric\n") | |
10675 | { | |
cdc2d765 | 10676 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
10677 | int idx_protocol = 1; |
10678 | int idx_number = 3; | |
718e3744 | 10679 | int type; |
10680 | u_int32_t metric; | |
7c8ff89e | 10681 | struct bgp_redist *red; |
718e3744 | 10682 | |
6d681bd8 QY |
10683 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
10684 | if (type < 0) | |
718e3744 | 10685 | { |
10686 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
10687 | return CMD_WARNING; | |
10688 | } | |
c500ae40 | 10689 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 10690 | |
cdc2d765 DL |
10691 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
10692 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
10693 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); | |
718e3744 | 10694 | } |
10695 | ||
10696 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
10697 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 10698 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 10699 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10700 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 10701 | "Route map reference\n" |
10702 | "Pointer to route-map entries\n" | |
10703 | "Metric for redistributed routes\n" | |
10704 | "Default metric\n") | |
10705 | { | |
cdc2d765 | 10706 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
10707 | int idx_protocol = 1; |
10708 | int idx_word = 3; | |
10709 | int idx_number = 5; | |
718e3744 | 10710 | int type; |
10711 | u_int32_t metric; | |
7c8ff89e | 10712 | struct bgp_redist *red; |
718e3744 | 10713 | |
6d681bd8 QY |
10714 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
10715 | if (type < 0) | |
718e3744 | 10716 | { |
10717 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
10718 | return CMD_WARNING; | |
10719 | } | |
c500ae40 | 10720 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 10721 | |
cdc2d765 | 10722 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
c500ae40 | 10723 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 DL |
10724 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); |
10725 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); | |
718e3744 | 10726 | } |
10727 | ||
10728 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
10729 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 10730 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 10731 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10732 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 10733 | "Metric for redistributed routes\n" |
10734 | "Default metric\n" | |
10735 | "Route map reference\n" | |
10736 | "Pointer to route-map entries\n") | |
10737 | { | |
cdc2d765 | 10738 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
10739 | int idx_protocol = 1; |
10740 | int idx_number = 3; | |
10741 | int idx_word = 5; | |
718e3744 | 10742 | int type; |
10743 | u_int32_t metric; | |
7c8ff89e | 10744 | struct bgp_redist *red; |
718e3744 | 10745 | |
6d681bd8 QY |
10746 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
10747 | if (type < 0) | |
718e3744 | 10748 | { |
10749 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
10750 | return CMD_WARNING; | |
10751 | } | |
c500ae40 | 10752 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 10753 | |
cdc2d765 DL |
10754 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
10755 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, metric); | |
c500ae40 | 10756 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 10757 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); |
718e3744 | 10758 | } |
10759 | ||
10760 | DEFUN (no_bgp_redistribute_ipv6, | |
10761 | no_bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 10762 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 10763 | NO_STR |
10764 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 10765 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
10766 | "Metric for redistributed routes\n" |
10767 | "Default metric\n" | |
10768 | "Route map reference\n" | |
10769 | "Pointer to route-map entries\n") | |
718e3744 | 10770 | { |
cdc2d765 | 10771 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 10772 | int idx_protocol = 2; |
718e3744 | 10773 | int type; |
10774 | ||
6d681bd8 QY |
10775 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
10776 | if (type < 0) | |
718e3744 | 10777 | { |
10778 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
10779 | return CMD_WARNING; | |
10780 | } | |
10781 | ||
cdc2d765 | 10782 | return bgp_redistribute_unset (bgp, AFI_IP6, type, 0); |
718e3744 | 10783 | } |
6b0655a2 | 10784 | |
718e3744 | 10785 | int |
10786 | bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi, | |
10787 | safi_t safi, int *write) | |
10788 | { | |
10789 | int i; | |
718e3744 | 10790 | |
10791 | /* Unicast redistribution only. */ | |
10792 | if (safi != SAFI_UNICAST) | |
10793 | return 0; | |
10794 | ||
10795 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) | |
10796 | { | |
10797 | /* Redistribute BGP does not make sense. */ | |
7c8ff89e | 10798 | if (i != ZEBRA_ROUTE_BGP) |
718e3744 | 10799 | { |
7c8ff89e DS |
10800 | struct list *red_list; |
10801 | struct listnode *node; | |
10802 | struct bgp_redist *red; | |
718e3744 | 10803 | |
7c8ff89e DS |
10804 | red_list = bgp->redist[afi][i]; |
10805 | if (!red_list) | |
10806 | continue; | |
718e3744 | 10807 | |
7c8ff89e DS |
10808 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) |
10809 | { | |
10810 | /* Display "address-family" when it is not yet diplayed. */ | |
10811 | bgp_config_write_family_header (vty, afi, safi, write); | |
10812 | ||
10813 | /* "redistribute" configuration. */ | |
0b960b4d | 10814 | vty_out (vty, " redistribute %s", zebra_route_string(i)); |
7c8ff89e DS |
10815 | if (red->instance) |
10816 | vty_out (vty, " %d", red->instance); | |
10817 | if (red->redist_metric_flag) | |
10818 | vty_out (vty, " metric %u", red->redist_metric); | |
10819 | if (red->rmap.name) | |
10820 | vty_out (vty, " route-map %s", red->rmap.name); | |
10821 | vty_out (vty, "%s", VTY_NEWLINE); | |
10822 | } | |
718e3744 | 10823 | } |
10824 | } | |
10825 | return *write; | |
10826 | } | |
6b0655a2 | 10827 | |
718e3744 | 10828 | /* BGP node structure. */ |
7fc626de | 10829 | static struct cmd_node bgp_node = |
718e3744 | 10830 | { |
10831 | BGP_NODE, | |
10832 | "%s(config-router)# ", | |
10833 | 1, | |
10834 | }; | |
10835 | ||
7fc626de | 10836 | static struct cmd_node bgp_ipv4_unicast_node = |
718e3744 | 10837 | { |
10838 | BGP_IPV4_NODE, | |
10839 | "%s(config-router-af)# ", | |
10840 | 1, | |
10841 | }; | |
10842 | ||
7fc626de | 10843 | static struct cmd_node bgp_ipv4_multicast_node = |
718e3744 | 10844 | { |
10845 | BGP_IPV4M_NODE, | |
10846 | "%s(config-router-af)# ", | |
10847 | 1, | |
10848 | }; | |
10849 | ||
f51bae9c DS |
10850 | static struct cmd_node bgp_ipv4_labeled_unicast_node = |
10851 | { | |
10852 | BGP_IPV4L_NODE, | |
10853 | "%s(config-router-af)# ", | |
10854 | 1, | |
10855 | }; | |
10856 | ||
7fc626de | 10857 | static struct cmd_node bgp_ipv6_unicast_node = |
718e3744 | 10858 | { |
10859 | BGP_IPV6_NODE, | |
10860 | "%s(config-router-af)# ", | |
10861 | 1, | |
10862 | }; | |
10863 | ||
7fc626de | 10864 | static struct cmd_node bgp_ipv6_multicast_node = |
25ffbdc1 | 10865 | { |
10866 | BGP_IPV6M_NODE, | |
10867 | "%s(config-router-af)# ", | |
10868 | 1, | |
10869 | }; | |
10870 | ||
f51bae9c DS |
10871 | static struct cmd_node bgp_ipv6_labeled_unicast_node = |
10872 | { | |
10873 | BGP_IPV6L_NODE, | |
10874 | "%s(config-router-af)# ", | |
10875 | 1, | |
10876 | }; | |
10877 | ||
7fc626de | 10878 | static struct cmd_node bgp_vpnv4_node = |
718e3744 | 10879 | { |
10880 | BGP_VPNV4_NODE, | |
10881 | "%s(config-router-af)# ", | |
10882 | 1 | |
10883 | }; | |
6b0655a2 | 10884 | |
8ecd3266 | 10885 | static struct cmd_node bgp_vpnv6_node = |
10886 | { | |
10887 | BGP_VPNV6_NODE, | |
10888 | "%s(config-router-af-vpnv6)# ", | |
10889 | 1 | |
10890 | }; | |
10891 | ||
8b1fb8be LB |
10892 | static struct cmd_node bgp_encap_node = |
10893 | { | |
10894 | BGP_ENCAP_NODE, | |
10895 | "%s(config-router-af-encap)# ", | |
10896 | 1 | |
10897 | }; | |
10898 | ||
10899 | static struct cmd_node bgp_encapv6_node = | |
10900 | { | |
10901 | BGP_ENCAPV6_NODE, | |
10902 | "%s(config-router-af-encapv6)# ", | |
10903 | 1 | |
10904 | }; | |
10905 | ||
4e0b7b6d PG |
10906 | static struct cmd_node bgp_evpn_node = |
10907 | { | |
10908 | BGP_EVPN_NODE, | |
10909 | "%s(config-router-evpn)# ", | |
10910 | 1 | |
10911 | }; | |
10912 | ||
1f8ae70b | 10913 | static void community_list_vty (void); |
10914 | ||
b8a815e5 DL |
10915 | static void |
10916 | bgp_ac_neighbor (vector comps, struct cmd_token *token) | |
10917 | { | |
10918 | struct bgp *bgp; | |
10919 | struct peer *peer; | |
d48ed3e0 | 10920 | struct peer_group *group; |
b8a815e5 DL |
10921 | struct listnode *lnbgp, *lnpeer; |
10922 | ||
b8a815e5 | 10923 | for (ALL_LIST_ELEMENTS_RO (bm->bgp, lnbgp, bgp)) |
d48ed3e0 DL |
10924 | { |
10925 | for (ALL_LIST_ELEMENTS_RO (bgp->peer, lnpeer, peer)) | |
b8a815e5 | 10926 | { |
d48ed3e0 DL |
10927 | /* only provide suggestions on the appropriate input token type, |
10928 | * they'll otherwise show up multiple times */ | |
10929 | enum cmd_token_type match_type; | |
10930 | char *name = peer->host; | |
10931 | ||
10932 | if (peer->conf_if) | |
10933 | { | |
10934 | match_type = VARIABLE_TKN; | |
10935 | name = peer->conf_if; | |
10936 | } | |
10937 | else if (strchr(peer->host, ':')) | |
10938 | match_type = IPV6_TKN; | |
10939 | else | |
10940 | match_type = IPV4_TKN; | |
10941 | ||
10942 | if (token->type != match_type) | |
b8a815e5 | 10943 | continue; |
d48ed3e0 DL |
10944 | |
10945 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); | |
b8a815e5 | 10946 | } |
d48ed3e0 DL |
10947 | |
10948 | if (token->type == VARIABLE_TKN) | |
10949 | for (ALL_LIST_ELEMENTS_RO (bgp->group, lnpeer, group)) | |
10950 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, group->name)); | |
10951 | } | |
b8a815e5 DL |
10952 | } |
10953 | ||
10954 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
10955 | { | |
10956 | .varname = "neighbor", | |
10957 | .completions = bgp_ac_neighbor | |
10958 | }, { | |
10959 | .varname = "neighbors", | |
10960 | .completions = bgp_ac_neighbor | |
10961 | }, { | |
10962 | .completions = NULL | |
10963 | } | |
10964 | }; | |
10965 | ||
718e3744 | 10966 | void |
94f2b392 | 10967 | bgp_vty_init (void) |
718e3744 | 10968 | { |
b8a815e5 DL |
10969 | cmd_variable_handler_register(bgp_var_neighbor); |
10970 | ||
718e3744 | 10971 | /* Install bgp top node. */ |
10972 | install_node (&bgp_node, bgp_config_write); | |
10973 | install_node (&bgp_ipv4_unicast_node, NULL); | |
10974 | install_node (&bgp_ipv4_multicast_node, NULL); | |
f51bae9c | 10975 | install_node (&bgp_ipv4_labeled_unicast_node, NULL); |
718e3744 | 10976 | install_node (&bgp_ipv6_unicast_node, NULL); |
25ffbdc1 | 10977 | install_node (&bgp_ipv6_multicast_node, NULL); |
f51bae9c | 10978 | install_node (&bgp_ipv6_labeled_unicast_node, NULL); |
718e3744 | 10979 | install_node (&bgp_vpnv4_node, NULL); |
8ecd3266 | 10980 | install_node (&bgp_vpnv6_node, NULL); |
8b1fb8be LB |
10981 | install_node (&bgp_encap_node, NULL); |
10982 | install_node (&bgp_encapv6_node, NULL); | |
4e0b7b6d | 10983 | install_node (&bgp_evpn_node, NULL); |
718e3744 | 10984 | |
10985 | /* Install default VTY commands to new nodes. */ | |
10986 | install_default (BGP_NODE); | |
10987 | install_default (BGP_IPV4_NODE); | |
10988 | install_default (BGP_IPV4M_NODE); | |
f51bae9c | 10989 | install_default (BGP_IPV4L_NODE); |
718e3744 | 10990 | install_default (BGP_IPV6_NODE); |
25ffbdc1 | 10991 | install_default (BGP_IPV6M_NODE); |
f51bae9c | 10992 | install_default (BGP_IPV6L_NODE); |
718e3744 | 10993 | install_default (BGP_VPNV4_NODE); |
8ecd3266 | 10994 | install_default (BGP_VPNV6_NODE); |
8b1fb8be LB |
10995 | install_default (BGP_ENCAP_NODE); |
10996 | install_default (BGP_ENCAPV6_NODE); | |
4e0b7b6d | 10997 | install_default (BGP_EVPN_NODE); |
e52702f2 | 10998 | |
718e3744 | 10999 | /* "bgp multiple-instance" commands. */ |
11000 | install_element (CONFIG_NODE, &bgp_multiple_instance_cmd); | |
11001 | install_element (CONFIG_NODE, &no_bgp_multiple_instance_cmd); | |
11002 | ||
11003 | /* "bgp config-type" commands. */ | |
11004 | install_element (CONFIG_NODE, &bgp_config_type_cmd); | |
8c3deaae | 11005 | install_element (CONFIG_NODE, &no_bgp_config_type_cmd); |
718e3744 | 11006 | |
5fe9f963 | 11007 | /* bgp route-map delay-timer commands. */ |
11008 | install_element (CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
11009 | install_element (CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
5fe9f963 | 11010 | |
718e3744 | 11011 | /* Dummy commands (Currently not supported) */ |
11012 | install_element (BGP_NODE, &no_synchronization_cmd); | |
11013 | install_element (BGP_NODE, &no_auto_summary_cmd); | |
11014 | ||
11015 | /* "router bgp" commands. */ | |
11016 | install_element (CONFIG_NODE, &router_bgp_cmd); | |
718e3744 | 11017 | |
11018 | /* "no router bgp" commands. */ | |
11019 | install_element (CONFIG_NODE, &no_router_bgp_cmd); | |
718e3744 | 11020 | |
11021 | /* "bgp router-id" commands. */ | |
11022 | install_element (BGP_NODE, &bgp_router_id_cmd); | |
11023 | install_element (BGP_NODE, &no_bgp_router_id_cmd); | |
718e3744 | 11024 | |
11025 | /* "bgp cluster-id" commands. */ | |
11026 | install_element (BGP_NODE, &bgp_cluster_id_cmd); | |
718e3744 | 11027 | install_element (BGP_NODE, &no_bgp_cluster_id_cmd); |
718e3744 | 11028 | |
11029 | /* "bgp confederation" commands. */ | |
11030 | install_element (BGP_NODE, &bgp_confederation_identifier_cmd); | |
11031 | install_element (BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
718e3744 | 11032 | |
11033 | /* "bgp confederation peers" commands. */ | |
11034 | install_element (BGP_NODE, &bgp_confederation_peers_cmd); | |
11035 | install_element (BGP_NODE, &no_bgp_confederation_peers_cmd); | |
11036 | ||
abc920f8 DS |
11037 | /* bgp max-med command */ |
11038 | install_element (BGP_NODE, &bgp_maxmed_admin_cmd); | |
11039 | install_element (BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
11040 | install_element (BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
abc920f8 DS |
11041 | install_element (BGP_NODE, &bgp_maxmed_onstartup_cmd); |
11042 | install_element (BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
abc920f8 | 11043 | install_element (BGP_NODE, &bgp_maxmed_onstartup_medv_cmd); |
abc920f8 | 11044 | |
907f92c8 DS |
11045 | /* bgp disable-ebgp-connected-nh-check */ |
11046 | install_element (BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
11047 | install_element (BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
11048 | ||
f188f2c4 DS |
11049 | /* bgp update-delay command */ |
11050 | install_element (BGP_NODE, &bgp_update_delay_cmd); | |
11051 | install_element (BGP_NODE, &no_bgp_update_delay_cmd); | |
11052 | install_element (BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
f188f2c4 | 11053 | |
cb1faec9 DS |
11054 | install_element (BGP_NODE, &bgp_wpkt_quanta_cmd); |
11055 | install_element (BGP_NODE, &no_bgp_wpkt_quanta_cmd); | |
11056 | ||
3f9c7369 DS |
11057 | install_element (BGP_NODE, &bgp_coalesce_time_cmd); |
11058 | install_element (BGP_NODE, &no_bgp_coalesce_time_cmd); | |
11059 | ||
165b5fff | 11060 | /* "maximum-paths" commands. */ |
596c17ba DW |
11061 | install_element (BGP_NODE, &bgp_maxpaths_hidden_cmd); |
11062 | install_element (BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
165b5fff JB |
11063 | install_element (BGP_IPV4_NODE, &bgp_maxpaths_cmd); |
11064 | install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
431aa9f9 DS |
11065 | install_element (BGP_IPV6_NODE, &bgp_maxpaths_cmd); |
11066 | install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
596c17ba DW |
11067 | install_element (BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); |
11068 | install_element (BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
11069 | install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
165b5fff | 11070 | install_element (BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); |
f51bae9c | 11071 | install_element (BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); |
165b5fff | 11072 | install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); |
431aa9f9 | 11073 | install_element (BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); |
f51bae9c | 11074 | install_element (BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); |
431aa9f9 | 11075 | install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); |
165b5fff | 11076 | |
f51bae9c DS |
11077 | install_element (BGP_IPV4L_NODE, &bgp_maxpaths_cmd); |
11078 | install_element (BGP_IPV4L_NODE, &no_bgp_maxpaths_cmd); | |
11079 | install_element (BGP_IPV6L_NODE, &bgp_maxpaths_cmd); | |
11080 | install_element (BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
11081 | ||
11082 | install_element (BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cmd); | |
11083 | install_element (BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
11084 | install_element (BGP_IPV4L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
11085 | install_element (BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
11086 | install_element (BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
11087 | install_element (BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
11088 | ||
718e3744 | 11089 | /* "timers bgp" commands. */ |
11090 | install_element (BGP_NODE, &bgp_timers_cmd); | |
11091 | install_element (BGP_NODE, &no_bgp_timers_cmd); | |
718e3744 | 11092 | |
5fe9f963 | 11093 | /* route-map delay-timer commands - per instance for backwards compat. */ |
518f0eb1 DS |
11094 | install_element (BGP_NODE, &bgp_set_route_map_delay_timer_cmd); |
11095 | install_element (BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
11096 | ||
718e3744 | 11097 | /* "bgp client-to-client reflection" commands */ |
11098 | install_element (BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
11099 | install_element (BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
11100 | ||
11101 | /* "bgp always-compare-med" commands */ | |
11102 | install_element (BGP_NODE, &bgp_always_compare_med_cmd); | |
11103 | install_element (BGP_NODE, &no_bgp_always_compare_med_cmd); | |
e52702f2 | 11104 | |
718e3744 | 11105 | /* "bgp deterministic-med" commands */ |
11106 | install_element (BGP_NODE, &bgp_deterministic_med_cmd); | |
11107 | install_element (BGP_NODE, &no_bgp_deterministic_med_cmd); | |
538621f2 | 11108 | |
538621f2 | 11109 | /* "bgp graceful-restart" commands */ |
11110 | install_element (BGP_NODE, &bgp_graceful_restart_cmd); | |
11111 | install_element (BGP_NODE, &no_bgp_graceful_restart_cmd); | |
93406d87 | 11112 | install_element (BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
11113 | install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
eb6f1b41 PG |
11114 | install_element (BGP_NODE, &bgp_graceful_restart_restart_time_cmd); |
11115 | install_element (BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
e52702f2 | 11116 | |
43fc21b3 JC |
11117 | install_element (BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
11118 | install_element (BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
11119 | ||
718e3744 | 11120 | /* "bgp fast-external-failover" commands */ |
11121 | install_element (BGP_NODE, &bgp_fast_external_failover_cmd); | |
11122 | install_element (BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
11123 | ||
11124 | /* "bgp enforce-first-as" commands */ | |
11125 | install_element (BGP_NODE, &bgp_enforce_first_as_cmd); | |
11126 | install_element (BGP_NODE, &no_bgp_enforce_first_as_cmd); | |
11127 | ||
11128 | /* "bgp bestpath compare-routerid" commands */ | |
11129 | install_element (BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
11130 | install_element (BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
11131 | ||
11132 | /* "bgp bestpath as-path ignore" commands */ | |
11133 | install_element (BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
11134 | install_element (BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
11135 | ||
6811845b | 11136 | /* "bgp bestpath as-path confed" commands */ |
11137 | install_element (BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
11138 | install_element (BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
11139 | ||
2fdd455c PM |
11140 | /* "bgp bestpath as-path multipath-relax" commands */ |
11141 | install_element (BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
11142 | install_element (BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
11143 | ||
848973c7 | 11144 | /* "bgp log-neighbor-changes" commands */ |
11145 | install_element (BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
11146 | install_element (BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
11147 | ||
718e3744 | 11148 | /* "bgp bestpath med" commands */ |
11149 | install_element (BGP_NODE, &bgp_bestpath_med_cmd); | |
718e3744 | 11150 | install_element (BGP_NODE, &no_bgp_bestpath_med_cmd); |
718e3744 | 11151 | |
11152 | /* "no bgp default ipv4-unicast" commands. */ | |
11153 | install_element (BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
11154 | install_element (BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
e52702f2 | 11155 | |
718e3744 | 11156 | /* "bgp network import-check" commands. */ |
11157 | install_element (BGP_NODE, &bgp_network_import_check_cmd); | |
8233ef81 | 11158 | install_element (BGP_NODE, &bgp_network_import_check_exact_cmd); |
718e3744 | 11159 | install_element (BGP_NODE, &no_bgp_network_import_check_cmd); |
11160 | ||
11161 | /* "bgp default local-preference" commands. */ | |
11162 | install_element (BGP_NODE, &bgp_default_local_preference_cmd); | |
11163 | install_element (BGP_NODE, &no_bgp_default_local_preference_cmd); | |
718e3744 | 11164 | |
04b6bdc0 DW |
11165 | /* bgp default show-hostname */ |
11166 | install_element (BGP_NODE, &bgp_default_show_hostname_cmd); | |
11167 | install_element (BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
11168 | ||
3f9c7369 DS |
11169 | /* "bgp default subgroup-pkt-queue-max" commands. */ |
11170 | install_element (BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
11171 | install_element (BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
11172 | ||
8bd9d948 DS |
11173 | /* bgp ibgp-allow-policy-mods command */ |
11174 | install_element (BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
11175 | install_element (BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
11176 | ||
f14e6fdb DS |
11177 | /* "bgp listen limit" commands. */ |
11178 | install_element (BGP_NODE, &bgp_listen_limit_cmd); | |
11179 | install_element (BGP_NODE, &no_bgp_listen_limit_cmd); | |
11180 | ||
11181 | /* "bgp listen range" commands. */ | |
11182 | install_element (BGP_NODE, &bgp_listen_range_cmd); | |
11183 | install_element (BGP_NODE, &no_bgp_listen_range_cmd); | |
11184 | ||
718e3744 | 11185 | /* "neighbor remote-as" commands. */ |
11186 | install_element (BGP_NODE, &neighbor_remote_as_cmd); | |
a80beece | 11187 | install_element (BGP_NODE, &neighbor_interface_config_cmd); |
4c48cf63 | 11188 | install_element (BGP_NODE, &neighbor_interface_config_v6only_cmd); |
b3a39dc5 DD |
11189 | install_element (BGP_NODE, &neighbor_interface_config_remote_as_cmd); |
11190 | install_element (BGP_NODE, &neighbor_interface_v6only_config_remote_as_cmd); | |
718e3744 | 11191 | install_element (BGP_NODE, &no_neighbor_cmd); |
a80beece | 11192 | install_element (BGP_NODE, &no_neighbor_interface_config_cmd); |
718e3744 | 11193 | |
11194 | /* "neighbor peer-group" commands. */ | |
11195 | install_element (BGP_NODE, &neighbor_peer_group_cmd); | |
11196 | install_element (BGP_NODE, &no_neighbor_peer_group_cmd); | |
a80beece | 11197 | install_element (BGP_NODE, &no_neighbor_interface_peer_group_remote_as_cmd); |
718e3744 | 11198 | |
11199 | /* "neighbor local-as" commands. */ | |
11200 | install_element (BGP_NODE, &neighbor_local_as_cmd); | |
11201 | install_element (BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
9d3f9705 | 11202 | install_element (BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); |
718e3744 | 11203 | install_element (BGP_NODE, &no_neighbor_local_as_cmd); |
718e3744 | 11204 | |
3f9c7369 DS |
11205 | /* "neighbor solo" commands. */ |
11206 | install_element (BGP_NODE, &neighbor_solo_cmd); | |
11207 | install_element (BGP_NODE, &no_neighbor_solo_cmd); | |
11208 | ||
0df7c91f PJ |
11209 | /* "neighbor password" commands. */ |
11210 | install_element (BGP_NODE, &neighbor_password_cmd); | |
11211 | install_element (BGP_NODE, &no_neighbor_password_cmd); | |
11212 | ||
718e3744 | 11213 | /* "neighbor activate" commands. */ |
596c17ba | 11214 | install_element (BGP_NODE, &neighbor_activate_hidden_cmd); |
718e3744 | 11215 | install_element (BGP_IPV4_NODE, &neighbor_activate_cmd); |
11216 | install_element (BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
f51bae9c | 11217 | install_element (BGP_IPV4L_NODE, &neighbor_activate_cmd); |
718e3744 | 11218 | install_element (BGP_IPV6_NODE, &neighbor_activate_cmd); |
25ffbdc1 | 11219 | install_element (BGP_IPV6M_NODE, &neighbor_activate_cmd); |
f51bae9c | 11220 | install_element (BGP_IPV6L_NODE, &neighbor_activate_cmd); |
718e3744 | 11221 | install_element (BGP_VPNV4_NODE, &neighbor_activate_cmd); |
8ecd3266 | 11222 | install_element (BGP_VPNV6_NODE, &neighbor_activate_cmd); |
8b1fb8be LB |
11223 | install_element (BGP_ENCAP_NODE, &neighbor_activate_cmd); |
11224 | install_element (BGP_ENCAPV6_NODE, &neighbor_activate_cmd); | |
4e0b7b6d | 11225 | install_element (BGP_EVPN_NODE, &neighbor_activate_cmd); |
718e3744 | 11226 | |
11227 | /* "no neighbor activate" commands. */ | |
596c17ba | 11228 | install_element (BGP_NODE, &no_neighbor_activate_hidden_cmd); |
718e3744 | 11229 | install_element (BGP_IPV4_NODE, &no_neighbor_activate_cmd); |
11230 | install_element (BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
f51bae9c | 11231 | install_element (BGP_IPV4L_NODE, &no_neighbor_activate_cmd); |
718e3744 | 11232 | install_element (BGP_IPV6_NODE, &no_neighbor_activate_cmd); |
25ffbdc1 | 11233 | install_element (BGP_IPV6M_NODE, &no_neighbor_activate_cmd); |
f51bae9c | 11234 | install_element (BGP_IPV6L_NODE, &no_neighbor_activate_cmd); |
718e3744 | 11235 | install_element (BGP_VPNV4_NODE, &no_neighbor_activate_cmd); |
8ecd3266 | 11236 | install_element (BGP_VPNV6_NODE, &no_neighbor_activate_cmd); |
8b1fb8be LB |
11237 | install_element (BGP_ENCAP_NODE, &no_neighbor_activate_cmd); |
11238 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_activate_cmd); | |
4e0b7b6d | 11239 | install_element (BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
718e3744 | 11240 | |
596c17ba | 11241 | /* "neighbor peer-group" set commands. */ |
718e3744 | 11242 | install_element (BGP_NODE, &neighbor_set_peer_group_cmd); |
596c17ba DW |
11243 | install_element (BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); |
11244 | install_element (BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11245 | install_element (BGP_IPV4L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11246 | install_element (BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11247 | install_element (BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11248 | install_element (BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11249 | install_element (BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11250 | install_element (BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11251 | install_element (BGP_ENCAP_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11252 | install_element (BGP_ENCAPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
c8560b44 | 11253 | |
718e3744 | 11254 | /* "no neighbor peer-group unset" commands. */ |
11255 | install_element (BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
596c17ba DW |
11256 | install_element (BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); |
11257 | install_element (BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11258 | install_element (BGP_IPV4L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11259 | install_element (BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11260 | install_element (BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11261 | install_element (BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11262 | install_element (BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11263 | install_element (BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11264 | install_element (BGP_ENCAP_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11265 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
e52702f2 | 11266 | |
718e3744 | 11267 | /* "neighbor softreconfiguration inbound" commands.*/ |
596c17ba DW |
11268 | install_element (BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); |
11269 | install_element (BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
718e3744 | 11270 | install_element (BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); |
11271 | install_element (BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
f51bae9c DS |
11272 | install_element (BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); |
11273 | install_element (BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
718e3744 | 11274 | install_element (BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); |
11275 | install_element (BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11276 | install_element (BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
11277 | install_element (BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
25ffbdc1 | 11278 | install_element (BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); |
11279 | install_element (BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
f51bae9c DS |
11280 | install_element (BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); |
11281 | install_element (BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
a58545bb | 11282 | install_element (BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); |
11283 | install_element (BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
8ecd3266 | 11284 | install_element (BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); |
11285 | install_element (BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
8b1fb8be LB |
11286 | install_element (BGP_ENCAP_NODE, &neighbor_soft_reconfiguration_cmd); |
11287 | install_element (BGP_ENCAP_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11288 | install_element (BGP_ENCAPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
11289 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
718e3744 | 11290 | |
11291 | /* "neighbor attribute-unchanged" commands. */ | |
596c17ba DW |
11292 | install_element (BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); |
11293 | install_element (BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
718e3744 | 11294 | install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 11295 | install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 11296 | install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 11297 | install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); |
f51bae9c DS |
11298 | install_element (BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); |
11299 | install_element (BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
718e3744 | 11300 | install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 11301 | install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); |
25ffbdc1 | 11302 | install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); |
25ffbdc1 | 11303 | install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); |
f51bae9c DS |
11304 | install_element (BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); |
11305 | install_element (BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
718e3744 | 11306 | install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 11307 | install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); |
8ecd3266 | 11308 | install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); |
8ecd3266 | 11309 | install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); |
8ecd3266 | 11310 | |
8b1fb8be | 11311 | install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged_cmd); |
8b1fb8be | 11312 | install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged_cmd); |
8b1fb8be LB |
11313 | |
11314 | install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged_cmd); | |
8b1fb8be | 11315 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 11316 | |
4e0b7b6d PG |
11317 | install_element (BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); |
11318 | install_element (BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
11319 | ||
fee0f4c6 | 11320 | /* "nexthop-local unchanged" commands */ |
11321 | install_element (BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
11322 | install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_local_unchanged_cmd); | |
11323 | ||
718e3744 | 11324 | /* "neighbor next-hop-self" commands. */ |
596c17ba DW |
11325 | install_element (BGP_NODE, &neighbor_nexthop_self_hidden_cmd); |
11326 | install_element (BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
718e3744 | 11327 | install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); |
11328 | install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
11329 | install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
11330 | install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
f51bae9c DS |
11331 | install_element (BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); |
11332 | install_element (BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
718e3744 | 11333 | install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); |
11334 | install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
25ffbdc1 | 11335 | install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); |
11336 | install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
f51bae9c DS |
11337 | install_element (BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); |
11338 | install_element (BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
718e3744 | 11339 | install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); |
11340 | install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
8ecd3266 | 11341 | install_element (BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); |
11342 | install_element (BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
8b1fb8be LB |
11343 | install_element (BGP_ENCAP_NODE, &neighbor_nexthop_self_cmd); |
11344 | install_element (BGP_ENCAP_NODE, &no_neighbor_nexthop_self_cmd); | |
11345 | install_element (BGP_ENCAPV6_NODE, &neighbor_nexthop_self_cmd); | |
11346 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
718e3744 | 11347 | |
a538debe | 11348 | /* "neighbor next-hop-self force" commands. */ |
596c17ba DW |
11349 | install_element (BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); |
11350 | install_element (BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
a538debe DS |
11351 | install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
11352 | install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11353 | install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); | |
11354 | install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
f51bae9c DS |
11355 | install_element (BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); |
11356 | install_element (BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
a538debe DS |
11357 | install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); |
11358 | install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11359 | install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); | |
11360 | install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
f51bae9c DS |
11361 | install_element (BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); |
11362 | install_element (BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
a538debe DS |
11363 | install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); |
11364 | install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
8ecd3266 | 11365 | install_element (BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
11366 | install_element (BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
a538debe | 11367 | |
c7122e14 | 11368 | /* "neighbor as-override" commands. */ |
596c17ba DW |
11369 | install_element (BGP_NODE, &neighbor_as_override_hidden_cmd); |
11370 | install_element (BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
c7122e14 DS |
11371 | install_element (BGP_IPV4_NODE, &neighbor_as_override_cmd); |
11372 | install_element (BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
11373 | install_element (BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
11374 | install_element (BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
f51bae9c DS |
11375 | install_element (BGP_IPV4L_NODE, &neighbor_as_override_cmd); |
11376 | install_element (BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
c7122e14 DS |
11377 | install_element (BGP_IPV6_NODE, &neighbor_as_override_cmd); |
11378 | install_element (BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
11379 | install_element (BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
11380 | install_element (BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
f51bae9c DS |
11381 | install_element (BGP_IPV6L_NODE, &neighbor_as_override_cmd); |
11382 | install_element (BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
c7122e14 DS |
11383 | install_element (BGP_VPNV4_NODE, &neighbor_as_override_cmd); |
11384 | install_element (BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
8ecd3266 | 11385 | install_element (BGP_VPNV6_NODE, &neighbor_as_override_cmd); |
11386 | install_element (BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
c7122e14 | 11387 | |
718e3744 | 11388 | /* "neighbor remove-private-AS" commands. */ |
596c17ba DW |
11389 | install_element (BGP_NODE, &neighbor_remove_private_as_hidden_cmd); |
11390 | install_element (BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
11391 | install_element (BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
11392 | install_element (BGP_NODE, &no_neighbor_remove_private_as_all_hidden_cmd); | |
11393 | install_element (BGP_NODE, &neighbor_remove_private_as_replace_as_hidden_cmd); | |
11394 | install_element (BGP_NODE, &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
11395 | install_element (BGP_NODE, &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
11396 | install_element (BGP_NODE, &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
718e3744 | 11397 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); |
11398 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
11399 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); |
11400 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11401 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
11402 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
11403 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
11404 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 11405 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); |
11406 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
11407 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); |
11408 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11409 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
11410 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
11411 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
11412 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
f51bae9c DS |
11413 | install_element (BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); |
11414 | install_element (BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
11415 | install_element (BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
11416 | install_element (BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11417 | install_element (BGP_IPV4L_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
11418 | install_element (BGP_IPV4L_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
11419 | install_element (BGP_IPV4L_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
11420 | install_element (BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 11421 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); |
11422 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
11423 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); |
11424 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11425 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
11426 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
11427 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
11428 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
25ffbdc1 | 11429 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); |
11430 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
11431 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); |
11432 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11433 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
11434 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
11435 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
11436 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
f51bae9c DS |
11437 | install_element (BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); |
11438 | install_element (BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
11439 | install_element (BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
11440 | install_element (BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11441 | install_element (BGP_IPV6L_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
11442 | install_element (BGP_IPV6L_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
11443 | install_element (BGP_IPV6L_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
11444 | install_element (BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 11445 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); |
11446 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
11447 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); |
11448 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11449 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
11450 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
11451 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
11452 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
8ecd3266 | 11453 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); |
11454 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
11455 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
11456 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11457 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
11458 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
11459 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
11460 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
8b1fb8be LB |
11461 | install_element (BGP_ENCAP_NODE, &neighbor_remove_private_as_cmd); |
11462 | install_element (BGP_ENCAP_NODE, &no_neighbor_remove_private_as_cmd); | |
11463 | install_element (BGP_ENCAPV6_NODE, &neighbor_remove_private_as_cmd); | |
11464 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
718e3744 | 11465 | |
11466 | /* "neighbor send-community" commands.*/ | |
596c17ba DW |
11467 | install_element (BGP_NODE, &neighbor_send_community_hidden_cmd); |
11468 | install_element (BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
11469 | install_element (BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
11470 | install_element (BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
718e3744 | 11471 | install_element (BGP_IPV4_NODE, &neighbor_send_community_cmd); |
11472 | install_element (BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
11473 | install_element (BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
11474 | install_element (BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
11475 | install_element (BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
11476 | install_element (BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
11477 | install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
11478 | install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
f51bae9c DS |
11479 | install_element (BGP_IPV4L_NODE, &neighbor_send_community_cmd); |
11480 | install_element (BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
11481 | install_element (BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
11482 | install_element (BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
718e3744 | 11483 | install_element (BGP_IPV6_NODE, &neighbor_send_community_cmd); |
11484 | install_element (BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
11485 | install_element (BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
11486 | install_element (BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
25ffbdc1 | 11487 | install_element (BGP_IPV6M_NODE, &neighbor_send_community_cmd); |
11488 | install_element (BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
11489 | install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
11490 | install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
f51bae9c DS |
11491 | install_element (BGP_IPV6L_NODE, &neighbor_send_community_cmd); |
11492 | install_element (BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
11493 | install_element (BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
11494 | install_element (BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
718e3744 | 11495 | install_element (BGP_VPNV4_NODE, &neighbor_send_community_cmd); |
11496 | install_element (BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
11497 | install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
11498 | install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
8ecd3266 | 11499 | install_element (BGP_VPNV6_NODE, &neighbor_send_community_cmd); |
11500 | install_element (BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
11501 | install_element (BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
11502 | install_element (BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
8b1fb8be LB |
11503 | install_element (BGP_ENCAP_NODE, &neighbor_send_community_cmd); |
11504 | install_element (BGP_ENCAP_NODE, &neighbor_send_community_type_cmd); | |
11505 | install_element (BGP_ENCAP_NODE, &no_neighbor_send_community_cmd); | |
11506 | install_element (BGP_ENCAP_NODE, &no_neighbor_send_community_type_cmd); | |
11507 | install_element (BGP_ENCAPV6_NODE, &neighbor_send_community_cmd); | |
11508 | install_element (BGP_ENCAPV6_NODE, &neighbor_send_community_type_cmd); | |
11509 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_send_community_cmd); | |
11510 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_send_community_type_cmd); | |
718e3744 | 11511 | |
11512 | /* "neighbor route-reflector" commands.*/ | |
596c17ba DW |
11513 | install_element (BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); |
11514 | install_element (BGP_NODE, &no_neighbor_route_reflector_client_hidden_cmd); | |
718e3744 | 11515 | install_element (BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); |
11516 | install_element (BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
11517 | install_element (BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
11518 | install_element (BGP_IPV4M_NODE, &no_neighbor_route_reflector_client_cmd); | |
f51bae9c DS |
11519 | install_element (BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); |
11520 | install_element (BGP_IPV4L_NODE, &no_neighbor_route_reflector_client_cmd); | |
718e3744 | 11521 | install_element (BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); |
11522 | install_element (BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
25ffbdc1 | 11523 | install_element (BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); |
11524 | install_element (BGP_IPV6M_NODE, &no_neighbor_route_reflector_client_cmd); | |
f51bae9c DS |
11525 | install_element (BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); |
11526 | install_element (BGP_IPV6L_NODE, &no_neighbor_route_reflector_client_cmd); | |
718e3744 | 11527 | install_element (BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); |
11528 | install_element (BGP_VPNV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
8ecd3266 | 11529 | install_element (BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); |
11530 | install_element (BGP_VPNV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
8b1fb8be LB |
11531 | install_element (BGP_ENCAP_NODE, &neighbor_route_reflector_client_cmd); |
11532 | install_element (BGP_ENCAP_NODE, &no_neighbor_route_reflector_client_cmd); | |
11533 | install_element (BGP_ENCAPV6_NODE, &neighbor_route_reflector_client_cmd); | |
11534 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
718e3744 | 11535 | |
11536 | /* "neighbor route-server" commands.*/ | |
596c17ba DW |
11537 | install_element (BGP_NODE, &neighbor_route_server_client_hidden_cmd); |
11538 | install_element (BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
718e3744 | 11539 | install_element (BGP_IPV4_NODE, &neighbor_route_server_client_cmd); |
11540 | install_element (BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
11541 | install_element (BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
11542 | install_element (BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
f51bae9c DS |
11543 | install_element (BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); |
11544 | install_element (BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
718e3744 | 11545 | install_element (BGP_IPV6_NODE, &neighbor_route_server_client_cmd); |
11546 | install_element (BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
25ffbdc1 | 11547 | install_element (BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); |
11548 | install_element (BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
f51bae9c DS |
11549 | install_element (BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); |
11550 | install_element (BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
718e3744 | 11551 | install_element (BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); |
11552 | install_element (BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
8ecd3266 | 11553 | install_element (BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); |
11554 | install_element (BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
8b1fb8be LB |
11555 | install_element (BGP_ENCAP_NODE, &neighbor_route_server_client_cmd); |
11556 | install_element (BGP_ENCAP_NODE, &no_neighbor_route_server_client_cmd); | |
11557 | install_element (BGP_ENCAPV6_NODE, &neighbor_route_server_client_cmd); | |
11558 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_server_client_cmd); | |
718e3744 | 11559 | |
adbac85e | 11560 | /* "neighbor addpath-tx-all-paths" commands.*/ |
596c17ba DW |
11561 | install_element (BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); |
11562 | install_element (BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
adbac85e DW |
11563 | install_element (BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); |
11564 | install_element (BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11565 | install_element (BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11566 | install_element (BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
f51bae9c DS |
11567 | install_element (BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); |
11568 | install_element (BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
adbac85e DW |
11569 | install_element (BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); |
11570 | install_element (BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11571 | install_element (BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11572 | install_element (BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
f51bae9c DS |
11573 | install_element (BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); |
11574 | install_element (BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
adbac85e DW |
11575 | install_element (BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); |
11576 | install_element (BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
8ecd3266 | 11577 | install_element (BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); |
11578 | install_element (BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
adbac85e | 11579 | |
06370dac | 11580 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ |
596c17ba DW |
11581 | install_element (BGP_NODE, &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); |
11582 | install_element (BGP_NODE, &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
06370dac DW |
11583 | install_element (BGP_IPV4_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); |
11584 | install_element (BGP_IPV4_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11585 | install_element (BGP_IPV4M_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11586 | install_element (BGP_IPV4M_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
f51bae9c DS |
11587 | install_element (BGP_IPV4L_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); |
11588 | install_element (BGP_IPV4L_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
06370dac DW |
11589 | install_element (BGP_IPV6_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); |
11590 | install_element (BGP_IPV6_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11591 | install_element (BGP_IPV6M_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11592 | install_element (BGP_IPV6M_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
f51bae9c DS |
11593 | install_element (BGP_IPV6L_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); |
11594 | install_element (BGP_IPV6L_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
06370dac DW |
11595 | install_element (BGP_VPNV4_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); |
11596 | install_element (BGP_VPNV4_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
8ecd3266 | 11597 | install_element (BGP_VPNV6_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); |
11598 | install_element (BGP_VPNV6_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
06370dac | 11599 | |
718e3744 | 11600 | /* "neighbor passive" commands. */ |
11601 | install_element (BGP_NODE, &neighbor_passive_cmd); | |
11602 | install_element (BGP_NODE, &no_neighbor_passive_cmd); | |
11603 | ||
d5a5c8f0 | 11604 | |
718e3744 | 11605 | /* "neighbor shutdown" commands. */ |
11606 | install_element (BGP_NODE, &neighbor_shutdown_cmd); | |
11607 | install_element (BGP_NODE, &no_neighbor_shutdown_cmd); | |
73d70fa6 DL |
11608 | install_element (BGP_NODE, &neighbor_shutdown_msg_cmd); |
11609 | install_element (BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
718e3744 | 11610 | |
8a92a8a0 DS |
11611 | /* "neighbor capability extended-nexthop" commands.*/ |
11612 | install_element (BGP_NODE, &neighbor_capability_enhe_cmd); | |
11613 | install_element (BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
11614 | ||
718e3744 | 11615 | /* "neighbor capability orf prefix-list" commands.*/ |
596c17ba DW |
11616 | install_element (BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); |
11617 | install_element (BGP_NODE, &no_neighbor_capability_orf_prefix_hidden_cmd); | |
718e3744 | 11618 | install_element (BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); |
11619 | install_element (BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
11620 | install_element (BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
11621 | install_element (BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
f51bae9c DS |
11622 | install_element (BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); |
11623 | install_element (BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
718e3744 | 11624 | install_element (BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); |
11625 | install_element (BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
25ffbdc1 | 11626 | install_element (BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); |
11627 | install_element (BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
f51bae9c DS |
11628 | install_element (BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); |
11629 | install_element (BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
718e3744 | 11630 | |
11631 | /* "neighbor capability dynamic" commands.*/ | |
11632 | install_element (BGP_NODE, &neighbor_capability_dynamic_cmd); | |
11633 | install_element (BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
11634 | ||
11635 | /* "neighbor dont-capability-negotiate" commands. */ | |
11636 | install_element (BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
11637 | install_element (BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
11638 | ||
11639 | /* "neighbor ebgp-multihop" commands. */ | |
11640 | install_element (BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
11641 | install_element (BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
11642 | install_element (BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
718e3744 | 11643 | |
6ffd2079 | 11644 | /* "neighbor disable-connected-check" commands. */ |
11645 | install_element (BGP_NODE, &neighbor_disable_connected_check_cmd); | |
11646 | install_element (BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
718e3744 | 11647 | |
11648 | /* "neighbor description" commands. */ | |
11649 | install_element (BGP_NODE, &neighbor_description_cmd); | |
11650 | install_element (BGP_NODE, &no_neighbor_description_cmd); | |
718e3744 | 11651 | |
11652 | /* "neighbor update-source" commands. "*/ | |
11653 | install_element (BGP_NODE, &neighbor_update_source_cmd); | |
11654 | install_element (BGP_NODE, &no_neighbor_update_source_cmd); | |
11655 | ||
11656 | /* "neighbor default-originate" commands. */ | |
596c17ba DW |
11657 | install_element (BGP_NODE, &neighbor_default_originate_hidden_cmd); |
11658 | install_element (BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
11659 | install_element (BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
718e3744 | 11660 | install_element (BGP_IPV4_NODE, &neighbor_default_originate_cmd); |
11661 | install_element (BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
11662 | install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 11663 | install_element (BGP_IPV4M_NODE, &neighbor_default_originate_cmd); |
11664 | install_element (BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
11665 | install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
f51bae9c DS |
11666 | install_element (BGP_IPV4L_NODE, &neighbor_default_originate_cmd); |
11667 | install_element (BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
11668 | install_element (BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 11669 | install_element (BGP_IPV6_NODE, &neighbor_default_originate_cmd); |
11670 | install_element (BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
11671 | install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
25ffbdc1 | 11672 | install_element (BGP_IPV6M_NODE, &neighbor_default_originate_cmd); |
11673 | install_element (BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
11674 | install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
f51bae9c DS |
11675 | install_element (BGP_IPV6L_NODE, &neighbor_default_originate_cmd); |
11676 | install_element (BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
11677 | install_element (BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 11678 | |
11679 | /* "neighbor port" commands. */ | |
11680 | install_element (BGP_NODE, &neighbor_port_cmd); | |
11681 | install_element (BGP_NODE, &no_neighbor_port_cmd); | |
718e3744 | 11682 | |
11683 | /* "neighbor weight" commands. */ | |
596c17ba DW |
11684 | install_element (BGP_NODE, &neighbor_weight_hidden_cmd); |
11685 | install_element (BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
718e3744 | 11686 | |
d93f7ffc DW |
11687 | install_element (BGP_IPV4_NODE, &neighbor_weight_cmd); |
11688 | install_element (BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
11689 | install_element (BGP_IPV4M_NODE, &neighbor_weight_cmd); |
11690 | install_element (BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
f51bae9c DS |
11691 | install_element (BGP_IPV4L_NODE, &neighbor_weight_cmd); |
11692 | install_element (BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
11693 | install_element (BGP_IPV6_NODE, &neighbor_weight_cmd); |
11694 | install_element (BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
11695 | install_element (BGP_IPV6M_NODE, &neighbor_weight_cmd); |
11696 | install_element (BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
f51bae9c DS |
11697 | install_element (BGP_IPV6L_NODE, &neighbor_weight_cmd); |
11698 | install_element (BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
11699 | install_element (BGP_VPNV4_NODE, &neighbor_weight_cmd); |
11700 | install_element (BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
11701 | install_element (BGP_VPNV6_NODE, &neighbor_weight_cmd); |
11702 | install_element (BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
11703 | install_element (BGP_ENCAP_NODE, &neighbor_weight_cmd); |
11704 | install_element (BGP_ENCAP_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
11705 | install_element (BGP_ENCAPV6_NODE, &neighbor_weight_cmd); |
11706 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_weight_cmd); | |
718e3744 | 11707 | |
11708 | /* "neighbor override-capability" commands. */ | |
11709 | install_element (BGP_NODE, &neighbor_override_capability_cmd); | |
11710 | install_element (BGP_NODE, &no_neighbor_override_capability_cmd); | |
11711 | ||
11712 | /* "neighbor strict-capability-match" commands. */ | |
11713 | install_element (BGP_NODE, &neighbor_strict_capability_cmd); | |
11714 | install_element (BGP_NODE, &no_neighbor_strict_capability_cmd); | |
11715 | ||
11716 | /* "neighbor timers" commands. */ | |
11717 | install_element (BGP_NODE, &neighbor_timers_cmd); | |
11718 | install_element (BGP_NODE, &no_neighbor_timers_cmd); | |
11719 | ||
11720 | /* "neighbor timers connect" commands. */ | |
11721 | install_element (BGP_NODE, &neighbor_timers_connect_cmd); | |
11722 | install_element (BGP_NODE, &no_neighbor_timers_connect_cmd); | |
718e3744 | 11723 | |
11724 | /* "neighbor advertisement-interval" commands. */ | |
11725 | install_element (BGP_NODE, &neighbor_advertise_interval_cmd); | |
11726 | install_element (BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
718e3744 | 11727 | |
718e3744 | 11728 | /* "neighbor interface" commands. */ |
11729 | install_element (BGP_NODE, &neighbor_interface_cmd); | |
11730 | install_element (BGP_NODE, &no_neighbor_interface_cmd); | |
11731 | ||
11732 | /* "neighbor distribute" commands. */ | |
596c17ba DW |
11733 | install_element (BGP_NODE, &neighbor_distribute_list_hidden_cmd); |
11734 | install_element (BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
718e3744 | 11735 | install_element (BGP_IPV4_NODE, &neighbor_distribute_list_cmd); |
11736 | install_element (BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
11737 | install_element (BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
11738 | install_element (BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
f51bae9c DS |
11739 | install_element (BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); |
11740 | install_element (BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
718e3744 | 11741 | install_element (BGP_IPV6_NODE, &neighbor_distribute_list_cmd); |
11742 | install_element (BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
25ffbdc1 | 11743 | install_element (BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); |
11744 | install_element (BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
f51bae9c DS |
11745 | install_element (BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); |
11746 | install_element (BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
718e3744 | 11747 | install_element (BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); |
11748 | install_element (BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
8ecd3266 | 11749 | install_element (BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); |
11750 | install_element (BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
8b1fb8be LB |
11751 | install_element (BGP_ENCAP_NODE, &neighbor_distribute_list_cmd); |
11752 | install_element (BGP_ENCAP_NODE, &no_neighbor_distribute_list_cmd); | |
11753 | install_element (BGP_ENCAPV6_NODE, &neighbor_distribute_list_cmd); | |
11754 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_distribute_list_cmd); | |
718e3744 | 11755 | |
11756 | /* "neighbor prefix-list" commands. */ | |
596c17ba DW |
11757 | install_element (BGP_NODE, &neighbor_prefix_list_hidden_cmd); |
11758 | install_element (BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
718e3744 | 11759 | install_element (BGP_IPV4_NODE, &neighbor_prefix_list_cmd); |
11760 | install_element (BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
11761 | install_element (BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
11762 | install_element (BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
f51bae9c DS |
11763 | install_element (BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); |
11764 | install_element (BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
718e3744 | 11765 | install_element (BGP_IPV6_NODE, &neighbor_prefix_list_cmd); |
11766 | install_element (BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
25ffbdc1 | 11767 | install_element (BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); |
11768 | install_element (BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
f51bae9c DS |
11769 | install_element (BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); |
11770 | install_element (BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
718e3744 | 11771 | install_element (BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); |
11772 | install_element (BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
8ecd3266 | 11773 | install_element (BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); |
11774 | install_element (BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
8b1fb8be LB |
11775 | install_element (BGP_ENCAP_NODE, &neighbor_prefix_list_cmd); |
11776 | install_element (BGP_ENCAP_NODE, &no_neighbor_prefix_list_cmd); | |
11777 | install_element (BGP_ENCAPV6_NODE, &neighbor_prefix_list_cmd); | |
11778 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_prefix_list_cmd); | |
718e3744 | 11779 | |
11780 | /* "neighbor filter-list" commands. */ | |
596c17ba DW |
11781 | install_element (BGP_NODE, &neighbor_filter_list_hidden_cmd); |
11782 | install_element (BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
718e3744 | 11783 | install_element (BGP_IPV4_NODE, &neighbor_filter_list_cmd); |
11784 | install_element (BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
11785 | install_element (BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
11786 | install_element (BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
f51bae9c DS |
11787 | install_element (BGP_IPV4L_NODE, &neighbor_filter_list_cmd); |
11788 | install_element (BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
718e3744 | 11789 | install_element (BGP_IPV6_NODE, &neighbor_filter_list_cmd); |
11790 | install_element (BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
25ffbdc1 | 11791 | install_element (BGP_IPV6M_NODE, &neighbor_filter_list_cmd); |
11792 | install_element (BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
f51bae9c DS |
11793 | install_element (BGP_IPV6L_NODE, &neighbor_filter_list_cmd); |
11794 | install_element (BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
718e3744 | 11795 | install_element (BGP_VPNV4_NODE, &neighbor_filter_list_cmd); |
11796 | install_element (BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
8ecd3266 | 11797 | install_element (BGP_VPNV6_NODE, &neighbor_filter_list_cmd); |
11798 | install_element (BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
8b1fb8be LB |
11799 | install_element (BGP_ENCAP_NODE, &neighbor_filter_list_cmd); |
11800 | install_element (BGP_ENCAP_NODE, &no_neighbor_filter_list_cmd); | |
11801 | install_element (BGP_ENCAPV6_NODE, &neighbor_filter_list_cmd); | |
11802 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_filter_list_cmd); | |
718e3744 | 11803 | |
11804 | /* "neighbor route-map" commands. */ | |
596c17ba DW |
11805 | install_element (BGP_NODE, &neighbor_route_map_hidden_cmd); |
11806 | install_element (BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
718e3744 | 11807 | install_element (BGP_IPV4_NODE, &neighbor_route_map_cmd); |
11808 | install_element (BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
11809 | install_element (BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
11810 | install_element (BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
f51bae9c DS |
11811 | install_element (BGP_IPV4L_NODE, &neighbor_route_map_cmd); |
11812 | install_element (BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
718e3744 | 11813 | install_element (BGP_IPV6_NODE, &neighbor_route_map_cmd); |
11814 | install_element (BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
25ffbdc1 | 11815 | install_element (BGP_IPV6M_NODE, &neighbor_route_map_cmd); |
11816 | install_element (BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
f51bae9c DS |
11817 | install_element (BGP_IPV6L_NODE, &neighbor_route_map_cmd); |
11818 | install_element (BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
718e3744 | 11819 | install_element (BGP_VPNV4_NODE, &neighbor_route_map_cmd); |
11820 | install_element (BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
8ecd3266 | 11821 | install_element (BGP_VPNV6_NODE, &neighbor_route_map_cmd); |
11822 | install_element (BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
8b1fb8be LB |
11823 | install_element (BGP_ENCAP_NODE, &neighbor_route_map_cmd); |
11824 | install_element (BGP_ENCAP_NODE, &no_neighbor_route_map_cmd); | |
11825 | install_element (BGP_ENCAPV6_NODE, &neighbor_route_map_cmd); | |
11826 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_map_cmd); | |
718e3744 | 11827 | |
11828 | /* "neighbor unsuppress-map" commands. */ | |
596c17ba DW |
11829 | install_element (BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); |
11830 | install_element (BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
718e3744 | 11831 | install_element (BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); |
11832 | install_element (BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
11833 | install_element (BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
11834 | install_element (BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
f51bae9c DS |
11835 | install_element (BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); |
11836 | install_element (BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
718e3744 | 11837 | install_element (BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); |
11838 | install_element (BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
25ffbdc1 | 11839 | install_element (BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); |
11840 | install_element (BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
f51bae9c DS |
11841 | install_element (BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); |
11842 | install_element (BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
a58545bb | 11843 | install_element (BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); |
bb86c601 | 11844 | install_element (BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); |
8ecd3266 | 11845 | install_element (BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); |
bb86c601 | 11846 | install_element (BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); |
8b1fb8be LB |
11847 | install_element (BGP_ENCAP_NODE, &neighbor_unsuppress_map_cmd); |
11848 | install_element (BGP_ENCAP_NODE, &no_neighbor_unsuppress_map_cmd); | |
11849 | install_element (BGP_ENCAPV6_NODE, &neighbor_unsuppress_map_cmd); | |
11850 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
718e3744 | 11851 | |
11852 | /* "neighbor maximum-prefix" commands. */ | |
596c17ba DW |
11853 | install_element (BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); |
11854 | install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_hidden_cmd); | |
11855 | install_element (BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
11856 | install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
11857 | install_element (BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
11858 | install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
11859 | install_element (BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
718e3744 | 11860 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 11861 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 11862 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 11863 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 11864 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); |
11865 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 11866 | install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); |
718e3744 | 11867 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 11868 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 11869 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 11870 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 11871 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); |
11872 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 11873 | install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); |
f51bae9c DS |
11874 | install_element (BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); |
11875 | install_element (BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
11876 | install_element (BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
11877 | install_element (BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
11878 | install_element (BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
11879 | install_element (BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
11880 | install_element (BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
718e3744 | 11881 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 11882 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 11883 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 11884 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 11885 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); |
11886 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 11887 | install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); |
25ffbdc1 | 11888 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); |
11889 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
11890 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
11891 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
11892 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
11893 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
11894 | install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
f51bae9c DS |
11895 | install_element (BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); |
11896 | install_element (BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
11897 | install_element (BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
11898 | install_element (BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
11899 | install_element (BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
11900 | install_element (BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
11901 | install_element (BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
718e3744 | 11902 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 11903 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 11904 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 11905 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 11906 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); |
11907 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 11908 | install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); |
8ecd3266 | 11909 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); |
11910 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
11911 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
11912 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
11913 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
11914 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
11915 | install_element (BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
718e3744 | 11916 | |
8b1fb8be LB |
11917 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_cmd); |
11918 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
11919 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_warning_cmd); | |
11920 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
11921 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_restart_cmd); | |
11922 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
11923 | install_element (BGP_ENCAP_NODE, &no_neighbor_maximum_prefix_cmd); | |
8b1fb8be LB |
11924 | |
11925 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_cmd); | |
11926 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
11927 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
11928 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
11929 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
11930 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
11931 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
8b1fb8be | 11932 | |
718e3744 | 11933 | /* "neighbor allowas-in" */ |
596c17ba DW |
11934 | install_element (BGP_NODE, &neighbor_allowas_in_hidden_cmd); |
11935 | install_element (BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
718e3744 | 11936 | install_element (BGP_IPV4_NODE, &neighbor_allowas_in_cmd); |
718e3744 | 11937 | install_element (BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); |
11938 | install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
718e3744 | 11939 | install_element (BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); |
f51bae9c DS |
11940 | install_element (BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); |
11941 | install_element (BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
718e3744 | 11942 | install_element (BGP_IPV6_NODE, &neighbor_allowas_in_cmd); |
718e3744 | 11943 | install_element (BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); |
25ffbdc1 | 11944 | install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); |
25ffbdc1 | 11945 | install_element (BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); |
f51bae9c DS |
11946 | install_element (BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); |
11947 | install_element (BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
718e3744 | 11948 | install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); |
718e3744 | 11949 | install_element (BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); |
8ecd3266 | 11950 | install_element (BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); |
8ecd3266 | 11951 | install_element (BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); |
8b1fb8be | 11952 | install_element (BGP_ENCAP_NODE, &neighbor_allowas_in_cmd); |
8b1fb8be LB |
11953 | install_element (BGP_ENCAP_NODE, &no_neighbor_allowas_in_cmd); |
11954 | install_element (BGP_ENCAPV6_NODE, &neighbor_allowas_in_cmd); | |
8b1fb8be | 11955 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_allowas_in_cmd); |
718e3744 | 11956 | |
11957 | /* address-family commands. */ | |
718e3744 | 11958 | install_element (BGP_NODE, &address_family_ipv4_safi_cmd); |
25ffbdc1 | 11959 | install_element (BGP_NODE, &address_family_ipv6_safi_cmd); |
d6902373 | 11960 | #ifdef KEEP_OLD_VPN_COMMANDS |
718e3744 | 11961 | install_element (BGP_NODE, &address_family_vpnv4_cmd); |
8b1fb8be | 11962 | install_element (BGP_NODE, &address_family_vpnv6_cmd); |
d6902373 | 11963 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be LB |
11964 | |
11965 | install_element (BGP_NODE, &address_family_encap_cmd); | |
8b1fb8be | 11966 | install_element (BGP_NODE, &address_family_encapv6_cmd); |
8b1fb8be | 11967 | |
4e0b7b6d PG |
11968 | install_element (BGP_NODE, &address_family_evpn_cmd); |
11969 | ||
718e3744 | 11970 | /* "exit-address-family" command. */ |
11971 | install_element (BGP_IPV4_NODE, &exit_address_family_cmd); | |
11972 | install_element (BGP_IPV4M_NODE, &exit_address_family_cmd); | |
f51bae9c | 11973 | install_element (BGP_IPV4L_NODE, &exit_address_family_cmd); |
718e3744 | 11974 | install_element (BGP_IPV6_NODE, &exit_address_family_cmd); |
25ffbdc1 | 11975 | install_element (BGP_IPV6M_NODE, &exit_address_family_cmd); |
f51bae9c | 11976 | install_element (BGP_IPV6L_NODE, &exit_address_family_cmd); |
718e3744 | 11977 | install_element (BGP_VPNV4_NODE, &exit_address_family_cmd); |
8ecd3266 | 11978 | install_element (BGP_VPNV6_NODE, &exit_address_family_cmd); |
8b1fb8be LB |
11979 | install_element (BGP_ENCAP_NODE, &exit_address_family_cmd); |
11980 | install_element (BGP_ENCAPV6_NODE, &exit_address_family_cmd); | |
4e0b7b6d | 11981 | install_element (BGP_EVPN_NODE, &exit_address_family_cmd); |
718e3744 | 11982 | |
11983 | /* "clear ip bgp commands" */ | |
11984 | install_element (ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
718e3744 | 11985 | |
8ad7271d DS |
11986 | /* clear ip bgp prefix */ |
11987 | install_element (ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
11988 | install_element (ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
01080f7c | 11989 | install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); |
8ad7271d | 11990 | |
716b2d8a | 11991 | /* "show [ip] bgp summary" commands. */ |
f186de26 | 11992 | install_element (VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); |
8386ac43 | 11993 | install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_cmd); |
8386ac43 | 11994 | install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_s_cmd); |
271ad8d5 | 11995 | install_element (VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
e52702f2 | 11996 | install_element (VIEW_NODE, &show_bgp_updgrps_adj_cmd); |
e52702f2 | 11997 | install_element (VIEW_NODE, &show_bgp_updgrps_adj_s_cmd); |
271ad8d5 | 11998 | install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_cmd); |
e52702f2 | 11999 | install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_s_cmd); |
8c3deaae | 12000 | install_element (VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
271ad8d5 QY |
12001 | install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_cmd); |
12002 | install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); | |
12003 | install_element (VIEW_NODE, &show_ip_bgp_summary_cmd); | |
12004 | install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_cmd); | |
12005 | install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_s_cmd); | |
12006 | install_element (VIEW_NODE, &show_ip_bgp_updgrps_cmd); | |
e3e29b32 | 12007 | |
716b2d8a | 12008 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 12009 | install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd); |
718e3744 | 12010 | |
716b2d8a | 12011 | /* "show [ip] bgp peer-group" commands. */ |
f14e6fdb | 12012 | install_element (VIEW_NODE, &show_ip_bgp_peer_groups_cmd); |
f14e6fdb | 12013 | |
716b2d8a | 12014 | /* "show [ip] bgp paths" commands. */ |
718e3744 | 12015 | install_element (VIEW_NODE, &show_ip_bgp_paths_cmd); |
718e3744 | 12016 | |
716b2d8a | 12017 | /* "show [ip] bgp community" commands. */ |
718e3744 | 12018 | install_element (VIEW_NODE, &show_ip_bgp_community_info_cmd); |
718e3744 | 12019 | |
57d187bc JS |
12020 | /* "show ip bgp large-community" commands. */ |
12021 | install_element (VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
716b2d8a | 12022 | /* "show [ip] bgp attribute-info" commands. */ |
718e3744 | 12023 | install_element (VIEW_NODE, &show_ip_bgp_attr_info_cmd); |
718e3744 | 12024 | |
12025 | /* "redistribute" commands. */ | |
596c17ba DW |
12026 | install_element (BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); |
12027 | install_element (BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
12028 | install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
12029 | install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
12030 | install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
12031 | install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
12032 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
12033 | install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
12034 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
12035 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
12036 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
12037 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
919e0666 DW |
12038 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); |
12039 | install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
12040 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
919e0666 | 12041 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); |
919e0666 DW |
12042 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); |
12043 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
919e0666 DW |
12044 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); |
12045 | install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
12046 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
919e0666 | 12047 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); |
919e0666 | 12048 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); |
919e0666 | 12049 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); |
718e3744 | 12050 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); |
12051 | install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
12052 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
718e3744 | 12053 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); |
718e3744 | 12054 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); |
12055 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
718e3744 | 12056 | |
fa411a21 NH |
12057 | /* ttl_security commands */ |
12058 | install_element (BGP_NODE, &neighbor_ttl_security_cmd); | |
12059 | install_element (BGP_NODE, &no_neighbor_ttl_security_cmd); | |
12060 | ||
716b2d8a | 12061 | /* "show [ip] bgp memory" commands. */ |
4bf6a362 | 12062 | install_element (VIEW_NODE, &show_bgp_memory_cmd); |
e52702f2 | 12063 | |
716b2d8a | 12064 | /* "show [ip] bgp views" commands. */ |
e0081f70 | 12065 | install_element (VIEW_NODE, &show_bgp_views_cmd); |
e52702f2 | 12066 | |
716b2d8a | 12067 | /* "show [ip] bgp vrfs" commands. */ |
8386ac43 | 12068 | install_element (VIEW_NODE, &show_bgp_vrfs_cmd); |
e52702f2 | 12069 | |
718e3744 | 12070 | /* Community-list. */ |
12071 | community_list_vty (); | |
12072 | } | |
6b0655a2 | 12073 | |
718e3744 | 12074 | #include "memory.h" |
12075 | #include "bgp_regex.h" | |
12076 | #include "bgp_clist.h" | |
12077 | #include "bgp_ecommunity.h" | |
12078 | ||
12079 | /* VTY functions. */ | |
12080 | ||
12081 | /* Direction value to string conversion. */ | |
94f2b392 | 12082 | static const char * |
718e3744 | 12083 | community_direct_str (int direct) |
12084 | { | |
12085 | switch (direct) | |
12086 | { | |
12087 | case COMMUNITY_DENY: | |
12088 | return "deny"; | |
718e3744 | 12089 | case COMMUNITY_PERMIT: |
12090 | return "permit"; | |
718e3744 | 12091 | default: |
12092 | return "unknown"; | |
718e3744 | 12093 | } |
12094 | } | |
12095 | ||
12096 | /* Display error string. */ | |
94f2b392 | 12097 | static void |
718e3744 | 12098 | community_list_perror (struct vty *vty, int ret) |
12099 | { | |
12100 | switch (ret) | |
12101 | { | |
12102 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
b729294c | 12103 | vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE); |
718e3744 | 12104 | break; |
12105 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
12106 | vty_out (vty, "%% Malformed community-list value%s", VTY_NEWLINE); | |
12107 | break; | |
12108 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
12109 | vty_out (vty, "%% Community name conflict, previously defined as standard community%s", VTY_NEWLINE); | |
12110 | break; | |
12111 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
12112 | vty_out (vty, "%% Community name conflict, previously defined as expanded community%s", VTY_NEWLINE); | |
12113 | break; | |
12114 | } | |
12115 | } | |
12116 | ||
5bf15956 DW |
12117 | /* "community-list" keyword help string. */ |
12118 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
12119 | ||
718e3744 | 12120 | |
5bf15956 | 12121 | /* ip community-list standard */ |
718e3744 | 12122 | DEFUN (ip_community_list_standard, |
12123 | ip_community_list_standard_cmd, | |
e961923c | 12124 | "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 12125 | IP_STR |
12126 | COMMUNITY_LIST_STR | |
12127 | "Community list number (standard)\n" | |
5bf15956 | 12128 | "Add an standard community-list entry\n" |
718e3744 | 12129 | "Community list name\n" |
12130 | "Specify community to reject\n" | |
12131 | "Specify community to accept\n" | |
12132 | COMMUNITY_VAL_STR) | |
12133 | { | |
42f914d4 QY |
12134 | char *cl_name_or_number = NULL; |
12135 | int direct = 0; | |
12136 | int style = COMMUNITY_LIST_STANDARD; | |
12137 | ||
12138 | int idx = 0; | |
12139 | argv_find (argv, argc, "(1-99)", &idx); | |
12140 | argv_find (argv, argc, "WORD", &idx); | |
12141 | cl_name_or_number = argv[idx]->arg; | |
12142 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
12143 | argv_find (argv, argc, "AA:NN", &idx); | |
12144 | char *str = argv_concat (argv, argc, idx); | |
12145 | ||
12146 | int ret = community_list_set (bgp_clist, cl_name_or_number, str, direct, style); | |
12147 | ||
12148 | XFREE (MTYPE_TMP, str); | |
12149 | ||
12150 | if (ret < 0) | |
12151 | { | |
12152 | /* Display error string. */ | |
12153 | community_list_perror (vty, ret); | |
12154 | return CMD_WARNING; | |
12155 | } | |
12156 | ||
12157 | return CMD_SUCCESS; | |
718e3744 | 12158 | } |
12159 | ||
fee6e4e4 | 12160 | DEFUN (no_ip_community_list_standard_all, |
12161 | no_ip_community_list_standard_all_cmd, | |
e961923c | 12162 | "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 12163 | NO_STR |
12164 | IP_STR | |
12165 | COMMUNITY_LIST_STR | |
12166 | "Community list number (standard)\n" | |
5bf15956 DW |
12167 | "Add an standard community-list entry\n" |
12168 | "Community list name\n" | |
718e3744 | 12169 | "Specify community to reject\n" |
12170 | "Specify community to accept\n" | |
12171 | COMMUNITY_VAL_STR) | |
12172 | { | |
42f914d4 QY |
12173 | int delete_all = 0; |
12174 | ||
12175 | char *cl_name_or_number = NULL; | |
12176 | int direct = 0; | |
12177 | int style = COMMUNITY_LIST_STANDARD; | |
12178 | ||
12179 | int idx = 0; | |
12180 | argv_find (argv, argc, "(1-99)", &idx); | |
12181 | argv_find (argv, argc, "WORD", &idx); | |
12182 | cl_name_or_number = argv[idx]->arg; | |
12183 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
12184 | argv_find (argv, argc, "AA:NN", &idx); | |
12185 | char *str = argv_concat (argv, argc, idx); | |
12186 | ||
12187 | int ret = community_list_unset (bgp_clist, cl_name_or_number, str, direct, style, delete_all); | |
12188 | ||
daf9ddbb DS |
12189 | XFREE (MTYPE_TMP, str); |
12190 | ||
42f914d4 QY |
12191 | if (ret < 0) |
12192 | { | |
12193 | community_list_perror (vty, ret); | |
12194 | return CMD_WARNING; | |
12195 | } | |
12196 | ||
12197 | return CMD_SUCCESS; | |
718e3744 | 12198 | } |
12199 | ||
5bf15956 DW |
12200 | /* ip community-list expanded */ |
12201 | DEFUN (ip_community_list_expanded_all, | |
12202 | ip_community_list_expanded_all_cmd, | |
42f914d4 | 12203 | "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 12204 | IP_STR |
12205 | COMMUNITY_LIST_STR | |
12206 | "Community list number (expanded)\n" | |
5bf15956 | 12207 | "Add an expanded community-list entry\n" |
718e3744 | 12208 | "Community list name\n" |
12209 | "Specify community to reject\n" | |
12210 | "Specify community to accept\n" | |
12211 | COMMUNITY_VAL_STR) | |
12212 | { | |
42f914d4 QY |
12213 | char *cl_name_or_number = NULL; |
12214 | int direct = 0; | |
12215 | int style = COMMUNITY_LIST_EXPANDED; | |
12216 | ||
12217 | int idx = 0; | |
12218 | argv_find (argv, argc, "(100-500)", &idx); | |
12219 | argv_find (argv, argc, "WORD", &idx); | |
12220 | cl_name_or_number = argv[idx]->arg; | |
12221 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
12222 | argv_find (argv, argc, "AA:NN", &idx); | |
12223 | char *str = argv_concat (argv, argc, idx); | |
12224 | ||
12225 | int ret = community_list_set (bgp_clist, cl_name_or_number, str, direct, style); | |
12226 | ||
12227 | XFREE (MTYPE_TMP, str); | |
12228 | ||
12229 | if (ret < 0) | |
12230 | { | |
12231 | /* Display error string. */ | |
12232 | community_list_perror (vty, ret); | |
12233 | return CMD_WARNING; | |
12234 | } | |
12235 | ||
12236 | return CMD_SUCCESS; | |
718e3744 | 12237 | } |
12238 | ||
5bf15956 DW |
12239 | DEFUN (no_ip_community_list_expanded_all, |
12240 | no_ip_community_list_expanded_all_cmd, | |
42f914d4 | 12241 | "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 12242 | NO_STR |
12243 | IP_STR | |
12244 | COMMUNITY_LIST_STR | |
5bf15956 DW |
12245 | "Community list number (expanded)\n" |
12246 | "Add an expanded community-list entry\n" | |
718e3744 | 12247 | "Community list name\n" |
12248 | "Specify community to reject\n" | |
12249 | "Specify community to accept\n" | |
5bf15956 | 12250 | COMMUNITY_VAL_STR) |
718e3744 | 12251 | { |
42f914d4 QY |
12252 | int delete_all = 0; |
12253 | ||
12254 | char *cl_name_or_number = NULL; | |
12255 | int direct = 0; | |
12256 | int style = COMMUNITY_LIST_EXPANDED; | |
12257 | ||
12258 | int idx = 0; | |
12259 | argv_find (argv, argc, "(100-500)", &idx); | |
12260 | argv_find (argv, argc, "WORD", &idx); | |
12261 | cl_name_or_number = argv[idx]->arg; | |
12262 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
12263 | argv_find (argv, argc, "AA:NN", &idx); | |
12264 | char *str = argv_concat (argv, argc, idx); | |
12265 | ||
12266 | int ret = community_list_unset (bgp_clist, cl_name_or_number, str, direct, style, delete_all); | |
12267 | ||
daf9ddbb DS |
12268 | XFREE (MTYPE_TMP, str); |
12269 | ||
42f914d4 QY |
12270 | if (ret < 0) |
12271 | { | |
12272 | community_list_perror (vty, ret); | |
12273 | return CMD_WARNING; | |
12274 | } | |
12275 | ||
12276 | return CMD_SUCCESS; | |
718e3744 | 12277 | } |
12278 | ||
94f2b392 | 12279 | static void |
718e3744 | 12280 | community_list_show (struct vty *vty, struct community_list *list) |
12281 | { | |
12282 | struct community_entry *entry; | |
12283 | ||
12284 | for (entry = list->head; entry; entry = entry->next) | |
12285 | { | |
12286 | if (entry == list->head) | |
12287 | { | |
12288 | if (all_digit (list->name)) | |
12289 | vty_out (vty, "Community %s list %s%s", | |
12290 | entry->style == COMMUNITY_LIST_STANDARD ? | |
12291 | "standard" : "(expanded) access", | |
12292 | list->name, VTY_NEWLINE); | |
12293 | else | |
12294 | vty_out (vty, "Named Community %s list %s%s", | |
12295 | entry->style == COMMUNITY_LIST_STANDARD ? | |
12296 | "standard" : "expanded", | |
12297 | list->name, VTY_NEWLINE); | |
12298 | } | |
12299 | if (entry->any) | |
12300 | vty_out (vty, " %s%s", | |
12301 | community_direct_str (entry->direct), VTY_NEWLINE); | |
12302 | else | |
12303 | vty_out (vty, " %s %s%s", | |
12304 | community_direct_str (entry->direct), | |
12305 | entry->style == COMMUNITY_LIST_STANDARD | |
12306 | ? community_str (entry->u.com) : entry->config, | |
12307 | VTY_NEWLINE); | |
12308 | } | |
12309 | } | |
12310 | ||
12311 | DEFUN (show_ip_community_list, | |
12312 | show_ip_community_list_cmd, | |
12313 | "show ip community-list", | |
12314 | SHOW_STR | |
12315 | IP_STR | |
12316 | "List community-list\n") | |
12317 | { | |
12318 | struct community_list *list; | |
12319 | struct community_list_master *cm; | |
12320 | ||
fee6e4e4 | 12321 | cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER); |
718e3744 | 12322 | if (! cm) |
12323 | return CMD_SUCCESS; | |
12324 | ||
12325 | for (list = cm->num.head; list; list = list->next) | |
12326 | community_list_show (vty, list); | |
12327 | ||
12328 | for (list = cm->str.head; list; list = list->next) | |
12329 | community_list_show (vty, list); | |
12330 | ||
12331 | return CMD_SUCCESS; | |
12332 | } | |
12333 | ||
12334 | DEFUN (show_ip_community_list_arg, | |
12335 | show_ip_community_list_arg_cmd, | |
6147e2c6 | 12336 | "show ip community-list <(1-500)|WORD>", |
718e3744 | 12337 | SHOW_STR |
12338 | IP_STR | |
12339 | "List community-list\n" | |
12340 | "Community-list number\n" | |
12341 | "Community-list name\n") | |
12342 | { | |
c500ae40 | 12343 | int idx_comm_list = 3; |
718e3744 | 12344 | struct community_list *list; |
12345 | ||
c500ae40 | 12346 | list = community_list_lookup (bgp_clist, argv[idx_comm_list]->arg, COMMUNITY_LIST_MASTER); |
718e3744 | 12347 | if (! list) |
12348 | { | |
b729294c | 12349 | vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE); |
718e3744 | 12350 | return CMD_WARNING; |
12351 | } | |
12352 | ||
12353 | community_list_show (vty, list); | |
12354 | ||
12355 | return CMD_SUCCESS; | |
12356 | } | |
6b0655a2 | 12357 | |
57d187bc JS |
12358 | /* |
12359 | * Large Community code. | |
12360 | */ | |
12361 | static int | |
12362 | lcommunity_list_set_vty (struct vty *vty, int argc, struct cmd_token **argv, | |
2acb4ac2 | 12363 | int style, int reject_all_digit_name) |
57d187bc JS |
12364 | { |
12365 | int ret; | |
12366 | int direct; | |
12367 | char *str; | |
12368 | int idx = 0; | |
12369 | char *cl_name; | |
12370 | ||
12371 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
12372 | ||
12373 | /* All digit name check. */ | |
12374 | idx = 0; | |
12375 | argv_find (argv, argc, "WORD", &idx); | |
12376 | argv_find (argv, argc, "(1-99)", &idx); | |
12377 | argv_find (argv, argc, "(100-500)", &idx); | |
12378 | cl_name = argv[idx]->arg; | |
12379 | if (reject_all_digit_name && all_digit (cl_name)) | |
12380 | { | |
12381 | vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE); | |
12382 | return CMD_WARNING; | |
12383 | } | |
12384 | ||
12385 | argv_find (argv, argc, "AA:BB:CC", &idx); | |
12386 | argv_find (argv, argc, "LINE", &idx); | |
12387 | /* Concat community string argument. */ | |
12388 | if (idx) | |
12389 | str = argv_concat (argv, argc, idx); | |
12390 | else | |
12391 | str = NULL; | |
12392 | ||
12393 | ret = lcommunity_list_set (bgp_clist, cl_name, str, direct, style); | |
12394 | ||
12395 | /* Free temporary community list string allocated by | |
12396 | argv_concat(). */ | |
12397 | if (str) | |
12398 | XFREE (MTYPE_TMP, str); | |
12399 | ||
12400 | if (ret < 0) | |
12401 | { | |
12402 | community_list_perror (vty, ret); | |
12403 | return CMD_WARNING; | |
12404 | } | |
12405 | return CMD_SUCCESS; | |
12406 | } | |
12407 | ||
12408 | static int | |
12409 | lcommunity_list_unset_vty (struct vty *vty, int argc, struct cmd_token **argv, | |
2acb4ac2 | 12410 | int style) |
57d187bc JS |
12411 | { |
12412 | int ret; | |
12413 | int direct = 0; | |
12414 | char *str = NULL; | |
12415 | int idx = 0; | |
12416 | ||
12417 | argv_find (argv, argc, "permit", &idx); | |
12418 | argv_find (argv, argc, "deny", &idx); | |
12419 | ||
12420 | if (idx) | |
12421 | { | |
12422 | /* Check the list direct. */ | |
12423 | if (strncmp (argv[idx]->arg, "p", 1) == 0) | |
2acb4ac2 | 12424 | direct = COMMUNITY_PERMIT; |
57d187bc | 12425 | else |
2acb4ac2 | 12426 | direct = COMMUNITY_DENY; |
57d187bc JS |
12427 | |
12428 | idx = 0; | |
12429 | argv_find (argv, argc, "LINE", &idx); | |
12430 | argv_find (argv, argc, "AA:AA:NN", &idx); | |
12431 | /* Concat community string argument. */ | |
12432 | str = argv_concat (argv, argc, idx); | |
12433 | } | |
12434 | ||
12435 | idx = 0; | |
12436 | argv_find (argv, argc, "(1-99)", &idx); | |
12437 | argv_find (argv, argc, "(100-500)", &idx); | |
12438 | argv_find (argv, argc, "WORD", &idx); | |
12439 | ||
12440 | /* Unset community list. */ | |
12441 | ret = lcommunity_list_unset (bgp_clist, argv[idx]->arg, str, direct, style); | |
12442 | ||
12443 | /* Free temporary community list string allocated by | |
12444 | argv_concat(). */ | |
12445 | if (str) | |
12446 | XFREE (MTYPE_TMP, str); | |
12447 | ||
12448 | if (ret < 0) | |
12449 | { | |
12450 | community_list_perror (vty, ret); | |
12451 | return CMD_WARNING; | |
12452 | } | |
12453 | ||
12454 | return CMD_SUCCESS; | |
12455 | } | |
12456 | ||
12457 | /* "large-community-list" keyword help string. */ | |
12458 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
12459 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
12460 | ||
12461 | DEFUN (ip_lcommunity_list_standard, | |
12462 | ip_lcommunity_list_standard_cmd, | |
52951b63 DS |
12463 | "ip large-community-list (1-99) <deny|permit>", |
12464 | IP_STR | |
12465 | LCOMMUNITY_LIST_STR | |
12466 | "Large Community list number (standard)\n" | |
12467 | "Specify large community to reject\n" | |
12468 | "Specify large community to accept\n" | |
12469 | LCOMMUNITY_VAL_STR) | |
12470 | { | |
12471 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD, 0); | |
12472 | } | |
12473 | ||
12474 | DEFUN (ip_lcommunity_list_standard1, | |
12475 | ip_lcommunity_list_standard1_cmd, | |
12476 | "ip large-community-list (1-99) <deny|permit> AA:BB:CC...", | |
57d187bc JS |
12477 | IP_STR |
12478 | LCOMMUNITY_LIST_STR | |
12479 | "Large Community list number (standard)\n" | |
12480 | "Specify large community to reject\n" | |
12481 | "Specify large community to accept\n" | |
12482 | LCOMMUNITY_VAL_STR) | |
12483 | { | |
12484 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD, 0); | |
12485 | } | |
12486 | ||
12487 | DEFUN (ip_lcommunity_list_expanded, | |
12488 | ip_lcommunity_list_expanded_cmd, | |
12489 | "ip large-community-list (100-500) <deny|permit> LINE...", | |
12490 | IP_STR | |
12491 | LCOMMUNITY_LIST_STR | |
12492 | "Large Community list number (expanded)\n" | |
12493 | "Specify large community to reject\n" | |
12494 | "Specify large community to accept\n" | |
12495 | "An ordered list as a regular-expression\n") | |
12496 | { | |
12497 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED, 0); | |
12498 | } | |
12499 | ||
12500 | DEFUN (ip_lcommunity_list_name_standard, | |
12501 | ip_lcommunity_list_name_standard_cmd, | |
52951b63 DS |
12502 | "ip large-community-list standard WORD <deny|permit>", |
12503 | IP_STR | |
12504 | LCOMMUNITY_LIST_STR | |
12505 | "Specify standard large-community-list\n" | |
12506 | "Large Community list name\n" | |
12507 | "Specify large community to reject\n" | |
12508 | "Specify large community to accept\n") | |
12509 | { | |
12510 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD, 1); | |
12511 | } | |
12512 | ||
12513 | DEFUN (ip_lcommunity_list_name_standard1, | |
12514 | ip_lcommunity_list_name_standard1_cmd, | |
12515 | "ip large-community-list standard WORD <deny|permit> AA:BB:CC...", | |
57d187bc JS |
12516 | IP_STR |
12517 | LCOMMUNITY_LIST_STR | |
12518 | "Specify standard large-community-list\n" | |
12519 | "Large Community list name\n" | |
12520 | "Specify large community to reject\n" | |
12521 | "Specify large community to accept\n" | |
12522 | LCOMMUNITY_VAL_STR) | |
12523 | { | |
12524 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD, 1); | |
12525 | } | |
12526 | ||
12527 | DEFUN (ip_lcommunity_list_name_expanded, | |
12528 | ip_lcommunity_list_name_expanded_cmd, | |
12529 | "ip large-community-list expanded WORD <deny|permit> LINE...", | |
12530 | IP_STR | |
12531 | LCOMMUNITY_LIST_STR | |
12532 | "Specify expanded large-community-list\n" | |
12533 | "Large Community list name\n" | |
12534 | "Specify large community to reject\n" | |
12535 | "Specify large community to accept\n" | |
12536 | "An ordered list as a regular-expression\n") | |
12537 | { | |
12538 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED, 1); | |
12539 | } | |
12540 | ||
12541 | DEFUN (no_ip_lcommunity_list_standard_all, | |
12542 | no_ip_lcommunity_list_standard_all_cmd, | |
12543 | "no ip large-community-list <(1-99)|(100-500)|WORD>", | |
12544 | NO_STR | |
12545 | IP_STR | |
12546 | LCOMMUNITY_LIST_STR | |
12547 | "Large Community list number (standard)\n" | |
12548 | "Large Community list number (expanded)\n" | |
12549 | "Large Community list name\n") | |
12550 | { | |
12551 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD); | |
12552 | } | |
12553 | ||
12554 | DEFUN (no_ip_lcommunity_list_name_expanded_all, | |
12555 | no_ip_lcommunity_list_name_expanded_all_cmd, | |
12556 | "no ip large-community-list expanded WORD", | |
12557 | NO_STR | |
12558 | IP_STR | |
12559 | LCOMMUNITY_LIST_STR | |
12560 | "Specify expanded large-community-list\n" | |
12561 | "Large Community list name\n") | |
12562 | { | |
12563 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED); | |
12564 | } | |
12565 | ||
12566 | DEFUN (no_ip_lcommunity_list_standard, | |
12567 | no_ip_lcommunity_list_standard_cmd, | |
12568 | "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...", | |
12569 | NO_STR | |
12570 | IP_STR | |
12571 | LCOMMUNITY_LIST_STR | |
12572 | "Large Community list number (standard)\n" | |
12573 | "Specify large community to reject\n" | |
12574 | "Specify large community to accept\n" | |
12575 | LCOMMUNITY_VAL_STR) | |
12576 | { | |
12577 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD); | |
12578 | } | |
12579 | ||
12580 | DEFUN (no_ip_lcommunity_list_expanded, | |
12581 | no_ip_lcommunity_list_expanded_cmd, | |
12582 | "no ip large-community-list (100-500) <deny|permit> LINE...", | |
12583 | NO_STR | |
12584 | IP_STR | |
12585 | LCOMMUNITY_LIST_STR | |
12586 | "Large Community list number (expanded)\n" | |
12587 | "Specify large community to reject\n" | |
12588 | "Specify large community to accept\n" | |
12589 | "An ordered list as a regular-expression\n") | |
12590 | { | |
12591 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED); | |
12592 | } | |
12593 | ||
12594 | DEFUN (no_ip_lcommunity_list_name_standard, | |
12595 | no_ip_lcommunity_list_name_standard_cmd, | |
12596 | "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...", | |
12597 | NO_STR | |
12598 | IP_STR | |
12599 | LCOMMUNITY_LIST_STR | |
12600 | "Specify standard large-community-list\n" | |
12601 | "Large Community list name\n" | |
12602 | "Specify large community to reject\n" | |
12603 | "Specify large community to accept\n" | |
12604 | LCOMMUNITY_VAL_STR) | |
12605 | { | |
12606 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD); | |
12607 | } | |
12608 | ||
12609 | DEFUN (no_ip_lcommunity_list_name_expanded, | |
12610 | no_ip_lcommunity_list_name_expanded_cmd, | |
12611 | "no ip large-community-list expanded WORD <deny|permit> LINE...", | |
12612 | NO_STR | |
12613 | IP_STR | |
12614 | LCOMMUNITY_LIST_STR | |
12615 | "Specify expanded large-community-list\n" | |
12616 | "Large community list name\n" | |
12617 | "Specify large community to reject\n" | |
12618 | "Specify large community to accept\n" | |
12619 | "An ordered list as a regular-expression\n") | |
12620 | { | |
12621 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED); | |
12622 | } | |
12623 | ||
12624 | static void | |
12625 | lcommunity_list_show (struct vty *vty, struct community_list *list) | |
12626 | { | |
12627 | struct community_entry *entry; | |
12628 | ||
12629 | for (entry = list->head; entry; entry = entry->next) | |
12630 | { | |
12631 | if (entry == list->head) | |
2acb4ac2 DL |
12632 | { |
12633 | if (all_digit (list->name)) | |
12634 | vty_out (vty, "Large community %s list %s%s", | |
12635 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
12636 | "standard" : "(expanded) access", | |
12637 | list->name, VTY_NEWLINE); | |
12638 | else | |
12639 | vty_out (vty, "Named large community %s list %s%s", | |
12640 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
12641 | "standard" : "expanded", | |
12642 | list->name, VTY_NEWLINE); | |
12643 | } | |
57d187bc | 12644 | if (entry->any) |
2acb4ac2 DL |
12645 | vty_out (vty, " %s%s", |
12646 | community_direct_str (entry->direct), VTY_NEWLINE); | |
57d187bc | 12647 | else |
2acb4ac2 DL |
12648 | vty_out (vty, " %s %s%s", |
12649 | community_direct_str (entry->direct), | |
12650 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
12651 | entry->u.ecom->str : entry->config, | |
12652 | VTY_NEWLINE); | |
57d187bc JS |
12653 | } |
12654 | } | |
12655 | ||
12656 | DEFUN (show_ip_lcommunity_list, | |
12657 | show_ip_lcommunity_list_cmd, | |
12658 | "show ip large-community-list", | |
12659 | SHOW_STR | |
12660 | IP_STR | |
12661 | "List large-community list\n") | |
12662 | { | |
12663 | struct community_list *list; | |
12664 | struct community_list_master *cm; | |
12665 | ||
12666 | cm = community_list_master_lookup (bgp_clist, LARGE_COMMUNITY_LIST_MASTER); | |
12667 | if (! cm) | |
12668 | return CMD_SUCCESS; | |
12669 | ||
12670 | for (list = cm->num.head; list; list = list->next) | |
12671 | lcommunity_list_show (vty, list); | |
12672 | ||
12673 | for (list = cm->str.head; list; list = list->next) | |
12674 | lcommunity_list_show (vty, list); | |
12675 | ||
12676 | return CMD_SUCCESS; | |
12677 | } | |
12678 | ||
12679 | DEFUN (show_ip_lcommunity_list_arg, | |
12680 | show_ip_lcommunity_list_arg_cmd, | |
12681 | "show ip large-community-list <(1-500)|WORD>", | |
12682 | SHOW_STR | |
12683 | IP_STR | |
12684 | "List large-community list\n" | |
12685 | "large-community-list number\n" | |
12686 | "large-community-list name\n") | |
12687 | { | |
12688 | struct community_list *list; | |
12689 | ||
12690 | list = community_list_lookup (bgp_clist, argv[3]->arg, LARGE_COMMUNITY_LIST_MASTER); | |
12691 | if (! list) | |
12692 | { | |
12693 | vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE); | |
12694 | return CMD_WARNING; | |
12695 | } | |
12696 | ||
12697 | lcommunity_list_show (vty, list); | |
12698 | ||
12699 | return CMD_SUCCESS; | |
12700 | } | |
12701 | ||
718e3744 | 12702 | /* "extcommunity-list" keyword help string. */ |
12703 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
12704 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
12705 | ||
12706 | DEFUN (ip_extcommunity_list_standard, | |
12707 | ip_extcommunity_list_standard_cmd, | |
e961923c | 12708 | "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 12709 | IP_STR |
12710 | EXTCOMMUNITY_LIST_STR | |
12711 | "Extended Community list number (standard)\n" | |
718e3744 | 12712 | "Specify standard extcommunity-list\n" |
5bf15956 | 12713 | "Community list name\n" |
718e3744 | 12714 | "Specify community to reject\n" |
12715 | "Specify community to accept\n" | |
12716 | EXTCOMMUNITY_VAL_STR) | |
12717 | { | |
42f914d4 QY |
12718 | int style = EXTCOMMUNITY_LIST_STANDARD; |
12719 | int direct = 0; | |
12720 | char *cl_number_or_name = NULL; | |
12721 | ||
12722 | int idx = 0; | |
12723 | argv_find (argv, argc, "(1-99)", &idx); | |
12724 | argv_find (argv, argc, "WORD", &idx); | |
12725 | cl_number_or_name = argv[idx]->arg; | |
12726 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
12727 | argv_find (argv, argc, "AA:NN", &idx); | |
12728 | char *str = argv_concat (argv, argc, idx); | |
12729 | ||
12730 | int ret = extcommunity_list_set (bgp_clist, cl_number_or_name, str, direct, style); | |
12731 | ||
12732 | XFREE (MTYPE_TMP, str); | |
12733 | ||
12734 | if (ret < 0) | |
12735 | { | |
12736 | community_list_perror (vty, ret); | |
12737 | return CMD_WARNING; | |
12738 | } | |
12739 | ||
12740 | return CMD_SUCCESS; | |
718e3744 | 12741 | } |
12742 | ||
718e3744 | 12743 | DEFUN (ip_extcommunity_list_name_expanded, |
12744 | ip_extcommunity_list_name_expanded_cmd, | |
e961923c | 12745 | "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 12746 | IP_STR |
12747 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 12748 | "Extended Community list number (expanded)\n" |
718e3744 | 12749 | "Specify expanded extcommunity-list\n" |
12750 | "Extended Community list name\n" | |
12751 | "Specify community to reject\n" | |
12752 | "Specify community to accept\n" | |
12753 | "An ordered list as a regular-expression\n") | |
12754 | { | |
42f914d4 QY |
12755 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
12756 | int direct = 0; | |
12757 | char *cl_number_or_name = NULL; | |
12758 | ||
12759 | int idx = 0; | |
12760 | argv_find (argv, argc, "(100-500)", &idx); | |
12761 | argv_find (argv, argc, "WORD", &idx); | |
12762 | cl_number_or_name = argv[idx]->arg; | |
12763 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
12764 | argv_find (argv, argc, "LINE", &idx); | |
12765 | char *str = argv_concat (argv, argc, idx); | |
12766 | ||
12767 | int ret = extcommunity_list_set (bgp_clist, cl_number_or_name, str, direct, style); | |
12768 | ||
12769 | XFREE (MTYPE_TMP, str); | |
12770 | ||
12771 | if (ret < 0) | |
12772 | { | |
12773 | community_list_perror (vty, ret); | |
12774 | return CMD_WARNING; | |
12775 | } | |
12776 | ||
12777 | return CMD_SUCCESS; | |
718e3744 | 12778 | } |
12779 | ||
fee6e4e4 | 12780 | DEFUN (no_ip_extcommunity_list_standard_all, |
12781 | no_ip_extcommunity_list_standard_all_cmd, | |
e961923c | 12782 | "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
813d4307 DW |
12783 | NO_STR |
12784 | IP_STR | |
12785 | EXTCOMMUNITY_LIST_STR | |
12786 | "Extended Community list number (standard)\n" | |
718e3744 | 12787 | "Specify standard extcommunity-list\n" |
5bf15956 | 12788 | "Community list name\n" |
718e3744 | 12789 | "Specify community to reject\n" |
12790 | "Specify community to accept\n" | |
12791 | EXTCOMMUNITY_VAL_STR) | |
12792 | { | |
42f914d4 QY |
12793 | int deleteall = 0; |
12794 | ||
12795 | int style = EXTCOMMUNITY_LIST_STANDARD; | |
12796 | int direct = 0; | |
12797 | char *cl_number_or_name = NULL; | |
12798 | ||
12799 | int idx = 0; | |
12800 | argv_find (argv, argc, "(1-99)", &idx); | |
12801 | argv_find (argv, argc, "WORD", &idx); | |
12802 | cl_number_or_name = argv[idx]->arg; | |
12803 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
12804 | argv_find (argv, argc, "AA:NN", &idx); | |
12805 | char *str = argv_concat (argv, argc, idx); | |
12806 | ||
12807 | int ret = extcommunity_list_unset (bgp_clist, cl_number_or_name, str, direct, style, deleteall); | |
12808 | ||
12809 | XFREE (MTYPE_TMP, str); | |
12810 | ||
12811 | if (ret < 0) | |
12812 | { | |
12813 | community_list_perror (vty, ret); | |
12814 | return CMD_WARNING; | |
12815 | } | |
12816 | ||
12817 | return CMD_SUCCESS; | |
718e3744 | 12818 | } |
12819 | ||
5bf15956 DW |
12820 | DEFUN (no_ip_extcommunity_list_expanded_all, |
12821 | no_ip_extcommunity_list_expanded_all_cmd, | |
e961923c | 12822 | "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 12823 | NO_STR |
12824 | IP_STR | |
12825 | EXTCOMMUNITY_LIST_STR | |
12826 | "Extended Community list number (expanded)\n" | |
718e3744 | 12827 | "Specify expanded extcommunity-list\n" |
5bf15956 | 12828 | "Extended Community list name\n" |
718e3744 | 12829 | "Specify community to reject\n" |
12830 | "Specify community to accept\n" | |
12831 | "An ordered list as a regular-expression\n") | |
12832 | { | |
42f914d4 QY |
12833 | int deleteall = 0; |
12834 | ||
12835 | int style = EXTCOMMUNITY_LIST_EXPANDED; | |
12836 | int direct = 0; | |
12837 | char *cl_number_or_name = NULL; | |
12838 | ||
12839 | int idx = 0; | |
12840 | argv_find (argv, argc, "(100-500)", &idx); | |
12841 | argv_find (argv, argc, "WORD", &idx); | |
12842 | cl_number_or_name = argv[idx]->arg; | |
12843 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
12844 | argv_find (argv, argc, "LINE", &idx); | |
12845 | char *str = argv_concat (argv, argc, idx); | |
12846 | ||
12847 | int ret = extcommunity_list_unset (bgp_clist, cl_number_or_name, str, direct, style, deleteall); | |
12848 | ||
12849 | XFREE (MTYPE_TMP, str); | |
12850 | ||
12851 | if (ret < 0) | |
12852 | { | |
12853 | community_list_perror (vty, ret); | |
12854 | return CMD_WARNING; | |
12855 | } | |
12856 | ||
12857 | return CMD_SUCCESS; | |
718e3744 | 12858 | } |
12859 | ||
94f2b392 | 12860 | static void |
718e3744 | 12861 | extcommunity_list_show (struct vty *vty, struct community_list *list) |
12862 | { | |
12863 | struct community_entry *entry; | |
12864 | ||
12865 | for (entry = list->head; entry; entry = entry->next) | |
12866 | { | |
12867 | if (entry == list->head) | |
12868 | { | |
12869 | if (all_digit (list->name)) | |
12870 | vty_out (vty, "Extended community %s list %s%s", | |
12871 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
12872 | "standard" : "(expanded) access", | |
12873 | list->name, VTY_NEWLINE); | |
12874 | else | |
12875 | vty_out (vty, "Named extended community %s list %s%s", | |
12876 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
12877 | "standard" : "expanded", | |
12878 | list->name, VTY_NEWLINE); | |
12879 | } | |
12880 | if (entry->any) | |
12881 | vty_out (vty, " %s%s", | |
12882 | community_direct_str (entry->direct), VTY_NEWLINE); | |
12883 | else | |
12884 | vty_out (vty, " %s %s%s", | |
12885 | community_direct_str (entry->direct), | |
12886 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
12887 | entry->u.ecom->str : entry->config, | |
12888 | VTY_NEWLINE); | |
12889 | } | |
12890 | } | |
12891 | ||
12892 | DEFUN (show_ip_extcommunity_list, | |
12893 | show_ip_extcommunity_list_cmd, | |
12894 | "show ip extcommunity-list", | |
12895 | SHOW_STR | |
12896 | IP_STR | |
12897 | "List extended-community list\n") | |
12898 | { | |
12899 | struct community_list *list; | |
12900 | struct community_list_master *cm; | |
12901 | ||
fee6e4e4 | 12902 | cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
718e3744 | 12903 | if (! cm) |
12904 | return CMD_SUCCESS; | |
12905 | ||
12906 | for (list = cm->num.head; list; list = list->next) | |
12907 | extcommunity_list_show (vty, list); | |
12908 | ||
12909 | for (list = cm->str.head; list; list = list->next) | |
12910 | extcommunity_list_show (vty, list); | |
12911 | ||
12912 | return CMD_SUCCESS; | |
12913 | } | |
12914 | ||
12915 | DEFUN (show_ip_extcommunity_list_arg, | |
12916 | show_ip_extcommunity_list_arg_cmd, | |
6147e2c6 | 12917 | "show ip extcommunity-list <(1-500)|WORD>", |
718e3744 | 12918 | SHOW_STR |
12919 | IP_STR | |
12920 | "List extended-community list\n" | |
12921 | "Extcommunity-list number\n" | |
12922 | "Extcommunity-list name\n") | |
12923 | { | |
c500ae40 | 12924 | int idx_comm_list = 3; |
718e3744 | 12925 | struct community_list *list; |
12926 | ||
c500ae40 | 12927 | list = community_list_lookup (bgp_clist, argv[idx_comm_list]->arg, EXTCOMMUNITY_LIST_MASTER); |
718e3744 | 12928 | if (! list) |
12929 | { | |
b729294c | 12930 | vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE); |
718e3744 | 12931 | return CMD_WARNING; |
12932 | } | |
12933 | ||
12934 | extcommunity_list_show (vty, list); | |
12935 | ||
12936 | return CMD_SUCCESS; | |
12937 | } | |
6b0655a2 | 12938 | |
718e3744 | 12939 | /* Return configuration string of community-list entry. */ |
fd79ac91 | 12940 | static const char * |
718e3744 | 12941 | community_list_config_str (struct community_entry *entry) |
12942 | { | |
fd79ac91 | 12943 | const char *str; |
718e3744 | 12944 | |
12945 | if (entry->any) | |
12946 | str = ""; | |
12947 | else | |
12948 | { | |
12949 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
12950 | str = community_str (entry->u.com); | |
12951 | else | |
12952 | str = entry->config; | |
12953 | } | |
12954 | return str; | |
12955 | } | |
12956 | ||
12957 | /* Display community-list and extcommunity-list configuration. */ | |
94f2b392 | 12958 | static int |
718e3744 | 12959 | community_list_config_write (struct vty *vty) |
12960 | { | |
12961 | struct community_list *list; | |
12962 | struct community_entry *entry; | |
12963 | struct community_list_master *cm; | |
12964 | int write = 0; | |
12965 | ||
12966 | /* Community-list. */ | |
fee6e4e4 | 12967 | cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER); |
718e3744 | 12968 | |
12969 | for (list = cm->num.head; list; list = list->next) | |
12970 | for (entry = list->head; entry; entry = entry->next) | |
12971 | { | |
fee6e4e4 | 12972 | vty_out (vty, "ip community-list %s %s %s%s", |
12973 | list->name, community_direct_str (entry->direct), | |
12974 | community_list_config_str (entry), | |
12975 | VTY_NEWLINE); | |
718e3744 | 12976 | write++; |
12977 | } | |
12978 | for (list = cm->str.head; list; list = list->next) | |
12979 | for (entry = list->head; entry; entry = entry->next) | |
12980 | { | |
12981 | vty_out (vty, "ip community-list %s %s %s %s%s", | |
12982 | entry->style == COMMUNITY_LIST_STANDARD | |
12983 | ? "standard" : "expanded", | |
12984 | list->name, community_direct_str (entry->direct), | |
12985 | community_list_config_str (entry), | |
12986 | VTY_NEWLINE); | |
12987 | write++; | |
12988 | } | |
12989 | ||
12990 | /* Extcommunity-list. */ | |
fee6e4e4 | 12991 | cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
718e3744 | 12992 | |
12993 | for (list = cm->num.head; list; list = list->next) | |
12994 | for (entry = list->head; entry; entry = entry->next) | |
12995 | { | |
fee6e4e4 | 12996 | vty_out (vty, "ip extcommunity-list %s %s %s%s", |
12997 | list->name, community_direct_str (entry->direct), | |
12998 | community_list_config_str (entry), VTY_NEWLINE); | |
718e3744 | 12999 | write++; |
13000 | } | |
13001 | for (list = cm->str.head; list; list = list->next) | |
13002 | for (entry = list->head; entry; entry = entry->next) | |
13003 | { | |
13004 | vty_out (vty, "ip extcommunity-list %s %s %s %s%s", | |
13005 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
13006 | ? "standard" : "expanded", | |
13007 | list->name, community_direct_str (entry->direct), | |
13008 | community_list_config_str (entry), VTY_NEWLINE); | |
13009 | write++; | |
13010 | } | |
57d187bc JS |
13011 | |
13012 | ||
13013 | /* lcommunity-list. */ | |
13014 | cm = community_list_master_lookup (bgp_clist, LARGE_COMMUNITY_LIST_MASTER); | |
13015 | ||
13016 | for (list = cm->num.head; list; list = list->next) | |
13017 | for (entry = list->head; entry; entry = entry->next) | |
13018 | { | |
2acb4ac2 DL |
13019 | vty_out (vty, "ip large-community-list %s %s %s%s", |
13020 | list->name, community_direct_str (entry->direct), | |
13021 | community_list_config_str (entry), VTY_NEWLINE); | |
13022 | write++; | |
57d187bc JS |
13023 | } |
13024 | for (list = cm->str.head; list; list = list->next) | |
13025 | for (entry = list->head; entry; entry = entry->next) | |
13026 | { | |
2acb4ac2 DL |
13027 | vty_out (vty, "ip large-community-list %s %s %s %s%s", |
13028 | entry->style == LARGE_COMMUNITY_LIST_STANDARD | |
13029 | ? "standard" : "expanded", | |
13030 | list->name, community_direct_str (entry->direct), | |
13031 | community_list_config_str (entry), VTY_NEWLINE); | |
13032 | write++; | |
57d187bc JS |
13033 | } |
13034 | ||
718e3744 | 13035 | return write; |
13036 | } | |
13037 | ||
7fc626de | 13038 | static struct cmd_node community_list_node = |
718e3744 | 13039 | { |
13040 | COMMUNITY_LIST_NODE, | |
13041 | "", | |
13042 | 1 /* Export to vtysh. */ | |
13043 | }; | |
13044 | ||
94f2b392 | 13045 | static void |
13046 | community_list_vty (void) | |
718e3744 | 13047 | { |
13048 | install_node (&community_list_node, community_list_config_write); | |
13049 | ||
13050 | /* Community-list. */ | |
718e3744 | 13051 | install_element (CONFIG_NODE, &ip_community_list_standard_cmd); |
d7d73ffc | 13052 | install_element (CONFIG_NODE, &ip_community_list_expanded_all_cmd); |
fee6e4e4 | 13053 | install_element (CONFIG_NODE, &no_ip_community_list_standard_all_cmd); |
13054 | install_element (CONFIG_NODE, &no_ip_community_list_expanded_all_cmd); | |
718e3744 | 13055 | install_element (VIEW_NODE, &show_ip_community_list_cmd); |
13056 | install_element (VIEW_NODE, &show_ip_community_list_arg_cmd); | |
718e3744 | 13057 | |
13058 | /* Extcommunity-list. */ | |
13059 | install_element (CONFIG_NODE, &ip_extcommunity_list_standard_cmd); | |
718e3744 | 13060 | install_element (CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd); |
fee6e4e4 | 13061 | install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd); |
13062 | install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd); | |
718e3744 | 13063 | install_element (VIEW_NODE, &show_ip_extcommunity_list_cmd); |
13064 | install_element (VIEW_NODE, &show_ip_extcommunity_list_arg_cmd); | |
57d187bc JS |
13065 | |
13066 | /* Large Community List */ | |
13067 | install_element (CONFIG_NODE, &ip_lcommunity_list_standard_cmd); | |
52951b63 | 13068 | install_element (CONFIG_NODE, &ip_lcommunity_list_standard1_cmd); |
57d187bc JS |
13069 | install_element (CONFIG_NODE, &ip_lcommunity_list_expanded_cmd); |
13070 | install_element (CONFIG_NODE, &ip_lcommunity_list_name_standard_cmd); | |
52951b63 | 13071 | install_element (CONFIG_NODE, &ip_lcommunity_list_name_standard1_cmd); |
57d187bc JS |
13072 | install_element (CONFIG_NODE, &ip_lcommunity_list_name_expanded_cmd); |
13073 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_standard_all_cmd); | |
13074 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_all_cmd); | |
13075 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_standard_cmd); | |
13076 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_expanded_cmd); | |
13077 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_name_standard_cmd); | |
13078 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_cmd); | |
13079 | install_element (VIEW_NODE, &show_ip_lcommunity_list_cmd); | |
13080 | install_element (VIEW_NODE, &show_ip_lcommunity_list_arg_cmd); | |
5bf15956 | 13081 | } |