]>
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; | |
f51bae9c DS |
84 | } |
85 | break; | |
86 | case AFI_IP6: | |
87 | switch (safi) | |
88 | { | |
89 | case SAFI_UNICAST: | |
90 | return BGP_IPV6_NODE; | |
91 | break; | |
92 | case SAFI_MULTICAST: | |
93 | return BGP_IPV6M_NODE; | |
94 | break; | |
95 | case SAFI_LABELED_UNICAST: | |
96 | return BGP_IPV6L_NODE; | |
97 | break; | |
98 | case SAFI_MPLS_VPN: | |
99 | return BGP_VPNV6_NODE; | |
100 | break; | |
f51bae9c DS |
101 | } |
102 | break; | |
b3b3879c DS |
103 | case AFI_L2VPN: |
104 | return BGP_EVPN_NODE; | |
105 | break; | |
106 | case AFI_MAX: | |
107 | // We should never be here but to clarify the switch statement.. | |
108 | return BGP_IPV4_NODE; | |
f51bae9c DS |
109 | break; |
110 | } | |
b3b3879c DS |
111 | |
112 | // Impossible to happen | |
113 | return BGP_IPV4_NODE; | |
f51bae9c | 114 | } |
20eb8864 | 115 | |
718e3744 | 116 | /* Utility function to get address family from current node. */ |
117 | afi_t | |
118 | bgp_node_afi (struct vty *vty) | |
119 | { | |
4e851f1f LB |
120 | afi_t afi; |
121 | switch (vty->node) | |
122 | { | |
123 | case BGP_IPV6_NODE: | |
124 | case BGP_IPV6M_NODE: | |
f51bae9c | 125 | case BGP_IPV6L_NODE: |
4e851f1f | 126 | case BGP_VPNV6_NODE: |
4e851f1f LB |
127 | afi = AFI_IP6; |
128 | break; | |
4e0b7b6d PG |
129 | case BGP_EVPN_NODE: |
130 | afi = AFI_L2VPN; | |
131 | break; | |
4e851f1f LB |
132 | default: |
133 | afi = AFI_IP; | |
134 | break; | |
135 | } | |
136 | return afi; | |
718e3744 | 137 | } |
138 | ||
139 | /* Utility function to get subsequent address family from current | |
140 | node. */ | |
141 | safi_t | |
142 | bgp_node_safi (struct vty *vty) | |
143 | { | |
4e851f1f LB |
144 | safi_t safi; |
145 | switch (vty->node) | |
146 | { | |
4e851f1f LB |
147 | case BGP_VPNV4_NODE: |
148 | case BGP_VPNV6_NODE: | |
149 | safi = SAFI_MPLS_VPN; | |
150 | break; | |
151 | case BGP_IPV4M_NODE: | |
152 | case BGP_IPV6M_NODE: | |
153 | safi = SAFI_MULTICAST; | |
154 | break; | |
4e0b7b6d PG |
155 | case BGP_EVPN_NODE: |
156 | safi = SAFI_EVPN; | |
157 | break; | |
f51bae9c DS |
158 | case BGP_IPV4L_NODE: |
159 | case BGP_IPV6L_NODE: | |
160 | safi = SAFI_LABELED_UNICAST; | |
161 | break; | |
4e851f1f LB |
162 | default: |
163 | safi = SAFI_UNICAST; | |
164 | break; | |
165 | } | |
166 | return safi; | |
718e3744 | 167 | } |
168 | ||
46f296b4 LB |
169 | /* supports <ipv4|ipv6> */ |
170 | afi_t | |
171 | bgp_vty_afi_from_arg(const char *afi_str) | |
8b1fb8be | 172 | { |
46f296b4 LB |
173 | afi_t afi = AFI_MAX; /* unknown */ |
174 | if (!strcmp(afi_str, "ipv4")) { | |
175 | afi = AFI_IP; | |
8b1fb8be | 176 | } |
46f296b4 LB |
177 | else if (!strcmp(afi_str, "ipv6")) { |
178 | afi = AFI_IP6; | |
179 | } | |
4e0b7b6d PG |
180 | else if (!strcmp(afi_str, "l2vpn")) { |
181 | afi = AFI_L2VPN; | |
182 | } | |
46f296b4 LB |
183 | return afi; |
184 | } | |
185 | ||
186 | int | |
187 | bgp_parse_afi(const char *str, afi_t *afi) | |
188 | { | |
189 | *afi = bgp_vty_afi_from_arg(str); | |
190 | if (*afi != AFI_MAX) | |
191 | return 0; | |
192 | else | |
8b1fb8be LB |
193 | return -1; |
194 | } | |
195 | ||
46f296b4 LB |
196 | int |
197 | argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, afi_t *afi) | |
198 | { | |
199 | int ret = 0; | |
200 | if (argv_find (argv, argc, "ipv4", index)) | |
201 | { | |
202 | ret = 1; | |
203 | if (afi) | |
204 | *afi = AFI_IP; | |
205 | } | |
206 | else if (argv_find (argv, argc, "ipv6", index)) | |
207 | { | |
208 | ret = 1; | |
209 | if (afi) | |
210 | *afi = AFI_IP6; | |
211 | } | |
212 | return ret; | |
213 | } | |
214 | ||
375a2e67 | 215 | /* supports <unicast|multicast|vpn|labeled-unicast> */ |
ccbb332a | 216 | safi_t |
3b14d86e | 217 | bgp_vty_safi_from_arg(const char *safi_str) |
ccbb332a LB |
218 | { |
219 | safi_t safi = SAFI_MAX; /* unknown */ | |
220 | if (strncmp (safi_str, "m", 1) == 0) | |
221 | safi = SAFI_MULTICAST; | |
222 | else if (strncmp (safi_str, "u", 1) == 0) | |
223 | safi = SAFI_UNICAST; | |
ccbb332a | 224 | else if (strncmp (safi_str, "v", 1) == 0) |
46f296b4 | 225 | safi = SAFI_MPLS_VPN; |
f51bae9c DS |
226 | else if (strncmp (safi_str, "l", 1) == 0) |
227 | safi = SAFI_LABELED_UNICAST; | |
ccbb332a LB |
228 | return safi; |
229 | } | |
230 | ||
8b1fb8be | 231 | int |
3289141f | 232 | argv_find_and_parse_safi (struct cmd_token **argv, int argc, int *index, safi_t *safi) |
46f296b4 LB |
233 | { |
234 | int ret = 0; | |
235 | if (argv_find (argv, argc, "unicast", index)) | |
236 | { | |
237 | ret = 1; | |
238 | if (safi) | |
239 | *safi = SAFI_UNICAST; | |
240 | } | |
241 | else if (argv_find (argv, argc, "multicast", index)) | |
242 | { | |
243 | ret = 1; | |
244 | if (safi) | |
245 | *safi = SAFI_MULTICAST; | |
246 | } | |
b60f5275 DS |
247 | else if (argv_find (argv, argc, "labeled-unicast", index)) |
248 | { | |
249 | ret = 1; | |
250 | if (safi) | |
251 | *safi = SAFI_LABELED_UNICAST; | |
252 | } | |
46f296b4 LB |
253 | else if (argv_find (argv, argc, "vpn", index)) |
254 | { | |
255 | ret = 1; | |
256 | if (safi) | |
257 | *safi = SAFI_MPLS_VPN; | |
258 | } | |
4e0b7b6d PG |
259 | else if (argv_find (argv, argc, "evpn", index)) |
260 | { | |
261 | ret = 1; | |
262 | if (safi) | |
263 | *safi = SAFI_EVPN; | |
264 | } | |
46f296b4 LB |
265 | return ret; |
266 | } | |
267 | ||
7eeee51e | 268 | /* |
f212a857 | 269 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 270 | * |
f212a857 DS |
271 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
272 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
273 | * to appropriate values for the calling function. This is to allow the |
274 | * calling function to make decisions appropriate for the show command | |
275 | * that is being parsed. | |
276 | * | |
277 | * The show commands are generally of the form: | |
18c57037 | 278 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] ..." |
7eeee51e DS |
279 | * |
280 | * Since we use argv_find if the show command in particular doesn't have: | |
281 | * [ip] | |
18c57037 | 282 | * [<view|vrf> VIEWVRFNAME] |
375a2e67 | 283 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] |
7eeee51e DS |
284 | * The command parsing should still be ok. |
285 | * | |
286 | * vty -> The vty for the command so we can output some useful data in | |
287 | * the event of a parse error in the vrf. | |
288 | * argv -> The command tokens | |
289 | * argc -> How many command tokens we have | |
290 | * idx -> The current place in the command, generally should be 0 for this function | |
291 | * afi -> The parsed afi if it was included in the show command, returned here | |
292 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 293 | * bgp -> Pointer to the bgp data structure we need to fill in. |
7eeee51e DS |
294 | * |
295 | * The function returns the correct location in the parse tree for the | |
296 | * last token found. | |
0e37c258 DS |
297 | * |
298 | * Returns 0 for failure to parse correctly, else the idx position of where | |
299 | * it found the last token. | |
7eeee51e | 300 | */ |
af462945 | 301 | int |
f212a857 DS |
302 | bgp_vty_find_and_parse_afi_safi_bgp (struct vty *vty, struct cmd_token **argv, int argc, int *idx, |
303 | afi_t *afi, safi_t *safi, struct bgp **bgp) | |
af462945 DS |
304 | { |
305 | char *vrf_name = NULL; | |
306 | ||
b4898a38 DS |
307 | assert (afi); |
308 | assert (safi); | |
f212a857 | 309 | assert (bgp); |
b4898a38 | 310 | |
9317e17d | 311 | if (argv_find (argv, argc, "ip", idx)) |
af462945 DS |
312 | *afi = AFI_IP; |
313 | ||
9317e17d | 314 | if (argv_find (argv, argc, "view", idx) || argv_find (argv, argc, "vrf", idx)) |
af462945 | 315 | { |
9317e17d | 316 | vrf_name = argv[*idx + 1]->arg; |
af462945 | 317 | |
f212a857 DS |
318 | if (strmatch (vrf_name, "all")) |
319 | *bgp = NULL; | |
af462945 | 320 | else |
f212a857 DS |
321 | { |
322 | *bgp = bgp_lookup_by_name (vrf_name); | |
323 | if (!*bgp) | |
324 | { | |
325 | vty_out (vty, "View/Vrf specified is unknown: %s%s", vrf_name, VTY_NEWLINE); | |
326 | *idx = 0; | |
327 | return 0; | |
328 | } | |
329 | } | |
af462945 | 330 | } |
f212a857 | 331 | else |
af462945 | 332 | { |
f212a857 DS |
333 | *bgp = bgp_get_default (); |
334 | if (!*bgp) | |
335 | { | |
336 | vty_out (vty, "Unable to find default BGP instance%s", VTY_NEWLINE); | |
337 | *idx = 0; | |
338 | return 0; | |
339 | } | |
af462945 | 340 | } |
9317e17d | 341 | |
f212a857 DS |
342 | if (argv_find_and_parse_afi (argv, argc, idx, afi)) |
343 | argv_find_and_parse_safi (argv, argc, idx, safi); | |
344 | ||
9317e17d DS |
345 | *idx += 1; |
346 | return *idx; | |
af462945 DS |
347 | } |
348 | ||
94f2b392 | 349 | static int |
6aeb9e78 | 350 | peer_address_self_check (struct bgp *bgp, union sockunion *su) |
718e3744 | 351 | { |
352 | struct interface *ifp = NULL; | |
353 | ||
354 | if (su->sa.sa_family == AF_INET) | |
6aeb9e78 | 355 | ifp = if_lookup_by_ipv4_exact (&su->sin.sin_addr, bgp->vrf_id); |
718e3744 | 356 | else if (su->sa.sa_family == AF_INET6) |
f2345335 | 357 | ifp = if_lookup_by_ipv6_exact (&su->sin6.sin6_addr, |
6aeb9e78 | 358 | su->sin6.sin6_scope_id, bgp->vrf_id); |
718e3744 | 359 | |
360 | if (ifp) | |
361 | return 1; | |
362 | ||
363 | return 0; | |
364 | } | |
365 | ||
366 | /* Utility function for looking up peer from VTY. */ | |
f14e6fdb DS |
367 | /* This is used only for configuration, so disallow if attempted on |
368 | * a dynamic neighbor. | |
369 | */ | |
94f2b392 | 370 | static struct peer * |
fd79ac91 | 371 | peer_lookup_vty (struct vty *vty, const char *ip_str) |
718e3744 | 372 | { |
cdc2d765 | 373 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); |
718e3744 | 374 | int ret; |
718e3744 | 375 | union sockunion su; |
376 | struct peer *peer; | |
377 | ||
cdc2d765 DL |
378 | if (!bgp) { |
379 | return NULL; | |
380 | } | |
718e3744 | 381 | |
382 | ret = str2sockunion (ip_str, &su); | |
383 | if (ret < 0) | |
384 | { | |
a80beece DS |
385 | peer = peer_lookup_by_conf_if (bgp, ip_str); |
386 | if (!peer) | |
387 | { | |
04b6bdc0 DW |
388 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) == NULL) |
389 | { | |
390 | vty_out (vty, "%% Malformed address or name: %s%s", ip_str, VTY_NEWLINE); | |
391 | return NULL; | |
392 | } | |
a80beece | 393 | } |
718e3744 | 394 | } |
a80beece | 395 | else |
718e3744 | 396 | { |
a80beece DS |
397 | peer = peer_lookup (bgp, &su); |
398 | if (! peer) | |
399 | { | |
400 | vty_out (vty, "%% Specify remote-as or peer-group commands first%s", | |
401 | VTY_NEWLINE); | |
402 | return NULL; | |
403 | } | |
f14e6fdb DS |
404 | if (peer_dynamic_neighbor (peer)) |
405 | { | |
406 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
407 | VTY_NEWLINE); | |
408 | return NULL; | |
409 | } | |
410 | ||
718e3744 | 411 | } |
412 | return peer; | |
413 | } | |
414 | ||
415 | /* Utility function for looking up peer or peer group. */ | |
f14e6fdb DS |
416 | /* This is used only for configuration, so disallow if attempted on |
417 | * a dynamic neighbor. | |
418 | */ | |
c43ed2e4 | 419 | struct peer * |
fd79ac91 | 420 | peer_and_group_lookup_vty (struct vty *vty, const char *peer_str) |
718e3744 | 421 | { |
cdc2d765 | 422 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); |
718e3744 | 423 | int ret; |
718e3744 | 424 | union sockunion su; |
f14e6fdb DS |
425 | struct peer *peer = NULL; |
426 | struct peer_group *group = NULL; | |
718e3744 | 427 | |
cdc2d765 DL |
428 | if (!bgp) { |
429 | return NULL; | |
430 | } | |
718e3744 | 431 | |
432 | ret = str2sockunion (peer_str, &su); | |
433 | if (ret == 0) | |
434 | { | |
f14e6fdb | 435 | /* IP address, locate peer. */ |
718e3744 | 436 | peer = peer_lookup (bgp, &su); |
718e3744 | 437 | } |
438 | else | |
439 | { | |
f14e6fdb | 440 | /* Not IP, could match either peer configured on interface or a group. */ |
a80beece | 441 | peer = peer_lookup_by_conf_if (bgp, peer_str); |
f14e6fdb DS |
442 | if (!peer) |
443 | group = peer_group_lookup (bgp, peer_str); | |
444 | } | |
a80beece | 445 | |
f14e6fdb DS |
446 | if (peer) |
447 | { | |
448 | if (peer_dynamic_neighbor (peer)) | |
449 | { | |
450 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
451 | VTY_NEWLINE); | |
452 | return NULL; | |
453 | } | |
454 | ||
455 | return peer; | |
718e3744 | 456 | } |
457 | ||
f14e6fdb DS |
458 | if (group) |
459 | return group->conf; | |
460 | ||
718e3744 | 461 | vty_out (vty, "%% Specify remote-as or peer-group commands first%s", |
462 | VTY_NEWLINE); | |
463 | ||
464 | return NULL; | |
465 | } | |
466 | ||
c43ed2e4 | 467 | int |
718e3744 | 468 | bgp_vty_return (struct vty *vty, int ret) |
469 | { | |
fd79ac91 | 470 | const char *str = NULL; |
718e3744 | 471 | |
472 | switch (ret) | |
473 | { | |
474 | case BGP_ERR_INVALID_VALUE: | |
475 | str = "Invalid value"; | |
476 | break; | |
477 | case BGP_ERR_INVALID_FLAG: | |
478 | str = "Invalid flag"; | |
479 | break; | |
718e3744 | 480 | case BGP_ERR_PEER_GROUP_SHUTDOWN: |
481 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
482 | break; | |
718e3744 | 483 | case BGP_ERR_PEER_FLAG_CONFLICT: |
484 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
485 | break; | |
718e3744 | 486 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: |
487 | str = "Specify remote-as or peer-group remote AS first"; | |
488 | break; | |
489 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
490 | str = "Cannot change the peer-group. Deconfigure first"; | |
491 | break; | |
492 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
4c48cf63 | 493 | str = "Peer is not a member of this peer-group"; |
718e3744 | 494 | break; |
495 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
496 | str = "Prefix/distribute list can not co-exist"; | |
497 | break; | |
498 | case BGP_ERR_NOT_INTERNAL_PEER: | |
499 | str = "Invalid command. Not an internal neighbor"; | |
500 | break; | |
501 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
5000f21c | 502 | str = "remove-private-AS cannot be configured for IBGP peers"; |
718e3744 | 503 | break; |
504 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
505 | str = "Local-AS allowed only for EBGP peers"; | |
506 | break; | |
507 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
508 | str = "Cannot have local-as same as BGP AS number"; | |
509 | break; | |
0df7c91f PJ |
510 | case BGP_ERR_TCPSIG_FAILED: |
511 | str = "Error while applying TCP-Sig to session(s)"; | |
512 | break; | |
fa411a21 NH |
513 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: |
514 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
515 | break; | |
f5a4827d SH |
516 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: |
517 | str = "ttl-security only allowed for EBGP peers"; | |
518 | break; | |
c7122e14 DS |
519 | case BGP_ERR_AS_OVERRIDE: |
520 | str = "as-override cannot be configured for IBGP peers"; | |
521 | break; | |
f14e6fdb DS |
522 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: |
523 | str = "Invalid limit for number of dynamic neighbors"; | |
524 | break; | |
525 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
526 | str = "Dynamic neighbor listen range already exists"; | |
527 | break; | |
528 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
529 | str = "Operation not allowed on a dynamic neighbor"; | |
530 | break; | |
63fa10b5 QY |
531 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: |
532 | str = "Operation not allowed on a directly connected neighbor"; | |
533 | break; | |
718e3744 | 534 | } |
535 | if (str) | |
536 | { | |
537 | vty_out (vty, "%% %s%s", str, VTY_NEWLINE); | |
538 | return CMD_WARNING; | |
539 | } | |
540 | return CMD_SUCCESS; | |
541 | } | |
542 | ||
7aafcaca DS |
543 | /* BGP clear sort. */ |
544 | enum clear_sort | |
545 | { | |
546 | clear_all, | |
547 | clear_peer, | |
548 | clear_group, | |
549 | clear_external, | |
550 | clear_as | |
551 | }; | |
552 | ||
7aafcaca DS |
553 | static void |
554 | bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi, | |
555 | safi_t safi, int error) | |
556 | { | |
557 | switch (error) | |
558 | { | |
559 | case BGP_ERR_AF_UNCONFIGURED: | |
560 | vty_out (vty, | |
46f296b4 LB |
561 | "%%BGP: Enable %s address family for the neighbor %s%s", |
562 | afi_safi_print(afi, safi), peer->host, VTY_NEWLINE); | |
7aafcaca DS |
563 | break; |
564 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
565 | 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); | |
566 | break; | |
567 | default: | |
568 | break; | |
569 | } | |
570 | } | |
571 | ||
572 | /* `clear ip bgp' functions. */ | |
573 | static int | |
574 | bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, | |
575 | enum clear_sort sort,enum bgp_clear_type stype, const char *arg) | |
576 | { | |
577 | int ret; | |
578 | struct peer *peer; | |
579 | struct listnode *node, *nnode; | |
580 | ||
581 | /* Clear all neighbors. */ | |
582 | /* | |
583 | * Pass along pointer to next node to peer_clear() when walking all nodes | |
584 | * on the BGP instance as that may get freed if it is a doppelganger | |
585 | */ | |
586 | if (sort == clear_all) | |
587 | { | |
588 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
589 | { | |
590 | if (stype == BGP_CLEAR_SOFT_NONE) | |
591 | ret = peer_clear (peer, &nnode); | |
592 | else if (peer->afc[afi][safi]) | |
593 | ret = peer_clear_soft (peer, afi, safi, stype); | |
594 | else | |
595 | ret = 0; | |
596 | ||
597 | if (ret < 0) | |
598 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
599 | } | |
600 | ||
601 | /* This is to apply read-only mode on this clear. */ | |
602 | if (stype == BGP_CLEAR_SOFT_NONE) | |
603 | bgp->update_delay_over = 0; | |
604 | ||
605 | return CMD_SUCCESS; | |
606 | } | |
607 | ||
608 | /* Clear specified neighbors. */ | |
609 | if (sort == clear_peer) | |
610 | { | |
611 | union sockunion su; | |
612 | int ret; | |
613 | ||
614 | /* Make sockunion for lookup. */ | |
615 | ret = str2sockunion (arg, &su); | |
616 | if (ret < 0) | |
617 | { | |
618 | peer = peer_lookup_by_conf_if (bgp, arg); | |
619 | if (!peer) | |
620 | { | |
04b6bdc0 DW |
621 | peer = peer_lookup_by_hostname(bgp, arg); |
622 | if (!peer) | |
623 | { | |
624 | vty_out (vty, "Malformed address or name: %s%s", arg, VTY_NEWLINE); | |
625 | return CMD_WARNING; | |
626 | } | |
7aafcaca DS |
627 | } |
628 | } | |
629 | else | |
630 | { | |
631 | peer = peer_lookup (bgp, &su); | |
632 | if (! peer) | |
633 | { | |
634 | vty_out (vty, "%%BGP: Unknown neighbor - \"%s\"%s", arg, VTY_NEWLINE); | |
635 | return CMD_WARNING; | |
636 | } | |
637 | } | |
638 | ||
639 | if (stype == BGP_CLEAR_SOFT_NONE) | |
640 | ret = peer_clear (peer, NULL); | |
641 | else | |
642 | ret = peer_clear_soft (peer, afi, safi, stype); | |
643 | ||
644 | if (ret < 0) | |
645 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
646 | ||
647 | return CMD_SUCCESS; | |
648 | } | |
649 | ||
650 | /* Clear all peer-group members. */ | |
651 | if (sort == clear_group) | |
652 | { | |
653 | struct peer_group *group; | |
654 | ||
655 | group = peer_group_lookup (bgp, arg); | |
656 | if (! group) | |
657 | { | |
658 | vty_out (vty, "%%BGP: No such peer-group %s%s", arg, VTY_NEWLINE); | |
659 | return CMD_WARNING; | |
660 | } | |
661 | ||
662 | for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) | |
663 | { | |
664 | if (stype == BGP_CLEAR_SOFT_NONE) | |
665 | { | |
18f1dc06 | 666 | peer_clear (peer, NULL); |
7aafcaca DS |
667 | continue; |
668 | } | |
669 | ||
c8560b44 | 670 | if (! peer->afc[afi][safi]) |
7aafcaca DS |
671 | continue; |
672 | ||
673 | ret = peer_clear_soft (peer, afi, safi, stype); | |
674 | ||
675 | if (ret < 0) | |
676 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
677 | } | |
678 | return CMD_SUCCESS; | |
679 | } | |
680 | ||
681 | if (sort == clear_external) | |
682 | { | |
683 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
684 | { | |
685 | if (peer->sort == BGP_PEER_IBGP) | |
686 | continue; | |
687 | ||
688 | if (stype == BGP_CLEAR_SOFT_NONE) | |
689 | ret = peer_clear (peer, &nnode); | |
690 | else | |
691 | ret = peer_clear_soft (peer, afi, safi, stype); | |
692 | ||
693 | if (ret < 0) | |
694 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
695 | } | |
696 | return CMD_SUCCESS; | |
697 | } | |
698 | ||
699 | if (sort == clear_as) | |
700 | { | |
701 | as_t as; | |
702 | int find = 0; | |
703 | ||
704 | VTY_GET_INTEGER_RANGE ("AS", as, arg, 1, BGP_AS4_MAX); | |
705 | ||
706 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
707 | { | |
708 | if (peer->as != as) | |
709 | continue; | |
710 | ||
711 | find = 1; | |
712 | if (stype == BGP_CLEAR_SOFT_NONE) | |
713 | ret = peer_clear (peer, &nnode); | |
714 | else | |
715 | ret = peer_clear_soft (peer, afi, safi, stype); | |
716 | ||
717 | if (ret < 0) | |
718 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
719 | } | |
720 | if (! find) | |
721 | vty_out (vty, "%%BGP: No peer is configured with AS %s%s", arg, | |
722 | VTY_NEWLINE); | |
723 | return CMD_SUCCESS; | |
724 | } | |
725 | ||
726 | return CMD_SUCCESS; | |
727 | } | |
728 | ||
729 | static int | |
730 | bgp_clear_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi, | |
731 | enum clear_sort sort, enum bgp_clear_type stype, | |
732 | const char *arg) | |
733 | { | |
734 | struct bgp *bgp; | |
735 | ||
736 | /* BGP structure lookup. */ | |
737 | if (name) | |
738 | { | |
739 | bgp = bgp_lookup_by_name (name); | |
740 | if (bgp == NULL) | |
741 | { | |
6aeb9e78 | 742 | vty_out (vty, "Can't find BGP instance %s%s", name, VTY_NEWLINE); |
7aafcaca DS |
743 | return CMD_WARNING; |
744 | } | |
745 | } | |
746 | else | |
747 | { | |
f31fa004 | 748 | bgp = bgp_get_default (); |
7aafcaca DS |
749 | if (bgp == NULL) |
750 | { | |
751 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
752 | return CMD_WARNING; | |
753 | } | |
754 | } | |
755 | ||
756 | return bgp_clear (vty, bgp, afi, safi, sort, stype, arg); | |
757 | } | |
758 | ||
759 | /* clear soft inbound */ | |
760 | static void | |
f31fa004 | 761 | bgp_clear_star_soft_in (struct vty *vty, const char *name) |
7aafcaca | 762 | { |
b09b5ae0 | 763 | bgp_clear_vty (vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
7aafcaca | 764 | BGP_CLEAR_SOFT_IN, NULL); |
f31fa004 | 765 | bgp_clear_vty (vty, name, AFI_IP6, SAFI_UNICAST, clear_all, |
7aafcaca | 766 | BGP_CLEAR_SOFT_IN, NULL); |
7aafcaca DS |
767 | } |
768 | ||
769 | /* clear soft outbound */ | |
770 | static void | |
f31fa004 | 771 | bgp_clear_star_soft_out (struct vty *vty, const char *name) |
7aafcaca | 772 | { |
f31fa004 | 773 | bgp_clear_vty (vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
7aafcaca | 774 | BGP_CLEAR_SOFT_OUT, NULL); |
f31fa004 | 775 | bgp_clear_vty (vty, name, AFI_IP6, SAFI_UNICAST, clear_all, |
7aafcaca | 776 | BGP_CLEAR_SOFT_OUT, NULL); |
7aafcaca DS |
777 | } |
778 | ||
779 | ||
718e3744 | 780 | /* BGP global configuration. */ |
781 | ||
782 | DEFUN (bgp_multiple_instance_func, | |
783 | bgp_multiple_instance_cmd, | |
784 | "bgp multiple-instance", | |
785 | BGP_STR | |
786 | "Enable bgp multiple instance\n") | |
787 | { | |
788 | bgp_option_set (BGP_OPT_MULTIPLE_INSTANCE); | |
789 | return CMD_SUCCESS; | |
790 | } | |
791 | ||
792 | DEFUN (no_bgp_multiple_instance, | |
793 | no_bgp_multiple_instance_cmd, | |
794 | "no bgp multiple-instance", | |
795 | NO_STR | |
796 | BGP_STR | |
797 | "BGP multiple instance\n") | |
798 | { | |
799 | int ret; | |
800 | ||
801 | ret = bgp_option_unset (BGP_OPT_MULTIPLE_INSTANCE); | |
802 | if (ret < 0) | |
803 | { | |
804 | vty_out (vty, "%% There are more than two BGP instances%s", VTY_NEWLINE); | |
805 | return CMD_WARNING; | |
806 | } | |
807 | return CMD_SUCCESS; | |
808 | } | |
809 | ||
810 | DEFUN (bgp_config_type, | |
811 | bgp_config_type_cmd, | |
6147e2c6 | 812 | "bgp config-type <cisco|zebra>", |
718e3744 | 813 | BGP_STR |
814 | "Configuration type\n" | |
815 | "cisco\n" | |
816 | "zebra\n") | |
817 | { | |
c500ae40 DW |
818 | int idx_vendor = 2; |
819 | if (strncmp (argv[idx_vendor]->arg, "c", 1) == 0) | |
718e3744 | 820 | bgp_option_set (BGP_OPT_CONFIG_CISCO); |
821 | else | |
822 | bgp_option_unset (BGP_OPT_CONFIG_CISCO); | |
823 | ||
824 | return CMD_SUCCESS; | |
825 | } | |
826 | ||
827 | DEFUN (no_bgp_config_type, | |
828 | no_bgp_config_type_cmd, | |
c7178fe7 | 829 | "no bgp config-type [<cisco|zebra>]", |
718e3744 | 830 | NO_STR |
831 | BGP_STR | |
838758ac DW |
832 | "Display configuration type\n" |
833 | "cisco\n" | |
834 | "zebra\n") | |
718e3744 | 835 | { |
836 | bgp_option_unset (BGP_OPT_CONFIG_CISCO); | |
837 | return CMD_SUCCESS; | |
838 | } | |
839 | ||
813d4307 | 840 | |
718e3744 | 841 | DEFUN (no_synchronization, |
842 | no_synchronization_cmd, | |
843 | "no synchronization", | |
844 | NO_STR | |
845 | "Perform IGP synchronization\n") | |
846 | { | |
847 | return CMD_SUCCESS; | |
848 | } | |
849 | ||
850 | DEFUN (no_auto_summary, | |
851 | no_auto_summary_cmd, | |
852 | "no auto-summary", | |
853 | NO_STR | |
854 | "Enable automatic network number summarization\n") | |
855 | { | |
856 | return CMD_SUCCESS; | |
857 | } | |
3d515fd9 | 858 | |
718e3744 | 859 | /* "router bgp" commands. */ |
505e5056 | 860 | DEFUN_NOSH (router_bgp, |
f412b39a | 861 | router_bgp_cmd, |
18c57037 | 862 | "router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 863 | ROUTER_STR |
864 | BGP_STR | |
31500417 DW |
865 | AS_STR |
866 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 867 | { |
31500417 DW |
868 | int idx_asn = 2; |
869 | int idx_view_vrf = 3; | |
870 | int idx_vrf = 4; | |
718e3744 | 871 | int ret; |
872 | as_t as; | |
873 | struct bgp *bgp; | |
fd79ac91 | 874 | const char *name = NULL; |
ad4cbda1 | 875 | enum bgp_instance_type inst_type; |
718e3744 | 876 | |
2385a876 | 877 | // "router bgp" without an ASN |
31500417 | 878 | if (argc == 2) |
2385a876 | 879 | { |
6aeb9e78 | 880 | //Pending: Make VRF option available for ASN less config |
2385a876 | 881 | bgp = bgp_get_default(); |
718e3744 | 882 | |
2385a876 DW |
883 | if (bgp == NULL) |
884 | { | |
885 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
886 | return CMD_WARNING; | |
887 | } | |
718e3744 | 888 | |
2385a876 DW |
889 | if (listcount(bm->bgp) > 1) |
890 | { | |
891 | vty_out (vty, "%% Multiple BGP processes are configured%s", VTY_NEWLINE); | |
892 | return CMD_WARNING; | |
893 | } | |
894 | } | |
895 | ||
896 | // "router bgp X" | |
897 | else | |
718e3744 | 898 | { |
31500417 | 899 | VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_asn]->arg, 1, BGP_AS4_MAX); |
2385a876 | 900 | |
ad4cbda1 | 901 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; |
31500417 | 902 | if (argc > 3) |
ad4cbda1 | 903 | { |
31500417 DW |
904 | name = argv[idx_vrf]->arg; |
905 | ||
e52702f2 | 906 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) |
ad4cbda1 | 907 | inst_type = BGP_INSTANCE_TYPE_VRF; |
e52702f2 | 908 | else if (!strcmp(argv[idx_view_vrf]->text, "view")) |
ad4cbda1 | 909 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
910 | } | |
2385a876 | 911 | |
ad4cbda1 | 912 | ret = bgp_get (&bgp, &as, name, inst_type); |
2385a876 DW |
913 | switch (ret) |
914 | { | |
915 | case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET: | |
916 | vty_out (vty, "Please specify 'bgp multiple-instance' first%s", | |
917 | VTY_NEWLINE); | |
918 | return CMD_WARNING; | |
919 | case BGP_ERR_AS_MISMATCH: | |
920 | vty_out (vty, "BGP is already running; AS is %u%s", as, VTY_NEWLINE); | |
921 | return CMD_WARNING; | |
922 | case BGP_ERR_INSTANCE_MISMATCH: | |
6aeb9e78 | 923 | vty_out (vty, "BGP instance name and AS number mismatch%s", VTY_NEWLINE); |
2385a876 DW |
924 | vty_out (vty, "BGP instance is already running; AS is %u%s", |
925 | as, VTY_NEWLINE); | |
926 | return CMD_WARNING; | |
927 | } | |
6aeb9e78 DS |
928 | |
929 | /* Pending: handle when user tries to change a view to vrf n vv. */ | |
718e3744 | 930 | } |
931 | ||
cdc2d765 | 932 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); |
718e3744 | 933 | |
934 | return CMD_SUCCESS; | |
935 | } | |
936 | ||
718e3744 | 937 | /* "no router bgp" commands. */ |
938 | DEFUN (no_router_bgp, | |
939 | no_router_bgp_cmd, | |
18c57037 | 940 | "no router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 941 | NO_STR |
942 | ROUTER_STR | |
943 | BGP_STR | |
31500417 DW |
944 | AS_STR |
945 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 946 | { |
31500417 | 947 | int idx_asn = 3; |
31500417 | 948 | int idx_vrf = 5; |
718e3744 | 949 | as_t as; |
950 | struct bgp *bgp; | |
fd79ac91 | 951 | const char *name = NULL; |
718e3744 | 952 | |
7fb21a9f | 953 | // "no router bgp" without an ASN |
31500417 | 954 | if (argc == 3) |
7fb21a9f QY |
955 | { |
956 | //Pending: Make VRF option available for ASN less config | |
957 | bgp = bgp_get_default(); | |
718e3744 | 958 | |
7fb21a9f QY |
959 | if (bgp == NULL) |
960 | { | |
961 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
962 | return CMD_WARNING; | |
963 | } | |
964 | ||
965 | if (listcount(bm->bgp) > 1) | |
966 | { | |
967 | vty_out (vty, "%% Multiple BGP processes are configured%s", VTY_NEWLINE); | |
968 | return CMD_WARNING; | |
969 | } | |
970 | } | |
971 | else | |
718e3744 | 972 | { |
31500417 | 973 | VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_asn]->arg, 1, BGP_AS4_MAX); |
7fb21a9f | 974 | |
31500417 DW |
975 | if (argc > 4) |
976 | name = argv[idx_vrf]->arg; | |
7fb21a9f QY |
977 | |
978 | /* Lookup bgp structure. */ | |
979 | bgp = bgp_lookup (as, name); | |
980 | if (! bgp) | |
981 | { | |
982 | vty_out (vty, "%% Can't find BGP instance%s", VTY_NEWLINE); | |
983 | return CMD_WARNING; | |
984 | } | |
718e3744 | 985 | } |
986 | ||
987 | bgp_delete (bgp); | |
988 | ||
989 | return CMD_SUCCESS; | |
990 | } | |
991 | ||
6b0655a2 | 992 | |
7fb21a9f | 993 | |
718e3744 | 994 | /* BGP router-id. */ |
995 | ||
996 | DEFUN (bgp_router_id, | |
997 | bgp_router_id_cmd, | |
998 | "bgp router-id A.B.C.D", | |
999 | BGP_STR | |
1000 | "Override configured router identifier\n" | |
1001 | "Manually configured router identifier\n") | |
1002 | { | |
cdc2d765 | 1003 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1004 | int idx_ipv4 = 2; |
718e3744 | 1005 | int ret; |
1006 | struct in_addr id; | |
718e3744 | 1007 | |
c500ae40 | 1008 | ret = inet_aton (argv[idx_ipv4]->arg, &id); |
718e3744 | 1009 | if (! ret) |
1010 | { | |
1011 | vty_out (vty, "%% Malformed bgp router identifier%s", VTY_NEWLINE); | |
1012 | return CMD_WARNING; | |
1013 | } | |
1014 | ||
0e6cb743 | 1015 | bgp_router_id_static_set (bgp, id); |
718e3744 | 1016 | |
1017 | return CMD_SUCCESS; | |
1018 | } | |
1019 | ||
1020 | DEFUN (no_bgp_router_id, | |
1021 | no_bgp_router_id_cmd, | |
31500417 | 1022 | "no bgp router-id [A.B.C.D]", |
718e3744 | 1023 | NO_STR |
1024 | BGP_STR | |
31500417 DW |
1025 | "Override configured router identifier\n" |
1026 | "Manually configured router identifier\n") | |
718e3744 | 1027 | { |
cdc2d765 | 1028 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
31500417 | 1029 | int idx_router_id = 3; |
718e3744 | 1030 | int ret; |
1031 | struct in_addr id; | |
718e3744 | 1032 | |
31500417 | 1033 | if (argc > idx_router_id) |
718e3744 | 1034 | { |
31500417 | 1035 | ret = inet_aton (argv[idx_router_id]->arg, &id); |
718e3744 | 1036 | if (! ret) |
e018c7cc SK |
1037 | { |
1038 | vty_out (vty, "%% Malformed BGP router identifier%s", VTY_NEWLINE); | |
1039 | return CMD_WARNING; | |
1040 | } | |
718e3744 | 1041 | |
18a6dce6 | 1042 | if (! IPV4_ADDR_SAME (&bgp->router_id_static, &id)) |
e018c7cc SK |
1043 | { |
1044 | vty_out (vty, "%% BGP router-id doesn't match%s", VTY_NEWLINE); | |
1045 | return CMD_WARNING; | |
1046 | } | |
718e3744 | 1047 | } |
1048 | ||
0e6cb743 DL |
1049 | id.s_addr = 0; |
1050 | bgp_router_id_static_set (bgp, id); | |
718e3744 | 1051 | |
1052 | return CMD_SUCCESS; | |
1053 | } | |
1054 | ||
6b0655a2 | 1055 | |
718e3744 | 1056 | /* BGP Cluster ID. */ |
718e3744 | 1057 | DEFUN (bgp_cluster_id, |
1058 | bgp_cluster_id_cmd, | |
838758ac | 1059 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", |
718e3744 | 1060 | BGP_STR |
1061 | "Configure Route-Reflector Cluster-id\n" | |
838758ac DW |
1062 | "Route-Reflector Cluster-id in IP address format\n" |
1063 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1064 | { |
cdc2d765 | 1065 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1066 | int idx_ipv4 = 2; |
718e3744 | 1067 | int ret; |
718e3744 | 1068 | struct in_addr cluster; |
1069 | ||
c500ae40 | 1070 | ret = inet_aton (argv[idx_ipv4]->arg, &cluster); |
718e3744 | 1071 | if (! ret) |
1072 | { | |
1073 | vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE); | |
1074 | return CMD_WARNING; | |
1075 | } | |
1076 | ||
1077 | bgp_cluster_id_set (bgp, &cluster); | |
f31fa004 | 1078 | bgp_clear_star_soft_out (vty, bgp->name); |
718e3744 | 1079 | |
1080 | return CMD_SUCCESS; | |
1081 | } | |
1082 | ||
718e3744 | 1083 | DEFUN (no_bgp_cluster_id, |
1084 | no_bgp_cluster_id_cmd, | |
c7178fe7 | 1085 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", |
718e3744 | 1086 | NO_STR |
1087 | BGP_STR | |
838758ac DW |
1088 | "Configure Route-Reflector Cluster-id\n" |
1089 | "Route-Reflector Cluster-id in IP address format\n" | |
1090 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1091 | { |
cdc2d765 | 1092 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1093 | bgp_cluster_id_unset (bgp); |
f31fa004 | 1094 | bgp_clear_star_soft_out (vty, bgp->name); |
718e3744 | 1095 | |
1096 | return CMD_SUCCESS; | |
1097 | } | |
1098 | ||
718e3744 | 1099 | DEFUN (bgp_confederation_identifier, |
1100 | bgp_confederation_identifier_cmd, | |
9ccf14f7 | 1101 | "bgp confederation identifier (1-4294967295)", |
718e3744 | 1102 | "BGP specific commands\n" |
1103 | "AS confederation parameters\n" | |
1104 | "AS number\n" | |
1105 | "Set routing domain confederation AS\n") | |
1106 | { | |
cdc2d765 | 1107 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1108 | int idx_number = 3; |
718e3744 | 1109 | as_t as; |
1110 | ||
c500ae40 | 1111 | VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); |
718e3744 | 1112 | |
1113 | bgp_confederation_id_set (bgp, as); | |
1114 | ||
1115 | return CMD_SUCCESS; | |
1116 | } | |
1117 | ||
1118 | DEFUN (no_bgp_confederation_identifier, | |
1119 | no_bgp_confederation_identifier_cmd, | |
838758ac | 1120 | "no bgp confederation identifier [(1-4294967295)]", |
718e3744 | 1121 | NO_STR |
1122 | "BGP specific commands\n" | |
1123 | "AS confederation parameters\n" | |
3a2d747c QY |
1124 | "AS number\n" |
1125 | "Set routing domain confederation AS\n") | |
718e3744 | 1126 | { |
cdc2d765 | 1127 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1128 | bgp_confederation_id_unset (bgp); |
1129 | ||
1130 | return CMD_SUCCESS; | |
1131 | } | |
1132 | ||
718e3744 | 1133 | DEFUN (bgp_confederation_peers, |
1134 | bgp_confederation_peers_cmd, | |
12dcf78e | 1135 | "bgp confederation peers (1-4294967295)...", |
718e3744 | 1136 | "BGP specific commands\n" |
1137 | "AS confederation parameters\n" | |
1138 | "Peer ASs in BGP confederation\n" | |
1139 | AS_STR) | |
1140 | { | |
cdc2d765 | 1141 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
58749582 | 1142 | int idx_asn = 3; |
718e3744 | 1143 | as_t as; |
1144 | int i; | |
1145 | ||
58749582 | 1146 | for (i = idx_asn; i < argc; i++) |
718e3744 | 1147 | { |
afec25d9 | 1148 | VTY_GET_INTEGER_RANGE ("AS", as, argv[i]->arg, 1, BGP_AS4_MAX); |
718e3744 | 1149 | |
1150 | if (bgp->as == as) | |
1151 | { | |
1152 | vty_out (vty, "%% Local member-AS not allowed in confed peer list%s", | |
1153 | VTY_NEWLINE); | |
1154 | continue; | |
1155 | } | |
1156 | ||
1157 | bgp_confederation_peers_add (bgp, as); | |
1158 | } | |
1159 | return CMD_SUCCESS; | |
1160 | } | |
1161 | ||
1162 | DEFUN (no_bgp_confederation_peers, | |
1163 | no_bgp_confederation_peers_cmd, | |
e83a9414 | 1164 | "no bgp confederation peers (1-4294967295)...", |
718e3744 | 1165 | NO_STR |
1166 | "BGP specific commands\n" | |
1167 | "AS confederation parameters\n" | |
1168 | "Peer ASs in BGP confederation\n" | |
1169 | AS_STR) | |
1170 | { | |
cdc2d765 | 1171 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
58749582 | 1172 | int idx_asn = 4; |
718e3744 | 1173 | as_t as; |
1174 | int i; | |
1175 | ||
58749582 | 1176 | for (i = idx_asn; i < argc; i++) |
718e3744 | 1177 | { |
afec25d9 | 1178 | VTY_GET_INTEGER_RANGE ("AS", as, argv[i]->arg, 1, BGP_AS4_MAX); |
0b2aa3a0 | 1179 | |
718e3744 | 1180 | bgp_confederation_peers_remove (bgp, as); |
1181 | } | |
1182 | return CMD_SUCCESS; | |
1183 | } | |
6b0655a2 | 1184 | |
5e242b0d DS |
1185 | /** |
1186 | * Central routine for maximum-paths configuration. | |
1187 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1188 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1189 | */ | |
ffd0c037 DS |
1190 | static int |
1191 | bgp_maxpaths_config_vty (struct vty *vty, int peer_type, const char *mpaths, | |
5e242b0d | 1192 | u_int16_t options, int set) |
165b5fff | 1193 | { |
cdc2d765 | 1194 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4c9dee98 | 1195 | u_int16_t maxpaths = 0; |
165b5fff | 1196 | int ret; |
5e242b0d DS |
1197 | afi_t afi; |
1198 | safi_t safi; | |
165b5fff | 1199 | |
5e242b0d DS |
1200 | afi = bgp_node_afi (vty); |
1201 | safi = bgp_node_safi (vty); | |
165b5fff | 1202 | |
5e242b0d | 1203 | if (set) |
4c9dee98 | 1204 | { |
c59f2066 | 1205 | maxpaths = strtol(mpaths, NULL, 10); |
37fe7731 DS |
1206 | if (maxpaths > multipath_num) |
1207 | { | |
1208 | vty_out (vty, | |
1209 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", | |
1210 | maxpaths, multipath_num); | |
1211 | return CMD_WARNING; | |
1212 | } | |
dff6764a | 1213 | ret = bgp_maximum_paths_set (bgp, afi, safi, peer_type, maxpaths, options); |
4c9dee98 | 1214 | } |
5e242b0d DS |
1215 | else |
1216 | ret = bgp_maximum_paths_unset (bgp, afi, safi, peer_type); | |
165b5fff | 1217 | |
165b5fff JB |
1218 | if (ret < 0) |
1219 | { | |
1220 | vty_out (vty, | |
5e242b0d DS |
1221 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u%s", |
1222 | (set == 1) ? "" : "un", | |
1223 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1224 | maxpaths, afi, safi, VTY_NEWLINE); | |
165b5fff JB |
1225 | return CMD_WARNING; |
1226 | } | |
1227 | ||
7aafcaca DS |
1228 | bgp_recalculate_all_bestpaths (bgp); |
1229 | ||
165b5fff JB |
1230 | return CMD_SUCCESS; |
1231 | } | |
1232 | ||
abc920f8 DS |
1233 | DEFUN (bgp_maxmed_admin, |
1234 | bgp_maxmed_admin_cmd, | |
1235 | "bgp max-med administrative ", | |
1236 | BGP_STR | |
1237 | "Advertise routes with max-med\n" | |
1238 | "Administratively applied, for an indefinite period\n") | |
1239 | { | |
cdc2d765 | 1240 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 DS |
1241 | |
1242 | bgp->v_maxmed_admin = 1; | |
1243 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1244 | ||
1245 | bgp_maxmed_update(bgp); | |
1246 | ||
1247 | return CMD_SUCCESS; | |
1248 | } | |
1249 | ||
1250 | DEFUN (bgp_maxmed_admin_medv, | |
1251 | bgp_maxmed_admin_medv_cmd, | |
4668a151 | 1252 | "bgp max-med administrative (0-4294967295)", |
abc920f8 DS |
1253 | BGP_STR |
1254 | "Advertise routes with max-med\n" | |
1255 | "Administratively applied, for an indefinite period\n" | |
1256 | "Max MED value to be used\n") | |
1257 | { | |
cdc2d765 | 1258 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1259 | int idx_number = 3; |
abc920f8 DS |
1260 | |
1261 | bgp->v_maxmed_admin = 1; | |
4668a151 | 1262 | bgp->maxmed_admin_value = strtoul (argv[idx_number]->arg, NULL, 10); |
abc920f8 DS |
1263 | |
1264 | bgp_maxmed_update(bgp); | |
1265 | ||
1266 | return CMD_SUCCESS; | |
1267 | } | |
1268 | ||
1269 | DEFUN (no_bgp_maxmed_admin, | |
1270 | no_bgp_maxmed_admin_cmd, | |
4668a151 | 1271 | "no bgp max-med administrative [(0-4294967295)]", |
abc920f8 DS |
1272 | NO_STR |
1273 | BGP_STR | |
1274 | "Advertise routes with max-med\n" | |
838758ac DW |
1275 | "Administratively applied, for an indefinite period\n" |
1276 | "Max MED value to be used\n") | |
abc920f8 | 1277 | { |
cdc2d765 | 1278 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 DS |
1279 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; |
1280 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 DS |
1281 | bgp_maxmed_update(bgp); |
1282 | ||
1283 | return CMD_SUCCESS; | |
1284 | } | |
1285 | ||
abc920f8 DS |
1286 | DEFUN (bgp_maxmed_onstartup, |
1287 | bgp_maxmed_onstartup_cmd, | |
4668a151 | 1288 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", |
abc920f8 DS |
1289 | BGP_STR |
1290 | "Advertise routes with max-med\n" | |
1291 | "Effective on a startup\n" | |
1292 | "Time (seconds) period for max-med\n" | |
1293 | "Max MED value to be used\n") | |
1294 | { | |
cdc2d765 | 1295 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 QY |
1296 | int idx = 0; |
1297 | ||
1298 | argv_find (argv, argc, "(5-86400)", &idx); | |
1299 | bgp->v_maxmed_onstartup = strtoul (argv[idx]->arg, NULL, 10); | |
1300 | if (argv_find (argv, argc, "(0-4294967295)", &idx)) | |
1301 | bgp->maxmed_onstartup_value = strtoul (argv[idx]->arg, NULL, 10); | |
1302 | else | |
1303 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
1304 | ||
abc920f8 DS |
1305 | bgp_maxmed_update(bgp); |
1306 | ||
1307 | return CMD_SUCCESS; | |
1308 | } | |
1309 | ||
1310 | DEFUN (no_bgp_maxmed_onstartup, | |
1311 | no_bgp_maxmed_onstartup_cmd, | |
4668a151 | 1312 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", |
abc920f8 DS |
1313 | NO_STR |
1314 | BGP_STR | |
1315 | "Advertise routes with max-med\n" | |
838758ac DW |
1316 | "Effective on a startup\n" |
1317 | "Time (seconds) period for max-med\n" | |
1318 | "Max MED value to be used\n") | |
abc920f8 | 1319 | { |
cdc2d765 | 1320 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 DS |
1321 | |
1322 | /* Cancel max-med onstartup if its on */ | |
1323 | if (bgp->t_maxmed_onstartup) | |
1324 | { | |
1325 | THREAD_TIMER_OFF (bgp->t_maxmed_onstartup); | |
1326 | bgp->maxmed_onstartup_over = 1; | |
1327 | } | |
1328 | ||
1329 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; | |
1330 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
1331 | ||
1332 | bgp_maxmed_update(bgp); | |
1333 | ||
1334 | return CMD_SUCCESS; | |
1335 | } | |
1336 | ||
f188f2c4 DS |
1337 | static int |
1338 | bgp_update_delay_config_vty (struct vty *vty, const char *delay, | |
1339 | const char *wait) | |
1340 | { | |
cdc2d765 | 1341 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 DS |
1342 | u_int16_t update_delay; |
1343 | u_int16_t establish_wait; | |
1344 | ||
f188f2c4 DS |
1345 | VTY_GET_INTEGER_RANGE ("update-delay", update_delay, delay, |
1346 | BGP_UPDATE_DELAY_MIN, BGP_UPDATE_DELAY_MAX); | |
1347 | ||
1348 | if (!wait) /* update-delay <delay> */ | |
1349 | { | |
1350 | bgp->v_update_delay = update_delay; | |
1351 | bgp->v_establish_wait = bgp->v_update_delay; | |
1352 | return CMD_SUCCESS; | |
1353 | } | |
1354 | ||
1355 | /* update-delay <delay> <establish-wait> */ | |
1356 | establish_wait = atoi (wait); | |
1357 | if (update_delay < establish_wait) | |
1358 | { | |
1359 | vty_out (vty, "%%Failed: update-delay less than the establish-wait!%s", | |
1360 | VTY_NEWLINE); | |
1361 | return CMD_WARNING; | |
1362 | } | |
1363 | ||
1364 | bgp->v_update_delay = update_delay; | |
1365 | bgp->v_establish_wait = establish_wait; | |
1366 | ||
1367 | return CMD_SUCCESS; | |
1368 | } | |
1369 | ||
1370 | static int | |
1371 | bgp_update_delay_deconfig_vty (struct vty *vty) | |
1372 | { | |
cdc2d765 | 1373 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 DS |
1374 | |
1375 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; | |
1376 | bgp->v_establish_wait = bgp->v_update_delay; | |
1377 | ||
1378 | return CMD_SUCCESS; | |
1379 | } | |
1380 | ||
1381 | int | |
1382 | bgp_config_write_update_delay (struct vty *vty, struct bgp *bgp) | |
1383 | { | |
1384 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) | |
1385 | { | |
1386 | vty_out (vty, " update-delay %d", bgp->v_update_delay); | |
1387 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1388 | vty_out (vty, " %d", bgp->v_establish_wait); | |
1389 | vty_out (vty, "%s", VTY_NEWLINE); | |
1390 | } | |
1391 | ||
1392 | return 0; | |
1393 | } | |
1394 | ||
1395 | ||
1396 | /* Update-delay configuration */ | |
1397 | DEFUN (bgp_update_delay, | |
1398 | bgp_update_delay_cmd, | |
6147e2c6 | 1399 | "update-delay (0-3600)", |
f188f2c4 DS |
1400 | "Force initial delay for best-path and updates\n" |
1401 | "Seconds\n") | |
1402 | { | |
c500ae40 DW |
1403 | int idx_number = 1; |
1404 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); | |
f188f2c4 DS |
1405 | } |
1406 | ||
1407 | DEFUN (bgp_update_delay_establish_wait, | |
1408 | bgp_update_delay_establish_wait_cmd, | |
6147e2c6 | 1409 | "update-delay (0-3600) (1-3600)", |
f188f2c4 DS |
1410 | "Force initial delay for best-path and updates\n" |
1411 | "Seconds\n" | |
1412 | "Wait for peers to be established\n" | |
1413 | "Seconds\n") | |
1414 | { | |
c500ae40 DW |
1415 | int idx_number = 1; |
1416 | int idx_number_2 = 2; | |
1417 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, argv[idx_number_2]->arg); | |
f188f2c4 DS |
1418 | } |
1419 | ||
1420 | /* Update-delay deconfiguration */ | |
1421 | DEFUN (no_bgp_update_delay, | |
1422 | no_bgp_update_delay_cmd, | |
838758ac DW |
1423 | "no update-delay [(0-3600) [(1-3600)]]", |
1424 | NO_STR | |
f188f2c4 | 1425 | "Force initial delay for best-path and updates\n" |
838758ac DW |
1426 | "Seconds\n" |
1427 | "Wait for peers to be established\n") | |
f188f2c4 DS |
1428 | { |
1429 | return bgp_update_delay_deconfig_vty(vty); | |
1430 | } | |
1431 | ||
5e242b0d | 1432 | |
ffd0c037 DS |
1433 | static int |
1434 | bgp_wpkt_quanta_config_vty (struct vty *vty, const char *num, char set) | |
cb1faec9 | 1435 | { |
cdc2d765 | 1436 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
cb1faec9 DS |
1437 | |
1438 | if (set) | |
1439 | VTY_GET_INTEGER_RANGE ("write-quanta", bgp->wpkt_quanta, num, | |
4543bbb4 | 1440 | 1, 10000); |
cb1faec9 DS |
1441 | else |
1442 | bgp->wpkt_quanta = BGP_WRITE_PACKET_MAX; | |
1443 | ||
1444 | return CMD_SUCCESS; | |
1445 | } | |
1446 | ||
1447 | int | |
1448 | bgp_config_write_wpkt_quanta (struct vty *vty, struct bgp *bgp) | |
1449 | { | |
1450 | if (bgp->wpkt_quanta != BGP_WRITE_PACKET_MAX) | |
1451 | vty_out (vty, " write-quanta %d%s", | |
1452 | bgp->wpkt_quanta, VTY_NEWLINE); | |
1453 | ||
1454 | return 0; | |
1455 | } | |
1456 | ||
1457 | ||
1458 | /* Update-delay configuration */ | |
1459 | DEFUN (bgp_wpkt_quanta, | |
1460 | bgp_wpkt_quanta_cmd, | |
6147e2c6 | 1461 | "write-quanta (1-10000)", |
cb1faec9 DS |
1462 | "How many packets to write to peer socket per run\n" |
1463 | "Number of packets\n") | |
1464 | { | |
c500ae40 DW |
1465 | int idx_number = 1; |
1466 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
cb1faec9 DS |
1467 | } |
1468 | ||
1469 | /* Update-delay deconfiguration */ | |
1470 | DEFUN (no_bgp_wpkt_quanta, | |
1471 | no_bgp_wpkt_quanta_cmd, | |
6147e2c6 | 1472 | "no write-quanta (1-10000)", |
d7fa34c1 | 1473 | NO_STR |
cb1faec9 DS |
1474 | "How many packets to write to peer socket per run\n" |
1475 | "Number of packets\n") | |
1476 | { | |
c500ae40 DW |
1477 | int idx_number = 2; |
1478 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
cb1faec9 DS |
1479 | } |
1480 | ||
3f9c7369 DS |
1481 | int |
1482 | bgp_config_write_coalesce_time (struct vty *vty, struct bgp *bgp) | |
1483 | { | |
1484 | if (bgp->coalesce_time != BGP_DEFAULT_SUBGROUP_COALESCE_TIME) | |
4668a151 | 1485 | vty_out (vty, " coalesce-time %u%s", |
3f9c7369 DS |
1486 | bgp->coalesce_time, VTY_NEWLINE); |
1487 | ||
1488 | return 0; | |
1489 | } | |
1490 | ||
1491 | ||
1492 | DEFUN (bgp_coalesce_time, | |
1493 | bgp_coalesce_time_cmd, | |
6147e2c6 | 1494 | "coalesce-time (0-4294967295)", |
3f9c7369 DS |
1495 | "Subgroup coalesce timer\n" |
1496 | "Subgroup coalesce timer value (in ms)\n") | |
1497 | { | |
4668a151 QY |
1498 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1499 | ||
1500 | int idx = 0; | |
1501 | argv_find (argv, argc, "(0-4294967295)", &idx); | |
1502 | bgp->coalesce_time = strtoul (argv[idx]->arg, NULL, 10); | |
1503 | return CMD_SUCCESS; | |
3f9c7369 DS |
1504 | } |
1505 | ||
1506 | DEFUN (no_bgp_coalesce_time, | |
1507 | no_bgp_coalesce_time_cmd, | |
6147e2c6 | 1508 | "no coalesce-time (0-4294967295)", |
3a2d747c | 1509 | NO_STR |
3f9c7369 DS |
1510 | "Subgroup coalesce timer\n" |
1511 | "Subgroup coalesce timer value (in ms)\n") | |
1512 | { | |
4668a151 QY |
1513 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1514 | ||
1515 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; | |
1516 | return CMD_SUCCESS; | |
3f9c7369 DS |
1517 | } |
1518 | ||
5e242b0d DS |
1519 | /* Maximum-paths configuration */ |
1520 | DEFUN (bgp_maxpaths, | |
1521 | bgp_maxpaths_cmd, | |
9ccf14f7 | 1522 | "maximum-paths (1-255)", |
5e242b0d DS |
1523 | "Forward packets over multiple paths\n" |
1524 | "Number of paths\n") | |
1525 | { | |
c500ae40 DW |
1526 | int idx_number = 1; |
1527 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
1528 | } |
1529 | ||
596c17ba DW |
1530 | ALIAS_HIDDEN (bgp_maxpaths, |
1531 | bgp_maxpaths_hidden_cmd, | |
1532 | "maximum-paths (1-255)", | |
1533 | "Forward packets over multiple paths\n" | |
1534 | "Number of paths\n") | |
1535 | ||
165b5fff JB |
1536 | DEFUN (bgp_maxpaths_ibgp, |
1537 | bgp_maxpaths_ibgp_cmd, | |
9ccf14f7 | 1538 | "maximum-paths ibgp (1-255)", |
165b5fff JB |
1539 | "Forward packets over multiple paths\n" |
1540 | "iBGP-multipath\n" | |
1541 | "Number of paths\n") | |
1542 | { | |
c500ae40 DW |
1543 | int idx_number = 2; |
1544 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[idx_number]->arg, 0, 1); | |
5e242b0d | 1545 | } |
165b5fff | 1546 | |
596c17ba DW |
1547 | ALIAS_HIDDEN (bgp_maxpaths_ibgp, |
1548 | bgp_maxpaths_ibgp_hidden_cmd, | |
1549 | "maximum-paths ibgp (1-255)", | |
1550 | "Forward packets over multiple paths\n" | |
1551 | "iBGP-multipath\n" | |
1552 | "Number of paths\n") | |
1553 | ||
5e242b0d DS |
1554 | DEFUN (bgp_maxpaths_ibgp_cluster, |
1555 | bgp_maxpaths_ibgp_cluster_cmd, | |
9ccf14f7 | 1556 | "maximum-paths ibgp (1-255) equal-cluster-length", |
5e242b0d DS |
1557 | "Forward packets over multiple paths\n" |
1558 | "iBGP-multipath\n" | |
1559 | "Number of paths\n" | |
1560 | "Match the cluster length\n") | |
1561 | { | |
c500ae40 DW |
1562 | int idx_number = 2; |
1563 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
5e242b0d | 1564 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); |
165b5fff JB |
1565 | } |
1566 | ||
596c17ba DW |
1567 | ALIAS_HIDDEN (bgp_maxpaths_ibgp_cluster, |
1568 | bgp_maxpaths_ibgp_cluster_hidden_cmd, | |
1569 | "maximum-paths ibgp (1-255) equal-cluster-length", | |
1570 | "Forward packets over multiple paths\n" | |
1571 | "iBGP-multipath\n" | |
1572 | "Number of paths\n" | |
1573 | "Match the cluster length\n") | |
1574 | ||
165b5fff JB |
1575 | DEFUN (no_bgp_maxpaths, |
1576 | no_bgp_maxpaths_cmd, | |
9ccf14f7 | 1577 | "no maximum-paths [(1-255)]", |
165b5fff JB |
1578 | NO_STR |
1579 | "Forward packets over multiple paths\n" | |
1580 | "Number of paths\n") | |
1581 | { | |
5e242b0d | 1582 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
1583 | } |
1584 | ||
596c17ba DW |
1585 | ALIAS_HIDDEN (no_bgp_maxpaths, |
1586 | no_bgp_maxpaths_hidden_cmd, | |
1587 | "no maximum-paths [(1-255)]", | |
1588 | NO_STR | |
1589 | "Forward packets over multiple paths\n" | |
1590 | "Number of paths\n") | |
1591 | ||
165b5fff JB |
1592 | DEFUN (no_bgp_maxpaths_ibgp, |
1593 | no_bgp_maxpaths_ibgp_cmd, | |
9ccf14f7 | 1594 | "no maximum-paths ibgp [(1-255) [equal-cluster-length]]", |
165b5fff JB |
1595 | NO_STR |
1596 | "Forward packets over multiple paths\n" | |
1597 | "iBGP-multipath\n" | |
838758ac DW |
1598 | "Number of paths\n" |
1599 | "Match the cluster length\n") | |
165b5fff | 1600 | { |
5e242b0d | 1601 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1602 | } |
1603 | ||
596c17ba DW |
1604 | ALIAS_HIDDEN (no_bgp_maxpaths_ibgp, |
1605 | no_bgp_maxpaths_ibgp_hidden_cmd, | |
1606 | "no maximum-paths ibgp [(1-255) [equal-cluster-length]]", | |
1607 | NO_STR | |
1608 | "Forward packets over multiple paths\n" | |
1609 | "iBGP-multipath\n" | |
1610 | "Number of paths\n" | |
1611 | "Match the cluster length\n") | |
1612 | ||
165b5fff JB |
1613 | int |
1614 | bgp_config_write_maxpaths (struct vty *vty, struct bgp *bgp, afi_t afi, | |
1615 | safi_t safi, int *write) | |
1616 | { | |
d5b77cc2 | 1617 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) |
165b5fff JB |
1618 | { |
1619 | bgp_config_write_family_header (vty, afi, safi, write); | |
0b960b4d | 1620 | vty_out (vty, " maximum-paths %d%s", |
165b5fff JB |
1621 | bgp->maxpaths[afi][safi].maxpaths_ebgp, VTY_NEWLINE); |
1622 | } | |
1623 | ||
d5b77cc2 | 1624 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) |
165b5fff JB |
1625 | { |
1626 | bgp_config_write_family_header (vty, afi, safi, write); | |
0b960b4d | 1627 | vty_out (vty, " maximum-paths ibgp %d", |
5e242b0d DS |
1628 | bgp->maxpaths[afi][safi].maxpaths_ibgp); |
1629 | if (CHECK_FLAG (bgp->maxpaths[afi][safi].ibgp_flags, | |
1630 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1631 | vty_out (vty, " equal-cluster-length"); | |
1632 | vty_out (vty, "%s", VTY_NEWLINE); | |
165b5fff JB |
1633 | } |
1634 | ||
1635 | return 0; | |
1636 | } | |
6b0655a2 | 1637 | |
718e3744 | 1638 | /* BGP timers. */ |
1639 | ||
1640 | DEFUN (bgp_timers, | |
1641 | bgp_timers_cmd, | |
6147e2c6 | 1642 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1643 | "Adjust routing timers\n" |
1644 | "BGP timers\n" | |
1645 | "Keepalive interval\n" | |
1646 | "Holdtime\n") | |
1647 | { | |
cdc2d765 | 1648 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
1649 | int idx_number = 2; |
1650 | int idx_number_2 = 3; | |
718e3744 | 1651 | unsigned long keepalive = 0; |
1652 | unsigned long holdtime = 0; | |
1653 | ||
c500ae40 DW |
1654 | VTY_GET_INTEGER ("keepalive", keepalive, argv[idx_number]->arg); |
1655 | VTY_GET_INTEGER ("holdtime", holdtime, argv[idx_number_2]->arg); | |
718e3744 | 1656 | |
1657 | /* Holdtime value check. */ | |
1658 | if (holdtime < 3 && holdtime != 0) | |
1659 | { | |
1660 | vty_out (vty, "%% hold time value must be either 0 or greater than 3%s", | |
1661 | VTY_NEWLINE); | |
1662 | return CMD_WARNING; | |
1663 | } | |
1664 | ||
1665 | bgp_timers_set (bgp, keepalive, holdtime); | |
1666 | ||
1667 | return CMD_SUCCESS; | |
1668 | } | |
1669 | ||
1670 | DEFUN (no_bgp_timers, | |
1671 | no_bgp_timers_cmd, | |
838758ac | 1672 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1673 | NO_STR |
1674 | "Adjust routing timers\n" | |
838758ac DW |
1675 | "BGP timers\n" |
1676 | "Keepalive interval\n" | |
1677 | "Holdtime\n") | |
718e3744 | 1678 | { |
cdc2d765 | 1679 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1680 | bgp_timers_unset (bgp); |
1681 | ||
1682 | return CMD_SUCCESS; | |
1683 | } | |
1684 | ||
6b0655a2 | 1685 | |
718e3744 | 1686 | DEFUN (bgp_client_to_client_reflection, |
1687 | bgp_client_to_client_reflection_cmd, | |
1688 | "bgp client-to-client reflection", | |
1689 | "BGP specific commands\n" | |
1690 | "Configure client to client route reflection\n" | |
1691 | "reflection of routes allowed\n") | |
1692 | { | |
cdc2d765 | 1693 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1694 | bgp_flag_unset (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); |
f31fa004 | 1695 | bgp_clear_star_soft_out (vty, bgp->name); |
7aafcaca | 1696 | |
718e3744 | 1697 | return CMD_SUCCESS; |
1698 | } | |
1699 | ||
1700 | DEFUN (no_bgp_client_to_client_reflection, | |
1701 | no_bgp_client_to_client_reflection_cmd, | |
1702 | "no bgp client-to-client reflection", | |
1703 | NO_STR | |
1704 | "BGP specific commands\n" | |
1705 | "Configure client to client route reflection\n" | |
1706 | "reflection of routes allowed\n") | |
1707 | { | |
cdc2d765 | 1708 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1709 | bgp_flag_set (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); |
f31fa004 | 1710 | bgp_clear_star_soft_out (vty, bgp->name); |
7aafcaca | 1711 | |
718e3744 | 1712 | return CMD_SUCCESS; |
1713 | } | |
1714 | ||
1715 | /* "bgp always-compare-med" configuration. */ | |
1716 | DEFUN (bgp_always_compare_med, | |
1717 | bgp_always_compare_med_cmd, | |
1718 | "bgp always-compare-med", | |
1719 | "BGP specific commands\n" | |
1720 | "Allow comparing MED from different neighbors\n") | |
1721 | { | |
cdc2d765 | 1722 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1723 | bgp_flag_set (bgp, BGP_FLAG_ALWAYS_COMPARE_MED); |
7aafcaca DS |
1724 | bgp_recalculate_all_bestpaths (bgp); |
1725 | ||
718e3744 | 1726 | return CMD_SUCCESS; |
1727 | } | |
1728 | ||
1729 | DEFUN (no_bgp_always_compare_med, | |
1730 | no_bgp_always_compare_med_cmd, | |
1731 | "no bgp always-compare-med", | |
1732 | NO_STR | |
1733 | "BGP specific commands\n" | |
1734 | "Allow comparing MED from different neighbors\n") | |
1735 | { | |
cdc2d765 | 1736 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1737 | bgp_flag_unset (bgp, BGP_FLAG_ALWAYS_COMPARE_MED); |
7aafcaca DS |
1738 | bgp_recalculate_all_bestpaths (bgp); |
1739 | ||
718e3744 | 1740 | return CMD_SUCCESS; |
1741 | } | |
6b0655a2 | 1742 | |
718e3744 | 1743 | /* "bgp deterministic-med" configuration. */ |
1744 | DEFUN (bgp_deterministic_med, | |
1745 | bgp_deterministic_med_cmd, | |
1746 | "bgp deterministic-med", | |
1747 | "BGP specific commands\n" | |
1748 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1749 | { | |
cdc2d765 | 1750 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1475ac87 DW |
1751 | |
1752 | if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) | |
1753 | { | |
1754 | bgp_flag_set (bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1755 | bgp_recalculate_all_bestpaths (bgp); | |
1756 | } | |
7aafcaca | 1757 | |
718e3744 | 1758 | return CMD_SUCCESS; |
1759 | } | |
1760 | ||
1761 | DEFUN (no_bgp_deterministic_med, | |
1762 | no_bgp_deterministic_med_cmd, | |
1763 | "no bgp deterministic-med", | |
1764 | NO_STR | |
1765 | "BGP specific commands\n" | |
1766 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1767 | { | |
cdc2d765 | 1768 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
06370dac DW |
1769 | int bestpath_per_as_used; |
1770 | afi_t afi; | |
1771 | safi_t safi; | |
1772 | struct peer *peer; | |
1773 | struct listnode *node, *nnode; | |
718e3744 | 1774 | |
1475ac87 DW |
1775 | if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) |
1776 | { | |
06370dac DW |
1777 | bestpath_per_as_used = 0; |
1778 | ||
1779 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
1780 | { | |
1781 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
1782 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
1783 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) | |
1784 | { | |
1785 | bestpath_per_as_used = 1; | |
1786 | break; | |
1787 | } | |
1788 | ||
1789 | if (bestpath_per_as_used) | |
1790 | break; | |
1791 | } | |
1792 | ||
1793 | if (bestpath_per_as_used) | |
1794 | { | |
1795 | vty_out (vty, "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use%s", | |
1796 | VTY_NEWLINE); | |
1797 | return CMD_WARNING; | |
1798 | } | |
1799 | else | |
1800 | { | |
1801 | bgp_flag_unset (bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1802 | bgp_recalculate_all_bestpaths (bgp); | |
1803 | } | |
1475ac87 | 1804 | } |
7aafcaca | 1805 | |
718e3744 | 1806 | return CMD_SUCCESS; |
1807 | } | |
538621f2 | 1808 | |
1809 | /* "bgp graceful-restart" configuration. */ | |
1810 | DEFUN (bgp_graceful_restart, | |
1811 | bgp_graceful_restart_cmd, | |
1812 | "bgp graceful-restart", | |
1813 | "BGP specific commands\n" | |
1814 | "Graceful restart capability parameters\n") | |
1815 | { | |
cdc2d765 | 1816 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
538621f2 | 1817 | bgp_flag_set (bgp, BGP_FLAG_GRACEFUL_RESTART); |
1818 | return CMD_SUCCESS; | |
1819 | } | |
1820 | ||
1821 | DEFUN (no_bgp_graceful_restart, | |
1822 | no_bgp_graceful_restart_cmd, | |
1823 | "no bgp graceful-restart", | |
1824 | NO_STR | |
1825 | "BGP specific commands\n" | |
1826 | "Graceful restart capability parameters\n") | |
1827 | { | |
cdc2d765 | 1828 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
538621f2 | 1829 | bgp_flag_unset (bgp, BGP_FLAG_GRACEFUL_RESTART); |
1830 | return CMD_SUCCESS; | |
1831 | } | |
1832 | ||
93406d87 | 1833 | DEFUN (bgp_graceful_restart_stalepath_time, |
1834 | bgp_graceful_restart_stalepath_time_cmd, | |
6147e2c6 | 1835 | "bgp graceful-restart stalepath-time (1-3600)", |
93406d87 | 1836 | "BGP specific commands\n" |
1837 | "Graceful restart capability parameters\n" | |
1838 | "Set the max time to hold onto restarting peer's stale paths\n" | |
1839 | "Delay value (seconds)\n") | |
1840 | { | |
cdc2d765 | 1841 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1842 | int idx_number = 3; |
93406d87 | 1843 | u_int32_t stalepath; |
1844 | ||
c500ae40 | 1845 | VTY_GET_INTEGER_RANGE ("stalepath-time", stalepath, argv[idx_number]->arg, 1, 3600); |
93406d87 | 1846 | bgp->stalepath_time = stalepath; |
1847 | return CMD_SUCCESS; | |
1848 | } | |
1849 | ||
eb6f1b41 PG |
1850 | DEFUN (bgp_graceful_restart_restart_time, |
1851 | bgp_graceful_restart_restart_time_cmd, | |
6147e2c6 | 1852 | "bgp graceful-restart restart-time (1-3600)", |
eb6f1b41 PG |
1853 | "BGP specific commands\n" |
1854 | "Graceful restart capability parameters\n" | |
1855 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
1856 | "Delay value (seconds)\n") | |
1857 | { | |
cdc2d765 | 1858 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1859 | int idx_number = 3; |
eb6f1b41 PG |
1860 | u_int32_t restart; |
1861 | ||
c500ae40 | 1862 | VTY_GET_INTEGER_RANGE ("restart-time", restart, argv[idx_number]->arg, 1, 3600); |
eb6f1b41 PG |
1863 | bgp->restart_time = restart; |
1864 | return CMD_SUCCESS; | |
1865 | } | |
1866 | ||
93406d87 | 1867 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
1868 | no_bgp_graceful_restart_stalepath_time_cmd, | |
838758ac | 1869 | "no bgp graceful-restart stalepath-time [(1-3600)]", |
93406d87 | 1870 | NO_STR |
1871 | "BGP specific commands\n" | |
1872 | "Graceful restart capability parameters\n" | |
838758ac DW |
1873 | "Set the max time to hold onto restarting peer's stale paths\n" |
1874 | "Delay value (seconds)\n") | |
93406d87 | 1875 | { |
cdc2d765 | 1876 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 1877 | |
1878 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; | |
1879 | return CMD_SUCCESS; | |
1880 | } | |
1881 | ||
eb6f1b41 PG |
1882 | DEFUN (no_bgp_graceful_restart_restart_time, |
1883 | no_bgp_graceful_restart_restart_time_cmd, | |
838758ac | 1884 | "no bgp graceful-restart restart-time [(1-3600)]", |
eb6f1b41 PG |
1885 | NO_STR |
1886 | "BGP specific commands\n" | |
1887 | "Graceful restart capability parameters\n" | |
838758ac DW |
1888 | "Set the time to wait to delete stale routes before a BGP open message is received\n" |
1889 | "Delay value (seconds)\n") | |
eb6f1b41 | 1890 | { |
cdc2d765 | 1891 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 PG |
1892 | |
1893 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; | |
1894 | return CMD_SUCCESS; | |
1895 | } | |
1896 | ||
43fc21b3 JC |
1897 | DEFUN (bgp_graceful_restart_preserve_fw, |
1898 | bgp_graceful_restart_preserve_fw_cmd, | |
1899 | "bgp graceful-restart preserve-fw-state", | |
1900 | "BGP specific commands\n" | |
1901 | "Graceful restart capability parameters\n" | |
1902 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1903 | { | |
1904 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1905 | bgp_flag_set(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1906 | return CMD_SUCCESS; | |
1907 | } | |
1908 | ||
1909 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
1910 | no_bgp_graceful_restart_preserve_fw_cmd, | |
1911 | "no bgp graceful-restart preserve-fw-state", | |
1912 | NO_STR | |
1913 | "BGP specific commands\n" | |
1914 | "Graceful restart capability parameters\n" | |
1915 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1916 | { | |
1917 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1918 | bgp_flag_unset(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1919 | return CMD_SUCCESS; | |
1920 | } | |
1921 | ||
718e3744 | 1922 | /* "bgp fast-external-failover" configuration. */ |
1923 | DEFUN (bgp_fast_external_failover, | |
1924 | bgp_fast_external_failover_cmd, | |
1925 | "bgp fast-external-failover", | |
1926 | BGP_STR | |
1927 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
1928 | { | |
cdc2d765 | 1929 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1930 | bgp_flag_unset (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); |
1931 | return CMD_SUCCESS; | |
1932 | } | |
1933 | ||
1934 | DEFUN (no_bgp_fast_external_failover, | |
1935 | no_bgp_fast_external_failover_cmd, | |
1936 | "no bgp fast-external-failover", | |
1937 | NO_STR | |
1938 | BGP_STR | |
1939 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
1940 | { | |
cdc2d765 | 1941 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1942 | bgp_flag_set (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); |
1943 | return CMD_SUCCESS; | |
1944 | } | |
6b0655a2 | 1945 | |
718e3744 | 1946 | /* "bgp enforce-first-as" configuration. */ |
1947 | DEFUN (bgp_enforce_first_as, | |
1948 | bgp_enforce_first_as_cmd, | |
1949 | "bgp enforce-first-as", | |
1950 | BGP_STR | |
1951 | "Enforce the first AS for EBGP routes\n") | |
1952 | { | |
cdc2d765 | 1953 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1954 | bgp_flag_set (bgp, BGP_FLAG_ENFORCE_FIRST_AS); |
f31fa004 | 1955 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 1956 | |
718e3744 | 1957 | return CMD_SUCCESS; |
1958 | } | |
1959 | ||
1960 | DEFUN (no_bgp_enforce_first_as, | |
1961 | no_bgp_enforce_first_as_cmd, | |
1962 | "no bgp enforce-first-as", | |
1963 | NO_STR | |
1964 | BGP_STR | |
1965 | "Enforce the first AS for EBGP routes\n") | |
1966 | { | |
cdc2d765 | 1967 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1968 | bgp_flag_unset (bgp, BGP_FLAG_ENFORCE_FIRST_AS); |
f31fa004 | 1969 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 1970 | |
718e3744 | 1971 | return CMD_SUCCESS; |
1972 | } | |
6b0655a2 | 1973 | |
718e3744 | 1974 | /* "bgp bestpath compare-routerid" configuration. */ |
1975 | DEFUN (bgp_bestpath_compare_router_id, | |
1976 | bgp_bestpath_compare_router_id_cmd, | |
1977 | "bgp bestpath compare-routerid", | |
1978 | "BGP specific commands\n" | |
1979 | "Change the default bestpath selection\n" | |
1980 | "Compare router-id for identical EBGP paths\n") | |
1981 | { | |
cdc2d765 | 1982 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1983 | bgp_flag_set (bgp, BGP_FLAG_COMPARE_ROUTER_ID); |
7aafcaca DS |
1984 | bgp_recalculate_all_bestpaths (bgp); |
1985 | ||
718e3744 | 1986 | return CMD_SUCCESS; |
1987 | } | |
1988 | ||
1989 | DEFUN (no_bgp_bestpath_compare_router_id, | |
1990 | no_bgp_bestpath_compare_router_id_cmd, | |
1991 | "no bgp bestpath compare-routerid", | |
1992 | NO_STR | |
1993 | "BGP specific commands\n" | |
1994 | "Change the default bestpath selection\n" | |
1995 | "Compare router-id for identical EBGP paths\n") | |
1996 | { | |
cdc2d765 | 1997 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1998 | bgp_flag_unset (bgp, BGP_FLAG_COMPARE_ROUTER_ID); |
7aafcaca DS |
1999 | bgp_recalculate_all_bestpaths (bgp); |
2000 | ||
718e3744 | 2001 | return CMD_SUCCESS; |
2002 | } | |
6b0655a2 | 2003 | |
718e3744 | 2004 | /* "bgp bestpath as-path ignore" configuration. */ |
2005 | DEFUN (bgp_bestpath_aspath_ignore, | |
2006 | bgp_bestpath_aspath_ignore_cmd, | |
2007 | "bgp bestpath as-path ignore", | |
2008 | "BGP specific commands\n" | |
2009 | "Change the default bestpath selection\n" | |
2010 | "AS-path attribute\n" | |
2011 | "Ignore as-path length in selecting a route\n") | |
2012 | { | |
cdc2d765 | 2013 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2014 | bgp_flag_set (bgp, BGP_FLAG_ASPATH_IGNORE); |
7aafcaca DS |
2015 | bgp_recalculate_all_bestpaths (bgp); |
2016 | ||
718e3744 | 2017 | return CMD_SUCCESS; |
2018 | } | |
2019 | ||
2020 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
2021 | no_bgp_bestpath_aspath_ignore_cmd, | |
2022 | "no bgp bestpath as-path ignore", | |
2023 | NO_STR | |
2024 | "BGP specific commands\n" | |
2025 | "Change the default bestpath selection\n" | |
2026 | "AS-path attribute\n" | |
2027 | "Ignore as-path length in selecting a route\n") | |
2028 | { | |
cdc2d765 | 2029 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2030 | bgp_flag_unset (bgp, BGP_FLAG_ASPATH_IGNORE); |
7aafcaca DS |
2031 | bgp_recalculate_all_bestpaths (bgp); |
2032 | ||
718e3744 | 2033 | return CMD_SUCCESS; |
2034 | } | |
6b0655a2 | 2035 | |
6811845b | 2036 | /* "bgp bestpath as-path confed" configuration. */ |
2037 | DEFUN (bgp_bestpath_aspath_confed, | |
2038 | bgp_bestpath_aspath_confed_cmd, | |
2039 | "bgp bestpath as-path confed", | |
2040 | "BGP specific commands\n" | |
2041 | "Change the default bestpath selection\n" | |
2042 | "AS-path attribute\n" | |
2043 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2044 | { | |
cdc2d765 | 2045 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6811845b | 2046 | bgp_flag_set (bgp, BGP_FLAG_ASPATH_CONFED); |
7aafcaca DS |
2047 | bgp_recalculate_all_bestpaths (bgp); |
2048 | ||
6811845b | 2049 | return CMD_SUCCESS; |
2050 | } | |
2051 | ||
2052 | DEFUN (no_bgp_bestpath_aspath_confed, | |
2053 | no_bgp_bestpath_aspath_confed_cmd, | |
2054 | "no bgp bestpath as-path confed", | |
2055 | NO_STR | |
2056 | "BGP specific commands\n" | |
2057 | "Change the default bestpath selection\n" | |
2058 | "AS-path attribute\n" | |
2059 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2060 | { | |
cdc2d765 | 2061 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6811845b | 2062 | bgp_flag_unset (bgp, BGP_FLAG_ASPATH_CONFED); |
7aafcaca DS |
2063 | bgp_recalculate_all_bestpaths (bgp); |
2064 | ||
6811845b | 2065 | return CMD_SUCCESS; |
2066 | } | |
6b0655a2 | 2067 | |
2fdd455c PM |
2068 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
2069 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
2070 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2071 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2072 | "BGP specific commands\n" |
2073 | "Change the default bestpath selection\n" | |
2074 | "AS-path attribute\n" | |
2075 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2076 | "Generate an AS_SET\n" |
16fc1eec DS |
2077 | "Do not generate an AS_SET\n") |
2078 | { | |
cdc2d765 | 2079 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4c4ff4c1 | 2080 | int idx = 0; |
16fc1eec | 2081 | bgp_flag_set (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); |
219178b6 DW |
2082 | |
2083 | /* no-as-set is now the default behavior so we can silently | |
2084 | * ignore it */ | |
4c4ff4c1 | 2085 | if (argv_find (argv, argc, "as-set", &idx)) |
219178b6 DW |
2086 | bgp_flag_set (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
2087 | else | |
2088 | bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET) ; | |
2089 | ||
7aafcaca DS |
2090 | bgp_recalculate_all_bestpaths (bgp); |
2091 | ||
16fc1eec DS |
2092 | return CMD_SUCCESS; |
2093 | } | |
2094 | ||
219178b6 DW |
2095 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
2096 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2097 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2098 | NO_STR |
2099 | "BGP specific commands\n" | |
2100 | "Change the default bestpath selection\n" | |
2101 | "AS-path attribute\n" | |
2102 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2103 | "Generate an AS_SET\n" |
16fc1eec DS |
2104 | "Do not generate an AS_SET\n") |
2105 | { | |
cdc2d765 | 2106 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
16fc1eec | 2107 | bgp_flag_unset (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); |
219178b6 | 2108 | bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
7aafcaca DS |
2109 | bgp_recalculate_all_bestpaths (bgp); |
2110 | ||
2fdd455c PM |
2111 | return CMD_SUCCESS; |
2112 | } | |
6b0655a2 | 2113 | |
848973c7 | 2114 | /* "bgp log-neighbor-changes" configuration. */ |
2115 | DEFUN (bgp_log_neighbor_changes, | |
2116 | bgp_log_neighbor_changes_cmd, | |
2117 | "bgp log-neighbor-changes", | |
2118 | "BGP specific commands\n" | |
2119 | "Log neighbor up/down and reset reason\n") | |
2120 | { | |
cdc2d765 | 2121 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
848973c7 | 2122 | bgp_flag_set (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
2123 | return CMD_SUCCESS; | |
2124 | } | |
2125 | ||
2126 | DEFUN (no_bgp_log_neighbor_changes, | |
2127 | no_bgp_log_neighbor_changes_cmd, | |
2128 | "no bgp log-neighbor-changes", | |
2129 | NO_STR | |
2130 | "BGP specific commands\n" | |
2131 | "Log neighbor up/down and reset reason\n") | |
2132 | { | |
cdc2d765 | 2133 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
848973c7 | 2134 | bgp_flag_unset (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
2135 | return CMD_SUCCESS; | |
2136 | } | |
6b0655a2 | 2137 | |
718e3744 | 2138 | /* "bgp bestpath med" configuration. */ |
2139 | DEFUN (bgp_bestpath_med, | |
2140 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 2141 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2142 | "BGP specific commands\n" |
2143 | "Change the default bestpath selection\n" | |
2144 | "MED attribute\n" | |
2145 | "Compare MED among confederation paths\n" | |
838758ac DW |
2146 | "Treat missing MED as the least preferred one\n" |
2147 | "Treat missing MED as the least preferred one\n" | |
2148 | "Compare MED among confederation paths\n") | |
718e3744 | 2149 | { |
cdc2d765 | 2150 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6cbd1915 QY |
2151 | |
2152 | int idx = 0; | |
2153 | if (argv_find (argv, argc, "confed", &idx)) | |
2154 | bgp_flag_set (bgp, BGP_FLAG_MED_CONFED); | |
2155 | idx = 0; | |
2156 | if (argv_find (argv, argc, "missing-as-worst", &idx)) | |
2157 | bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
e52702f2 | 2158 | |
7aafcaca DS |
2159 | bgp_recalculate_all_bestpaths (bgp); |
2160 | ||
718e3744 | 2161 | return CMD_SUCCESS; |
2162 | } | |
2163 | ||
718e3744 | 2164 | DEFUN (no_bgp_bestpath_med, |
2165 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2166 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2167 | NO_STR |
2168 | "BGP specific commands\n" | |
2169 | "Change the default bestpath selection\n" | |
2170 | "MED attribute\n" | |
2171 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2172 | "Treat missing MED as the least preferred one\n" |
2173 | "Treat missing MED as the least preferred one\n" | |
2174 | "Compare MED among confederation paths\n") | |
718e3744 | 2175 | { |
cdc2d765 | 2176 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
e52702f2 | 2177 | |
6cbd1915 QY |
2178 | int idx = 0; |
2179 | if (argv_find (argv, argc, "confed", &idx)) | |
718e3744 | 2180 | bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED); |
6cbd1915 QY |
2181 | idx = 0; |
2182 | if (argv_find (argv, argc, "missing-as-worst", &idx)) | |
718e3744 | 2183 | bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST); |
2184 | ||
7aafcaca DS |
2185 | bgp_recalculate_all_bestpaths (bgp); |
2186 | ||
718e3744 | 2187 | return CMD_SUCCESS; |
2188 | } | |
2189 | ||
718e3744 | 2190 | /* "no bgp default ipv4-unicast". */ |
2191 | DEFUN (no_bgp_default_ipv4_unicast, | |
2192 | no_bgp_default_ipv4_unicast_cmd, | |
2193 | "no bgp default ipv4-unicast", | |
2194 | NO_STR | |
2195 | "BGP specific commands\n" | |
2196 | "Configure BGP defaults\n" | |
2197 | "Activate ipv4-unicast for a peer by default\n") | |
2198 | { | |
cdc2d765 | 2199 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2200 | bgp_flag_set (bgp, BGP_FLAG_NO_DEFAULT_IPV4); |
2201 | return CMD_SUCCESS; | |
2202 | } | |
2203 | ||
2204 | DEFUN (bgp_default_ipv4_unicast, | |
2205 | bgp_default_ipv4_unicast_cmd, | |
2206 | "bgp default ipv4-unicast", | |
2207 | "BGP specific commands\n" | |
2208 | "Configure BGP defaults\n" | |
2209 | "Activate ipv4-unicast for a peer by default\n") | |
2210 | { | |
cdc2d765 | 2211 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2212 | bgp_flag_unset (bgp, BGP_FLAG_NO_DEFAULT_IPV4); |
2213 | return CMD_SUCCESS; | |
2214 | } | |
6b0655a2 | 2215 | |
04b6bdc0 DW |
2216 | /* Display hostname in certain command outputs */ |
2217 | DEFUN (bgp_default_show_hostname, | |
2218 | bgp_default_show_hostname_cmd, | |
2219 | "bgp default show-hostname", | |
2220 | "BGP specific commands\n" | |
2221 | "Configure BGP defaults\n" | |
2222 | "Show hostname in certain command ouputs\n") | |
2223 | { | |
cdc2d765 | 2224 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
04b6bdc0 DW |
2225 | bgp_flag_set (bgp, BGP_FLAG_SHOW_HOSTNAME); |
2226 | return CMD_SUCCESS; | |
2227 | } | |
2228 | ||
2229 | DEFUN (no_bgp_default_show_hostname, | |
2230 | no_bgp_default_show_hostname_cmd, | |
2231 | "no bgp default show-hostname", | |
2232 | NO_STR | |
2233 | "BGP specific commands\n" | |
2234 | "Configure BGP defaults\n" | |
2235 | "Show hostname in certain command ouputs\n") | |
2236 | { | |
cdc2d765 | 2237 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
04b6bdc0 DW |
2238 | bgp_flag_unset (bgp, BGP_FLAG_SHOW_HOSTNAME); |
2239 | return CMD_SUCCESS; | |
2240 | } | |
2241 | ||
8233ef81 | 2242 | /* "bgp network import-check" configuration. */ |
718e3744 | 2243 | DEFUN (bgp_network_import_check, |
2244 | bgp_network_import_check_cmd, | |
5623e905 | 2245 | "bgp network import-check", |
718e3744 | 2246 | "BGP specific commands\n" |
2247 | "BGP network command\n" | |
5623e905 | 2248 | "Check BGP network route exists in IGP\n") |
718e3744 | 2249 | { |
cdc2d765 | 2250 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
078430f6 DS |
2251 | if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) |
2252 | { | |
2253 | bgp_flag_set (bgp, BGP_FLAG_IMPORT_CHECK); | |
5623e905 | 2254 | bgp_static_redo_import_check(bgp); |
078430f6 DS |
2255 | } |
2256 | ||
718e3744 | 2257 | return CMD_SUCCESS; |
2258 | } | |
2259 | ||
8233ef81 DW |
2260 | ALIAS_HIDDEN (bgp_network_import_check, |
2261 | bgp_network_import_check_exact_cmd, | |
2262 | "bgp network import-check exact", | |
2263 | "BGP specific commands\n" | |
2264 | "BGP network command\n" | |
2265 | "Check BGP network route exists in IGP\n" | |
2266 | "Match route precisely\n") | |
2267 | ||
718e3744 | 2268 | DEFUN (no_bgp_network_import_check, |
2269 | no_bgp_network_import_check_cmd, | |
5623e905 | 2270 | "no bgp network import-check", |
718e3744 | 2271 | NO_STR |
2272 | "BGP specific commands\n" | |
2273 | "BGP network command\n" | |
2274 | "Check BGP network route exists in IGP\n") | |
2275 | { | |
cdc2d765 | 2276 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
078430f6 DS |
2277 | if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) |
2278 | { | |
2279 | bgp_flag_unset (bgp, BGP_FLAG_IMPORT_CHECK); | |
078430f6 DS |
2280 | bgp_static_redo_import_check(bgp); |
2281 | } | |
5623e905 | 2282 | |
718e3744 | 2283 | return CMD_SUCCESS; |
2284 | } | |
6b0655a2 | 2285 | |
718e3744 | 2286 | DEFUN (bgp_default_local_preference, |
2287 | bgp_default_local_preference_cmd, | |
6147e2c6 | 2288 | "bgp default local-preference (0-4294967295)", |
718e3744 | 2289 | "BGP specific commands\n" |
2290 | "Configure BGP defaults\n" | |
2291 | "local preference (higher=more preferred)\n" | |
2292 | "Configure default local preference value\n") | |
2293 | { | |
cdc2d765 | 2294 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2295 | int idx_number = 3; |
718e3744 | 2296 | u_int32_t local_pref; |
2297 | ||
c500ae40 | 2298 | VTY_GET_INTEGER ("local preference", local_pref, argv[idx_number]->arg); |
718e3744 | 2299 | |
2300 | bgp_default_local_preference_set (bgp, local_pref); | |
f31fa004 | 2301 | bgp_clear_star_soft_in (vty, bgp->name); |
718e3744 | 2302 | |
2303 | return CMD_SUCCESS; | |
2304 | } | |
2305 | ||
2306 | DEFUN (no_bgp_default_local_preference, | |
2307 | no_bgp_default_local_preference_cmd, | |
838758ac | 2308 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 2309 | NO_STR |
2310 | "BGP specific commands\n" | |
2311 | "Configure BGP defaults\n" | |
838758ac DW |
2312 | "local preference (higher=more preferred)\n" |
2313 | "Configure default local preference value\n") | |
718e3744 | 2314 | { |
cdc2d765 | 2315 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2316 | bgp_default_local_preference_unset (bgp); |
f31fa004 | 2317 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 2318 | |
718e3744 | 2319 | return CMD_SUCCESS; |
2320 | } | |
2321 | ||
6b0655a2 | 2322 | |
3f9c7369 DS |
2323 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
2324 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 2325 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
2326 | "BGP specific commands\n" |
2327 | "Configure BGP defaults\n" | |
2328 | "subgroup-pkt-queue-max\n" | |
2329 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 2330 | { |
cdc2d765 | 2331 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2332 | int idx_number = 3; |
3f9c7369 | 2333 | u_int32_t max_size; |
8bd9d948 | 2334 | |
c500ae40 | 2335 | VTY_GET_INTEGER ("subgroup packet queue max", max_size, argv[idx_number]->arg); |
3f9c7369 DS |
2336 | |
2337 | bgp_default_subgroup_pkt_queue_max_set (bgp, max_size); | |
2338 | ||
2339 | return CMD_SUCCESS; | |
2340 | } | |
2341 | ||
2342 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
2343 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 2344 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
2345 | NO_STR |
2346 | "BGP specific commands\n" | |
2347 | "Configure BGP defaults\n" | |
838758ac DW |
2348 | "subgroup-pkt-queue-max\n" |
2349 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 2350 | { |
cdc2d765 | 2351 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3f9c7369 DS |
2352 | bgp_default_subgroup_pkt_queue_max_unset (bgp); |
2353 | return CMD_SUCCESS; | |
8bd9d948 DS |
2354 | } |
2355 | ||
813d4307 | 2356 | |
8bd9d948 DS |
2357 | DEFUN (bgp_rr_allow_outbound_policy, |
2358 | bgp_rr_allow_outbound_policy_cmd, | |
2359 | "bgp route-reflector allow-outbound-policy", | |
2360 | "BGP specific commands\n" | |
2361 | "Allow modifications made by out route-map\n" | |
2362 | "on ibgp neighbors\n") | |
2363 | { | |
cdc2d765 | 2364 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 DS |
2365 | |
2366 | if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) | |
2367 | { | |
2368 | bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3f9c7369 | 2369 | update_group_announce_rrclients(bgp); |
f31fa004 | 2370 | bgp_clear_star_soft_out (vty, bgp->name); |
8bd9d948 DS |
2371 | } |
2372 | ||
2373 | return CMD_SUCCESS; | |
2374 | } | |
2375 | ||
2376 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
2377 | no_bgp_rr_allow_outbound_policy_cmd, | |
2378 | "no bgp route-reflector allow-outbound-policy", | |
2379 | NO_STR | |
2380 | "BGP specific commands\n" | |
2381 | "Allow modifications made by out route-map\n" | |
2382 | "on ibgp neighbors\n") | |
2383 | { | |
cdc2d765 | 2384 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 DS |
2385 | |
2386 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) | |
2387 | { | |
2388 | bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3f9c7369 | 2389 | update_group_announce_rrclients(bgp); |
f31fa004 | 2390 | bgp_clear_star_soft_out (vty, bgp->name); |
8bd9d948 DS |
2391 | } |
2392 | ||
2393 | return CMD_SUCCESS; | |
2394 | } | |
2395 | ||
f14e6fdb DS |
2396 | DEFUN (bgp_listen_limit, |
2397 | bgp_listen_limit_cmd, | |
9ccf14f7 | 2398 | "bgp listen limit (1-5000)", |
f14e6fdb DS |
2399 | "BGP specific commands\n" |
2400 | "Configure BGP defaults\n" | |
2401 | "maximum number of BGP Dynamic Neighbors that can be created\n" | |
2402 | "Configure Dynamic Neighbors listen limit value\n") | |
2403 | { | |
cdc2d765 | 2404 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2405 | int idx_number = 3; |
f14e6fdb DS |
2406 | int listen_limit; |
2407 | ||
c500ae40 | 2408 | VTY_GET_INTEGER_RANGE ("listen limit", listen_limit, argv[idx_number]->arg, |
f14e6fdb DS |
2409 | BGP_DYNAMIC_NEIGHBORS_LIMIT_MIN, |
2410 | BGP_DYNAMIC_NEIGHBORS_LIMIT_MAX); | |
2411 | ||
2412 | bgp_listen_limit_set (bgp, listen_limit); | |
2413 | ||
2414 | return CMD_SUCCESS; | |
2415 | } | |
2416 | ||
2417 | DEFUN (no_bgp_listen_limit, | |
2418 | no_bgp_listen_limit_cmd, | |
838758ac | 2419 | "no bgp listen limit [(1-5000)]", |
f14e6fdb DS |
2420 | "BGP specific commands\n" |
2421 | "Configure BGP defaults\n" | |
2422 | "unset maximum number of BGP Dynamic Neighbors that can be created\n" | |
838758ac DW |
2423 | "Configure Dynamic Neighbors listen limit value to default\n" |
2424 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 2425 | { |
cdc2d765 | 2426 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f14e6fdb DS |
2427 | bgp_listen_limit_unset (bgp); |
2428 | return CMD_SUCCESS; | |
2429 | } | |
2430 | ||
2431 | ||
20eb8864 | 2432 | /* |
2433 | * Check if this listen range is already configured. Check for exact | |
2434 | * match or overlap based on input. | |
2435 | */ | |
2436 | static struct peer_group * | |
2437 | listen_range_exists (struct bgp *bgp, struct prefix *range, int exact) | |
2438 | { | |
2439 | struct listnode *node, *nnode; | |
2440 | struct listnode *node1, *nnode1; | |
2441 | struct peer_group *group; | |
2442 | struct prefix *lr; | |
2443 | afi_t afi; | |
2444 | int match; | |
2445 | ||
2446 | afi = family2afi(range->family); | |
2447 | for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) | |
2448 | { | |
2449 | for (ALL_LIST_ELEMENTS (group->listen_range[afi], node1, | |
2450 | nnode1, lr)) | |
2451 | { | |
2452 | if (exact) | |
2453 | match = prefix_same (range, lr); | |
2454 | else | |
2455 | match = (prefix_match (range, lr) || prefix_match (lr, range)); | |
2456 | if (match) | |
2457 | return group; | |
2458 | } | |
2459 | } | |
2460 | ||
2461 | return NULL; | |
2462 | } | |
2463 | ||
f14e6fdb DS |
2464 | DEFUN (bgp_listen_range, |
2465 | bgp_listen_range_cmd, | |
9ccf14f7 | 2466 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
f14e6fdb | 2467 | "BGP specific commands\n" |
d7fa34c1 QY |
2468 | "Configure BGP dynamic neighbors listen range\n" |
2469 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
2470 | NEIGHBOR_ADDR_STR |
2471 | "Member of the peer-group\n" | |
2472 | "Peer-group name\n") | |
f14e6fdb | 2473 | { |
cdc2d765 | 2474 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f14e6fdb | 2475 | struct prefix range; |
20eb8864 | 2476 | struct peer_group *group, *existing_group; |
f14e6fdb DS |
2477 | afi_t afi; |
2478 | int ret; | |
d7fa34c1 | 2479 | int idx = 0; |
f14e6fdb | 2480 | |
d7fa34c1 QY |
2481 | argv_find (argv, argc, "A.B.C.D/M", &idx); |
2482 | argv_find (argv, argc, "X:X::X:X/M", &idx); | |
2483 | char *prefix = argv[idx]->arg; | |
2484 | argv_find (argv, argc, "WORD", &idx); | |
2485 | char *peergroup = argv[idx]->arg; | |
f14e6fdb | 2486 | |
f14e6fdb | 2487 | /* Convert IP prefix string to struct prefix. */ |
d7fa34c1 | 2488 | ret = str2prefix (prefix, &range); |
f14e6fdb DS |
2489 | if (! ret) |
2490 | { | |
2491 | vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE); | |
2492 | return CMD_WARNING; | |
2493 | } | |
2494 | ||
2495 | afi = family2afi(range.family); | |
2496 | ||
f14e6fdb DS |
2497 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6)) |
2498 | { | |
2499 | vty_out (vty, "%% Malformed listen range (link-local address)%s", | |
2500 | VTY_NEWLINE); | |
2501 | return CMD_WARNING; | |
2502 | } | |
f14e6fdb DS |
2503 | |
2504 | apply_mask (&range); | |
2505 | ||
20eb8864 | 2506 | /* Check if same listen range is already configured. */ |
2507 | existing_group = listen_range_exists (bgp, &range, 1); | |
2508 | if (existing_group) | |
2509 | { | |
d7fa34c1 | 2510 | if (strcmp (existing_group->name, peergroup) == 0) |
20eb8864 | 2511 | return CMD_SUCCESS; |
2512 | else | |
2513 | { | |
2514 | vty_out (vty, "%% Same listen range is attached to peer-group %s%s", | |
2515 | existing_group->name, VTY_NEWLINE); | |
2516 | return CMD_WARNING; | |
2517 | } | |
2518 | } | |
2519 | ||
2520 | /* Check if an overlapping listen range exists. */ | |
2521 | if (listen_range_exists (bgp, &range, 0)) | |
2522 | { | |
2523 | vty_out (vty, "%% Listen range overlaps with existing listen range%s", | |
2524 | VTY_NEWLINE); | |
2525 | return CMD_WARNING; | |
2526 | } | |
f14e6fdb | 2527 | |
d7fa34c1 | 2528 | group = peer_group_lookup (bgp, peergroup); |
f14e6fdb DS |
2529 | if (! group) |
2530 | { | |
2531 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
2532 | return CMD_WARNING; | |
2533 | } | |
2534 | ||
2535 | ret = peer_group_listen_range_add(group, &range); | |
2536 | return bgp_vty_return (vty, ret); | |
2537 | } | |
2538 | ||
2539 | DEFUN (no_bgp_listen_range, | |
2540 | no_bgp_listen_range_cmd, | |
d7fa34c1 QY |
2541 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
2542 | NO_STR | |
f14e6fdb | 2543 | "BGP specific commands\n" |
d7fa34c1 QY |
2544 | "Unconfigure BGP dynamic neighbors listen range\n" |
2545 | "Unconfigure BGP dynamic neighbors listen range\n" | |
2546 | NEIGHBOR_ADDR_STR | |
2547 | "Member of the peer-group\n" | |
2548 | "Peer-group name\n") | |
f14e6fdb | 2549 | { |
cdc2d765 | 2550 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f14e6fdb DS |
2551 | struct prefix range; |
2552 | struct peer_group *group; | |
2553 | afi_t afi; | |
2554 | int ret; | |
d7fa34c1 QY |
2555 | int idx = 0; |
2556 | ||
2557 | argv_find (argv, argc, "A.B.C.D/M", &idx); | |
2558 | argv_find (argv, argc, "X:X::X:X/M", &idx); | |
2559 | char *prefix = argv[idx]->arg; | |
2560 | argv_find (argv, argc, "WORD", &idx); | |
2561 | char *peergroup = argv[idx]->arg; | |
f14e6fdb | 2562 | |
c500ae40 | 2563 | // VTY_GET_IPV4_PREFIX ("listen range", range, argv[idx_ipv4_prefixlen]->arg); |
f14e6fdb DS |
2564 | |
2565 | /* Convert IP prefix string to struct prefix. */ | |
d7fa34c1 | 2566 | ret = str2prefix (prefix, &range); |
f14e6fdb DS |
2567 | if (! ret) |
2568 | { | |
2569 | vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE); | |
2570 | return CMD_WARNING; | |
2571 | } | |
2572 | ||
2573 | afi = family2afi(range.family); | |
2574 | ||
f14e6fdb DS |
2575 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6)) |
2576 | { | |
2577 | vty_out (vty, "%% Malformed listen range (link-local address)%s", | |
2578 | VTY_NEWLINE); | |
2579 | return CMD_WARNING; | |
2580 | } | |
f14e6fdb DS |
2581 | |
2582 | apply_mask (&range); | |
2583 | ||
d7fa34c1 | 2584 | group = peer_group_lookup (bgp, peergroup); |
f14e6fdb DS |
2585 | if (! group) |
2586 | { | |
2587 | vty_out (vty, "%% Peer-group does not exist%s", VTY_NEWLINE); | |
2588 | return CMD_WARNING; | |
2589 | } | |
2590 | ||
2591 | ret = peer_group_listen_range_del(group, &range); | |
2592 | return bgp_vty_return (vty, ret); | |
2593 | } | |
2594 | ||
2595 | int | |
2596 | bgp_config_write_listen (struct vty *vty, struct bgp *bgp) | |
2597 | { | |
2598 | struct peer_group *group; | |
2599 | struct listnode *node, *nnode, *rnode, *nrnode; | |
2600 | struct prefix *range; | |
2601 | afi_t afi; | |
4690c7d7 | 2602 | char buf[PREFIX2STR_BUFFER]; |
f14e6fdb DS |
2603 | |
2604 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
2605 | vty_out (vty, " bgp listen limit %d%s", | |
2606 | bgp->dynamic_neighbors_limit, VTY_NEWLINE); | |
2607 | ||
2608 | for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) | |
2609 | { | |
2610 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
2611 | { | |
2612 | for (ALL_LIST_ELEMENTS (group->listen_range[afi], rnode, nrnode, range)) | |
2613 | { | |
2614 | prefix2str(range, buf, sizeof(buf)); | |
2615 | vty_out(vty, " bgp listen range %s peer-group %s%s", | |
2616 | buf, group->name, VTY_NEWLINE); | |
2617 | } | |
2618 | } | |
2619 | } | |
2620 | ||
2621 | return 0; | |
2622 | } | |
2623 | ||
2624 | ||
907f92c8 DS |
2625 | DEFUN (bgp_disable_connected_route_check, |
2626 | bgp_disable_connected_route_check_cmd, | |
2627 | "bgp disable-ebgp-connected-route-check", | |
2628 | "BGP specific commands\n" | |
2629 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2630 | { | |
cdc2d765 | 2631 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
907f92c8 | 2632 | bgp_flag_set (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); |
f31fa004 | 2633 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 2634 | |
907f92c8 DS |
2635 | return CMD_SUCCESS; |
2636 | } | |
2637 | ||
2638 | DEFUN (no_bgp_disable_connected_route_check, | |
2639 | no_bgp_disable_connected_route_check_cmd, | |
2640 | "no bgp disable-ebgp-connected-route-check", | |
2641 | NO_STR | |
2642 | "BGP specific commands\n" | |
2643 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2644 | { | |
cdc2d765 | 2645 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
907f92c8 | 2646 | bgp_flag_unset (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); |
f31fa004 | 2647 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 2648 | |
907f92c8 DS |
2649 | return CMD_SUCCESS; |
2650 | } | |
2651 | ||
2652 | ||
718e3744 | 2653 | static int |
e52702f2 | 2654 | peer_remote_as_vty (struct vty *vty, const char *peer_str, |
fd79ac91 | 2655 | const char *as_str, afi_t afi, safi_t safi) |
718e3744 | 2656 | { |
cdc2d765 | 2657 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2658 | int ret; |
718e3744 | 2659 | as_t as; |
0299c004 | 2660 | int as_type = AS_SPECIFIED; |
718e3744 | 2661 | union sockunion su; |
2662 | ||
7ae5fc81 | 2663 | if (as_str[0] == 'i') |
0299c004 DS |
2664 | { |
2665 | as = 0; | |
2666 | as_type = AS_INTERNAL; | |
2667 | } | |
7ae5fc81 | 2668 | else if (as_str[0] == 'e') |
0299c004 DS |
2669 | { |
2670 | as = 0; | |
2671 | as_type = AS_EXTERNAL; | |
2672 | } | |
2673 | else | |
2674 | { | |
2675 | /* Get AS number. */ | |
2676 | VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX); | |
2677 | } | |
718e3744 | 2678 | |
2679 | /* If peer is peer group, call proper function. */ | |
2680 | ret = str2sockunion (peer_str, &su); | |
2681 | if (ret < 0) | |
2682 | { | |
a80beece | 2683 | /* Check for peer by interface */ |
0299c004 | 2684 | ret = peer_remote_as (bgp, NULL, peer_str, &as, as_type, afi, safi); |
718e3744 | 2685 | if (ret < 0) |
a80beece | 2686 | { |
0299c004 | 2687 | ret = peer_group_remote_as (bgp, peer_str, &as, as_type); |
a80beece DS |
2688 | if (ret < 0) |
2689 | { | |
2690 | vty_out (vty, "%% Create the peer-group or interface first%s", | |
2691 | VTY_NEWLINE); | |
2692 | return CMD_WARNING; | |
2693 | } | |
2694 | return CMD_SUCCESS; | |
2695 | } | |
718e3744 | 2696 | } |
a80beece | 2697 | else |
718e3744 | 2698 | { |
6aeb9e78 | 2699 | if (peer_address_self_check (bgp, &su)) |
a80beece DS |
2700 | { |
2701 | vty_out (vty, "%% Can not configure the local system as neighbor%s", | |
2702 | VTY_NEWLINE); | |
2703 | return CMD_WARNING; | |
2704 | } | |
0299c004 | 2705 | ret = peer_remote_as (bgp, &su, NULL, &as, as_type, afi, safi); |
718e3744 | 2706 | } |
2707 | ||
718e3744 | 2708 | /* This peer belongs to peer group. */ |
2709 | switch (ret) | |
2710 | { | |
2711 | case BGP_ERR_PEER_GROUP_MEMBER: | |
aea339f7 | 2712 | vty_out (vty, "%% Peer-group AS %u. Cannot configure remote-as for member%s", as, VTY_NEWLINE); |
718e3744 | 2713 | return CMD_WARNING; |
718e3744 | 2714 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: |
aea339f7 | 2715 | 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 | 2716 | return CMD_WARNING; |
718e3744 | 2717 | } |
2718 | return bgp_vty_return (vty, ret); | |
2719 | } | |
2720 | ||
2721 | DEFUN (neighbor_remote_as, | |
2722 | neighbor_remote_as_cmd, | |
3a2d747c | 2723 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2724 | NEIGHBOR_STR |
2725 | NEIGHBOR_ADDR_STR2 | |
2726 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 2727 | AS_STR |
3a2d747c QY |
2728 | "Internal BGP peer\n" |
2729 | "External BGP peer\n") | |
718e3744 | 2730 | { |
c500ae40 DW |
2731 | int idx_peer = 1; |
2732 | int idx_remote_as = 3; | |
2733 | return peer_remote_as_vty (vty, argv[idx_peer]->arg, argv[idx_remote_as]->arg, AFI_IP, SAFI_UNICAST); | |
718e3744 | 2734 | } |
6b0655a2 | 2735 | |
4c48cf63 DW |
2736 | static int |
2737 | peer_conf_interface_get (struct vty *vty, const char *conf_if, afi_t afi, | |
b3a39dc5 DD |
2738 | safi_t safi, int v6only, const char *peer_group_name, |
2739 | const char *as_str) | |
a80beece | 2740 | { |
cdc2d765 | 2741 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
b3a39dc5 DD |
2742 | as_t as = 0; |
2743 | int as_type = AS_UNSPECIFIED; | |
a80beece DS |
2744 | struct peer *peer; |
2745 | struct peer_group *group; | |
4c48cf63 DW |
2746 | int ret = 0; |
2747 | union sockunion su; | |
a80beece | 2748 | |
4c48cf63 DW |
2749 | group = peer_group_lookup (bgp, conf_if); |
2750 | ||
a80beece DS |
2751 | if (group) |
2752 | { | |
2753 | vty_out (vty, "%% Name conflict with peer-group %s", VTY_NEWLINE); | |
2754 | return CMD_WARNING; | |
2755 | } | |
2756 | ||
b3a39dc5 DD |
2757 | if (as_str) |
2758 | { | |
7ae5fc81 | 2759 | if (as_str[0] == 'i') |
b3a39dc5 DD |
2760 | { |
2761 | as_type = AS_INTERNAL; | |
2762 | } | |
7ae5fc81 | 2763 | else if (as_str[0] == 'e') |
b3a39dc5 DD |
2764 | { |
2765 | as_type = AS_EXTERNAL; | |
2766 | } | |
2767 | else | |
2768 | { | |
2769 | /* Get AS number. */ | |
2770 | VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX); | |
2771 | as_type = AS_SPECIFIED; | |
2772 | } | |
2773 | } | |
2774 | ||
4c48cf63 | 2775 | peer = peer_lookup_by_conf_if (bgp, conf_if); |
464598de DW |
2776 | if (peer) |
2777 | { | |
2778 | if (as_str) | |
3bd07551 | 2779 | ret = peer_remote_as (bgp, &su, conf_if, &as, as_type, afi, safi); |
464598de DW |
2780 | } |
2781 | else | |
4c48cf63 DW |
2782 | { |
2783 | if (bgp_flag_check (bgp, BGP_FLAG_NO_DEFAULT_IPV4) | |
2784 | && afi == AFI_IP && safi == SAFI_UNICAST) | |
b3a39dc5 DD |
2785 | peer = peer_create (NULL, conf_if, bgp, bgp->as, as, as_type, 0, 0, |
2786 | NULL); | |
4c48cf63 | 2787 | else |
b3a39dc5 DD |
2788 | peer = peer_create (NULL, conf_if, bgp, bgp->as, as, as_type, afi, safi, |
2789 | NULL); | |
4c48cf63 | 2790 | |
c358f112 DS |
2791 | if (!peer) |
2792 | return CMD_WARNING; | |
2793 | ||
2794 | if (v6only) | |
4c48cf63 | 2795 | SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); |
4a04e5f7 | 2796 | |
2797 | /* Request zebra to initiate IPv6 RAs on this interface. We do this | |
2798 | * any unnumbered peer in order to not worry about run-time transitions | |
2799 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 address | |
2800 | * gets deleted later etc.) | |
2801 | */ | |
2802 | if (peer->ifp) | |
c358f112 | 2803 | bgp_zebra_initiate_radv (bgp, peer); |
4c48cf63 | 2804 | } |
464598de DW |
2805 | |
2806 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) || | |
2807 | (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) | |
4c48cf63 DW |
2808 | { |
2809 | if (v6only) | |
2810 | SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2811 | else | |
2812 | UNSET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2813 | ||
2814 | /* v6only flag changed. Reset bgp seesion */ | |
2815 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) | |
2816 | { | |
2817 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
2818 | bgp_notify_send (peer, BGP_NOTIFY_CEASE, | |
2819 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2820 | } | |
2821 | else | |
2822 | bgp_session_reset(peer); | |
2823 | } | |
2824 | ||
c358f112 DS |
2825 | if (!CHECK_FLAG (peer->flags, PEER_FLAG_CAPABILITY_ENHE)) |
2826 | peer_flag_set (peer, PEER_FLAG_CAPABILITY_ENHE); | |
a80beece | 2827 | |
4c48cf63 DW |
2828 | if (peer_group_name) |
2829 | { | |
2830 | group = peer_group_lookup (bgp, peer_group_name); | |
2831 | if (! group) | |
2832 | { | |
2833 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
2834 | return CMD_WARNING; | |
2835 | } | |
2836 | ||
2837 | ret = peer_group_bind (bgp, &su, peer, group, &as); | |
2838 | } | |
2839 | ||
2840 | return bgp_vty_return (vty, ret); | |
a80beece DS |
2841 | } |
2842 | ||
4c48cf63 DW |
2843 | DEFUN (neighbor_interface_config, |
2844 | neighbor_interface_config_cmd, | |
31500417 | 2845 | "neighbor WORD interface [peer-group WORD]", |
4c48cf63 DW |
2846 | NEIGHBOR_STR |
2847 | "Interface name or neighbor tag\n" | |
31500417 DW |
2848 | "Enable BGP on interface\n" |
2849 | "Member of the peer-group\n" | |
16cedbb0 | 2850 | "Peer-group name\n") |
4c48cf63 | 2851 | { |
c500ae40 | 2852 | int idx_word = 1; |
31500417 DW |
2853 | int idx_peer_group_word = 4; |
2854 | ||
2855 | if (argc > idx_peer_group_word) | |
c500ae40 | 2856 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, |
31500417 | 2857 | argv[idx_peer_group_word]->arg, NULL); |
4c48cf63 | 2858 | else |
c500ae40 | 2859 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, |
b3a39dc5 | 2860 | NULL, NULL); |
4c48cf63 DW |
2861 | } |
2862 | ||
4c48cf63 DW |
2863 | DEFUN (neighbor_interface_config_v6only, |
2864 | neighbor_interface_config_v6only_cmd, | |
31500417 | 2865 | "neighbor WORD interface v6only [peer-group WORD]", |
4c48cf63 DW |
2866 | NEIGHBOR_STR |
2867 | "Interface name or neighbor tag\n" | |
2868 | "Enable BGP on interface\n" | |
31500417 DW |
2869 | "Enable BGP with v6 link-local only\n" |
2870 | "Member of the peer-group\n" | |
16cedbb0 | 2871 | "Peer-group name\n") |
4c48cf63 | 2872 | { |
c500ae40 | 2873 | int idx_word = 1; |
31500417 DW |
2874 | int idx_peer_group_word = 5; |
2875 | ||
2876 | if (argc > idx_peer_group_word) | |
2877 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
2878 | argv[idx_peer_group_word]->arg, NULL); | |
2879 | ||
c500ae40 | 2880 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, |
31500417 | 2881 | NULL, NULL); |
4c48cf63 DW |
2882 | } |
2883 | ||
a80beece | 2884 | |
b3a39dc5 DD |
2885 | DEFUN (neighbor_interface_config_remote_as, |
2886 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 2887 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2888 | NEIGHBOR_STR |
2889 | "Interface name or neighbor tag\n" | |
2890 | "Enable BGP on interface\n" | |
3a2d747c | 2891 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2892 | AS_STR |
3a2d747c QY |
2893 | "Internal BGP peer\n" |
2894 | "External BGP peer\n") | |
b3a39dc5 | 2895 | { |
c500ae40 DW |
2896 | int idx_word = 1; |
2897 | int idx_remote_as = 4; | |
2898 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
2899 | NULL, argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2900 | } |
2901 | ||
2902 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
2903 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 2904 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2905 | NEIGHBOR_STR |
2906 | "Interface name or neighbor tag\n" | |
3a2d747c | 2907 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 2908 | "Enable BGP on interface\n" |
3a2d747c | 2909 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2910 | AS_STR |
3a2d747c QY |
2911 | "Internal BGP peer\n" |
2912 | "External BGP peer\n") | |
b3a39dc5 | 2913 | { |
c500ae40 DW |
2914 | int idx_word = 1; |
2915 | int idx_remote_as = 5; | |
2916 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
2917 | NULL, argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2918 | } |
2919 | ||
718e3744 | 2920 | DEFUN (neighbor_peer_group, |
2921 | neighbor_peer_group_cmd, | |
2922 | "neighbor WORD peer-group", | |
2923 | NEIGHBOR_STR | |
a80beece | 2924 | "Interface name or neighbor tag\n" |
718e3744 | 2925 | "Configure peer-group\n") |
2926 | { | |
cdc2d765 | 2927 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2928 | int idx_word = 1; |
a80beece | 2929 | struct peer *peer; |
718e3744 | 2930 | struct peer_group *group; |
2931 | ||
c500ae40 | 2932 | peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg); |
a80beece DS |
2933 | if (peer) |
2934 | { | |
2935 | vty_out (vty, "%% Name conflict with interface: %s", VTY_NEWLINE); | |
2936 | return CMD_WARNING; | |
2937 | } | |
718e3744 | 2938 | |
c500ae40 | 2939 | group = peer_group_get (bgp, argv[idx_word]->arg); |
718e3744 | 2940 | if (! group) |
2941 | return CMD_WARNING; | |
2942 | ||
2943 | return CMD_SUCCESS; | |
2944 | } | |
2945 | ||
2946 | DEFUN (no_neighbor, | |
2947 | no_neighbor_cmd, | |
dab8cd00 | 2948 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 2949 | NO_STR |
2950 | NEIGHBOR_STR | |
3a2d747c QY |
2951 | NEIGHBOR_ADDR_STR2 |
2952 | "Specify a BGP neighbor\n" | |
2953 | AS_STR | |
2954 | "Internal BGP peer\n" | |
2955 | "External BGP peer\n") | |
718e3744 | 2956 | { |
cdc2d765 | 2957 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2958 | int idx_peer = 2; |
718e3744 | 2959 | int ret; |
2960 | union sockunion su; | |
2961 | struct peer_group *group; | |
2962 | struct peer *peer; | |
1ff9a340 | 2963 | struct peer *other; |
718e3744 | 2964 | |
c500ae40 | 2965 | ret = str2sockunion (argv[idx_peer]->arg, &su); |
718e3744 | 2966 | if (ret < 0) |
2967 | { | |
a80beece | 2968 | /* look up for neighbor by interface name config. */ |
cdc2d765 | 2969 | peer = peer_lookup_by_conf_if (bgp, argv[idx_peer]->arg); |
a80beece DS |
2970 | if (peer) |
2971 | { | |
4a04e5f7 | 2972 | /* Request zebra to terminate IPv6 RAs on this interface. */ |
2973 | if (peer->ifp) | |
2974 | bgp_zebra_terminate_radv (peer->bgp, peer); | |
a80beece DS |
2975 | peer_delete (peer); |
2976 | return CMD_SUCCESS; | |
2977 | } | |
2978 | ||
cdc2d765 | 2979 | group = peer_group_lookup (bgp, argv[idx_peer]->arg); |
718e3744 | 2980 | if (group) |
2981 | peer_group_delete (group); | |
2982 | else | |
2983 | { | |
2984 | vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE); | |
2985 | return CMD_WARNING; | |
2986 | } | |
2987 | } | |
2988 | else | |
2989 | { | |
cdc2d765 | 2990 | peer = peer_lookup (bgp, &su); |
718e3744 | 2991 | if (peer) |
1ff9a340 | 2992 | { |
f14e6fdb DS |
2993 | if (peer_dynamic_neighbor (peer)) |
2994 | { | |
2995 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
2996 | VTY_NEWLINE); | |
2997 | return CMD_WARNING; | |
2998 | } | |
2999 | ||
1ff9a340 DS |
3000 | other = peer->doppelganger; |
3001 | peer_delete (peer); | |
3002 | if (other && other->status != Deleted) | |
3003 | peer_delete(other); | |
3004 | } | |
718e3744 | 3005 | } |
3006 | ||
3007 | return CMD_SUCCESS; | |
3008 | } | |
3009 | ||
a80beece DS |
3010 | DEFUN (no_neighbor_interface_config, |
3011 | no_neighbor_interface_config_cmd, | |
31500417 | 3012 | "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
3013 | NO_STR |
3014 | NEIGHBOR_STR | |
3015 | "Interface name\n" | |
31500417 DW |
3016 | "Configure BGP on interface\n" |
3017 | "Enable BGP with v6 link-local only\n" | |
3018 | "Member of the peer-group\n" | |
16cedbb0 | 3019 | "Peer-group name\n" |
3a2d747c QY |
3020 | "Specify a BGP neighbor\n" |
3021 | AS_STR | |
3022 | "Internal BGP peer\n" | |
3023 | "External BGP peer\n") | |
a80beece | 3024 | { |
cdc2d765 | 3025 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 3026 | int idx_word = 2; |
a80beece DS |
3027 | struct peer *peer; |
3028 | ||
3029 | /* look up for neighbor by interface name config. */ | |
cdc2d765 | 3030 | peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg); |
a80beece DS |
3031 | if (peer) |
3032 | { | |
4a04e5f7 | 3033 | /* Request zebra to terminate IPv6 RAs on this interface. */ |
3034 | if (peer->ifp) | |
3035 | bgp_zebra_terminate_radv (peer->bgp, peer); | |
a80beece DS |
3036 | peer_delete (peer); |
3037 | } | |
3038 | else | |
3039 | { | |
3040 | vty_out (vty, "%% Create the bgp interface first%s", VTY_NEWLINE); | |
3041 | return CMD_WARNING; | |
3042 | } | |
3043 | return CMD_SUCCESS; | |
3044 | } | |
3045 | ||
718e3744 | 3046 | DEFUN (no_neighbor_peer_group, |
3047 | no_neighbor_peer_group_cmd, | |
3048 | "no neighbor WORD peer-group", | |
3049 | NO_STR | |
3050 | NEIGHBOR_STR | |
3051 | "Neighbor tag\n" | |
3052 | "Configure peer-group\n") | |
3053 | { | |
cdc2d765 | 3054 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 3055 | int idx_word = 2; |
718e3744 | 3056 | struct peer_group *group; |
3057 | ||
cdc2d765 | 3058 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 3059 | if (group) |
3060 | peer_group_delete (group); | |
3061 | else | |
3062 | { | |
3063 | vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE); | |
3064 | return CMD_WARNING; | |
3065 | } | |
3066 | return CMD_SUCCESS; | |
3067 | } | |
3068 | ||
a80beece DS |
3069 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
3070 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 3071 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3072 | NO_STR |
3073 | NEIGHBOR_STR | |
a80beece | 3074 | "Interface name or neighbor tag\n" |
718e3744 | 3075 | "Specify a BGP neighbor\n" |
3a2d747c QY |
3076 | AS_STR |
3077 | "Internal BGP peer\n" | |
3078 | "External BGP peer\n") | |
718e3744 | 3079 | { |
cdc2d765 | 3080 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 3081 | int idx_word = 2; |
718e3744 | 3082 | struct peer_group *group; |
a80beece DS |
3083 | struct peer *peer; |
3084 | ||
3085 | /* look up for neighbor by interface name config. */ | |
cdc2d765 | 3086 | peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg); |
a80beece DS |
3087 | if (peer) |
3088 | { | |
0299c004 | 3089 | peer_as_change (peer, 0, AS_SPECIFIED); |
a80beece DS |
3090 | return CMD_SUCCESS; |
3091 | } | |
718e3744 | 3092 | |
cdc2d765 | 3093 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 3094 | if (group) |
3095 | peer_group_remote_as_delete (group); | |
3096 | else | |
3097 | { | |
a80beece | 3098 | vty_out (vty, "%% Create the peer-group or interface first%s", VTY_NEWLINE); |
718e3744 | 3099 | return CMD_WARNING; |
3100 | } | |
3101 | return CMD_SUCCESS; | |
3102 | } | |
6b0655a2 | 3103 | |
718e3744 | 3104 | DEFUN (neighbor_local_as, |
3105 | neighbor_local_as_cmd, | |
9ccf14f7 | 3106 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 3107 | NEIGHBOR_STR |
3108 | NEIGHBOR_ADDR_STR2 | |
3109 | "Specify a local-as number\n" | |
3110 | "AS number used as local AS\n") | |
3111 | { | |
c500ae40 DW |
3112 | int idx_peer = 1; |
3113 | int idx_number = 3; | |
718e3744 | 3114 | struct peer *peer; |
3115 | int ret; | |
e14fda0f | 3116 | as_t as; |
718e3744 | 3117 | |
c500ae40 | 3118 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3119 | if (! peer) |
3120 | return CMD_WARNING; | |
3121 | ||
b6f1faf0 | 3122 | VTY_GET_INTEGER_RANGE ("Local AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); |
e14fda0f | 3123 | ret = peer_local_as_set (peer, as, 0, 0); |
718e3744 | 3124 | return bgp_vty_return (vty, ret); |
3125 | } | |
3126 | ||
3127 | DEFUN (neighbor_local_as_no_prepend, | |
3128 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 3129 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 3130 | NEIGHBOR_STR |
3131 | NEIGHBOR_ADDR_STR2 | |
3132 | "Specify a local-as number\n" | |
3133 | "AS number used as local AS\n" | |
3134 | "Do not prepend local-as to updates from ebgp peers\n") | |
3135 | { | |
c500ae40 DW |
3136 | int idx_peer = 1; |
3137 | int idx_number = 3; | |
718e3744 | 3138 | struct peer *peer; |
3139 | int ret; | |
e14fda0f | 3140 | as_t as; |
718e3744 | 3141 | |
c500ae40 | 3142 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3143 | if (! peer) |
3144 | return CMD_WARNING; | |
3145 | ||
b6f1faf0 | 3146 | VTY_GET_INTEGER_RANGE ("Local AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); |
e14fda0f | 3147 | ret = peer_local_as_set (peer, as, 1, 0); |
718e3744 | 3148 | return bgp_vty_return (vty, ret); |
3149 | } | |
3150 | ||
9d3f9705 AC |
3151 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
3152 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 3153 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
3154 | NEIGHBOR_STR |
3155 | NEIGHBOR_ADDR_STR2 | |
3156 | "Specify a local-as number\n" | |
3157 | "AS number used as local AS\n" | |
3158 | "Do not prepend local-as to updates from ebgp peers\n" | |
3159 | "Do not prepend local-as to updates from ibgp peers\n") | |
3160 | { | |
c500ae40 DW |
3161 | int idx_peer = 1; |
3162 | int idx_number = 3; | |
9d3f9705 AC |
3163 | struct peer *peer; |
3164 | int ret; | |
e14fda0f | 3165 | as_t as; |
9d3f9705 | 3166 | |
c500ae40 | 3167 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
9d3f9705 AC |
3168 | if (! peer) |
3169 | return CMD_WARNING; | |
3170 | ||
b6f1faf0 | 3171 | VTY_GET_INTEGER_RANGE ("Local AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); |
e14fda0f | 3172 | ret = peer_local_as_set (peer, as, 1, 1); |
9d3f9705 AC |
3173 | return bgp_vty_return (vty, ret); |
3174 | } | |
3175 | ||
718e3744 | 3176 | DEFUN (no_neighbor_local_as, |
3177 | no_neighbor_local_as_cmd, | |
a636c635 | 3178 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 3179 | NO_STR |
3180 | NEIGHBOR_STR | |
3181 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
3182 | "Specify a local-as number\n" |
3183 | "AS number used as local AS\n" | |
3184 | "Do not prepend local-as to updates from ebgp peers\n" | |
3185 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 3186 | { |
c500ae40 | 3187 | int idx_peer = 2; |
718e3744 | 3188 | struct peer *peer; |
3189 | int ret; | |
3190 | ||
c500ae40 | 3191 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3192 | if (! peer) |
3193 | return CMD_WARNING; | |
3194 | ||
3195 | ret = peer_local_as_unset (peer); | |
3196 | return bgp_vty_return (vty, ret); | |
3197 | } | |
3198 | ||
718e3744 | 3199 | |
9d3f9705 | 3200 | |
6b0655a2 | 3201 | |
3f9c7369 DS |
3202 | DEFUN (neighbor_solo, |
3203 | neighbor_solo_cmd, | |
9ccf14f7 | 3204 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3205 | NEIGHBOR_STR |
3206 | NEIGHBOR_ADDR_STR2 | |
3207 | "Solo peer - part of its own update group\n") | |
3208 | { | |
c500ae40 | 3209 | int idx_peer = 1; |
3f9c7369 DS |
3210 | struct peer *peer; |
3211 | int ret; | |
3212 | ||
c500ae40 | 3213 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
3f9c7369 DS |
3214 | if (! peer) |
3215 | return CMD_WARNING; | |
3216 | ||
3217 | ret = update_group_adjust_soloness(peer, 1); | |
3218 | return bgp_vty_return (vty, ret); | |
3219 | } | |
3220 | ||
3221 | DEFUN (no_neighbor_solo, | |
3222 | no_neighbor_solo_cmd, | |
9ccf14f7 | 3223 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3224 | NO_STR |
3225 | NEIGHBOR_STR | |
3226 | NEIGHBOR_ADDR_STR2 | |
3227 | "Solo peer - part of its own update group\n") | |
3228 | { | |
c500ae40 | 3229 | int idx_peer = 2; |
3f9c7369 DS |
3230 | struct peer *peer; |
3231 | int ret; | |
3232 | ||
c500ae40 | 3233 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
3f9c7369 DS |
3234 | if (! peer) |
3235 | return CMD_WARNING; | |
3236 | ||
3237 | ret = update_group_adjust_soloness(peer, 0); | |
3238 | return bgp_vty_return (vty, ret); | |
3239 | } | |
3240 | ||
0df7c91f PJ |
3241 | DEFUN (neighbor_password, |
3242 | neighbor_password_cmd, | |
9ccf14f7 | 3243 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
3244 | NEIGHBOR_STR |
3245 | NEIGHBOR_ADDR_STR2 | |
3246 | "Set a password\n" | |
3247 | "The password\n") | |
3248 | { | |
c500ae40 DW |
3249 | int idx_peer = 1; |
3250 | int idx_line = 3; | |
0df7c91f PJ |
3251 | struct peer *peer; |
3252 | int ret; | |
3253 | ||
c500ae40 | 3254 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
0df7c91f PJ |
3255 | if (! peer) |
3256 | return CMD_WARNING; | |
3257 | ||
c500ae40 | 3258 | ret = peer_password_set (peer, argv[idx_line]->arg); |
0df7c91f PJ |
3259 | return bgp_vty_return (vty, ret); |
3260 | } | |
3261 | ||
3262 | DEFUN (no_neighbor_password, | |
3263 | no_neighbor_password_cmd, | |
a636c635 | 3264 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
3265 | NO_STR |
3266 | NEIGHBOR_STR | |
3267 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
3268 | "Set a password\n" |
3269 | "The password\n") | |
0df7c91f | 3270 | { |
c500ae40 | 3271 | int idx_peer = 2; |
0df7c91f PJ |
3272 | struct peer *peer; |
3273 | int ret; | |
3274 | ||
c500ae40 | 3275 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
0df7c91f PJ |
3276 | if (! peer) |
3277 | return CMD_WARNING; | |
3278 | ||
3279 | ret = peer_password_unset (peer); | |
3280 | return bgp_vty_return (vty, ret); | |
3281 | } | |
6b0655a2 | 3282 | |
813d4307 | 3283 | |
718e3744 | 3284 | DEFUN (neighbor_activate, |
3285 | neighbor_activate_cmd, | |
9ccf14f7 | 3286 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3287 | NEIGHBOR_STR |
3288 | NEIGHBOR_ADDR_STR2 | |
3289 | "Enable the Address Family for this Neighbor\n") | |
3290 | { | |
c500ae40 | 3291 | int idx_peer = 1; |
c8560b44 | 3292 | int ret; |
718e3744 | 3293 | struct peer *peer; |
3294 | ||
c500ae40 | 3295 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3296 | if (! peer) |
3297 | return CMD_WARNING; | |
3298 | ||
c8560b44 | 3299 | ret = peer_activate (peer, bgp_node_afi (vty), bgp_node_safi (vty)); |
718e3744 | 3300 | |
c8560b44 DW |
3301 | if (ret) |
3302 | return CMD_WARNING; | |
718e3744 | 3303 | return CMD_SUCCESS; |
3304 | } | |
3305 | ||
596c17ba DW |
3306 | ALIAS_HIDDEN (neighbor_activate, |
3307 | neighbor_activate_hidden_cmd, | |
3308 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3309 | NEIGHBOR_STR | |
3310 | NEIGHBOR_ADDR_STR2 | |
3311 | "Enable the Address Family for this Neighbor\n") | |
3312 | ||
718e3744 | 3313 | DEFUN (no_neighbor_activate, |
3314 | no_neighbor_activate_cmd, | |
9ccf14f7 | 3315 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3316 | NO_STR |
3317 | NEIGHBOR_STR | |
3318 | NEIGHBOR_ADDR_STR2 | |
3319 | "Enable the Address Family for this Neighbor\n") | |
3320 | { | |
c500ae40 | 3321 | int idx_peer = 2; |
718e3744 | 3322 | int ret; |
3323 | struct peer *peer; | |
3324 | ||
3325 | /* Lookup peer. */ | |
c500ae40 | 3326 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3327 | if (! peer) |
3328 | return CMD_WARNING; | |
3329 | ||
3330 | ret = peer_deactivate (peer, bgp_node_afi (vty), bgp_node_safi (vty)); | |
3331 | ||
c8560b44 DW |
3332 | if (ret) |
3333 | return CMD_WARNING; | |
3334 | return CMD_SUCCESS; | |
718e3744 | 3335 | } |
6b0655a2 | 3336 | |
596c17ba DW |
3337 | ALIAS_HIDDEN (no_neighbor_activate, |
3338 | no_neighbor_activate_hidden_cmd, | |
3339 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3340 | NO_STR | |
3341 | NEIGHBOR_STR | |
3342 | NEIGHBOR_ADDR_STR2 | |
3343 | "Enable the Address Family for this Neighbor\n") | |
3344 | ||
718e3744 | 3345 | DEFUN (neighbor_set_peer_group, |
3346 | neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3347 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3348 | NEIGHBOR_STR |
a80beece | 3349 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3350 | "Member of the peer-group\n" |
16cedbb0 | 3351 | "Peer-group name\n") |
718e3744 | 3352 | { |
cdc2d765 | 3353 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
3354 | int idx_peer = 1; |
3355 | int idx_word = 3; | |
718e3744 | 3356 | int ret; |
3357 | as_t as; | |
3358 | union sockunion su; | |
a80beece | 3359 | struct peer *peer; |
718e3744 | 3360 | struct peer_group *group; |
3361 | ||
a80beece | 3362 | peer = NULL; |
718e3744 | 3363 | |
c500ae40 | 3364 | ret = str2sockunion (argv[idx_peer]->arg, &su); |
718e3744 | 3365 | if (ret < 0) |
3366 | { | |
c500ae40 | 3367 | peer = peer_lookup_by_conf_if (bgp, argv[idx_peer]->arg); |
a80beece DS |
3368 | if (!peer) |
3369 | { | |
c500ae40 | 3370 | vty_out (vty, "%% Malformed address or name: %s%s", argv[idx_peer]->arg, VTY_NEWLINE); |
a80beece DS |
3371 | return CMD_WARNING; |
3372 | } | |
3373 | } | |
3374 | else | |
3375 | { | |
6aeb9e78 | 3376 | if (peer_address_self_check (bgp, &su)) |
a80beece DS |
3377 | { |
3378 | vty_out (vty, "%% Can not configure the local system as neighbor%s", | |
3379 | VTY_NEWLINE); | |
3380 | return CMD_WARNING; | |
3381 | } | |
f14e6fdb DS |
3382 | |
3383 | /* Disallow for dynamic neighbor. */ | |
3384 | peer = peer_lookup (bgp, &su); | |
3385 | if (peer && peer_dynamic_neighbor (peer)) | |
3386 | { | |
3387 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
3388 | VTY_NEWLINE); | |
3389 | return CMD_WARNING; | |
3390 | } | |
718e3744 | 3391 | } |
3392 | ||
c500ae40 | 3393 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 3394 | if (! group) |
3395 | { | |
3396 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
3397 | return CMD_WARNING; | |
3398 | } | |
3399 | ||
c8560b44 | 3400 | ret = peer_group_bind (bgp, &su, peer, group, &as); |
718e3744 | 3401 | |
3402 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) | |
3403 | { | |
aea339f7 | 3404 | 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 | 3405 | return CMD_WARNING; |
3406 | } | |
3407 | ||
3408 | return bgp_vty_return (vty, ret); | |
3409 | } | |
3410 | ||
596c17ba DW |
3411 | ALIAS_HIDDEN (neighbor_set_peer_group, |
3412 | neighbor_set_peer_group_hidden_cmd, | |
3413 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", | |
3414 | NEIGHBOR_STR | |
3415 | NEIGHBOR_ADDR_STR2 | |
3416 | "Member of the peer-group\n" | |
3417 | "Peer-group name\n") | |
3418 | ||
718e3744 | 3419 | DEFUN (no_neighbor_set_peer_group, |
3420 | no_neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3421 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3422 | NO_STR |
3423 | NEIGHBOR_STR | |
a80beece | 3424 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3425 | "Member of the peer-group\n" |
16cedbb0 | 3426 | "Peer-group name\n") |
718e3744 | 3427 | { |
cdc2d765 | 3428 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
3429 | int idx_peer = 2; |
3430 | int idx_word = 4; | |
718e3744 | 3431 | int ret; |
718e3744 | 3432 | struct peer *peer; |
3433 | struct peer_group *group; | |
3434 | ||
c500ae40 | 3435 | peer = peer_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3436 | if (! peer) |
3437 | return CMD_WARNING; | |
3438 | ||
c500ae40 | 3439 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 3440 | if (! group) |
3441 | { | |
3442 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
3443 | return CMD_WARNING; | |
3444 | } | |
3445 | ||
c8560b44 | 3446 | ret = peer_group_unbind (bgp, peer, group); |
718e3744 | 3447 | |
3448 | return bgp_vty_return (vty, ret); | |
3449 | } | |
6b0655a2 | 3450 | |
596c17ba DW |
3451 | ALIAS_HIDDEN (no_neighbor_set_peer_group, |
3452 | no_neighbor_set_peer_group_hidden_cmd, | |
3453 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", | |
3454 | NO_STR | |
3455 | NEIGHBOR_STR | |
3456 | NEIGHBOR_ADDR_STR2 | |
3457 | "Member of the peer-group\n" | |
3458 | "Peer-group name\n") | |
3459 | ||
94f2b392 | 3460 | static int |
e52702f2 | 3461 | peer_flag_modify_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 3462 | u_int16_t flag, int set) |
718e3744 | 3463 | { |
3464 | int ret; | |
3465 | struct peer *peer; | |
3466 | ||
3467 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
3468 | if (! peer) | |
3469 | return CMD_WARNING; | |
3470 | ||
8cdabf90 SK |
3471 | /* |
3472 | * If 'neighbor <interface>', then this is for directly connected peers, | |
3473 | * we should not accept disable-connected-check. | |
3474 | */ | |
3475 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
3476 | vty_out (vty, "%s is directly connected peer, cannot accept disable-" | |
3477 | "connected-check%s", ip_str, VTY_NEWLINE); | |
3478 | return CMD_WARNING; | |
3479 | } | |
3480 | ||
ae9b0e11 DS |
3481 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
3482 | peer_tx_shutdown_message_unset (peer); | |
3483 | ||
718e3744 | 3484 | if (set) |
3485 | ret = peer_flag_set (peer, flag); | |
3486 | else | |
3487 | ret = peer_flag_unset (peer, flag); | |
3488 | ||
3489 | return bgp_vty_return (vty, ret); | |
3490 | } | |
3491 | ||
94f2b392 | 3492 | static int |
fd79ac91 | 3493 | peer_flag_set_vty (struct vty *vty, const char *ip_str, u_int16_t flag) |
718e3744 | 3494 | { |
3495 | return peer_flag_modify_vty (vty, ip_str, flag, 1); | |
3496 | } | |
3497 | ||
94f2b392 | 3498 | static int |
fd79ac91 | 3499 | peer_flag_unset_vty (struct vty *vty, const char *ip_str, u_int16_t flag) |
718e3744 | 3500 | { |
3501 | return peer_flag_modify_vty (vty, ip_str, flag, 0); | |
3502 | } | |
3503 | ||
3504 | /* neighbor passive. */ | |
3505 | DEFUN (neighbor_passive, | |
3506 | neighbor_passive_cmd, | |
9ccf14f7 | 3507 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3508 | NEIGHBOR_STR |
3509 | NEIGHBOR_ADDR_STR2 | |
3510 | "Don't send open messages to this neighbor\n") | |
3511 | { | |
c500ae40 DW |
3512 | int idx_peer = 1; |
3513 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3514 | } |
3515 | ||
3516 | DEFUN (no_neighbor_passive, | |
3517 | no_neighbor_passive_cmd, | |
9ccf14f7 | 3518 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3519 | NO_STR |
3520 | NEIGHBOR_STR | |
3521 | NEIGHBOR_ADDR_STR2 | |
3522 | "Don't send open messages to this neighbor\n") | |
3523 | { | |
c500ae40 DW |
3524 | int idx_peer = 2; |
3525 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3526 | } |
6b0655a2 | 3527 | |
718e3744 | 3528 | /* neighbor shutdown. */ |
73d70fa6 DL |
3529 | DEFUN (neighbor_shutdown_msg, |
3530 | neighbor_shutdown_msg_cmd, | |
3531 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
718e3744 | 3532 | NEIGHBOR_STR |
3533 | NEIGHBOR_ADDR_STR2 | |
73d70fa6 DL |
3534 | "Administratively shut down this neighbor\n" |
3535 | "Add a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3536 | "Shutdown message\n") | |
718e3744 | 3537 | { |
c500ae40 | 3538 | int idx_peer = 1; |
73d70fa6 DL |
3539 | |
3540 | if (argc >= 5) | |
3541 | { | |
ae9b0e11 | 3542 | struct peer *peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
73d70fa6 DL |
3543 | char *message; |
3544 | ||
ae9b0e11 DS |
3545 | if (!peer) |
3546 | return CMD_WARNING; | |
73d70fa6 DL |
3547 | message = argv_concat (argv, argc, 4); |
3548 | peer_tx_shutdown_message_set (peer, message); | |
3549 | XFREE (MTYPE_TMP, message); | |
3550 | } | |
3551 | ||
c500ae40 | 3552 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 3553 | } |
3554 | ||
73d70fa6 DL |
3555 | ALIAS (neighbor_shutdown_msg, |
3556 | neighbor_shutdown_cmd, | |
3557 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
718e3744 | 3558 | NEIGHBOR_STR |
3559 | NEIGHBOR_ADDR_STR2 | |
3560 | "Administratively shut down this neighbor\n") | |
73d70fa6 DL |
3561 | |
3562 | DEFUN (no_neighbor_shutdown_msg, | |
3563 | no_neighbor_shutdown_msg_cmd, | |
3564 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
3565 | NO_STR | |
3566 | NEIGHBOR_STR | |
3567 | NEIGHBOR_ADDR_STR2 | |
3568 | "Administratively shut down this neighbor\n" | |
3569 | "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3570 | "Shutdown message\n") | |
718e3744 | 3571 | { |
c500ae40 | 3572 | int idx_peer = 2; |
73d70fa6 | 3573 | |
c500ae40 | 3574 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 3575 | } |
6b0655a2 | 3576 | |
73d70fa6 DL |
3577 | ALIAS (no_neighbor_shutdown_msg, |
3578 | no_neighbor_shutdown_cmd, | |
3579 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3580 | NO_STR | |
3581 | NEIGHBOR_STR | |
3582 | NEIGHBOR_ADDR_STR2 | |
3583 | "Administratively shut down this neighbor\n") | |
3584 | ||
718e3744 | 3585 | /* neighbor capability dynamic. */ |
3586 | DEFUN (neighbor_capability_dynamic, | |
3587 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3588 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3589 | NEIGHBOR_STR |
3590 | NEIGHBOR_ADDR_STR2 | |
3591 | "Advertise capability to the peer\n" | |
3592 | "Advertise dynamic capability to this neighbor\n") | |
3593 | { | |
c500ae40 DW |
3594 | int idx_peer = 1; |
3595 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3596 | } |
3597 | ||
3598 | DEFUN (no_neighbor_capability_dynamic, | |
3599 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3600 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3601 | NO_STR |
3602 | NEIGHBOR_STR | |
3603 | NEIGHBOR_ADDR_STR2 | |
3604 | "Advertise capability to the peer\n" | |
3605 | "Advertise dynamic capability to this neighbor\n") | |
3606 | { | |
c500ae40 DW |
3607 | int idx_peer = 2; |
3608 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3609 | } |
6b0655a2 | 3610 | |
718e3744 | 3611 | /* neighbor dont-capability-negotiate */ |
3612 | DEFUN (neighbor_dont_capability_negotiate, | |
3613 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3614 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3615 | NEIGHBOR_STR |
3616 | NEIGHBOR_ADDR_STR2 | |
3617 | "Do not perform capability negotiation\n") | |
3618 | { | |
c500ae40 DW |
3619 | int idx_peer = 1; |
3620 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3621 | } |
3622 | ||
3623 | DEFUN (no_neighbor_dont_capability_negotiate, | |
3624 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3625 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3626 | NO_STR |
3627 | NEIGHBOR_STR | |
3628 | NEIGHBOR_ADDR_STR2 | |
3629 | "Do not perform capability negotiation\n") | |
3630 | { | |
c500ae40 DW |
3631 | int idx_peer = 2; |
3632 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3633 | } |
6b0655a2 | 3634 | |
8a92a8a0 DS |
3635 | /* neighbor capability extended next hop encoding */ |
3636 | DEFUN (neighbor_capability_enhe, | |
3637 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3638 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3639 | NEIGHBOR_STR |
3640 | NEIGHBOR_ADDR_STR2 | |
3641 | "Advertise capability to the peer\n" | |
3642 | "Advertise extended next-hop capability to the peer\n") | |
3643 | { | |
c500ae40 DW |
3644 | int idx_peer = 1; |
3645 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3646 | } |
3647 | ||
3648 | DEFUN (no_neighbor_capability_enhe, | |
3649 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3650 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3651 | NO_STR |
3652 | NEIGHBOR_STR | |
3653 | NEIGHBOR_ADDR_STR2 | |
3654 | "Advertise capability to the peer\n" | |
3655 | "Advertise extended next-hop capability to the peer\n") | |
3656 | { | |
c500ae40 DW |
3657 | int idx_peer = 2; |
3658 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3659 | } |
3660 | ||
94f2b392 | 3661 | static int |
fd79ac91 | 3662 | peer_af_flag_modify_vty (struct vty *vty, const char *peer_str, afi_t afi, |
fee0f4c6 | 3663 | safi_t safi, u_int32_t flag, int set) |
718e3744 | 3664 | { |
3665 | int ret; | |
3666 | struct peer *peer; | |
3667 | ||
3668 | peer = peer_and_group_lookup_vty (vty, peer_str); | |
3669 | if (! peer) | |
3670 | return CMD_WARNING; | |
3671 | ||
3672 | if (set) | |
3673 | ret = peer_af_flag_set (peer, afi, safi, flag); | |
3674 | else | |
3675 | ret = peer_af_flag_unset (peer, afi, safi, flag); | |
3676 | ||
3677 | return bgp_vty_return (vty, ret); | |
3678 | } | |
3679 | ||
94f2b392 | 3680 | static int |
fd79ac91 | 3681 | peer_af_flag_set_vty (struct vty *vty, const char *peer_str, afi_t afi, |
fee0f4c6 | 3682 | safi_t safi, u_int32_t flag) |
718e3744 | 3683 | { |
3684 | return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 1); | |
3685 | } | |
3686 | ||
94f2b392 | 3687 | static int |
fd79ac91 | 3688 | peer_af_flag_unset_vty (struct vty *vty, const char *peer_str, afi_t afi, |
fee0f4c6 | 3689 | safi_t safi, u_int32_t flag) |
718e3744 | 3690 | { |
3691 | return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 0); | |
3692 | } | |
6b0655a2 | 3693 | |
718e3744 | 3694 | /* neighbor capability orf prefix-list. */ |
3695 | DEFUN (neighbor_capability_orf_prefix, | |
3696 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3697 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3698 | NEIGHBOR_STR |
3699 | NEIGHBOR_ADDR_STR2 | |
3700 | "Advertise capability to the peer\n" | |
3701 | "Advertise ORF capability to the peer\n" | |
3702 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3703 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3704 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3705 | "Capability to SEND the ORF to this neighbor\n") | |
3706 | { | |
c500ae40 DW |
3707 | int idx_peer = 1; |
3708 | int idx_send_recv = 5; | |
718e3744 | 3709 | u_int16_t flag = 0; |
3710 | ||
c500ae40 | 3711 | if (strncmp (argv[idx_send_recv]->arg, "s", 1) == 0) |
718e3744 | 3712 | flag = PEER_FLAG_ORF_PREFIX_SM; |
c500ae40 | 3713 | else if (strncmp (argv[idx_send_recv]->arg, "r", 1) == 0) |
718e3744 | 3714 | flag = PEER_FLAG_ORF_PREFIX_RM; |
c500ae40 | 3715 | else if (strncmp (argv[idx_send_recv]->arg, "b", 1) == 0) |
718e3744 | 3716 | flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM; |
3717 | else | |
3718 | return CMD_WARNING; | |
3719 | ||
c500ae40 | 3720 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 3721 | bgp_node_safi (vty), flag); |
3722 | } | |
3723 | ||
596c17ba DW |
3724 | ALIAS_HIDDEN (neighbor_capability_orf_prefix, |
3725 | neighbor_capability_orf_prefix_hidden_cmd, | |
3726 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3727 | NEIGHBOR_STR | |
3728 | NEIGHBOR_ADDR_STR2 | |
3729 | "Advertise capability to the peer\n" | |
3730 | "Advertise ORF capability to the peer\n" | |
3731 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3732 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3733 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3734 | "Capability to SEND the ORF to this neighbor\n") | |
3735 | ||
718e3744 | 3736 | DEFUN (no_neighbor_capability_orf_prefix, |
3737 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3738 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3739 | NO_STR |
3740 | NEIGHBOR_STR | |
3741 | NEIGHBOR_ADDR_STR2 | |
3742 | "Advertise capability to the peer\n" | |
3743 | "Advertise ORF capability to the peer\n" | |
3744 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3745 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3746 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3747 | "Capability to SEND the ORF to this neighbor\n") | |
3748 | { | |
c500ae40 DW |
3749 | int idx_peer = 2; |
3750 | int idx_send_recv = 6; | |
718e3744 | 3751 | u_int16_t flag = 0; |
3752 | ||
c500ae40 | 3753 | if (strncmp (argv[idx_send_recv]->arg, "s", 1) == 0) |
718e3744 | 3754 | flag = PEER_FLAG_ORF_PREFIX_SM; |
c500ae40 | 3755 | else if (strncmp (argv[idx_send_recv]->arg, "r", 1) == 0) |
718e3744 | 3756 | flag = PEER_FLAG_ORF_PREFIX_RM; |
c500ae40 | 3757 | else if (strncmp (argv[idx_send_recv]->arg, "b", 1) == 0) |
718e3744 | 3758 | flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM; |
3759 | else | |
3760 | return CMD_WARNING; | |
3761 | ||
c500ae40 | 3762 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 3763 | bgp_node_safi (vty), flag); |
3764 | } | |
6b0655a2 | 3765 | |
596c17ba DW |
3766 | ALIAS_HIDDEN (no_neighbor_capability_orf_prefix, |
3767 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
3768 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3769 | NO_STR | |
3770 | NEIGHBOR_STR | |
3771 | NEIGHBOR_ADDR_STR2 | |
3772 | "Advertise capability to the peer\n" | |
3773 | "Advertise ORF capability to the peer\n" | |
3774 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3775 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3776 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3777 | "Capability to SEND the ORF to this neighbor\n") | |
3778 | ||
718e3744 | 3779 | /* neighbor next-hop-self. */ |
3780 | DEFUN (neighbor_nexthop_self, | |
3781 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3782 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3783 | NEIGHBOR_STR |
3784 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3785 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3786 | { |
c500ae40 DW |
3787 | int idx_peer = 1; |
3788 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
a538debe DS |
3789 | bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF); |
3790 | } | |
9e7a53c1 | 3791 | |
596c17ba DW |
3792 | ALIAS_HIDDEN (neighbor_nexthop_self, |
3793 | neighbor_nexthop_self_hidden_cmd, | |
3794 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3795 | NEIGHBOR_STR | |
3796 | NEIGHBOR_ADDR_STR2 | |
3797 | "Disable the next hop calculation for this neighbor\n") | |
3798 | ||
a538debe DS |
3799 | /* neighbor next-hop-self. */ |
3800 | DEFUN (neighbor_nexthop_self_force, | |
3801 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 3802 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3803 | NEIGHBOR_STR |
3804 | NEIGHBOR_ADDR_STR2 | |
3805 | "Disable the next hop calculation for this neighbor\n" | |
3806 | "Set the next hop to self for reflected routes\n") | |
3807 | { | |
c500ae40 DW |
3808 | int idx_peer = 1; |
3809 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
a538debe | 3810 | bgp_node_safi (vty), |
88b8ed8d | 3811 | PEER_FLAG_FORCE_NEXTHOP_SELF); |
718e3744 | 3812 | } |
3813 | ||
596c17ba DW |
3814 | ALIAS_HIDDEN (neighbor_nexthop_self_force, |
3815 | neighbor_nexthop_self_force_hidden_cmd, | |
3816 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3817 | NEIGHBOR_STR | |
3818 | NEIGHBOR_ADDR_STR2 | |
3819 | "Disable the next hop calculation for this neighbor\n" | |
3820 | "Set the next hop to self for reflected routes\n") | |
3821 | ||
718e3744 | 3822 | DEFUN (no_neighbor_nexthop_self, |
3823 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3824 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3825 | NO_STR |
3826 | NEIGHBOR_STR | |
3827 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3828 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3829 | { |
c500ae40 DW |
3830 | int idx_peer = 2; |
3831 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
9e7a53c1 | 3832 | bgp_node_safi (vty), |
88b8ed8d | 3833 | PEER_FLAG_NEXTHOP_SELF); |
718e3744 | 3834 | } |
6b0655a2 | 3835 | |
596c17ba DW |
3836 | ALIAS_HIDDEN (no_neighbor_nexthop_self, |
3837 | no_neighbor_nexthop_self_hidden_cmd, | |
3838 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3839 | NO_STR | |
3840 | NEIGHBOR_STR | |
3841 | NEIGHBOR_ADDR_STR2 | |
3842 | "Disable the next hop calculation for this neighbor\n") | |
3843 | ||
88b8ed8d | 3844 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 3845 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 3846 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3847 | NO_STR |
3848 | NEIGHBOR_STR | |
3849 | NEIGHBOR_ADDR_STR2 | |
3850 | "Disable the next hop calculation for this neighbor\n" | |
3851 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 3852 | { |
c500ae40 DW |
3853 | int idx_peer = 2; |
3854 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
3855 | bgp_node_safi (vty), |
3856 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
3857 | } | |
a538debe | 3858 | |
596c17ba DW |
3859 | ALIAS_HIDDEN (no_neighbor_nexthop_self_force, |
3860 | no_neighbor_nexthop_self_force_hidden_cmd, | |
3861 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3862 | NO_STR | |
3863 | NEIGHBOR_STR | |
3864 | NEIGHBOR_ADDR_STR2 | |
3865 | "Disable the next hop calculation for this neighbor\n" | |
3866 | "Set the next hop to self for reflected routes\n") | |
3867 | ||
c7122e14 DS |
3868 | /* neighbor as-override */ |
3869 | DEFUN (neighbor_as_override, | |
3870 | neighbor_as_override_cmd, | |
9ccf14f7 | 3871 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3872 | NEIGHBOR_STR |
3873 | NEIGHBOR_ADDR_STR2 | |
3874 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3875 | { | |
c500ae40 DW |
3876 | int idx_peer = 1; |
3877 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
c7122e14 DS |
3878 | bgp_node_safi (vty), |
3879 | PEER_FLAG_AS_OVERRIDE); | |
3880 | } | |
3881 | ||
596c17ba DW |
3882 | ALIAS_HIDDEN (neighbor_as_override, |
3883 | neighbor_as_override_hidden_cmd, | |
3884 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
3885 | NEIGHBOR_STR | |
3886 | NEIGHBOR_ADDR_STR2 | |
3887 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3888 | ||
c7122e14 DS |
3889 | DEFUN (no_neighbor_as_override, |
3890 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 3891 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3892 | NO_STR |
3893 | NEIGHBOR_STR | |
3894 | NEIGHBOR_ADDR_STR2 | |
3895 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3896 | { | |
c500ae40 DW |
3897 | int idx_peer = 2; |
3898 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
c7122e14 DS |
3899 | bgp_node_safi (vty), |
3900 | PEER_FLAG_AS_OVERRIDE); | |
3901 | } | |
3902 | ||
596c17ba DW |
3903 | ALIAS_HIDDEN (no_neighbor_as_override, |
3904 | no_neighbor_as_override_hidden_cmd, | |
3905 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
3906 | NO_STR | |
3907 | NEIGHBOR_STR | |
3908 | NEIGHBOR_ADDR_STR2 | |
3909 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3910 | ||
718e3744 | 3911 | /* neighbor remove-private-AS. */ |
3912 | DEFUN (neighbor_remove_private_as, | |
3913 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3914 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3915 | NEIGHBOR_STR |
3916 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3917 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3918 | { |
c500ae40 DW |
3919 | int idx_peer = 1; |
3920 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3921 | bgp_node_safi (vty), |
3922 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
3923 | } | |
3924 | ||
596c17ba DW |
3925 | ALIAS_HIDDEN (neighbor_remove_private_as, |
3926 | neighbor_remove_private_as_hidden_cmd, | |
3927 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
3928 | NEIGHBOR_STR | |
3929 | NEIGHBOR_ADDR_STR2 | |
3930 | "Remove private ASNs in outbound updates\n") | |
3931 | ||
5000f21c DS |
3932 | DEFUN (neighbor_remove_private_as_all, |
3933 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 3934 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
3935 | NEIGHBOR_STR |
3936 | NEIGHBOR_ADDR_STR2 | |
3937 | "Remove private ASNs in outbound updates\n" | |
3938 | "Apply to all AS numbers") | |
3939 | { | |
c500ae40 DW |
3940 | int idx_peer = 1; |
3941 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5000f21c | 3942 | bgp_node_safi (vty), |
5000f21c DS |
3943 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); |
3944 | } | |
3945 | ||
596c17ba DW |
3946 | ALIAS_HIDDEN (neighbor_remove_private_as_all, |
3947 | neighbor_remove_private_as_all_hidden_cmd, | |
3948 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
3949 | NEIGHBOR_STR | |
3950 | NEIGHBOR_ADDR_STR2 | |
3951 | "Remove private ASNs in outbound updates\n" | |
3952 | "Apply to all AS numbers") | |
3953 | ||
5000f21c DS |
3954 | DEFUN (neighbor_remove_private_as_replace_as, |
3955 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 3956 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
3957 | NEIGHBOR_STR |
3958 | NEIGHBOR_ADDR_STR2 | |
3959 | "Remove private ASNs in outbound updates\n" | |
3960 | "Replace private ASNs with our ASN in outbound updates\n") | |
3961 | { | |
c500ae40 DW |
3962 | int idx_peer = 1; |
3963 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5000f21c | 3964 | bgp_node_safi (vty), |
5000f21c DS |
3965 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); |
3966 | } | |
3967 | ||
596c17ba DW |
3968 | ALIAS_HIDDEN (neighbor_remove_private_as_replace_as, |
3969 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
3970 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
3971 | NEIGHBOR_STR | |
3972 | NEIGHBOR_ADDR_STR2 | |
3973 | "Remove private ASNs in outbound updates\n" | |
3974 | "Replace private ASNs with our ASN in outbound updates\n") | |
3975 | ||
5000f21c DS |
3976 | DEFUN (neighbor_remove_private_as_all_replace_as, |
3977 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 3978 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
3979 | NEIGHBOR_STR |
3980 | NEIGHBOR_ADDR_STR2 | |
3981 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3982 | "Apply to all AS numbers\n" |
5000f21c DS |
3983 | "Replace private ASNs with our ASN in outbound updates\n") |
3984 | { | |
c500ae40 DW |
3985 | int idx_peer = 1; |
3986 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5000f21c | 3987 | bgp_node_safi (vty), |
88b8ed8d | 3988 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); |
5000f21c DS |
3989 | } |
3990 | ||
596c17ba DW |
3991 | ALIAS_HIDDEN (neighbor_remove_private_as_all_replace_as, |
3992 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
3993 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
3994 | NEIGHBOR_STR | |
3995 | NEIGHBOR_ADDR_STR2 | |
3996 | "Remove private ASNs in outbound updates\n" | |
3997 | "Apply to all AS numbers\n" | |
3998 | "Replace private ASNs with our ASN in outbound updates\n") | |
3999 | ||
718e3744 | 4000 | DEFUN (no_neighbor_remove_private_as, |
4001 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4002 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4003 | NO_STR |
4004 | NEIGHBOR_STR | |
4005 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4006 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4007 | { |
c500ae40 DW |
4008 | int idx_peer = 2; |
4009 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4010 | bgp_node_safi (vty), |
88b8ed8d | 4011 | PEER_FLAG_REMOVE_PRIVATE_AS); |
718e3744 | 4012 | } |
6b0655a2 | 4013 | |
596c17ba DW |
4014 | ALIAS_HIDDEN (no_neighbor_remove_private_as, |
4015 | no_neighbor_remove_private_as_hidden_cmd, | |
4016 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4017 | NO_STR | |
4018 | NEIGHBOR_STR | |
4019 | NEIGHBOR_ADDR_STR2 | |
4020 | "Remove private ASNs in outbound updates\n") | |
4021 | ||
88b8ed8d | 4022 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 4023 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 4024 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4025 | NO_STR |
4026 | NEIGHBOR_STR | |
4027 | NEIGHBOR_ADDR_STR2 | |
4028 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4029 | "Apply to all AS numbers\n") |
88b8ed8d | 4030 | { |
c500ae40 DW |
4031 | int idx_peer = 2; |
4032 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
4033 | bgp_node_safi (vty), |
4034 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
4035 | } | |
5000f21c | 4036 | |
596c17ba DW |
4037 | ALIAS_HIDDEN (no_neighbor_remove_private_as_all, |
4038 | no_neighbor_remove_private_as_all_hidden_cmd, | |
4039 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4040 | NO_STR | |
4041 | NEIGHBOR_STR | |
4042 | NEIGHBOR_ADDR_STR2 | |
4043 | "Remove private ASNs in outbound updates\n" | |
4044 | "Apply to all AS numbers\n") | |
4045 | ||
88b8ed8d | 4046 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 4047 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 4048 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4049 | NO_STR |
4050 | NEIGHBOR_STR | |
4051 | NEIGHBOR_ADDR_STR2 | |
4052 | "Remove private ASNs in outbound updates\n" | |
4053 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 4054 | { |
c500ae40 DW |
4055 | int idx_peer = 2; |
4056 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
4057 | bgp_node_safi (vty), |
4058 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
4059 | } | |
5000f21c | 4060 | |
596c17ba DW |
4061 | ALIAS_HIDDEN (no_neighbor_remove_private_as_replace_as, |
4062 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
4063 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4064 | NO_STR | |
4065 | NEIGHBOR_STR | |
4066 | NEIGHBOR_ADDR_STR2 | |
4067 | "Remove private ASNs in outbound updates\n" | |
4068 | "Replace private ASNs with our ASN in outbound updates\n") | |
4069 | ||
88b8ed8d | 4070 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 4071 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 4072 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4073 | NO_STR |
4074 | NEIGHBOR_STR | |
4075 | NEIGHBOR_ADDR_STR2 | |
4076 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4077 | "Apply to all AS numbers\n" |
5000f21c | 4078 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 4079 | { |
c500ae40 DW |
4080 | int idx_peer = 2; |
4081 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
4082 | bgp_node_safi (vty), |
4083 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
4084 | } | |
5000f21c | 4085 | |
596c17ba DW |
4086 | ALIAS_HIDDEN (no_neighbor_remove_private_as_all_replace_as, |
4087 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4088 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4089 | NO_STR | |
4090 | NEIGHBOR_STR | |
4091 | NEIGHBOR_ADDR_STR2 | |
4092 | "Remove private ASNs in outbound updates\n" | |
4093 | "Apply to all AS numbers\n" | |
4094 | "Replace private ASNs with our ASN in outbound updates\n") | |
4095 | ||
5000f21c | 4096 | |
718e3744 | 4097 | /* neighbor send-community. */ |
4098 | DEFUN (neighbor_send_community, | |
4099 | neighbor_send_community_cmd, | |
9ccf14f7 | 4100 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4101 | NEIGHBOR_STR |
4102 | NEIGHBOR_ADDR_STR2 | |
4103 | "Send Community attribute to this neighbor\n") | |
4104 | { | |
c500ae40 DW |
4105 | int idx_peer = 1; |
4106 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4107 | bgp_node_safi (vty), |
4108 | PEER_FLAG_SEND_COMMUNITY); | |
4109 | } | |
4110 | ||
596c17ba DW |
4111 | ALIAS_HIDDEN (neighbor_send_community, |
4112 | neighbor_send_community_hidden_cmd, | |
4113 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4114 | NEIGHBOR_STR | |
4115 | NEIGHBOR_ADDR_STR2 | |
4116 | "Send Community attribute to this neighbor\n") | |
4117 | ||
718e3744 | 4118 | DEFUN (no_neighbor_send_community, |
4119 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 4120 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4121 | NO_STR |
4122 | NEIGHBOR_STR | |
4123 | NEIGHBOR_ADDR_STR2 | |
4124 | "Send Community attribute to this neighbor\n") | |
4125 | { | |
c500ae40 DW |
4126 | int idx_peer = 2; |
4127 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4128 | bgp_node_safi (vty), |
4129 | PEER_FLAG_SEND_COMMUNITY); | |
4130 | } | |
6b0655a2 | 4131 | |
596c17ba DW |
4132 | ALIAS_HIDDEN (no_neighbor_send_community, |
4133 | no_neighbor_send_community_hidden_cmd, | |
4134 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4135 | NO_STR | |
4136 | NEIGHBOR_STR | |
4137 | NEIGHBOR_ADDR_STR2 | |
4138 | "Send Community attribute to this neighbor\n") | |
4139 | ||
718e3744 | 4140 | /* neighbor send-community extended. */ |
4141 | DEFUN (neighbor_send_community_type, | |
4142 | neighbor_send_community_type_cmd, | |
57d187bc | 4143 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4144 | NEIGHBOR_STR |
4145 | NEIGHBOR_ADDR_STR2 | |
4146 | "Send Community attribute to this neighbor\n" | |
4147 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4148 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4149 | "Send Extended Community attributes\n" |
57d187bc JS |
4150 | "Send Standard Community attributes\n" |
4151 | "Send Large Community attributes\n") | |
718e3744 | 4152 | { |
4c4ff4c1 QY |
4153 | int idx = 0; |
4154 | u_int32_t flag = 0; | |
718e3744 | 4155 | |
4c4ff4c1 QY |
4156 | char *peer = argv[1]->arg; |
4157 | ||
4158 | if (argv_find (argv, argc, "standard", &idx)) | |
4159 | SET_FLAG (flag, PEER_FLAG_SEND_COMMUNITY); | |
4160 | else if (argv_find (argv, argc, "extended", &idx)) | |
4161 | SET_FLAG (flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
57d187bc JS |
4162 | else if (argv_find (argv, argc, "large", &idx)) |
4163 | SET_FLAG (flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4164 | else if (argv_find (argv, argc, "both", &idx)) | |
4165 | { | |
4166 | SET_FLAG (flag, PEER_FLAG_SEND_COMMUNITY); | |
4167 | SET_FLAG (flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4168 | } | |
4c4ff4c1 | 4169 | else |
57d187bc JS |
4170 | { |
4171 | SET_FLAG (flag, PEER_FLAG_SEND_COMMUNITY); | |
4172 | SET_FLAG (flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4173 | SET_FLAG (flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4174 | } | |
4c4ff4c1 QY |
4175 | |
4176 | return peer_af_flag_set_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flag); | |
718e3744 | 4177 | } |
4178 | ||
596c17ba DW |
4179 | ALIAS_HIDDEN (neighbor_send_community_type, |
4180 | neighbor_send_community_type_hidden_cmd, | |
4181 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4182 | NEIGHBOR_STR | |
4183 | NEIGHBOR_ADDR_STR2 | |
4184 | "Send Community attribute to this neighbor\n" | |
4185 | "Send Standard and Extended Community attributes\n" | |
4186 | "Send Standard, Large and Extended Community attributes\n" | |
4187 | "Send Extended Community attributes\n" | |
4188 | "Send Standard Community attributes\n" | |
4189 | "Send Large Community attributes\n") | |
4190 | ||
718e3744 | 4191 | DEFUN (no_neighbor_send_community_type, |
4192 | no_neighbor_send_community_type_cmd, | |
57d187bc | 4193 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4194 | NO_STR |
4195 | NEIGHBOR_STR | |
4196 | NEIGHBOR_ADDR_STR2 | |
4197 | "Send Community attribute to this neighbor\n" | |
4198 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4199 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4200 | "Send Extended Community attributes\n" |
57d187bc JS |
4201 | "Send Standard Community attributes\n" |
4202 | "Send Large Community attributes\n") | |
718e3744 | 4203 | { |
c500ae40 DW |
4204 | int idx_peer = 2; |
4205 | int idx_type = 4; | |
4206 | if (strncmp (argv[idx_type]->arg, "s", 1) == 0) | |
4207 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4208 | bgp_node_safi (vty), |
4209 | PEER_FLAG_SEND_COMMUNITY); | |
c500ae40 DW |
4210 | if (strncmp (argv[idx_type]->arg, "e", 1) == 0) |
4211 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4212 | bgp_node_safi (vty), |
4213 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
57d187bc JS |
4214 | if (strncmp (argv[idx_type]->arg, "l", 1) == 0) |
4215 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4216 | bgp_node_safi (vty), | |
4217 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4218 | if (strncmp (argv[idx_type]->arg, "b", 1) == 0) | |
4219 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4220 | bgp_node_safi (vty), | |
4221 | PEER_FLAG_SEND_COMMUNITY | | |
4222 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
718e3744 | 4223 | |
c500ae40 | 4224 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 4225 | bgp_node_safi (vty), |
4226 | (PEER_FLAG_SEND_COMMUNITY | | |
57d187bc JS |
4227 | PEER_FLAG_SEND_EXT_COMMUNITY| |
4228 | PEER_FLAG_SEND_LARGE_COMMUNITY)); | |
718e3744 | 4229 | } |
6b0655a2 | 4230 | |
596c17ba DW |
4231 | ALIAS_HIDDEN (no_neighbor_send_community_type, |
4232 | no_neighbor_send_community_type_hidden_cmd, | |
4233 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4234 | NO_STR | |
4235 | NEIGHBOR_STR | |
4236 | NEIGHBOR_ADDR_STR2 | |
4237 | "Send Community attribute to this neighbor\n" | |
4238 | "Send Standard and Extended Community attributes\n" | |
4239 | "Send Standard, Large and Extended Community attributes\n" | |
4240 | "Send Extended Community attributes\n" | |
4241 | "Send Standard Community attributes\n" | |
4242 | "Send Large Community attributes\n") | |
4243 | ||
718e3744 | 4244 | /* neighbor soft-reconfig. */ |
4245 | DEFUN (neighbor_soft_reconfiguration, | |
4246 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4247 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4248 | NEIGHBOR_STR |
4249 | NEIGHBOR_ADDR_STR2 | |
4250 | "Per neighbor soft reconfiguration\n" | |
4251 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4252 | { | |
c500ae40 DW |
4253 | int idx_peer = 1; |
4254 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, | |
718e3744 | 4255 | bgp_node_afi (vty), bgp_node_safi (vty), |
4256 | PEER_FLAG_SOFT_RECONFIG); | |
4257 | } | |
4258 | ||
596c17ba DW |
4259 | ALIAS_HIDDEN (neighbor_soft_reconfiguration, |
4260 | neighbor_soft_reconfiguration_hidden_cmd, | |
4261 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4262 | NEIGHBOR_STR | |
4263 | NEIGHBOR_ADDR_STR2 | |
4264 | "Per neighbor soft reconfiguration\n" | |
4265 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4266 | ||
718e3744 | 4267 | DEFUN (no_neighbor_soft_reconfiguration, |
4268 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4269 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4270 | NO_STR |
4271 | NEIGHBOR_STR | |
4272 | NEIGHBOR_ADDR_STR2 | |
4273 | "Per neighbor soft reconfiguration\n" | |
4274 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4275 | { | |
c500ae40 DW |
4276 | int idx_peer = 2; |
4277 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, | |
718e3744 | 4278 | bgp_node_afi (vty), bgp_node_safi (vty), |
4279 | PEER_FLAG_SOFT_RECONFIG); | |
4280 | } | |
6b0655a2 | 4281 | |
596c17ba DW |
4282 | ALIAS_HIDDEN (no_neighbor_soft_reconfiguration, |
4283 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
4284 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4285 | NO_STR | |
4286 | NEIGHBOR_STR | |
4287 | NEIGHBOR_ADDR_STR2 | |
4288 | "Per neighbor soft reconfiguration\n" | |
4289 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4290 | ||
718e3744 | 4291 | DEFUN (neighbor_route_reflector_client, |
4292 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4293 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4294 | NEIGHBOR_STR |
4295 | NEIGHBOR_ADDR_STR2 | |
4296 | "Configure a neighbor as Route Reflector client\n") | |
4297 | { | |
c500ae40 | 4298 | int idx_peer = 1; |
718e3744 | 4299 | struct peer *peer; |
4300 | ||
4301 | ||
c500ae40 | 4302 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 4303 | if (! peer) |
4304 | return CMD_WARNING; | |
4305 | ||
c500ae40 | 4306 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 4307 | bgp_node_safi (vty), |
4308 | PEER_FLAG_REFLECTOR_CLIENT); | |
4309 | } | |
4310 | ||
596c17ba DW |
4311 | ALIAS_HIDDEN (neighbor_route_reflector_client, |
4312 | neighbor_route_reflector_client_hidden_cmd, | |
4313 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4314 | NEIGHBOR_STR | |
4315 | NEIGHBOR_ADDR_STR2 | |
4316 | "Configure a neighbor as Route Reflector client\n") | |
4317 | ||
718e3744 | 4318 | DEFUN (no_neighbor_route_reflector_client, |
4319 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4320 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4321 | NO_STR |
4322 | NEIGHBOR_STR | |
4323 | NEIGHBOR_ADDR_STR2 | |
4324 | "Configure a neighbor as Route Reflector client\n") | |
4325 | { | |
c500ae40 DW |
4326 | int idx_peer = 2; |
4327 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4328 | bgp_node_safi (vty), |
4329 | PEER_FLAG_REFLECTOR_CLIENT); | |
4330 | } | |
6b0655a2 | 4331 | |
596c17ba DW |
4332 | ALIAS_HIDDEN (no_neighbor_route_reflector_client, |
4333 | no_neighbor_route_reflector_client_hidden_cmd, | |
4334 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4335 | NO_STR | |
4336 | NEIGHBOR_STR | |
4337 | NEIGHBOR_ADDR_STR2 | |
4338 | "Configure a neighbor as Route Reflector client\n") | |
4339 | ||
718e3744 | 4340 | /* neighbor route-server-client. */ |
4341 | DEFUN (neighbor_route_server_client, | |
4342 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 4343 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4344 | NEIGHBOR_STR |
4345 | NEIGHBOR_ADDR_STR2 | |
4346 | "Configure a neighbor as Route Server client\n") | |
4347 | { | |
c500ae40 | 4348 | int idx_peer = 1; |
2a3d5731 DW |
4349 | struct peer *peer; |
4350 | ||
c500ae40 | 4351 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
2a3d5731 DW |
4352 | if (! peer) |
4353 | return CMD_WARNING; | |
c500ae40 | 4354 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
2a3d5731 DW |
4355 | bgp_node_safi (vty), |
4356 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 4357 | } |
4358 | ||
596c17ba DW |
4359 | ALIAS_HIDDEN (neighbor_route_server_client, |
4360 | neighbor_route_server_client_hidden_cmd, | |
4361 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4362 | NEIGHBOR_STR | |
4363 | NEIGHBOR_ADDR_STR2 | |
4364 | "Configure a neighbor as Route Server client\n") | |
4365 | ||
718e3744 | 4366 | DEFUN (no_neighbor_route_server_client, |
4367 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 4368 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4369 | NO_STR |
4370 | NEIGHBOR_STR | |
4371 | NEIGHBOR_ADDR_STR2 | |
4372 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 4373 | { |
c500ae40 DW |
4374 | int idx_peer = 2; |
4375 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
2a3d5731 DW |
4376 | bgp_node_safi (vty), |
4377 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 4378 | } |
6b0655a2 | 4379 | |
596c17ba DW |
4380 | ALIAS_HIDDEN (no_neighbor_route_server_client, |
4381 | no_neighbor_route_server_client_hidden_cmd, | |
4382 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4383 | NO_STR | |
4384 | NEIGHBOR_STR | |
4385 | NEIGHBOR_ADDR_STR2 | |
4386 | "Configure a neighbor as Route Server client\n") | |
4387 | ||
fee0f4c6 | 4388 | DEFUN (neighbor_nexthop_local_unchanged, |
4389 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4390 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4391 | NEIGHBOR_STR |
4392 | NEIGHBOR_ADDR_STR2 | |
4393 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
4394 | "Leave link-local nexthop unchanged for this peer\n") | |
4395 | { | |
c500ae40 DW |
4396 | int idx_peer = 1; |
4397 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
fee0f4c6 | 4398 | bgp_node_safi (vty), |
4399 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED ); | |
4400 | } | |
6b0655a2 | 4401 | |
fee0f4c6 | 4402 | DEFUN (no_neighbor_nexthop_local_unchanged, |
4403 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4404 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4405 | NO_STR |
4406 | NEIGHBOR_STR | |
4407 | NEIGHBOR_ADDR_STR2 | |
4408 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
4409 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 4410 | { |
c500ae40 DW |
4411 | int idx_peer = 2; |
4412 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4413 | bgp_node_safi (vty), |
fee0f4c6 | 4414 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED ); |
718e3744 | 4415 | } |
6b0655a2 | 4416 | |
718e3744 | 4417 | DEFUN (neighbor_attr_unchanged, |
4418 | neighbor_attr_unchanged_cmd, | |
1084263f QY |
4419 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged\ |
4420 | [<\ | |
ddbaf941 QY |
4421 | as-path [<next-hop [med]|med [next-hop]>]|\ |
4422 | next-hop [<as-path [med]|med [as-path]>]|\ | |
4423 | med [<as-path [next-hop]|next-hop [as-path]>]\ | |
1084263f | 4424 | >]", |
718e3744 | 4425 | NEIGHBOR_STR |
4426 | NEIGHBOR_ADDR_STR2 | |
4427 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4428 | "As-path attribute\n" | |
4429 | "Nexthop attribute\n" | |
40e718b5 | 4430 | "Med attribute\n" |
1084263f QY |
4431 | "Med attribute\n" |
4432 | "Nexthop attribute\n" | |
4433 | "Nexthop attribute\n" | |
4434 | "As-path attribute\n" | |
4435 | "Med attribute\n" | |
40e718b5 | 4436 | "Med attribute\n" |
718e3744 | 4437 | "As-path attribute\n" |
1084263f QY |
4438 | "Med attribute\n" |
4439 | "As-path attribute\n" | |
4440 | "Nexthop attribute\n" | |
40e718b5 | 4441 | "Nexthop attribute\n" |
1084263f | 4442 | "As-path attribute\n") |
718e3744 | 4443 | { |
40e718b5 QY |
4444 | int idx = 0; |
4445 | char *peer = argv[1]->arg; | |
4446 | u_int16_t flags = 0; | |
718e3744 | 4447 | |
40e718b5 | 4448 | if (argv_find (argv, argc, "as-path", &idx)) |
718e3744 | 4449 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
40e718b5 QY |
4450 | idx = 0; |
4451 | if (argv_find (argv, argc, "next-hop", &idx)) | |
4452 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4453 | idx = 0; | |
4454 | if (argv_find (argv, argc, "med", &idx)) | |
718e3744 | 4455 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
4456 | ||
40e718b5 QY |
4457 | if (!flags) // no flags means all of them! |
4458 | { | |
718e3744 | 4459 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
718e3744 | 4460 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); |
40e718b5 QY |
4461 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
4462 | } | |
718e3744 | 4463 | |
40e718b5 | 4464 | return peer_af_flag_set_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flags); |
718e3744 | 4465 | } |
4466 | ||
596c17ba DW |
4467 | ALIAS_HIDDEN (neighbor_attr_unchanged, |
4468 | neighbor_attr_unchanged_hidden_cmd, | |
4469 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged\ | |
4470 | [<\ | |
4471 | as-path [<next-hop [med]|med [next-hop]>]|\ | |
4472 | next-hop [<as-path [med]|med [as-path]>]|\ | |
4473 | med [<as-path [next-hop]|next-hop [as-path]>]\ | |
4474 | >]", | |
4475 | NEIGHBOR_STR | |
4476 | NEIGHBOR_ADDR_STR2 | |
4477 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4478 | "As-path attribute\n" | |
4479 | "Nexthop attribute\n" | |
4480 | "Med attribute\n" | |
4481 | "Med attribute\n" | |
4482 | "Nexthop attribute\n" | |
4483 | "Nexthop attribute\n" | |
4484 | "As-path attribute\n" | |
4485 | "Med attribute\n" | |
4486 | "Med attribute\n" | |
4487 | "As-path attribute\n" | |
4488 | "Med attribute\n" | |
4489 | "As-path attribute\n" | |
4490 | "Nexthop attribute\n" | |
4491 | "Nexthop attribute\n" | |
4492 | "As-path attribute\n") | |
4493 | ||
718e3744 | 4494 | DEFUN (no_neighbor_attr_unchanged, |
4495 | no_neighbor_attr_unchanged_cmd, | |
1084263f QY |
4496 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged\ |
4497 | [<\ | |
ddbaf941 QY |
4498 | as-path [<next-hop [med]|med [next-hop]>]|\ |
4499 | next-hop [<as-path [med]|med [as-path]>]|\ | |
4500 | med [<as-path [next-hop]|next-hop [as-path]>]\ | |
1084263f | 4501 | >]", |
e52702f2 | 4502 | NO_STR |
718e3744 | 4503 | NEIGHBOR_STR |
4504 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
4505 | "BGP attribute is propagated unchanged to this neighbor\n" |
4506 | "As-path attribute\n" | |
40e718b5 | 4507 | "Nexthop attribute\n" |
31500417 | 4508 | "Med attribute\n" |
1084263f QY |
4509 | "Med attribute\n" |
4510 | "Nexthop attribute\n" | |
4511 | "Nexthop attribute\n" | |
4512 | "As-path attribute\n" | |
4513 | "Med attribute\n" | |
40e718b5 | 4514 | "Med attribute\n" |
718e3744 | 4515 | "As-path attribute\n" |
1084263f QY |
4516 | "Med attribute\n" |
4517 | "As-path attribute\n" | |
4518 | "Nexthop attribute\n" | |
718e3744 | 4519 | "Nexthop attribute\n" |
1084263f | 4520 | "As-path attribute\n") |
718e3744 | 4521 | { |
40e718b5 QY |
4522 | int idx = 0; |
4523 | char *peer = argv[2]->arg; | |
4524 | u_int16_t flags = 0; | |
718e3744 | 4525 | |
40e718b5 | 4526 | if (argv_find (argv, argc, "as-path", &idx)) |
718e3744 | 4527 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
40e718b5 QY |
4528 | idx = 0; |
4529 | if (argv_find (argv, argc, "next-hop", &idx)) | |
4530 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4531 | idx = 0; | |
4532 | if (argv_find (argv, argc, "med", &idx)) | |
718e3744 | 4533 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
4534 | ||
40e718b5 QY |
4535 | if (!flags) // no flags means all of them! |
4536 | { | |
718e3744 | 4537 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
718e3744 | 4538 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); |
40e718b5 QY |
4539 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
4540 | } | |
718e3744 | 4541 | |
40e718b5 | 4542 | return peer_af_flag_unset_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flags); |
718e3744 | 4543 | } |
4544 | ||
596c17ba DW |
4545 | ALIAS_HIDDEN (no_neighbor_attr_unchanged, |
4546 | no_neighbor_attr_unchanged_hidden_cmd, | |
4547 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged\ | |
4548 | [<\ | |
4549 | as-path [<next-hop [med]|med [next-hop]>]|\ | |
4550 | next-hop [<as-path [med]|med [as-path]>]|\ | |
4551 | med [<as-path [next-hop]|next-hop [as-path]>]\ | |
4552 | >]", | |
4553 | NO_STR | |
4554 | NEIGHBOR_STR | |
4555 | NEIGHBOR_ADDR_STR2 | |
4556 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4557 | "As-path attribute\n" | |
4558 | "Nexthop attribute\n" | |
4559 | "Med attribute\n" | |
4560 | "Med attribute\n" | |
4561 | "Nexthop attribute\n" | |
4562 | "Nexthop attribute\n" | |
4563 | "As-path attribute\n" | |
4564 | "Med attribute\n" | |
4565 | "Med attribute\n" | |
4566 | "As-path attribute\n" | |
4567 | "Med attribute\n" | |
4568 | "As-path attribute\n" | |
4569 | "Nexthop attribute\n" | |
4570 | "Nexthop attribute\n" | |
4571 | "As-path attribute\n") | |
4572 | ||
718e3744 | 4573 | |
718e3744 | 4574 | /* EBGP multihop configuration. */ |
94f2b392 | 4575 | static int |
e52702f2 | 4576 | peer_ebgp_multihop_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4577 | const char *ttl_str) |
718e3744 | 4578 | { |
4579 | struct peer *peer; | |
fd79ac91 | 4580 | unsigned int ttl; |
718e3744 | 4581 | |
4582 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4583 | if (! peer) | |
4584 | return CMD_WARNING; | |
4585 | ||
63fa10b5 QY |
4586 | if (peer->conf_if) |
4587 | return bgp_vty_return (vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
4588 | ||
718e3744 | 4589 | if (! ttl_str) |
9b1be336 | 4590 | ttl = MAXTTL; |
718e3744 | 4591 | else |
9b1be336 | 4592 | VTY_GET_INTEGER_RANGE ("TTL", ttl, ttl_str, 1, MAXTTL); |
718e3744 | 4593 | |
89b6d1f8 | 4594 | return bgp_vty_return (vty, peer_ebgp_multihop_set (peer, ttl)); |
718e3744 | 4595 | } |
4596 | ||
94f2b392 | 4597 | static int |
e52702f2 | 4598 | peer_ebgp_multihop_unset_vty (struct vty *vty, const char *ip_str) |
718e3744 | 4599 | { |
4600 | struct peer *peer; | |
4601 | ||
4602 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4603 | if (! peer) | |
4604 | return CMD_WARNING; | |
4605 | ||
89b6d1f8 | 4606 | return bgp_vty_return (vty, peer_ebgp_multihop_unset (peer)); |
718e3744 | 4607 | } |
4608 | ||
4609 | /* neighbor ebgp-multihop. */ | |
4610 | DEFUN (neighbor_ebgp_multihop, | |
4611 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 4612 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 4613 | NEIGHBOR_STR |
4614 | NEIGHBOR_ADDR_STR2 | |
4615 | "Allow EBGP neighbors not on directly connected networks\n") | |
4616 | { | |
c500ae40 DW |
4617 | int idx_peer = 1; |
4618 | return peer_ebgp_multihop_set_vty (vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4619 | } |
4620 | ||
4621 | DEFUN (neighbor_ebgp_multihop_ttl, | |
4622 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 4623 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 4624 | NEIGHBOR_STR |
4625 | NEIGHBOR_ADDR_STR2 | |
4626 | "Allow EBGP neighbors not on directly connected networks\n" | |
4627 | "maximum hop count\n") | |
4628 | { | |
c500ae40 DW |
4629 | int idx_peer = 1; |
4630 | int idx_number = 3; | |
4631 | return peer_ebgp_multihop_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg); | |
718e3744 | 4632 | } |
4633 | ||
4634 | DEFUN (no_neighbor_ebgp_multihop, | |
4635 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 4636 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 4637 | NO_STR |
4638 | NEIGHBOR_STR | |
4639 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4640 | "Allow EBGP neighbors not on directly connected networks\n" |
4641 | "maximum hop count\n") | |
718e3744 | 4642 | { |
c500ae40 DW |
4643 | int idx_peer = 2; |
4644 | return peer_ebgp_multihop_unset_vty (vty, argv[idx_peer]->arg); | |
718e3744 | 4645 | } |
4646 | ||
6b0655a2 | 4647 | |
6ffd2079 | 4648 | /* disable-connected-check */ |
4649 | DEFUN (neighbor_disable_connected_check, | |
4650 | neighbor_disable_connected_check_cmd, | |
a636c635 | 4651 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4652 | NEIGHBOR_STR |
4653 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4654 | "one-hop away EBGP peer using loopback address\n" |
4655 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4656 | { |
c500ae40 DW |
4657 | int idx_peer = 1; |
4658 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4659 | } |
4660 | ||
4661 | DEFUN (no_neighbor_disable_connected_check, | |
4662 | no_neighbor_disable_connected_check_cmd, | |
a636c635 | 4663 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4664 | NO_STR |
4665 | NEIGHBOR_STR | |
4666 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4667 | "one-hop away EBGP peer using loopback address\n" |
4668 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4669 | { |
c500ae40 DW |
4670 | int idx_peer = 2; |
4671 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4672 | } |
4673 | ||
718e3744 | 4674 | DEFUN (neighbor_description, |
4675 | neighbor_description_cmd, | |
e961923c | 4676 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 4677 | NEIGHBOR_STR |
4678 | NEIGHBOR_ADDR_STR2 | |
4679 | "Neighbor specific description\n" | |
4680 | "Up to 80 characters describing this neighbor\n") | |
4681 | { | |
c500ae40 | 4682 | int idx_peer = 1; |
58749582 | 4683 | int idx_line = 3; |
718e3744 | 4684 | struct peer *peer; |
718e3744 | 4685 | char *str; |
718e3744 | 4686 | |
c500ae40 | 4687 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 4688 | if (! peer) |
4689 | return CMD_WARNING; | |
4690 | ||
58749582 | 4691 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 4692 | |
4693 | peer_description_set (peer, str); | |
4694 | ||
3b8b1855 | 4695 | XFREE (MTYPE_TMP, str); |
718e3744 | 4696 | |
4697 | return CMD_SUCCESS; | |
4698 | } | |
4699 | ||
4700 | DEFUN (no_neighbor_description, | |
4701 | no_neighbor_description_cmd, | |
a636c635 | 4702 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description [LINE]", |
718e3744 | 4703 | NO_STR |
4704 | NEIGHBOR_STR | |
4705 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4706 | "Neighbor specific description\n" |
4707 | "Up to 80 characters describing this neighbor\n") | |
718e3744 | 4708 | { |
c500ae40 | 4709 | int idx_peer = 2; |
718e3744 | 4710 | struct peer *peer; |
4711 | ||
c500ae40 | 4712 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 4713 | if (! peer) |
4714 | return CMD_WARNING; | |
4715 | ||
4716 | peer_description_unset (peer); | |
4717 | ||
4718 | return CMD_SUCCESS; | |
4719 | } | |
4720 | ||
6b0655a2 | 4721 | |
718e3744 | 4722 | /* Neighbor update-source. */ |
94f2b392 | 4723 | static int |
e52702f2 | 4724 | peer_update_source_vty (struct vty *vty, const char *peer_str, |
fd79ac91 | 4725 | const char *source_str) |
718e3744 | 4726 | { |
4727 | struct peer *peer; | |
3b69fd51 | 4728 | struct prefix p; |
718e3744 | 4729 | |
4730 | peer = peer_and_group_lookup_vty (vty, peer_str); | |
4731 | if (! peer) | |
4732 | return CMD_WARNING; | |
4733 | ||
a80beece DS |
4734 | if (peer->conf_if) |
4735 | return CMD_WARNING; | |
4736 | ||
718e3744 | 4737 | if (source_str) |
4738 | { | |
c63b83fe JBD |
4739 | union sockunion su; |
4740 | int ret = str2sockunion (source_str, &su); | |
4741 | ||
4742 | if (ret == 0) | |
4743 | peer_update_source_addr_set (peer, &su); | |
718e3744 | 4744 | else |
3b69fd51 DS |
4745 | { |
4746 | if (str2prefix (source_str, &p)) | |
4747 | { | |
4748 | vty_out (vty, "%% Invalid update-source, remove prefix length %s", | |
4749 | VTY_NEWLINE); | |
4750 | return CMD_WARNING; | |
4751 | } | |
4752 | else | |
4753 | peer_update_source_if_set (peer, source_str); | |
4754 | } | |
718e3744 | 4755 | } |
4756 | else | |
4757 | peer_update_source_unset (peer); | |
4758 | ||
4759 | return CMD_SUCCESS; | |
4760 | } | |
4761 | ||
369688c0 PJ |
4762 | #define BGP_UPDATE_SOURCE_HELP_STR \ |
4763 | "IPv4 address\n" \ | |
9a1a331d PJ |
4764 | "IPv6 address\n" \ |
4765 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 4766 | |
718e3744 | 4767 | DEFUN (neighbor_update_source, |
4768 | neighbor_update_source_cmd, | |
9ccf14f7 | 4769 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 4770 | NEIGHBOR_STR |
4771 | NEIGHBOR_ADDR_STR2 | |
4772 | "Source of routing updates\n" | |
369688c0 | 4773 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 4774 | { |
c500ae40 DW |
4775 | int idx_peer = 1; |
4776 | int idx_peer_2 = 3; | |
4777 | return peer_update_source_vty (vty, argv[idx_peer]->arg, argv[idx_peer_2]->arg); | |
718e3744 | 4778 | } |
4779 | ||
4780 | DEFUN (no_neighbor_update_source, | |
4781 | no_neighbor_update_source_cmd, | |
c7178fe7 | 4782 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 4783 | NO_STR |
4784 | NEIGHBOR_STR | |
4785 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
4786 | "Source of routing updates\n" |
4787 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 4788 | { |
c500ae40 DW |
4789 | int idx_peer = 2; |
4790 | return peer_update_source_vty (vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4791 | } |
6b0655a2 | 4792 | |
94f2b392 | 4793 | static int |
e52702f2 QY |
4794 | peer_default_originate_set_vty (struct vty *vty, const char *peer_str, |
4795 | afi_t afi, safi_t safi, | |
fd79ac91 | 4796 | const char *rmap, int set) |
718e3744 | 4797 | { |
4798 | int ret; | |
4799 | struct peer *peer; | |
4800 | ||
4801 | peer = peer_and_group_lookup_vty (vty, peer_str); | |
4802 | if (! peer) | |
4803 | return CMD_WARNING; | |
4804 | ||
4805 | if (set) | |
4806 | ret = peer_default_originate_set (peer, afi, safi, rmap); | |
4807 | else | |
4808 | ret = peer_default_originate_unset (peer, afi, safi); | |
4809 | ||
4810 | return bgp_vty_return (vty, ret); | |
4811 | } | |
4812 | ||
4813 | /* neighbor default-originate. */ | |
4814 | DEFUN (neighbor_default_originate, | |
4815 | neighbor_default_originate_cmd, | |
9ccf14f7 | 4816 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 4817 | NEIGHBOR_STR |
4818 | NEIGHBOR_ADDR_STR2 | |
4819 | "Originate default route to this neighbor\n") | |
4820 | { | |
c500ae40 DW |
4821 | int idx_peer = 1; |
4822 | return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4823 | bgp_node_safi (vty), NULL, 1); |
4824 | } | |
4825 | ||
596c17ba DW |
4826 | ALIAS_HIDDEN (neighbor_default_originate, |
4827 | neighbor_default_originate_hidden_cmd, | |
4828 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
4829 | NEIGHBOR_STR | |
4830 | NEIGHBOR_ADDR_STR2 | |
4831 | "Originate default route to this neighbor\n") | |
4832 | ||
718e3744 | 4833 | DEFUN (neighbor_default_originate_rmap, |
4834 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 4835 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 4836 | NEIGHBOR_STR |
4837 | NEIGHBOR_ADDR_STR2 | |
4838 | "Originate default route to this neighbor\n" | |
4839 | "Route-map to specify criteria to originate default\n" | |
4840 | "route-map name\n") | |
4841 | { | |
c500ae40 DW |
4842 | int idx_peer = 1; |
4843 | int idx_word = 4; | |
4844 | return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4845 | bgp_node_safi (vty), argv[idx_word]->arg, 1); | |
718e3744 | 4846 | } |
4847 | ||
596c17ba DW |
4848 | ALIAS_HIDDEN (neighbor_default_originate_rmap, |
4849 | neighbor_default_originate_rmap_hidden_cmd, | |
4850 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
4851 | NEIGHBOR_STR | |
4852 | NEIGHBOR_ADDR_STR2 | |
4853 | "Originate default route to this neighbor\n" | |
4854 | "Route-map to specify criteria to originate default\n" | |
4855 | "route-map name\n") | |
4856 | ||
718e3744 | 4857 | DEFUN (no_neighbor_default_originate, |
4858 | no_neighbor_default_originate_cmd, | |
a636c635 | 4859 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 4860 | NO_STR |
4861 | NEIGHBOR_STR | |
4862 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4863 | "Originate default route to this neighbor\n" |
4864 | "Route-map to specify criteria to originate default\n" | |
4865 | "route-map name\n") | |
718e3744 | 4866 | { |
c500ae40 DW |
4867 | int idx_peer = 2; |
4868 | return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4869 | bgp_node_safi (vty), NULL, 0); |
4870 | } | |
4871 | ||
596c17ba DW |
4872 | ALIAS_HIDDEN (no_neighbor_default_originate, |
4873 | no_neighbor_default_originate_hidden_cmd, | |
4874 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
4875 | NO_STR | |
4876 | NEIGHBOR_STR | |
4877 | NEIGHBOR_ADDR_STR2 | |
4878 | "Originate default route to this neighbor\n" | |
4879 | "Route-map to specify criteria to originate default\n" | |
4880 | "route-map name\n") | |
4881 | ||
6b0655a2 | 4882 | |
718e3744 | 4883 | /* Set neighbor's BGP port. */ |
94f2b392 | 4884 | static int |
e52702f2 | 4885 | peer_port_vty (struct vty *vty, const char *ip_str, int afi, |
fd79ac91 | 4886 | const char *port_str) |
718e3744 | 4887 | { |
4888 | struct peer *peer; | |
4889 | u_int16_t port; | |
4890 | struct servent *sp; | |
4891 | ||
4892 | peer = peer_lookup_vty (vty, ip_str); | |
4893 | if (! peer) | |
4894 | return CMD_WARNING; | |
4895 | ||
4896 | if (! port_str) | |
e52702f2 | 4897 | { |
718e3744 | 4898 | sp = getservbyname ("bgp", "tcp"); |
4899 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs (sp->s_port); | |
4900 | } | |
4901 | else | |
4902 | { | |
4903 | VTY_GET_INTEGER("port", port, port_str); | |
4904 | } | |
4905 | ||
4906 | peer_port_set (peer, port); | |
4907 | ||
4908 | return CMD_SUCCESS; | |
4909 | } | |
4910 | ||
f418446b | 4911 | /* Set specified peer's BGP port. */ |
718e3744 | 4912 | DEFUN (neighbor_port, |
4913 | neighbor_port_cmd, | |
9ccf14f7 | 4914 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 4915 | NEIGHBOR_STR |
4916 | NEIGHBOR_ADDR_STR | |
4917 | "Neighbor's BGP port\n" | |
4918 | "TCP port number\n") | |
4919 | { | |
c500ae40 DW |
4920 | int idx_ip = 1; |
4921 | int idx_number = 3; | |
4922 | return peer_port_vty (vty, argv[idx_ip]->arg, AFI_IP, argv[idx_number]->arg); | |
718e3744 | 4923 | } |
4924 | ||
4925 | DEFUN (no_neighbor_port, | |
4926 | no_neighbor_port_cmd, | |
9ccf14f7 | 4927 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 4928 | NO_STR |
4929 | NEIGHBOR_STR | |
4930 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
4931 | "Neighbor's BGP port\n" |
4932 | "TCP port number\n") | |
718e3744 | 4933 | { |
c500ae40 DW |
4934 | int idx_ip = 2; |
4935 | return peer_port_vty (vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 4936 | } |
4937 | ||
6b0655a2 | 4938 | |
718e3744 | 4939 | /* neighbor weight. */ |
94f2b392 | 4940 | static int |
e52702f2 | 4941 | peer_weight_set_vty (struct vty *vty, const char *ip_str, |
d93f7ffc | 4942 | afi_t afi, safi_t safi, |
fd79ac91 | 4943 | const char *weight_str) |
718e3744 | 4944 | { |
1f9a9fff | 4945 | int ret; |
718e3744 | 4946 | struct peer *peer; |
4947 | unsigned long weight; | |
4948 | ||
4949 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4950 | if (! peer) | |
4951 | return CMD_WARNING; | |
4952 | ||
4953 | VTY_GET_INTEGER_RANGE("weight", weight, weight_str, 0, 65535); | |
4954 | ||
d93f7ffc | 4955 | ret = peer_weight_set (peer, afi, safi, weight); |
1f9a9fff | 4956 | return bgp_vty_return (vty, ret); |
718e3744 | 4957 | } |
4958 | ||
94f2b392 | 4959 | static int |
d93f7ffc DW |
4960 | peer_weight_unset_vty (struct vty *vty, const char *ip_str, |
4961 | afi_t afi, safi_t safi) | |
718e3744 | 4962 | { |
1f9a9fff | 4963 | int ret; |
718e3744 | 4964 | struct peer *peer; |
4965 | ||
4966 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4967 | if (! peer) | |
4968 | return CMD_WARNING; | |
4969 | ||
d93f7ffc | 4970 | ret = peer_weight_unset (peer, afi, safi); |
1f9a9fff | 4971 | return bgp_vty_return (vty, ret); |
718e3744 | 4972 | } |
4973 | ||
4974 | DEFUN (neighbor_weight, | |
4975 | neighbor_weight_cmd, | |
9ccf14f7 | 4976 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 4977 | NEIGHBOR_STR |
4978 | NEIGHBOR_ADDR_STR2 | |
4979 | "Set default weight for routes from this neighbor\n" | |
4980 | "default weight\n") | |
4981 | { | |
c500ae40 DW |
4982 | int idx_peer = 1; |
4983 | int idx_number = 3; | |
e52702f2 QY |
4984 | return peer_weight_set_vty (vty, |
4985 | argv[idx_peer]->arg, | |
4986 | bgp_node_afi (vty), | |
4987 | bgp_node_safi (vty), | |
4988 | argv[idx_number]->arg); | |
718e3744 | 4989 | } |
4990 | ||
596c17ba DW |
4991 | ALIAS_HIDDEN (neighbor_weight, |
4992 | neighbor_weight_hidden_cmd, | |
4993 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
4994 | NEIGHBOR_STR | |
4995 | NEIGHBOR_ADDR_STR2 | |
4996 | "Set default weight for routes from this neighbor\n" | |
4997 | "default weight\n") | |
4998 | ||
718e3744 | 4999 | DEFUN (no_neighbor_weight, |
5000 | no_neighbor_weight_cmd, | |
9ccf14f7 | 5001 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 5002 | NO_STR |
5003 | NEIGHBOR_STR | |
5004 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5005 | "Set default weight for routes from this neighbor\n" |
5006 | "default weight\n") | |
718e3744 | 5007 | { |
c500ae40 | 5008 | int idx_peer = 2; |
e52702f2 | 5009 | return peer_weight_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty)); |
718e3744 | 5010 | } |
5011 | ||
596c17ba DW |
5012 | ALIAS_HIDDEN (no_neighbor_weight, |
5013 | no_neighbor_weight_hidden_cmd, | |
5014 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
5015 | NO_STR | |
5016 | NEIGHBOR_STR | |
5017 | NEIGHBOR_ADDR_STR2 | |
5018 | "Set default weight for routes from this neighbor\n" | |
5019 | "default weight\n") | |
5020 | ||
6b0655a2 | 5021 | |
718e3744 | 5022 | /* Override capability negotiation. */ |
5023 | DEFUN (neighbor_override_capability, | |
5024 | neighbor_override_capability_cmd, | |
9ccf14f7 | 5025 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5026 | NEIGHBOR_STR |
5027 | NEIGHBOR_ADDR_STR2 | |
5028 | "Override capability negotiation result\n") | |
5029 | { | |
c500ae40 DW |
5030 | int idx_peer = 1; |
5031 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5032 | } |
5033 | ||
5034 | DEFUN (no_neighbor_override_capability, | |
5035 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 5036 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5037 | NO_STR |
5038 | NEIGHBOR_STR | |
5039 | NEIGHBOR_ADDR_STR2 | |
5040 | "Override capability negotiation result\n") | |
5041 | { | |
c500ae40 DW |
5042 | int idx_peer = 2; |
5043 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5044 | } |
6b0655a2 | 5045 | |
718e3744 | 5046 | DEFUN (neighbor_strict_capability, |
5047 | neighbor_strict_capability_cmd, | |
9ccf14f7 | 5048 | "neighbor <A.B.C.D|X:X::X:X> strict-capability-match", |
718e3744 | 5049 | NEIGHBOR_STR |
5050 | NEIGHBOR_ADDR_STR | |
5051 | "Strict capability negotiation match\n") | |
5052 | { | |
c500ae40 DW |
5053 | int idx_ip = 1; |
5054 | return peer_flag_set_vty (vty, argv[idx_ip]->arg, PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 5055 | } |
5056 | ||
5057 | DEFUN (no_neighbor_strict_capability, | |
5058 | no_neighbor_strict_capability_cmd, | |
9ccf14f7 | 5059 | "no neighbor <A.B.C.D|X:X::X:X> strict-capability-match", |
718e3744 | 5060 | NO_STR |
5061 | NEIGHBOR_STR | |
5062 | NEIGHBOR_ADDR_STR | |
5063 | "Strict capability negotiation match\n") | |
5064 | { | |
c500ae40 DW |
5065 | int idx_ip = 2; |
5066 | return peer_flag_unset_vty (vty, argv[idx_ip]->arg, PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 5067 | } |
6b0655a2 | 5068 | |
94f2b392 | 5069 | static int |
e52702f2 | 5070 | peer_timers_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 5071 | const char *keep_str, const char *hold_str) |
718e3744 | 5072 | { |
5073 | int ret; | |
5074 | struct peer *peer; | |
5075 | u_int32_t keepalive; | |
5076 | u_int32_t holdtime; | |
5077 | ||
5078 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5079 | if (! peer) | |
5080 | return CMD_WARNING; | |
5081 | ||
5082 | VTY_GET_INTEGER_RANGE ("Keepalive", keepalive, keep_str, 0, 65535); | |
5083 | VTY_GET_INTEGER_RANGE ("Holdtime", holdtime, hold_str, 0, 65535); | |
5084 | ||
5085 | ret = peer_timers_set (peer, keepalive, holdtime); | |
5086 | ||
5087 | return bgp_vty_return (vty, ret); | |
5088 | } | |
6b0655a2 | 5089 | |
94f2b392 | 5090 | static int |
fd79ac91 | 5091 | peer_timers_unset_vty (struct vty *vty, const char *ip_str) |
718e3744 | 5092 | { |
5093 | int ret; | |
5094 | struct peer *peer; | |
5095 | ||
0c412461 | 5096 | peer = peer_and_group_lookup_vty (vty, ip_str); |
718e3744 | 5097 | if (! peer) |
5098 | return CMD_WARNING; | |
5099 | ||
5100 | ret = peer_timers_unset (peer); | |
5101 | ||
5102 | return bgp_vty_return (vty, ret); | |
5103 | } | |
5104 | ||
5105 | DEFUN (neighbor_timers, | |
5106 | neighbor_timers_cmd, | |
9ccf14f7 | 5107 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 5108 | NEIGHBOR_STR |
5109 | NEIGHBOR_ADDR_STR2 | |
5110 | "BGP per neighbor timers\n" | |
5111 | "Keepalive interval\n" | |
5112 | "Holdtime\n") | |
5113 | { | |
c500ae40 DW |
5114 | int idx_peer = 1; |
5115 | int idx_number = 3; | |
5116 | int idx_number_2 = 4; | |
5117 | return peer_timers_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg); | |
718e3744 | 5118 | } |
5119 | ||
5120 | DEFUN (no_neighbor_timers, | |
5121 | no_neighbor_timers_cmd, | |
9ccf14f7 | 5122 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 5123 | NO_STR |
5124 | NEIGHBOR_STR | |
5125 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5126 | "BGP per neighbor timers\n" |
5127 | "Keepalive interval\n" | |
5128 | "Holdtime\n") | |
718e3744 | 5129 | { |
c500ae40 DW |
5130 | int idx_peer = 2; |
5131 | return peer_timers_unset_vty (vty, argv[idx_peer]->arg); | |
718e3744 | 5132 | } |
6b0655a2 | 5133 | |
813d4307 | 5134 | |
94f2b392 | 5135 | static int |
e52702f2 | 5136 | peer_timers_connect_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 5137 | const char *time_str) |
718e3744 | 5138 | { |
5139 | int ret; | |
5140 | struct peer *peer; | |
5141 | u_int32_t connect; | |
5142 | ||
966f821c | 5143 | peer = peer_and_group_lookup_vty (vty, ip_str); |
718e3744 | 5144 | if (! peer) |
5145 | return CMD_WARNING; | |
5146 | ||
5147 | VTY_GET_INTEGER_RANGE ("Connect time", connect, time_str, 0, 65535); | |
5148 | ||
5149 | ret = peer_timers_connect_set (peer, connect); | |
5150 | ||
966f821c | 5151 | return bgp_vty_return (vty, ret); |
718e3744 | 5152 | } |
5153 | ||
94f2b392 | 5154 | static int |
fd79ac91 | 5155 | peer_timers_connect_unset_vty (struct vty *vty, const char *ip_str) |
718e3744 | 5156 | { |
5157 | int ret; | |
5158 | struct peer *peer; | |
5159 | ||
5160 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5161 | if (! peer) | |
5162 | return CMD_WARNING; | |
5163 | ||
5164 | ret = peer_timers_connect_unset (peer); | |
5165 | ||
966f821c | 5166 | return bgp_vty_return (vty, ret); |
718e3744 | 5167 | } |
5168 | ||
5169 | DEFUN (neighbor_timers_connect, | |
5170 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 5171 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 5172 | NEIGHBOR_STR |
966f821c | 5173 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5174 | "BGP per neighbor timers\n" |
5175 | "BGP connect timer\n" | |
5176 | "Connect timer\n") | |
5177 | { | |
c500ae40 DW |
5178 | int idx_peer = 1; |
5179 | int idx_number = 4; | |
5180 | return peer_timers_connect_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg); | |
718e3744 | 5181 | } |
5182 | ||
5183 | DEFUN (no_neighbor_timers_connect, | |
5184 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 5185 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 5186 | NO_STR |
5187 | NEIGHBOR_STR | |
966f821c | 5188 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5189 | "BGP per neighbor timers\n" |
8334fd5a DW |
5190 | "BGP connect timer\n" |
5191 | "Connect timer\n") | |
718e3744 | 5192 | { |
c500ae40 DW |
5193 | int idx_peer = 2; |
5194 | return peer_timers_connect_unset_vty (vty, argv[idx_peer]->arg); | |
718e3744 | 5195 | } |
5196 | ||
6b0655a2 | 5197 | |
94f2b392 | 5198 | static int |
e52702f2 QY |
5199 | peer_advertise_interval_vty (struct vty *vty, const char *ip_str, |
5200 | const char *time_str, int set) | |
718e3744 | 5201 | { |
5202 | int ret; | |
5203 | struct peer *peer; | |
5204 | u_int32_t routeadv = 0; | |
5205 | ||
966f821c | 5206 | peer = peer_and_group_lookup_vty (vty, ip_str); |
718e3744 | 5207 | if (! peer) |
5208 | return CMD_WARNING; | |
5209 | ||
5210 | if (time_str) | |
5211 | VTY_GET_INTEGER_RANGE ("advertise interval", routeadv, time_str, 0, 600); | |
5212 | ||
5213 | if (set) | |
5214 | ret = peer_advertise_interval_set (peer, routeadv); | |
5215 | else | |
5216 | ret = peer_advertise_interval_unset (peer); | |
5217 | ||
966f821c | 5218 | return bgp_vty_return (vty, ret); |
718e3744 | 5219 | } |
5220 | ||
5221 | DEFUN (neighbor_advertise_interval, | |
5222 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5223 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 5224 | NEIGHBOR_STR |
966f821c | 5225 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5226 | "Minimum interval between sending BGP routing updates\n" |
5227 | "time in seconds\n") | |
5228 | { | |
c500ae40 DW |
5229 | int idx_peer = 1; |
5230 | int idx_number = 3; | |
5231 | return peer_advertise_interval_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg, 1); | |
718e3744 | 5232 | } |
5233 | ||
5234 | DEFUN (no_neighbor_advertise_interval, | |
5235 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5236 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 5237 | NO_STR |
5238 | NEIGHBOR_STR | |
966f821c | 5239 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
5240 | "Minimum interval between sending BGP routing updates\n" |
5241 | "time in seconds\n") | |
718e3744 | 5242 | { |
c500ae40 DW |
5243 | int idx_peer = 2; |
5244 | return peer_advertise_interval_vty (vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 5245 | } |
5246 | ||
6b0655a2 | 5247 | |
518f0eb1 DS |
5248 | /* Time to wait before processing route-map updates */ |
5249 | DEFUN (bgp_set_route_map_delay_timer, | |
5250 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 5251 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
5252 | SET_STR |
5253 | "BGP route-map delay timer\n" | |
5254 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 5255 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 5256 | { |
c500ae40 | 5257 | int idx_number = 3; |
518f0eb1 | 5258 | u_int32_t rmap_delay_timer; |
518f0eb1 | 5259 | |
c500ae40 | 5260 | if (argv[idx_number]->arg) |
518f0eb1 | 5261 | { |
c500ae40 | 5262 | VTY_GET_INTEGER_RANGE ("delay-timer", rmap_delay_timer, argv[idx_number]->arg, 0, 600); |
5fe9f963 | 5263 | bm->rmap_update_timer = rmap_delay_timer; |
518f0eb1 DS |
5264 | |
5265 | /* if the dynamic update handling is being disabled, and a timer is | |
5266 | * running, stop the timer and act as if the timer has already fired. | |
5267 | */ | |
5fe9f963 | 5268 | if (!rmap_delay_timer && bm->t_rmap_update ) |
518f0eb1 | 5269 | { |
5fe9f963 | 5270 | BGP_TIMER_OFF(bm->t_rmap_update); |
5271 | thread_execute (bm->master, bgp_route_map_update_timer, NULL, 0); | |
518f0eb1 DS |
5272 | } |
5273 | return CMD_SUCCESS; | |
5274 | } | |
5275 | else | |
ffd0c037 | 5276 | return CMD_WARNING; |
518f0eb1 DS |
5277 | } |
5278 | ||
5279 | DEFUN (no_bgp_set_route_map_delay_timer, | |
5280 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 5281 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 5282 | NO_STR |
3a2d747c | 5283 | BGP_STR |
518f0eb1 | 5284 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
5285 | "Reset to default time to wait for processing route-map changes\n" |
5286 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 5287 | { |
518f0eb1 | 5288 | |
5fe9f963 | 5289 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 DS |
5290 | |
5291 | return CMD_SUCCESS; | |
5292 | } | |
5293 | ||
f414725f | 5294 | |
718e3744 | 5295 | /* neighbor interface */ |
94f2b392 | 5296 | static int |
fd79ac91 | 5297 | peer_interface_vty (struct vty *vty, const char *ip_str, const char *str) |
718e3744 | 5298 | { |
718e3744 | 5299 | struct peer *peer; |
5300 | ||
5301 | peer = peer_lookup_vty (vty, ip_str); | |
a80beece | 5302 | if (! peer || peer->conf_if) |
718e3744 | 5303 | return CMD_WARNING; |
5304 | ||
5305 | if (str) | |
ffd0c037 | 5306 | peer_interface_set (peer, str); |
718e3744 | 5307 | else |
ffd0c037 | 5308 | peer_interface_unset (peer); |
718e3744 | 5309 | |
5310 | return CMD_SUCCESS; | |
5311 | } | |
5312 | ||
5313 | DEFUN (neighbor_interface, | |
5314 | neighbor_interface_cmd, | |
9ccf14f7 | 5315 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 5316 | NEIGHBOR_STR |
5317 | NEIGHBOR_ADDR_STR | |
5318 | "Interface\n" | |
5319 | "Interface name\n") | |
5320 | { | |
c500ae40 DW |
5321 | int idx_ip = 1; |
5322 | int idx_word = 3; | |
00d7d2d3 | 5323 | return peer_interface_vty (vty, argv[idx_ip]->arg, argv[idx_word]->arg); |
718e3744 | 5324 | } |
5325 | ||
5326 | DEFUN (no_neighbor_interface, | |
5327 | no_neighbor_interface_cmd, | |
9ccf14f7 | 5328 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 5329 | NO_STR |
5330 | NEIGHBOR_STR | |
16cedbb0 | 5331 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5332 | "Interface\n" |
5333 | "Interface name\n") | |
5334 | { | |
c500ae40 DW |
5335 | int idx_peer = 2; |
5336 | return peer_interface_vty (vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5337 | } |
6b0655a2 | 5338 | |
718e3744 | 5339 | /* Set distribute list to the peer. */ |
94f2b392 | 5340 | static int |
e52702f2 | 5341 | peer_distribute_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 5342 | afi_t afi, safi_t safi, |
5343 | const char *name_str, const char *direct_str) | |
718e3744 | 5344 | { |
5345 | int ret; | |
5346 | struct peer *peer; | |
5347 | int direct = FILTER_IN; | |
5348 | ||
5349 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5350 | if (! peer) | |
5351 | return CMD_WARNING; | |
5352 | ||
5353 | /* Check filter direction. */ | |
5354 | if (strncmp (direct_str, "i", 1) == 0) | |
5355 | direct = FILTER_IN; | |
5356 | else if (strncmp (direct_str, "o", 1) == 0) | |
5357 | direct = FILTER_OUT; | |
5358 | ||
5359 | ret = peer_distribute_set (peer, afi, safi, direct, name_str); | |
5360 | ||
5361 | return bgp_vty_return (vty, ret); | |
5362 | } | |
5363 | ||
94f2b392 | 5364 | static int |
fd79ac91 | 5365 | peer_distribute_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
5366 | safi_t safi, const char *direct_str) | |
718e3744 | 5367 | { |
5368 | int ret; | |
5369 | struct peer *peer; | |
5370 | int direct = FILTER_IN; | |
5371 | ||
5372 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5373 | if (! peer) | |
5374 | return CMD_WARNING; | |
5375 | ||
5376 | /* Check filter direction. */ | |
5377 | if (strncmp (direct_str, "i", 1) == 0) | |
5378 | direct = FILTER_IN; | |
5379 | else if (strncmp (direct_str, "o", 1) == 0) | |
5380 | direct = FILTER_OUT; | |
5381 | ||
5382 | ret = peer_distribute_unset (peer, afi, safi, direct); | |
5383 | ||
5384 | return bgp_vty_return (vty, ret); | |
5385 | } | |
5386 | ||
5387 | DEFUN (neighbor_distribute_list, | |
5388 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 5389 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5390 | NEIGHBOR_STR |
5391 | NEIGHBOR_ADDR_STR2 | |
5392 | "Filter updates to/from this neighbor\n" | |
5393 | "IP access-list number\n" | |
5394 | "IP access-list number (expanded range)\n" | |
5395 | "IP Access-list name\n" | |
5396 | "Filter incoming updates\n" | |
5397 | "Filter outgoing updates\n") | |
5398 | { | |
c500ae40 DW |
5399 | int idx_peer = 1; |
5400 | int idx_acl = 3; | |
5401 | int idx_in_out = 4; | |
5402 | return peer_distribute_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5403 | bgp_node_safi (vty), argv[idx_acl]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5404 | } |
5405 | ||
596c17ba DW |
5406 | ALIAS_HIDDEN (neighbor_distribute_list, |
5407 | neighbor_distribute_list_hidden_cmd, | |
5408 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5409 | NEIGHBOR_STR | |
5410 | NEIGHBOR_ADDR_STR2 | |
5411 | "Filter updates to/from this neighbor\n" | |
5412 | "IP access-list number\n" | |
5413 | "IP access-list number (expanded range)\n" | |
5414 | "IP Access-list name\n" | |
5415 | "Filter incoming updates\n" | |
5416 | "Filter outgoing updates\n") | |
5417 | ||
718e3744 | 5418 | DEFUN (no_neighbor_distribute_list, |
5419 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 5420 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5421 | NO_STR |
5422 | NEIGHBOR_STR | |
5423 | NEIGHBOR_ADDR_STR2 | |
5424 | "Filter updates to/from this neighbor\n" | |
5425 | "IP access-list number\n" | |
5426 | "IP access-list number (expanded range)\n" | |
5427 | "IP Access-list name\n" | |
5428 | "Filter incoming updates\n" | |
5429 | "Filter outgoing updates\n") | |
5430 | { | |
c500ae40 DW |
5431 | int idx_peer = 2; |
5432 | int idx_in_out = 5; | |
5433 | return peer_distribute_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5434 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 5435 | } |
6b0655a2 | 5436 | |
596c17ba DW |
5437 | ALIAS_HIDDEN (no_neighbor_distribute_list, |
5438 | no_neighbor_distribute_list_hidden_cmd, | |
5439 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5440 | NO_STR | |
5441 | NEIGHBOR_STR | |
5442 | NEIGHBOR_ADDR_STR2 | |
5443 | "Filter updates to/from this neighbor\n" | |
5444 | "IP access-list number\n" | |
5445 | "IP access-list number (expanded range)\n" | |
5446 | "IP Access-list name\n" | |
5447 | "Filter incoming updates\n" | |
5448 | "Filter outgoing updates\n") | |
5449 | ||
718e3744 | 5450 | /* Set prefix list to the peer. */ |
94f2b392 | 5451 | static int |
fd79ac91 | 5452 | peer_prefix_list_set_vty (struct vty *vty, const char *ip_str, afi_t afi, |
e52702f2 | 5453 | safi_t safi, const char *name_str, |
fd79ac91 | 5454 | const char *direct_str) |
718e3744 | 5455 | { |
5456 | int ret; | |
5457 | struct peer *peer; | |
5458 | int direct = FILTER_IN; | |
5459 | ||
5460 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5461 | if (! peer) | |
5462 | return CMD_WARNING; | |
5463 | ||
5464 | /* Check filter direction. */ | |
5465 | if (strncmp (direct_str, "i", 1) == 0) | |
5466 | direct = FILTER_IN; | |
5467 | else if (strncmp (direct_str, "o", 1) == 0) | |
5468 | direct = FILTER_OUT; | |
5469 | ||
5470 | ret = peer_prefix_list_set (peer, afi, safi, direct, name_str); | |
5471 | ||
5472 | return bgp_vty_return (vty, ret); | |
5473 | } | |
5474 | ||
94f2b392 | 5475 | static int |
fd79ac91 | 5476 | peer_prefix_list_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
5477 | safi_t safi, const char *direct_str) | |
718e3744 | 5478 | { |
5479 | int ret; | |
5480 | struct peer *peer; | |
5481 | int direct = FILTER_IN; | |
5482 | ||
5483 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5484 | if (! peer) | |
5485 | return CMD_WARNING; | |
e52702f2 | 5486 | |
718e3744 | 5487 | /* Check filter direction. */ |
5488 | if (strncmp (direct_str, "i", 1) == 0) | |
5489 | direct = FILTER_IN; | |
5490 | else if (strncmp (direct_str, "o", 1) == 0) | |
5491 | direct = FILTER_OUT; | |
5492 | ||
5493 | ret = peer_prefix_list_unset (peer, afi, safi, direct); | |
5494 | ||
5495 | return bgp_vty_return (vty, ret); | |
5496 | } | |
5497 | ||
5498 | DEFUN (neighbor_prefix_list, | |
5499 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 5500 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5501 | NEIGHBOR_STR |
5502 | NEIGHBOR_ADDR_STR2 | |
5503 | "Filter updates to/from this neighbor\n" | |
5504 | "Name of a prefix list\n" | |
5505 | "Filter incoming updates\n" | |
5506 | "Filter outgoing updates\n") | |
5507 | { | |
c500ae40 DW |
5508 | int idx_peer = 1; |
5509 | int idx_word = 3; | |
5510 | int idx_in_out = 4; | |
5511 | return peer_prefix_list_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5512 | bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5513 | } |
5514 | ||
596c17ba DW |
5515 | ALIAS_HIDDEN (neighbor_prefix_list, |
5516 | neighbor_prefix_list_hidden_cmd, | |
5517 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5518 | NEIGHBOR_STR | |
5519 | NEIGHBOR_ADDR_STR2 | |
5520 | "Filter updates to/from this neighbor\n" | |
5521 | "Name of a prefix list\n" | |
5522 | "Filter incoming updates\n" | |
5523 | "Filter outgoing updates\n") | |
5524 | ||
718e3744 | 5525 | DEFUN (no_neighbor_prefix_list, |
5526 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 5527 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5528 | NO_STR |
5529 | NEIGHBOR_STR | |
5530 | NEIGHBOR_ADDR_STR2 | |
5531 | "Filter updates to/from this neighbor\n" | |
5532 | "Name of a prefix list\n" | |
5533 | "Filter incoming updates\n" | |
5534 | "Filter outgoing updates\n") | |
5535 | { | |
c500ae40 DW |
5536 | int idx_peer = 2; |
5537 | int idx_in_out = 5; | |
5538 | return peer_prefix_list_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5539 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 5540 | } |
6b0655a2 | 5541 | |
596c17ba DW |
5542 | ALIAS_HIDDEN (no_neighbor_prefix_list, |
5543 | no_neighbor_prefix_list_hidden_cmd, | |
5544 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5545 | NO_STR | |
5546 | NEIGHBOR_STR | |
5547 | NEIGHBOR_ADDR_STR2 | |
5548 | "Filter updates to/from this neighbor\n" | |
5549 | "Name of a prefix list\n" | |
5550 | "Filter incoming updates\n" | |
5551 | "Filter outgoing updates\n") | |
5552 | ||
94f2b392 | 5553 | static int |
e52702f2 | 5554 | peer_aslist_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 5555 | afi_t afi, safi_t safi, |
5556 | const char *name_str, const char *direct_str) | |
718e3744 | 5557 | { |
5558 | int ret; | |
5559 | struct peer *peer; | |
5560 | int direct = FILTER_IN; | |
5561 | ||
5562 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5563 | if (! peer) | |
5564 | return CMD_WARNING; | |
5565 | ||
5566 | /* Check filter direction. */ | |
5567 | if (strncmp (direct_str, "i", 1) == 0) | |
5568 | direct = FILTER_IN; | |
5569 | else if (strncmp (direct_str, "o", 1) == 0) | |
5570 | direct = FILTER_OUT; | |
5571 | ||
5572 | ret = peer_aslist_set (peer, afi, safi, direct, name_str); | |
5573 | ||
5574 | return bgp_vty_return (vty, ret); | |
5575 | } | |
5576 | ||
94f2b392 | 5577 | static int |
e52702f2 | 5578 | peer_aslist_unset_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 5579 | afi_t afi, safi_t safi, |
5580 | const char *direct_str) | |
718e3744 | 5581 | { |
5582 | int ret; | |
5583 | struct peer *peer; | |
5584 | int direct = FILTER_IN; | |
5585 | ||
5586 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5587 | if (! peer) | |
5588 | return CMD_WARNING; | |
5589 | ||
5590 | /* Check filter direction. */ | |
5591 | if (strncmp (direct_str, "i", 1) == 0) | |
5592 | direct = FILTER_IN; | |
5593 | else if (strncmp (direct_str, "o", 1) == 0) | |
5594 | direct = FILTER_OUT; | |
5595 | ||
5596 | ret = peer_aslist_unset (peer, afi, safi, direct); | |
5597 | ||
5598 | return bgp_vty_return (vty, ret); | |
5599 | } | |
5600 | ||
5601 | DEFUN (neighbor_filter_list, | |
5602 | neighbor_filter_list_cmd, | |
9ccf14f7 | 5603 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5604 | NEIGHBOR_STR |
5605 | NEIGHBOR_ADDR_STR2 | |
5606 | "Establish BGP filters\n" | |
5607 | "AS path access-list name\n" | |
5608 | "Filter incoming routes\n" | |
5609 | "Filter outgoing routes\n") | |
5610 | { | |
c500ae40 DW |
5611 | int idx_peer = 1; |
5612 | int idx_word = 3; | |
5613 | int idx_in_out = 4; | |
5614 | return peer_aslist_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5615 | bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5616 | } |
5617 | ||
596c17ba DW |
5618 | ALIAS_HIDDEN (neighbor_filter_list, |
5619 | neighbor_filter_list_hidden_cmd, | |
5620 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5621 | NEIGHBOR_STR | |
5622 | NEIGHBOR_ADDR_STR2 | |
5623 | "Establish BGP filters\n" | |
5624 | "AS path access-list name\n" | |
5625 | "Filter incoming routes\n" | |
5626 | "Filter outgoing routes\n") | |
5627 | ||
718e3744 | 5628 | DEFUN (no_neighbor_filter_list, |
5629 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 5630 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5631 | NO_STR |
5632 | NEIGHBOR_STR | |
5633 | NEIGHBOR_ADDR_STR2 | |
5634 | "Establish BGP filters\n" | |
5635 | "AS path access-list name\n" | |
5636 | "Filter incoming routes\n" | |
5637 | "Filter outgoing routes\n") | |
5638 | { | |
c500ae40 DW |
5639 | int idx_peer = 2; |
5640 | int idx_in_out = 5; | |
5641 | return peer_aslist_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5642 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 5643 | } |
6b0655a2 | 5644 | |
596c17ba DW |
5645 | ALIAS_HIDDEN (no_neighbor_filter_list, |
5646 | no_neighbor_filter_list_hidden_cmd, | |
5647 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5648 | NO_STR | |
5649 | NEIGHBOR_STR | |
5650 | NEIGHBOR_ADDR_STR2 | |
5651 | "Establish BGP filters\n" | |
5652 | "AS path access-list name\n" | |
5653 | "Filter incoming routes\n" | |
5654 | "Filter outgoing routes\n") | |
5655 | ||
718e3744 | 5656 | /* Set route-map to the peer. */ |
94f2b392 | 5657 | static int |
e52702f2 | 5658 | peer_route_map_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 5659 | afi_t afi, safi_t safi, |
5660 | const char *name_str, const char *direct_str) | |
718e3744 | 5661 | { |
5662 | int ret; | |
5663 | struct peer *peer; | |
fee0f4c6 | 5664 | int direct = RMAP_IN; |
718e3744 | 5665 | |
5666 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5667 | if (! peer) | |
5668 | return CMD_WARNING; | |
5669 | ||
5670 | /* Check filter direction. */ | |
fee0f4c6 | 5671 | if (strncmp (direct_str, "in", 2) == 0) |
5672 | direct = RMAP_IN; | |
718e3744 | 5673 | else if (strncmp (direct_str, "o", 1) == 0) |
fee0f4c6 | 5674 | direct = RMAP_OUT; |
718e3744 | 5675 | |
5676 | ret = peer_route_map_set (peer, afi, safi, direct, name_str); | |
5677 | ||
5678 | return bgp_vty_return (vty, ret); | |
5679 | } | |
5680 | ||
94f2b392 | 5681 | static int |
fd79ac91 | 5682 | peer_route_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
5683 | safi_t safi, const char *direct_str) | |
718e3744 | 5684 | { |
5685 | int ret; | |
5686 | struct peer *peer; | |
fee0f4c6 | 5687 | int direct = RMAP_IN; |
718e3744 | 5688 | |
5689 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5690 | if (! peer) | |
5691 | return CMD_WARNING; | |
5692 | ||
5693 | /* Check filter direction. */ | |
fee0f4c6 | 5694 | if (strncmp (direct_str, "in", 2) == 0) |
5695 | direct = RMAP_IN; | |
718e3744 | 5696 | else if (strncmp (direct_str, "o", 1) == 0) |
fee0f4c6 | 5697 | direct = RMAP_OUT; |
718e3744 | 5698 | |
5699 | ret = peer_route_map_unset (peer, afi, safi, direct); | |
5700 | ||
5701 | return bgp_vty_return (vty, ret); | |
5702 | } | |
5703 | ||
5704 | DEFUN (neighbor_route_map, | |
5705 | neighbor_route_map_cmd, | |
9ccf14f7 | 5706 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5707 | NEIGHBOR_STR |
5708 | NEIGHBOR_ADDR_STR2 | |
5709 | "Apply route map to neighbor\n" | |
5710 | "Name of route map\n" | |
5711 | "Apply map to incoming routes\n" | |
2a3d5731 | 5712 | "Apply map to outbound routes\n") |
718e3744 | 5713 | { |
c500ae40 DW |
5714 | int idx_peer = 1; |
5715 | int idx_word = 3; | |
5716 | int idx_in_out = 4; | |
5717 | return peer_route_map_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5718 | bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5719 | } |
5720 | ||
596c17ba DW |
5721 | ALIAS_HIDDEN (neighbor_route_map, |
5722 | neighbor_route_map_hidden_cmd, | |
5723 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5724 | NEIGHBOR_STR | |
5725 | NEIGHBOR_ADDR_STR2 | |
5726 | "Apply route map to neighbor\n" | |
5727 | "Name of route map\n" | |
5728 | "Apply map to incoming routes\n" | |
5729 | "Apply map to outbound routes\n") | |
5730 | ||
718e3744 | 5731 | DEFUN (no_neighbor_route_map, |
5732 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 5733 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5734 | NO_STR |
5735 | NEIGHBOR_STR | |
5736 | NEIGHBOR_ADDR_STR2 | |
5737 | "Apply route map to neighbor\n" | |
5738 | "Name of route map\n" | |
5739 | "Apply map to incoming routes\n" | |
2a3d5731 | 5740 | "Apply map to outbound routes\n") |
718e3744 | 5741 | { |
c500ae40 DW |
5742 | int idx_peer = 2; |
5743 | int idx_in_out = 5; | |
5744 | return peer_route_map_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5745 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 5746 | } |
6b0655a2 | 5747 | |
596c17ba DW |
5748 | ALIAS_HIDDEN (no_neighbor_route_map, |
5749 | no_neighbor_route_map_hidden_cmd, | |
5750 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5751 | NO_STR | |
5752 | NEIGHBOR_STR | |
5753 | NEIGHBOR_ADDR_STR2 | |
5754 | "Apply route map to neighbor\n" | |
5755 | "Name of route map\n" | |
5756 | "Apply map to incoming routes\n" | |
5757 | "Apply map to outbound routes\n") | |
5758 | ||
718e3744 | 5759 | /* Set unsuppress-map to the peer. */ |
94f2b392 | 5760 | static int |
fd79ac91 | 5761 | peer_unsuppress_map_set_vty (struct vty *vty, const char *ip_str, afi_t afi, |
5762 | safi_t safi, const char *name_str) | |
718e3744 | 5763 | { |
5764 | int ret; | |
5765 | struct peer *peer; | |
5766 | ||
5767 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5768 | if (! peer) | |
5769 | return CMD_WARNING; | |
5770 | ||
5771 | ret = peer_unsuppress_map_set (peer, afi, safi, name_str); | |
5772 | ||
5773 | return bgp_vty_return (vty, ret); | |
5774 | } | |
5775 | ||
5776 | /* Unset route-map from the peer. */ | |
94f2b392 | 5777 | static int |
fd79ac91 | 5778 | peer_unsuppress_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
718e3744 | 5779 | safi_t safi) |
5780 | { | |
5781 | int ret; | |
5782 | struct peer *peer; | |
5783 | ||
5784 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5785 | if (! peer) | |
5786 | return CMD_WARNING; | |
5787 | ||
5788 | ret = peer_unsuppress_map_unset (peer, afi, safi); | |
5789 | ||
5790 | return bgp_vty_return (vty, ret); | |
5791 | } | |
5792 | ||
5793 | DEFUN (neighbor_unsuppress_map, | |
5794 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5795 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5796 | NEIGHBOR_STR |
5797 | NEIGHBOR_ADDR_STR2 | |
5798 | "Route-map to selectively unsuppress suppressed routes\n" | |
5799 | "Name of route map\n") | |
5800 | { | |
c500ae40 DW |
5801 | int idx_peer = 1; |
5802 | int idx_word = 3; | |
5803 | return peer_unsuppress_map_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5804 | bgp_node_safi (vty), argv[idx_word]->arg); | |
718e3744 | 5805 | } |
5806 | ||
596c17ba DW |
5807 | ALIAS_HIDDEN (neighbor_unsuppress_map, |
5808 | neighbor_unsuppress_map_hidden_cmd, | |
5809 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5810 | NEIGHBOR_STR | |
5811 | NEIGHBOR_ADDR_STR2 | |
5812 | "Route-map to selectively unsuppress suppressed routes\n" | |
5813 | "Name of route map\n") | |
5814 | ||
718e3744 | 5815 | DEFUN (no_neighbor_unsuppress_map, |
5816 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5817 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5818 | NO_STR |
5819 | NEIGHBOR_STR | |
5820 | NEIGHBOR_ADDR_STR2 | |
5821 | "Route-map to selectively unsuppress suppressed routes\n" | |
5822 | "Name of route map\n") | |
5823 | { | |
c500ae40 DW |
5824 | int idx_peer = 2; |
5825 | return peer_unsuppress_map_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 5826 | bgp_node_safi (vty)); |
5827 | } | |
6b0655a2 | 5828 | |
596c17ba DW |
5829 | ALIAS_HIDDEN (no_neighbor_unsuppress_map, |
5830 | no_neighbor_unsuppress_map_hidden_cmd, | |
5831 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5832 | NO_STR | |
5833 | NEIGHBOR_STR | |
5834 | NEIGHBOR_ADDR_STR2 | |
5835 | "Route-map to selectively unsuppress suppressed routes\n" | |
5836 | "Name of route map\n") | |
5837 | ||
94f2b392 | 5838 | static int |
fd79ac91 | 5839 | peer_maximum_prefix_set_vty (struct vty *vty, const char *ip_str, afi_t afi, |
e52702f2 | 5840 | safi_t safi, const char *num_str, |
0a486e5f | 5841 | const char *threshold_str, int warning, |
5842 | const char *restart_str) | |
718e3744 | 5843 | { |
5844 | int ret; | |
5845 | struct peer *peer; | |
5846 | u_int32_t max; | |
e0701b79 | 5847 | u_char threshold; |
0a486e5f | 5848 | u_int16_t restart; |
718e3744 | 5849 | |
5850 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5851 | if (! peer) | |
5852 | return CMD_WARNING; | |
5853 | ||
e6ec1c36 | 5854 | VTY_GET_INTEGER ("maximum number", max, num_str); |
e0701b79 | 5855 | if (threshold_str) |
5856 | threshold = atoi (threshold_str); | |
5857 | else | |
5858 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 5859 | |
0a486e5f | 5860 | if (restart_str) |
5861 | restart = atoi (restart_str); | |
5862 | else | |
5863 | restart = 0; | |
5864 | ||
5865 | ret = peer_maximum_prefix_set (peer, afi, safi, max, threshold, warning, restart); | |
718e3744 | 5866 | |
5867 | return bgp_vty_return (vty, ret); | |
5868 | } | |
5869 | ||
94f2b392 | 5870 | static int |
fd79ac91 | 5871 | peer_maximum_prefix_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
718e3744 | 5872 | safi_t safi) |
5873 | { | |
5874 | int ret; | |
5875 | struct peer *peer; | |
5876 | ||
5877 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5878 | if (! peer) | |
5879 | return CMD_WARNING; | |
5880 | ||
5881 | ret = peer_maximum_prefix_unset (peer, afi, safi); | |
5882 | ||
5883 | return bgp_vty_return (vty, ret); | |
5884 | } | |
5885 | ||
5886 | /* Maximum number of prefix configuration. prefix count is different | |
5887 | for each peer configuration. So this configuration can be set for | |
5888 | each peer configuration. */ | |
5889 | DEFUN (neighbor_maximum_prefix, | |
5890 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 5891 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 5892 | NEIGHBOR_STR |
5893 | NEIGHBOR_ADDR_STR2 | |
5894 | "Maximum number of prefix accept from this peer\n" | |
5895 | "maximum no. of prefix limit\n") | |
5896 | { | |
c500ae40 DW |
5897 | int idx_peer = 1; |
5898 | int idx_number = 3; | |
5899 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5900 | bgp_node_safi (vty), argv[idx_number]->arg, NULL, 0, | |
0a486e5f | 5901 | NULL); |
718e3744 | 5902 | } |
5903 | ||
596c17ba DW |
5904 | ALIAS_HIDDEN (neighbor_maximum_prefix, |
5905 | neighbor_maximum_prefix_hidden_cmd, | |
5906 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", | |
5907 | NEIGHBOR_STR | |
5908 | NEIGHBOR_ADDR_STR2 | |
5909 | "Maximum number of prefix accept from this peer\n" | |
5910 | "maximum no. of prefix limit\n") | |
5911 | ||
e0701b79 | 5912 | DEFUN (neighbor_maximum_prefix_threshold, |
5913 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 5914 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 5915 | NEIGHBOR_STR |
5916 | NEIGHBOR_ADDR_STR2 | |
5917 | "Maximum number of prefix accept from this peer\n" | |
5918 | "maximum no. of prefix limit\n" | |
5919 | "Threshold value (%) at which to generate a warning msg\n") | |
5920 | { | |
c500ae40 DW |
5921 | int idx_peer = 1; |
5922 | int idx_number = 3; | |
5923 | int idx_number_2 = 4; | |
5924 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5925 | bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
0a486e5f | 5926 | NULL); |
5927 | } | |
e0701b79 | 5928 | |
596c17ba DW |
5929 | ALIAS_HIDDEN (neighbor_maximum_prefix_threshold, |
5930 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
5931 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", | |
5932 | NEIGHBOR_STR | |
5933 | NEIGHBOR_ADDR_STR2 | |
5934 | "Maximum number of prefix accept from this peer\n" | |
5935 | "maximum no. of prefix limit\n" | |
5936 | "Threshold value (%) at which to generate a warning msg\n") | |
5937 | ||
718e3744 | 5938 | DEFUN (neighbor_maximum_prefix_warning, |
5939 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 5940 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 5941 | NEIGHBOR_STR |
5942 | NEIGHBOR_ADDR_STR2 | |
5943 | "Maximum number of prefix accept from this peer\n" | |
5944 | "maximum no. of prefix limit\n" | |
5945 | "Only give warning message when limit is exceeded\n") | |
5946 | { | |
c500ae40 DW |
5947 | int idx_peer = 1; |
5948 | int idx_number = 3; | |
5949 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5950 | bgp_node_safi (vty), argv[idx_number]->arg, NULL, 1, | |
0a486e5f | 5951 | NULL); |
718e3744 | 5952 | } |
5953 | ||
596c17ba DW |
5954 | ALIAS_HIDDEN (neighbor_maximum_prefix_warning, |
5955 | neighbor_maximum_prefix_warning_hidden_cmd, | |
5956 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", | |
5957 | NEIGHBOR_STR | |
5958 | NEIGHBOR_ADDR_STR2 | |
5959 | "Maximum number of prefix accept from this peer\n" | |
5960 | "maximum no. of prefix limit\n" | |
5961 | "Only give warning message when limit is exceeded\n") | |
5962 | ||
e0701b79 | 5963 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
5964 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 5965 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 5966 | NEIGHBOR_STR |
5967 | NEIGHBOR_ADDR_STR2 | |
5968 | "Maximum number of prefix accept from this peer\n" | |
5969 | "maximum no. of prefix limit\n" | |
5970 | "Threshold value (%) at which to generate a warning msg\n" | |
5971 | "Only give warning message when limit is exceeded\n") | |
5972 | { | |
c500ae40 DW |
5973 | int idx_peer = 1; |
5974 | int idx_number = 3; | |
5975 | int idx_number_2 = 4; | |
5976 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5977 | bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 5978 | } |
5979 | ||
596c17ba DW |
5980 | ALIAS_HIDDEN (neighbor_maximum_prefix_threshold_warning, |
5981 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
5982 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", | |
5983 | NEIGHBOR_STR | |
5984 | NEIGHBOR_ADDR_STR2 | |
5985 | "Maximum number of prefix accept from this peer\n" | |
5986 | "maximum no. of prefix limit\n" | |
5987 | "Threshold value (%) at which to generate a warning msg\n" | |
5988 | "Only give warning message when limit is exceeded\n") | |
5989 | ||
0a486e5f | 5990 | DEFUN (neighbor_maximum_prefix_restart, |
5991 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 5992 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 5993 | NEIGHBOR_STR |
5994 | NEIGHBOR_ADDR_STR2 | |
5995 | "Maximum number of prefix accept from this peer\n" | |
5996 | "maximum no. of prefix limit\n" | |
5997 | "Restart bgp connection after limit is exceeded\n" | |
5998 | "Restart interval in minutes") | |
5999 | { | |
c500ae40 DW |
6000 | int idx_peer = 1; |
6001 | int idx_number = 3; | |
6002 | int idx_number_2 = 5; | |
6003 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
6004 | bgp_node_safi (vty), argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 6005 | } |
6006 | ||
596c17ba DW |
6007 | ALIAS_HIDDEN (neighbor_maximum_prefix_restart, |
6008 | neighbor_maximum_prefix_restart_hidden_cmd, | |
6009 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", | |
6010 | NEIGHBOR_STR | |
6011 | NEIGHBOR_ADDR_STR2 | |
6012 | "Maximum number of prefix accept from this peer\n" | |
6013 | "maximum no. of prefix limit\n" | |
6014 | "Restart bgp connection after limit is exceeded\n" | |
6015 | "Restart interval in minutes") | |
6016 | ||
0a486e5f | 6017 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
6018 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 6019 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 6020 | NEIGHBOR_STR |
6021 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6022 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 6023 | "maximum no. of prefix limit\n" |
6024 | "Threshold value (%) at which to generate a warning msg\n" | |
6025 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6026 | "Restart interval in minutes\n") |
0a486e5f | 6027 | { |
c500ae40 DW |
6028 | int idx_peer = 1; |
6029 | int idx_number = 3; | |
6030 | int idx_number_2 = 4; | |
6031 | int idx_number_3 = 6; | |
6032 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
6033 | bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 0, argv[idx_number_3]->arg); | |
0a486e5f | 6034 | } |
e0701b79 | 6035 | |
596c17ba DW |
6036 | ALIAS_HIDDEN (neighbor_maximum_prefix_threshold_restart, |
6037 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
6038 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", | |
6039 | NEIGHBOR_STR | |
6040 | NEIGHBOR_ADDR_STR2 | |
6041 | "Maximum number of prefixes to accept from this peer\n" | |
6042 | "maximum no. of prefix limit\n" | |
6043 | "Threshold value (%) at which to generate a warning msg\n" | |
6044 | "Restart bgp connection after limit is exceeded\n" | |
6045 | "Restart interval in minutes\n") | |
6046 | ||
718e3744 | 6047 | DEFUN (no_neighbor_maximum_prefix, |
6048 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 6049 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 6050 | NO_STR |
6051 | NEIGHBOR_STR | |
6052 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6053 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
6054 | "maximum no. of prefix limit\n" |
6055 | "Threshold value (%) at which to generate a warning msg\n" | |
6056 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6057 | "Restart interval in minutes\n" |
31500417 | 6058 | "Only give warning message when limit is exceeded\n") |
718e3744 | 6059 | { |
c500ae40 DW |
6060 | int idx_peer = 2; |
6061 | return peer_maximum_prefix_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 6062 | bgp_node_safi (vty)); |
6063 | } | |
e52702f2 | 6064 | |
596c17ba DW |
6065 | ALIAS_HIDDEN (no_neighbor_maximum_prefix, |
6066 | no_neighbor_maximum_prefix_hidden_cmd, | |
6067 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", | |
6068 | NO_STR | |
6069 | NEIGHBOR_STR | |
6070 | NEIGHBOR_ADDR_STR2 | |
6071 | "Maximum number of prefixes to accept from this peer\n" | |
6072 | "maximum no. of prefix limit\n" | |
6073 | "Threshold value (%) at which to generate a warning msg\n" | |
6074 | "Restart bgp connection after limit is exceeded\n" | |
6075 | "Restart interval in minutes\n" | |
6076 | "Only give warning message when limit is exceeded\n") | |
6077 | ||
718e3744 | 6078 | |
718e3744 | 6079 | /* "neighbor allowas-in" */ |
6080 | DEFUN (neighbor_allowas_in, | |
6081 | neighbor_allowas_in_cmd, | |
fd8503f5 | 6082 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6083 | NEIGHBOR_STR |
6084 | NEIGHBOR_ADDR_STR2 | |
31500417 | 6085 | "Accept as-path with my AS present in it\n" |
fd8503f5 QY |
6086 | "Number of occurances of AS number\n" |
6087 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 6088 | { |
c500ae40 | 6089 | int idx_peer = 1; |
fd8503f5 | 6090 | int idx_number_origin = 3; |
718e3744 | 6091 | int ret; |
aac9ef6c | 6092 | int origin = 0; |
718e3744 | 6093 | struct peer *peer; |
aac9ef6c | 6094 | int allow_num = 0; |
718e3744 | 6095 | |
c500ae40 | 6096 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 6097 | if (! peer) |
6098 | return CMD_WARNING; | |
6099 | ||
fd8503f5 | 6100 | if (argc <= idx_number_origin) |
718e3744 | 6101 | allow_num = 3; |
6102 | else | |
aac9ef6c | 6103 | { |
fd8503f5 | 6104 | if (argv[idx_number_origin]->type == WORD_TKN) |
aac9ef6c DW |
6105 | origin = 1; |
6106 | else | |
fd8503f5 | 6107 | allow_num = atoi (argv[idx_number_origin]->arg); |
aac9ef6c | 6108 | } |
718e3744 | 6109 | |
6110 | ret = peer_allowas_in_set (peer, bgp_node_afi (vty), bgp_node_safi (vty), | |
aac9ef6c | 6111 | allow_num, origin); |
718e3744 | 6112 | |
6113 | return bgp_vty_return (vty, ret); | |
6114 | } | |
6115 | ||
596c17ba DW |
6116 | ALIAS_HIDDEN (neighbor_allowas_in, |
6117 | neighbor_allowas_in_hidden_cmd, | |
6118 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6119 | NEIGHBOR_STR | |
6120 | NEIGHBOR_ADDR_STR2 | |
6121 | "Accept as-path with my AS present in it\n" | |
6122 | "Number of occurances of AS number\n" | |
6123 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
6124 | ||
718e3744 | 6125 | DEFUN (no_neighbor_allowas_in, |
6126 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 6127 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6128 | NO_STR |
6129 | NEIGHBOR_STR | |
6130 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 6131 | "allow local ASN appears in aspath attribute\n" |
fd8503f5 QY |
6132 | "Number of occurances of AS number\n" |
6133 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 6134 | { |
c500ae40 | 6135 | int idx_peer = 2; |
718e3744 | 6136 | int ret; |
6137 | struct peer *peer; | |
6138 | ||
c500ae40 | 6139 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 6140 | if (! peer) |
6141 | return CMD_WARNING; | |
6142 | ||
6143 | ret = peer_allowas_in_unset (peer, bgp_node_afi (vty), bgp_node_safi (vty)); | |
6144 | ||
6145 | return bgp_vty_return (vty, ret); | |
6146 | } | |
6b0655a2 | 6147 | |
596c17ba DW |
6148 | ALIAS_HIDDEN (no_neighbor_allowas_in, |
6149 | no_neighbor_allowas_in_hidden_cmd, | |
6150 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6151 | NO_STR | |
6152 | NEIGHBOR_STR | |
6153 | NEIGHBOR_ADDR_STR2 | |
6154 | "allow local ASN appears in aspath attribute\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 | ||
fa411a21 NH |
6158 | DEFUN (neighbor_ttl_security, |
6159 | neighbor_ttl_security_cmd, | |
9ccf14f7 | 6160 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
6161 | NEIGHBOR_STR |
6162 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6163 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
6164 | "Specify the maximum number of hops to the BGP peer\n" |
6165 | "Number of hops to BGP peer\n") | |
fa411a21 | 6166 | { |
c500ae40 DW |
6167 | int idx_peer = 1; |
6168 | int idx_number = 4; | |
fa411a21 | 6169 | struct peer *peer; |
89b6d1f8 | 6170 | int gtsm_hops; |
fa411a21 | 6171 | |
c500ae40 | 6172 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
fa411a21 NH |
6173 | if (! peer) |
6174 | return CMD_WARNING; | |
e52702f2 | 6175 | |
c500ae40 | 6176 | VTY_GET_INTEGER_RANGE ("", gtsm_hops, argv[idx_number]->arg, 1, 254); |
fa411a21 | 6177 | |
8cdabf90 SK |
6178 | /* |
6179 | * If 'neighbor swpX', then this is for directly connected peers, | |
6180 | * we should not accept a ttl-security hops value greater than 1. | |
6181 | */ | |
6182 | if (peer->conf_if && (gtsm_hops > 1)) { | |
6183 | vty_out (vty, "%s is directly connected peer, hops cannot exceed 1%s", | |
c500ae40 | 6184 | argv[idx_peer]->arg, VTY_NEWLINE); |
8cdabf90 SK |
6185 | return CMD_WARNING; |
6186 | } | |
6187 | ||
89b6d1f8 | 6188 | return bgp_vty_return (vty, peer_ttl_security_hops_set (peer, gtsm_hops)); |
fa411a21 NH |
6189 | } |
6190 | ||
6191 | DEFUN (no_neighbor_ttl_security, | |
6192 | no_neighbor_ttl_security_cmd, | |
9ccf14f7 | 6193 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
6194 | NO_STR |
6195 | NEIGHBOR_STR | |
6196 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6197 | "BGP ttl-security parameters\n" |
3a2d747c QY |
6198 | "Specify the maximum number of hops to the BGP peer\n" |
6199 | "Number of hops to BGP peer\n") | |
fa411a21 | 6200 | { |
c500ae40 | 6201 | int idx_peer = 2; |
fa411a21 | 6202 | struct peer *peer; |
fa411a21 | 6203 | |
c500ae40 | 6204 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
fa411a21 NH |
6205 | if (! peer) |
6206 | return CMD_WARNING; | |
6207 | ||
89b6d1f8 | 6208 | return bgp_vty_return (vty, peer_ttl_security_hops_unset (peer)); |
fa411a21 | 6209 | } |
6b0655a2 | 6210 | |
adbac85e DW |
6211 | DEFUN (neighbor_addpath_tx_all_paths, |
6212 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6213 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6214 | NEIGHBOR_STR |
6215 | NEIGHBOR_ADDR_STR2 | |
6216 | "Use addpath to advertise all paths to a neighbor\n") | |
6217 | { | |
c500ae40 | 6218 | int idx_peer = 1; |
adbac85e DW |
6219 | struct peer *peer; |
6220 | ||
c500ae40 | 6221 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
adbac85e DW |
6222 | if (! peer) |
6223 | return CMD_WARNING; | |
6224 | ||
c500ae40 | 6225 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
adbac85e DW |
6226 | bgp_node_safi (vty), |
6227 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
6228 | } | |
6229 | ||
596c17ba DW |
6230 | ALIAS_HIDDEN (neighbor_addpath_tx_all_paths, |
6231 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
6232 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6233 | NEIGHBOR_STR | |
6234 | NEIGHBOR_ADDR_STR2 | |
6235 | "Use addpath to advertise all paths to a neighbor\n") | |
6236 | ||
adbac85e DW |
6237 | DEFUN (no_neighbor_addpath_tx_all_paths, |
6238 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6239 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6240 | NO_STR |
6241 | NEIGHBOR_STR | |
6242 | NEIGHBOR_ADDR_STR2 | |
6243 | "Use addpath to advertise all paths to a neighbor\n") | |
6244 | { | |
c500ae40 DW |
6245 | int idx_peer = 2; |
6246 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
adbac85e DW |
6247 | bgp_node_safi (vty), |
6248 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
6249 | } | |
6250 | ||
596c17ba DW |
6251 | ALIAS_HIDDEN (no_neighbor_addpath_tx_all_paths, |
6252 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
6253 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6254 | NO_STR | |
6255 | NEIGHBOR_STR | |
6256 | NEIGHBOR_ADDR_STR2 | |
6257 | "Use addpath to advertise all paths to a neighbor\n") | |
6258 | ||
06370dac DW |
6259 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
6260 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6261 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6262 | NEIGHBOR_STR |
6263 | NEIGHBOR_ADDR_STR2 | |
6264 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6265 | { | |
c500ae40 | 6266 | int idx_peer = 1; |
06370dac DW |
6267 | struct peer *peer; |
6268 | ||
c500ae40 | 6269 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
06370dac DW |
6270 | if (! peer) |
6271 | return CMD_WARNING; | |
6272 | ||
c500ae40 | 6273 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
06370dac DW |
6274 | bgp_node_safi (vty), |
6275 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
6276 | } | |
6277 | ||
596c17ba DW |
6278 | ALIAS_HIDDEN (neighbor_addpath_tx_bestpath_per_as, |
6279 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6280 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6281 | NEIGHBOR_STR | |
6282 | NEIGHBOR_ADDR_STR2 | |
6283 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6284 | ||
06370dac DW |
6285 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
6286 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6287 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6288 | NO_STR |
6289 | NEIGHBOR_STR | |
6290 | NEIGHBOR_ADDR_STR2 | |
6291 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6292 | { | |
c500ae40 DW |
6293 | int idx_peer = 2; |
6294 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
06370dac DW |
6295 | bgp_node_safi (vty), |
6296 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
6297 | } | |
6298 | ||
596c17ba DW |
6299 | ALIAS_HIDDEN (no_neighbor_addpath_tx_bestpath_per_as, |
6300 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6301 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6302 | NO_STR | |
6303 | NEIGHBOR_STR | |
6304 | NEIGHBOR_ADDR_STR2 | |
6305 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6306 | ||
505e5056 | 6307 | DEFUN_NOSH (address_family_ipv4_safi, |
718e3744 | 6308 | address_family_ipv4_safi_cmd, |
5b1f0f29 | 6309 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast>]", |
718e3744 | 6310 | "Enter Address Family command mode\n" |
8c3deaae | 6311 | "Address Family\n" |
46f296b4 | 6312 | BGP_SAFI_HELP_STR) |
718e3744 | 6313 | { |
f51bae9c DS |
6314 | |
6315 | if (argc == 3) | |
ccbb332a | 6316 | { |
f51bae9c DS |
6317 | safi_t safi = bgp_vty_safi_from_arg(argv[2]->arg); |
6318 | vty->node = bgp_node_type(AFI_IP, safi); | |
ccbb332a | 6319 | } |
c7f1274b DS |
6320 | else |
6321 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 6322 | |
6323 | return CMD_SUCCESS; | |
6324 | } | |
6325 | ||
505e5056 | 6326 | DEFUN_NOSH (address_family_ipv6_safi, |
25ffbdc1 | 6327 | address_family_ipv6_safi_cmd, |
5b1f0f29 | 6328 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast>]", |
718e3744 | 6329 | "Enter Address Family command mode\n" |
8c3deaae | 6330 | "Address Family\n" |
46f296b4 | 6331 | BGP_SAFI_HELP_STR) |
25ffbdc1 | 6332 | { |
f51bae9c | 6333 | if (argc == 3) |
46f296b4 | 6334 | { |
f51bae9c DS |
6335 | safi_t safi = bgp_vty_safi_from_arg(argv[2]->arg); |
6336 | vty->node = bgp_node_type(AFI_IP6, safi); | |
46f296b4 | 6337 | } |
c7f1274b DS |
6338 | else |
6339 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 6340 | |
6341 | return CMD_SUCCESS; | |
6342 | } | |
718e3744 | 6343 | |
d6902373 | 6344 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 6345 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 6346 | address_family_vpnv4_cmd, |
8334fd5a | 6347 | "address-family vpnv4 [unicast]", |
718e3744 | 6348 | "Enter Address Family command mode\n" |
8c3deaae | 6349 | "Address Family\n" |
3a2d747c | 6350 | "Address Family modifier\n") |
718e3744 | 6351 | { |
6352 | vty->node = BGP_VPNV4_NODE; | |
6353 | return CMD_SUCCESS; | |
6354 | } | |
6355 | ||
505e5056 | 6356 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 6357 | address_family_vpnv6_cmd, |
8334fd5a | 6358 | "address-family vpnv6 [unicast]", |
8ecd3266 | 6359 | "Enter Address Family command mode\n" |
8c3deaae | 6360 | "Address Family\n" |
3a2d747c | 6361 | "Address Family modifier\n") |
8ecd3266 | 6362 | { |
6363 | vty->node = BGP_VPNV6_NODE; | |
6364 | return CMD_SUCCESS; | |
6365 | } | |
c016b6c7 | 6366 | #endif |
d6902373 | 6367 | |
505e5056 | 6368 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 6369 | address_family_evpn_cmd, |
b194703e | 6370 | "address-family <l2vpn evpn>", |
4e0b7b6d | 6371 | "Enter Address Family command mode\n" |
61a51962 PG |
6372 | "EVPN Address family\n" |
6373 | "Layer2 VPN Address family\n" | |
6374 | "Ethernet Virtual Private Network Subsequent Address Family\n") | |
4e0b7b6d | 6375 | { |
4e0b7b6d | 6376 | vty->node = BGP_EVPN_NODE; |
4e0b7b6d PG |
6377 | return CMD_SUCCESS; |
6378 | } | |
6379 | ||
505e5056 | 6380 | DEFUN_NOSH (exit_address_family, |
718e3744 | 6381 | exit_address_family_cmd, |
6382 | "exit-address-family", | |
6383 | "Exit from Address Family configuration mode\n") | |
6384 | { | |
a8a80d53 | 6385 | if (vty->node == BGP_IPV4_NODE |
6386 | || vty->node == BGP_IPV4M_NODE | |
f51bae9c | 6387 | || vty->node == BGP_IPV4L_NODE |
718e3744 | 6388 | || vty->node == BGP_VPNV4_NODE |
25ffbdc1 | 6389 | || vty->node == BGP_IPV6_NODE |
8ecd3266 | 6390 | || vty->node == BGP_IPV6M_NODE |
f51bae9c | 6391 | || vty->node == BGP_IPV6L_NODE |
8b1fb8be | 6392 | || vty->node == BGP_VPNV6_NODE |
4e0b7b6d | 6393 | || vty->node == BGP_EVPN_NODE) |
718e3744 | 6394 | vty->node = BGP_NODE; |
6395 | return CMD_SUCCESS; | |
6396 | } | |
6b0655a2 | 6397 | |
8ad7271d DS |
6398 | /* Recalculate bestpath and re-advertise a prefix */ |
6399 | static int | |
01080f7c | 6400 | bgp_clear_prefix (struct vty *vty, const char *view_name, const char *ip_str, |
8ad7271d DS |
6401 | afi_t afi, safi_t safi, struct prefix_rd *prd) |
6402 | { | |
6403 | int ret; | |
6404 | struct prefix match; | |
6405 | struct bgp_node *rn; | |
6406 | struct bgp_node *rm; | |
8ad7271d DS |
6407 | struct bgp *bgp; |
6408 | struct bgp_table *table; | |
6409 | struct bgp_table *rib; | |
6410 | ||
6411 | /* BGP structure lookup. */ | |
6412 | if (view_name) | |
6413 | { | |
6414 | bgp = bgp_lookup_by_name (view_name); | |
6415 | if (bgp == NULL) | |
6416 | { | |
6aeb9e78 | 6417 | vty_out (vty, "%% Can't find BGP instance %s%s", view_name, VTY_NEWLINE); |
8ad7271d DS |
6418 | return CMD_WARNING; |
6419 | } | |
6420 | } | |
6421 | else | |
6422 | { | |
6423 | bgp = bgp_get_default (); | |
6424 | if (bgp == NULL) | |
6425 | { | |
6426 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
6427 | return CMD_WARNING; | |
6428 | } | |
6429 | } | |
6430 | ||
6431 | /* Check IP address argument. */ | |
6432 | ret = str2prefix (ip_str, &match); | |
6433 | if (! ret) | |
6434 | { | |
6435 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); | |
6436 | return CMD_WARNING; | |
6437 | } | |
6438 | ||
6439 | match.family = afi2family (afi); | |
6440 | rib = bgp->rib[afi][safi]; | |
6441 | ||
6442 | if (safi == SAFI_MPLS_VPN) | |
6443 | { | |
6444 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) | |
6445 | { | |
6446 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) | |
6447 | continue; | |
6448 | ||
6449 | if ((table = rn->info) != NULL) | |
6450 | { | |
6451 | if ((rm = bgp_node_match (table, &match)) != NULL) | |
6452 | { | |
6453 | if (rm->p.prefixlen == match.prefixlen) | |
6454 | { | |
6455 | SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR); | |
6456 | bgp_process (bgp, rm, afi, safi); | |
6457 | } | |
6458 | bgp_unlock_node (rm); | |
6459 | } | |
6460 | } | |
6461 | } | |
6462 | } | |
6463 | else | |
6464 | { | |
6465 | if ((rn = bgp_node_match (rib, &match)) != NULL) | |
6466 | { | |
6467 | if (rn->p.prefixlen == match.prefixlen) | |
6468 | { | |
6469 | SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR); | |
6470 | bgp_process (bgp, rn, afi, safi); | |
6471 | } | |
6472 | bgp_unlock_node (rn); | |
6473 | } | |
6474 | } | |
6475 | ||
6476 | return CMD_SUCCESS; | |
6477 | } | |
6478 | ||
b09b5ae0 | 6479 | /* one clear bgp command to rule them all */ |
718e3744 | 6480 | DEFUN (clear_ip_bgp_all, |
6481 | clear_ip_bgp_all_cmd, | |
18c57037 | 6482 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] ["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 | 6483 | CLEAR_STR |
6484 | IP_STR | |
6485 | BGP_STR | |
838758ac | 6486 | BGP_INSTANCE_HELP_STR |
b09b5ae0 DW |
6487 | "Clear all peers\n" |
6488 | "BGP neighbor address to clear\n" | |
a80beece | 6489 | "BGP IPv6 neighbor to clear\n" |
838758ac | 6490 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
6491 | "Clear peers with the AS number\n" |
6492 | "Clear all external peers\n" | |
718e3744 | 6493 | "Clear all members of peer-group\n" |
b09b5ae0 | 6494 | "BGP peer-group name\n" |
46f296b4 LB |
6495 | BGP_AFI_HELP_STR |
6496 | BGP_SAFI_HELP_STR | |
b09b5ae0 DW |
6497 | BGP_SOFT_STR |
6498 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
6499 | BGP_SOFT_OUT_STR |
6500 | BGP_SOFT_IN_STR | |
6501 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 6502 | BGP_SOFT_OUT_STR) |
718e3744 | 6503 | { |
8334fd5a | 6504 | char *vrf = NULL; |
630a298c | 6505 | |
ae19d7dd QY |
6506 | afi_t afi = AFI_IP6; |
6507 | safi_t safi = SAFI_UNICAST; | |
5bf15956 | 6508 | enum clear_sort clr_sort = clear_peer; |
b09b5ae0 DW |
6509 | enum bgp_clear_type clr_type; |
6510 | char *clr_arg = NULL; | |
718e3744 | 6511 | |
ae19d7dd | 6512 | int idx = 0; |
01080f7c | 6513 | |
ae19d7dd QY |
6514 | /* clear [ip] bgp */ |
6515 | if (argv_find (argv, argc, "ip", &idx)) | |
6516 | afi = AFI_IP; | |
18c57037 | 6517 | /* [<view|vrf> VIEWVRFNAME] */ |
ae19d7dd | 6518 | if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) |
838758ac | 6519 | { |
ae19d7dd QY |
6520 | vrf = argv[idx + 1]->arg; |
6521 | idx += 2; | |
838758ac | 6522 | } |
ae19d7dd QY |
6523 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */ |
6524 | if (argv_find (argv, argc, "*", &idx)) | |
b09b5ae0 | 6525 | { |
ae19d7dd | 6526 | clr_sort = clear_all; |
b09b5ae0 | 6527 | } |
ae19d7dd | 6528 | else if (argv_find (argv, argc, "A.B.C.D", &idx)) |
b09b5ae0 DW |
6529 | { |
6530 | clr_sort = clear_peer; | |
ae19d7dd | 6531 | clr_arg = argv[idx]->arg; |
b09b5ae0 | 6532 | } |
ae19d7dd | 6533 | else if (argv_find (argv, argc, "X:X::X:X", &idx)) |
b09b5ae0 | 6534 | { |
ae19d7dd QY |
6535 | clr_sort = clear_peer; |
6536 | clr_arg = argv[idx]->arg; | |
838758ac | 6537 | } |
ae19d7dd | 6538 | else if (argv_find (argv, argc, "peer-group", &idx)) |
b09b5ae0 DW |
6539 | { |
6540 | clr_sort = clear_group; | |
ae19d7dd QY |
6541 | idx++; |
6542 | clr_arg = argv[idx]->arg; | |
b09b5ae0 | 6543 | } |
ae19d7dd | 6544 | else if (argv_find (argv, argc, "WORD", &idx)) |
b09b5ae0 | 6545 | { |
f0dac89f RW |
6546 | clr_sort = clear_peer; |
6547 | clr_arg = argv[idx]->arg; | |
b09b5ae0 | 6548 | } |
ae19d7dd QY |
6549 | else if (argv_find (argv, argc, "(1-4294967295)", &idx)) |
6550 | { | |
6551 | clr_sort = clear_as; | |
6552 | clr_arg = argv[idx]->arg; | |
6553 | } | |
6554 | else if (argv_find (argv, argc, "external", &idx)) | |
6555 | { | |
6556 | clr_sort = clear_external; | |
6557 | } | |
46f296b4 LB |
6558 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
6559 | if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) | |
ae19d7dd | 6560 | { |
46f296b4 | 6561 | argv_find_and_parse_safi (argv, argc, &idx, &safi); |
ae19d7dd QY |
6562 | } |
6563 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
6564 | if (argv_find (argv, argc, "soft", &idx)) | |
6565 | { | |
6566 | if (argv_find (argv, argc, "in", &idx) || argv_find (argv, argc, "out", &idx)) | |
6567 | clr_type = strmatch (argv[idx]->text, "in") ? BGP_CLEAR_SOFT_IN : BGP_CLEAR_SOFT_OUT; | |
6568 | else | |
6569 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
6570 | } | |
6571 | else if (argv_find (argv, argc, "in", &idx)) | |
6572 | { | |
6573 | clr_type = argv_find (argv, argc, "prefix-filter", &idx) ? BGP_CLEAR_SOFT_IN_ORF_PREFIX : BGP_CLEAR_SOFT_IN; | |
6574 | } | |
6575 | else if (argv_find (argv, argc, "out", &idx)) | |
6576 | { | |
5daa3e5e | 6577 | clr_type = BGP_CLEAR_SOFT_OUT; |
ae19d7dd QY |
6578 | } |
6579 | else | |
6580 | clr_type = BGP_CLEAR_SOFT_NONE; | |
718e3744 | 6581 | |
b09b5ae0 | 6582 | return bgp_clear_vty (vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); |
838758ac | 6583 | } |
01080f7c | 6584 | |
8ad7271d DS |
6585 | DEFUN (clear_ip_bgp_prefix, |
6586 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 6587 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
6588 | CLEAR_STR |
6589 | IP_STR | |
6590 | BGP_STR | |
838758ac | 6591 | BGP_INSTANCE_HELP_STR |
8ad7271d | 6592 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 6593 | "IPv4 prefix\n") |
8ad7271d | 6594 | { |
8334fd5a | 6595 | char *vrf = NULL; |
630a298c | 6596 | char *prefix = NULL; |
8ad7271d | 6597 | |
630a298c | 6598 | int idx = 0; |
01080f7c | 6599 | |
18c57037 | 6600 | /* [<view|vrf> VIEWVRFNAME] */ |
630a298c QY |
6601 | if (argv_find (argv, argc, "WORD", &idx)) |
6602 | vrf = argv[idx]->arg; | |
0c7b1b01 | 6603 | |
630a298c | 6604 | prefix = argv[argc-1]->arg; |
8ad7271d | 6605 | |
630a298c | 6606 | return bgp_clear_prefix (vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 6607 | } |
8ad7271d | 6608 | |
b09b5ae0 DW |
6609 | DEFUN (clear_bgp_ipv6_safi_prefix, |
6610 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 6611 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 6612 | CLEAR_STR |
3a2d747c | 6613 | IP_STR |
718e3744 | 6614 | BGP_STR |
8c3deaae | 6615 | "Address Family\n" |
46f296b4 | 6616 | BGP_SAFI_HELP_STR |
b09b5ae0 | 6617 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 6618 | "IPv6 prefix\n") |
718e3744 | 6619 | { |
b09b5ae0 DW |
6620 | int idx_safi = 3; |
6621 | int idx_ipv6_prefixlen = 5; | |
46f296b4 LB |
6622 | return bgp_clear_prefix (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, |
6623 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), NULL); | |
838758ac | 6624 | } |
01080f7c | 6625 | |
b09b5ae0 DW |
6626 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
6627 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 6628 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 6629 | CLEAR_STR |
3a2d747c | 6630 | IP_STR |
718e3744 | 6631 | BGP_STR |
838758ac | 6632 | BGP_INSTANCE_HELP_STR |
8c3deaae | 6633 | "Address Family\n" |
46f296b4 | 6634 | BGP_SAFI_HELP_STR |
b09b5ae0 | 6635 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 6636 | "IPv6 prefix\n") |
718e3744 | 6637 | { |
b09b5ae0 | 6638 | int idx_word = 3; |
c500ae40 | 6639 | int idx_safi = 5; |
b09b5ae0 | 6640 | int idx_ipv6_prefixlen = 7; |
46f296b4 LB |
6641 | return bgp_clear_prefix (vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, |
6642 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), NULL); | |
718e3744 | 6643 | } |
6644 | ||
b09b5ae0 DW |
6645 | DEFUN (show_bgp_views, |
6646 | show_bgp_views_cmd, | |
d6e3c605 | 6647 | "show [ip] bgp views", |
b09b5ae0 | 6648 | SHOW_STR |
d6e3c605 | 6649 | IP_STR |
01080f7c | 6650 | BGP_STR |
b09b5ae0 | 6651 | "Show the defined BGP views\n") |
01080f7c | 6652 | { |
b09b5ae0 DW |
6653 | struct list *inst = bm->bgp; |
6654 | struct listnode *node; | |
6655 | struct bgp *bgp; | |
01080f7c | 6656 | |
b09b5ae0 DW |
6657 | if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE)) |
6658 | { | |
6659 | vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE); | |
6660 | return CMD_WARNING; | |
6661 | } | |
e52702f2 | 6662 | |
b09b5ae0 DW |
6663 | vty_out (vty, "Defined BGP views:%s", VTY_NEWLINE); |
6664 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) | |
6665 | { | |
6666 | /* Skip VRFs. */ | |
6667 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
6668 | continue; | |
6669 | vty_out (vty, "\t%s (AS%u)%s", | |
6670 | bgp->name ? bgp->name : "(null)", | |
6671 | bgp->as, VTY_NEWLINE); | |
6672 | } | |
e52702f2 | 6673 | |
b09b5ae0 | 6674 | return CMD_SUCCESS; |
e0081f70 ML |
6675 | } |
6676 | ||
8386ac43 | 6677 | DEFUN (show_bgp_vrfs, |
6678 | show_bgp_vrfs_cmd, | |
d6e3c605 | 6679 | "show [ip] bgp vrfs [json]", |
8386ac43 | 6680 | SHOW_STR |
d6e3c605 | 6681 | IP_STR |
8386ac43 | 6682 | BGP_STR |
6683 | "Show BGP VRFs\n" | |
9973d184 | 6684 | JSON_STR) |
8386ac43 | 6685 | { |
6686 | struct list *inst = bm->bgp; | |
6687 | struct listnode *node; | |
6688 | struct bgp *bgp; | |
6689 | u_char uj = use_json(argc, argv); | |
6690 | json_object *json = NULL; | |
6691 | json_object *json_vrfs = NULL; | |
6692 | int count = 0; | |
6693 | static char header[] = "Type Id RouterId #PeersCfg #PeersEstb Name"; | |
6694 | ||
6695 | if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE)) | |
6696 | { | |
6697 | vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE); | |
6698 | return CMD_WARNING; | |
6699 | } | |
6700 | ||
6701 | if (uj) | |
6702 | { | |
6703 | json = json_object_new_object(); | |
6704 | json_vrfs = json_object_new_object(); | |
6705 | } | |
6706 | ||
6707 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) | |
6708 | { | |
6709 | const char *name, *type; | |
6710 | struct peer *peer; | |
6711 | struct listnode *node, *nnode; | |
6712 | int peers_cfg, peers_estb; | |
6713 | json_object *json_vrf = NULL; | |
5c81a5f3 | 6714 | int vrf_id_ui; |
8386ac43 | 6715 | |
6716 | /* Skip Views. */ | |
6717 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
6718 | continue; | |
6719 | ||
6720 | count++; | |
6721 | if (!uj && count == 1) | |
6722 | vty_out (vty, "%s%s", header, VTY_NEWLINE); | |
6723 | ||
6724 | peers_cfg = peers_estb = 0; | |
6725 | if (uj) | |
6726 | json_vrf = json_object_new_object(); | |
6727 | ||
6728 | ||
6729 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
6730 | { | |
6731 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6732 | continue; | |
6733 | peers_cfg++; | |
6734 | if (peer->status == Established) | |
6735 | peers_estb++; | |
6736 | } | |
6737 | ||
6738 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
6739 | { | |
6740 | name = "Default"; | |
6741 | type = "DFLT"; | |
6742 | } | |
6743 | else | |
6744 | { | |
6745 | name = bgp->name; | |
6746 | type = "VRF"; | |
6747 | } | |
6748 | ||
5c81a5f3 | 6749 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id; |
8386ac43 | 6750 | if (uj) |
6751 | { | |
6752 | json_object_string_add(json_vrf, "type", type); | |
5c81a5f3 | 6753 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); |
8386ac43 | 6754 | json_object_string_add(json_vrf, "routerId", inet_ntoa (bgp->router_id)); |
6755 | json_object_int_add(json_vrf, "numConfiguredPeers", peers_cfg); | |
6756 | json_object_int_add(json_vrf, "numEstablishedPeers", peers_estb); | |
6757 | ||
6758 | json_object_object_add(json_vrfs, name, json_vrf); | |
6759 | } | |
6760 | else | |
5c81a5f3 | 6761 | vty_out (vty, "%4s %-5d %-16s %9u %10u %s%s", |
6762 | type, vrf_id_ui, inet_ntoa (bgp->router_id), | |
8386ac43 | 6763 | peers_cfg, peers_estb, name, |
6764 | VTY_NEWLINE); | |
6765 | } | |
6766 | ||
6767 | if (uj) | |
6768 | { | |
6769 | json_object_object_add(json, "vrfs", json_vrfs); | |
6770 | ||
6771 | json_object_int_add(json, "totalVrfs", count); | |
6772 | ||
2aac5767 | 6773 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
8386ac43 | 6774 | json_object_free(json); |
6775 | } | |
6776 | else | |
6777 | { | |
6778 | if (count) | |
6779 | vty_out (vty, "%sTotal number of VRFs (including default): %d%s", | |
6780 | VTY_NEWLINE, count, VTY_NEWLINE); | |
6781 | } | |
6782 | ||
6783 | return CMD_SUCCESS; | |
6784 | } | |
6785 | ||
f412b39a | 6786 | DEFUN (show_bgp_memory, |
4bf6a362 | 6787 | show_bgp_memory_cmd, |
7fa12b13 | 6788 | "show [ip] bgp memory", |
4bf6a362 | 6789 | SHOW_STR |
3a2d747c | 6790 | IP_STR |
4bf6a362 PJ |
6791 | BGP_STR |
6792 | "Global BGP memory statistics\n") | |
6793 | { | |
6794 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
6795 | unsigned long count; | |
e52702f2 | 6796 | |
4bf6a362 PJ |
6797 | /* RIB related usage stats */ |
6798 | count = mtype_stats_alloc (MTYPE_BGP_NODE); | |
6799 | vty_out (vty, "%ld RIB nodes, using %s of memory%s", count, | |
6800 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6801 | count * sizeof (struct bgp_node)), | |
6802 | VTY_NEWLINE); | |
e52702f2 | 6803 | |
4bf6a362 PJ |
6804 | count = mtype_stats_alloc (MTYPE_BGP_ROUTE); |
6805 | vty_out (vty, "%ld BGP routes, using %s of memory%s", count, | |
6806 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6807 | count * sizeof (struct bgp_info)), | |
6808 | VTY_NEWLINE); | |
fb982c25 PJ |
6809 | if ((count = mtype_stats_alloc (MTYPE_BGP_ROUTE_EXTRA))) |
6810 | vty_out (vty, "%ld BGP route ancillaries, using %s of memory%s", count, | |
6811 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6812 | count * sizeof (struct bgp_info_extra)), | |
6813 | VTY_NEWLINE); | |
e52702f2 | 6814 | |
4bf6a362 PJ |
6815 | if ((count = mtype_stats_alloc (MTYPE_BGP_STATIC))) |
6816 | vty_out (vty, "%ld Static routes, using %s of memory%s", count, | |
6817 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6818 | count * sizeof (struct bgp_static)), | |
6819 | VTY_NEWLINE); | |
3f9c7369 DS |
6820 | |
6821 | if ((count = mtype_stats_alloc (MTYPE_BGP_PACKET))) | |
6822 | vty_out (vty, "%ld Packets, using %s of memory%s", count, | |
6823 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6824 | count * sizeof (struct bpacket)), | |
6825 | VTY_NEWLINE); | |
e52702f2 | 6826 | |
4bf6a362 PJ |
6827 | /* Adj-In/Out */ |
6828 | if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_IN))) | |
6829 | vty_out (vty, "%ld Adj-In entries, using %s of memory%s", count, | |
6830 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6831 | count * sizeof (struct bgp_adj_in)), | |
6832 | VTY_NEWLINE); | |
6833 | if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_OUT))) | |
6834 | vty_out (vty, "%ld Adj-Out entries, using %s of memory%s", count, | |
6835 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6836 | count * sizeof (struct bgp_adj_out)), | |
6837 | VTY_NEWLINE); | |
e52702f2 | 6838 | |
4bf6a362 PJ |
6839 | if ((count = mtype_stats_alloc (MTYPE_BGP_NEXTHOP_CACHE))) |
6840 | vty_out (vty, "%ld Nexthop cache entries, using %s of memory%s", count, | |
6841 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6842 | count * sizeof (struct bgp_nexthop_cache)), | |
6843 | VTY_NEWLINE); | |
6844 | ||
6845 | if ((count = mtype_stats_alloc (MTYPE_BGP_DAMP_INFO))) | |
6846 | vty_out (vty, "%ld Dampening entries, using %s of memory%s", count, | |
6847 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6848 | count * sizeof (struct bgp_damp_info)), | |
6849 | VTY_NEWLINE); | |
6850 | ||
6851 | /* Attributes */ | |
6852 | count = attr_count(); | |
e52702f2 QY |
6853 | vty_out (vty, "%ld BGP attributes, using %s of memory%s", count, |
6854 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6855 | count * sizeof(struct attr)), | |
4bf6a362 | 6856 | VTY_NEWLINE); |
fb982c25 | 6857 | if ((count = mtype_stats_alloc (MTYPE_ATTR_EXTRA))) |
e52702f2 QY |
6858 | vty_out (vty, "%ld BGP extra attributes, using %s of memory%s", count, |
6859 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6860 | count * sizeof(struct attr_extra)), | |
fb982c25 | 6861 | VTY_NEWLINE); |
e52702f2 | 6862 | |
4bf6a362 PJ |
6863 | if ((count = attr_unknown_count())) |
6864 | vty_out (vty, "%ld unknown attributes%s", count, VTY_NEWLINE); | |
e52702f2 | 6865 | |
4bf6a362 PJ |
6866 | /* AS_PATH attributes */ |
6867 | count = aspath_count (); | |
6868 | vty_out (vty, "%ld BGP AS-PATH entries, using %s of memory%s", count, | |
6869 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6870 | count * sizeof (struct aspath)), | |
6871 | VTY_NEWLINE); | |
e52702f2 | 6872 | |
4bf6a362 PJ |
6873 | count = mtype_stats_alloc (MTYPE_AS_SEG); |
6874 | vty_out (vty, "%ld BGP AS-PATH segments, using %s of memory%s", count, | |
6875 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6876 | count * sizeof (struct assegment)), | |
6877 | VTY_NEWLINE); | |
e52702f2 | 6878 | |
4bf6a362 PJ |
6879 | /* Other attributes */ |
6880 | if ((count = community_count ())) | |
6881 | vty_out (vty, "%ld BGP community entries, using %s of memory%s", count, | |
6882 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6883 | count * sizeof (struct community)), | |
6884 | VTY_NEWLINE); | |
6885 | if ((count = mtype_stats_alloc (MTYPE_ECOMMUNITY))) | |
6886 | vty_out (vty, "%ld BGP community entries, using %s of memory%s", count, | |
6887 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6888 | count * sizeof (struct ecommunity)), | |
6889 | VTY_NEWLINE); | |
57d187bc JS |
6890 | if ((count = mtype_stats_alloc (MTYPE_LCOMMUNITY))) |
6891 | vty_out (vty, "%ld BGP large-community entries, using %s of memory%s", | |
2acb4ac2 | 6892 | count, |
57d187bc JS |
6893 | mtype_memstr (memstrbuf, sizeof (memstrbuf), |
6894 | count * sizeof (struct lcommunity)), | |
6895 | VTY_NEWLINE); | |
e52702f2 | 6896 | |
4bf6a362 PJ |
6897 | if ((count = mtype_stats_alloc (MTYPE_CLUSTER))) |
6898 | vty_out (vty, "%ld Cluster lists, using %s of memory%s", count, | |
6899 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6900 | count * sizeof (struct cluster_list)), | |
6901 | VTY_NEWLINE); | |
e52702f2 | 6902 | |
4bf6a362 PJ |
6903 | /* Peer related usage */ |
6904 | count = mtype_stats_alloc (MTYPE_BGP_PEER); | |
6905 | vty_out (vty, "%ld peers, using %s of memory%s", count, | |
6906 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6907 | count * sizeof (struct peer)), | |
6908 | VTY_NEWLINE); | |
e52702f2 | 6909 | |
4a1ab8e4 | 6910 | if ((count = mtype_stats_alloc (MTYPE_PEER_GROUP))) |
4bf6a362 PJ |
6911 | vty_out (vty, "%ld peer groups, using %s of memory%s", count, |
6912 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6913 | count * sizeof (struct peer_group)), | |
6914 | VTY_NEWLINE); | |
e52702f2 | 6915 | |
4bf6a362 PJ |
6916 | /* Other */ |
6917 | if ((count = mtype_stats_alloc (MTYPE_HASH))) | |
6918 | vty_out (vty, "%ld hash tables, using %s of memory%s", count, | |
6919 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6920 | count * sizeof (struct hash)), | |
6921 | VTY_NEWLINE); | |
6922 | if ((count = mtype_stats_alloc (MTYPE_HASH_BACKET))) | |
6923 | vty_out (vty, "%ld hash buckets, using %s of memory%s", count, | |
6924 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6925 | count * sizeof (struct hash_backet)), | |
6926 | VTY_NEWLINE); | |
6927 | if ((count = mtype_stats_alloc (MTYPE_BGP_REGEXP))) | |
6928 | vty_out (vty, "%ld compiled regexes, using %s of memory%s", count, | |
6929 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6930 | count * sizeof (regex_t)), | |
6931 | VTY_NEWLINE); | |
6932 | return CMD_SUCCESS; | |
6933 | } | |
fee0f4c6 | 6934 | |
718e3744 | 6935 | /* Show BGP peer's summary information. */ |
94f2b392 | 6936 | static int |
b05a1c8b | 6937 | bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi, |
9f689658 | 6938 | u_char use_json, json_object *json) |
718e3744 | 6939 | { |
6940 | struct peer *peer; | |
1eb8ef25 | 6941 | struct listnode *node, *nnode; |
f14e6fdb DS |
6942 | unsigned int count = 0, dn_count = 0; |
6943 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
f933309e DW |
6944 | char neighbor_buf[VTY_BUFSIZ]; |
6945 | int neighbor_col_default_width = 16; | |
718e3744 | 6946 | int len; |
f933309e | 6947 | int max_neighbor_width = 0; |
ffd0c037 DS |
6948 | json_object *json_peer = NULL; |
6949 | json_object *json_peers = NULL; | |
718e3744 | 6950 | |
b05a1c8b DS |
6951 | if (use_json) |
6952 | { | |
9f689658 DD |
6953 | if (json == NULL) |
6954 | json = json_object_new_object(); | |
6955 | ||
f1aa5d8a | 6956 | json_peers = json_object_new_object(); |
b05a1c8b | 6957 | } |
f933309e DW |
6958 | else |
6959 | { | |
6960 | /* Loop over all neighbors that will be displayed to determine how many | |
6961 | * characters are needed for the Neighbor column | |
6962 | */ | |
6963 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
6964 | { | |
6965 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6966 | continue; | |
6967 | ||
6968 | if (peer->afc[afi][safi]) | |
6969 | { | |
c9d5bd27 DS |
6970 | memset(dn_flag, '\0', sizeof(dn_flag)); |
6971 | if (peer_dynamic_neighbor(peer)) | |
6972 | dn_flag[0] = '*'; | |
6973 | ||
f933309e DW |
6974 | if (peer->hostname && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) |
6975 | sprintf(neighbor_buf, "%s%s(%s) ", dn_flag, peer->hostname, peer->host); | |
6976 | else | |
6977 | sprintf(neighbor_buf, "%s%s ", dn_flag, peer->host); | |
6978 | ||
6979 | len = strlen(neighbor_buf); | |
6980 | ||
6981 | if (len > max_neighbor_width) | |
6982 | max_neighbor_width = len; | |
6983 | } | |
6984 | } | |
6985 | ||
6986 | /* Originally we displayed the Neighbor column as 16 | |
6987 | * characters wide so make that the default | |
6988 | */ | |
6989 | if (max_neighbor_width < neighbor_col_default_width) | |
6990 | max_neighbor_width = neighbor_col_default_width; | |
6991 | } | |
b05a1c8b | 6992 | |
1eb8ef25 | 6993 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
718e3744 | 6994 | { |
1ff9a340 DS |
6995 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
6996 | continue; | |
6997 | ||
718e3744 | 6998 | if (peer->afc[afi][safi]) |
6999 | { | |
b05a1c8b | 7000 | if (!count) |
4bf6a362 PJ |
7001 | { |
7002 | unsigned long ents; | |
7003 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
5c81a5f3 | 7004 | int vrf_id_ui; |
7005 | ||
7006 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id; | |
b05a1c8b | 7007 | |
4bf6a362 | 7008 | /* Usage summary and header */ |
b05a1c8b DS |
7009 | if (use_json) |
7010 | { | |
62d6dca0 | 7011 | json_object_string_add(json, "routerId", inet_ntoa (bgp->router_id)); |
f1aa5d8a | 7012 | json_object_int_add(json, "as", bgp->as); |
9f689658 DD |
7013 | json_object_int_add(json, "vrfId", vrf_id_ui); |
7014 | json_object_string_add(json, "vrfName", | |
7015 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
7016 | ? "Default" : bgp->name); | |
b05a1c8b DS |
7017 | } |
7018 | else | |
7019 | { | |
7020 | vty_out (vty, | |
5c81a5f3 | 7021 | "BGP router identifier %s, local AS number %u vrf-id %d", |
7022 | inet_ntoa (bgp->router_id), bgp->as, vrf_id_ui); | |
6aeb9e78 | 7023 | vty_out (vty, "%s", VTY_NEWLINE); |
b05a1c8b DS |
7024 | } |
7025 | ||
f188f2c4 DS |
7026 | if (bgp_update_delay_configured(bgp)) |
7027 | { | |
b05a1c8b | 7028 | if (use_json) |
f188f2c4 | 7029 | { |
62d6dca0 | 7030 | json_object_int_add(json, "updateDelayLimit", bgp->v_update_delay); |
b05a1c8b DS |
7031 | |
7032 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
62d6dca0 | 7033 | json_object_int_add(json, "updateDelayEstablishWait", bgp->v_establish_wait); |
b05a1c8b DS |
7034 | |
7035 | if (bgp_update_delay_active(bgp)) | |
7036 | { | |
62d6dca0 DS |
7037 | json_object_string_add(json, "updateDelayFirstNeighbor", bgp->update_delay_begin_time); |
7038 | json_object_boolean_true_add(json, "updateDelayInProgress"); | |
b05a1c8b DS |
7039 | } |
7040 | else | |
7041 | { | |
7042 | if (bgp->update_delay_over) | |
7043 | { | |
62d6dca0 | 7044 | json_object_string_add(json, "updateDelayFirstNeighbor", |
f1aa5d8a | 7045 | bgp->update_delay_begin_time); |
62d6dca0 | 7046 | json_object_string_add(json, "updateDelayBestpathResumed", |
f1aa5d8a | 7047 | bgp->update_delay_end_time); |
62d6dca0 | 7048 | json_object_string_add(json, "updateDelayZebraUpdateResume", |
f1aa5d8a | 7049 | bgp->update_delay_zebra_resume_time); |
62d6dca0 | 7050 | json_object_string_add(json, "updateDelayPeerUpdateResume", |
f1aa5d8a | 7051 | bgp->update_delay_peers_resume_time); |
b05a1c8b DS |
7052 | } |
7053 | } | |
f188f2c4 DS |
7054 | } |
7055 | else | |
7056 | { | |
b05a1c8b DS |
7057 | vty_out (vty, "Read-only mode update-delay limit: %d seconds%s", |
7058 | bgp->v_update_delay, VTY_NEWLINE); | |
7059 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
7060 | vty_out (vty, " Establish wait: %d seconds%s", | |
7061 | bgp->v_establish_wait, VTY_NEWLINE); | |
7062 | ||
7063 | if (bgp_update_delay_active(bgp)) | |
f188f2c4 DS |
7064 | { |
7065 | vty_out (vty, " First neighbor established: %s%s", | |
7066 | bgp->update_delay_begin_time, VTY_NEWLINE); | |
b05a1c8b DS |
7067 | vty_out (vty, " Delay in progress%s", VTY_NEWLINE); |
7068 | } | |
7069 | else | |
7070 | { | |
7071 | if (bgp->update_delay_over) | |
7072 | { | |
7073 | vty_out (vty, " First neighbor established: %s%s", | |
7074 | bgp->update_delay_begin_time, VTY_NEWLINE); | |
7075 | vty_out (vty, " Best-paths resumed: %s%s", | |
7076 | bgp->update_delay_end_time, VTY_NEWLINE); | |
7077 | vty_out (vty, " zebra update resumed: %s%s", | |
7078 | bgp->update_delay_zebra_resume_time, VTY_NEWLINE); | |
7079 | vty_out (vty, " peers update resumed: %s%s", | |
7080 | bgp->update_delay_peers_resume_time, VTY_NEWLINE); | |
7081 | } | |
f188f2c4 DS |
7082 | } |
7083 | } | |
7084 | } | |
4bf6a362 | 7085 | |
b05a1c8b DS |
7086 | if (use_json) |
7087 | { | |
7088 | if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active) | |
62d6dca0 | 7089 | json_object_boolean_true_add(json, "maxMedOnStartup"); |
b05a1c8b | 7090 | if (bgp->v_maxmed_admin) |
62d6dca0 | 7091 | json_object_boolean_true_add(json, "maxMedAdministrative"); |
b05a1c8b | 7092 | |
62d6dca0 | 7093 | json_object_int_add(json, "tableVersion", bgp_table_version(bgp->rib[afi][safi])); |
b05a1c8b DS |
7094 | |
7095 | ents = bgp_table_count (bgp->rib[afi][safi]); | |
62d6dca0 DS |
7096 | json_object_int_add(json, "ribCount", ents); |
7097 | json_object_int_add(json, "ribMemory", ents * sizeof (struct bgp_node)); | |
b05a1c8b DS |
7098 | |
7099 | ents = listcount (bgp->peer); | |
62d6dca0 DS |
7100 | json_object_int_add(json, "peerCount", ents); |
7101 | json_object_int_add(json, "peerMemory", ents * sizeof (struct peer)); | |
b05a1c8b | 7102 | |
b05a1c8b DS |
7103 | if ((ents = listcount (bgp->group))) |
7104 | { | |
62d6dca0 DS |
7105 | json_object_int_add(json, "peerGroupCount", ents); |
7106 | json_object_int_add(json, "peerGroupMemory", ents * sizeof (struct peer_group)); | |
b05a1c8b | 7107 | } |
3f9c7369 | 7108 | |
b05a1c8b | 7109 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) |
62d6dca0 | 7110 | json_object_boolean_true_add(json, "dampeningEnabled"); |
b05a1c8b DS |
7111 | } |
7112 | else | |
7113 | { | |
7114 | if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active) | |
7115 | vty_out (vty, "Max-med on-startup active%s", VTY_NEWLINE); | |
7116 | if (bgp->v_maxmed_admin) | |
7117 | vty_out (vty, "Max-med administrative active%s", VTY_NEWLINE); | |
7118 | ||
ffd0c037 | 7119 | vty_out(vty, "BGP table version %" PRIu64 "%s", |
b05a1c8b DS |
7120 | bgp_table_version(bgp->rib[afi][safi]), VTY_NEWLINE); |
7121 | ||
7122 | ents = bgp_table_count (bgp->rib[afi][safi]); | |
7123 | vty_out (vty, "RIB entries %ld, using %s of memory%s", ents, | |
7124 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
7125 | ents * sizeof (struct bgp_node)), | |
7126 | VTY_NEWLINE); | |
7127 | ||
7128 | /* Peer related usage */ | |
7129 | ents = listcount (bgp->peer); | |
7130 | vty_out (vty, "Peers %ld, using %s of memory%s", | |
7131 | ents, | |
7132 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
7133 | ents * sizeof (struct peer)), | |
7134 | VTY_NEWLINE); | |
7135 | ||
b05a1c8b DS |
7136 | if ((ents = listcount (bgp->group))) |
7137 | vty_out (vty, "Peer groups %ld, using %s of memory%s", ents, | |
7138 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
7139 | ents * sizeof (struct peer_group)), | |
7140 | VTY_NEWLINE); | |
7141 | ||
7142 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) | |
7143 | vty_out (vty, "Dampening enabled.%s", VTY_NEWLINE); | |
7144 | vty_out (vty, "%s", VTY_NEWLINE); | |
f933309e DW |
7145 | |
7146 | /* Subtract 8 here because 'Neighbor' is 8 characters */ | |
7147 | vty_out (vty, "Neighbor"); | |
7148 | vty_out (vty, "%*s", max_neighbor_width - 8, " "); | |
7149 | vty_out (vty, "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd%s", VTY_NEWLINE); | |
b05a1c8b | 7150 | } |
4bf6a362 | 7151 | } |
e52702f2 | 7152 | |
b05a1c8b | 7153 | count++; |
718e3744 | 7154 | |
b05a1c8b DS |
7155 | if (use_json) |
7156 | { | |
7157 | json_peer = json_object_new_object(); | |
f14e6fdb | 7158 | |
b05a1c8b | 7159 | if (peer_dynamic_neighbor(peer)) |
62d6dca0 | 7160 | json_object_boolean_true_add(json_peer, "dynamicPeer"); |
b05a1c8b | 7161 | |
04b6bdc0 DW |
7162 | if (peer->hostname) |
7163 | json_object_string_add(json_peer, "hostname", peer->hostname); | |
7164 | ||
7165 | if (peer->domainname) | |
7166 | json_object_string_add(json_peer, "domainname", peer->domainname); | |
7167 | ||
62d6dca0 | 7168 | json_object_int_add(json_peer, "remoteAs", peer->as); |
f1aa5d8a | 7169 | json_object_int_add(json_peer, "version", 4); |
62d6dca0 | 7170 | json_object_int_add(json_peer, "msgRcvd", |
f1aa5d8a DS |
7171 | peer->open_in + peer->update_in + peer->keepalive_in |
7172 | + peer->notify_in + peer->refresh_in | |
7173 | + peer->dynamic_cap_in); | |
62d6dca0 | 7174 | json_object_int_add(json_peer, "msgSent", |
f1aa5d8a DS |
7175 | peer->open_out + peer->update_out + peer->keepalive_out |
7176 | + peer->notify_out + peer->refresh_out | |
7177 | + peer->dynamic_cap_out); | |
7178 | ||
62d6dca0 | 7179 | json_object_int_add(json_peer, "tableVersion", peer->version[afi][safi]); |
f1aa5d8a DS |
7180 | json_object_int_add(json_peer, "outq", peer->obuf->count); |
7181 | json_object_int_add(json_peer, "inq", 0); | |
856ca177 | 7182 | peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, use_json, json_peer); |
62d6dca0 | 7183 | json_object_int_add(json_peer, "prefixReceivedCount", peer->pcount[afi][safi]); |
b05a1c8b DS |
7184 | |
7185 | if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) | |
f1aa5d8a | 7186 | json_object_string_add(json_peer, "state", "Idle (Admin)"); |
b05a1c8b | 7187 | else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) |
f1aa5d8a | 7188 | json_object_string_add(json_peer, "state", "Idle (PfxCt)"); |
b05a1c8b | 7189 | else |
56b40679 | 7190 | json_object_string_add(json_peer, "state", lookup_msg(bgp_status_msg, peer->status, NULL)); |
b05a1c8b | 7191 | |
f1aa5d8a | 7192 | if (peer->conf_if) |
62d6dca0 | 7193 | json_object_string_add(json_peer, "idType", "interface"); |
f1aa5d8a | 7194 | else if (peer->su.sa.sa_family == AF_INET) |
62d6dca0 | 7195 | json_object_string_add(json_peer, "idType", "ipv4"); |
f1aa5d8a | 7196 | else if (peer->su.sa.sa_family == AF_INET6) |
62d6dca0 | 7197 | json_object_string_add(json_peer, "idType", "ipv6"); |
b05a1c8b | 7198 | |
f1aa5d8a | 7199 | json_object_object_add(json_peers, peer->host, json_peer); |
b05a1c8b DS |
7200 | } |
7201 | else | |
7202 | { | |
7203 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
7204 | if (peer_dynamic_neighbor(peer)) | |
7205 | { | |
7206 | dn_count++; | |
7207 | dn_flag[0] = '*'; | |
7208 | } | |
7209 | ||
04b6bdc0 DW |
7210 | if (peer->hostname && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) |
7211 | len = vty_out (vty, "%s%s(%s)", dn_flag, peer->hostname, | |
7212 | peer->host); | |
7213 | else | |
7214 | len = vty_out (vty, "%s%s", dn_flag, peer->host); | |
b05a1c8b | 7215 | |
f933309e DW |
7216 | /* pad the neighbor column with spaces */ |
7217 | if (len < max_neighbor_width) | |
7218 | vty_out (vty, "%*s", max_neighbor_width - len, " "); | |
b05a1c8b | 7219 | |
f933309e | 7220 | vty_out (vty, "4 %10u %7d %7d %8" PRIu64 " %4d %4zd %8s", |
b05a1c8b DS |
7221 | peer->as, |
7222 | peer->open_in + peer->update_in + peer->keepalive_in | |
7223 | + peer->notify_in + peer->refresh_in | |
7224 | + peer->dynamic_cap_in, | |
7225 | peer->open_out + peer->update_out + peer->keepalive_out | |
7226 | + peer->notify_out + peer->refresh_out | |
7227 | + peer->dynamic_cap_out, | |
7228 | peer->version[afi][safi], | |
7229 | 0, | |
f933309e | 7230 | peer->obuf->count, |
856ca177 | 7231 | peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL)); |
b05a1c8b DS |
7232 | |
7233 | if (peer->status == Established) | |
46f8c104 | 7234 | vty_out (vty, " %12ld", peer->pcount[afi][safi]); |
b05a1c8b DS |
7235 | else |
7236 | { | |
7237 | if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) | |
7238 | vty_out (vty, " Idle (Admin)"); | |
7239 | else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) | |
7240 | vty_out (vty, " Idle (PfxCt)"); | |
7241 | else | |
56b40679 | 7242 | vty_out (vty, " %12s", lookup_msg(bgp_status_msg, peer->status, NULL)); |
b05a1c8b DS |
7243 | } |
7244 | vty_out (vty, "%s", VTY_NEWLINE); | |
7245 | } | |
718e3744 | 7246 | } |
7247 | } | |
7248 | ||
b05a1c8b DS |
7249 | if (use_json) |
7250 | { | |
7251 | json_object_object_add(json, "peers", json_peers); | |
14151a32 | 7252 | |
62d6dca0 DS |
7253 | json_object_int_add(json, "totalPeers", count); |
7254 | json_object_int_add(json, "dynamicPeers", dn_count); | |
14151a32 | 7255 | |
2aac5767 | 7256 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
f1aa5d8a | 7257 | json_object_free(json); |
b05a1c8b DS |
7258 | } |
7259 | else | |
f14e6fdb | 7260 | { |
b05a1c8b DS |
7261 | if (count) |
7262 | vty_out (vty, "%sTotal number of neighbors %d%s", VTY_NEWLINE, | |
7263 | count, VTY_NEWLINE); | |
7264 | else | |
9f689658 DD |
7265 | { |
7266 | if (use_json) | |
7267 | vty_out(vty, "{\"error\": {\"message\": \"No %s neighbor configured\"}}%s", | |
46f296b4 | 7268 | afi_safi_print(afi, safi), VTY_NEWLINE); |
9f689658 DD |
7269 | else |
7270 | vty_out (vty, "No %s neighbor is configured%s", | |
46f296b4 | 7271 | afi_safi_print(afi, safi), VTY_NEWLINE); |
9f689658 | 7272 | } |
b05a1c8b | 7273 | |
9f689658 | 7274 | if (dn_count && ! use_json) |
b05a1c8b DS |
7275 | { |
7276 | vty_out(vty, "* - dynamic neighbor%s", VTY_NEWLINE); | |
7277 | vty_out(vty, | |
7278 | "%d dynamic neighbor(s), limit %d%s", | |
7279 | dn_count, bgp->dynamic_neighbors_limit, VTY_NEWLINE); | |
7280 | } | |
f14e6fdb DS |
7281 | } |
7282 | ||
718e3744 | 7283 | return CMD_SUCCESS; |
7284 | } | |
7285 | ||
798c3572 DS |
7286 | /* |
7287 | * Return if we have a peer configured to use this afi/safi | |
7288 | */ | |
7289 | static int | |
7290 | bgp_show_summary_afi_safi_peer_exists (struct bgp *bgp, int afi, int safi) | |
7291 | { | |
7292 | struct listnode *node; | |
7293 | struct peer *peer; | |
7294 | ||
7295 | for (ALL_LIST_ELEMENTS_RO (bgp->peer, node, peer)) | |
7296 | { | |
7297 | if (!CHECK_FLAG (peer->flags, PEER_FLAG_CONFIG_NODE)) | |
7298 | continue; | |
7299 | ||
7300 | if (peer->afc[afi][safi]) | |
7301 | return 1; | |
7302 | } | |
7303 | ||
7304 | return 0; | |
7305 | } | |
7306 | ||
27162734 LB |
7307 | static void |
7308 | bgp_show_summary_afi_safi (struct vty *vty, struct bgp *bgp, int afi, int safi, | |
7309 | u_char use_json, json_object *json) | |
7310 | { | |
7311 | int is_first = 1; | |
7312 | int afi_wildcard = (afi == AFI_MAX); | |
7313 | int safi_wildcard = (safi == SAFI_MAX); | |
7314 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
5ce77b2b | 7315 | bool json_output = false; |
798c3572 | 7316 | |
27162734 LB |
7317 | if (use_json && is_wildcard) |
7318 | vty_out (vty, "{%s", VTY_NEWLINE); | |
7319 | if (afi_wildcard) | |
7320 | afi = 1; /* AFI_IP */ | |
7321 | while (afi < AFI_MAX) | |
7322 | { | |
7323 | if (safi_wildcard) | |
7324 | safi = 1; /* SAFI_UNICAST */ | |
7325 | while (safi < SAFI_MAX) | |
7326 | { | |
798c3572 | 7327 | if (bgp_show_summary_afi_safi_peer_exists (bgp, afi, safi)) |
27162734 | 7328 | { |
5ce77b2b | 7329 | json_output = true; |
798c3572 | 7330 | if (is_wildcard) |
27162734 | 7331 | { |
798c3572 DS |
7332 | /* |
7333 | * So limit output to those afi/safi pairs that | |
7334 | * actualy have something interesting in them | |
7335 | */ | |
7336 | if (use_json) | |
7337 | { | |
7338 | json = json_object_new_object(); | |
27162734 | 7339 | |
798c3572 DS |
7340 | if (! is_first) |
7341 | vty_out (vty, ",%s", VTY_NEWLINE); | |
7342 | else | |
7343 | is_first = 0; | |
27162734 | 7344 | |
798c3572 DS |
7345 | vty_out(vty, "\"%s\":", afi_safi_json(afi, safi)); |
7346 | } | |
7347 | else | |
7348 | { | |
7349 | vty_out (vty, "%s%s Summary:%s", | |
7350 | VTY_NEWLINE, afi_safi_print(afi, safi), VTY_NEWLINE); | |
7351 | } | |
27162734 | 7352 | } |
798c3572 | 7353 | bgp_show_summary (vty, bgp, afi, safi, use_json, json); |
27162734 | 7354 | } |
f62a5c33 LB |
7355 | safi++; |
7356 | if (safi == SAFI_RESERVED_4 || | |
7357 | safi == SAFI_RESERVED_5) /* handle special cases to match zebra.h */ | |
7358 | safi++; | |
27162734 LB |
7359 | if (! safi_wildcard) |
7360 | safi = SAFI_MAX; | |
7361 | } | |
7362 | afi++; | |
7363 | if (! afi_wildcard || | |
5ef6cd69 | 7364 | afi == AFI_L2VPN) /* special case, not handled yet */ |
27162734 LB |
7365 | afi = AFI_MAX; |
7366 | } | |
7367 | ||
7368 | if (use_json && is_wildcard) | |
7369 | vty_out (vty, "}%s", VTY_NEWLINE); | |
5ce77b2b DS |
7370 | else if (use_json && !json_output) |
7371 | vty_out (vty, "{}%s", VTY_NEWLINE); | |
27162734 LB |
7372 | } |
7373 | ||
f186de26 | 7374 | static void |
7375 | bgp_show_all_instances_summary_vty (struct vty *vty, afi_t afi, safi_t safi, | |
7376 | u_char use_json) | |
7377 | { | |
7378 | struct listnode *node, *nnode; | |
7379 | struct bgp *bgp; | |
9f689658 DD |
7380 | json_object *json = NULL; |
7381 | int is_first = 1; | |
7382 | ||
7383 | if (use_json) | |
7384 | vty_out (vty, "{%s", VTY_NEWLINE); | |
f186de26 | 7385 | |
7386 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) | |
7387 | { | |
9f689658 DD |
7388 | if (use_json) |
7389 | { | |
4fb25c53 | 7390 | json = json_object_new_object(); |
9f689658 DD |
7391 | |
7392 | if (! is_first) | |
7393 | vty_out (vty, ",%s", VTY_NEWLINE); | |
7394 | else | |
7395 | is_first = 0; | |
7396 | ||
7397 | vty_out(vty, "\"%s\":", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
7398 | ? "Default" : bgp->name); | |
7399 | } | |
7400 | else | |
7401 | { | |
7402 | vty_out (vty, "%sInstance %s:%s", | |
7403 | VTY_NEWLINE, | |
7404 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
7405 | ? "Default" : bgp->name, VTY_NEWLINE); | |
7406 | } | |
27162734 | 7407 | bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, json); |
f186de26 | 7408 | } |
9f689658 DD |
7409 | |
7410 | if (use_json) | |
7411 | vty_out (vty, "}%s", VTY_NEWLINE); | |
7412 | ||
f186de26 | 7413 | } |
7414 | ||
4fb25c53 DW |
7415 | static int |
7416 | bgp_show_summary_vty (struct vty *vty, const char *name, | |
7417 | afi_t afi, safi_t safi, u_char use_json) | |
7418 | { | |
7419 | struct bgp *bgp; | |
7420 | ||
7421 | if (name) | |
7422 | { | |
7423 | if (strmatch(name, "all")) | |
7424 | { | |
7425 | bgp_show_all_instances_summary_vty (vty, afi, safi, use_json); | |
7426 | return CMD_SUCCESS; | |
7427 | } | |
7428 | else | |
7429 | { | |
7430 | bgp = bgp_lookup_by_name (name); | |
7431 | ||
7432 | if (! bgp) | |
7433 | { | |
7434 | if (use_json) | |
7435 | vty_out (vty, "{}%s", VTY_NEWLINE); | |
7436 | else | |
7437 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
7438 | return CMD_WARNING; | |
7439 | } | |
7440 | ||
27162734 | 7441 | bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, NULL); |
4fb25c53 DW |
7442 | return CMD_SUCCESS; |
7443 | } | |
7444 | } | |
7445 | ||
7446 | bgp = bgp_get_default (); | |
7447 | ||
7448 | if (bgp) | |
27162734 | 7449 | bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, NULL); |
4fb25c53 DW |
7450 | |
7451 | return CMD_SUCCESS; | |
7452 | } | |
7453 | ||
716b2d8a | 7454 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 7455 | DEFUN (show_ip_bgp_summary, |
718e3744 | 7456 | show_ip_bgp_summary_cmd, |
18c57037 | 7457 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] summary [json]", |
718e3744 | 7458 | SHOW_STR |
7459 | IP_STR | |
7460 | BGP_STR | |
8386ac43 | 7461 | BGP_INSTANCE_HELP_STR |
46f296b4 LB |
7462 | BGP_AFI_HELP_STR |
7463 | BGP_SAFI_HELP_STR | |
b05a1c8b | 7464 | "Summary of BGP neighbor status\n" |
9973d184 | 7465 | JSON_STR) |
718e3744 | 7466 | { |
74ca3d33 | 7467 | char *vrf = NULL; |
27162734 LB |
7468 | afi_t afi = AFI_MAX; |
7469 | safi_t safi = SAFI_MAX; | |
ae19d7dd QY |
7470 | |
7471 | int idx = 0; | |
7472 | ||
7473 | /* show [ip] bgp */ | |
7474 | if (argv_find (argv, argc, "ip", &idx)) | |
7475 | afi = AFI_IP; | |
18c57037 | 7476 | /* [<view|vrf> VIEWVRFNAME] */ |
ae19d7dd QY |
7477 | if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) |
7478 | vrf = argv[++idx]->arg; | |
46f296b4 LB |
7479 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
7480 | if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) | |
ae19d7dd | 7481 | { |
46f296b4 | 7482 | argv_find_and_parse_safi (argv, argc, &idx, &safi); |
91d37724 QY |
7483 | } |
7484 | ||
ae19d7dd | 7485 | int uj = use_json (argc, argv); |
74ca3d33 DW |
7486 | |
7487 | return bgp_show_summary_vty (vty, vrf, afi, safi, uj); | |
718e3744 | 7488 | } |
7489 | ||
fd79ac91 | 7490 | const char * |
538621f2 | 7491 | afi_safi_print (afi_t afi, safi_t safi) |
7492 | { | |
7493 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
7494 | return "IPv4 Unicast"; | |
7495 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
7496 | return "IPv4 Multicast"; | |
b60f5275 DS |
7497 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) |
7498 | return "IPv4 labeled-unicast"; | |
538621f2 | 7499 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) |
46f296b4 | 7500 | return "IPv4 VPN"; |
8b1fb8be | 7501 | else if (afi == AFI_IP && safi == SAFI_ENCAP) |
46f296b4 | 7502 | return "IPv4 Encap"; |
538621f2 | 7503 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
7504 | return "IPv6 Unicast"; | |
7505 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
7506 | return "IPv6 Multicast"; | |
b60f5275 DS |
7507 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) |
7508 | return "IPv6 labeled-unicast"; | |
945c8fe9 | 7509 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) |
46f296b4 | 7510 | return "IPv6 VPN"; |
8b1fb8be | 7511 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) |
46f296b4 | 7512 | return "IPv6 Encap"; |
3d6c0dfa PG |
7513 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) |
7514 | return "L2VPN EVPN"; | |
538621f2 | 7515 | else |
7516 | return "Unknown"; | |
7517 | } | |
7518 | ||
b9f77ec8 DS |
7519 | /* |
7520 | * Please note that we have intentionally camelCased | |
7521 | * the return strings here. So if you want | |
7522 | * to use this function, please ensure you | |
7523 | * are doing this within json output | |
7524 | */ | |
27162734 LB |
7525 | const char * |
7526 | afi_safi_json (afi_t afi, safi_t safi) | |
7527 | { | |
7528 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
b9f77ec8 | 7529 | return "ipv4Unicast"; |
27162734 | 7530 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) |
b9f77ec8 | 7531 | return "ipv4Multicast"; |
b60f5275 | 7532 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) |
05ba625a | 7533 | return "ipv4LabeledUnicast"; |
27162734 | 7534 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) |
b9f77ec8 | 7535 | return "ipv4Vpn"; |
27162734 | 7536 | else if (afi == AFI_IP && safi == SAFI_ENCAP) |
b9f77ec8 | 7537 | return "ipv4Encap"; |
27162734 | 7538 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
b9f77ec8 | 7539 | return "ipv6Unicast"; |
27162734 | 7540 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) |
b9f77ec8 | 7541 | return "ipv6Multicast"; |
b60f5275 | 7542 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) |
05ba625a | 7543 | return "ipv6LabeledUnicast"; |
27162734 | 7544 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) |
b9f77ec8 | 7545 | return "ipv6Vpn"; |
27162734 | 7546 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) |
b9f77ec8 | 7547 | return "ipv6Encap"; |
3d6c0dfa | 7548 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) |
b9f77ec8 | 7549 | return "l2VpnEvpn"; |
27162734 LB |
7550 | else |
7551 | return "Unknown"; | |
7552 | } | |
7553 | ||
718e3744 | 7554 | /* Show BGP peer's information. */ |
7555 | enum show_type | |
7556 | { | |
7557 | show_all, | |
7558 | show_peer | |
7559 | }; | |
7560 | ||
94f2b392 | 7561 | static void |
856ca177 MS |
7562 | bgp_show_peer_afi_orf_cap (struct vty *vty, struct peer *p, afi_t afi, safi_t safi, |
7563 | u_int16_t adv_smcap, u_int16_t adv_rmcap, u_int16_t rcv_smcap, | |
7564 | u_int16_t rcv_rmcap, u_char use_json, json_object *json_pref) | |
718e3744 | 7565 | { |
7566 | /* Send-Mode */ | |
7567 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) | |
7568 | || CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
7569 | { | |
856ca177 MS |
7570 | if (use_json) |
7571 | { | |
7572 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
7573 | json_object_string_add(json_pref, "sendMode", "advertisedAndReceived"); | |
7574 | else if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)) | |
7575 | json_object_string_add(json_pref, "sendMode", "advertised"); | |
7576 | else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
7577 | json_object_string_add(json_pref, "sendMode", "received"); | |
7578 | } | |
7579 | else | |
7580 | { | |
7581 | vty_out (vty, " Send-mode: "); | |
7582 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)) | |
7583 | vty_out (vty, "advertised"); | |
7584 | if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
7585 | vty_out (vty, "%sreceived", | |
7586 | CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) ? | |
7587 | ", " : ""); | |
7588 | vty_out (vty, "%s", VTY_NEWLINE); | |
7589 | } | |
718e3744 | 7590 | } |
7591 | ||
7592 | /* Receive-Mode */ | |
7593 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) | |
7594 | || CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
7595 | { | |
856ca177 MS |
7596 | if (use_json) |
7597 | { | |
7598 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
7599 | json_object_string_add(json_pref, "recvMode", "advertisedAndReceived"); | |
7600 | else if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)) | |
7601 | json_object_string_add(json_pref, "recvMode", "advertised"); | |
7602 | else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
7603 | json_object_string_add(json_pref, "recvMode", "received"); | |
7604 | } | |
7605 | else | |
7606 | { | |
7607 | vty_out (vty, " Receive-mode: "); | |
7608 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)) | |
7609 | vty_out (vty, "advertised"); | |
7610 | if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
7611 | vty_out (vty, "%sreceived", | |
7612 | CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) ? | |
7613 | ", " : ""); | |
7614 | vty_out (vty, "%s", VTY_NEWLINE); | |
7615 | } | |
718e3744 | 7616 | } |
7617 | } | |
7618 | ||
94f2b392 | 7619 | static void |
856ca177 MS |
7620 | bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi, |
7621 | u_char use_json, json_object *json_neigh) | |
718e3744 | 7622 | { |
7623 | struct bgp_filter *filter; | |
3f9c7369 | 7624 | struct peer_af *paf; |
718e3744 | 7625 | char orf_pfx_name[BUFSIZ]; |
7626 | int orf_pfx_count; | |
856ca177 MS |
7627 | json_object *json_af = NULL; |
7628 | json_object *json_prefA = NULL; | |
7629 | json_object *json_prefB = NULL; | |
7630 | json_object *json_addr = NULL; | |
718e3744 | 7631 | |
856ca177 MS |
7632 | if (use_json) |
7633 | { | |
7634 | json_addr = json_object_new_object(); | |
7635 | json_af = json_object_new_object(); | |
856ca177 | 7636 | filter = &p->filter[afi][safi]; |
718e3744 | 7637 | |
c8560b44 | 7638 | if (peer_group_active(p)) |
856ca177 | 7639 | json_object_string_add(json_addr, "peerGroupMember", p->group->name); |
538621f2 | 7640 | |
856ca177 MS |
7641 | paf = peer_af_find(p, afi, safi); |
7642 | if (paf && PAF_SUBGRP(paf)) | |
7643 | { | |
7644 | json_object_int_add(json_addr, "updateGroupId", PAF_UPDGRP(paf)->id); | |
7645 | json_object_int_add(json_addr, "subGroupId", PAF_SUBGRP(paf)->id); | |
7646 | json_object_int_add(json_addr, "packetQueueLength", bpacket_queue_virtual_length(paf)); | |
7647 | } | |
7648 | ||
7649 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7650 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
7651 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7652 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)) | |
7653 | { | |
7654 | json_object_int_add(json_af, "orfType", ORF_TYPE_PREFIX); | |
b6df4090 | 7655 | json_prefA = json_object_new_object(); |
856ca177 MS |
7656 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, |
7657 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
7658 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7659 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
7660 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, json_prefA); | |
7661 | json_object_object_add(json_af, "orfPrefixList", json_prefA); | |
7662 | } | |
7663 | ||
7664 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7665 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7666 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7667 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7668 | { | |
7669 | json_object_int_add(json_af, "orfOldType", ORF_TYPE_PREFIX_OLD); | |
b6df4090 | 7670 | json_prefB = json_object_new_object(); |
856ca177 MS |
7671 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, |
7672 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
7673 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7674 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
7675 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, json_prefB); | |
7676 | json_object_object_add(json_af, "orfOldPrefixList", json_prefB); | |
7677 | } | |
7678 | ||
7679 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7680 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
7681 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7682 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7683 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV) | |
7684 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7685 | json_object_object_add(json_addr, "afDependentCap", json_af); | |
b6df4090 DS |
7686 | else |
7687 | json_object_free(json_af); | |
856ca177 MS |
7688 | |
7689 | sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
7690 | orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json); | |
7691 | ||
7692 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND) | |
7693 | || orf_pfx_count) | |
7694 | { | |
7695 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)) | |
7696 | json_object_boolean_true_add(json_neigh, "orfSent"); | |
7697 | if (orf_pfx_count) | |
7698 | json_object_int_add(json_addr, "orfRecvCounter", orf_pfx_count); | |
7699 | } | |
7700 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) | |
7701 | json_object_string_add(json_addr, "orfFirstUpdate", "deferredUntilORFOrRouteRefreshRecvd"); | |
7702 | ||
7703 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) | |
7704 | json_object_boolean_true_add(json_addr, "routeReflectorClient"); | |
7705 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
7706 | json_object_boolean_true_add(json_addr, "routeServerClient"); | |
7707 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
7708 | json_object_boolean_true_add(json_addr, "inboundSoftConfigPermit"); | |
7709 | ||
88b8ed8d DW |
7710 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) |
7711 | json_object_boolean_true_add(json_addr, "privateAsNumsAllReplacedInUpdatesToNbr"); | |
7712 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
856ca177 | 7713 | json_object_boolean_true_add(json_addr, "privateAsNumsReplacedInUpdatesToNbr"); |
88b8ed8d DW |
7714 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) |
7715 | json_object_boolean_true_add(json_addr, "privateAsNumsAllRemovedInUpdatesToNbr"); | |
856ca177 MS |
7716 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS)) |
7717 | json_object_boolean_true_add(json_addr, "privateAsNumsRemovedInUpdatesToNbr"); | |
7718 | ||
adbac85e DW |
7719 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS)) |
7720 | json_object_boolean_true_add(json_addr, "addpathTxAllPaths"); | |
7721 | ||
06370dac DW |
7722 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) |
7723 | json_object_boolean_true_add(json_addr, "addpathTxBestpathPerAS"); | |
7724 | ||
856ca177 MS |
7725 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) |
7726 | json_object_string_add(json_addr, "overrideASNsInOutboundUpdates", "ifAspathEqualRemoteAs"); | |
7727 | ||
7728 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) || | |
7729 | CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
7730 | json_object_boolean_true_add(json_addr, "routerAlwaysNextHop"); | |
7731 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED)) | |
7732 | json_object_boolean_true_add(json_addr, "unchangedAsPathPropogatedToNbr"); | |
7733 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)) | |
7734 | json_object_boolean_true_add(json_addr, "unchangedNextHopPropogatedToNbr"); | |
7735 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
7736 | json_object_boolean_true_add(json_addr, "unchangedMedPropogatedToNbr"); | |
718e3744 | 7737 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) |
856ca177 MS |
7738 | || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) |
7739 | { | |
7740 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
7741 | && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7742 | json_object_string_add(json_addr, "commAttriSentToNbr", "extendedAndStandard"); | |
7743 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7744 | json_object_string_add(json_addr, "commAttriSentToNbr", "extended"); | |
7745 | else | |
7746 | json_object_string_add(json_addr, "commAttriSentToNbr", "standard"); | |
7747 | } | |
7748 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) | |
7749 | { | |
7750 | if (p->default_rmap[afi][safi].name) | |
7751 | json_object_string_add(json_addr, "defaultRouteMap", p->default_rmap[afi][safi].name); | |
7752 | ||
7753 | if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
7754 | json_object_boolean_true_add(json_addr, "defaultSent"); | |
7755 | else | |
7756 | json_object_boolean_true_add(json_addr, "defaultNotSent"); | |
7757 | } | |
7758 | ||
7759 | if (filter->plist[FILTER_IN].name | |
7760 | || filter->dlist[FILTER_IN].name | |
7761 | || filter->aslist[FILTER_IN].name | |
7762 | || filter->map[RMAP_IN].name) | |
7763 | json_object_boolean_true_add(json_addr, "inboundPathPolicyConfig"); | |
7764 | if (filter->plist[FILTER_OUT].name | |
7765 | || filter->dlist[FILTER_OUT].name | |
7766 | || filter->aslist[FILTER_OUT].name | |
7767 | || filter->map[RMAP_OUT].name | |
7768 | || filter->usmap.name) | |
7769 | json_object_boolean_true_add(json_addr, "outboundPathPolicyConfig"); | |
856ca177 MS |
7770 | |
7771 | /* prefix-list */ | |
7772 | if (filter->plist[FILTER_IN].name) | |
7773 | json_object_string_add(json_addr, "incomingUpdatePrefixFilterList", filter->plist[FILTER_IN].name); | |
7774 | if (filter->plist[FILTER_OUT].name) | |
7775 | json_object_string_add(json_addr, "outgoingUpdatePrefixFilterList", filter->plist[FILTER_OUT].name); | |
7776 | ||
7777 | /* distribute-list */ | |
7778 | if (filter->dlist[FILTER_IN].name) | |
7779 | json_object_string_add(json_addr, "incomingUpdateNetworkFilterList", filter->dlist[FILTER_IN].name); | |
7780 | if (filter->dlist[FILTER_OUT].name) | |
7781 | json_object_string_add(json_addr, "outgoingUpdateNetworkFilterList", filter->dlist[FILTER_OUT].name); | |
7782 | ||
7783 | /* filter-list. */ | |
7784 | if (filter->aslist[FILTER_IN].name) | |
7785 | json_object_string_add(json_addr, "incomingUpdateAsPathFilterList", filter->aslist[FILTER_IN].name); | |
7786 | if (filter->aslist[FILTER_OUT].name) | |
7787 | json_object_string_add(json_addr, "outgoingUpdateAsPathFilterList", filter->aslist[FILTER_OUT].name); | |
7788 | ||
7789 | /* route-map. */ | |
7790 | if (filter->map[RMAP_IN].name) | |
7791 | json_object_string_add(json_addr, "routeMapForIncomingAdvertisements", filter->map[RMAP_IN].name); | |
7792 | if (filter->map[RMAP_OUT].name) | |
7793 | json_object_string_add(json_addr, "routeMapForOutgoingAdvertisements", filter->map[RMAP_OUT].name); | |
856ca177 MS |
7794 | |
7795 | /* unsuppress-map */ | |
7796 | if (filter->usmap.name) | |
7797 | json_object_string_add(json_addr, "selectiveUnsuppressRouteMap", filter->usmap.name); | |
7798 | ||
7799 | /* Receive prefix count */ | |
7800 | json_object_int_add(json_addr, "acceptedPrefixCounter", p->pcount[afi][safi]); | |
7801 | ||
7802 | /* Maximum prefix */ | |
7803 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) | |
7804 | { | |
7805 | json_object_int_add(json_addr, "prefixAllowedMax", p->pmax[afi][safi]); | |
7806 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) | |
7807 | json_object_boolean_true_add(json_addr, "prefixAllowedMaxWarning"); | |
7808 | json_object_int_add(json_addr, "prefixAllowedWarningThresh", p->pmax_threshold[afi][safi]); | |
7809 | if (p->pmax_restart[afi][safi]) | |
7810 | json_object_int_add(json_addr, "prefixAllowedRestartIntervalMsecs", p->pmax_restart[afi][safi] * 60000); | |
7811 | } | |
7812 | json_object_object_add(json_neigh, afi_safi_print (afi, safi), json_addr); | |
7813 | ||
7814 | } | |
7815 | else | |
7816 | { | |
7817 | filter = &p->filter[afi][safi]; | |
7818 | ||
7819 | vty_out (vty, " For address family: %s%s", afi_safi_print (afi, safi), | |
7820 | VTY_NEWLINE); | |
7821 | ||
c8560b44 | 7822 | if (peer_group_active(p)) |
856ca177 MS |
7823 | vty_out (vty, " %s peer-group member%s", p->group->name, VTY_NEWLINE); |
7824 | ||
7825 | paf = peer_af_find(p, afi, safi); | |
7826 | if (paf && PAF_SUBGRP(paf)) | |
7827 | { | |
7828 | vty_out (vty, " Update group %" PRIu64 ", subgroup %" PRIu64 "%s", | |
7829 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id, VTY_NEWLINE); | |
7830 | vty_out (vty, " Packet Queue length %d%s", | |
7831 | bpacket_queue_virtual_length(paf), VTY_NEWLINE); | |
7832 | } | |
718e3744 | 7833 | else |
856ca177 MS |
7834 | { |
7835 | vty_out(vty, " Not part of any update group%s", VTY_NEWLINE); | |
7836 | } | |
7837 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7838 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
7839 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7840 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7841 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV) | |
7842 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7843 | vty_out (vty, " AF-dependant capabilities:%s", VTY_NEWLINE); | |
7844 | ||
7845 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7846 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
7847 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7848 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)) | |
7849 | { | |
7850 | vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s", | |
7851 | ORF_TYPE_PREFIX, VTY_NEWLINE); | |
7852 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, | |
7853 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
7854 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7855 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
7856 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
7857 | } | |
7858 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7859 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7860 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7861 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7862 | { | |
7863 | vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s", | |
7864 | ORF_TYPE_PREFIX_OLD, VTY_NEWLINE); | |
7865 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, | |
7866 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
7867 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7868 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
7869 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
7870 | } | |
718e3744 | 7871 | |
856ca177 MS |
7872 | sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi); |
7873 | orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json); | |
718e3744 | 7874 | |
856ca177 MS |
7875 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND) |
7876 | || orf_pfx_count) | |
7877 | { | |
7878 | vty_out (vty, " Outbound Route Filter (ORF):"); | |
7879 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)) | |
7880 | vty_out (vty, " sent;"); | |
7881 | if (orf_pfx_count) | |
7882 | vty_out (vty, " received (%d entries)", orf_pfx_count); | |
7883 | vty_out (vty, "%s", VTY_NEWLINE); | |
7884 | } | |
7885 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) | |
7886 | vty_out (vty, " First update is deferred until ORF or ROUTE-REFRESH is received%s", VTY_NEWLINE); | |
7887 | ||
7888 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) | |
7889 | vty_out (vty, " Route-Reflector Client%s", VTY_NEWLINE); | |
7890 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
7891 | vty_out (vty, " Route-Server Client%s", VTY_NEWLINE); | |
7892 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
7893 | vty_out (vty, " Inbound soft reconfiguration allowed%s", VTY_NEWLINE); | |
7894 | ||
88b8ed8d DW |
7895 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) |
7896 | vty_out (vty, " Private AS numbers (all) replaced in updates to this neighbor%s", VTY_NEWLINE); | |
7897 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
856ca177 | 7898 | vty_out (vty, " Private AS numbers replaced in updates to this neighbor%s", VTY_NEWLINE); |
88b8ed8d DW |
7899 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) |
7900 | vty_out (vty, " Private AS numbers (all) removed in updates to this neighbor%s", VTY_NEWLINE); | |
856ca177 MS |
7901 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS)) |
7902 | vty_out (vty, " Private AS numbers removed in updates to this neighbor%s", VTY_NEWLINE); | |
7903 | ||
adbac85e DW |
7904 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS)) |
7905 | vty_out (vty, " Advertise all paths via addpath%s", VTY_NEWLINE); | |
7906 | ||
06370dac DW |
7907 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) |
7908 | vty_out (vty, " Advertise bestpath per AS via addpath%s", VTY_NEWLINE); | |
7909 | ||
856ca177 MS |
7910 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) |
7911 | vty_out (vty, " Override ASNs in outbound updates if aspath equals remote-as%s", VTY_NEWLINE); | |
7912 | ||
7913 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) || | |
7914 | CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
7915 | vty_out (vty, " NEXT_HOP is always this router%s", VTY_NEWLINE); | |
7916 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED)) | |
7917 | vty_out (vty, " AS_PATH is propagated unchanged to this neighbor%s", VTY_NEWLINE); | |
7918 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)) | |
7919 | vty_out (vty, " NEXT_HOP is propagated unchanged to this neighbor%s", VTY_NEWLINE); | |
7920 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
7921 | vty_out (vty, " MED is propagated unchanged to this neighbor%s", VTY_NEWLINE); | |
7922 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
57d187bc JS |
7923 | || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY) |
7924 | || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
856ca177 MS |
7925 | { |
7926 | vty_out (vty, " Community attribute sent to this neighbor"); | |
7927 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
57d187bc JS |
7928 | && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY) |
7929 | && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
7930 | vty_out (vty, "(all)%s", VTY_NEWLINE); | |
7931 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
7932 | vty_out (vty, "(large)%s", VTY_NEWLINE); | |
856ca177 MS |
7933 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) |
7934 | vty_out (vty, "(extended)%s", VTY_NEWLINE); | |
7935 | else | |
7936 | vty_out (vty, "(standard)%s", VTY_NEWLINE); | |
7937 | } | |
7938 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) | |
7939 | { | |
7940 | vty_out (vty, " Default information originate,"); | |
7941 | ||
7942 | if (p->default_rmap[afi][safi].name) | |
7943 | vty_out (vty, " default route-map %s%s,", | |
7944 | p->default_rmap[afi][safi].map ? "*" : "", | |
7945 | p->default_rmap[afi][safi].name); | |
7946 | if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
7947 | vty_out (vty, " default sent%s", VTY_NEWLINE); | |
7948 | else | |
7949 | vty_out (vty, " default not sent%s", VTY_NEWLINE); | |
7950 | } | |
718e3744 | 7951 | |
856ca177 MS |
7952 | if (filter->plist[FILTER_IN].name |
7953 | || filter->dlist[FILTER_IN].name | |
7954 | || filter->aslist[FILTER_IN].name | |
7955 | || filter->map[RMAP_IN].name) | |
7956 | vty_out (vty, " Inbound path policy configured%s", VTY_NEWLINE); | |
7957 | if (filter->plist[FILTER_OUT].name | |
7958 | || filter->dlist[FILTER_OUT].name | |
7959 | || filter->aslist[FILTER_OUT].name | |
7960 | || filter->map[RMAP_OUT].name | |
7961 | || filter->usmap.name) | |
7962 | vty_out (vty, " Outbound path policy configured%s", VTY_NEWLINE); | |
856ca177 MS |
7963 | |
7964 | /* prefix-list */ | |
7965 | if (filter->plist[FILTER_IN].name) | |
7966 | vty_out (vty, " Incoming update prefix filter list is %s%s%s", | |
7967 | filter->plist[FILTER_IN].plist ? "*" : "", | |
7968 | filter->plist[FILTER_IN].name, | |
7969 | VTY_NEWLINE); | |
7970 | if (filter->plist[FILTER_OUT].name) | |
7971 | vty_out (vty, " Outgoing update prefix filter list is %s%s%s", | |
7972 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
7973 | filter->plist[FILTER_OUT].name, | |
7974 | VTY_NEWLINE); | |
7975 | ||
7976 | /* distribute-list */ | |
7977 | if (filter->dlist[FILTER_IN].name) | |
7978 | vty_out (vty, " Incoming update network filter list is %s%s%s", | |
7979 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
7980 | filter->dlist[FILTER_IN].name, | |
7981 | VTY_NEWLINE); | |
7982 | if (filter->dlist[FILTER_OUT].name) | |
7983 | vty_out (vty, " Outgoing update network filter list is %s%s%s", | |
7984 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
7985 | filter->dlist[FILTER_OUT].name, | |
7986 | VTY_NEWLINE); | |
7987 | ||
7988 | /* filter-list. */ | |
7989 | if (filter->aslist[FILTER_IN].name) | |
7990 | vty_out (vty, " Incoming update AS path filter list is %s%s%s", | |
7991 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
7992 | filter->aslist[FILTER_IN].name, | |
7993 | VTY_NEWLINE); | |
7994 | if (filter->aslist[FILTER_OUT].name) | |
7995 | vty_out (vty, " Outgoing update AS path filter list is %s%s%s", | |
7996 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
7997 | filter->aslist[FILTER_OUT].name, | |
7998 | VTY_NEWLINE); | |
7999 | ||
8000 | /* route-map. */ | |
8001 | if (filter->map[RMAP_IN].name) | |
8002 | vty_out (vty, " Route map for incoming advertisements is %s%s%s", | |
8003 | filter->map[RMAP_IN].map ? "*" : "", | |
8004 | filter->map[RMAP_IN].name, | |
8005 | VTY_NEWLINE); | |
8006 | if (filter->map[RMAP_OUT].name) | |
8007 | vty_out (vty, " Route map for outgoing advertisements is %s%s%s", | |
8008 | filter->map[RMAP_OUT].map ? "*" : "", | |
8009 | filter->map[RMAP_OUT].name, | |
8010 | VTY_NEWLINE); | |
856ca177 MS |
8011 | |
8012 | /* unsuppress-map */ | |
8013 | if (filter->usmap.name) | |
8014 | vty_out (vty, " Route map for selective unsuppress is %s%s%s", | |
8015 | filter->usmap.map ? "*" : "", | |
8016 | filter->usmap.name, VTY_NEWLINE); | |
8017 | ||
8018 | /* Receive prefix count */ | |
8019 | vty_out (vty, " %ld accepted prefixes%s", p->pcount[afi][safi], VTY_NEWLINE); | |
8020 | ||
8021 | /* Maximum prefix */ | |
8022 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) | |
8023 | { | |
8024 | vty_out (vty, " Maximum prefixes allowed %ld%s%s", p->pmax[afi][safi], | |
8025 | CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING) | |
8026 | ? " (warning-only)" : "", VTY_NEWLINE); | |
8027 | vty_out (vty, " Threshold for warning message %d%%", | |
8028 | p->pmax_threshold[afi][safi]); | |
8029 | if (p->pmax_restart[afi][safi]) | |
8030 | vty_out (vty, ", restart interval %d min", p->pmax_restart[afi][safi]); | |
8031 | vty_out (vty, "%s", VTY_NEWLINE); | |
8032 | } | |
718e3744 | 8033 | |
0a486e5f | 8034 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 8035 | } |
718e3744 | 8036 | } |
8037 | ||
94f2b392 | 8038 | static void |
e8f7da3a | 8039 | bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *json) |
718e3744 | 8040 | { |
8041 | struct bgp *bgp; | |
4690c7d7 | 8042 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; |
718e3744 | 8043 | char timebuf[BGP_UPTIME_LEN]; |
f14e6fdb | 8044 | char dn_flag[2]; |
3a8c7ba1 DW |
8045 | const char *subcode_str; |
8046 | const char *code_str; | |
538621f2 | 8047 | afi_t afi; |
8048 | safi_t safi; | |
d6661008 DS |
8049 | u_int16_t i; |
8050 | u_char *msg; | |
e8f7da3a | 8051 | json_object *json_neigh = NULL; |
46111f2f | 8052 | time_t epoch_tbuf; |
718e3744 | 8053 | |
8054 | bgp = p->bgp; | |
8055 | ||
e8f7da3a DW |
8056 | if (use_json) |
8057 | json_neigh = json_object_new_object(); | |
8058 | ||
517cd68a DS |
8059 | memset (dn_flag, '\0', sizeof (dn_flag)); |
8060 | if (!p->conf_if && peer_dynamic_neighbor (p)) | |
8061 | dn_flag[0] = '*'; | |
8062 | ||
856ca177 | 8063 | if (!use_json) |
f14e6fdb | 8064 | { |
856ca177 MS |
8065 | if (p->conf_if) /* Configured interface name. */ |
8066 | vty_out (vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
8067 | BGP_PEER_SU_UNSPEC(p) ? "None" : | |
8068 | sockunion2str (&p->su, buf, SU_ADDRSTRLEN)); | |
8069 | else /* Configured IP address. */ | |
74ef1672 | 8070 | vty_out (vty, "BGP neighbor is %s%s, ", dn_flag, p->host); |
f14e6fdb DS |
8071 | } |
8072 | ||
856ca177 MS |
8073 | if (use_json) |
8074 | { | |
8075 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
8076 | json_object_string_add(json_neigh, "bgpNeighborAddr", "none"); | |
8077 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
8078 | json_object_string_add(json_neigh, "bgpNeighborAddr", sockunion2str (&p->su, buf, SU_ADDRSTRLEN)); | |
8079 | ||
8080 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
8081 | ||
8082 | if (p->change_local_as) | |
8083 | json_object_int_add(json_neigh, "localAs", p->change_local_as); | |
8084 | else | |
8085 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
8086 | ||
8087 | if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
8088 | json_object_boolean_true_add(json_neigh, "localAsNoPrepend"); | |
66b199b2 | 8089 | |
856ca177 MS |
8090 | if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) |
8091 | json_object_boolean_true_add(json_neigh, "localAsReplaceAs"); | |
8092 | } | |
8093 | else | |
8094 | { | |
f8cfafda DS |
8095 | if ((p->as_type == AS_SPECIFIED) || |
8096 | (p->as_type == AS_EXTERNAL) || | |
8097 | (p->as_type == AS_INTERNAL)) | |
8098 | vty_out (vty, "remote AS %u, ", p->as); | |
8099 | else | |
8100 | vty_out (vty, "remote AS Unspecified, "); | |
856ca177 MS |
8101 | vty_out (vty, "local AS %u%s%s, ", |
8102 | p->change_local_as ? p->change_local_as : p->local_as, | |
8103 | CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ? | |
8104 | " no-prepend" : "", | |
8105 | CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) ? | |
8106 | " replace-as" : ""); | |
8107 | } | |
66b199b2 DS |
8108 | /* peer type internal, external, confed-internal or confed-external */ |
8109 | if (p->as == p->local_as) | |
8110 | { | |
856ca177 MS |
8111 | if (use_json) |
8112 | { | |
8113 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
8114 | json_object_boolean_true_add(json_neigh, "nbrConfedInternalLink"); | |
8115 | else | |
8116 | json_object_boolean_true_add(json_neigh, "nbrInternalLink"); | |
8117 | } | |
66b199b2 | 8118 | else |
856ca177 MS |
8119 | { |
8120 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
8121 | vty_out (vty, "confed-internal link%s", VTY_NEWLINE); | |
8122 | else | |
8123 | vty_out (vty, "internal link%s", VTY_NEWLINE); | |
8124 | } | |
66b199b2 DS |
8125 | } |
8126 | else | |
8127 | { | |
856ca177 MS |
8128 | if (use_json) |
8129 | { | |
8130 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
8131 | json_object_boolean_true_add(json_neigh, "nbrConfedExternalLink"); | |
8132 | else | |
8133 | json_object_boolean_true_add(json_neigh, "nbrExternalLink"); | |
8134 | } | |
66b199b2 | 8135 | else |
856ca177 MS |
8136 | { |
8137 | if (bgp_confederation_peers_check(bgp, p->as)) | |
8138 | vty_out (vty, "confed-external link%s", VTY_NEWLINE); | |
8139 | else | |
8140 | vty_out (vty, "external link%s", VTY_NEWLINE); | |
8141 | } | |
66b199b2 | 8142 | } |
718e3744 | 8143 | |
8144 | /* Description. */ | |
8145 | if (p->desc) | |
856ca177 MS |
8146 | { |
8147 | if (use_json) | |
8148 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
8149 | else | |
8150 | vty_out (vty, " Description: %s%s", p->desc, VTY_NEWLINE); | |
8151 | } | |
6410e93a | 8152 | |
04b6bdc0 DW |
8153 | if (p->hostname) |
8154 | { | |
d1570739 DW |
8155 | if (use_json) |
8156 | { | |
8157 | if (p->hostname) | |
8158 | json_object_string_add(json_neigh, "hostname", p->hostname); | |
8159 | ||
8160 | if (p->domainname) | |
8161 | json_object_string_add(json_neigh, "domainname", p->domainname); | |
8162 | } | |
04b6bdc0 | 8163 | else |
d1570739 DW |
8164 | { |
8165 | if (p->domainname && (p->domainname[0] != '\0')) | |
8166 | vty_out(vty, "Hostname: %s.%s%s", p->hostname, p->domainname, | |
8167 | VTY_NEWLINE); | |
8168 | else | |
8169 | vty_out(vty, "Hostname: %s%s", p->hostname, VTY_NEWLINE); | |
8170 | } | |
8171 | ||
04b6bdc0 DW |
8172 | } |
8173 | ||
c744aa9f | 8174 | /* Peer-group */ |
718e3744 | 8175 | if (p->group) |
f14e6fdb | 8176 | { |
856ca177 MS |
8177 | if (use_json) |
8178 | { | |
8179 | json_object_string_add(json_neigh, "peerGroup", p->group->name); | |
8180 | ||
8181 | if (dn_flag[0]) | |
8182 | { | |
40ee54a7 | 8183 | struct prefix prefix, *range = NULL; |
f14e6fdb | 8184 | |
40ee54a7 TT |
8185 | sockunion2hostprefix(&(p->su), &prefix); |
8186 | range = peer_group_lookup_dynamic_neighbor_range (p->group, &prefix); | |
856ca177 MS |
8187 | |
8188 | if (range) | |
8189 | { | |
8190 | prefix2str(range, buf1, sizeof(buf1)); | |
8191 | json_object_string_add(json_neigh, "peerSubnetRangeGroup", buf1); | |
8192 | } | |
8193 | } | |
8194 | } | |
8195 | else | |
f14e6fdb | 8196 | { |
856ca177 MS |
8197 | vty_out (vty, " Member of peer-group %s for session parameters%s", |
8198 | p->group->name, VTY_NEWLINE); | |
f14e6fdb | 8199 | |
856ca177 | 8200 | if (dn_flag[0]) |
f14e6fdb | 8201 | { |
40ee54a7 | 8202 | struct prefix prefix, *range = NULL; |
856ca177 | 8203 | |
40ee54a7 TT |
8204 | sockunion2hostprefix(&(p->su), &prefix); |
8205 | range = peer_group_lookup_dynamic_neighbor_range (p->group, &prefix); | |
856ca177 MS |
8206 | |
8207 | if (range) | |
8208 | { | |
8209 | prefix2str(range, buf1, sizeof(buf1)); | |
8210 | vty_out (vty, " Belongs to the subnet range group: %s%s", buf1, VTY_NEWLINE); | |
8211 | } | |
f14e6fdb DS |
8212 | } |
8213 | } | |
8214 | } | |
718e3744 | 8215 | |
856ca177 MS |
8216 | if (use_json) |
8217 | { | |
8218 | /* Administrative shutdown. */ | |
8219 | if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN)) | |
8220 | json_object_boolean_true_add(json_neigh, "adminShutDown"); | |
718e3744 | 8221 | |
856ca177 MS |
8222 | /* BGP Version. */ |
8223 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
389e3fe0 | 8224 | json_object_string_add(json_neigh, "remoteRouterId", |
44b8cd53 | 8225 | inet_ntop (AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
718e3744 | 8226 | |
856ca177 MS |
8227 | /* Confederation */ |
8228 | if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION) && bgp_confederation_peers_check (bgp, p->as)) | |
8229 | json_object_boolean_true_add(json_neigh, "nbrCommonAdmin"); | |
8230 | ||
8231 | /* Status. */ | |
56b40679 | 8232 | json_object_string_add(json_neigh, "bgpState", lookup_msg(bgp_status_msg, p->status, NULL)); |
856ca177 MS |
8233 | |
8234 | if (p->status == Established) | |
8235 | { | |
8236 | time_t uptime; | |
8237 | struct tm *tm; | |
8238 | ||
8239 | uptime = bgp_clock(); | |
8240 | uptime -= p->uptime; | |
8241 | tm = gmtime(&uptime); | |
46111f2f | 8242 | epoch_tbuf = time(NULL) - uptime; |
856ca177 MS |
8243 | |
8244 | json_object_int_add(json_neigh, "bgpTimerUp", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); | |
46111f2f DW |
8245 | json_object_string_add(json_neigh, "bgpTimerUpString", peer_uptime (p->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL)); |
8246 | json_object_int_add(json_neigh, "bgpTimerUpEstablishedEpoch", epoch_tbuf); | |
856ca177 MS |
8247 | } |
8248 | ||
8249 | else if (p->status == Active) | |
8250 | { | |
8251 | if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE)) | |
8252 | json_object_string_add(json_neigh, "bgpStateIs", "passive"); | |
8253 | else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT)) | |
8254 | json_object_string_add(json_neigh, "bgpStateIs", "passiveNSF"); | |
8255 | } | |
8256 | ||
8257 | /* read timer */ | |
8258 | time_t uptime; | |
8259 | struct tm *tm; | |
8260 | ||
8261 | uptime = bgp_clock(); | |
8262 | uptime -= p->readtime; | |
8263 | tm = gmtime(&uptime); | |
8264 | json_object_int_add(json_neigh, "bgpTimerLastRead", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); | |
8265 | ||
8266 | uptime = bgp_clock(); | |
8267 | uptime -= p->last_write; | |
8268 | tm = gmtime(&uptime); | |
39e871e6 ST |
8269 | json_object_int_add(json_neigh, "bgpTimerLastWrite", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); |
8270 | ||
8271 | uptime = bgp_clock(); | |
8272 | uptime -= p->update_time; | |
8273 | tm = gmtime(&uptime); | |
8274 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", | |
8275 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); | |
856ca177 MS |
8276 | |
8277 | /* Configured timer values. */ | |
8278 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", p->v_holdtime * 1000); | |
8279 | json_object_int_add(json_neigh, "bgpTimerKeepAliveIntervalMsecs", p->v_keepalive * 1000); | |
8280 | ||
8281 | if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER)) | |
8282 | { | |
8283 | json_object_int_add(json_neigh, "bgpTimerConfiguredHoldTimeMsecs", p->holdtime * 1000); | |
8284 | json_object_int_add(json_neigh, "bgpTimerConfiguredKeepAliveIntervalMsecs", p->keepalive * 1000); | |
8285 | } | |
93406d87 | 8286 | } |
856ca177 MS |
8287 | else |
8288 | { | |
8289 | /* Administrative shutdown. */ | |
8290 | if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN)) | |
8291 | vty_out (vty, " Administratively shut down%s", VTY_NEWLINE); | |
8292 | ||
8293 | /* BGP Version. */ | |
8294 | vty_out (vty, " BGP version 4"); | |
389e3fe0 | 8295 | vty_out (vty, ", remote router ID %s%s", |
44b8cd53 | 8296 | inet_ntop (AF_INET, &p->remote_id, buf1, sizeof(buf1)), |
856ca177 MS |
8297 | VTY_NEWLINE); |
8298 | ||
8299 | /* Confederation */ | |
8300 | if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION) | |
8301 | && bgp_confederation_peers_check (bgp, p->as)) | |
8302 | vty_out (vty, " Neighbor under common administration%s", VTY_NEWLINE); | |
e52702f2 | 8303 | |
856ca177 | 8304 | /* Status. */ |
56b40679 | 8305 | vty_out (vty, " BGP state = %s", lookup_msg(bgp_status_msg, p->status, NULL)); |
718e3744 | 8306 | |
856ca177 MS |
8307 | if (p->status == Established) |
8308 | vty_out (vty, ", up for %8s", peer_uptime (p->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL)); | |
8309 | ||
8310 | else if (p->status == Active) | |
8311 | { | |
8312 | if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE)) | |
8313 | vty_out (vty, " (passive)"); | |
8314 | else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT)) | |
8315 | vty_out (vty, " (NSF passive)"); | |
8316 | } | |
8317 | vty_out (vty, "%s", VTY_NEWLINE); | |
93406d87 | 8318 | |
856ca177 MS |
8319 | /* read timer */ |
8320 | vty_out (vty, " Last read %s", peer_uptime (p->readtime, timebuf, BGP_UPTIME_LEN, 0, NULL)); | |
8321 | vty_out (vty, ", Last write %s%s", | |
8322 | peer_uptime (p->last_write, timebuf, BGP_UPTIME_LEN, 0, NULL), VTY_NEWLINE); | |
8323 | ||
8324 | /* Configured timer values. */ | |
8325 | vty_out (vty, " Hold time is %d, keepalive interval is %d seconds%s", | |
8326 | p->v_holdtime, p->v_keepalive, VTY_NEWLINE); | |
8327 | if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER)) | |
8328 | { | |
8329 | vty_out (vty, " Configured hold time is %d", p->holdtime); | |
8330 | vty_out (vty, ", keepalive interval is %d seconds%s", | |
8331 | p->keepalive, VTY_NEWLINE); | |
8332 | } | |
8333 | } | |
718e3744 | 8334 | /* Capability. */ |
e52702f2 | 8335 | if (p->status == Established) |
718e3744 | 8336 | { |
538621f2 | 8337 | if (p->cap |
718e3744 | 8338 | || p->afc_adv[AFI_IP][SAFI_UNICAST] |
8339 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
8340 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
8341 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
718e3744 | 8342 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] |
8343 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
8344 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
8345 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
945c8fe9 LB |
8346 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] |
8347 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
8b1fb8be LB |
8348 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] |
8349 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
8b1fb8be LB |
8350 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
8351 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
718e3744 | 8352 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
8353 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) | |
8354 | { | |
856ca177 MS |
8355 | if (use_json) |
8356 | { | |
8357 | json_object *json_cap = NULL; | |
8358 | ||
8359 | json_cap = json_object_new_object(); | |
8360 | ||
8361 | /* AS4 */ | |
8362 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV) | |
8363 | || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
8364 | { | |
8365 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) && CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)) | |
8366 | json_object_string_add(json_cap, "4byteAs", "advertisedAndReceived"); | |
8367 | else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
8368 | json_object_string_add(json_cap, "4byteAs", "advertised"); | |
8369 | else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)) | |
8370 | json_object_string_add(json_cap, "4byteAs", "received"); | |
8371 | } | |
8372 | ||
8373 | /* AddPath */ | |
8374 | if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV) | |
8375 | || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV)) | |
8376 | { | |
8377 | json_object *json_add = NULL; | |
8378 | const char *print_store; | |
718e3744 | 8379 | |
856ca177 | 8380 | json_add = json_object_new_object(); |
a82478b9 | 8381 | |
856ca177 MS |
8382 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) |
8383 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8384 | { | |
8385 | json_object *json_sub = NULL; | |
8386 | json_sub = json_object_new_object(); | |
8387 | print_store = afi_safi_print (afi, safi); | |
8388 | ||
8389 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) || | |
8390 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) | |
8391 | { | |
8392 | 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)) | |
8393 | json_object_boolean_true_add(json_sub, "txAdvertisedAndReceived"); | |
8394 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV)) | |
8395 | json_object_boolean_true_add(json_sub, "txAdvertised"); | |
8396 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) | |
8397 | json_object_boolean_true_add(json_sub, "txReceived"); | |
8398 | } | |
8399 | ||
8400 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) || | |
8401 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) | |
8402 | { | |
8403 | 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)) | |
8404 | json_object_boolean_true_add(json_sub, "rxAdvertisedAndReceived"); | |
8405 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV)) | |
8406 | json_object_boolean_true_add(json_sub, "rxAdvertised"); | |
8407 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) | |
8408 | json_object_boolean_true_add(json_sub, "rxReceived"); | |
8409 | } | |
8410 | ||
8411 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) || | |
8412 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV) || | |
8413 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) || | |
8414 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) | |
8415 | json_object_object_add(json_add, print_store, json_sub); | |
b6df4090 DS |
8416 | else |
8417 | json_object_free(json_sub); | |
856ca177 | 8418 | } |
a82478b9 | 8419 | |
856ca177 MS |
8420 | json_object_object_add(json_cap, "addPath", json_add); |
8421 | } | |
8422 | ||
8423 | /* Dynamic */ | |
8424 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV) | |
8425 | || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
8426 | { | |
8427 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) && CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)) | |
8428 | json_object_string_add(json_cap, "dynamic", "advertisedAndReceived"); | |
8429 | else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
8430 | json_object_string_add(json_cap, "dynamic", "advertised"); | |
8431 | else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)) | |
8432 | json_object_string_add(json_cap, "dynamic", "received"); | |
8433 | } | |
8434 | ||
8435 | /* Extended nexthop */ | |
8436 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV) | |
8437 | || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
8438 | { | |
8439 | json_object *json_nxt = NULL; | |
8440 | const char *print_store; | |
8441 | ||
856ca177 MS |
8442 | |
8443 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) && CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
8444 | json_object_string_add(json_cap, "extendedNexthop", "advertisedAndReceived"); | |
8445 | else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
8446 | json_object_string_add(json_cap, "extendedNexthop", "advertised"); | |
8447 | else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
8448 | json_object_string_add(json_cap, "extendedNexthop", "received"); | |
8449 | ||
8450 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
8451 | { | |
b6df4090 DS |
8452 | json_nxt = json_object_new_object(); |
8453 | ||
856ca177 MS |
8454 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) |
8455 | { | |
8456 | if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV)) | |
8457 | { | |
8458 | print_store = afi_safi_print (AFI_IP, safi); | |
8459 | json_object_string_add(json_nxt, print_store, "recieved"); | |
8460 | } | |
8461 | } | |
8462 | json_object_object_add(json_cap, "extendedNexthopFamililesByPeer", json_nxt); | |
8463 | } | |
8464 | } | |
8465 | ||
8466 | /* Route Refresh */ | |
8467 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) | |
8468 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) | |
8469 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
8470 | { | |
8471 | 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))) | |
8472 | { | |
8473 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) | |
8474 | json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOldNew"); | |
8475 | else | |
8476 | { | |
8477 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
8478 | json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOld"); | |
8479 | else | |
8480 | json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedNew"); | |
8481 | } | |
8482 | } | |
8483 | else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)) | |
8484 | json_object_string_add(json_cap, "routeRefresh", "advertised"); | |
8485 | else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
8486 | json_object_string_add(json_cap, "routeRefresh", "received"); | |
8487 | } | |
8488 | ||
8489 | /* Multiprotocol Extensions */ | |
8490 | json_object *json_multi = NULL; | |
8491 | json_multi = json_object_new_object(); | |
8492 | ||
8493 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8494 | { | |
8495 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8496 | { | |
8497 | if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi]) | |
8498 | { | |
8499 | json_object *json_exten = NULL; | |
8500 | json_exten = json_object_new_object(); | |
8501 | ||
8502 | if (p->afc_adv[afi][safi] && p->afc_recv[afi][safi]) | |
8503 | json_object_boolean_true_add(json_exten, "advertisedAndReceived"); | |
8504 | else if (p->afc_adv[afi][safi]) | |
8505 | json_object_boolean_true_add(json_exten, "advertised"); | |
8506 | else if (p->afc_recv[afi][safi]) | |
8507 | json_object_boolean_true_add(json_exten, "received"); | |
8508 | ||
8509 | json_object_object_add(json_multi, afi_safi_print (afi, safi), json_exten); | |
8510 | } | |
8511 | } | |
8512 | } | |
8513 | json_object_object_add(json_cap, "multiprotocolExtensions", json_multi); | |
8514 | ||
8515 | /* Gracefull Restart */ | |
8516 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV) | |
8517 | || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
8518 | { | |
8519 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) && CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) | |
8520 | json_object_string_add(json_cap, "gracefulRestart", "advertisedAndReceived"); | |
8521 | else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
8522 | json_object_string_add(json_cap, "gracefulRestartCapability", "advertised"); | |
8523 | else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) | |
8524 | json_object_string_add(json_cap, "gracefulRestartCapability", "received"); | |
8525 | ||
8526 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) | |
8527 | { | |
8528 | int restart_af_count = 0; | |
8529 | json_object *json_restart = NULL; | |
8530 | json_restart = json_object_new_object(); | |
8531 | ||
8532 | json_object_int_add(json_cap, "gracefulRestartRemoteTimerMsecs", p->v_gr_restart * 1000); | |
8533 | ||
8534 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8535 | { | |
8536 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8537 | { | |
8538 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV)) | |
8539 | { | |
8540 | json_object *json_sub = NULL; | |
8541 | json_sub = json_object_new_object(); | |
8542 | ||
8543 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV)) | |
8544 | json_object_boolean_true_add(json_sub, "preserved"); | |
8545 | restart_af_count++; | |
8546 | json_object_object_add(json_restart, afi_safi_print (afi, safi), json_sub); | |
8547 | } | |
8548 | } | |
8549 | } | |
8550 | if (! restart_af_count) | |
b6df4090 | 8551 | { |
856ca177 | 8552 | json_object_string_add(json_cap, "addressFamiliesByPeer", "none"); |
b6df4090 DS |
8553 | json_object_free(json_restart); |
8554 | } | |
856ca177 MS |
8555 | else |
8556 | json_object_object_add(json_cap, "addressFamiliesByPeer", json_restart); | |
8557 | } | |
8558 | } | |
8559 | json_object_object_add(json_neigh, "neighborCapabilities", json_cap); | |
8560 | } | |
8561 | else | |
8562 | { | |
8563 | vty_out (vty, " Neighbor capabilities:%s", VTY_NEWLINE); | |
8564 | ||
8565 | /* AS4 */ | |
8566 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV) | |
8567 | || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
8568 | { | |
8569 | vty_out (vty, " 4 Byte AS:"); | |
8570 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
8571 | vty_out (vty, " advertised"); | |
8572 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)) | |
8573 | vty_out (vty, " %sreceived", | |
8574 | CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) ? "and " : ""); | |
8575 | vty_out (vty, "%s", VTY_NEWLINE); | |
8576 | } | |
8577 | ||
8578 | /* AddPath */ | |
8579 | if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV) | |
8580 | || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV)) | |
8581 | { | |
8582 | vty_out (vty, " AddPath:%s", VTY_NEWLINE); | |
a82478b9 | 8583 | |
856ca177 MS |
8584 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) |
8585 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
a82478b9 | 8586 | { |
856ca177 MS |
8587 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) || |
8588 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) | |
8589 | { | |
8590 | vty_out (vty, " %s: TX ", afi_safi_print (afi, safi)); | |
a82478b9 | 8591 | |
856ca177 MS |
8592 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV)) |
8593 | vty_out (vty, "advertised %s", afi_safi_print (afi, safi)); | |
a82478b9 | 8594 | |
856ca177 MS |
8595 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) |
8596 | vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ? " and " : "" ); | |
a82478b9 | 8597 | |
856ca177 MS |
8598 | vty_out (vty, "%s", VTY_NEWLINE); |
8599 | } | |
a82478b9 | 8600 | |
856ca177 | 8601 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) || |
a82478b9 | 8602 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) |
856ca177 MS |
8603 | { |
8604 | vty_out (vty, " %s: RX ", afi_safi_print (afi, safi)); | |
a82478b9 | 8605 | |
856ca177 MS |
8606 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV)) |
8607 | vty_out (vty, "advertised %s", afi_safi_print (afi, safi)); | |
a82478b9 | 8608 | |
856ca177 MS |
8609 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) |
8610 | vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ? " and " : "" ); | |
a82478b9 | 8611 | |
856ca177 MS |
8612 | vty_out (vty, "%s", VTY_NEWLINE); |
8613 | } | |
a82478b9 | 8614 | } |
856ca177 | 8615 | } |
a82478b9 | 8616 | |
856ca177 MS |
8617 | /* Dynamic */ |
8618 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV) | |
8619 | || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
8620 | { | |
8621 | vty_out (vty, " Dynamic:"); | |
8622 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
8623 | vty_out (vty, " advertised"); | |
8624 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)) | |
8625 | vty_out (vty, " %sreceived", | |
8626 | CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) ? "and " : ""); | |
8627 | vty_out (vty, "%s", VTY_NEWLINE); | |
8628 | } | |
8629 | ||
8630 | /* Extended nexthop */ | |
8631 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV) | |
8632 | || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
8633 | { | |
8634 | vty_out (vty, " Extended nexthop:"); | |
8635 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
8636 | vty_out (vty, " advertised"); | |
8637 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
8638 | vty_out (vty, " %sreceived", | |
8639 | CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) ? "and " : ""); | |
8640 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 8641 | |
856ca177 MS |
8642 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) |
8643 | { | |
8644 | vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE); | |
8645 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8646 | if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV)) | |
8647 | vty_out (vty, " %s%s", | |
8648 | afi_safi_print (AFI_IP, safi), VTY_NEWLINE); | |
8649 | } | |
8650 | } | |
8a92a8a0 | 8651 | |
856ca177 MS |
8652 | /* Route Refresh */ |
8653 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) | |
8654 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) | |
8655 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
8656 | { | |
8657 | vty_out (vty, " Route refresh:"); | |
8658 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)) | |
8659 | vty_out (vty, " advertised"); | |
8660 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) | |
8661 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
8662 | vty_out (vty, " %sreceived(%s)", | |
8663 | CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) ? "and " : "", | |
8664 | (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) | |
8665 | && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) ? | |
8666 | "old & new" : CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) ? "old" : "new"); | |
8a92a8a0 | 8667 | |
856ca177 MS |
8668 | vty_out (vty, "%s", VTY_NEWLINE); |
8669 | } | |
718e3744 | 8670 | |
856ca177 MS |
8671 | /* Multiprotocol Extensions */ |
8672 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8673 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8674 | if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi]) | |
8675 | { | |
8c3deaae | 8676 | vty_out (vty, " Address Family %s:", afi_safi_print (afi, safi)); |
856ca177 MS |
8677 | if (p->afc_adv[afi][safi]) |
8678 | vty_out (vty, " advertised"); | |
8679 | if (p->afc_recv[afi][safi]) | |
8680 | vty_out (vty, " %sreceived", p->afc_adv[afi][safi] ? "and " : ""); | |
8681 | vty_out (vty, "%s", VTY_NEWLINE); | |
8682 | } | |
538621f2 | 8683 | |
04b6bdc0 DW |
8684 | /* Hostname capability */ |
8685 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV) || | |
8686 | CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) | |
8687 | { | |
8688 | vty_out (vty, " Hostname Capability:"); | |
8689 | if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV)) | |
8690 | vty_out (vty, " advertised"); | |
8691 | if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_RCV)) | |
8692 | vty_out (vty, " %sreceived", | |
8693 | CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV) ? "and " : ""); | |
8694 | vty_out (vty, "%s", VTY_NEWLINE); | |
8695 | } | |
8696 | ||
856ca177 MS |
8697 | /* Gracefull Restart */ |
8698 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV) | |
8699 | || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
8700 | { | |
8701 | vty_out (vty, " Graceful Restart Capabilty:"); | |
8702 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
538621f2 | 8703 | vty_out (vty, " advertised"); |
856ca177 MS |
8704 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) |
8705 | vty_out (vty, " %sreceived", | |
8706 | CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) ? "and " : ""); | |
8707 | vty_out (vty, "%s", VTY_NEWLINE); | |
538621f2 | 8708 | |
856ca177 MS |
8709 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) |
8710 | { | |
8711 | int restart_af_count = 0; | |
8712 | ||
8713 | vty_out (vty, " Remote Restart timer is %d seconds%s", | |
8714 | p->v_gr_restart, VTY_NEWLINE); | |
8715 | vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE); | |
8716 | ||
8717 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8718 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8719 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV)) | |
8720 | { | |
8721 | vty_out (vty, "%s%s(%s)", restart_af_count ? ", " : "", | |
8722 | afi_safi_print (afi, safi), | |
8723 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV) ? | |
8724 | "preserved" : "not preserved"); | |
8725 | restart_af_count++; | |
8726 | } | |
8727 | if (! restart_af_count) | |
8728 | vty_out (vty, "none"); | |
8729 | vty_out (vty, "%s", VTY_NEWLINE); | |
8730 | } | |
8731 | } | |
8732 | } | |
718e3744 | 8733 | } |
8734 | } | |
8735 | ||
93406d87 | 8736 | /* graceful restart information */ |
8737 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV) | |
8738 | || p->t_gr_restart | |
8739 | || p->t_gr_stale) | |
8740 | { | |
856ca177 MS |
8741 | json_object *json_grace = NULL; |
8742 | json_object *json_grace_send = NULL; | |
8743 | json_object *json_grace_recv = NULL; | |
93406d87 | 8744 | int eor_send_af_count = 0; |
8745 | int eor_receive_af_count = 0; | |
8746 | ||
856ca177 MS |
8747 | if (use_json) |
8748 | { | |
8749 | json_grace = json_object_new_object(); | |
8750 | json_grace_send = json_object_new_object(); | |
8751 | json_grace_recv = json_object_new_object(); | |
8752 | ||
8753 | if (p->status == Established) | |
8754 | { | |
8755 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8756 | { | |
8757 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8758 | { | |
8759 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND)) | |
8760 | { | |
8761 | json_object_boolean_true_add(json_grace_send, afi_safi_print (afi, safi)); | |
8762 | eor_send_af_count++; | |
8763 | } | |
8764 | } | |
8765 | } | |
8766 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8767 | { | |
8768 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8769 | { | |
8770 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED)) | |
8771 | { | |
8772 | json_object_boolean_true_add(json_grace_recv, afi_safi_print (afi, safi)); | |
8773 | eor_receive_af_count++; | |
8774 | } | |
8775 | } | |
8776 | } | |
8777 | } | |
8778 | ||
8779 | json_object_object_add(json_grace, "endOfRibSend", json_grace_send); | |
8780 | json_object_object_add(json_grace, "endOfRibRecv", json_grace_recv); | |
8781 | ||
8782 | if (p->t_gr_restart) | |
8783 | json_object_int_add(json_grace, "gracefulRestartTimerMsecs", thread_timer_remain_second (p->t_gr_restart) * 1000); | |
8784 | ||
8785 | if (p->t_gr_stale) | |
8786 | json_object_int_add(json_grace, "gracefulStalepathTimerMsecs", thread_timer_remain_second (p->t_gr_stale) * 1000); | |
8787 | ||
8788 | json_object_object_add(json_neigh, "gracefulRestartInfo", json_grace); | |
8789 | } | |
8790 | else | |
8791 | { | |
8792 | vty_out (vty, " Graceful restart informations:%s", VTY_NEWLINE); | |
8793 | if (p->status == Established) | |
8794 | { | |
8795 | vty_out (vty, " End-of-RIB send: "); | |
8796 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8797 | { | |
8798 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8799 | { | |
8800 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND)) | |
8801 | { | |
8802 | vty_out (vty, "%s%s", eor_send_af_count ? ", " : "", | |
8803 | afi_safi_print (afi, safi)); | |
8804 | eor_send_af_count++; | |
8805 | } | |
8806 | } | |
8807 | } | |
8808 | vty_out (vty, "%s", VTY_NEWLINE); | |
8809 | vty_out (vty, " End-of-RIB received: "); | |
8810 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8811 | { | |
8812 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8813 | { | |
8814 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED)) | |
8815 | { | |
8816 | vty_out (vty, "%s%s", eor_receive_af_count ? ", " : "", | |
8817 | afi_safi_print (afi, safi)); | |
8818 | eor_receive_af_count++; | |
8819 | } | |
8820 | } | |
8821 | } | |
8822 | vty_out (vty, "%s", VTY_NEWLINE); | |
8823 | } | |
93406d87 | 8824 | |
856ca177 MS |
8825 | if (p->t_gr_restart) |
8826 | vty_out (vty, " The remaining time of restart timer is %ld%s", | |
8827 | thread_timer_remain_second (p->t_gr_restart), VTY_NEWLINE); | |
e52702f2 | 8828 | |
856ca177 MS |
8829 | if (p->t_gr_stale) |
8830 | vty_out (vty, " The remaining time of stalepath timer is %ld%s", | |
8831 | thread_timer_remain_second (p->t_gr_stale), VTY_NEWLINE); | |
8832 | } | |
8833 | } | |
8834 | if (use_json) | |
8835 | { | |
8836 | json_object *json_stat = NULL; | |
8837 | json_stat = json_object_new_object(); | |
8838 | /* Packet counts. */ | |
8839 | json_object_int_add(json_stat, "depthInq", 0); | |
8840 | json_object_int_add(json_stat, "depthOutq", (unsigned long) p->obuf->count); | |
8841 | json_object_int_add(json_stat, "opensSent", p->open_out); | |
8842 | json_object_int_add(json_stat, "opensRecv", p->open_in); | |
8843 | json_object_int_add(json_stat, "notificationsSent", p->notify_out); | |
8844 | json_object_int_add(json_stat, "notificationsRecv", p->notify_in); | |
8845 | json_object_int_add(json_stat, "updatesSent", p->update_out); | |
8846 | json_object_int_add(json_stat, "updatesRecv", p->update_in); | |
8847 | json_object_int_add(json_stat, "keepalivesSent", p->keepalive_out); | |
8848 | json_object_int_add(json_stat, "keepalivesRecv", p->keepalive_in); | |
8849 | json_object_int_add(json_stat, "routeRefreshSent", p->refresh_out); | |
8850 | json_object_int_add(json_stat, "routeRefreshRecv", p->refresh_in); | |
8851 | json_object_int_add(json_stat, "capabilitySent", p->dynamic_cap_out); | |
8852 | json_object_int_add(json_stat, "capabilityRecv", p->dynamic_cap_in); | |
8853 | 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); | |
8854 | 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); | |
8855 | json_object_object_add(json_neigh, "messageStats", json_stat); | |
8856 | } | |
8857 | else | |
8858 | { | |
8859 | /* Packet counts. */ | |
8860 | vty_out (vty, " Message statistics:%s", VTY_NEWLINE); | |
8861 | vty_out (vty, " Inq depth is 0%s", VTY_NEWLINE); | |
8862 | vty_out (vty, " Outq depth is %lu%s", (unsigned long) p->obuf->count, VTY_NEWLINE); | |
8863 | vty_out (vty, " Sent Rcvd%s", VTY_NEWLINE); | |
8864 | vty_out (vty, " Opens: %10d %10d%s", p->open_out, p->open_in, VTY_NEWLINE); | |
8865 | vty_out (vty, " Notifications: %10d %10d%s", p->notify_out, p->notify_in, VTY_NEWLINE); | |
8866 | vty_out (vty, " Updates: %10d %10d%s", p->update_out, p->update_in, VTY_NEWLINE); | |
8867 | vty_out (vty, " Keepalives: %10d %10d%s", p->keepalive_out, p->keepalive_in, VTY_NEWLINE); | |
8868 | vty_out (vty, " Route Refresh: %10d %10d%s", p->refresh_out, p->refresh_in, VTY_NEWLINE); | |
8869 | vty_out (vty, " Capability: %10d %10d%s", p->dynamic_cap_out, p->dynamic_cap_in, VTY_NEWLINE); | |
8870 | vty_out (vty, " Total: %10d %10d%s", p->open_out + p->notify_out + | |
8871 | p->update_out + p->keepalive_out + p->refresh_out + p->dynamic_cap_out, | |
8872 | p->open_in + p->notify_in + p->update_in + p->keepalive_in + p->refresh_in + | |
8873 | p->dynamic_cap_in, VTY_NEWLINE); | |
718e3744 | 8874 | } |
8875 | ||
856ca177 MS |
8876 | if (use_json) |
8877 | { | |
8878 | /* advertisement-interval */ | |
8879 | json_object_int_add(json_neigh, "minBtwnAdvertisementRunsTimerMsecs", p->v_routeadv * 1000); | |
718e3744 | 8880 | |
856ca177 MS |
8881 | /* Update-source. */ |
8882 | if (p->update_if || p->update_source) | |
8883 | { | |
8884 | if (p->update_if) | |
8885 | json_object_string_add(json_neigh, "updateSource", p->update_if); | |
8886 | else if (p->update_source) | |
8887 | json_object_string_add(json_neigh, "updateSource", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN)); | |
8888 | } | |
856ca177 MS |
8889 | } |
8890 | else | |
8891 | { | |
8892 | /* advertisement-interval */ | |
8893 | vty_out (vty, " Minimum time between advertisement runs is %d seconds%s", | |
8894 | p->v_routeadv, VTY_NEWLINE); | |
8895 | ||
8896 | /* Update-source. */ | |
8897 | if (p->update_if || p->update_source) | |
8898 | { | |
8899 | vty_out (vty, " Update source is "); | |
8900 | if (p->update_if) | |
8901 | vty_out (vty, "%s", p->update_if); | |
8902 | else if (p->update_source) | |
8903 | vty_out (vty, "%s", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN)); | |
8904 | vty_out (vty, "%s", VTY_NEWLINE); | |
8905 | } | |
8906 | ||
856ca177 MS |
8907 | vty_out (vty, "%s", VTY_NEWLINE); |
8908 | } | |
718e3744 | 8909 | |
8910 | /* Address Family Information */ | |
856ca177 MS |
8911 | json_object *json_hold = NULL; |
8912 | ||
8913 | if (use_json) | |
8914 | json_hold = json_object_new_object(); | |
8915 | ||
538621f2 | 8916 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) |
8917 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8918 | if (p->afc[afi][safi]) | |
856ca177 | 8919 | bgp_show_peer_afi (vty, p, afi, safi, use_json, json_hold); |
718e3744 | 8920 | |
856ca177 MS |
8921 | if (use_json) |
8922 | { | |
58433ae6 | 8923 | json_object_object_add(json_neigh, "addressFamilyInfo", json_hold); |
e08ac8b7 DW |
8924 | json_object_int_add(json_neigh, "connectionsEstablished", p->established); |
8925 | json_object_int_add(json_neigh, "connectionsDropped", p->dropped); | |
856ca177 MS |
8926 | } |
8927 | else | |
8928 | vty_out (vty, " Connections established %d; dropped %d%s", p->established, p->dropped, | |
8929 | VTY_NEWLINE); | |
718e3744 | 8930 | |
d6661008 | 8931 | if (! p->last_reset) |
856ca177 MS |
8932 | { |
8933 | if (use_json) | |
e08ac8b7 | 8934 | json_object_string_add(json_neigh, "lastReset", "never"); |
856ca177 MS |
8935 | else |
8936 | vty_out (vty, " Last reset never%s", VTY_NEWLINE); | |
8937 | } | |
e0701b79 | 8938 | else |
d6661008 | 8939 | { |
856ca177 MS |
8940 | if (use_json) |
8941 | { | |
8942 | time_t uptime; | |
8943 | struct tm *tm; | |
8944 | ||
8945 | uptime = bgp_clock(); | |
8946 | uptime -= p->resettime; | |
8947 | tm = gmtime(&uptime); | |
e08ac8b7 DW |
8948 | json_object_int_add(json_neigh, "lastResetTimerMsecs", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); |
8949 | json_object_string_add(json_neigh, "lastResetDueTo", peer_down_str[(int) p->last_reset]); | |
cca1dda8 DD |
8950 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND || |
8951 | p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) | |
856ca177 | 8952 | { |
39e871e6 | 8953 | char errorcodesubcode_hexstr[5]; |
cca1dda8 DD |
8954 | char errorcodesubcode_str[256]; |
8955 | ||
8956 | code_str = bgp_notify_code_str(p->notify.code); | |
8957 | subcode_str = bgp_notify_subcode_str(p->notify.code, p->notify.subcode); | |
8958 | ||
39e871e6 | 8959 | sprintf(errorcodesubcode_hexstr, "%02X%02X", p->notify.code, p->notify.subcode); |
e08ac8b7 | 8960 | json_object_string_add(json_neigh, "lastErrorCodeSubcode", errorcodesubcode_hexstr); |
cca1dda8 DD |
8961 | snprintf(errorcodesubcode_str, 255, "%s%s", code_str, subcode_str); |
8962 | json_object_string_add(json_neigh, "lastNotificationReason", errorcodesubcode_str); | |
652b9429 DS |
8963 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED |
8964 | && p->notify.code == BGP_NOTIFY_CEASE | |
8965 | && (p->notify.subcode == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
8966 | || p->notify.subcode == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
8967 | && p->notify.length) | |
8968 | { | |
8969 | char msgbuf[1024]; | |
8970 | const char *msg_str; | |
8971 | ||
8972 | msg_str = bgp_notify_admin_message(msgbuf, sizeof(msgbuf), | |
8973 | (u_char*)p->notify.data, p->notify.length); | |
8974 | if (msg_str) | |
8975 | json_object_string_add(json_neigh, "lastShutdownDescription", msg_str); | |
8976 | } | |
856ca177 MS |
8977 | } |
8978 | } | |
8979 | else | |
d6661008 | 8980 | { |
3a8c7ba1 DW |
8981 | vty_out (vty, " Last reset %s, ", |
8982 | peer_uptime (p->resettime, timebuf, BGP_UPTIME_LEN, 0, NULL)); | |
8983 | ||
8984 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND || | |
8985 | p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) | |
8986 | { | |
8987 | code_str = bgp_notify_code_str(p->notify.code); | |
8988 | subcode_str = bgp_notify_subcode_str(p->notify.code, p->notify.subcode); | |
8989 | vty_out (vty, "due to NOTIFICATION %s (%s%s)%s", | |
8990 | p->last_reset == PEER_DOWN_NOTIFY_SEND ? "sent" : "received", | |
8991 | code_str, subcode_str, VTY_NEWLINE); | |
38de8d02 DL |
8992 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED |
8993 | && p->notify.code == BGP_NOTIFY_CEASE | |
8994 | && (p->notify.subcode == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
8995 | || p->notify.subcode == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
8996 | && p->notify.length) | |
8997 | { | |
8998 | char msgbuf[1024]; | |
8999 | const char *msg_str; | |
9000 | ||
9001 | msg_str = bgp_notify_admin_message(msgbuf, sizeof(msgbuf), | |
9002 | (u_char*)p->notify.data, p->notify.length); | |
9003 | if (msg_str) | |
9004 | vty_out (vty, " Message: \"%s\"%s", msg_str, VTY_NEWLINE); | |
9005 | } | |
3a8c7ba1 DW |
9006 | } |
9007 | else | |
9008 | { | |
9009 | vty_out (vty, "due to %s%s", | |
9010 | peer_down_str[(int) p->last_reset], VTY_NEWLINE); | |
9011 | } | |
856ca177 MS |
9012 | |
9013 | if (p->last_reset_cause_size) | |
d6661008 | 9014 | { |
856ca177 MS |
9015 | msg = p->last_reset_cause; |
9016 | vty_out(vty, " Message received that caused BGP to send a NOTIFICATION:%s ", VTY_NEWLINE); | |
9017 | for (i = 1; i <= p->last_reset_cause_size; i++) | |
9018 | { | |
9019 | vty_out(vty, "%02X", *msg++); | |
d6661008 | 9020 | |
856ca177 MS |
9021 | if (i != p->last_reset_cause_size) |
9022 | { | |
9023 | if (i % 16 == 0) | |
9024 | { | |
9025 | vty_out(vty, "%s ", VTY_NEWLINE); | |
9026 | } | |
9027 | else if (i % 4 == 0) | |
9028 | { | |
9029 | vty_out(vty, " "); | |
9030 | } | |
9031 | } | |
9032 | } | |
9033 | vty_out(vty, "%s", VTY_NEWLINE); | |
d6661008 | 9034 | } |
d6661008 DS |
9035 | } |
9036 | } | |
848973c7 | 9037 | |
718e3744 | 9038 | if (CHECK_FLAG (p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) |
9039 | { | |
856ca177 | 9040 | if (use_json) |
e08ac8b7 | 9041 | json_object_boolean_true_add(json_neigh, "prefixesConfigExceedMax"); |
856ca177 MS |
9042 | else |
9043 | vty_out (vty, " Peer had exceeded the max. no. of prefixes configured.%s", VTY_NEWLINE); | |
0a486e5f | 9044 | |
9045 | if (p->t_pmax_restart) | |
856ca177 MS |
9046 | { |
9047 | if (use_json) | |
9048 | { | |
e08ac8b7 DW |
9049 | json_object_boolean_true_add(json_neigh, "reducePrefixNumFrom"); |
9050 | json_object_int_add(json_neigh, "restartInTimerMsec", thread_timer_remain_second (p->t_pmax_restart) * 1000); | |
856ca177 MS |
9051 | } |
9052 | else | |
9053 | vty_out (vty, " Reduce the no. of prefix from %s, will restart in %ld seconds%s", | |
9054 | p->host, thread_timer_remain_second (p->t_pmax_restart), | |
9055 | VTY_NEWLINE); | |
9056 | } | |
0a486e5f | 9057 | else |
856ca177 MS |
9058 | { |
9059 | if (use_json) | |
e08ac8b7 | 9060 | json_object_boolean_true_add(json_neigh, "reducePrefixNumAndClearIpBgp"); |
856ca177 MS |
9061 | else |
9062 | vty_out (vty, " Reduce the no. of prefix and clear ip bgp %s to restore peering%s", | |
9063 | p->host, VTY_NEWLINE); | |
9064 | } | |
718e3744 | 9065 | } |
9066 | ||
f5a4827d | 9067 | /* EBGP Multihop and GTSM */ |
6d85b15b | 9068 | if (p->sort != BGP_PEER_IBGP) |
f5a4827d | 9069 | { |
856ca177 MS |
9070 | if (use_json) |
9071 | { | |
9072 | if (p->gtsm_hops > 0) | |
9073 | json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->gtsm_hops); | |
9074 | else if (p->ttl > 1) | |
9075 | json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->ttl); | |
9076 | } | |
9077 | else | |
9078 | { | |
9079 | if (p->gtsm_hops > 0) | |
9080 | vty_out (vty, " External BGP neighbor may be up to %d hops away.%s", | |
9081 | p->gtsm_hops, VTY_NEWLINE); | |
9082 | else if (p->ttl > 1) | |
9083 | vty_out (vty, " External BGP neighbor may be up to %d hops away.%s", | |
9084 | p->ttl, VTY_NEWLINE); | |
9085 | } | |
f5a4827d | 9086 | } |
5d804b43 PM |
9087 | else |
9088 | { | |
9089 | if (p->gtsm_hops > 0) | |
856ca177 MS |
9090 | { |
9091 | if (use_json) | |
9092 | json_object_int_add(json_neigh, "internalBgpNbrMaxHopsAway", p->gtsm_hops); | |
9093 | else | |
9094 | vty_out (vty, " Internal BGP neighbor may be up to %d hops away.%s", | |
9095 | p->gtsm_hops, VTY_NEWLINE); | |
9096 | } | |
5d804b43 | 9097 | } |
718e3744 | 9098 | |
9099 | /* Local address. */ | |
9100 | if (p->su_local) | |
9101 | { | |
856ca177 MS |
9102 | if (use_json) |
9103 | { | |
9104 | json_object_string_add(json_neigh, "hostLocal", sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN)); | |
9105 | json_object_int_add(json_neigh, "portLocal", ntohs (p->su_local->sin.sin_port)); | |
9106 | } | |
9107 | else | |
9108 | vty_out (vty, "Local host: %s, Local port: %d%s", | |
9109 | sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN), | |
9110 | ntohs (p->su_local->sin.sin_port), | |
9111 | VTY_NEWLINE); | |
718e3744 | 9112 | } |
e52702f2 | 9113 | |
718e3744 | 9114 | /* Remote address. */ |
9115 | if (p->su_remote) | |
9116 | { | |
856ca177 MS |
9117 | if (use_json) |
9118 | { | |
9119 | json_object_string_add(json_neigh, "hostForeign", sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN)); | |
9120 | json_object_int_add(json_neigh, "portForeign", ntohs (p->su_remote->sin.sin_port)); | |
9121 | } | |
9122 | else | |
9123 | vty_out (vty, "Foreign host: %s, Foreign port: %d%s", | |
718e3744 | 9124 | sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN), |
9125 | ntohs (p->su_remote->sin.sin_port), | |
9126 | VTY_NEWLINE); | |
9127 | } | |
9128 | ||
9129 | /* Nexthop display. */ | |
9130 | if (p->su_local) | |
9131 | { | |
856ca177 MS |
9132 | if (use_json) |
9133 | { | |
389e3fe0 | 9134 | json_object_string_add(json_neigh, "nexthop", |
44b8cd53 | 9135 | inet_ntop (AF_INET, &p->nexthop.v4, buf1, sizeof(buf1))); |
389e3fe0 | 9136 | json_object_string_add(json_neigh, "nexthopGlobal", |
44b8cd53 | 9137 | inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, sizeof(buf1))); |
389e3fe0 | 9138 | json_object_string_add(json_neigh, "nexthopLocal", |
44b8cd53 | 9139 | inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, sizeof(buf1))); |
856ca177 MS |
9140 | if (p->shared_network) |
9141 | json_object_string_add(json_neigh, "bgpConnection", "sharedNetwork"); | |
9142 | else | |
9143 | json_object_string_add(json_neigh, "bgpConnection", "nonSharedNetwork"); | |
856ca177 MS |
9144 | } |
9145 | else | |
9146 | { | |
9147 | vty_out (vty, "Nexthop: %s%s", | |
44b8cd53 DL |
9148 | inet_ntop (AF_INET, &p->nexthop.v4, buf1, sizeof(buf1)), |
9149 | VTY_NEWLINE); | |
856ca177 | 9150 | vty_out (vty, "Nexthop global: %s%s", |
44b8cd53 DL |
9151 | inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, sizeof(buf1)), |
9152 | VTY_NEWLINE); | |
856ca177 | 9153 | vty_out (vty, "Nexthop local: %s%s", |
44b8cd53 DL |
9154 | inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, sizeof(buf1)), |
9155 | VTY_NEWLINE); | |
856ca177 | 9156 | vty_out (vty, "BGP connection: %s%s", |
44b8cd53 DL |
9157 | p->shared_network ? "shared network" : "non shared network", |
9158 | VTY_NEWLINE); | |
856ca177 | 9159 | } |
718e3744 | 9160 | } |
9161 | ||
9162 | /* Timer information. */ | |
856ca177 MS |
9163 | if (use_json) |
9164 | { | |
39e871e6 | 9165 | json_object_int_add(json_neigh, "connectRetryTimer", p->v_connect); |
dd9275d6 ST |
9166 | if (p->status == Established && p->rtt) |
9167 | json_object_int_add(json_neigh, "estimatedRttInMsecs", p->rtt); | |
856ca177 MS |
9168 | if (p->t_start) |
9169 | json_object_int_add(json_neigh, "nextStartTimerDueInMsecs", thread_timer_remain_second (p->t_start) * 1000); | |
9170 | if (p->t_connect) | |
9171 | json_object_int_add(json_neigh, "nextConnectTimerDueInMsecs", thread_timer_remain_second (p->t_connect) * 1000); | |
9172 | if (p->t_routeadv) | |
9173 | { | |
9174 | json_object_int_add(json_neigh, "mraiInterval", p->v_routeadv); | |
9175 | json_object_int_add(json_neigh, "mraiTimerExpireInMsecs", thread_timer_remain_second (p->t_routeadv) * 1000); | |
9176 | } | |
047fc950 DS |
9177 | if (p->password) |
9178 | json_object_int_add(json_neigh, "authenticationEnabled", 1); | |
cb1faec9 | 9179 | |
856ca177 MS |
9180 | if (p->t_read) |
9181 | json_object_string_add(json_neigh, "readThread", "on"); | |
9182 | else | |
9183 | json_object_string_add(json_neigh, "readThread", "off"); | |
9184 | if (p->t_write) | |
9185 | json_object_string_add(json_neigh, "writeThread", "on"); | |
9186 | else | |
9187 | json_object_string_add(json_neigh, "writeThread", "off"); | |
9188 | } | |
9189 | else | |
9190 | { | |
39e871e6 ST |
9191 | vty_out (vty, "BGP Connect Retry Timer in Seconds: %d%s", |
9192 | p->v_connect, VTY_NEWLINE); | |
dd9275d6 ST |
9193 | if (p->status == Established && p->rtt) |
9194 | vty_out (vty, "Estimated round trip time: %d ms%s", | |
9195 | p->rtt, VTY_NEWLINE); | |
856ca177 MS |
9196 | if (p->t_start) |
9197 | vty_out (vty, "Next start timer due in %ld seconds%s", | |
9198 | thread_timer_remain_second (p->t_start), VTY_NEWLINE); | |
9199 | if (p->t_connect) | |
9200 | vty_out (vty, "Next connect timer due in %ld seconds%s", | |
9201 | thread_timer_remain_second (p->t_connect), VTY_NEWLINE); | |
9202 | if (p->t_routeadv) | |
9203 | vty_out (vty, "MRAI (interval %u) timer expires in %ld seconds%s", | |
9204 | p->v_routeadv, thread_timer_remain_second (p->t_routeadv), | |
9205 | VTY_NEWLINE); | |
047fc950 DS |
9206 | if (p->password) |
9207 | vty_out (vty, "Peer Authentication Enabled%s", VTY_NEWLINE); | |
856ca177 MS |
9208 | |
9209 | vty_out (vty, "Read thread: %s Write thread: %s%s", | |
9210 | p->t_read ? "on" : "off", | |
9211 | p->t_write ? "on" : "off", | |
9212 | VTY_NEWLINE); | |
9213 | } | |
718e3744 | 9214 | |
9215 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
9216 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
856ca177 MS |
9217 | bgp_capability_vty_out (vty, p, use_json, json_neigh); |
9218 | ||
9219 | if (!use_json) | |
9220 | vty_out (vty, "%s", VTY_NEWLINE); | |
c43ed2e4 DS |
9221 | |
9222 | /* BFD information. */ | |
856ca177 MS |
9223 | bgp_bfd_show_info(vty, p, use_json, json_neigh); |
9224 | ||
9225 | if (use_json) | |
9226 | { | |
9227 | if (p->conf_if) /* Configured interface name. */ | |
9228 | json_object_object_add(json, p->conf_if, json_neigh); | |
9229 | else /* Configured IP address. */ | |
9230 | json_object_object_add(json, p->host, json_neigh); | |
9231 | } | |
718e3744 | 9232 | } |
9233 | ||
94f2b392 | 9234 | static int |
856ca177 MS |
9235 | bgp_show_neighbor (struct vty *vty, struct bgp *bgp, enum show_type type, |
9236 | union sockunion *su, const char *conf_if, u_char use_json, json_object *json) | |
718e3744 | 9237 | { |
1eb8ef25 | 9238 | struct listnode *node, *nnode; |
718e3744 | 9239 | struct peer *peer; |
9240 | int find = 0; | |
9241 | ||
1eb8ef25 | 9242 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
718e3744 | 9243 | { |
1ff9a340 DS |
9244 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
9245 | continue; | |
9246 | ||
718e3744 | 9247 | switch (type) |
856ca177 MS |
9248 | { |
9249 | case show_all: | |
e8f7da3a | 9250 | bgp_show_peer (vty, peer, use_json, json); |
856ca177 MS |
9251 | break; |
9252 | case show_peer: | |
9253 | if (conf_if) | |
9254 | { | |
4873b3b9 DW |
9255 | if ((peer->conf_if && !strcmp(peer->conf_if, conf_if)) || |
9256 | (peer->hostname && !strcmp(peer->hostname, conf_if))) | |
856ca177 MS |
9257 | { |
9258 | find = 1; | |
e8f7da3a | 9259 | bgp_show_peer (vty, peer, use_json, json); |
856ca177 MS |
9260 | } |
9261 | } | |
9262 | else | |
9263 | { | |
9264 | if (sockunion_same (&peer->su, su)) | |
9265 | { | |
9266 | find = 1; | |
e8f7da3a | 9267 | bgp_show_peer (vty, peer, use_json, json); |
856ca177 MS |
9268 | } |
9269 | } | |
9270 | break; | |
718e3744 | 9271 | } |
9272 | } | |
9273 | ||
9274 | if (type == show_peer && ! find) | |
856ca177 MS |
9275 | { |
9276 | if (use_json) | |
9277 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
9278 | else | |
9279 | vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE); | |
9280 | } | |
9281 | ||
9282 | if (use_json) | |
9283 | { | |
2aac5767 | 9284 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
856ca177 MS |
9285 | json_object_free(json); |
9286 | } | |
9287 | else | |
9288 | { | |
9289 | vty_out (vty, "%s", VTY_NEWLINE); | |
9290 | } | |
9291 | ||
718e3744 | 9292 | return CMD_SUCCESS; |
9293 | } | |
9294 | ||
f186de26 | 9295 | static void |
9296 | bgp_show_all_instances_neighbors_vty (struct vty *vty, u_char use_json) | |
9297 | { | |
9298 | struct listnode *node, *nnode; | |
9299 | struct bgp *bgp; | |
9300 | json_object *json = NULL; | |
9f689658 DD |
9301 | int is_first = 1; |
9302 | ||
9303 | if (use_json) | |
9304 | vty_out (vty, "{%s", VTY_NEWLINE); | |
f186de26 | 9305 | |
9306 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) | |
9307 | { | |
f186de26 | 9308 | if (use_json) |
9f689658 DD |
9309 | { |
9310 | if (!(json = json_object_new_object())) | |
9311 | { | |
9312 | zlog_err("Unable to allocate memory for JSON object"); | |
9313 | vty_out (vty, | |
9314 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}%s", | |
9315 | VTY_NEWLINE); | |
9316 | return; | |
9317 | } | |
9318 | ||
9319 | json_object_int_add(json, "vrfId", | |
9320 | (bgp->vrf_id == VRF_UNKNOWN) | |
9321 | ? -1 : bgp->vrf_id); | |
9322 | json_object_string_add(json, "vrfName", | |
9323 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
9324 | ? "Default" : bgp->name); | |
9325 | ||
9326 | if (! is_first) | |
9327 | vty_out (vty, ",%s", VTY_NEWLINE); | |
9328 | else | |
9329 | is_first = 0; | |
9330 | ||
9331 | vty_out(vty, "\"%s\":", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
9332 | ? "Default" : bgp->name); | |
9333 | } | |
9334 | else | |
9335 | { | |
9336 | vty_out (vty, "%sInstance %s:%s", | |
9337 | VTY_NEWLINE, | |
9338 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
9339 | ? "Default" : bgp->name, | |
9340 | VTY_NEWLINE); | |
9341 | } | |
f186de26 | 9342 | bgp_show_neighbor (vty, bgp, show_all, NULL, NULL, use_json, json); |
9343 | } | |
9f689658 DD |
9344 | |
9345 | if (use_json) | |
9346 | vty_out (vty, "}%s", VTY_NEWLINE); | |
f186de26 | 9347 | } |
9348 | ||
4fb25c53 DW |
9349 | static int |
9350 | bgp_show_neighbor_vty (struct vty *vty, const char *name, | |
9351 | enum show_type type, const char *ip_str, u_char use_json) | |
9352 | { | |
9353 | int ret; | |
9354 | struct bgp *bgp; | |
9355 | union sockunion su; | |
9356 | json_object *json = NULL; | |
9357 | ||
4fb25c53 DW |
9358 | if (name) |
9359 | { | |
9360 | if (strmatch(name, "all")) | |
9361 | { | |
9362 | bgp_show_all_instances_neighbors_vty (vty, use_json); | |
9363 | return CMD_SUCCESS; | |
9364 | } | |
9365 | else | |
9366 | { | |
9367 | bgp = bgp_lookup_by_name (name); | |
9368 | if (! bgp) | |
9369 | { | |
9370 | if (use_json) | |
9371 | { | |
47332bd0 | 9372 | json = json_object_new_object(); |
4fb25c53 | 9373 | json_object_boolean_true_add(json, "bgpNoSuchInstance"); |
e52702f2 | 9374 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
4fb25c53 DW |
9375 | json_object_free(json); |
9376 | } | |
9377 | else | |
9378 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
9379 | ||
9380 | return CMD_WARNING; | |
9381 | } | |
9382 | } | |
9383 | } | |
9384 | else | |
9385 | { | |
9386 | bgp = bgp_get_default (); | |
9387 | } | |
9388 | ||
9389 | if (bgp) | |
9390 | { | |
47332bd0 | 9391 | json = json_object_new_object(); |
4fb25c53 DW |
9392 | if (ip_str) |
9393 | { | |
9394 | ret = str2sockunion (ip_str, &su); | |
9395 | if (ret < 0) | |
9396 | bgp_show_neighbor (vty, bgp, type, NULL, ip_str, use_json, json); | |
9397 | else | |
9398 | bgp_show_neighbor (vty, bgp, type, &su, NULL, use_json, json); | |
9399 | } | |
9400 | else | |
9401 | { | |
9402 | bgp_show_neighbor (vty, bgp, type, NULL, NULL, use_json, json); | |
9403 | } | |
47332bd0 | 9404 | json_object_free (json); |
4fb25c53 DW |
9405 | } |
9406 | ||
9407 | return CMD_SUCCESS; | |
9408 | } | |
9409 | ||
716b2d8a | 9410 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 9411 | DEFUN (show_ip_bgp_neighbors, |
9412 | show_ip_bgp_neighbors_cmd, | |
18c57037 | 9413 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6|vpnv4 <all|rd ASN:nn_or_IP-address:nn>>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 9414 | SHOW_STR |
9415 | IP_STR | |
9416 | BGP_STR | |
f2a8972b | 9417 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
9418 | "Address Family\n" |
9419 | "Address Family\n" | |
91d37724 QY |
9420 | "Address Family\n" |
9421 | "Display information about all VPNv4 NLRIs\n" | |
9422 | "Display information for a route distinguisher\n" | |
9423 | "VPN Route Distinguisher\n" | |
718e3744 | 9424 | "Detailed information on TCP and BGP neighbor connections\n" |
9425 | "Neighbor to display information about\n" | |
a80beece | 9426 | "Neighbor to display information about\n" |
91d37724 | 9427 | "Neighbor on BGP configured interface\n" |
9973d184 | 9428 | JSON_STR) |
718e3744 | 9429 | { |
5bf15956 DW |
9430 | char *vrf = NULL; |
9431 | char *sh_arg = NULL; | |
9432 | enum show_type sh_type; | |
718e3744 | 9433 | |
5bf15956 | 9434 | u_char uj = use_json(argc, argv); |
718e3744 | 9435 | |
630a298c | 9436 | int idx = 0; |
718e3744 | 9437 | |
46854ac0 DS |
9438 | if (argv_find (argv, argc, "view", &idx) || |
9439 | argv_find (argv, argc, "vrf", &idx)) | |
9440 | vrf = argv[idx+1]->arg; | |
718e3744 | 9441 | |
46854ac0 | 9442 | idx++; |
91d37724 QY |
9443 | if (argv_find (argv, argc, "A.B.C.D", &idx) || |
9444 | argv_find (argv, argc, "X:X::X:X", &idx) || | |
630a298c QY |
9445 | argv_find (argv, argc, "WORD", &idx)) |
9446 | { | |
9447 | sh_type = show_peer; | |
9448 | sh_arg = argv[idx]->arg; | |
9449 | } | |
5bf15956 | 9450 | else |
630a298c | 9451 | sh_type = show_all; |
856ca177 | 9452 | |
5bf15956 | 9453 | return bgp_show_neighbor_vty (vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 9454 | } |
9455 | ||
716b2d8a | 9456 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 9457 | paths' and `show ip mbgp paths'. Those functions results are the |
9458 | same.*/ | |
f412b39a | 9459 | DEFUN (show_ip_bgp_paths, |
718e3744 | 9460 | show_ip_bgp_paths_cmd, |
46f296b4 | 9461 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 9462 | SHOW_STR |
9463 | IP_STR | |
9464 | BGP_STR | |
46f296b4 | 9465 | BGP_SAFI_HELP_STR |
718e3744 | 9466 | "Path information\n") |
9467 | { | |
9468 | vty_out (vty, "Address Refcnt Path%s", VTY_NEWLINE); | |
9469 | aspath_print_all_vty (vty); | |
9470 | return CMD_SUCCESS; | |
9471 | } | |
9472 | ||
718e3744 | 9473 | #include "hash.h" |
9474 | ||
94f2b392 | 9475 | static void |
718e3744 | 9476 | community_show_all_iterator (struct hash_backet *backet, struct vty *vty) |
9477 | { | |
9478 | struct community *com; | |
9479 | ||
9480 | com = (struct community *) backet->data; | |
6c4f4e6e | 9481 | vty_out (vty, "[%p] (%ld) %s%s", (void *)backet, com->refcnt, |
718e3744 | 9482 | community_str (com), VTY_NEWLINE); |
9483 | } | |
9484 | ||
9485 | /* Show BGP's community internal data. */ | |
f412b39a | 9486 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 9487 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 9488 | "show [ip] bgp community-info", |
718e3744 | 9489 | SHOW_STR |
9490 | IP_STR | |
9491 | BGP_STR | |
9492 | "List all bgp community information\n") | |
9493 | { | |
9494 | vty_out (vty, "Address Refcnt Community%s", VTY_NEWLINE); | |
9495 | ||
e52702f2 | 9496 | hash_iterate (community_hash (), |
718e3744 | 9497 | (void (*) (struct hash_backet *, void *)) |
9498 | community_show_all_iterator, | |
9499 | vty); | |
9500 | ||
9501 | return CMD_SUCCESS; | |
9502 | } | |
9503 | ||
57d187bc JS |
9504 | static void |
9505 | lcommunity_show_all_iterator (struct hash_backet *backet, struct vty *vty) | |
9506 | { | |
9507 | struct lcommunity *lcom; | |
9508 | ||
9509 | lcom = (struct lcommunity *) backet->data; | |
9510 | vty_out (vty, "[%p] (%ld) %s%s", (void *)backet, lcom->refcnt, | |
2acb4ac2 | 9511 | lcommunity_str (lcom), VTY_NEWLINE); |
57d187bc JS |
9512 | } |
9513 | ||
9514 | /* Show BGP's community internal data. */ | |
9515 | DEFUN (show_ip_bgp_lcommunity_info, | |
9516 | show_ip_bgp_lcommunity_info_cmd, | |
9517 | "show ip bgp large-community-info", | |
9518 | SHOW_STR | |
9519 | IP_STR | |
9520 | BGP_STR | |
9521 | "List all bgp large-community information\n") | |
9522 | { | |
9523 | vty_out (vty, "Address Refcnt Large-community%s", VTY_NEWLINE); | |
9524 | ||
9525 | hash_iterate (lcommunity_hash (), | |
2acb4ac2 DL |
9526 | (void (*) (struct hash_backet *, void *)) |
9527 | lcommunity_show_all_iterator, | |
9528 | vty); | |
57d187bc JS |
9529 | |
9530 | return CMD_SUCCESS; | |
9531 | } | |
9532 | ||
9533 | ||
f412b39a | 9534 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 9535 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 9536 | "show [ip] bgp attribute-info", |
718e3744 | 9537 | SHOW_STR |
9538 | IP_STR | |
9539 | BGP_STR | |
9540 | "List all bgp attribute information\n") | |
9541 | { | |
9542 | attr_show_all (vty); | |
9543 | return CMD_SUCCESS; | |
9544 | } | |
6b0655a2 | 9545 | |
f186de26 | 9546 | static void |
9547 | bgp_show_all_instances_updgrps_vty (struct vty *vty, afi_t afi, safi_t safi) | |
9548 | { | |
9549 | struct listnode *node, *nnode; | |
9550 | struct bgp *bgp; | |
9551 | ||
9552 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) | |
9553 | { | |
9554 | vty_out (vty, "%sInstance %s:%s", | |
9555 | VTY_NEWLINE, | |
9556 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) ? "Default" : bgp->name, | |
9557 | VTY_NEWLINE); | |
9558 | update_group_show(bgp, afi, safi, vty, 0); | |
9559 | } | |
9560 | } | |
9561 | ||
4fb25c53 DW |
9562 | static int |
9563 | bgp_show_update_groups(struct vty *vty, const char *name, | |
9564 | int afi, int safi, | |
9565 | uint64_t subgrp_id) | |
9566 | { | |
9567 | struct bgp *bgp; | |
9568 | ||
9569 | if (name) | |
9570 | { | |
9571 | if (strmatch (name, "all")) | |
9572 | { | |
9573 | bgp_show_all_instances_updgrps_vty (vty, afi, safi); | |
9574 | return CMD_SUCCESS; | |
9575 | } | |
9576 | else | |
9577 | { | |
9578 | bgp = bgp_lookup_by_name (name); | |
9579 | } | |
9580 | } | |
9581 | else | |
9582 | { | |
9583 | bgp = bgp_get_default (); | |
9584 | } | |
9585 | ||
9586 | if (bgp) | |
9587 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
9588 | return CMD_SUCCESS; | |
9589 | } | |
9590 | ||
8fe8a7f6 DS |
9591 | DEFUN (show_ip_bgp_updgrps, |
9592 | show_ip_bgp_updgrps_cmd, | |
18c57037 | 9593 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 9594 | SHOW_STR |
9595 | IP_STR | |
9596 | BGP_STR | |
9597 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 9598 | BGP_AFI_HELP_STR |
46f296b4 | 9599 | BGP_SAFI_HELP_STR |
5bf15956 DW |
9600 | "Detailed info about dynamic update groups\n" |
9601 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 9602 | { |
5bf15956 | 9603 | char *vrf = NULL; |
ae19d7dd QY |
9604 | afi_t afi = AFI_IP6; |
9605 | safi_t safi = SAFI_UNICAST; | |
5bf15956 DW |
9606 | uint64_t subgrp_id = 0; |
9607 | ||
ae19d7dd QY |
9608 | int idx = 0; |
9609 | ||
9610 | /* show [ip] bgp */ | |
9611 | if (argv_find (argv, argc, "ip", &idx)) | |
9612 | afi = AFI_IP; | |
18c57037 | 9613 | /* [<view|vrf> VIEWVRFNAME] */ |
ae19d7dd QY |
9614 | if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) |
9615 | vrf = argv[++idx]->arg; | |
c9e571b4 LB |
9616 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
9617 | if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) | |
9618 | { | |
9619 | argv_find_and_parse_safi (argv, argc, &idx, &safi); | |
9620 | } | |
5bf15956 | 9621 | |
ae19d7dd QY |
9622 | /* get subgroup id, if provided */ |
9623 | idx = argc - 1; | |
9624 | if (argv[idx]->type == VARIABLE_TKN) | |
9625 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx]->arg); | |
5bf15956 DW |
9626 | |
9627 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); | |
8fe8a7f6 DS |
9628 | } |
9629 | ||
f186de26 | 9630 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
9631 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 9632 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 9633 | SHOW_STR |
716b2d8a | 9634 | IP_STR |
f186de26 | 9635 | BGP_STR |
9636 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 9637 | "Detailed info about dynamic update groups\n") |
f186de26 | 9638 | { |
9639 | bgp_show_all_instances_updgrps_vty (vty, AFI_IP6, SAFI_UNICAST); | |
9640 | return CMD_SUCCESS; | |
9641 | } | |
9642 | ||
5bf15956 DW |
9643 | DEFUN (show_bgp_updgrps_stats, |
9644 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 9645 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 9646 | SHOW_STR |
716b2d8a | 9647 | IP_STR |
3f9c7369 | 9648 | BGP_STR |
0c7b1b01 | 9649 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
9650 | "Statistics\n") |
9651 | { | |
9652 | struct bgp *bgp; | |
9653 | ||
9654 | bgp = bgp_get_default(); | |
9655 | if (bgp) | |
9656 | update_group_show_stats(bgp, vty); | |
9657 | ||
9658 | return CMD_SUCCESS; | |
9659 | } | |
9660 | ||
8386ac43 | 9661 | DEFUN (show_bgp_instance_updgrps_stats, |
9662 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 9663 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 9664 | SHOW_STR |
716b2d8a | 9665 | IP_STR |
8386ac43 | 9666 | BGP_STR |
9667 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 9668 | "Detailed info about dynamic update groups\n" |
8386ac43 | 9669 | "Statistics\n") |
9670 | { | |
c500ae40 | 9671 | int idx_word = 3; |
8386ac43 | 9672 | struct bgp *bgp; |
9673 | ||
c500ae40 | 9674 | bgp = bgp_lookup_by_name (argv[idx_word]->arg); |
8386ac43 | 9675 | if (bgp) |
9676 | update_group_show_stats(bgp, vty); | |
9677 | ||
9678 | return CMD_SUCCESS; | |
9679 | } | |
9680 | ||
3f9c7369 | 9681 | static void |
8386ac43 | 9682 | show_bgp_updgrps_adj_info_aux (struct vty *vty, const char *name, |
9683 | afi_t afi, safi_t safi, | |
f43e655e | 9684 | const char *what, uint64_t subgrp_id) |
3f9c7369 DS |
9685 | { |
9686 | struct bgp *bgp; | |
8386ac43 | 9687 | |
9688 | if (name) | |
9689 | bgp = bgp_lookup_by_name (name); | |
9690 | else | |
9691 | bgp = bgp_get_default (); | |
9692 | ||
3f9c7369 DS |
9693 | if (bgp) |
9694 | { | |
9695 | if (!strcmp(what, "advertise-queue")) | |
9696 | update_group_show_adj_queue(bgp, afi, safi, vty, subgrp_id); | |
9697 | else if (!strcmp(what, "advertised-routes")) | |
9698 | update_group_show_advertised(bgp, afi, safi, vty, subgrp_id); | |
9699 | else if (!strcmp(what, "packet-queue")) | |
9700 | update_group_show_packet_queue(bgp, afi, safi, vty, subgrp_id); | |
9701 | } | |
9702 | } | |
9703 | ||
9704 | DEFUN (show_ip_bgp_updgrps_adj, | |
9705 | show_ip_bgp_updgrps_adj_cmd, | |
716b2d8a | 9706 | "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 DS |
9707 | SHOW_STR |
9708 | IP_STR | |
9709 | BGP_STR | |
0c7b1b01 | 9710 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
9711 | "Advertisement queue\n" |
9712 | "Announced routes\n" | |
9713 | "Packet queue\n") | |
8fe8a7f6 | 9714 | |
3f9c7369 | 9715 | { |
c500ae40 DW |
9716 | int idx_type = 4; |
9717 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
8386ac43 | 9718 | return CMD_SUCCESS; |
9719 | } | |
9720 | ||
9721 | DEFUN (show_ip_bgp_instance_updgrps_adj, | |
9722 | show_ip_bgp_instance_updgrps_adj_cmd, | |
18c57037 | 9723 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 9724 | SHOW_STR |
9725 | IP_STR | |
9726 | BGP_STR | |
9727 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 9728 | "Detailed info about dynamic update groups\n" |
8386ac43 | 9729 | "Advertisement queue\n" |
9730 | "Announced routes\n" | |
9731 | "Packet queue\n") | |
9732 | ||
9733 | { | |
c500ae40 DW |
9734 | int idx_word = 4; |
9735 | int idx_type = 6; | |
9736 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
3f9c7369 DS |
9737 | return CMD_SUCCESS; |
9738 | } | |
9739 | ||
9740 | DEFUN (show_bgp_updgrps_afi_adj, | |
9741 | show_bgp_updgrps_afi_adj_cmd, | |
46f296b4 | 9742 | "show [ip] bgp "BGP_AFI_SAFI_CMD_STR" update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 9743 | SHOW_STR |
716b2d8a | 9744 | IP_STR |
3f9c7369 | 9745 | BGP_STR |
46f296b4 | 9746 | BGP_AFI_SAFI_HELP_STR |
0c7b1b01 | 9747 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
9748 | "Advertisement queue\n" |
9749 | "Announced routes\n" | |
8fe8a7f6 DS |
9750 | "Packet queue\n" |
9751 | "Specific subgroup info wanted for\n") | |
3f9c7369 | 9752 | { |
c500ae40 DW |
9753 | int idx_afi = 2; |
9754 | int idx_safi = 3; | |
9755 | int idx_type = 5; | |
46f296b4 LB |
9756 | show_bgp_updgrps_adj_info_aux(vty, NULL, |
9757 | bgp_vty_afi_from_arg(argv[idx_afi]->arg), | |
9758 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), | |
9759 | argv[idx_type]->arg, 0); | |
8fe8a7f6 | 9760 | return CMD_SUCCESS; |
3f9c7369 DS |
9761 | } |
9762 | ||
9763 | DEFUN (show_bgp_updgrps_adj, | |
9764 | show_bgp_updgrps_adj_cmd, | |
716b2d8a | 9765 | "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 9766 | SHOW_STR |
716b2d8a | 9767 | IP_STR |
3f9c7369 | 9768 | BGP_STR |
0c7b1b01 | 9769 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
9770 | "Advertisement queue\n" |
9771 | "Announced routes\n" | |
9772 | "Packet queue\n") | |
9773 | { | |
c500ae40 DW |
9774 | int idx_type = 3; |
9775 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
8386ac43 | 9776 | return CMD_SUCCESS; |
9777 | } | |
9778 | ||
9779 | DEFUN (show_bgp_instance_updgrps_adj, | |
9780 | show_bgp_instance_updgrps_adj_cmd, | |
18c57037 | 9781 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 9782 | SHOW_STR |
716b2d8a | 9783 | IP_STR |
8386ac43 | 9784 | BGP_STR |
9785 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 9786 | "Detailed info about dynamic update groups\n" |
8386ac43 | 9787 | "Advertisement queue\n" |
9788 | "Announced routes\n" | |
9789 | "Packet queue\n") | |
9790 | { | |
c500ae40 DW |
9791 | int idx_word = 3; |
9792 | int idx_type = 5; | |
9793 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
3f9c7369 DS |
9794 | return CMD_SUCCESS; |
9795 | } | |
9796 | ||
9797 | DEFUN (show_ip_bgp_updgrps_adj_s, | |
8fe8a7f6 | 9798 | show_ip_bgp_updgrps_adj_s_cmd, |
716b2d8a | 9799 | "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 DS |
9800 | SHOW_STR |
9801 | IP_STR | |
9802 | BGP_STR | |
0c7b1b01 | 9803 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 | 9804 | "Specific subgroup to display info for\n" |
3f9c7369 DS |
9805 | "Advertisement queue\n" |
9806 | "Announced routes\n" | |
9807 | "Packet queue\n") | |
3f9c7369 | 9808 | |
3f9c7369 | 9809 | { |
5bf15956 | 9810 | int idx_subgroup_id = 4; |
c500ae40 | 9811 | int idx_type = 5; |
f43e655e | 9812 | uint64_t subgrp_id; |
8fe8a7f6 | 9813 | |
5bf15956 | 9814 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8fe8a7f6 | 9815 | |
5bf15956 | 9816 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
8386ac43 | 9817 | return CMD_SUCCESS; |
9818 | } | |
9819 | ||
9820 | DEFUN (show_ip_bgp_instance_updgrps_adj_s, | |
9821 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
18c57037 | 9822 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 9823 | SHOW_STR |
9824 | IP_STR | |
9825 | BGP_STR | |
9826 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 9827 | "Detailed info about dynamic update groups\n" |
8386ac43 | 9828 | "Specific subgroup to display info for\n" |
9829 | "Advertisement queue\n" | |
9830 | "Announced routes\n" | |
9831 | "Packet queue\n") | |
9832 | ||
9833 | { | |
5bf15956 DW |
9834 | int idx_vrf = 4; |
9835 | int idx_subgroup_id = 6; | |
c500ae40 | 9836 | int idx_type = 7; |
f43e655e | 9837 | uint64_t subgrp_id; |
8386ac43 | 9838 | |
5bf15956 | 9839 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8386ac43 | 9840 | |
5bf15956 | 9841 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
3f9c7369 DS |
9842 | return CMD_SUCCESS; |
9843 | } | |
9844 | ||
8fe8a7f6 DS |
9845 | DEFUN (show_bgp_updgrps_afi_adj_s, |
9846 | show_bgp_updgrps_afi_adj_s_cmd, | |
46f296b4 | 9847 | "show [ip] bgp "BGP_AFI_SAFI_CMD_STR" update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 9848 | SHOW_STR |
716b2d8a | 9849 | IP_STR |
3f9c7369 | 9850 | BGP_STR |
46f296b4 | 9851 | BGP_AFI_SAFI_HELP_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" | |
8fe8a7f6 DS |
9856 | "Packet queue\n" |
9857 | "Specific subgroup info wanted for\n") | |
3f9c7369 | 9858 | { |
c500ae40 DW |
9859 | int idx_afi = 2; |
9860 | int idx_safi = 3; | |
5bf15956 | 9861 | int idx_subgroup_id = 5; |
c500ae40 | 9862 | int idx_type = 6; |
f43e655e | 9863 | uint64_t subgrp_id; |
3f9c7369 | 9864 | |
5bf15956 | 9865 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8fe8a7f6 | 9866 | |
46f296b4 LB |
9867 | show_bgp_updgrps_adj_info_aux(vty, NULL, |
9868 | bgp_vty_afi_from_arg(argv[idx_afi]->arg), | |
9869 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), | |
9870 | argv[idx_type]->arg, subgrp_id); | |
8fe8a7f6 | 9871 | return CMD_SUCCESS; |
3f9c7369 DS |
9872 | } |
9873 | ||
8fe8a7f6 DS |
9874 | DEFUN (show_bgp_updgrps_adj_s, |
9875 | show_bgp_updgrps_adj_s_cmd, | |
716b2d8a | 9876 | "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8fe8a7f6 | 9877 | SHOW_STR |
716b2d8a | 9878 | IP_STR |
8fe8a7f6 | 9879 | BGP_STR |
0c7b1b01 | 9880 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 DS |
9881 | "Specific subgroup to display info for\n" |
9882 | "Advertisement queue\n" | |
9883 | "Announced routes\n" | |
9884 | "Packet queue\n") | |
9885 | { | |
5bf15956 | 9886 | int idx_subgroup_id = 3; |
c500ae40 | 9887 | int idx_type = 4; |
f43e655e | 9888 | uint64_t subgrp_id; |
8fe8a7f6 | 9889 | |
5bf15956 | 9890 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8fe8a7f6 | 9891 | |
5bf15956 | 9892 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
8fe8a7f6 DS |
9893 | return CMD_SUCCESS; |
9894 | } | |
9895 | ||
8386ac43 | 9896 | DEFUN (show_bgp_instance_updgrps_adj_s, |
9897 | show_bgp_instance_updgrps_adj_s_cmd, | |
18c57037 | 9898 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 9899 | SHOW_STR |
716b2d8a | 9900 | IP_STR |
8386ac43 | 9901 | BGP_STR |
9902 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 9903 | "Detailed info about dynamic update groups\n" |
8386ac43 | 9904 | "Specific subgroup to display info for\n" |
9905 | "Advertisement queue\n" | |
9906 | "Announced routes\n" | |
9907 | "Packet queue\n") | |
9908 | { | |
5bf15956 DW |
9909 | int idx_vrf = 3; |
9910 | int idx_subgroup_id = 5; | |
c500ae40 | 9911 | int idx_type = 6; |
f43e655e | 9912 | uint64_t subgrp_id; |
8386ac43 | 9913 | |
5bf15956 | 9914 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8386ac43 | 9915 | |
5bf15956 | 9916 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
8386ac43 | 9917 | return CMD_SUCCESS; |
9918 | } | |
9919 | ||
9920 | ||
8fe8a7f6 | 9921 | |
f14e6fdb DS |
9922 | static int |
9923 | bgp_show_one_peer_group (struct vty *vty, struct peer_group *group) | |
9924 | { | |
9925 | struct listnode *node, *nnode; | |
9926 | struct prefix *range; | |
9927 | struct peer *conf; | |
9928 | struct peer *peer; | |
4690c7d7 | 9929 | char buf[PREFIX2STR_BUFFER]; |
f14e6fdb DS |
9930 | afi_t afi; |
9931 | safi_t safi; | |
ffd0c037 DS |
9932 | const char *peer_status; |
9933 | const char *af_str; | |
f14e6fdb DS |
9934 | int lr_count; |
9935 | int dynamic; | |
9936 | int af_cfgd; | |
9937 | ||
9938 | conf = group->conf; | |
9939 | ||
0299c004 DS |
9940 | if (conf->as_type == AS_SPECIFIED || |
9941 | conf->as_type == AS_EXTERNAL) { | |
66b199b2 | 9942 | vty_out (vty, "%sBGP peer-group %s, remote AS %d%s", |
f14e6fdb | 9943 | VTY_NEWLINE, group->name, conf->as, VTY_NEWLINE); |
0299c004 | 9944 | } else if (conf->as_type == AS_INTERNAL) { |
66b199b2 | 9945 | vty_out (vty, "%sBGP peer-group %s, remote AS %d%s", |
0299c004 | 9946 | VTY_NEWLINE, group->name, group->bgp->as, VTY_NEWLINE); |
66b199b2 DS |
9947 | } else { |
9948 | vty_out (vty, "%sBGP peer-group %s%s", | |
9949 | VTY_NEWLINE, group->name, VTY_NEWLINE); | |
0299c004 | 9950 | } |
f14e6fdb | 9951 | |
0299c004 | 9952 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
f14e6fdb DS |
9953 | vty_out (vty, " Peer-group type is internal%s", VTY_NEWLINE); |
9954 | else | |
9955 | vty_out (vty, " Peer-group type is external%s", VTY_NEWLINE); | |
9956 | ||
9957 | /* Display AFs configured. */ | |
9958 | vty_out (vty, " Configured address-families:"); | |
9959 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
9960 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
9961 | { | |
9962 | if (conf->afc[afi][safi]) | |
9963 | { | |
9964 | af_cfgd = 1; | |
9965 | vty_out (vty, " %s;", afi_safi_print(afi, safi)); | |
9966 | } | |
9967 | } | |
9968 | if (!af_cfgd) | |
9969 | vty_out (vty, " none%s", VTY_NEWLINE); | |
9970 | else | |
9971 | vty_out (vty, "%s", VTY_NEWLINE); | |
9972 | ||
9973 | /* Display listen ranges (for dynamic neighbors), if any */ | |
9974 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
9975 | { | |
9976 | if (afi == AFI_IP) | |
9977 | af_str = "IPv4"; | |
9978 | else if (afi == AFI_IP6) | |
9979 | af_str = "IPv6"; | |
45ef4300 DL |
9980 | else |
9981 | af_str = "???"; | |
f14e6fdb DS |
9982 | lr_count = listcount(group->listen_range[afi]); |
9983 | if (lr_count) | |
9984 | { | |
9985 | vty_out(vty, | |
9986 | " %d %s listen range(s)%s", | |
9987 | lr_count, af_str, VTY_NEWLINE); | |
9988 | ||
9989 | ||
9990 | for (ALL_LIST_ELEMENTS (group->listen_range[afi], node, | |
9991 | nnode, range)) | |
9992 | { | |
9993 | prefix2str(range, buf, sizeof(buf)); | |
9994 | vty_out(vty, " %s%s", buf, VTY_NEWLINE); | |
9995 | } | |
9996 | } | |
9997 | } | |
9998 | ||
9999 | /* Display group members and their status */ | |
10000 | if (listcount(group->peer)) | |
10001 | { | |
10002 | vty_out (vty, " Peer-group members:%s", VTY_NEWLINE); | |
10003 | for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) | |
10004 | { | |
10005 | if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) | |
10006 | peer_status = "Idle (Admin)"; | |
10007 | else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) | |
10008 | peer_status = "Idle (PfxCt)"; | |
10009 | else | |
56b40679 | 10010 | peer_status = lookup_msg(bgp_status_msg, peer->status, NULL); |
f14e6fdb DS |
10011 | |
10012 | dynamic = peer_dynamic_neighbor(peer); | |
10013 | vty_out (vty, " %s %s %s %s", | |
10014 | peer->host, dynamic ? "(dynamic)" : "", | |
10015 | peer_status, VTY_NEWLINE); | |
10016 | } | |
10017 | } | |
10018 | ||
10019 | return CMD_SUCCESS; | |
10020 | } | |
10021 | ||
10022 | /* Show BGP peer group's information. */ | |
10023 | enum show_group_type | |
10024 | { | |
10025 | show_all_groups, | |
10026 | show_peer_group | |
10027 | }; | |
10028 | ||
10029 | static int | |
10030 | bgp_show_peer_group (struct vty *vty, struct bgp *bgp, | |
10031 | enum show_group_type type, const char *group_name) | |
10032 | { | |
10033 | struct listnode *node, *nnode; | |
10034 | struct peer_group *group; | |
10035 | int find = 0; | |
10036 | ||
10037 | for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) | |
10038 | { | |
10039 | switch (type) | |
10040 | { | |
10041 | case show_all_groups: | |
10042 | bgp_show_one_peer_group (vty, group); | |
10043 | break; | |
10044 | case show_peer_group: | |
10045 | if (group_name && (strcmp(group->name, group_name) == 0)) | |
10046 | { | |
10047 | find = 1; | |
10048 | bgp_show_one_peer_group (vty, group); | |
10049 | } | |
10050 | break; | |
10051 | } | |
10052 | } | |
10053 | ||
10054 | if (type == show_peer_group && ! find) | |
6d9e66dc | 10055 | vty_out (vty, "%% No such peer-group%s", VTY_NEWLINE); |
f14e6fdb DS |
10056 | |
10057 | return CMD_SUCCESS; | |
10058 | } | |
10059 | ||
10060 | static int | |
10061 | bgp_show_peer_group_vty (struct vty *vty, const char *name, | |
10062 | enum show_group_type type, const char *group_name) | |
10063 | { | |
10064 | struct bgp *bgp; | |
10065 | int ret = CMD_SUCCESS; | |
10066 | ||
10067 | if (name) | |
8386ac43 | 10068 | bgp = bgp_lookup_by_name (name); |
10069 | else | |
10070 | bgp = bgp_get_default (); | |
f14e6fdb | 10071 | |
8386ac43 | 10072 | if (! bgp) |
10073 | { | |
10074 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
10075 | return CMD_WARNING; | |
f14e6fdb DS |
10076 | } |
10077 | ||
8386ac43 | 10078 | ret = bgp_show_peer_group (vty, bgp, type, group_name); |
f14e6fdb DS |
10079 | |
10080 | return ret; | |
10081 | } | |
10082 | ||
10083 | DEFUN (show_ip_bgp_peer_groups, | |
10084 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 10085 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
10086 | SHOW_STR |
10087 | IP_STR | |
10088 | BGP_STR | |
8386ac43 | 10089 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
10090 | "Detailed information on BGP peer groups\n" |
10091 | "Peer group name\n") | |
f14e6fdb | 10092 | { |
d6e3c605 QY |
10093 | char *vrf, *pg; |
10094 | vrf = pg = NULL; | |
10095 | int idx = 0; | |
f14e6fdb | 10096 | |
f2a8972b | 10097 | vrf = argv_find (argv, argc, "WORD", &idx) ? argv[idx]->arg : NULL; |
d6e3c605 | 10098 | pg = argv_find (argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 10099 | |
d6e3c605 | 10100 | return bgp_show_peer_group_vty (vty, vrf, show_all_groups, pg); |
f14e6fdb | 10101 | } |
3f9c7369 | 10102 | |
d6e3c605 | 10103 | |
718e3744 | 10104 | /* Redistribute VTY commands. */ |
10105 | ||
718e3744 | 10106 | DEFUN (bgp_redistribute_ipv4, |
10107 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 10108 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 10109 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10110 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 10111 | { |
cdc2d765 | 10112 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 10113 | int idx_protocol = 1; |
718e3744 | 10114 | int type; |
10115 | ||
6d681bd8 QY |
10116 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
10117 | if (type < 0) | |
718e3744 | 10118 | { |
10119 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
10120 | return CMD_WARNING; | |
10121 | } | |
cdc2d765 DL |
10122 | bgp_redist_add(bgp, AFI_IP, type, 0); |
10123 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); | |
718e3744 | 10124 | } |
10125 | ||
596c17ba DW |
10126 | ALIAS_HIDDEN (bgp_redistribute_ipv4, |
10127 | bgp_redistribute_ipv4_hidden_cmd, | |
10128 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
10129 | "Redistribute information from another routing protocol\n" | |
10130 | FRR_IP_REDIST_HELP_STR_BGPD) | |
10131 | ||
718e3744 | 10132 | DEFUN (bgp_redistribute_ipv4_rmap, |
10133 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 10134 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 10135 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10136 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 10137 | "Route map reference\n" |
10138 | "Pointer to route-map entries\n") | |
10139 | { | |
cdc2d765 | 10140 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
10141 | int idx_protocol = 1; |
10142 | int idx_word = 3; | |
718e3744 | 10143 | int type; |
7c8ff89e | 10144 | struct bgp_redist *red; |
718e3744 | 10145 | |
6d681bd8 QY |
10146 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
10147 | if (type < 0) | |
718e3744 | 10148 | { |
10149 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
10150 | return CMD_WARNING; | |
10151 | } | |
10152 | ||
cdc2d765 | 10153 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
c500ae40 | 10154 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 10155 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); |
718e3744 | 10156 | } |
10157 | ||
596c17ba DW |
10158 | ALIAS_HIDDEN (bgp_redistribute_ipv4_rmap, |
10159 | bgp_redistribute_ipv4_rmap_hidden_cmd, | |
10160 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
10161 | "Redistribute information from another routing protocol\n" | |
10162 | FRR_IP_REDIST_HELP_STR_BGPD | |
10163 | "Route map reference\n" | |
10164 | "Pointer to route-map entries\n") | |
10165 | ||
718e3744 | 10166 | DEFUN (bgp_redistribute_ipv4_metric, |
10167 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 10168 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 10169 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10170 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 10171 | "Metric for redistributed routes\n" |
10172 | "Default metric\n") | |
10173 | { | |
cdc2d765 | 10174 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
10175 | int idx_protocol = 1; |
10176 | int idx_number = 3; | |
718e3744 | 10177 | int type; |
10178 | u_int32_t metric; | |
7c8ff89e | 10179 | struct bgp_redist *red; |
718e3744 | 10180 | |
6d681bd8 QY |
10181 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
10182 | if (type < 0) | |
718e3744 | 10183 | { |
10184 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
10185 | return CMD_WARNING; | |
10186 | } | |
c500ae40 | 10187 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 10188 | |
cdc2d765 DL |
10189 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
10190 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
10191 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); | |
718e3744 | 10192 | } |
10193 | ||
596c17ba DW |
10194 | ALIAS_HIDDEN (bgp_redistribute_ipv4_metric, |
10195 | bgp_redistribute_ipv4_metric_hidden_cmd, | |
10196 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
10197 | "Redistribute information from another routing protocol\n" | |
10198 | FRR_IP_REDIST_HELP_STR_BGPD | |
10199 | "Metric for redistributed routes\n" | |
10200 | "Default metric\n") | |
10201 | ||
718e3744 | 10202 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
10203 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 10204 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 10205 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10206 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 10207 | "Route map reference\n" |
10208 | "Pointer to route-map entries\n" | |
10209 | "Metric for redistributed routes\n" | |
10210 | "Default metric\n") | |
10211 | { | |
cdc2d765 | 10212 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
10213 | int idx_protocol = 1; |
10214 | int idx_word = 3; | |
10215 | int idx_number = 5; | |
718e3744 | 10216 | int type; |
10217 | u_int32_t metric; | |
7c8ff89e | 10218 | struct bgp_redist *red; |
718e3744 | 10219 | |
6d681bd8 QY |
10220 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
10221 | if (type < 0) | |
718e3744 | 10222 | { |
10223 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
10224 | return CMD_WARNING; | |
10225 | } | |
c500ae40 | 10226 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 10227 | |
cdc2d765 | 10228 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
c500ae40 | 10229 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 DL |
10230 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
10231 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); | |
718e3744 | 10232 | } |
10233 | ||
596c17ba DW |
10234 | ALIAS_HIDDEN (bgp_redistribute_ipv4_rmap_metric, |
10235 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
10236 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", | |
10237 | "Redistribute information from another routing protocol\n" | |
10238 | FRR_IP_REDIST_HELP_STR_BGPD | |
10239 | "Route map reference\n" | |
10240 | "Pointer to route-map entries\n" | |
10241 | "Metric for redistributed routes\n" | |
10242 | "Default metric\n") | |
10243 | ||
718e3744 | 10244 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
10245 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 10246 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 10247 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10248 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 10249 | "Metric for redistributed routes\n" |
10250 | "Default metric\n" | |
10251 | "Route map reference\n" | |
10252 | "Pointer to route-map entries\n") | |
10253 | { | |
cdc2d765 | 10254 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
10255 | int idx_protocol = 1; |
10256 | int idx_number = 3; | |
10257 | int idx_word = 5; | |
718e3744 | 10258 | int type; |
10259 | u_int32_t metric; | |
7c8ff89e | 10260 | struct bgp_redist *red; |
718e3744 | 10261 | |
6d681bd8 QY |
10262 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
10263 | if (type < 0) | |
718e3744 | 10264 | { |
10265 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
10266 | return CMD_WARNING; | |
10267 | } | |
c500ae40 | 10268 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 10269 | |
cdc2d765 DL |
10270 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
10271 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
c500ae40 | 10272 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 10273 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); |
718e3744 | 10274 | } |
10275 | ||
596c17ba DW |
10276 | ALIAS_HIDDEN (bgp_redistribute_ipv4_metric_rmap, |
10277 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
10278 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", | |
10279 | "Redistribute information from another routing protocol\n" | |
10280 | FRR_IP_REDIST_HELP_STR_BGPD | |
10281 | "Metric for redistributed routes\n" | |
10282 | "Default metric\n" | |
10283 | "Route map reference\n" | |
10284 | "Pointer to route-map entries\n") | |
10285 | ||
7c8ff89e DS |
10286 | DEFUN (bgp_redistribute_ipv4_ospf, |
10287 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 10288 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
10289 | "Redistribute information from another routing protocol\n" |
10290 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
10291 | "Non-main Kernel Routing Table\n" |
10292 | "Instance ID/Table ID\n") | |
7c8ff89e | 10293 | { |
cdc2d765 | 10294 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
10295 | int idx_ospf_table = 1; |
10296 | int idx_number = 2; | |
7c8ff89e | 10297 | u_short instance; |
7a4bb9c5 | 10298 | u_short protocol; |
7c8ff89e | 10299 | |
c500ae40 | 10300 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
7a4bb9c5 | 10301 | |
c500ae40 | 10302 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
10303 | protocol = ZEBRA_ROUTE_OSPF; |
10304 | else | |
10305 | protocol = ZEBRA_ROUTE_TABLE; | |
10306 | ||
cdc2d765 DL |
10307 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
10308 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
10309 | } |
10310 | ||
596c17ba DW |
10311 | ALIAS_HIDDEN (bgp_redistribute_ipv4_ospf, |
10312 | bgp_redistribute_ipv4_ospf_hidden_cmd, | |
10313 | "redistribute <ospf|table> (1-65535)", | |
10314 | "Redistribute information from another routing protocol\n" | |
10315 | "Open Shortest Path First (OSPFv2)\n" | |
10316 | "Non-main Kernel Routing Table\n" | |
10317 | "Instance ID/Table ID\n") | |
10318 | ||
7c8ff89e DS |
10319 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
10320 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 10321 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
10322 | "Redistribute information from another routing protocol\n" |
10323 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
10324 | "Non-main Kernel Routing Table\n" |
10325 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
10326 | "Route map reference\n" |
10327 | "Pointer to route-map entries\n") | |
10328 | { | |
cdc2d765 | 10329 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
10330 | int idx_ospf_table = 1; |
10331 | int idx_number = 2; | |
10332 | int idx_word = 4; | |
7c8ff89e DS |
10333 | struct bgp_redist *red; |
10334 | u_short instance; | |
7a4bb9c5 | 10335 | int protocol; |
7c8ff89e | 10336 | |
c500ae40 | 10337 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
10338 | protocol = ZEBRA_ROUTE_OSPF; |
10339 | else | |
10340 | protocol = ZEBRA_ROUTE_TABLE; | |
10341 | ||
c500ae40 | 10342 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
cdc2d765 | 10343 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
c500ae40 | 10344 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 10345 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); |
7c8ff89e DS |
10346 | } |
10347 | ||
596c17ba DW |
10348 | ALIAS_HIDDEN (bgp_redistribute_ipv4_ospf_rmap, |
10349 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
10350 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
10351 | "Redistribute information from another routing protocol\n" | |
10352 | "Open Shortest Path First (OSPFv2)\n" | |
10353 | "Non-main Kernel Routing Table\n" | |
10354 | "Instance ID/Table ID\n" | |
10355 | "Route map reference\n" | |
10356 | "Pointer to route-map entries\n") | |
10357 | ||
7c8ff89e DS |
10358 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
10359 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 10360 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
10361 | "Redistribute information from another routing protocol\n" |
10362 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
10363 | "Non-main Kernel Routing Table\n" |
10364 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
10365 | "Metric for redistributed routes\n" |
10366 | "Default metric\n") | |
10367 | { | |
cdc2d765 | 10368 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
10369 | int idx_ospf_table = 1; |
10370 | int idx_number = 2; | |
10371 | int idx_number_2 = 4; | |
7c8ff89e DS |
10372 | u_int32_t metric; |
10373 | struct bgp_redist *red; | |
10374 | u_short instance; | |
7a4bb9c5 | 10375 | int protocol; |
7c8ff89e | 10376 | |
c500ae40 | 10377 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
10378 | protocol = ZEBRA_ROUTE_OSPF; |
10379 | else | |
10380 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 10381 | |
c500ae40 DW |
10382 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
10383 | VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); | |
7a4bb9c5 | 10384 | |
cdc2d765 DL |
10385 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
10386 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
10387 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
10388 | } |
10389 | ||
596c17ba DW |
10390 | ALIAS_HIDDEN (bgp_redistribute_ipv4_ospf_metric, |
10391 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
10392 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
10393 | "Redistribute information from another routing protocol\n" | |
10394 | "Open Shortest Path First (OSPFv2)\n" | |
10395 | "Non-main Kernel Routing Table\n" | |
10396 | "Instance ID/Table ID\n" | |
10397 | "Metric for redistributed routes\n" | |
10398 | "Default metric\n") | |
10399 | ||
7c8ff89e DS |
10400 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
10401 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 10402 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
10403 | "Redistribute information from another routing protocol\n" |
10404 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
10405 | "Non-main Kernel Routing Table\n" |
10406 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
10407 | "Route map reference\n" |
10408 | "Pointer to route-map entries\n" | |
10409 | "Metric for redistributed routes\n" | |
10410 | "Default metric\n") | |
10411 | { | |
cdc2d765 | 10412 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
10413 | int idx_ospf_table = 1; |
10414 | int idx_number = 2; | |
10415 | int idx_word = 4; | |
10416 | int idx_number_2 = 6; | |
7c8ff89e DS |
10417 | u_int32_t metric; |
10418 | struct bgp_redist *red; | |
10419 | u_short instance; | |
7a4bb9c5 | 10420 | int protocol; |
7c8ff89e | 10421 | |
c500ae40 | 10422 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
10423 | protocol = ZEBRA_ROUTE_OSPF; |
10424 | else | |
10425 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 10426 | |
c500ae40 DW |
10427 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
10428 | VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); | |
7a4bb9c5 | 10429 | |
cdc2d765 | 10430 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
c500ae40 | 10431 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 DL |
10432 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); |
10433 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
10434 | } |
10435 | ||
596c17ba DW |
10436 | ALIAS_HIDDEN (bgp_redistribute_ipv4_ospf_rmap_metric, |
10437 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
10438 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
10439 | "Redistribute information from another routing protocol\n" | |
10440 | "Open Shortest Path First (OSPFv2)\n" | |
10441 | "Non-main Kernel Routing Table\n" | |
10442 | "Instance ID/Table ID\n" | |
10443 | "Route map reference\n" | |
10444 | "Pointer to route-map entries\n" | |
10445 | "Metric for redistributed routes\n" | |
10446 | "Default metric\n") | |
10447 | ||
7c8ff89e DS |
10448 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
10449 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 10450 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
10451 | "Redistribute information from another routing protocol\n" |
10452 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
10453 | "Non-main Kernel Routing Table\n" |
10454 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
10455 | "Metric for redistributed routes\n" |
10456 | "Default metric\n" | |
10457 | "Route map reference\n" | |
10458 | "Pointer to route-map entries\n") | |
10459 | { | |
cdc2d765 | 10460 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
10461 | int idx_ospf_table = 1; |
10462 | int idx_number = 2; | |
10463 | int idx_number_2 = 4; | |
10464 | int idx_word = 6; | |
7c8ff89e DS |
10465 | u_int32_t metric; |
10466 | struct bgp_redist *red; | |
10467 | u_short instance; | |
7a4bb9c5 | 10468 | int protocol; |
7c8ff89e | 10469 | |
c500ae40 | 10470 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
10471 | protocol = ZEBRA_ROUTE_OSPF; |
10472 | else | |
10473 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 10474 | |
c500ae40 DW |
10475 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
10476 | VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); | |
7a4bb9c5 | 10477 | |
cdc2d765 DL |
10478 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
10479 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
c500ae40 | 10480 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 10481 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); |
7c8ff89e DS |
10482 | } |
10483 | ||
596c17ba DW |
10484 | ALIAS_HIDDEN (bgp_redistribute_ipv4_ospf_metric_rmap, |
10485 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
10486 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
10487 | "Redistribute information from another routing protocol\n" | |
10488 | "Open Shortest Path First (OSPFv2)\n" | |
10489 | "Non-main Kernel Routing Table\n" | |
10490 | "Instance ID/Table ID\n" | |
10491 | "Metric for redistributed routes\n" | |
10492 | "Default metric\n" | |
10493 | "Route map reference\n" | |
10494 | "Pointer to route-map entries\n") | |
10495 | ||
7c8ff89e DS |
10496 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
10497 | no_bgp_redistribute_ipv4_ospf_cmd, | |
d04c479d | 10498 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", |
7c8ff89e DS |
10499 | NO_STR |
10500 | "Redistribute information from another routing protocol\n" | |
10501 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 10502 | "Non-main Kernel Routing Table\n" |
31500417 DW |
10503 | "Instance ID/Table ID\n" |
10504 | "Metric for redistributed routes\n" | |
10505 | "Default metric\n" | |
10506 | "Route map reference\n" | |
10507 | "Pointer to route-map entries\n") | |
7c8ff89e | 10508 | { |
cdc2d765 | 10509 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
10510 | int idx_ospf_table = 2; |
10511 | int idx_number = 3; | |
7c8ff89e | 10512 | u_short instance; |
7a4bb9c5 DS |
10513 | int protocol; |
10514 | ||
c500ae40 | 10515 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
10516 | protocol = ZEBRA_ROUTE_OSPF; |
10517 | else | |
10518 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 10519 | |
c500ae40 | 10520 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
cdc2d765 | 10521 | return bgp_redistribute_unset (bgp, AFI_IP, protocol, instance); |
7c8ff89e DS |
10522 | } |
10523 | ||
596c17ba DW |
10524 | ALIAS_HIDDEN (no_bgp_redistribute_ipv4_ospf, |
10525 | no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
10526 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", | |
10527 | NO_STR | |
10528 | "Redistribute information from another routing protocol\n" | |
10529 | "Open Shortest Path First (OSPFv2)\n" | |
10530 | "Non-main Kernel Routing Table\n" | |
10531 | "Instance ID/Table ID\n" | |
10532 | "Metric for redistributed routes\n" | |
10533 | "Default metric\n" | |
10534 | "Route map reference\n" | |
10535 | "Pointer to route-map entries\n") | |
10536 | ||
718e3744 | 10537 | DEFUN (no_bgp_redistribute_ipv4, |
10538 | no_bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 10539 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 10540 | NO_STR |
10541 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 10542 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
10543 | "Metric for redistributed routes\n" |
10544 | "Default metric\n" | |
10545 | "Route map reference\n" | |
10546 | "Pointer to route-map entries\n") | |
718e3744 | 10547 | { |
cdc2d765 | 10548 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 10549 | int idx_protocol = 2; |
718e3744 | 10550 | int type; |
10551 | ||
6d681bd8 QY |
10552 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
10553 | if (type < 0) | |
718e3744 | 10554 | { |
10555 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
10556 | return CMD_WARNING; | |
10557 | } | |
cdc2d765 | 10558 | return bgp_redistribute_unset (bgp, AFI_IP, type, 0); |
718e3744 | 10559 | } |
10560 | ||
596c17ba DW |
10561 | ALIAS_HIDDEN (no_bgp_redistribute_ipv4, |
10562 | no_bgp_redistribute_ipv4_hidden_cmd, | |
10563 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", | |
10564 | NO_STR | |
10565 | "Redistribute information from another routing protocol\n" | |
10566 | FRR_IP_REDIST_HELP_STR_BGPD | |
10567 | "Metric for redistributed routes\n" | |
10568 | "Default metric\n" | |
10569 | "Route map reference\n" | |
10570 | "Pointer to route-map entries\n") | |
10571 | ||
718e3744 | 10572 | DEFUN (bgp_redistribute_ipv6, |
10573 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 10574 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 10575 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10576 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 10577 | { |
cdc2d765 | 10578 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 10579 | int idx_protocol = 1; |
718e3744 | 10580 | int type; |
10581 | ||
6d681bd8 QY |
10582 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
10583 | if (type < 0) | |
718e3744 | 10584 | { |
10585 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
10586 | return CMD_WARNING; | |
10587 | } | |
10588 | ||
cdc2d765 DL |
10589 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
10590 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); | |
718e3744 | 10591 | } |
10592 | ||
10593 | DEFUN (bgp_redistribute_ipv6_rmap, | |
10594 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 10595 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 10596 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10597 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 10598 | "Route map reference\n" |
10599 | "Pointer to route-map entries\n") | |
10600 | { | |
cdc2d765 | 10601 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
10602 | int idx_protocol = 1; |
10603 | int idx_word = 3; | |
718e3744 | 10604 | int type; |
7c8ff89e | 10605 | struct bgp_redist *red; |
718e3744 | 10606 | |
6d681bd8 QY |
10607 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
10608 | if (type < 0) | |
718e3744 | 10609 | { |
10610 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
10611 | return CMD_WARNING; | |
10612 | } | |
10613 | ||
cdc2d765 | 10614 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
c500ae40 | 10615 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 10616 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); |
718e3744 | 10617 | } |
10618 | ||
10619 | DEFUN (bgp_redistribute_ipv6_metric, | |
10620 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 10621 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 10622 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10623 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 10624 | "Metric for redistributed routes\n" |
10625 | "Default metric\n") | |
10626 | { | |
cdc2d765 | 10627 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
10628 | int idx_protocol = 1; |
10629 | int idx_number = 3; | |
718e3744 | 10630 | int type; |
10631 | u_int32_t metric; | |
7c8ff89e | 10632 | struct bgp_redist *red; |
718e3744 | 10633 | |
6d681bd8 QY |
10634 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
10635 | if (type < 0) | |
718e3744 | 10636 | { |
10637 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
10638 | return CMD_WARNING; | |
10639 | } | |
c500ae40 | 10640 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 10641 | |
cdc2d765 DL |
10642 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
10643 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
10644 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); | |
718e3744 | 10645 | } |
10646 | ||
10647 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
10648 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 10649 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 10650 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10651 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 10652 | "Route map reference\n" |
10653 | "Pointer to route-map entries\n" | |
10654 | "Metric for redistributed routes\n" | |
10655 | "Default metric\n") | |
10656 | { | |
cdc2d765 | 10657 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
10658 | int idx_protocol = 1; |
10659 | int idx_word = 3; | |
10660 | int idx_number = 5; | |
718e3744 | 10661 | int type; |
10662 | u_int32_t metric; | |
7c8ff89e | 10663 | struct bgp_redist *red; |
718e3744 | 10664 | |
6d681bd8 QY |
10665 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
10666 | if (type < 0) | |
718e3744 | 10667 | { |
10668 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
10669 | return CMD_WARNING; | |
10670 | } | |
c500ae40 | 10671 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 10672 | |
cdc2d765 | 10673 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
c500ae40 | 10674 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 DL |
10675 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); |
10676 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); | |
718e3744 | 10677 | } |
10678 | ||
10679 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
10680 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 10681 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 10682 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10683 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 10684 | "Metric for redistributed routes\n" |
10685 | "Default metric\n" | |
10686 | "Route map reference\n" | |
10687 | "Pointer to route-map entries\n") | |
10688 | { | |
cdc2d765 | 10689 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
10690 | int idx_protocol = 1; |
10691 | int idx_number = 3; | |
10692 | int idx_word = 5; | |
718e3744 | 10693 | int type; |
10694 | u_int32_t metric; | |
7c8ff89e | 10695 | struct bgp_redist *red; |
718e3744 | 10696 | |
6d681bd8 QY |
10697 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
10698 | if (type < 0) | |
718e3744 | 10699 | { |
10700 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
10701 | return CMD_WARNING; | |
10702 | } | |
c500ae40 | 10703 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 10704 | |
cdc2d765 DL |
10705 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
10706 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, metric); | |
c500ae40 | 10707 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 10708 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); |
718e3744 | 10709 | } |
10710 | ||
10711 | DEFUN (no_bgp_redistribute_ipv6, | |
10712 | no_bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 10713 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 10714 | NO_STR |
10715 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 10716 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
10717 | "Metric for redistributed routes\n" |
10718 | "Default metric\n" | |
10719 | "Route map reference\n" | |
10720 | "Pointer to route-map entries\n") | |
718e3744 | 10721 | { |
cdc2d765 | 10722 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 10723 | int idx_protocol = 2; |
718e3744 | 10724 | int type; |
10725 | ||
6d681bd8 QY |
10726 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
10727 | if (type < 0) | |
718e3744 | 10728 | { |
10729 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
10730 | return CMD_WARNING; | |
10731 | } | |
10732 | ||
cdc2d765 | 10733 | return bgp_redistribute_unset (bgp, AFI_IP6, type, 0); |
718e3744 | 10734 | } |
6b0655a2 | 10735 | |
718e3744 | 10736 | int |
10737 | bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi, | |
10738 | safi_t safi, int *write) | |
10739 | { | |
10740 | int i; | |
718e3744 | 10741 | |
10742 | /* Unicast redistribution only. */ | |
10743 | if (safi != SAFI_UNICAST) | |
10744 | return 0; | |
10745 | ||
10746 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) | |
10747 | { | |
10748 | /* Redistribute BGP does not make sense. */ | |
7c8ff89e | 10749 | if (i != ZEBRA_ROUTE_BGP) |
718e3744 | 10750 | { |
7c8ff89e DS |
10751 | struct list *red_list; |
10752 | struct listnode *node; | |
10753 | struct bgp_redist *red; | |
718e3744 | 10754 | |
7c8ff89e DS |
10755 | red_list = bgp->redist[afi][i]; |
10756 | if (!red_list) | |
10757 | continue; | |
718e3744 | 10758 | |
7c8ff89e DS |
10759 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) |
10760 | { | |
10761 | /* Display "address-family" when it is not yet diplayed. */ | |
10762 | bgp_config_write_family_header (vty, afi, safi, write); | |
10763 | ||
10764 | /* "redistribute" configuration. */ | |
0b960b4d | 10765 | vty_out (vty, " redistribute %s", zebra_route_string(i)); |
7c8ff89e DS |
10766 | if (red->instance) |
10767 | vty_out (vty, " %d", red->instance); | |
10768 | if (red->redist_metric_flag) | |
10769 | vty_out (vty, " metric %u", red->redist_metric); | |
10770 | if (red->rmap.name) | |
10771 | vty_out (vty, " route-map %s", red->rmap.name); | |
10772 | vty_out (vty, "%s", VTY_NEWLINE); | |
10773 | } | |
718e3744 | 10774 | } |
10775 | } | |
10776 | return *write; | |
10777 | } | |
6b0655a2 | 10778 | |
718e3744 | 10779 | /* BGP node structure. */ |
7fc626de | 10780 | static struct cmd_node bgp_node = |
718e3744 | 10781 | { |
10782 | BGP_NODE, | |
10783 | "%s(config-router)# ", | |
10784 | 1, | |
10785 | }; | |
10786 | ||
7fc626de | 10787 | static struct cmd_node bgp_ipv4_unicast_node = |
718e3744 | 10788 | { |
10789 | BGP_IPV4_NODE, | |
10790 | "%s(config-router-af)# ", | |
10791 | 1, | |
10792 | }; | |
10793 | ||
7fc626de | 10794 | static struct cmd_node bgp_ipv4_multicast_node = |
718e3744 | 10795 | { |
10796 | BGP_IPV4M_NODE, | |
10797 | "%s(config-router-af)# ", | |
10798 | 1, | |
10799 | }; | |
10800 | ||
f51bae9c DS |
10801 | static struct cmd_node bgp_ipv4_labeled_unicast_node = |
10802 | { | |
10803 | BGP_IPV4L_NODE, | |
10804 | "%s(config-router-af)# ", | |
10805 | 1, | |
10806 | }; | |
10807 | ||
7fc626de | 10808 | static struct cmd_node bgp_ipv6_unicast_node = |
718e3744 | 10809 | { |
10810 | BGP_IPV6_NODE, | |
10811 | "%s(config-router-af)# ", | |
10812 | 1, | |
10813 | }; | |
10814 | ||
7fc626de | 10815 | static struct cmd_node bgp_ipv6_multicast_node = |
25ffbdc1 | 10816 | { |
10817 | BGP_IPV6M_NODE, | |
10818 | "%s(config-router-af)# ", | |
10819 | 1, | |
10820 | }; | |
10821 | ||
f51bae9c DS |
10822 | static struct cmd_node bgp_ipv6_labeled_unicast_node = |
10823 | { | |
10824 | BGP_IPV6L_NODE, | |
10825 | "%s(config-router-af)# ", | |
10826 | 1, | |
10827 | }; | |
10828 | ||
7fc626de | 10829 | static struct cmd_node bgp_vpnv4_node = |
718e3744 | 10830 | { |
10831 | BGP_VPNV4_NODE, | |
10832 | "%s(config-router-af)# ", | |
10833 | 1 | |
10834 | }; | |
6b0655a2 | 10835 | |
8ecd3266 | 10836 | static struct cmd_node bgp_vpnv6_node = |
10837 | { | |
10838 | BGP_VPNV6_NODE, | |
10839 | "%s(config-router-af-vpnv6)# ", | |
10840 | 1 | |
10841 | }; | |
10842 | ||
4e0b7b6d PG |
10843 | static struct cmd_node bgp_evpn_node = |
10844 | { | |
10845 | BGP_EVPN_NODE, | |
10846 | "%s(config-router-evpn)# ", | |
10847 | 1 | |
10848 | }; | |
10849 | ||
1f8ae70b | 10850 | static void community_list_vty (void); |
10851 | ||
b8a815e5 DL |
10852 | static void |
10853 | bgp_ac_neighbor (vector comps, struct cmd_token *token) | |
10854 | { | |
10855 | struct bgp *bgp; | |
10856 | struct peer *peer; | |
d48ed3e0 | 10857 | struct peer_group *group; |
b8a815e5 DL |
10858 | struct listnode *lnbgp, *lnpeer; |
10859 | ||
b8a815e5 | 10860 | for (ALL_LIST_ELEMENTS_RO (bm->bgp, lnbgp, bgp)) |
d48ed3e0 DL |
10861 | { |
10862 | for (ALL_LIST_ELEMENTS_RO (bgp->peer, lnpeer, peer)) | |
b8a815e5 | 10863 | { |
d48ed3e0 DL |
10864 | /* only provide suggestions on the appropriate input token type, |
10865 | * they'll otherwise show up multiple times */ | |
10866 | enum cmd_token_type match_type; | |
10867 | char *name = peer->host; | |
10868 | ||
10869 | if (peer->conf_if) | |
10870 | { | |
10871 | match_type = VARIABLE_TKN; | |
10872 | name = peer->conf_if; | |
10873 | } | |
10874 | else if (strchr(peer->host, ':')) | |
10875 | match_type = IPV6_TKN; | |
10876 | else | |
10877 | match_type = IPV4_TKN; | |
10878 | ||
10879 | if (token->type != match_type) | |
b8a815e5 | 10880 | continue; |
d48ed3e0 DL |
10881 | |
10882 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); | |
b8a815e5 | 10883 | } |
d48ed3e0 DL |
10884 | |
10885 | if (token->type == VARIABLE_TKN) | |
10886 | for (ALL_LIST_ELEMENTS_RO (bgp->group, lnpeer, group)) | |
10887 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, group->name)); | |
10888 | } | |
b8a815e5 DL |
10889 | } |
10890 | ||
10891 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
10892 | { | |
10893 | .varname = "neighbor", | |
10894 | .completions = bgp_ac_neighbor | |
10895 | }, { | |
10896 | .varname = "neighbors", | |
10897 | .completions = bgp_ac_neighbor | |
10898 | }, { | |
10899 | .completions = NULL | |
10900 | } | |
10901 | }; | |
10902 | ||
718e3744 | 10903 | void |
94f2b392 | 10904 | bgp_vty_init (void) |
718e3744 | 10905 | { |
b8a815e5 DL |
10906 | cmd_variable_handler_register(bgp_var_neighbor); |
10907 | ||
718e3744 | 10908 | /* Install bgp top node. */ |
10909 | install_node (&bgp_node, bgp_config_write); | |
10910 | install_node (&bgp_ipv4_unicast_node, NULL); | |
10911 | install_node (&bgp_ipv4_multicast_node, NULL); | |
f51bae9c | 10912 | install_node (&bgp_ipv4_labeled_unicast_node, NULL); |
718e3744 | 10913 | install_node (&bgp_ipv6_unicast_node, NULL); |
25ffbdc1 | 10914 | install_node (&bgp_ipv6_multicast_node, NULL); |
f51bae9c | 10915 | install_node (&bgp_ipv6_labeled_unicast_node, NULL); |
718e3744 | 10916 | install_node (&bgp_vpnv4_node, NULL); |
8ecd3266 | 10917 | install_node (&bgp_vpnv6_node, NULL); |
4e0b7b6d | 10918 | install_node (&bgp_evpn_node, NULL); |
718e3744 | 10919 | |
10920 | /* Install default VTY commands to new nodes. */ | |
10921 | install_default (BGP_NODE); | |
10922 | install_default (BGP_IPV4_NODE); | |
10923 | install_default (BGP_IPV4M_NODE); | |
f51bae9c | 10924 | install_default (BGP_IPV4L_NODE); |
718e3744 | 10925 | install_default (BGP_IPV6_NODE); |
25ffbdc1 | 10926 | install_default (BGP_IPV6M_NODE); |
f51bae9c | 10927 | install_default (BGP_IPV6L_NODE); |
718e3744 | 10928 | install_default (BGP_VPNV4_NODE); |
8ecd3266 | 10929 | install_default (BGP_VPNV6_NODE); |
4e0b7b6d | 10930 | install_default (BGP_EVPN_NODE); |
e52702f2 | 10931 | |
718e3744 | 10932 | /* "bgp multiple-instance" commands. */ |
10933 | install_element (CONFIG_NODE, &bgp_multiple_instance_cmd); | |
10934 | install_element (CONFIG_NODE, &no_bgp_multiple_instance_cmd); | |
10935 | ||
10936 | /* "bgp config-type" commands. */ | |
10937 | install_element (CONFIG_NODE, &bgp_config_type_cmd); | |
8c3deaae | 10938 | install_element (CONFIG_NODE, &no_bgp_config_type_cmd); |
718e3744 | 10939 | |
5fe9f963 | 10940 | /* bgp route-map delay-timer commands. */ |
10941 | install_element (CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
10942 | install_element (CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
5fe9f963 | 10943 | |
718e3744 | 10944 | /* Dummy commands (Currently not supported) */ |
10945 | install_element (BGP_NODE, &no_synchronization_cmd); | |
10946 | install_element (BGP_NODE, &no_auto_summary_cmd); | |
10947 | ||
10948 | /* "router bgp" commands. */ | |
10949 | install_element (CONFIG_NODE, &router_bgp_cmd); | |
718e3744 | 10950 | |
10951 | /* "no router bgp" commands. */ | |
10952 | install_element (CONFIG_NODE, &no_router_bgp_cmd); | |
718e3744 | 10953 | |
10954 | /* "bgp router-id" commands. */ | |
10955 | install_element (BGP_NODE, &bgp_router_id_cmd); | |
10956 | install_element (BGP_NODE, &no_bgp_router_id_cmd); | |
718e3744 | 10957 | |
10958 | /* "bgp cluster-id" commands. */ | |
10959 | install_element (BGP_NODE, &bgp_cluster_id_cmd); | |
718e3744 | 10960 | install_element (BGP_NODE, &no_bgp_cluster_id_cmd); |
718e3744 | 10961 | |
10962 | /* "bgp confederation" commands. */ | |
10963 | install_element (BGP_NODE, &bgp_confederation_identifier_cmd); | |
10964 | install_element (BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
718e3744 | 10965 | |
10966 | /* "bgp confederation peers" commands. */ | |
10967 | install_element (BGP_NODE, &bgp_confederation_peers_cmd); | |
10968 | install_element (BGP_NODE, &no_bgp_confederation_peers_cmd); | |
10969 | ||
abc920f8 DS |
10970 | /* bgp max-med command */ |
10971 | install_element (BGP_NODE, &bgp_maxmed_admin_cmd); | |
10972 | install_element (BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
10973 | install_element (BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
abc920f8 DS |
10974 | install_element (BGP_NODE, &bgp_maxmed_onstartup_cmd); |
10975 | install_element (BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
abc920f8 | 10976 | |
907f92c8 DS |
10977 | /* bgp disable-ebgp-connected-nh-check */ |
10978 | install_element (BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
10979 | install_element (BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
10980 | ||
f188f2c4 DS |
10981 | /* bgp update-delay command */ |
10982 | install_element (BGP_NODE, &bgp_update_delay_cmd); | |
10983 | install_element (BGP_NODE, &no_bgp_update_delay_cmd); | |
10984 | install_element (BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
f188f2c4 | 10985 | |
cb1faec9 DS |
10986 | install_element (BGP_NODE, &bgp_wpkt_quanta_cmd); |
10987 | install_element (BGP_NODE, &no_bgp_wpkt_quanta_cmd); | |
10988 | ||
3f9c7369 DS |
10989 | install_element (BGP_NODE, &bgp_coalesce_time_cmd); |
10990 | install_element (BGP_NODE, &no_bgp_coalesce_time_cmd); | |
10991 | ||
165b5fff | 10992 | /* "maximum-paths" commands. */ |
596c17ba DW |
10993 | install_element (BGP_NODE, &bgp_maxpaths_hidden_cmd); |
10994 | install_element (BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
165b5fff JB |
10995 | install_element (BGP_IPV4_NODE, &bgp_maxpaths_cmd); |
10996 | install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
431aa9f9 DS |
10997 | install_element (BGP_IPV6_NODE, &bgp_maxpaths_cmd); |
10998 | install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
596c17ba DW |
10999 | install_element (BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); |
11000 | install_element (BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
11001 | install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
165b5fff | 11002 | install_element (BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); |
f51bae9c | 11003 | install_element (BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); |
165b5fff | 11004 | install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); |
431aa9f9 | 11005 | install_element (BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); |
f51bae9c | 11006 | install_element (BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); |
431aa9f9 | 11007 | install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); |
165b5fff | 11008 | |
f51bae9c DS |
11009 | install_element (BGP_IPV4L_NODE, &bgp_maxpaths_cmd); |
11010 | install_element (BGP_IPV4L_NODE, &no_bgp_maxpaths_cmd); | |
11011 | install_element (BGP_IPV6L_NODE, &bgp_maxpaths_cmd); | |
11012 | install_element (BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
11013 | ||
11014 | install_element (BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cmd); | |
11015 | install_element (BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
11016 | install_element (BGP_IPV4L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
11017 | install_element (BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
11018 | install_element (BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
11019 | install_element (BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
11020 | ||
718e3744 | 11021 | /* "timers bgp" commands. */ |
11022 | install_element (BGP_NODE, &bgp_timers_cmd); | |
11023 | install_element (BGP_NODE, &no_bgp_timers_cmd); | |
718e3744 | 11024 | |
5fe9f963 | 11025 | /* route-map delay-timer commands - per instance for backwards compat. */ |
518f0eb1 DS |
11026 | install_element (BGP_NODE, &bgp_set_route_map_delay_timer_cmd); |
11027 | install_element (BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
11028 | ||
718e3744 | 11029 | /* "bgp client-to-client reflection" commands */ |
11030 | install_element (BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
11031 | install_element (BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
11032 | ||
11033 | /* "bgp always-compare-med" commands */ | |
11034 | install_element (BGP_NODE, &bgp_always_compare_med_cmd); | |
11035 | install_element (BGP_NODE, &no_bgp_always_compare_med_cmd); | |
e52702f2 | 11036 | |
718e3744 | 11037 | /* "bgp deterministic-med" commands */ |
11038 | install_element (BGP_NODE, &bgp_deterministic_med_cmd); | |
11039 | install_element (BGP_NODE, &no_bgp_deterministic_med_cmd); | |
538621f2 | 11040 | |
538621f2 | 11041 | /* "bgp graceful-restart" commands */ |
11042 | install_element (BGP_NODE, &bgp_graceful_restart_cmd); | |
11043 | install_element (BGP_NODE, &no_bgp_graceful_restart_cmd); | |
93406d87 | 11044 | install_element (BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
11045 | install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
eb6f1b41 PG |
11046 | install_element (BGP_NODE, &bgp_graceful_restart_restart_time_cmd); |
11047 | install_element (BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
e52702f2 | 11048 | |
43fc21b3 JC |
11049 | install_element (BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
11050 | install_element (BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
11051 | ||
718e3744 | 11052 | /* "bgp fast-external-failover" commands */ |
11053 | install_element (BGP_NODE, &bgp_fast_external_failover_cmd); | |
11054 | install_element (BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
11055 | ||
11056 | /* "bgp enforce-first-as" commands */ | |
11057 | install_element (BGP_NODE, &bgp_enforce_first_as_cmd); | |
11058 | install_element (BGP_NODE, &no_bgp_enforce_first_as_cmd); | |
11059 | ||
11060 | /* "bgp bestpath compare-routerid" commands */ | |
11061 | install_element (BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
11062 | install_element (BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
11063 | ||
11064 | /* "bgp bestpath as-path ignore" commands */ | |
11065 | install_element (BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
11066 | install_element (BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
11067 | ||
6811845b | 11068 | /* "bgp bestpath as-path confed" commands */ |
11069 | install_element (BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
11070 | install_element (BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
11071 | ||
2fdd455c PM |
11072 | /* "bgp bestpath as-path multipath-relax" commands */ |
11073 | install_element (BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
11074 | install_element (BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
11075 | ||
848973c7 | 11076 | /* "bgp log-neighbor-changes" commands */ |
11077 | install_element (BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
11078 | install_element (BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
11079 | ||
718e3744 | 11080 | /* "bgp bestpath med" commands */ |
11081 | install_element (BGP_NODE, &bgp_bestpath_med_cmd); | |
718e3744 | 11082 | install_element (BGP_NODE, &no_bgp_bestpath_med_cmd); |
718e3744 | 11083 | |
11084 | /* "no bgp default ipv4-unicast" commands. */ | |
11085 | install_element (BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
11086 | install_element (BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
e52702f2 | 11087 | |
718e3744 | 11088 | /* "bgp network import-check" commands. */ |
11089 | install_element (BGP_NODE, &bgp_network_import_check_cmd); | |
8233ef81 | 11090 | install_element (BGP_NODE, &bgp_network_import_check_exact_cmd); |
718e3744 | 11091 | install_element (BGP_NODE, &no_bgp_network_import_check_cmd); |
11092 | ||
11093 | /* "bgp default local-preference" commands. */ | |
11094 | install_element (BGP_NODE, &bgp_default_local_preference_cmd); | |
11095 | install_element (BGP_NODE, &no_bgp_default_local_preference_cmd); | |
718e3744 | 11096 | |
04b6bdc0 DW |
11097 | /* bgp default show-hostname */ |
11098 | install_element (BGP_NODE, &bgp_default_show_hostname_cmd); | |
11099 | install_element (BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
11100 | ||
3f9c7369 DS |
11101 | /* "bgp default subgroup-pkt-queue-max" commands. */ |
11102 | install_element (BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
11103 | install_element (BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
11104 | ||
8bd9d948 DS |
11105 | /* bgp ibgp-allow-policy-mods command */ |
11106 | install_element (BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
11107 | install_element (BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
11108 | ||
f14e6fdb DS |
11109 | /* "bgp listen limit" commands. */ |
11110 | install_element (BGP_NODE, &bgp_listen_limit_cmd); | |
11111 | install_element (BGP_NODE, &no_bgp_listen_limit_cmd); | |
11112 | ||
11113 | /* "bgp listen range" commands. */ | |
11114 | install_element (BGP_NODE, &bgp_listen_range_cmd); | |
11115 | install_element (BGP_NODE, &no_bgp_listen_range_cmd); | |
11116 | ||
718e3744 | 11117 | /* "neighbor remote-as" commands. */ |
11118 | install_element (BGP_NODE, &neighbor_remote_as_cmd); | |
a80beece | 11119 | install_element (BGP_NODE, &neighbor_interface_config_cmd); |
4c48cf63 | 11120 | install_element (BGP_NODE, &neighbor_interface_config_v6only_cmd); |
b3a39dc5 DD |
11121 | install_element (BGP_NODE, &neighbor_interface_config_remote_as_cmd); |
11122 | install_element (BGP_NODE, &neighbor_interface_v6only_config_remote_as_cmd); | |
718e3744 | 11123 | install_element (BGP_NODE, &no_neighbor_cmd); |
a80beece | 11124 | install_element (BGP_NODE, &no_neighbor_interface_config_cmd); |
718e3744 | 11125 | |
11126 | /* "neighbor peer-group" commands. */ | |
11127 | install_element (BGP_NODE, &neighbor_peer_group_cmd); | |
11128 | install_element (BGP_NODE, &no_neighbor_peer_group_cmd); | |
a80beece | 11129 | install_element (BGP_NODE, &no_neighbor_interface_peer_group_remote_as_cmd); |
718e3744 | 11130 | |
11131 | /* "neighbor local-as" commands. */ | |
11132 | install_element (BGP_NODE, &neighbor_local_as_cmd); | |
11133 | install_element (BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
9d3f9705 | 11134 | install_element (BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); |
718e3744 | 11135 | install_element (BGP_NODE, &no_neighbor_local_as_cmd); |
718e3744 | 11136 | |
3f9c7369 DS |
11137 | /* "neighbor solo" commands. */ |
11138 | install_element (BGP_NODE, &neighbor_solo_cmd); | |
11139 | install_element (BGP_NODE, &no_neighbor_solo_cmd); | |
11140 | ||
0df7c91f PJ |
11141 | /* "neighbor password" commands. */ |
11142 | install_element (BGP_NODE, &neighbor_password_cmd); | |
11143 | install_element (BGP_NODE, &no_neighbor_password_cmd); | |
11144 | ||
718e3744 | 11145 | /* "neighbor activate" commands. */ |
596c17ba | 11146 | install_element (BGP_NODE, &neighbor_activate_hidden_cmd); |
718e3744 | 11147 | install_element (BGP_IPV4_NODE, &neighbor_activate_cmd); |
11148 | install_element (BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
f51bae9c | 11149 | install_element (BGP_IPV4L_NODE, &neighbor_activate_cmd); |
718e3744 | 11150 | install_element (BGP_IPV6_NODE, &neighbor_activate_cmd); |
25ffbdc1 | 11151 | install_element (BGP_IPV6M_NODE, &neighbor_activate_cmd); |
f51bae9c | 11152 | install_element (BGP_IPV6L_NODE, &neighbor_activate_cmd); |
718e3744 | 11153 | install_element (BGP_VPNV4_NODE, &neighbor_activate_cmd); |
8ecd3266 | 11154 | install_element (BGP_VPNV6_NODE, &neighbor_activate_cmd); |
4e0b7b6d | 11155 | install_element (BGP_EVPN_NODE, &neighbor_activate_cmd); |
718e3744 | 11156 | |
11157 | /* "no neighbor activate" commands. */ | |
596c17ba | 11158 | install_element (BGP_NODE, &no_neighbor_activate_hidden_cmd); |
718e3744 | 11159 | install_element (BGP_IPV4_NODE, &no_neighbor_activate_cmd); |
11160 | install_element (BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
f51bae9c | 11161 | install_element (BGP_IPV4L_NODE, &no_neighbor_activate_cmd); |
718e3744 | 11162 | install_element (BGP_IPV6_NODE, &no_neighbor_activate_cmd); |
25ffbdc1 | 11163 | install_element (BGP_IPV6M_NODE, &no_neighbor_activate_cmd); |
f51bae9c | 11164 | install_element (BGP_IPV6L_NODE, &no_neighbor_activate_cmd); |
718e3744 | 11165 | install_element (BGP_VPNV4_NODE, &no_neighbor_activate_cmd); |
8ecd3266 | 11166 | install_element (BGP_VPNV6_NODE, &no_neighbor_activate_cmd); |
4e0b7b6d | 11167 | install_element (BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
718e3744 | 11168 | |
596c17ba | 11169 | /* "neighbor peer-group" set commands. */ |
718e3744 | 11170 | install_element (BGP_NODE, &neighbor_set_peer_group_cmd); |
596c17ba DW |
11171 | install_element (BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); |
11172 | install_element (BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11173 | install_element (BGP_IPV4L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11174 | install_element (BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11175 | install_element (BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11176 | install_element (BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11177 | install_element (BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11178 | install_element (BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
c8560b44 | 11179 | |
718e3744 | 11180 | /* "no neighbor peer-group unset" commands. */ |
11181 | install_element (BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
596c17ba DW |
11182 | install_element (BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); |
11183 | install_element (BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11184 | install_element (BGP_IPV4L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11185 | install_element (BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11186 | install_element (BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11187 | install_element (BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11188 | install_element (BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11189 | install_element (BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
e52702f2 | 11190 | |
718e3744 | 11191 | /* "neighbor softreconfiguration inbound" commands.*/ |
596c17ba DW |
11192 | install_element (BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); |
11193 | install_element (BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
718e3744 | 11194 | install_element (BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); |
11195 | install_element (BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
f51bae9c DS |
11196 | install_element (BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); |
11197 | install_element (BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
718e3744 | 11198 | install_element (BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); |
11199 | install_element (BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11200 | install_element (BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
11201 | install_element (BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
25ffbdc1 | 11202 | install_element (BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); |
11203 | install_element (BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
f51bae9c DS |
11204 | install_element (BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); |
11205 | install_element (BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
a58545bb | 11206 | install_element (BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); |
11207 | install_element (BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
8ecd3266 | 11208 | install_element (BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); |
11209 | install_element (BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
718e3744 | 11210 | |
11211 | /* "neighbor attribute-unchanged" commands. */ | |
596c17ba DW |
11212 | install_element (BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); |
11213 | install_element (BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
718e3744 | 11214 | install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 11215 | install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 11216 | install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 11217 | install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); |
f51bae9c DS |
11218 | install_element (BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); |
11219 | install_element (BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
718e3744 | 11220 | install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 11221 | install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); |
25ffbdc1 | 11222 | install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); |
25ffbdc1 | 11223 | install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); |
f51bae9c DS |
11224 | install_element (BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); |
11225 | install_element (BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
718e3744 | 11226 | install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 11227 | install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); |
8ecd3266 | 11228 | install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); |
8ecd3266 | 11229 | install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); |
8ecd3266 | 11230 | |
4e0b7b6d PG |
11231 | install_element (BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); |
11232 | install_element (BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
11233 | ||
fee0f4c6 | 11234 | /* "nexthop-local unchanged" commands */ |
11235 | install_element (BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
11236 | install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_local_unchanged_cmd); | |
11237 | ||
718e3744 | 11238 | /* "neighbor next-hop-self" commands. */ |
596c17ba DW |
11239 | install_element (BGP_NODE, &neighbor_nexthop_self_hidden_cmd); |
11240 | install_element (BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
718e3744 | 11241 | install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); |
11242 | install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
11243 | install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
11244 | install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
f51bae9c DS |
11245 | install_element (BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); |
11246 | install_element (BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
718e3744 | 11247 | install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); |
11248 | install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
25ffbdc1 | 11249 | install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); |
11250 | install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
f51bae9c DS |
11251 | install_element (BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); |
11252 | install_element (BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
718e3744 | 11253 | install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); |
11254 | install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
8ecd3266 | 11255 | install_element (BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); |
11256 | install_element (BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
718e3744 | 11257 | |
a538debe | 11258 | /* "neighbor next-hop-self force" commands. */ |
596c17ba DW |
11259 | install_element (BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); |
11260 | install_element (BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
a538debe DS |
11261 | install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
11262 | install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11263 | install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); | |
11264 | install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
f51bae9c DS |
11265 | install_element (BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); |
11266 | install_element (BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
a538debe DS |
11267 | install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); |
11268 | install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11269 | install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); | |
11270 | install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
f51bae9c DS |
11271 | install_element (BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); |
11272 | install_element (BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
a538debe DS |
11273 | install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); |
11274 | install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
8ecd3266 | 11275 | install_element (BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
11276 | install_element (BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
a538debe | 11277 | |
c7122e14 | 11278 | /* "neighbor as-override" commands. */ |
596c17ba DW |
11279 | install_element (BGP_NODE, &neighbor_as_override_hidden_cmd); |
11280 | install_element (BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
c7122e14 DS |
11281 | install_element (BGP_IPV4_NODE, &neighbor_as_override_cmd); |
11282 | install_element (BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
11283 | install_element (BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
11284 | install_element (BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
f51bae9c DS |
11285 | install_element (BGP_IPV4L_NODE, &neighbor_as_override_cmd); |
11286 | install_element (BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
c7122e14 DS |
11287 | install_element (BGP_IPV6_NODE, &neighbor_as_override_cmd); |
11288 | install_element (BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
11289 | install_element (BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
11290 | install_element (BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
f51bae9c DS |
11291 | install_element (BGP_IPV6L_NODE, &neighbor_as_override_cmd); |
11292 | install_element (BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
c7122e14 DS |
11293 | install_element (BGP_VPNV4_NODE, &neighbor_as_override_cmd); |
11294 | install_element (BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
8ecd3266 | 11295 | install_element (BGP_VPNV6_NODE, &neighbor_as_override_cmd); |
11296 | install_element (BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
c7122e14 | 11297 | |
718e3744 | 11298 | /* "neighbor remove-private-AS" commands. */ |
596c17ba DW |
11299 | install_element (BGP_NODE, &neighbor_remove_private_as_hidden_cmd); |
11300 | install_element (BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
11301 | install_element (BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
11302 | install_element (BGP_NODE, &no_neighbor_remove_private_as_all_hidden_cmd); | |
11303 | install_element (BGP_NODE, &neighbor_remove_private_as_replace_as_hidden_cmd); | |
11304 | install_element (BGP_NODE, &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
11305 | install_element (BGP_NODE, &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
11306 | install_element (BGP_NODE, &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
718e3744 | 11307 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); |
11308 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
11309 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); |
11310 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11311 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
11312 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
11313 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
11314 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 11315 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); |
11316 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
11317 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); |
11318 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11319 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
11320 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
11321 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
11322 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
f51bae9c DS |
11323 | install_element (BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); |
11324 | install_element (BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
11325 | install_element (BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
11326 | install_element (BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11327 | install_element (BGP_IPV4L_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
11328 | install_element (BGP_IPV4L_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
11329 | install_element (BGP_IPV4L_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
11330 | install_element (BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 11331 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); |
11332 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
11333 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); |
11334 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11335 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
11336 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
11337 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
11338 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
25ffbdc1 | 11339 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); |
11340 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
11341 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); |
11342 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11343 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
11344 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
11345 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
11346 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
f51bae9c DS |
11347 | install_element (BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); |
11348 | install_element (BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
11349 | install_element (BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
11350 | install_element (BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11351 | install_element (BGP_IPV6L_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
11352 | install_element (BGP_IPV6L_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
11353 | install_element (BGP_IPV6L_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
11354 | install_element (BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 11355 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); |
11356 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
11357 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); |
11358 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11359 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
11360 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
11361 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
11362 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
8ecd3266 | 11363 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); |
11364 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
11365 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
11366 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11367 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
11368 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
11369 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
11370 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 11371 | |
11372 | /* "neighbor send-community" commands.*/ | |
596c17ba DW |
11373 | install_element (BGP_NODE, &neighbor_send_community_hidden_cmd); |
11374 | install_element (BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
11375 | install_element (BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
11376 | install_element (BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
718e3744 | 11377 | install_element (BGP_IPV4_NODE, &neighbor_send_community_cmd); |
11378 | install_element (BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
11379 | install_element (BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
11380 | install_element (BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
11381 | install_element (BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
11382 | install_element (BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
11383 | install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
11384 | install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
f51bae9c DS |
11385 | install_element (BGP_IPV4L_NODE, &neighbor_send_community_cmd); |
11386 | install_element (BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
11387 | install_element (BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
11388 | install_element (BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
718e3744 | 11389 | install_element (BGP_IPV6_NODE, &neighbor_send_community_cmd); |
11390 | install_element (BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
11391 | install_element (BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
11392 | install_element (BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
25ffbdc1 | 11393 | install_element (BGP_IPV6M_NODE, &neighbor_send_community_cmd); |
11394 | install_element (BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
11395 | install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
11396 | install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
f51bae9c DS |
11397 | install_element (BGP_IPV6L_NODE, &neighbor_send_community_cmd); |
11398 | install_element (BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
11399 | install_element (BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
11400 | install_element (BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
718e3744 | 11401 | install_element (BGP_VPNV4_NODE, &neighbor_send_community_cmd); |
11402 | install_element (BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
11403 | install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
11404 | install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
8ecd3266 | 11405 | install_element (BGP_VPNV6_NODE, &neighbor_send_community_cmd); |
11406 | install_element (BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
11407 | install_element (BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
11408 | install_element (BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
718e3744 | 11409 | |
11410 | /* "neighbor route-reflector" commands.*/ | |
596c17ba DW |
11411 | install_element (BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); |
11412 | install_element (BGP_NODE, &no_neighbor_route_reflector_client_hidden_cmd); | |
718e3744 | 11413 | install_element (BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); |
11414 | install_element (BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
11415 | install_element (BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
11416 | install_element (BGP_IPV4M_NODE, &no_neighbor_route_reflector_client_cmd); | |
f51bae9c DS |
11417 | install_element (BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); |
11418 | install_element (BGP_IPV4L_NODE, &no_neighbor_route_reflector_client_cmd); | |
718e3744 | 11419 | install_element (BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); |
11420 | install_element (BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
25ffbdc1 | 11421 | install_element (BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); |
11422 | install_element (BGP_IPV6M_NODE, &no_neighbor_route_reflector_client_cmd); | |
f51bae9c DS |
11423 | install_element (BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); |
11424 | install_element (BGP_IPV6L_NODE, &no_neighbor_route_reflector_client_cmd); | |
718e3744 | 11425 | install_element (BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); |
11426 | install_element (BGP_VPNV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
8ecd3266 | 11427 | install_element (BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); |
11428 | install_element (BGP_VPNV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
718e3744 | 11429 | |
11430 | /* "neighbor route-server" commands.*/ | |
596c17ba DW |
11431 | install_element (BGP_NODE, &neighbor_route_server_client_hidden_cmd); |
11432 | install_element (BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
718e3744 | 11433 | install_element (BGP_IPV4_NODE, &neighbor_route_server_client_cmd); |
11434 | install_element (BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
11435 | install_element (BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
11436 | install_element (BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
f51bae9c DS |
11437 | install_element (BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); |
11438 | install_element (BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
718e3744 | 11439 | install_element (BGP_IPV6_NODE, &neighbor_route_server_client_cmd); |
11440 | install_element (BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
25ffbdc1 | 11441 | install_element (BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); |
11442 | install_element (BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
f51bae9c DS |
11443 | install_element (BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); |
11444 | install_element (BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
718e3744 | 11445 | install_element (BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); |
11446 | install_element (BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
8ecd3266 | 11447 | install_element (BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); |
11448 | install_element (BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
718e3744 | 11449 | |
adbac85e | 11450 | /* "neighbor addpath-tx-all-paths" commands.*/ |
596c17ba DW |
11451 | install_element (BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); |
11452 | install_element (BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
adbac85e DW |
11453 | install_element (BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); |
11454 | install_element (BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11455 | install_element (BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11456 | install_element (BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
f51bae9c DS |
11457 | install_element (BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); |
11458 | install_element (BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
adbac85e DW |
11459 | install_element (BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); |
11460 | install_element (BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11461 | install_element (BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11462 | install_element (BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
f51bae9c DS |
11463 | install_element (BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); |
11464 | install_element (BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
adbac85e DW |
11465 | install_element (BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); |
11466 | install_element (BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
8ecd3266 | 11467 | install_element (BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); |
11468 | install_element (BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
adbac85e | 11469 | |
06370dac | 11470 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ |
596c17ba DW |
11471 | install_element (BGP_NODE, &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); |
11472 | install_element (BGP_NODE, &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
06370dac DW |
11473 | install_element (BGP_IPV4_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); |
11474 | install_element (BGP_IPV4_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11475 | install_element (BGP_IPV4M_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11476 | install_element (BGP_IPV4M_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
f51bae9c DS |
11477 | install_element (BGP_IPV4L_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); |
11478 | install_element (BGP_IPV4L_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
06370dac DW |
11479 | install_element (BGP_IPV6_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); |
11480 | install_element (BGP_IPV6_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11481 | install_element (BGP_IPV6M_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11482 | install_element (BGP_IPV6M_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
f51bae9c DS |
11483 | install_element (BGP_IPV6L_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); |
11484 | install_element (BGP_IPV6L_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
06370dac DW |
11485 | install_element (BGP_VPNV4_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); |
11486 | install_element (BGP_VPNV4_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
8ecd3266 | 11487 | install_element (BGP_VPNV6_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); |
11488 | install_element (BGP_VPNV6_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
06370dac | 11489 | |
718e3744 | 11490 | /* "neighbor passive" commands. */ |
11491 | install_element (BGP_NODE, &neighbor_passive_cmd); | |
11492 | install_element (BGP_NODE, &no_neighbor_passive_cmd); | |
11493 | ||
d5a5c8f0 | 11494 | |
718e3744 | 11495 | /* "neighbor shutdown" commands. */ |
11496 | install_element (BGP_NODE, &neighbor_shutdown_cmd); | |
11497 | install_element (BGP_NODE, &no_neighbor_shutdown_cmd); | |
73d70fa6 DL |
11498 | install_element (BGP_NODE, &neighbor_shutdown_msg_cmd); |
11499 | install_element (BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
718e3744 | 11500 | |
8a92a8a0 DS |
11501 | /* "neighbor capability extended-nexthop" commands.*/ |
11502 | install_element (BGP_NODE, &neighbor_capability_enhe_cmd); | |
11503 | install_element (BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
11504 | ||
718e3744 | 11505 | /* "neighbor capability orf prefix-list" commands.*/ |
596c17ba DW |
11506 | install_element (BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); |
11507 | install_element (BGP_NODE, &no_neighbor_capability_orf_prefix_hidden_cmd); | |
718e3744 | 11508 | install_element (BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); |
11509 | install_element (BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
11510 | install_element (BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
11511 | install_element (BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
f51bae9c DS |
11512 | install_element (BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); |
11513 | install_element (BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
718e3744 | 11514 | install_element (BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); |
11515 | install_element (BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
25ffbdc1 | 11516 | install_element (BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); |
11517 | install_element (BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
f51bae9c DS |
11518 | install_element (BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); |
11519 | install_element (BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
718e3744 | 11520 | |
11521 | /* "neighbor capability dynamic" commands.*/ | |
11522 | install_element (BGP_NODE, &neighbor_capability_dynamic_cmd); | |
11523 | install_element (BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
11524 | ||
11525 | /* "neighbor dont-capability-negotiate" commands. */ | |
11526 | install_element (BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
11527 | install_element (BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
11528 | ||
11529 | /* "neighbor ebgp-multihop" commands. */ | |
11530 | install_element (BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
11531 | install_element (BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
11532 | install_element (BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
718e3744 | 11533 | |
6ffd2079 | 11534 | /* "neighbor disable-connected-check" commands. */ |
11535 | install_element (BGP_NODE, &neighbor_disable_connected_check_cmd); | |
11536 | install_element (BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
718e3744 | 11537 | |
11538 | /* "neighbor description" commands. */ | |
11539 | install_element (BGP_NODE, &neighbor_description_cmd); | |
11540 | install_element (BGP_NODE, &no_neighbor_description_cmd); | |
718e3744 | 11541 | |
11542 | /* "neighbor update-source" commands. "*/ | |
11543 | install_element (BGP_NODE, &neighbor_update_source_cmd); | |
11544 | install_element (BGP_NODE, &no_neighbor_update_source_cmd); | |
11545 | ||
11546 | /* "neighbor default-originate" commands. */ | |
596c17ba DW |
11547 | install_element (BGP_NODE, &neighbor_default_originate_hidden_cmd); |
11548 | install_element (BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
11549 | install_element (BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
718e3744 | 11550 | install_element (BGP_IPV4_NODE, &neighbor_default_originate_cmd); |
11551 | install_element (BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
11552 | install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 11553 | install_element (BGP_IPV4M_NODE, &neighbor_default_originate_cmd); |
11554 | install_element (BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
11555 | install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
f51bae9c DS |
11556 | install_element (BGP_IPV4L_NODE, &neighbor_default_originate_cmd); |
11557 | install_element (BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
11558 | install_element (BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 11559 | install_element (BGP_IPV6_NODE, &neighbor_default_originate_cmd); |
11560 | install_element (BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
11561 | install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
25ffbdc1 | 11562 | install_element (BGP_IPV6M_NODE, &neighbor_default_originate_cmd); |
11563 | install_element (BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
11564 | install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
f51bae9c DS |
11565 | install_element (BGP_IPV6L_NODE, &neighbor_default_originate_cmd); |
11566 | install_element (BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
11567 | install_element (BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 11568 | |
11569 | /* "neighbor port" commands. */ | |
11570 | install_element (BGP_NODE, &neighbor_port_cmd); | |
11571 | install_element (BGP_NODE, &no_neighbor_port_cmd); | |
718e3744 | 11572 | |
11573 | /* "neighbor weight" commands. */ | |
596c17ba DW |
11574 | install_element (BGP_NODE, &neighbor_weight_hidden_cmd); |
11575 | install_element (BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
718e3744 | 11576 | |
d93f7ffc DW |
11577 | install_element (BGP_IPV4_NODE, &neighbor_weight_cmd); |
11578 | install_element (BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
11579 | install_element (BGP_IPV4M_NODE, &neighbor_weight_cmd); |
11580 | install_element (BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
f51bae9c DS |
11581 | install_element (BGP_IPV4L_NODE, &neighbor_weight_cmd); |
11582 | install_element (BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
11583 | install_element (BGP_IPV6_NODE, &neighbor_weight_cmd); |
11584 | install_element (BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
11585 | install_element (BGP_IPV6M_NODE, &neighbor_weight_cmd); |
11586 | install_element (BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
f51bae9c DS |
11587 | install_element (BGP_IPV6L_NODE, &neighbor_weight_cmd); |
11588 | install_element (BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
11589 | install_element (BGP_VPNV4_NODE, &neighbor_weight_cmd); |
11590 | install_element (BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
11591 | install_element (BGP_VPNV6_NODE, &neighbor_weight_cmd); |
11592 | install_element (BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
718e3744 | 11593 | |
11594 | /* "neighbor override-capability" commands. */ | |
11595 | install_element (BGP_NODE, &neighbor_override_capability_cmd); | |
11596 | install_element (BGP_NODE, &no_neighbor_override_capability_cmd); | |
11597 | ||
11598 | /* "neighbor strict-capability-match" commands. */ | |
11599 | install_element (BGP_NODE, &neighbor_strict_capability_cmd); | |
11600 | install_element (BGP_NODE, &no_neighbor_strict_capability_cmd); | |
11601 | ||
11602 | /* "neighbor timers" commands. */ | |
11603 | install_element (BGP_NODE, &neighbor_timers_cmd); | |
11604 | install_element (BGP_NODE, &no_neighbor_timers_cmd); | |
11605 | ||
11606 | /* "neighbor timers connect" commands. */ | |
11607 | install_element (BGP_NODE, &neighbor_timers_connect_cmd); | |
11608 | install_element (BGP_NODE, &no_neighbor_timers_connect_cmd); | |
718e3744 | 11609 | |
11610 | /* "neighbor advertisement-interval" commands. */ | |
11611 | install_element (BGP_NODE, &neighbor_advertise_interval_cmd); | |
11612 | install_element (BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
718e3744 | 11613 | |
718e3744 | 11614 | /* "neighbor interface" commands. */ |
11615 | install_element (BGP_NODE, &neighbor_interface_cmd); | |
11616 | install_element (BGP_NODE, &no_neighbor_interface_cmd); | |
11617 | ||
11618 | /* "neighbor distribute" commands. */ | |
596c17ba DW |
11619 | install_element (BGP_NODE, &neighbor_distribute_list_hidden_cmd); |
11620 | install_element (BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
718e3744 | 11621 | install_element (BGP_IPV4_NODE, &neighbor_distribute_list_cmd); |
11622 | install_element (BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
11623 | install_element (BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
11624 | install_element (BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
f51bae9c DS |
11625 | install_element (BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); |
11626 | install_element (BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
718e3744 | 11627 | install_element (BGP_IPV6_NODE, &neighbor_distribute_list_cmd); |
11628 | install_element (BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
25ffbdc1 | 11629 | install_element (BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); |
11630 | install_element (BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
f51bae9c DS |
11631 | install_element (BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); |
11632 | install_element (BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
718e3744 | 11633 | install_element (BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); |
11634 | install_element (BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
8ecd3266 | 11635 | install_element (BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); |
11636 | install_element (BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
718e3744 | 11637 | |
11638 | /* "neighbor prefix-list" commands. */ | |
596c17ba DW |
11639 | install_element (BGP_NODE, &neighbor_prefix_list_hidden_cmd); |
11640 | install_element (BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
718e3744 | 11641 | install_element (BGP_IPV4_NODE, &neighbor_prefix_list_cmd); |
11642 | install_element (BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
11643 | install_element (BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
11644 | install_element (BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
f51bae9c DS |
11645 | install_element (BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); |
11646 | install_element (BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
718e3744 | 11647 | install_element (BGP_IPV6_NODE, &neighbor_prefix_list_cmd); |
11648 | install_element (BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
25ffbdc1 | 11649 | install_element (BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); |
11650 | install_element (BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
f51bae9c DS |
11651 | install_element (BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); |
11652 | install_element (BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
718e3744 | 11653 | install_element (BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); |
11654 | install_element (BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
8ecd3266 | 11655 | install_element (BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); |
11656 | install_element (BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
718e3744 | 11657 | |
11658 | /* "neighbor filter-list" commands. */ | |
596c17ba DW |
11659 | install_element (BGP_NODE, &neighbor_filter_list_hidden_cmd); |
11660 | install_element (BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
718e3744 | 11661 | install_element (BGP_IPV4_NODE, &neighbor_filter_list_cmd); |
11662 | install_element (BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
11663 | install_element (BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
11664 | install_element (BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
f51bae9c DS |
11665 | install_element (BGP_IPV4L_NODE, &neighbor_filter_list_cmd); |
11666 | install_element (BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
718e3744 | 11667 | install_element (BGP_IPV6_NODE, &neighbor_filter_list_cmd); |
11668 | install_element (BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
25ffbdc1 | 11669 | install_element (BGP_IPV6M_NODE, &neighbor_filter_list_cmd); |
11670 | install_element (BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
f51bae9c DS |
11671 | install_element (BGP_IPV6L_NODE, &neighbor_filter_list_cmd); |
11672 | install_element (BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
718e3744 | 11673 | install_element (BGP_VPNV4_NODE, &neighbor_filter_list_cmd); |
11674 | install_element (BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
8ecd3266 | 11675 | install_element (BGP_VPNV6_NODE, &neighbor_filter_list_cmd); |
11676 | install_element (BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
718e3744 | 11677 | |
11678 | /* "neighbor route-map" commands. */ | |
596c17ba DW |
11679 | install_element (BGP_NODE, &neighbor_route_map_hidden_cmd); |
11680 | install_element (BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
718e3744 | 11681 | install_element (BGP_IPV4_NODE, &neighbor_route_map_cmd); |
11682 | install_element (BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
11683 | install_element (BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
11684 | install_element (BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
f51bae9c DS |
11685 | install_element (BGP_IPV4L_NODE, &neighbor_route_map_cmd); |
11686 | install_element (BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
718e3744 | 11687 | install_element (BGP_IPV6_NODE, &neighbor_route_map_cmd); |
11688 | install_element (BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
25ffbdc1 | 11689 | install_element (BGP_IPV6M_NODE, &neighbor_route_map_cmd); |
11690 | install_element (BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
f51bae9c DS |
11691 | install_element (BGP_IPV6L_NODE, &neighbor_route_map_cmd); |
11692 | install_element (BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
718e3744 | 11693 | install_element (BGP_VPNV4_NODE, &neighbor_route_map_cmd); |
11694 | install_element (BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
8ecd3266 | 11695 | install_element (BGP_VPNV6_NODE, &neighbor_route_map_cmd); |
11696 | install_element (BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
718e3744 | 11697 | |
11698 | /* "neighbor unsuppress-map" commands. */ | |
596c17ba DW |
11699 | install_element (BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); |
11700 | install_element (BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
718e3744 | 11701 | install_element (BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); |
11702 | install_element (BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
11703 | install_element (BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
11704 | install_element (BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
f51bae9c DS |
11705 | install_element (BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); |
11706 | install_element (BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
718e3744 | 11707 | install_element (BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); |
11708 | install_element (BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
25ffbdc1 | 11709 | install_element (BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); |
11710 | install_element (BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
f51bae9c DS |
11711 | install_element (BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); |
11712 | install_element (BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
a58545bb | 11713 | install_element (BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); |
bb86c601 | 11714 | install_element (BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); |
8ecd3266 | 11715 | install_element (BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); |
bb86c601 | 11716 | install_element (BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); |
718e3744 | 11717 | |
11718 | /* "neighbor maximum-prefix" commands. */ | |
596c17ba DW |
11719 | install_element (BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); |
11720 | install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_hidden_cmd); | |
11721 | install_element (BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
11722 | install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
11723 | install_element (BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
11724 | install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
11725 | install_element (BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
718e3744 | 11726 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 11727 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 11728 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 11729 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 11730 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); |
11731 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 11732 | install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); |
718e3744 | 11733 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 11734 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 11735 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 11736 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 11737 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); |
11738 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 11739 | install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); |
f51bae9c DS |
11740 | install_element (BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); |
11741 | install_element (BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
11742 | install_element (BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
11743 | install_element (BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
11744 | install_element (BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
11745 | install_element (BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
11746 | install_element (BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
718e3744 | 11747 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 11748 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 11749 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 11750 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 11751 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); |
11752 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 11753 | install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); |
25ffbdc1 | 11754 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); |
11755 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
11756 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
11757 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
11758 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
11759 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
11760 | install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
f51bae9c DS |
11761 | install_element (BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); |
11762 | install_element (BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
11763 | install_element (BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
11764 | install_element (BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
11765 | install_element (BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
11766 | install_element (BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
11767 | install_element (BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
718e3744 | 11768 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 11769 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 11770 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 11771 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 11772 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); |
11773 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 11774 | install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); |
8ecd3266 | 11775 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); |
11776 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
11777 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
11778 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
11779 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
11780 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
11781 | install_element (BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
718e3744 | 11782 | |
11783 | /* "neighbor allowas-in" */ | |
596c17ba DW |
11784 | install_element (BGP_NODE, &neighbor_allowas_in_hidden_cmd); |
11785 | install_element (BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
718e3744 | 11786 | install_element (BGP_IPV4_NODE, &neighbor_allowas_in_cmd); |
718e3744 | 11787 | install_element (BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); |
11788 | install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
718e3744 | 11789 | install_element (BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); |
f51bae9c DS |
11790 | install_element (BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); |
11791 | install_element (BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
718e3744 | 11792 | install_element (BGP_IPV6_NODE, &neighbor_allowas_in_cmd); |
718e3744 | 11793 | install_element (BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); |
25ffbdc1 | 11794 | install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); |
25ffbdc1 | 11795 | install_element (BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); |
f51bae9c DS |
11796 | install_element (BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); |
11797 | install_element (BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
718e3744 | 11798 | install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); |
718e3744 | 11799 | install_element (BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); |
8ecd3266 | 11800 | install_element (BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); |
8ecd3266 | 11801 | install_element (BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); |
718e3744 | 11802 | |
11803 | /* address-family commands. */ | |
718e3744 | 11804 | install_element (BGP_NODE, &address_family_ipv4_safi_cmd); |
25ffbdc1 | 11805 | install_element (BGP_NODE, &address_family_ipv6_safi_cmd); |
d6902373 | 11806 | #ifdef KEEP_OLD_VPN_COMMANDS |
718e3744 | 11807 | install_element (BGP_NODE, &address_family_vpnv4_cmd); |
8b1fb8be | 11808 | install_element (BGP_NODE, &address_family_vpnv6_cmd); |
d6902373 | 11809 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 11810 | |
4e0b7b6d PG |
11811 | install_element (BGP_NODE, &address_family_evpn_cmd); |
11812 | ||
718e3744 | 11813 | /* "exit-address-family" command. */ |
11814 | install_element (BGP_IPV4_NODE, &exit_address_family_cmd); | |
11815 | install_element (BGP_IPV4M_NODE, &exit_address_family_cmd); | |
f51bae9c | 11816 | install_element (BGP_IPV4L_NODE, &exit_address_family_cmd); |
718e3744 | 11817 | install_element (BGP_IPV6_NODE, &exit_address_family_cmd); |
25ffbdc1 | 11818 | install_element (BGP_IPV6M_NODE, &exit_address_family_cmd); |
f51bae9c | 11819 | install_element (BGP_IPV6L_NODE, &exit_address_family_cmd); |
718e3744 | 11820 | install_element (BGP_VPNV4_NODE, &exit_address_family_cmd); |
8ecd3266 | 11821 | install_element (BGP_VPNV6_NODE, &exit_address_family_cmd); |
4e0b7b6d | 11822 | install_element (BGP_EVPN_NODE, &exit_address_family_cmd); |
718e3744 | 11823 | |
11824 | /* "clear ip bgp commands" */ | |
11825 | install_element (ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
718e3744 | 11826 | |
8ad7271d DS |
11827 | /* clear ip bgp prefix */ |
11828 | install_element (ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
11829 | install_element (ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
01080f7c | 11830 | install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); |
8ad7271d | 11831 | |
716b2d8a | 11832 | /* "show [ip] bgp summary" commands. */ |
f186de26 | 11833 | install_element (VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); |
8386ac43 | 11834 | install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_cmd); |
8386ac43 | 11835 | install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_s_cmd); |
271ad8d5 | 11836 | install_element (VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
e52702f2 | 11837 | install_element (VIEW_NODE, &show_bgp_updgrps_adj_cmd); |
e52702f2 | 11838 | install_element (VIEW_NODE, &show_bgp_updgrps_adj_s_cmd); |
271ad8d5 | 11839 | install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_cmd); |
e52702f2 | 11840 | install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_s_cmd); |
8c3deaae | 11841 | install_element (VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
271ad8d5 QY |
11842 | install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_cmd); |
11843 | install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); | |
11844 | install_element (VIEW_NODE, &show_ip_bgp_summary_cmd); | |
11845 | install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_cmd); | |
11846 | install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_s_cmd); | |
11847 | install_element (VIEW_NODE, &show_ip_bgp_updgrps_cmd); | |
e3e29b32 | 11848 | |
716b2d8a | 11849 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 11850 | install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd); |
718e3744 | 11851 | |
716b2d8a | 11852 | /* "show [ip] bgp peer-group" commands. */ |
f14e6fdb | 11853 | install_element (VIEW_NODE, &show_ip_bgp_peer_groups_cmd); |
f14e6fdb | 11854 | |
716b2d8a | 11855 | /* "show [ip] bgp paths" commands. */ |
718e3744 | 11856 | install_element (VIEW_NODE, &show_ip_bgp_paths_cmd); |
718e3744 | 11857 | |
716b2d8a | 11858 | /* "show [ip] bgp community" commands. */ |
718e3744 | 11859 | install_element (VIEW_NODE, &show_ip_bgp_community_info_cmd); |
718e3744 | 11860 | |
57d187bc JS |
11861 | /* "show ip bgp large-community" commands. */ |
11862 | install_element (VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
716b2d8a | 11863 | /* "show [ip] bgp attribute-info" commands. */ |
718e3744 | 11864 | install_element (VIEW_NODE, &show_ip_bgp_attr_info_cmd); |
718e3744 | 11865 | |
11866 | /* "redistribute" commands. */ | |
596c17ba DW |
11867 | install_element (BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); |
11868 | install_element (BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
11869 | install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
11870 | install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
11871 | install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
11872 | install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
11873 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
11874 | install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
11875 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
11876 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
11877 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
11878 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
919e0666 DW |
11879 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); |
11880 | install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
11881 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
919e0666 | 11882 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); |
919e0666 DW |
11883 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); |
11884 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
919e0666 DW |
11885 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); |
11886 | install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
11887 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
919e0666 | 11888 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); |
919e0666 | 11889 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); |
919e0666 | 11890 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); |
718e3744 | 11891 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); |
11892 | install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
11893 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
718e3744 | 11894 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); |
718e3744 | 11895 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); |
11896 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
718e3744 | 11897 | |
fa411a21 NH |
11898 | /* ttl_security commands */ |
11899 | install_element (BGP_NODE, &neighbor_ttl_security_cmd); | |
11900 | install_element (BGP_NODE, &no_neighbor_ttl_security_cmd); | |
11901 | ||
716b2d8a | 11902 | /* "show [ip] bgp memory" commands. */ |
4bf6a362 | 11903 | install_element (VIEW_NODE, &show_bgp_memory_cmd); |
e52702f2 | 11904 | |
716b2d8a | 11905 | /* "show [ip] bgp views" commands. */ |
e0081f70 | 11906 | install_element (VIEW_NODE, &show_bgp_views_cmd); |
e52702f2 | 11907 | |
716b2d8a | 11908 | /* "show [ip] bgp vrfs" commands. */ |
8386ac43 | 11909 | install_element (VIEW_NODE, &show_bgp_vrfs_cmd); |
e52702f2 | 11910 | |
718e3744 | 11911 | /* Community-list. */ |
11912 | community_list_vty (); | |
11913 | } | |
6b0655a2 | 11914 | |
718e3744 | 11915 | #include "memory.h" |
11916 | #include "bgp_regex.h" | |
11917 | #include "bgp_clist.h" | |
11918 | #include "bgp_ecommunity.h" | |
11919 | ||
11920 | /* VTY functions. */ | |
11921 | ||
11922 | /* Direction value to string conversion. */ | |
94f2b392 | 11923 | static const char * |
718e3744 | 11924 | community_direct_str (int direct) |
11925 | { | |
11926 | switch (direct) | |
11927 | { | |
11928 | case COMMUNITY_DENY: | |
11929 | return "deny"; | |
718e3744 | 11930 | case COMMUNITY_PERMIT: |
11931 | return "permit"; | |
718e3744 | 11932 | default: |
11933 | return "unknown"; | |
718e3744 | 11934 | } |
11935 | } | |
11936 | ||
11937 | /* Display error string. */ | |
94f2b392 | 11938 | static void |
718e3744 | 11939 | community_list_perror (struct vty *vty, int ret) |
11940 | { | |
11941 | switch (ret) | |
11942 | { | |
11943 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
b729294c | 11944 | vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE); |
718e3744 | 11945 | break; |
11946 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
11947 | vty_out (vty, "%% Malformed community-list value%s", VTY_NEWLINE); | |
11948 | break; | |
11949 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
11950 | vty_out (vty, "%% Community name conflict, previously defined as standard community%s", VTY_NEWLINE); | |
11951 | break; | |
11952 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
11953 | vty_out (vty, "%% Community name conflict, previously defined as expanded community%s", VTY_NEWLINE); | |
11954 | break; | |
11955 | } | |
11956 | } | |
11957 | ||
5bf15956 DW |
11958 | /* "community-list" keyword help string. */ |
11959 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
11960 | ||
718e3744 | 11961 | |
5bf15956 | 11962 | /* ip community-list standard */ |
718e3744 | 11963 | DEFUN (ip_community_list_standard, |
11964 | ip_community_list_standard_cmd, | |
e961923c | 11965 | "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 11966 | IP_STR |
11967 | COMMUNITY_LIST_STR | |
11968 | "Community list number (standard)\n" | |
5bf15956 | 11969 | "Add an standard community-list entry\n" |
718e3744 | 11970 | "Community list name\n" |
11971 | "Specify community to reject\n" | |
11972 | "Specify community to accept\n" | |
11973 | COMMUNITY_VAL_STR) | |
11974 | { | |
42f914d4 QY |
11975 | char *cl_name_or_number = NULL; |
11976 | int direct = 0; | |
11977 | int style = COMMUNITY_LIST_STANDARD; | |
11978 | ||
11979 | int idx = 0; | |
11980 | argv_find (argv, argc, "(1-99)", &idx); | |
11981 | argv_find (argv, argc, "WORD", &idx); | |
11982 | cl_name_or_number = argv[idx]->arg; | |
11983 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11984 | argv_find (argv, argc, "AA:NN", &idx); | |
11985 | char *str = argv_concat (argv, argc, idx); | |
11986 | ||
11987 | int ret = community_list_set (bgp_clist, cl_name_or_number, str, direct, style); | |
11988 | ||
11989 | XFREE (MTYPE_TMP, str); | |
11990 | ||
11991 | if (ret < 0) | |
11992 | { | |
11993 | /* Display error string. */ | |
11994 | community_list_perror (vty, ret); | |
11995 | return CMD_WARNING; | |
11996 | } | |
11997 | ||
11998 | return CMD_SUCCESS; | |
718e3744 | 11999 | } |
12000 | ||
fee6e4e4 | 12001 | DEFUN (no_ip_community_list_standard_all, |
12002 | no_ip_community_list_standard_all_cmd, | |
e961923c | 12003 | "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 12004 | NO_STR |
12005 | IP_STR | |
12006 | COMMUNITY_LIST_STR | |
12007 | "Community list number (standard)\n" | |
5bf15956 DW |
12008 | "Add an standard community-list entry\n" |
12009 | "Community list name\n" | |
718e3744 | 12010 | "Specify community to reject\n" |
12011 | "Specify community to accept\n" | |
12012 | COMMUNITY_VAL_STR) | |
12013 | { | |
42f914d4 QY |
12014 | int delete_all = 0; |
12015 | ||
12016 | char *cl_name_or_number = NULL; | |
12017 | int direct = 0; | |
12018 | int style = COMMUNITY_LIST_STANDARD; | |
12019 | ||
12020 | int idx = 0; | |
12021 | argv_find (argv, argc, "(1-99)", &idx); | |
12022 | argv_find (argv, argc, "WORD", &idx); | |
12023 | cl_name_or_number = argv[idx]->arg; | |
12024 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
12025 | argv_find (argv, argc, "AA:NN", &idx); | |
12026 | char *str = argv_concat (argv, argc, idx); | |
12027 | ||
12028 | int ret = community_list_unset (bgp_clist, cl_name_or_number, str, direct, style, delete_all); | |
12029 | ||
daf9ddbb DS |
12030 | XFREE (MTYPE_TMP, str); |
12031 | ||
42f914d4 QY |
12032 | if (ret < 0) |
12033 | { | |
12034 | community_list_perror (vty, ret); | |
12035 | return CMD_WARNING; | |
12036 | } | |
12037 | ||
12038 | return CMD_SUCCESS; | |
718e3744 | 12039 | } |
12040 | ||
5bf15956 DW |
12041 | /* ip community-list expanded */ |
12042 | DEFUN (ip_community_list_expanded_all, | |
12043 | ip_community_list_expanded_all_cmd, | |
42f914d4 | 12044 | "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 12045 | IP_STR |
12046 | COMMUNITY_LIST_STR | |
12047 | "Community list number (expanded)\n" | |
5bf15956 | 12048 | "Add an expanded community-list entry\n" |
718e3744 | 12049 | "Community list name\n" |
12050 | "Specify community to reject\n" | |
12051 | "Specify community to accept\n" | |
12052 | COMMUNITY_VAL_STR) | |
12053 | { | |
42f914d4 QY |
12054 | char *cl_name_or_number = NULL; |
12055 | int direct = 0; | |
12056 | int style = COMMUNITY_LIST_EXPANDED; | |
12057 | ||
12058 | int idx = 0; | |
12059 | argv_find (argv, argc, "(100-500)", &idx); | |
12060 | argv_find (argv, argc, "WORD", &idx); | |
12061 | cl_name_or_number = argv[idx]->arg; | |
12062 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
12063 | argv_find (argv, argc, "AA:NN", &idx); | |
12064 | char *str = argv_concat (argv, argc, idx); | |
12065 | ||
12066 | int ret = community_list_set (bgp_clist, cl_name_or_number, str, direct, style); | |
12067 | ||
12068 | XFREE (MTYPE_TMP, str); | |
12069 | ||
12070 | if (ret < 0) | |
12071 | { | |
12072 | /* Display error string. */ | |
12073 | community_list_perror (vty, ret); | |
12074 | return CMD_WARNING; | |
12075 | } | |
12076 | ||
12077 | return CMD_SUCCESS; | |
718e3744 | 12078 | } |
12079 | ||
5bf15956 DW |
12080 | DEFUN (no_ip_community_list_expanded_all, |
12081 | no_ip_community_list_expanded_all_cmd, | |
42f914d4 | 12082 | "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 12083 | NO_STR |
12084 | IP_STR | |
12085 | COMMUNITY_LIST_STR | |
5bf15956 DW |
12086 | "Community list number (expanded)\n" |
12087 | "Add an expanded community-list entry\n" | |
718e3744 | 12088 | "Community list name\n" |
12089 | "Specify community to reject\n" | |
12090 | "Specify community to accept\n" | |
5bf15956 | 12091 | COMMUNITY_VAL_STR) |
718e3744 | 12092 | { |
42f914d4 QY |
12093 | int delete_all = 0; |
12094 | ||
12095 | char *cl_name_or_number = NULL; | |
12096 | int direct = 0; | |
12097 | int style = COMMUNITY_LIST_EXPANDED; | |
12098 | ||
12099 | int idx = 0; | |
12100 | argv_find (argv, argc, "(100-500)", &idx); | |
12101 | argv_find (argv, argc, "WORD", &idx); | |
12102 | cl_name_or_number = argv[idx]->arg; | |
12103 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
12104 | argv_find (argv, argc, "AA:NN", &idx); | |
12105 | char *str = argv_concat (argv, argc, idx); | |
12106 | ||
12107 | int ret = community_list_unset (bgp_clist, cl_name_or_number, str, direct, style, delete_all); | |
12108 | ||
daf9ddbb DS |
12109 | XFREE (MTYPE_TMP, str); |
12110 | ||
42f914d4 QY |
12111 | if (ret < 0) |
12112 | { | |
12113 | community_list_perror (vty, ret); | |
12114 | return CMD_WARNING; | |
12115 | } | |
12116 | ||
12117 | return CMD_SUCCESS; | |
718e3744 | 12118 | } |
12119 | ||
94f2b392 | 12120 | static void |
718e3744 | 12121 | community_list_show (struct vty *vty, struct community_list *list) |
12122 | { | |
12123 | struct community_entry *entry; | |
12124 | ||
12125 | for (entry = list->head; entry; entry = entry->next) | |
12126 | { | |
12127 | if (entry == list->head) | |
12128 | { | |
12129 | if (all_digit (list->name)) | |
12130 | vty_out (vty, "Community %s list %s%s", | |
12131 | entry->style == COMMUNITY_LIST_STANDARD ? | |
12132 | "standard" : "(expanded) access", | |
12133 | list->name, VTY_NEWLINE); | |
12134 | else | |
12135 | vty_out (vty, "Named Community %s list %s%s", | |
12136 | entry->style == COMMUNITY_LIST_STANDARD ? | |
12137 | "standard" : "expanded", | |
12138 | list->name, VTY_NEWLINE); | |
12139 | } | |
12140 | if (entry->any) | |
12141 | vty_out (vty, " %s%s", | |
12142 | community_direct_str (entry->direct), VTY_NEWLINE); | |
12143 | else | |
12144 | vty_out (vty, " %s %s%s", | |
12145 | community_direct_str (entry->direct), | |
12146 | entry->style == COMMUNITY_LIST_STANDARD | |
12147 | ? community_str (entry->u.com) : entry->config, | |
12148 | VTY_NEWLINE); | |
12149 | } | |
12150 | } | |
12151 | ||
12152 | DEFUN (show_ip_community_list, | |
12153 | show_ip_community_list_cmd, | |
12154 | "show ip community-list", | |
12155 | SHOW_STR | |
12156 | IP_STR | |
12157 | "List community-list\n") | |
12158 | { | |
12159 | struct community_list *list; | |
12160 | struct community_list_master *cm; | |
12161 | ||
fee6e4e4 | 12162 | cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER); |
718e3744 | 12163 | if (! cm) |
12164 | return CMD_SUCCESS; | |
12165 | ||
12166 | for (list = cm->num.head; list; list = list->next) | |
12167 | community_list_show (vty, list); | |
12168 | ||
12169 | for (list = cm->str.head; list; list = list->next) | |
12170 | community_list_show (vty, list); | |
12171 | ||
12172 | return CMD_SUCCESS; | |
12173 | } | |
12174 | ||
12175 | DEFUN (show_ip_community_list_arg, | |
12176 | show_ip_community_list_arg_cmd, | |
6147e2c6 | 12177 | "show ip community-list <(1-500)|WORD>", |
718e3744 | 12178 | SHOW_STR |
12179 | IP_STR | |
12180 | "List community-list\n" | |
12181 | "Community-list number\n" | |
12182 | "Community-list name\n") | |
12183 | { | |
c500ae40 | 12184 | int idx_comm_list = 3; |
718e3744 | 12185 | struct community_list *list; |
12186 | ||
c500ae40 | 12187 | list = community_list_lookup (bgp_clist, argv[idx_comm_list]->arg, COMMUNITY_LIST_MASTER); |
718e3744 | 12188 | if (! list) |
12189 | { | |
b729294c | 12190 | vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE); |
718e3744 | 12191 | return CMD_WARNING; |
12192 | } | |
12193 | ||
12194 | community_list_show (vty, list); | |
12195 | ||
12196 | return CMD_SUCCESS; | |
12197 | } | |
6b0655a2 | 12198 | |
57d187bc JS |
12199 | /* |
12200 | * Large Community code. | |
12201 | */ | |
12202 | static int | |
12203 | lcommunity_list_set_vty (struct vty *vty, int argc, struct cmd_token **argv, | |
2acb4ac2 | 12204 | int style, int reject_all_digit_name) |
57d187bc JS |
12205 | { |
12206 | int ret; | |
12207 | int direct; | |
12208 | char *str; | |
12209 | int idx = 0; | |
12210 | char *cl_name; | |
12211 | ||
12212 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
12213 | ||
12214 | /* All digit name check. */ | |
12215 | idx = 0; | |
12216 | argv_find (argv, argc, "WORD", &idx); | |
12217 | argv_find (argv, argc, "(1-99)", &idx); | |
12218 | argv_find (argv, argc, "(100-500)", &idx); | |
12219 | cl_name = argv[idx]->arg; | |
12220 | if (reject_all_digit_name && all_digit (cl_name)) | |
12221 | { | |
12222 | vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE); | |
12223 | return CMD_WARNING; | |
12224 | } | |
12225 | ||
ce2570bc | 12226 | idx = 0; |
57d187bc JS |
12227 | argv_find (argv, argc, "AA:BB:CC", &idx); |
12228 | argv_find (argv, argc, "LINE", &idx); | |
12229 | /* Concat community string argument. */ | |
12230 | if (idx) | |
12231 | str = argv_concat (argv, argc, idx); | |
12232 | else | |
12233 | str = NULL; | |
12234 | ||
12235 | ret = lcommunity_list_set (bgp_clist, cl_name, str, direct, style); | |
12236 | ||
12237 | /* Free temporary community list string allocated by | |
12238 | argv_concat(). */ | |
12239 | if (str) | |
12240 | XFREE (MTYPE_TMP, str); | |
12241 | ||
12242 | if (ret < 0) | |
12243 | { | |
12244 | community_list_perror (vty, ret); | |
12245 | return CMD_WARNING; | |
12246 | } | |
12247 | return CMD_SUCCESS; | |
12248 | } | |
12249 | ||
12250 | static int | |
12251 | lcommunity_list_unset_vty (struct vty *vty, int argc, struct cmd_token **argv, | |
2acb4ac2 | 12252 | int style) |
57d187bc JS |
12253 | { |
12254 | int ret; | |
12255 | int direct = 0; | |
12256 | char *str = NULL; | |
12257 | int idx = 0; | |
12258 | ||
12259 | argv_find (argv, argc, "permit", &idx); | |
12260 | argv_find (argv, argc, "deny", &idx); | |
12261 | ||
12262 | if (idx) | |
12263 | { | |
12264 | /* Check the list direct. */ | |
12265 | if (strncmp (argv[idx]->arg, "p", 1) == 0) | |
2acb4ac2 | 12266 | direct = COMMUNITY_PERMIT; |
57d187bc | 12267 | else |
2acb4ac2 | 12268 | direct = COMMUNITY_DENY; |
57d187bc JS |
12269 | |
12270 | idx = 0; | |
12271 | argv_find (argv, argc, "LINE", &idx); | |
12272 | argv_find (argv, argc, "AA:AA:NN", &idx); | |
12273 | /* Concat community string argument. */ | |
12274 | str = argv_concat (argv, argc, idx); | |
12275 | } | |
12276 | ||
12277 | idx = 0; | |
12278 | argv_find (argv, argc, "(1-99)", &idx); | |
12279 | argv_find (argv, argc, "(100-500)", &idx); | |
12280 | argv_find (argv, argc, "WORD", &idx); | |
12281 | ||
12282 | /* Unset community list. */ | |
12283 | ret = lcommunity_list_unset (bgp_clist, argv[idx]->arg, str, direct, style); | |
12284 | ||
12285 | /* Free temporary community list string allocated by | |
12286 | argv_concat(). */ | |
12287 | if (str) | |
12288 | XFREE (MTYPE_TMP, str); | |
12289 | ||
12290 | if (ret < 0) | |
12291 | { | |
12292 | community_list_perror (vty, ret); | |
12293 | return CMD_WARNING; | |
12294 | } | |
12295 | ||
12296 | return CMD_SUCCESS; | |
12297 | } | |
12298 | ||
12299 | /* "large-community-list" keyword help string. */ | |
12300 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
12301 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
12302 | ||
12303 | DEFUN (ip_lcommunity_list_standard, | |
12304 | ip_lcommunity_list_standard_cmd, | |
52951b63 DS |
12305 | "ip large-community-list (1-99) <deny|permit>", |
12306 | IP_STR | |
12307 | LCOMMUNITY_LIST_STR | |
12308 | "Large Community list number (standard)\n" | |
12309 | "Specify large community to reject\n" | |
12310 | "Specify large community to accept\n" | |
12311 | LCOMMUNITY_VAL_STR) | |
12312 | { | |
12313 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD, 0); | |
12314 | } | |
12315 | ||
12316 | DEFUN (ip_lcommunity_list_standard1, | |
12317 | ip_lcommunity_list_standard1_cmd, | |
12318 | "ip large-community-list (1-99) <deny|permit> AA:BB:CC...", | |
57d187bc JS |
12319 | IP_STR |
12320 | LCOMMUNITY_LIST_STR | |
12321 | "Large Community list number (standard)\n" | |
12322 | "Specify large community to reject\n" | |
12323 | "Specify large community to accept\n" | |
12324 | LCOMMUNITY_VAL_STR) | |
12325 | { | |
12326 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD, 0); | |
12327 | } | |
12328 | ||
12329 | DEFUN (ip_lcommunity_list_expanded, | |
12330 | ip_lcommunity_list_expanded_cmd, | |
12331 | "ip large-community-list (100-500) <deny|permit> LINE...", | |
12332 | IP_STR | |
12333 | LCOMMUNITY_LIST_STR | |
12334 | "Large Community list number (expanded)\n" | |
12335 | "Specify large community to reject\n" | |
12336 | "Specify large community to accept\n" | |
12337 | "An ordered list as a regular-expression\n") | |
12338 | { | |
12339 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED, 0); | |
12340 | } | |
12341 | ||
12342 | DEFUN (ip_lcommunity_list_name_standard, | |
12343 | ip_lcommunity_list_name_standard_cmd, | |
52951b63 DS |
12344 | "ip large-community-list standard WORD <deny|permit>", |
12345 | IP_STR | |
12346 | LCOMMUNITY_LIST_STR | |
12347 | "Specify standard large-community-list\n" | |
12348 | "Large Community list name\n" | |
12349 | "Specify large community to reject\n" | |
12350 | "Specify large community to accept\n") | |
12351 | { | |
12352 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD, 1); | |
12353 | } | |
12354 | ||
12355 | DEFUN (ip_lcommunity_list_name_standard1, | |
12356 | ip_lcommunity_list_name_standard1_cmd, | |
12357 | "ip large-community-list standard WORD <deny|permit> AA:BB:CC...", | |
57d187bc JS |
12358 | IP_STR |
12359 | LCOMMUNITY_LIST_STR | |
12360 | "Specify standard large-community-list\n" | |
12361 | "Large Community list name\n" | |
12362 | "Specify large community to reject\n" | |
12363 | "Specify large community to accept\n" | |
12364 | LCOMMUNITY_VAL_STR) | |
12365 | { | |
12366 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD, 1); | |
12367 | } | |
12368 | ||
12369 | DEFUN (ip_lcommunity_list_name_expanded, | |
12370 | ip_lcommunity_list_name_expanded_cmd, | |
12371 | "ip large-community-list expanded WORD <deny|permit> LINE...", | |
12372 | IP_STR | |
12373 | LCOMMUNITY_LIST_STR | |
12374 | "Specify expanded large-community-list\n" | |
12375 | "Large Community list name\n" | |
12376 | "Specify large community to reject\n" | |
12377 | "Specify large community to accept\n" | |
12378 | "An ordered list as a regular-expression\n") | |
12379 | { | |
12380 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED, 1); | |
12381 | } | |
12382 | ||
12383 | DEFUN (no_ip_lcommunity_list_standard_all, | |
12384 | no_ip_lcommunity_list_standard_all_cmd, | |
12385 | "no ip large-community-list <(1-99)|(100-500)|WORD>", | |
12386 | NO_STR | |
12387 | IP_STR | |
12388 | LCOMMUNITY_LIST_STR | |
12389 | "Large Community list number (standard)\n" | |
12390 | "Large Community list number (expanded)\n" | |
12391 | "Large Community list name\n") | |
12392 | { | |
12393 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD); | |
12394 | } | |
12395 | ||
12396 | DEFUN (no_ip_lcommunity_list_name_expanded_all, | |
12397 | no_ip_lcommunity_list_name_expanded_all_cmd, | |
12398 | "no ip large-community-list expanded WORD", | |
12399 | NO_STR | |
12400 | IP_STR | |
12401 | LCOMMUNITY_LIST_STR | |
12402 | "Specify expanded large-community-list\n" | |
12403 | "Large Community list name\n") | |
12404 | { | |
12405 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED); | |
12406 | } | |
12407 | ||
12408 | DEFUN (no_ip_lcommunity_list_standard, | |
12409 | no_ip_lcommunity_list_standard_cmd, | |
12410 | "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...", | |
12411 | NO_STR | |
12412 | IP_STR | |
12413 | LCOMMUNITY_LIST_STR | |
12414 | "Large Community list number (standard)\n" | |
12415 | "Specify large community to reject\n" | |
12416 | "Specify large community to accept\n" | |
12417 | LCOMMUNITY_VAL_STR) | |
12418 | { | |
12419 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD); | |
12420 | } | |
12421 | ||
12422 | DEFUN (no_ip_lcommunity_list_expanded, | |
12423 | no_ip_lcommunity_list_expanded_cmd, | |
12424 | "no ip large-community-list (100-500) <deny|permit> LINE...", | |
12425 | NO_STR | |
12426 | IP_STR | |
12427 | LCOMMUNITY_LIST_STR | |
12428 | "Large Community list number (expanded)\n" | |
12429 | "Specify large community to reject\n" | |
12430 | "Specify large community to accept\n" | |
12431 | "An ordered list as a regular-expression\n") | |
12432 | { | |
12433 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED); | |
12434 | } | |
12435 | ||
12436 | DEFUN (no_ip_lcommunity_list_name_standard, | |
12437 | no_ip_lcommunity_list_name_standard_cmd, | |
12438 | "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...", | |
12439 | NO_STR | |
12440 | IP_STR | |
12441 | LCOMMUNITY_LIST_STR | |
12442 | "Specify standard large-community-list\n" | |
12443 | "Large Community list name\n" | |
12444 | "Specify large community to reject\n" | |
12445 | "Specify large community to accept\n" | |
12446 | LCOMMUNITY_VAL_STR) | |
12447 | { | |
12448 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD); | |
12449 | } | |
12450 | ||
12451 | DEFUN (no_ip_lcommunity_list_name_expanded, | |
12452 | no_ip_lcommunity_list_name_expanded_cmd, | |
12453 | "no ip large-community-list expanded WORD <deny|permit> LINE...", | |
12454 | NO_STR | |
12455 | IP_STR | |
12456 | LCOMMUNITY_LIST_STR | |
12457 | "Specify expanded large-community-list\n" | |
12458 | "Large community list name\n" | |
12459 | "Specify large community to reject\n" | |
12460 | "Specify large community to accept\n" | |
12461 | "An ordered list as a regular-expression\n") | |
12462 | { | |
12463 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED); | |
12464 | } | |
12465 | ||
12466 | static void | |
12467 | lcommunity_list_show (struct vty *vty, struct community_list *list) | |
12468 | { | |
12469 | struct community_entry *entry; | |
12470 | ||
12471 | for (entry = list->head; entry; entry = entry->next) | |
12472 | { | |
12473 | if (entry == list->head) | |
2acb4ac2 DL |
12474 | { |
12475 | if (all_digit (list->name)) | |
12476 | vty_out (vty, "Large community %s list %s%s", | |
12477 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
12478 | "standard" : "(expanded) access", | |
12479 | list->name, VTY_NEWLINE); | |
12480 | else | |
12481 | vty_out (vty, "Named large community %s list %s%s", | |
12482 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
12483 | "standard" : "expanded", | |
12484 | list->name, VTY_NEWLINE); | |
12485 | } | |
57d187bc | 12486 | if (entry->any) |
2acb4ac2 DL |
12487 | vty_out (vty, " %s%s", |
12488 | community_direct_str (entry->direct), VTY_NEWLINE); | |
57d187bc | 12489 | else |
2acb4ac2 DL |
12490 | vty_out (vty, " %s %s%s", |
12491 | community_direct_str (entry->direct), | |
12492 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
12493 | entry->u.ecom->str : entry->config, | |
12494 | VTY_NEWLINE); | |
57d187bc JS |
12495 | } |
12496 | } | |
12497 | ||
12498 | DEFUN (show_ip_lcommunity_list, | |
12499 | show_ip_lcommunity_list_cmd, | |
12500 | "show ip large-community-list", | |
12501 | SHOW_STR | |
12502 | IP_STR | |
12503 | "List large-community list\n") | |
12504 | { | |
12505 | struct community_list *list; | |
12506 | struct community_list_master *cm; | |
12507 | ||
12508 | cm = community_list_master_lookup (bgp_clist, LARGE_COMMUNITY_LIST_MASTER); | |
12509 | if (! cm) | |
12510 | return CMD_SUCCESS; | |
12511 | ||
12512 | for (list = cm->num.head; list; list = list->next) | |
12513 | lcommunity_list_show (vty, list); | |
12514 | ||
12515 | for (list = cm->str.head; list; list = list->next) | |
12516 | lcommunity_list_show (vty, list); | |
12517 | ||
12518 | return CMD_SUCCESS; | |
12519 | } | |
12520 | ||
12521 | DEFUN (show_ip_lcommunity_list_arg, | |
12522 | show_ip_lcommunity_list_arg_cmd, | |
12523 | "show ip large-community-list <(1-500)|WORD>", | |
12524 | SHOW_STR | |
12525 | IP_STR | |
12526 | "List large-community list\n" | |
12527 | "large-community-list number\n" | |
12528 | "large-community-list name\n") | |
12529 | { | |
12530 | struct community_list *list; | |
12531 | ||
12532 | list = community_list_lookup (bgp_clist, argv[3]->arg, LARGE_COMMUNITY_LIST_MASTER); | |
12533 | if (! list) | |
12534 | { | |
12535 | vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE); | |
12536 | return CMD_WARNING; | |
12537 | } | |
12538 | ||
12539 | lcommunity_list_show (vty, list); | |
12540 | ||
12541 | return CMD_SUCCESS; | |
12542 | } | |
12543 | ||
718e3744 | 12544 | /* "extcommunity-list" keyword help string. */ |
12545 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
12546 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
12547 | ||
12548 | DEFUN (ip_extcommunity_list_standard, | |
12549 | ip_extcommunity_list_standard_cmd, | |
e961923c | 12550 | "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 12551 | IP_STR |
12552 | EXTCOMMUNITY_LIST_STR | |
12553 | "Extended Community list number (standard)\n" | |
718e3744 | 12554 | "Specify standard extcommunity-list\n" |
5bf15956 | 12555 | "Community list name\n" |
718e3744 | 12556 | "Specify community to reject\n" |
12557 | "Specify community to accept\n" | |
12558 | EXTCOMMUNITY_VAL_STR) | |
12559 | { | |
42f914d4 QY |
12560 | int style = EXTCOMMUNITY_LIST_STANDARD; |
12561 | int direct = 0; | |
12562 | char *cl_number_or_name = NULL; | |
12563 | ||
12564 | int idx = 0; | |
12565 | argv_find (argv, argc, "(1-99)", &idx); | |
12566 | argv_find (argv, argc, "WORD", &idx); | |
12567 | cl_number_or_name = argv[idx]->arg; | |
12568 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
12569 | argv_find (argv, argc, "AA:NN", &idx); | |
12570 | char *str = argv_concat (argv, argc, idx); | |
12571 | ||
12572 | int ret = extcommunity_list_set (bgp_clist, cl_number_or_name, str, direct, style); | |
12573 | ||
12574 | XFREE (MTYPE_TMP, str); | |
12575 | ||
12576 | if (ret < 0) | |
12577 | { | |
12578 | community_list_perror (vty, ret); | |
12579 | return CMD_WARNING; | |
12580 | } | |
12581 | ||
12582 | return CMD_SUCCESS; | |
718e3744 | 12583 | } |
12584 | ||
718e3744 | 12585 | DEFUN (ip_extcommunity_list_name_expanded, |
12586 | ip_extcommunity_list_name_expanded_cmd, | |
e961923c | 12587 | "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 12588 | IP_STR |
12589 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 12590 | "Extended Community list number (expanded)\n" |
718e3744 | 12591 | "Specify expanded extcommunity-list\n" |
12592 | "Extended Community list name\n" | |
12593 | "Specify community to reject\n" | |
12594 | "Specify community to accept\n" | |
12595 | "An ordered list as a regular-expression\n") | |
12596 | { | |
42f914d4 QY |
12597 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
12598 | int direct = 0; | |
12599 | char *cl_number_or_name = NULL; | |
12600 | ||
12601 | int idx = 0; | |
12602 | argv_find (argv, argc, "(100-500)", &idx); | |
12603 | argv_find (argv, argc, "WORD", &idx); | |
12604 | cl_number_or_name = argv[idx]->arg; | |
12605 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
12606 | argv_find (argv, argc, "LINE", &idx); | |
12607 | char *str = argv_concat (argv, argc, idx); | |
12608 | ||
12609 | int ret = extcommunity_list_set (bgp_clist, cl_number_or_name, str, direct, style); | |
12610 | ||
12611 | XFREE (MTYPE_TMP, str); | |
12612 | ||
12613 | if (ret < 0) | |
12614 | { | |
12615 | community_list_perror (vty, ret); | |
12616 | return CMD_WARNING; | |
12617 | } | |
12618 | ||
12619 | return CMD_SUCCESS; | |
718e3744 | 12620 | } |
12621 | ||
fee6e4e4 | 12622 | DEFUN (no_ip_extcommunity_list_standard_all, |
12623 | no_ip_extcommunity_list_standard_all_cmd, | |
e961923c | 12624 | "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
813d4307 DW |
12625 | NO_STR |
12626 | IP_STR | |
12627 | EXTCOMMUNITY_LIST_STR | |
12628 | "Extended Community list number (standard)\n" | |
718e3744 | 12629 | "Specify standard extcommunity-list\n" |
5bf15956 | 12630 | "Community list name\n" |
718e3744 | 12631 | "Specify community to reject\n" |
12632 | "Specify community to accept\n" | |
12633 | EXTCOMMUNITY_VAL_STR) | |
12634 | { | |
42f914d4 QY |
12635 | int deleteall = 0; |
12636 | ||
12637 | int style = EXTCOMMUNITY_LIST_STANDARD; | |
12638 | int direct = 0; | |
12639 | char *cl_number_or_name = NULL; | |
12640 | ||
12641 | int idx = 0; | |
12642 | argv_find (argv, argc, "(1-99)", &idx); | |
12643 | argv_find (argv, argc, "WORD", &idx); | |
12644 | cl_number_or_name = argv[idx]->arg; | |
12645 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
12646 | argv_find (argv, argc, "AA:NN", &idx); | |
12647 | char *str = argv_concat (argv, argc, idx); | |
12648 | ||
12649 | int ret = extcommunity_list_unset (bgp_clist, cl_number_or_name, str, direct, style, deleteall); | |
12650 | ||
12651 | XFREE (MTYPE_TMP, str); | |
12652 | ||
12653 | if (ret < 0) | |
12654 | { | |
12655 | community_list_perror (vty, ret); | |
12656 | return CMD_WARNING; | |
12657 | } | |
12658 | ||
12659 | return CMD_SUCCESS; | |
718e3744 | 12660 | } |
12661 | ||
5bf15956 DW |
12662 | DEFUN (no_ip_extcommunity_list_expanded_all, |
12663 | no_ip_extcommunity_list_expanded_all_cmd, | |
e961923c | 12664 | "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 12665 | NO_STR |
12666 | IP_STR | |
12667 | EXTCOMMUNITY_LIST_STR | |
12668 | "Extended Community list number (expanded)\n" | |
718e3744 | 12669 | "Specify expanded extcommunity-list\n" |
5bf15956 | 12670 | "Extended Community list name\n" |
718e3744 | 12671 | "Specify community to reject\n" |
12672 | "Specify community to accept\n" | |
12673 | "An ordered list as a regular-expression\n") | |
12674 | { | |
42f914d4 QY |
12675 | int deleteall = 0; |
12676 | ||
12677 | int style = EXTCOMMUNITY_LIST_EXPANDED; | |
12678 | int direct = 0; | |
12679 | char *cl_number_or_name = NULL; | |
12680 | ||
12681 | int idx = 0; | |
12682 | argv_find (argv, argc, "(100-500)", &idx); | |
12683 | argv_find (argv, argc, "WORD", &idx); | |
12684 | cl_number_or_name = argv[idx]->arg; | |
12685 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
12686 | argv_find (argv, argc, "LINE", &idx); | |
12687 | char *str = argv_concat (argv, argc, idx); | |
12688 | ||
12689 | int ret = extcommunity_list_unset (bgp_clist, cl_number_or_name, str, direct, style, deleteall); | |
12690 | ||
12691 | XFREE (MTYPE_TMP, str); | |
12692 | ||
12693 | if (ret < 0) | |
12694 | { | |
12695 | community_list_perror (vty, ret); | |
12696 | return CMD_WARNING; | |
12697 | } | |
12698 | ||
12699 | return CMD_SUCCESS; | |
718e3744 | 12700 | } |
12701 | ||
94f2b392 | 12702 | static void |
718e3744 | 12703 | extcommunity_list_show (struct vty *vty, struct community_list *list) |
12704 | { | |
12705 | struct community_entry *entry; | |
12706 | ||
12707 | for (entry = list->head; entry; entry = entry->next) | |
12708 | { | |
12709 | if (entry == list->head) | |
12710 | { | |
12711 | if (all_digit (list->name)) | |
12712 | vty_out (vty, "Extended community %s list %s%s", | |
12713 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
12714 | "standard" : "(expanded) access", | |
12715 | list->name, VTY_NEWLINE); | |
12716 | else | |
12717 | vty_out (vty, "Named extended community %s list %s%s", | |
12718 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
12719 | "standard" : "expanded", | |
12720 | list->name, VTY_NEWLINE); | |
12721 | } | |
12722 | if (entry->any) | |
12723 | vty_out (vty, " %s%s", | |
12724 | community_direct_str (entry->direct), VTY_NEWLINE); | |
12725 | else | |
12726 | vty_out (vty, " %s %s%s", | |
12727 | community_direct_str (entry->direct), | |
12728 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
12729 | entry->u.ecom->str : entry->config, | |
12730 | VTY_NEWLINE); | |
12731 | } | |
12732 | } | |
12733 | ||
12734 | DEFUN (show_ip_extcommunity_list, | |
12735 | show_ip_extcommunity_list_cmd, | |
12736 | "show ip extcommunity-list", | |
12737 | SHOW_STR | |
12738 | IP_STR | |
12739 | "List extended-community list\n") | |
12740 | { | |
12741 | struct community_list *list; | |
12742 | struct community_list_master *cm; | |
12743 | ||
fee6e4e4 | 12744 | cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
718e3744 | 12745 | if (! cm) |
12746 | return CMD_SUCCESS; | |
12747 | ||
12748 | for (list = cm->num.head; list; list = list->next) | |
12749 | extcommunity_list_show (vty, list); | |
12750 | ||
12751 | for (list = cm->str.head; list; list = list->next) | |
12752 | extcommunity_list_show (vty, list); | |
12753 | ||
12754 | return CMD_SUCCESS; | |
12755 | } | |
12756 | ||
12757 | DEFUN (show_ip_extcommunity_list_arg, | |
12758 | show_ip_extcommunity_list_arg_cmd, | |
6147e2c6 | 12759 | "show ip extcommunity-list <(1-500)|WORD>", |
718e3744 | 12760 | SHOW_STR |
12761 | IP_STR | |
12762 | "List extended-community list\n" | |
12763 | "Extcommunity-list number\n" | |
12764 | "Extcommunity-list name\n") | |
12765 | { | |
c500ae40 | 12766 | int idx_comm_list = 3; |
718e3744 | 12767 | struct community_list *list; |
12768 | ||
c500ae40 | 12769 | list = community_list_lookup (bgp_clist, argv[idx_comm_list]->arg, EXTCOMMUNITY_LIST_MASTER); |
718e3744 | 12770 | if (! list) |
12771 | { | |
b729294c | 12772 | vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE); |
718e3744 | 12773 | return CMD_WARNING; |
12774 | } | |
12775 | ||
12776 | extcommunity_list_show (vty, list); | |
12777 | ||
12778 | return CMD_SUCCESS; | |
12779 | } | |
6b0655a2 | 12780 | |
718e3744 | 12781 | /* Return configuration string of community-list entry. */ |
fd79ac91 | 12782 | static const char * |
718e3744 | 12783 | community_list_config_str (struct community_entry *entry) |
12784 | { | |
fd79ac91 | 12785 | const char *str; |
718e3744 | 12786 | |
12787 | if (entry->any) | |
12788 | str = ""; | |
12789 | else | |
12790 | { | |
12791 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
12792 | str = community_str (entry->u.com); | |
12793 | else | |
12794 | str = entry->config; | |
12795 | } | |
12796 | return str; | |
12797 | } | |
12798 | ||
12799 | /* Display community-list and extcommunity-list configuration. */ | |
94f2b392 | 12800 | static int |
718e3744 | 12801 | community_list_config_write (struct vty *vty) |
12802 | { | |
12803 | struct community_list *list; | |
12804 | struct community_entry *entry; | |
12805 | struct community_list_master *cm; | |
12806 | int write = 0; | |
12807 | ||
12808 | /* Community-list. */ | |
fee6e4e4 | 12809 | cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER); |
718e3744 | 12810 | |
12811 | for (list = cm->num.head; list; list = list->next) | |
12812 | for (entry = list->head; entry; entry = entry->next) | |
12813 | { | |
fee6e4e4 | 12814 | vty_out (vty, "ip community-list %s %s %s%s", |
12815 | list->name, community_direct_str (entry->direct), | |
12816 | community_list_config_str (entry), | |
12817 | VTY_NEWLINE); | |
718e3744 | 12818 | write++; |
12819 | } | |
12820 | for (list = cm->str.head; list; list = list->next) | |
12821 | for (entry = list->head; entry; entry = entry->next) | |
12822 | { | |
12823 | vty_out (vty, "ip community-list %s %s %s %s%s", | |
12824 | entry->style == COMMUNITY_LIST_STANDARD | |
12825 | ? "standard" : "expanded", | |
12826 | list->name, community_direct_str (entry->direct), | |
12827 | community_list_config_str (entry), | |
12828 | VTY_NEWLINE); | |
12829 | write++; | |
12830 | } | |
12831 | ||
12832 | /* Extcommunity-list. */ | |
fee6e4e4 | 12833 | cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
718e3744 | 12834 | |
12835 | for (list = cm->num.head; list; list = list->next) | |
12836 | for (entry = list->head; entry; entry = entry->next) | |
12837 | { | |
fee6e4e4 | 12838 | vty_out (vty, "ip extcommunity-list %s %s %s%s", |
12839 | list->name, community_direct_str (entry->direct), | |
12840 | community_list_config_str (entry), VTY_NEWLINE); | |
718e3744 | 12841 | write++; |
12842 | } | |
12843 | for (list = cm->str.head; list; list = list->next) | |
12844 | for (entry = list->head; entry; entry = entry->next) | |
12845 | { | |
12846 | vty_out (vty, "ip extcommunity-list %s %s %s %s%s", | |
12847 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
12848 | ? "standard" : "expanded", | |
12849 | list->name, community_direct_str (entry->direct), | |
12850 | community_list_config_str (entry), VTY_NEWLINE); | |
12851 | write++; | |
12852 | } | |
57d187bc JS |
12853 | |
12854 | ||
12855 | /* lcommunity-list. */ | |
12856 | cm = community_list_master_lookup (bgp_clist, LARGE_COMMUNITY_LIST_MASTER); | |
12857 | ||
12858 | for (list = cm->num.head; list; list = list->next) | |
12859 | for (entry = list->head; entry; entry = entry->next) | |
12860 | { | |
2acb4ac2 DL |
12861 | vty_out (vty, "ip large-community-list %s %s %s%s", |
12862 | list->name, community_direct_str (entry->direct), | |
12863 | community_list_config_str (entry), VTY_NEWLINE); | |
12864 | write++; | |
57d187bc JS |
12865 | } |
12866 | for (list = cm->str.head; list; list = list->next) | |
12867 | for (entry = list->head; entry; entry = entry->next) | |
12868 | { | |
2acb4ac2 DL |
12869 | vty_out (vty, "ip large-community-list %s %s %s %s%s", |
12870 | entry->style == LARGE_COMMUNITY_LIST_STANDARD | |
12871 | ? "standard" : "expanded", | |
12872 | list->name, community_direct_str (entry->direct), | |
12873 | community_list_config_str (entry), VTY_NEWLINE); | |
12874 | write++; | |
57d187bc JS |
12875 | } |
12876 | ||
718e3744 | 12877 | return write; |
12878 | } | |
12879 | ||
7fc626de | 12880 | static struct cmd_node community_list_node = |
718e3744 | 12881 | { |
12882 | COMMUNITY_LIST_NODE, | |
12883 | "", | |
12884 | 1 /* Export to vtysh. */ | |
12885 | }; | |
12886 | ||
94f2b392 | 12887 | static void |
12888 | community_list_vty (void) | |
718e3744 | 12889 | { |
12890 | install_node (&community_list_node, community_list_config_write); | |
12891 | ||
12892 | /* Community-list. */ | |
718e3744 | 12893 | install_element (CONFIG_NODE, &ip_community_list_standard_cmd); |
d7d73ffc | 12894 | install_element (CONFIG_NODE, &ip_community_list_expanded_all_cmd); |
fee6e4e4 | 12895 | install_element (CONFIG_NODE, &no_ip_community_list_standard_all_cmd); |
12896 | install_element (CONFIG_NODE, &no_ip_community_list_expanded_all_cmd); | |
718e3744 | 12897 | install_element (VIEW_NODE, &show_ip_community_list_cmd); |
12898 | install_element (VIEW_NODE, &show_ip_community_list_arg_cmd); | |
718e3744 | 12899 | |
12900 | /* Extcommunity-list. */ | |
12901 | install_element (CONFIG_NODE, &ip_extcommunity_list_standard_cmd); | |
718e3744 | 12902 | install_element (CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd); |
fee6e4e4 | 12903 | install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd); |
12904 | install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd); | |
718e3744 | 12905 | install_element (VIEW_NODE, &show_ip_extcommunity_list_cmd); |
12906 | install_element (VIEW_NODE, &show_ip_extcommunity_list_arg_cmd); | |
57d187bc JS |
12907 | |
12908 | /* Large Community List */ | |
12909 | install_element (CONFIG_NODE, &ip_lcommunity_list_standard_cmd); | |
52951b63 | 12910 | install_element (CONFIG_NODE, &ip_lcommunity_list_standard1_cmd); |
57d187bc JS |
12911 | install_element (CONFIG_NODE, &ip_lcommunity_list_expanded_cmd); |
12912 | install_element (CONFIG_NODE, &ip_lcommunity_list_name_standard_cmd); | |
52951b63 | 12913 | install_element (CONFIG_NODE, &ip_lcommunity_list_name_standard1_cmd); |
57d187bc JS |
12914 | install_element (CONFIG_NODE, &ip_lcommunity_list_name_expanded_cmd); |
12915 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_standard_all_cmd); | |
12916 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_all_cmd); | |
12917 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_standard_cmd); | |
12918 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_expanded_cmd); | |
12919 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_name_standard_cmd); | |
12920 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_cmd); | |
12921 | install_element (VIEW_NODE, &show_ip_lcommunity_list_cmd); | |
12922 | install_element (VIEW_NODE, &show_ip_lcommunity_list_arg_cmd); | |
5bf15956 | 12923 | } |