]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* BGP VTY interface. |
2 | Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro | |
3 | ||
4 | This file is part of GNU Zebra. | |
5 | ||
6 | GNU Zebra is free software; you can redistribute it and/or modify it | |
7 | under the terms of the GNU General Public License as published by the | |
8 | Free Software Foundation; either version 2, or (at your option) any | |
9 | later version. | |
10 | ||
11 | GNU Zebra is distributed in the hope that it will be useful, but | |
12 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with GNU Zebra; see the file COPYING. If not, write to the Free | |
18 | Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
19 | 02111-1307, USA. */ | |
20 | ||
21 | #include <zebra.h> | |
22 | ||
23 | #include "command.h" | |
afec25d9 | 24 | #include "lib/json.h" |
718e3744 | 25 | #include "prefix.h" |
26 | #include "plist.h" | |
27 | #include "buffer.h" | |
28 | #include "linklist.h" | |
29 | #include "stream.h" | |
30 | #include "thread.h" | |
31 | #include "log.h" | |
3b8b1855 | 32 | #include "memory.h" |
fc7948fa | 33 | #include "memory_vty.h" |
4bf6a362 | 34 | #include "hash.h" |
3f9c7369 | 35 | #include "queue.h" |
039f3a34 | 36 | #include "filter.h" |
718e3744 | 37 | |
38 | #include "bgpd/bgpd.h" | |
4bf6a362 | 39 | #include "bgpd/bgp_advertise.h" |
718e3744 | 40 | #include "bgpd/bgp_attr.h" |
41 | #include "bgpd/bgp_aspath.h" | |
42 | #include "bgpd/bgp_community.h" | |
4bf6a362 | 43 | #include "bgpd/bgp_ecommunity.h" |
57d187bc | 44 | #include "bgpd/bgp_lcommunity.h" |
4bf6a362 | 45 | #include "bgpd/bgp_damp.h" |
718e3744 | 46 | #include "bgpd/bgp_debug.h" |
e0701b79 | 47 | #include "bgpd/bgp_fsm.h" |
4bf6a362 | 48 | #include "bgpd/bgp_nexthop.h" |
718e3744 | 49 | #include "bgpd/bgp_open.h" |
4bf6a362 | 50 | #include "bgpd/bgp_regex.h" |
718e3744 | 51 | #include "bgpd/bgp_route.h" |
c016b6c7 | 52 | #include "bgpd/bgp_mplsvpn.h" |
718e3744 | 53 | #include "bgpd/bgp_zebra.h" |
fee0f4c6 | 54 | #include "bgpd/bgp_table.h" |
94f2b392 | 55 | #include "bgpd/bgp_vty.h" |
165b5fff | 56 | #include "bgpd/bgp_mpath.h" |
cb1faec9 | 57 | #include "bgpd/bgp_packet.h" |
3f9c7369 | 58 | #include "bgpd/bgp_updgrp.h" |
c43ed2e4 | 59 | #include "bgpd/bgp_bfd.h" |
718e3744 | 60 | |
20eb8864 | 61 | static struct peer_group * |
62 | listen_range_exists (struct bgp *bgp, struct prefix *range, int exact); | |
63 | ||
718e3744 | 64 | /* Utility function to get address family from current node. */ |
65 | afi_t | |
66 | bgp_node_afi (struct vty *vty) | |
67 | { | |
4e851f1f LB |
68 | afi_t afi; |
69 | switch (vty->node) | |
70 | { | |
71 | case BGP_IPV6_NODE: | |
72 | case BGP_IPV6M_NODE: | |
73 | case BGP_VPNV6_NODE: | |
74 | case BGP_ENCAPV6_NODE: | |
75 | afi = AFI_IP6; | |
76 | break; | |
4e0b7b6d PG |
77 | case BGP_EVPN_NODE: |
78 | afi = AFI_L2VPN; | |
79 | break; | |
4e851f1f LB |
80 | default: |
81 | afi = AFI_IP; | |
82 | break; | |
83 | } | |
84 | return afi; | |
718e3744 | 85 | } |
86 | ||
87 | /* Utility function to get subsequent address family from current | |
88 | node. */ | |
89 | safi_t | |
90 | bgp_node_safi (struct vty *vty) | |
91 | { | |
4e851f1f LB |
92 | safi_t safi; |
93 | switch (vty->node) | |
94 | { | |
95 | case BGP_ENCAP_NODE: | |
96 | case BGP_ENCAPV6_NODE: | |
97 | safi = SAFI_ENCAP; | |
98 | break; | |
99 | case BGP_VPNV4_NODE: | |
100 | case BGP_VPNV6_NODE: | |
101 | safi = SAFI_MPLS_VPN; | |
102 | break; | |
103 | case BGP_IPV4M_NODE: | |
104 | case BGP_IPV6M_NODE: | |
105 | safi = SAFI_MULTICAST; | |
106 | break; | |
4e0b7b6d PG |
107 | case BGP_EVPN_NODE: |
108 | safi = SAFI_EVPN; | |
109 | break; | |
4e851f1f LB |
110 | default: |
111 | safi = SAFI_UNICAST; | |
112 | break; | |
113 | } | |
114 | return safi; | |
718e3744 | 115 | } |
116 | ||
46f296b4 LB |
117 | /* supports <ipv4|ipv6> */ |
118 | afi_t | |
119 | bgp_vty_afi_from_arg(const char *afi_str) | |
8b1fb8be | 120 | { |
46f296b4 LB |
121 | afi_t afi = AFI_MAX; /* unknown */ |
122 | if (!strcmp(afi_str, "ipv4")) { | |
123 | afi = AFI_IP; | |
8b1fb8be | 124 | } |
46f296b4 LB |
125 | else if (!strcmp(afi_str, "ipv6")) { |
126 | afi = AFI_IP6; | |
127 | } | |
4e0b7b6d PG |
128 | else if (!strcmp(afi_str, "l2vpn")) { |
129 | afi = AFI_L2VPN; | |
130 | } | |
46f296b4 LB |
131 | return afi; |
132 | } | |
133 | ||
134 | int | |
135 | bgp_parse_afi(const char *str, afi_t *afi) | |
136 | { | |
137 | *afi = bgp_vty_afi_from_arg(str); | |
138 | if (*afi != AFI_MAX) | |
139 | return 0; | |
140 | else | |
8b1fb8be LB |
141 | return -1; |
142 | } | |
143 | ||
46f296b4 LB |
144 | int |
145 | argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, afi_t *afi) | |
146 | { | |
147 | int ret = 0; | |
148 | if (argv_find (argv, argc, "ipv4", index)) | |
149 | { | |
150 | ret = 1; | |
151 | if (afi) | |
152 | *afi = AFI_IP; | |
153 | } | |
154 | else if (argv_find (argv, argc, "ipv6", index)) | |
155 | { | |
156 | ret = 1; | |
157 | if (afi) | |
158 | *afi = AFI_IP6; | |
159 | } | |
160 | return ret; | |
161 | } | |
162 | ||
163 | /* supports <unicast|multicast|vpn|encap> */ | |
ccbb332a | 164 | safi_t |
3b14d86e | 165 | bgp_vty_safi_from_arg(const char *safi_str) |
ccbb332a LB |
166 | { |
167 | safi_t safi = SAFI_MAX; /* unknown */ | |
168 | if (strncmp (safi_str, "m", 1) == 0) | |
169 | safi = SAFI_MULTICAST; | |
170 | else if (strncmp (safi_str, "u", 1) == 0) | |
171 | safi = SAFI_UNICAST; | |
172 | else if (strncmp (safi_str, "e", 1) == 0) | |
173 | safi = SAFI_ENCAP; | |
174 | else if (strncmp (safi_str, "v", 1) == 0) | |
46f296b4 | 175 | safi = SAFI_MPLS_VPN; |
ccbb332a LB |
176 | return safi; |
177 | } | |
178 | ||
8b1fb8be | 179 | int |
3289141f | 180 | argv_find_and_parse_safi (struct cmd_token **argv, int argc, int *index, safi_t *safi) |
46f296b4 LB |
181 | { |
182 | int ret = 0; | |
183 | if (argv_find (argv, argc, "unicast", index)) | |
184 | { | |
185 | ret = 1; | |
186 | if (safi) | |
187 | *safi = SAFI_UNICAST; | |
188 | } | |
189 | else if (argv_find (argv, argc, "multicast", index)) | |
190 | { | |
191 | ret = 1; | |
192 | if (safi) | |
193 | *safi = SAFI_MULTICAST; | |
194 | } | |
195 | else if (argv_find (argv, argc, "vpn", index)) | |
196 | { | |
197 | ret = 1; | |
198 | if (safi) | |
199 | *safi = SAFI_MPLS_VPN; | |
200 | } | |
201 | else if (argv_find (argv, argc, "encap", index)) | |
202 | { | |
203 | ret = 1; | |
204 | if (safi) | |
205 | *safi = SAFI_ENCAP; | |
206 | } | |
4e0b7b6d PG |
207 | else if (argv_find (argv, argc, "evpn", index)) |
208 | { | |
209 | ret = 1; | |
210 | if (safi) | |
211 | *safi = SAFI_EVPN; | |
212 | } | |
46f296b4 LB |
213 | return ret; |
214 | } | |
215 | ||
7eeee51e DS |
216 | /* |
217 | * bgp_vty_find_and_parse_afi_safi_vrf | |
218 | * | |
219 | * For a given 'show ...' command, correctly parse the afi/safi/vrf out from it | |
220 | * This function *assumes* that the calling function pre-sets the afi/safi/vrf | |
221 | * to appropriate values for the calling function. This is to allow the | |
222 | * calling function to make decisions appropriate for the show command | |
223 | * that is being parsed. | |
224 | * | |
225 | * The show commands are generally of the form: | |
226 | * "show [ip] bgp [<view|vrf> WORD] [<ipv4|ipv6> [<unicast|multicast|vpn|encap>]] ..." | |
227 | * | |
228 | * Since we use argv_find if the show command in particular doesn't have: | |
229 | * [ip] | |
230 | * [<view|vrf> WORD] | |
231 | * [<ipv4|ipv6> [<unicast|multicast|vpn|encap>]] | |
232 | * The command parsing should still be ok. | |
233 | * | |
234 | * vty -> The vty for the command so we can output some useful data in | |
235 | * the event of a parse error in the vrf. | |
236 | * argv -> The command tokens | |
237 | * argc -> How many command tokens we have | |
238 | * idx -> The current place in the command, generally should be 0 for this function | |
239 | * afi -> The parsed afi if it was included in the show command, returned here | |
240 | * safi -> The parsed safi if it was included in the show command, returned here | |
241 | * vrf -> The parsed vrf id if it was included in the show command, returned here | |
242 | * | |
243 | * The function returns the correct location in the parse tree for the | |
244 | * last token found. | |
0e37c258 DS |
245 | * |
246 | * Returns 0 for failure to parse correctly, else the idx position of where | |
247 | * it found the last token. | |
7eeee51e | 248 | */ |
af462945 | 249 | int |
9317e17d | 250 | bgp_vty_find_and_parse_afi_safi_vrf (struct vty *vty, struct cmd_token **argv, int argc, int *idx, |
af462945 DS |
251 | afi_t *afi, safi_t *safi, vrf_id_t *vrf) |
252 | { | |
253 | char *vrf_name = NULL; | |
254 | ||
b4898a38 DS |
255 | assert (afi); |
256 | assert (safi); | |
69d143a0 | 257 | assert (vrf && *vrf != VRF_UNKNOWN); |
b4898a38 | 258 | |
9317e17d | 259 | if (argv_find (argv, argc, "ip", idx)) |
af462945 DS |
260 | *afi = AFI_IP; |
261 | ||
9317e17d | 262 | if (argv_find (argv, argc, "view", idx) || argv_find (argv, argc, "vrf", idx)) |
af462945 | 263 | { |
9317e17d DS |
264 | vrf_name = argv[*idx + 1]->arg; |
265 | *idx += 2; | |
af462945 DS |
266 | } |
267 | ||
9317e17d DS |
268 | if (argv_find_and_parse_afi (argv, argc, idx, afi)) |
269 | argv_find_and_parse_safi (argv, argc, idx, safi); | |
af462945 DS |
270 | |
271 | if (vrf_name) | |
272 | { | |
273 | if (strmatch(vrf_name, "all")) | |
274 | *vrf = VRF_ALL; | |
275 | else | |
276 | *vrf = vrf_name_to_id (vrf_name); | |
277 | } | |
278 | ||
279 | if (*vrf == VRF_UNKNOWN) | |
280 | { | |
281 | vty_out (vty, "View/Vrf specified is unknown: %s", vrf_name); | |
9317e17d | 282 | *idx = 0; |
af462945 DS |
283 | return 0; |
284 | } | |
9317e17d DS |
285 | |
286 | *idx += 1; | |
287 | return *idx; | |
af462945 DS |
288 | } |
289 | ||
94f2b392 | 290 | static int |
6aeb9e78 | 291 | peer_address_self_check (struct bgp *bgp, union sockunion *su) |
718e3744 | 292 | { |
293 | struct interface *ifp = NULL; | |
294 | ||
295 | if (su->sa.sa_family == AF_INET) | |
6aeb9e78 | 296 | ifp = if_lookup_by_ipv4_exact (&su->sin.sin_addr, bgp->vrf_id); |
718e3744 | 297 | else if (su->sa.sa_family == AF_INET6) |
f2345335 | 298 | ifp = if_lookup_by_ipv6_exact (&su->sin6.sin6_addr, |
6aeb9e78 | 299 | su->sin6.sin6_scope_id, bgp->vrf_id); |
718e3744 | 300 | |
301 | if (ifp) | |
302 | return 1; | |
303 | ||
304 | return 0; | |
305 | } | |
306 | ||
307 | /* Utility function for looking up peer from VTY. */ | |
f14e6fdb DS |
308 | /* This is used only for configuration, so disallow if attempted on |
309 | * a dynamic neighbor. | |
310 | */ | |
94f2b392 | 311 | static struct peer * |
fd79ac91 | 312 | peer_lookup_vty (struct vty *vty, const char *ip_str) |
718e3744 | 313 | { |
cdc2d765 | 314 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); |
718e3744 | 315 | int ret; |
718e3744 | 316 | union sockunion su; |
317 | struct peer *peer; | |
318 | ||
cdc2d765 DL |
319 | if (!bgp) { |
320 | return NULL; | |
321 | } | |
718e3744 | 322 | |
323 | ret = str2sockunion (ip_str, &su); | |
324 | if (ret < 0) | |
325 | { | |
a80beece DS |
326 | peer = peer_lookup_by_conf_if (bgp, ip_str); |
327 | if (!peer) | |
328 | { | |
04b6bdc0 DW |
329 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) == NULL) |
330 | { | |
331 | vty_out (vty, "%% Malformed address or name: %s%s", ip_str, VTY_NEWLINE); | |
332 | return NULL; | |
333 | } | |
a80beece | 334 | } |
718e3744 | 335 | } |
a80beece | 336 | else |
718e3744 | 337 | { |
a80beece DS |
338 | peer = peer_lookup (bgp, &su); |
339 | if (! peer) | |
340 | { | |
341 | vty_out (vty, "%% Specify remote-as or peer-group commands first%s", | |
342 | VTY_NEWLINE); | |
343 | return NULL; | |
344 | } | |
f14e6fdb DS |
345 | if (peer_dynamic_neighbor (peer)) |
346 | { | |
347 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
348 | VTY_NEWLINE); | |
349 | return NULL; | |
350 | } | |
351 | ||
718e3744 | 352 | } |
353 | return peer; | |
354 | } | |
355 | ||
356 | /* Utility function for looking up peer or peer group. */ | |
f14e6fdb DS |
357 | /* This is used only for configuration, so disallow if attempted on |
358 | * a dynamic neighbor. | |
359 | */ | |
c43ed2e4 | 360 | struct peer * |
fd79ac91 | 361 | peer_and_group_lookup_vty (struct vty *vty, const char *peer_str) |
718e3744 | 362 | { |
cdc2d765 | 363 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); |
718e3744 | 364 | int ret; |
718e3744 | 365 | union sockunion su; |
f14e6fdb DS |
366 | struct peer *peer = NULL; |
367 | struct peer_group *group = NULL; | |
718e3744 | 368 | |
cdc2d765 DL |
369 | if (!bgp) { |
370 | return NULL; | |
371 | } | |
718e3744 | 372 | |
373 | ret = str2sockunion (peer_str, &su); | |
374 | if (ret == 0) | |
375 | { | |
f14e6fdb | 376 | /* IP address, locate peer. */ |
718e3744 | 377 | peer = peer_lookup (bgp, &su); |
718e3744 | 378 | } |
379 | else | |
380 | { | |
f14e6fdb | 381 | /* Not IP, could match either peer configured on interface or a group. */ |
a80beece | 382 | peer = peer_lookup_by_conf_if (bgp, peer_str); |
f14e6fdb DS |
383 | if (!peer) |
384 | group = peer_group_lookup (bgp, peer_str); | |
385 | } | |
a80beece | 386 | |
f14e6fdb DS |
387 | if (peer) |
388 | { | |
389 | if (peer_dynamic_neighbor (peer)) | |
390 | { | |
391 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
392 | VTY_NEWLINE); | |
393 | return NULL; | |
394 | } | |
395 | ||
396 | return peer; | |
718e3744 | 397 | } |
398 | ||
f14e6fdb DS |
399 | if (group) |
400 | return group->conf; | |
401 | ||
718e3744 | 402 | vty_out (vty, "%% Specify remote-as or peer-group commands first%s", |
403 | VTY_NEWLINE); | |
404 | ||
405 | return NULL; | |
406 | } | |
407 | ||
c43ed2e4 | 408 | int |
718e3744 | 409 | bgp_vty_return (struct vty *vty, int ret) |
410 | { | |
fd79ac91 | 411 | const char *str = NULL; |
718e3744 | 412 | |
413 | switch (ret) | |
414 | { | |
415 | case BGP_ERR_INVALID_VALUE: | |
416 | str = "Invalid value"; | |
417 | break; | |
418 | case BGP_ERR_INVALID_FLAG: | |
419 | str = "Invalid flag"; | |
420 | break; | |
718e3744 | 421 | case BGP_ERR_PEER_GROUP_SHUTDOWN: |
422 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
423 | break; | |
718e3744 | 424 | case BGP_ERR_PEER_FLAG_CONFLICT: |
425 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
426 | break; | |
718e3744 | 427 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: |
428 | str = "Specify remote-as or peer-group remote AS first"; | |
429 | break; | |
430 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
431 | str = "Cannot change the peer-group. Deconfigure first"; | |
432 | break; | |
433 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
4c48cf63 | 434 | str = "Peer is not a member of this peer-group"; |
718e3744 | 435 | break; |
436 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
437 | str = "Prefix/distribute list can not co-exist"; | |
438 | break; | |
439 | case BGP_ERR_NOT_INTERNAL_PEER: | |
440 | str = "Invalid command. Not an internal neighbor"; | |
441 | break; | |
442 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
5000f21c | 443 | str = "remove-private-AS cannot be configured for IBGP peers"; |
718e3744 | 444 | break; |
445 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
446 | str = "Local-AS allowed only for EBGP peers"; | |
447 | break; | |
448 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
449 | str = "Cannot have local-as same as BGP AS number"; | |
450 | break; | |
0df7c91f PJ |
451 | case BGP_ERR_TCPSIG_FAILED: |
452 | str = "Error while applying TCP-Sig to session(s)"; | |
453 | break; | |
fa411a21 NH |
454 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: |
455 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
456 | break; | |
f5a4827d SH |
457 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: |
458 | str = "ttl-security only allowed for EBGP peers"; | |
459 | break; | |
c7122e14 DS |
460 | case BGP_ERR_AS_OVERRIDE: |
461 | str = "as-override cannot be configured for IBGP peers"; | |
462 | break; | |
f14e6fdb DS |
463 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: |
464 | str = "Invalid limit for number of dynamic neighbors"; | |
465 | break; | |
466 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
467 | str = "Dynamic neighbor listen range already exists"; | |
468 | break; | |
469 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
470 | str = "Operation not allowed on a dynamic neighbor"; | |
471 | break; | |
63fa10b5 QY |
472 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: |
473 | str = "Operation not allowed on a directly connected neighbor"; | |
474 | break; | |
718e3744 | 475 | } |
476 | if (str) | |
477 | { | |
478 | vty_out (vty, "%% %s%s", str, VTY_NEWLINE); | |
479 | return CMD_WARNING; | |
480 | } | |
481 | return CMD_SUCCESS; | |
482 | } | |
483 | ||
7aafcaca DS |
484 | /* BGP clear sort. */ |
485 | enum clear_sort | |
486 | { | |
487 | clear_all, | |
488 | clear_peer, | |
489 | clear_group, | |
490 | clear_external, | |
491 | clear_as | |
492 | }; | |
493 | ||
7aafcaca DS |
494 | static void |
495 | bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi, | |
496 | safi_t safi, int error) | |
497 | { | |
498 | switch (error) | |
499 | { | |
500 | case BGP_ERR_AF_UNCONFIGURED: | |
501 | vty_out (vty, | |
46f296b4 LB |
502 | "%%BGP: Enable %s address family for the neighbor %s%s", |
503 | afi_safi_print(afi, safi), peer->host, VTY_NEWLINE); | |
7aafcaca DS |
504 | break; |
505 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
506 | 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); | |
507 | break; | |
508 | default: | |
509 | break; | |
510 | } | |
511 | } | |
512 | ||
513 | /* `clear ip bgp' functions. */ | |
514 | static int | |
515 | bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, | |
516 | enum clear_sort sort,enum bgp_clear_type stype, const char *arg) | |
517 | { | |
518 | int ret; | |
519 | struct peer *peer; | |
520 | struct listnode *node, *nnode; | |
521 | ||
522 | /* Clear all neighbors. */ | |
523 | /* | |
524 | * Pass along pointer to next node to peer_clear() when walking all nodes | |
525 | * on the BGP instance as that may get freed if it is a doppelganger | |
526 | */ | |
527 | if (sort == clear_all) | |
528 | { | |
529 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
530 | { | |
531 | if (stype == BGP_CLEAR_SOFT_NONE) | |
532 | ret = peer_clear (peer, &nnode); | |
533 | else if (peer->afc[afi][safi]) | |
534 | ret = peer_clear_soft (peer, afi, safi, stype); | |
535 | else | |
536 | ret = 0; | |
537 | ||
538 | if (ret < 0) | |
539 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
540 | } | |
541 | ||
542 | /* This is to apply read-only mode on this clear. */ | |
543 | if (stype == BGP_CLEAR_SOFT_NONE) | |
544 | bgp->update_delay_over = 0; | |
545 | ||
546 | return CMD_SUCCESS; | |
547 | } | |
548 | ||
549 | /* Clear specified neighbors. */ | |
550 | if (sort == clear_peer) | |
551 | { | |
552 | union sockunion su; | |
553 | int ret; | |
554 | ||
555 | /* Make sockunion for lookup. */ | |
556 | ret = str2sockunion (arg, &su); | |
557 | if (ret < 0) | |
558 | { | |
559 | peer = peer_lookup_by_conf_if (bgp, arg); | |
560 | if (!peer) | |
561 | { | |
04b6bdc0 DW |
562 | peer = peer_lookup_by_hostname(bgp, arg); |
563 | if (!peer) | |
564 | { | |
565 | vty_out (vty, "Malformed address or name: %s%s", arg, VTY_NEWLINE); | |
566 | return CMD_WARNING; | |
567 | } | |
7aafcaca DS |
568 | } |
569 | } | |
570 | else | |
571 | { | |
572 | peer = peer_lookup (bgp, &su); | |
573 | if (! peer) | |
574 | { | |
575 | vty_out (vty, "%%BGP: Unknown neighbor - \"%s\"%s", arg, VTY_NEWLINE); | |
576 | return CMD_WARNING; | |
577 | } | |
578 | } | |
579 | ||
580 | if (stype == BGP_CLEAR_SOFT_NONE) | |
581 | ret = peer_clear (peer, NULL); | |
582 | else | |
583 | ret = peer_clear_soft (peer, afi, safi, stype); | |
584 | ||
585 | if (ret < 0) | |
586 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
587 | ||
588 | return CMD_SUCCESS; | |
589 | } | |
590 | ||
591 | /* Clear all peer-group members. */ | |
592 | if (sort == clear_group) | |
593 | { | |
594 | struct peer_group *group; | |
595 | ||
596 | group = peer_group_lookup (bgp, arg); | |
597 | if (! group) | |
598 | { | |
599 | vty_out (vty, "%%BGP: No such peer-group %s%s", arg, VTY_NEWLINE); | |
600 | return CMD_WARNING; | |
601 | } | |
602 | ||
603 | for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) | |
604 | { | |
605 | if (stype == BGP_CLEAR_SOFT_NONE) | |
606 | { | |
18f1dc06 | 607 | peer_clear (peer, NULL); |
7aafcaca DS |
608 | continue; |
609 | } | |
610 | ||
c8560b44 | 611 | if (! peer->afc[afi][safi]) |
7aafcaca DS |
612 | continue; |
613 | ||
614 | ret = peer_clear_soft (peer, afi, safi, stype); | |
615 | ||
616 | if (ret < 0) | |
617 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
618 | } | |
619 | return CMD_SUCCESS; | |
620 | } | |
621 | ||
622 | if (sort == clear_external) | |
623 | { | |
624 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
625 | { | |
626 | if (peer->sort == BGP_PEER_IBGP) | |
627 | continue; | |
628 | ||
629 | if (stype == BGP_CLEAR_SOFT_NONE) | |
630 | ret = peer_clear (peer, &nnode); | |
631 | else | |
632 | ret = peer_clear_soft (peer, afi, safi, stype); | |
633 | ||
634 | if (ret < 0) | |
635 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
636 | } | |
637 | return CMD_SUCCESS; | |
638 | } | |
639 | ||
640 | if (sort == clear_as) | |
641 | { | |
642 | as_t as; | |
643 | int find = 0; | |
644 | ||
645 | VTY_GET_INTEGER_RANGE ("AS", as, arg, 1, BGP_AS4_MAX); | |
646 | ||
647 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
648 | { | |
649 | if (peer->as != as) | |
650 | continue; | |
651 | ||
652 | find = 1; | |
653 | if (stype == BGP_CLEAR_SOFT_NONE) | |
654 | ret = peer_clear (peer, &nnode); | |
655 | else | |
656 | ret = peer_clear_soft (peer, afi, safi, stype); | |
657 | ||
658 | if (ret < 0) | |
659 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
660 | } | |
661 | if (! find) | |
662 | vty_out (vty, "%%BGP: No peer is configured with AS %s%s", arg, | |
663 | VTY_NEWLINE); | |
664 | return CMD_SUCCESS; | |
665 | } | |
666 | ||
667 | return CMD_SUCCESS; | |
668 | } | |
669 | ||
670 | static int | |
671 | bgp_clear_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi, | |
672 | enum clear_sort sort, enum bgp_clear_type stype, | |
673 | const char *arg) | |
674 | { | |
675 | struct bgp *bgp; | |
676 | ||
677 | /* BGP structure lookup. */ | |
678 | if (name) | |
679 | { | |
680 | bgp = bgp_lookup_by_name (name); | |
681 | if (bgp == NULL) | |
682 | { | |
6aeb9e78 | 683 | vty_out (vty, "Can't find BGP instance %s%s", name, VTY_NEWLINE); |
7aafcaca DS |
684 | return CMD_WARNING; |
685 | } | |
686 | } | |
687 | else | |
688 | { | |
f31fa004 | 689 | bgp = bgp_get_default (); |
7aafcaca DS |
690 | if (bgp == NULL) |
691 | { | |
692 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
693 | return CMD_WARNING; | |
694 | } | |
695 | } | |
696 | ||
697 | return bgp_clear (vty, bgp, afi, safi, sort, stype, arg); | |
698 | } | |
699 | ||
700 | /* clear soft inbound */ | |
701 | static void | |
f31fa004 | 702 | bgp_clear_star_soft_in (struct vty *vty, const char *name) |
7aafcaca | 703 | { |
b09b5ae0 | 704 | bgp_clear_vty (vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
7aafcaca | 705 | BGP_CLEAR_SOFT_IN, NULL); |
f31fa004 | 706 | bgp_clear_vty (vty, name, AFI_IP6, SAFI_UNICAST, clear_all, |
7aafcaca | 707 | BGP_CLEAR_SOFT_IN, NULL); |
7aafcaca DS |
708 | } |
709 | ||
710 | /* clear soft outbound */ | |
711 | static void | |
f31fa004 | 712 | bgp_clear_star_soft_out (struct vty *vty, const char *name) |
7aafcaca | 713 | { |
f31fa004 | 714 | bgp_clear_vty (vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
7aafcaca | 715 | BGP_CLEAR_SOFT_OUT, NULL); |
f31fa004 | 716 | bgp_clear_vty (vty, name, AFI_IP6, SAFI_UNICAST, clear_all, |
7aafcaca | 717 | BGP_CLEAR_SOFT_OUT, NULL); |
7aafcaca DS |
718 | } |
719 | ||
720 | ||
718e3744 | 721 | /* BGP global configuration. */ |
722 | ||
723 | DEFUN (bgp_multiple_instance_func, | |
724 | bgp_multiple_instance_cmd, | |
725 | "bgp multiple-instance", | |
726 | BGP_STR | |
727 | "Enable bgp multiple instance\n") | |
728 | { | |
729 | bgp_option_set (BGP_OPT_MULTIPLE_INSTANCE); | |
730 | return CMD_SUCCESS; | |
731 | } | |
732 | ||
733 | DEFUN (no_bgp_multiple_instance, | |
734 | no_bgp_multiple_instance_cmd, | |
735 | "no bgp multiple-instance", | |
736 | NO_STR | |
737 | BGP_STR | |
738 | "BGP multiple instance\n") | |
739 | { | |
740 | int ret; | |
741 | ||
742 | ret = bgp_option_unset (BGP_OPT_MULTIPLE_INSTANCE); | |
743 | if (ret < 0) | |
744 | { | |
745 | vty_out (vty, "%% There are more than two BGP instances%s", VTY_NEWLINE); | |
746 | return CMD_WARNING; | |
747 | } | |
748 | return CMD_SUCCESS; | |
749 | } | |
750 | ||
751 | DEFUN (bgp_config_type, | |
752 | bgp_config_type_cmd, | |
6147e2c6 | 753 | "bgp config-type <cisco|zebra>", |
718e3744 | 754 | BGP_STR |
755 | "Configuration type\n" | |
756 | "cisco\n" | |
757 | "zebra\n") | |
758 | { | |
c500ae40 DW |
759 | int idx_vendor = 2; |
760 | if (strncmp (argv[idx_vendor]->arg, "c", 1) == 0) | |
718e3744 | 761 | bgp_option_set (BGP_OPT_CONFIG_CISCO); |
762 | else | |
763 | bgp_option_unset (BGP_OPT_CONFIG_CISCO); | |
764 | ||
765 | return CMD_SUCCESS; | |
766 | } | |
767 | ||
768 | DEFUN (no_bgp_config_type, | |
769 | no_bgp_config_type_cmd, | |
c7178fe7 | 770 | "no bgp config-type [<cisco|zebra>]", |
718e3744 | 771 | NO_STR |
772 | BGP_STR | |
838758ac DW |
773 | "Display configuration type\n" |
774 | "cisco\n" | |
775 | "zebra\n") | |
718e3744 | 776 | { |
777 | bgp_option_unset (BGP_OPT_CONFIG_CISCO); | |
778 | return CMD_SUCCESS; | |
779 | } | |
780 | ||
813d4307 | 781 | |
718e3744 | 782 | DEFUN (no_synchronization, |
783 | no_synchronization_cmd, | |
784 | "no synchronization", | |
785 | NO_STR | |
786 | "Perform IGP synchronization\n") | |
787 | { | |
788 | return CMD_SUCCESS; | |
789 | } | |
790 | ||
791 | DEFUN (no_auto_summary, | |
792 | no_auto_summary_cmd, | |
793 | "no auto-summary", | |
794 | NO_STR | |
795 | "Enable automatic network number summarization\n") | |
796 | { | |
797 | return CMD_SUCCESS; | |
798 | } | |
3d515fd9 | 799 | |
718e3744 | 800 | /* "router bgp" commands. */ |
f412b39a DW |
801 | DEFUN (router_bgp, |
802 | router_bgp_cmd, | |
31500417 | 803 | "router bgp [(1-4294967295) [<view|vrf> WORD]]", |
718e3744 | 804 | ROUTER_STR |
805 | BGP_STR | |
31500417 DW |
806 | AS_STR |
807 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 808 | { |
31500417 DW |
809 | int idx_asn = 2; |
810 | int idx_view_vrf = 3; | |
811 | int idx_vrf = 4; | |
718e3744 | 812 | int ret; |
813 | as_t as; | |
814 | struct bgp *bgp; | |
fd79ac91 | 815 | const char *name = NULL; |
ad4cbda1 | 816 | enum bgp_instance_type inst_type; |
718e3744 | 817 | |
2385a876 | 818 | // "router bgp" without an ASN |
31500417 | 819 | if (argc == 2) |
2385a876 | 820 | { |
6aeb9e78 | 821 | //Pending: Make VRF option available for ASN less config |
2385a876 | 822 | bgp = bgp_get_default(); |
718e3744 | 823 | |
2385a876 DW |
824 | if (bgp == NULL) |
825 | { | |
826 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
827 | return CMD_WARNING; | |
828 | } | |
718e3744 | 829 | |
2385a876 DW |
830 | if (listcount(bm->bgp) > 1) |
831 | { | |
832 | vty_out (vty, "%% Multiple BGP processes are configured%s", VTY_NEWLINE); | |
833 | return CMD_WARNING; | |
834 | } | |
835 | } | |
836 | ||
837 | // "router bgp X" | |
838 | else | |
718e3744 | 839 | { |
31500417 | 840 | VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_asn]->arg, 1, BGP_AS4_MAX); |
2385a876 | 841 | |
ad4cbda1 | 842 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; |
31500417 | 843 | if (argc > 3) |
ad4cbda1 | 844 | { |
31500417 DW |
845 | name = argv[idx_vrf]->arg; |
846 | ||
e52702f2 | 847 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) |
ad4cbda1 | 848 | inst_type = BGP_INSTANCE_TYPE_VRF; |
e52702f2 | 849 | else if (!strcmp(argv[idx_view_vrf]->text, "view")) |
ad4cbda1 | 850 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
851 | } | |
2385a876 | 852 | |
ad4cbda1 | 853 | ret = bgp_get (&bgp, &as, name, inst_type); |
2385a876 DW |
854 | switch (ret) |
855 | { | |
856 | case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET: | |
857 | vty_out (vty, "Please specify 'bgp multiple-instance' first%s", | |
858 | VTY_NEWLINE); | |
859 | return CMD_WARNING; | |
860 | case BGP_ERR_AS_MISMATCH: | |
861 | vty_out (vty, "BGP is already running; AS is %u%s", as, VTY_NEWLINE); | |
862 | return CMD_WARNING; | |
863 | case BGP_ERR_INSTANCE_MISMATCH: | |
6aeb9e78 | 864 | vty_out (vty, "BGP instance name and AS number mismatch%s", VTY_NEWLINE); |
2385a876 DW |
865 | vty_out (vty, "BGP instance is already running; AS is %u%s", |
866 | as, VTY_NEWLINE); | |
867 | return CMD_WARNING; | |
868 | } | |
6aeb9e78 DS |
869 | |
870 | /* Pending: handle when user tries to change a view to vrf n vv. */ | |
718e3744 | 871 | } |
872 | ||
cdc2d765 | 873 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); |
718e3744 | 874 | |
875 | return CMD_SUCCESS; | |
876 | } | |
877 | ||
718e3744 | 878 | /* "no router bgp" commands. */ |
879 | DEFUN (no_router_bgp, | |
880 | no_router_bgp_cmd, | |
31500417 | 881 | "no router bgp [(1-4294967295) [<view|vrf> WORD]]", |
718e3744 | 882 | NO_STR |
883 | ROUTER_STR | |
884 | BGP_STR | |
31500417 DW |
885 | AS_STR |
886 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 887 | { |
31500417 | 888 | int idx_asn = 3; |
31500417 | 889 | int idx_vrf = 5; |
718e3744 | 890 | as_t as; |
891 | struct bgp *bgp; | |
fd79ac91 | 892 | const char *name = NULL; |
718e3744 | 893 | |
7fb21a9f | 894 | // "no router bgp" without an ASN |
31500417 | 895 | if (argc == 3) |
7fb21a9f QY |
896 | { |
897 | //Pending: Make VRF option available for ASN less config | |
898 | bgp = bgp_get_default(); | |
718e3744 | 899 | |
7fb21a9f QY |
900 | if (bgp == NULL) |
901 | { | |
902 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
903 | return CMD_WARNING; | |
904 | } | |
905 | ||
906 | if (listcount(bm->bgp) > 1) | |
907 | { | |
908 | vty_out (vty, "%% Multiple BGP processes are configured%s", VTY_NEWLINE); | |
909 | return CMD_WARNING; | |
910 | } | |
911 | } | |
912 | else | |
718e3744 | 913 | { |
31500417 | 914 | VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_asn]->arg, 1, BGP_AS4_MAX); |
7fb21a9f | 915 | |
31500417 DW |
916 | if (argc > 4) |
917 | name = argv[idx_vrf]->arg; | |
7fb21a9f QY |
918 | |
919 | /* Lookup bgp structure. */ | |
920 | bgp = bgp_lookup (as, name); | |
921 | if (! bgp) | |
922 | { | |
923 | vty_out (vty, "%% Can't find BGP instance%s", VTY_NEWLINE); | |
924 | return CMD_WARNING; | |
925 | } | |
718e3744 | 926 | } |
927 | ||
928 | bgp_delete (bgp); | |
929 | ||
930 | return CMD_SUCCESS; | |
931 | } | |
932 | ||
6b0655a2 | 933 | |
7fb21a9f | 934 | |
718e3744 | 935 | /* BGP router-id. */ |
936 | ||
937 | DEFUN (bgp_router_id, | |
938 | bgp_router_id_cmd, | |
939 | "bgp router-id A.B.C.D", | |
940 | BGP_STR | |
941 | "Override configured router identifier\n" | |
942 | "Manually configured router identifier\n") | |
943 | { | |
cdc2d765 | 944 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 945 | int idx_ipv4 = 2; |
718e3744 | 946 | int ret; |
947 | struct in_addr id; | |
718e3744 | 948 | |
c500ae40 | 949 | ret = inet_aton (argv[idx_ipv4]->arg, &id); |
718e3744 | 950 | if (! ret) |
951 | { | |
952 | vty_out (vty, "%% Malformed bgp router identifier%s", VTY_NEWLINE); | |
953 | return CMD_WARNING; | |
954 | } | |
955 | ||
0e6cb743 | 956 | bgp_router_id_static_set (bgp, id); |
718e3744 | 957 | |
958 | return CMD_SUCCESS; | |
959 | } | |
960 | ||
961 | DEFUN (no_bgp_router_id, | |
962 | no_bgp_router_id_cmd, | |
31500417 | 963 | "no bgp router-id [A.B.C.D]", |
718e3744 | 964 | NO_STR |
965 | BGP_STR | |
31500417 DW |
966 | "Override configured router identifier\n" |
967 | "Manually configured router identifier\n") | |
718e3744 | 968 | { |
cdc2d765 | 969 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
31500417 | 970 | int idx_router_id = 3; |
718e3744 | 971 | int ret; |
972 | struct in_addr id; | |
718e3744 | 973 | |
31500417 | 974 | if (argc > idx_router_id) |
718e3744 | 975 | { |
31500417 | 976 | ret = inet_aton (argv[idx_router_id]->arg, &id); |
718e3744 | 977 | if (! ret) |
e018c7cc SK |
978 | { |
979 | vty_out (vty, "%% Malformed BGP router identifier%s", VTY_NEWLINE); | |
980 | return CMD_WARNING; | |
981 | } | |
718e3744 | 982 | |
18a6dce6 | 983 | if (! IPV4_ADDR_SAME (&bgp->router_id_static, &id)) |
e018c7cc SK |
984 | { |
985 | vty_out (vty, "%% BGP router-id doesn't match%s", VTY_NEWLINE); | |
986 | return CMD_WARNING; | |
987 | } | |
718e3744 | 988 | } |
989 | ||
0e6cb743 DL |
990 | id.s_addr = 0; |
991 | bgp_router_id_static_set (bgp, id); | |
718e3744 | 992 | |
993 | return CMD_SUCCESS; | |
994 | } | |
995 | ||
6b0655a2 | 996 | |
718e3744 | 997 | /* BGP Cluster ID. */ |
718e3744 | 998 | DEFUN (bgp_cluster_id, |
999 | bgp_cluster_id_cmd, | |
838758ac | 1000 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", |
718e3744 | 1001 | BGP_STR |
1002 | "Configure Route-Reflector Cluster-id\n" | |
838758ac DW |
1003 | "Route-Reflector Cluster-id in IP address format\n" |
1004 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1005 | { |
cdc2d765 | 1006 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1007 | int idx_ipv4 = 2; |
718e3744 | 1008 | int ret; |
718e3744 | 1009 | struct in_addr cluster; |
1010 | ||
c500ae40 | 1011 | ret = inet_aton (argv[idx_ipv4]->arg, &cluster); |
718e3744 | 1012 | if (! ret) |
1013 | { | |
1014 | vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE); | |
1015 | return CMD_WARNING; | |
1016 | } | |
1017 | ||
1018 | bgp_cluster_id_set (bgp, &cluster); | |
f31fa004 | 1019 | bgp_clear_star_soft_out (vty, bgp->name); |
718e3744 | 1020 | |
1021 | return CMD_SUCCESS; | |
1022 | } | |
1023 | ||
718e3744 | 1024 | DEFUN (no_bgp_cluster_id, |
1025 | no_bgp_cluster_id_cmd, | |
c7178fe7 | 1026 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", |
718e3744 | 1027 | NO_STR |
1028 | BGP_STR | |
838758ac DW |
1029 | "Configure Route-Reflector Cluster-id\n" |
1030 | "Route-Reflector Cluster-id in IP address format\n" | |
1031 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1032 | { |
cdc2d765 | 1033 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1034 | bgp_cluster_id_unset (bgp); |
f31fa004 | 1035 | bgp_clear_star_soft_out (vty, bgp->name); |
718e3744 | 1036 | |
1037 | return CMD_SUCCESS; | |
1038 | } | |
1039 | ||
718e3744 | 1040 | DEFUN (bgp_confederation_identifier, |
1041 | bgp_confederation_identifier_cmd, | |
9ccf14f7 | 1042 | "bgp confederation identifier (1-4294967295)", |
718e3744 | 1043 | "BGP specific commands\n" |
1044 | "AS confederation parameters\n" | |
1045 | "AS number\n" | |
1046 | "Set routing domain confederation AS\n") | |
1047 | { | |
cdc2d765 | 1048 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1049 | int idx_number = 3; |
718e3744 | 1050 | as_t as; |
1051 | ||
c500ae40 | 1052 | VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); |
718e3744 | 1053 | |
1054 | bgp_confederation_id_set (bgp, as); | |
1055 | ||
1056 | return CMD_SUCCESS; | |
1057 | } | |
1058 | ||
1059 | DEFUN (no_bgp_confederation_identifier, | |
1060 | no_bgp_confederation_identifier_cmd, | |
838758ac | 1061 | "no bgp confederation identifier [(1-4294967295)]", |
718e3744 | 1062 | NO_STR |
1063 | "BGP specific commands\n" | |
1064 | "AS confederation parameters\n" | |
3a2d747c QY |
1065 | "AS number\n" |
1066 | "Set routing domain confederation AS\n") | |
718e3744 | 1067 | { |
cdc2d765 | 1068 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1069 | bgp_confederation_id_unset (bgp); |
1070 | ||
1071 | return CMD_SUCCESS; | |
1072 | } | |
1073 | ||
718e3744 | 1074 | DEFUN (bgp_confederation_peers, |
1075 | bgp_confederation_peers_cmd, | |
12dcf78e | 1076 | "bgp confederation peers (1-4294967295)...", |
718e3744 | 1077 | "BGP specific commands\n" |
1078 | "AS confederation parameters\n" | |
1079 | "Peer ASs in BGP confederation\n" | |
1080 | AS_STR) | |
1081 | { | |
cdc2d765 | 1082 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
58749582 | 1083 | int idx_asn = 3; |
718e3744 | 1084 | as_t as; |
1085 | int i; | |
1086 | ||
58749582 | 1087 | for (i = idx_asn; i < argc; i++) |
718e3744 | 1088 | { |
afec25d9 | 1089 | VTY_GET_INTEGER_RANGE ("AS", as, argv[i]->arg, 1, BGP_AS4_MAX); |
718e3744 | 1090 | |
1091 | if (bgp->as == as) | |
1092 | { | |
1093 | vty_out (vty, "%% Local member-AS not allowed in confed peer list%s", | |
1094 | VTY_NEWLINE); | |
1095 | continue; | |
1096 | } | |
1097 | ||
1098 | bgp_confederation_peers_add (bgp, as); | |
1099 | } | |
1100 | return CMD_SUCCESS; | |
1101 | } | |
1102 | ||
1103 | DEFUN (no_bgp_confederation_peers, | |
1104 | no_bgp_confederation_peers_cmd, | |
e83a9414 | 1105 | "no bgp confederation peers (1-4294967295)...", |
718e3744 | 1106 | NO_STR |
1107 | "BGP specific commands\n" | |
1108 | "AS confederation parameters\n" | |
1109 | "Peer ASs in BGP confederation\n" | |
1110 | AS_STR) | |
1111 | { | |
cdc2d765 | 1112 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
58749582 | 1113 | int idx_asn = 4; |
718e3744 | 1114 | as_t as; |
1115 | int i; | |
1116 | ||
58749582 | 1117 | for (i = idx_asn; i < argc; i++) |
718e3744 | 1118 | { |
afec25d9 | 1119 | VTY_GET_INTEGER_RANGE ("AS", as, argv[i]->arg, 1, BGP_AS4_MAX); |
0b2aa3a0 | 1120 | |
718e3744 | 1121 | bgp_confederation_peers_remove (bgp, as); |
1122 | } | |
1123 | return CMD_SUCCESS; | |
1124 | } | |
6b0655a2 | 1125 | |
5e242b0d DS |
1126 | /** |
1127 | * Central routine for maximum-paths configuration. | |
1128 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1129 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1130 | */ | |
ffd0c037 DS |
1131 | static int |
1132 | bgp_maxpaths_config_vty (struct vty *vty, int peer_type, const char *mpaths, | |
5e242b0d | 1133 | u_int16_t options, int set) |
165b5fff | 1134 | { |
cdc2d765 | 1135 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4c9dee98 | 1136 | u_int16_t maxpaths = 0; |
165b5fff | 1137 | int ret; |
5e242b0d DS |
1138 | afi_t afi; |
1139 | safi_t safi; | |
165b5fff | 1140 | |
5e242b0d DS |
1141 | afi = bgp_node_afi (vty); |
1142 | safi = bgp_node_safi (vty); | |
165b5fff | 1143 | |
5e242b0d | 1144 | if (set) |
4c9dee98 | 1145 | { |
c59f2066 | 1146 | maxpaths = strtol(mpaths, NULL, 10); |
dff6764a | 1147 | ret = bgp_maximum_paths_set (bgp, afi, safi, peer_type, maxpaths, options); |
4c9dee98 | 1148 | } |
5e242b0d DS |
1149 | else |
1150 | ret = bgp_maximum_paths_unset (bgp, afi, safi, peer_type); | |
165b5fff | 1151 | |
165b5fff JB |
1152 | if (ret < 0) |
1153 | { | |
1154 | vty_out (vty, | |
5e242b0d DS |
1155 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u%s", |
1156 | (set == 1) ? "" : "un", | |
1157 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1158 | maxpaths, afi, safi, VTY_NEWLINE); | |
165b5fff JB |
1159 | return CMD_WARNING; |
1160 | } | |
1161 | ||
7aafcaca DS |
1162 | bgp_recalculate_all_bestpaths (bgp); |
1163 | ||
165b5fff JB |
1164 | return CMD_SUCCESS; |
1165 | } | |
1166 | ||
abc920f8 DS |
1167 | DEFUN (bgp_maxmed_admin, |
1168 | bgp_maxmed_admin_cmd, | |
1169 | "bgp max-med administrative ", | |
1170 | BGP_STR | |
1171 | "Advertise routes with max-med\n" | |
1172 | "Administratively applied, for an indefinite period\n") | |
1173 | { | |
cdc2d765 | 1174 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 DS |
1175 | |
1176 | bgp->v_maxmed_admin = 1; | |
1177 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1178 | ||
1179 | bgp_maxmed_update(bgp); | |
1180 | ||
1181 | return CMD_SUCCESS; | |
1182 | } | |
1183 | ||
1184 | DEFUN (bgp_maxmed_admin_medv, | |
1185 | bgp_maxmed_admin_medv_cmd, | |
6147e2c6 | 1186 | "bgp max-med administrative (0-4294967294)", |
abc920f8 DS |
1187 | BGP_STR |
1188 | "Advertise routes with max-med\n" | |
1189 | "Administratively applied, for an indefinite period\n" | |
1190 | "Max MED value to be used\n") | |
1191 | { | |
cdc2d765 | 1192 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1193 | int idx_number = 3; |
abc920f8 DS |
1194 | |
1195 | bgp->v_maxmed_admin = 1; | |
c500ae40 | 1196 | VTY_GET_INTEGER ("max-med admin med-value", bgp->maxmed_admin_value, argv[idx_number]->arg); |
abc920f8 DS |
1197 | |
1198 | bgp_maxmed_update(bgp); | |
1199 | ||
1200 | return CMD_SUCCESS; | |
1201 | } | |
1202 | ||
1203 | DEFUN (no_bgp_maxmed_admin, | |
1204 | no_bgp_maxmed_admin_cmd, | |
8334fd5a | 1205 | "no bgp max-med administrative [(0-4294967294)]", |
abc920f8 DS |
1206 | NO_STR |
1207 | BGP_STR | |
1208 | "Advertise routes with max-med\n" | |
838758ac DW |
1209 | "Administratively applied, for an indefinite period\n" |
1210 | "Max MED value to be used\n") | |
abc920f8 | 1211 | { |
cdc2d765 | 1212 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 DS |
1213 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; |
1214 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 DS |
1215 | bgp_maxmed_update(bgp); |
1216 | ||
1217 | return CMD_SUCCESS; | |
1218 | } | |
1219 | ||
abc920f8 DS |
1220 | DEFUN (bgp_maxmed_onstartup, |
1221 | bgp_maxmed_onstartup_cmd, | |
6147e2c6 | 1222 | "bgp max-med on-startup (5-86400)", |
abc920f8 DS |
1223 | BGP_STR |
1224 | "Advertise routes with max-med\n" | |
1225 | "Effective on a startup\n" | |
1226 | "Time (seconds) period for max-med\n") | |
1227 | { | |
cdc2d765 | 1228 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1229 | int idx_number = 3; |
c500ae40 | 1230 | VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[idx_number]->arg); |
abc920f8 | 1231 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; |
abc920f8 DS |
1232 | bgp_maxmed_update(bgp); |
1233 | ||
1234 | return CMD_SUCCESS; | |
1235 | } | |
1236 | ||
1237 | DEFUN (bgp_maxmed_onstartup_medv, | |
1238 | bgp_maxmed_onstartup_medv_cmd, | |
6147e2c6 | 1239 | "bgp max-med on-startup (5-86400) (0-4294967294)", |
abc920f8 DS |
1240 | BGP_STR |
1241 | "Advertise routes with max-med\n" | |
1242 | "Effective on a startup\n" | |
1243 | "Time (seconds) period for max-med\n" | |
1244 | "Max MED value to be used\n") | |
1245 | { | |
cdc2d765 | 1246 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
1247 | int idx_number = 3; |
1248 | int idx_number_2 = 4; | |
c500ae40 DW |
1249 | VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[idx_number]->arg); |
1250 | VTY_GET_INTEGER ("max-med on-startup med-value", bgp->maxmed_onstartup_value, argv[idx_number_2]->arg); | |
abc920f8 DS |
1251 | bgp_maxmed_update(bgp); |
1252 | ||
1253 | return CMD_SUCCESS; | |
1254 | } | |
1255 | ||
1256 | DEFUN (no_bgp_maxmed_onstartup, | |
1257 | no_bgp_maxmed_onstartup_cmd, | |
8334fd5a | 1258 | "no bgp max-med on-startup [(5-86400) [(0-4294967294)]]", |
abc920f8 DS |
1259 | NO_STR |
1260 | BGP_STR | |
1261 | "Advertise routes with max-med\n" | |
838758ac DW |
1262 | "Effective on a startup\n" |
1263 | "Time (seconds) period for max-med\n" | |
1264 | "Max MED value to be used\n") | |
abc920f8 | 1265 | { |
cdc2d765 | 1266 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 DS |
1267 | |
1268 | /* Cancel max-med onstartup if its on */ | |
1269 | if (bgp->t_maxmed_onstartup) | |
1270 | { | |
1271 | THREAD_TIMER_OFF (bgp->t_maxmed_onstartup); | |
1272 | bgp->maxmed_onstartup_over = 1; | |
1273 | } | |
1274 | ||
1275 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; | |
1276 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
1277 | ||
1278 | bgp_maxmed_update(bgp); | |
1279 | ||
1280 | return CMD_SUCCESS; | |
1281 | } | |
1282 | ||
f188f2c4 DS |
1283 | static int |
1284 | bgp_update_delay_config_vty (struct vty *vty, const char *delay, | |
1285 | const char *wait) | |
1286 | { | |
cdc2d765 | 1287 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 DS |
1288 | u_int16_t update_delay; |
1289 | u_int16_t establish_wait; | |
1290 | ||
f188f2c4 DS |
1291 | VTY_GET_INTEGER_RANGE ("update-delay", update_delay, delay, |
1292 | BGP_UPDATE_DELAY_MIN, BGP_UPDATE_DELAY_MAX); | |
1293 | ||
1294 | if (!wait) /* update-delay <delay> */ | |
1295 | { | |
1296 | bgp->v_update_delay = update_delay; | |
1297 | bgp->v_establish_wait = bgp->v_update_delay; | |
1298 | return CMD_SUCCESS; | |
1299 | } | |
1300 | ||
1301 | /* update-delay <delay> <establish-wait> */ | |
1302 | establish_wait = atoi (wait); | |
1303 | if (update_delay < establish_wait) | |
1304 | { | |
1305 | vty_out (vty, "%%Failed: update-delay less than the establish-wait!%s", | |
1306 | VTY_NEWLINE); | |
1307 | return CMD_WARNING; | |
1308 | } | |
1309 | ||
1310 | bgp->v_update_delay = update_delay; | |
1311 | bgp->v_establish_wait = establish_wait; | |
1312 | ||
1313 | return CMD_SUCCESS; | |
1314 | } | |
1315 | ||
1316 | static int | |
1317 | bgp_update_delay_deconfig_vty (struct vty *vty) | |
1318 | { | |
cdc2d765 | 1319 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 DS |
1320 | |
1321 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; | |
1322 | bgp->v_establish_wait = bgp->v_update_delay; | |
1323 | ||
1324 | return CMD_SUCCESS; | |
1325 | } | |
1326 | ||
1327 | int | |
1328 | bgp_config_write_update_delay (struct vty *vty, struct bgp *bgp) | |
1329 | { | |
1330 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) | |
1331 | { | |
1332 | vty_out (vty, " update-delay %d", bgp->v_update_delay); | |
1333 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1334 | vty_out (vty, " %d", bgp->v_establish_wait); | |
1335 | vty_out (vty, "%s", VTY_NEWLINE); | |
1336 | } | |
1337 | ||
1338 | return 0; | |
1339 | } | |
1340 | ||
1341 | ||
1342 | /* Update-delay configuration */ | |
1343 | DEFUN (bgp_update_delay, | |
1344 | bgp_update_delay_cmd, | |
6147e2c6 | 1345 | "update-delay (0-3600)", |
f188f2c4 DS |
1346 | "Force initial delay for best-path and updates\n" |
1347 | "Seconds\n") | |
1348 | { | |
c500ae40 DW |
1349 | int idx_number = 1; |
1350 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); | |
f188f2c4 DS |
1351 | } |
1352 | ||
1353 | DEFUN (bgp_update_delay_establish_wait, | |
1354 | bgp_update_delay_establish_wait_cmd, | |
6147e2c6 | 1355 | "update-delay (0-3600) (1-3600)", |
f188f2c4 DS |
1356 | "Force initial delay for best-path and updates\n" |
1357 | "Seconds\n" | |
1358 | "Wait for peers to be established\n" | |
1359 | "Seconds\n") | |
1360 | { | |
c500ae40 DW |
1361 | int idx_number = 1; |
1362 | int idx_number_2 = 2; | |
1363 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, argv[idx_number_2]->arg); | |
f188f2c4 DS |
1364 | } |
1365 | ||
1366 | /* Update-delay deconfiguration */ | |
1367 | DEFUN (no_bgp_update_delay, | |
1368 | no_bgp_update_delay_cmd, | |
838758ac DW |
1369 | "no update-delay [(0-3600) [(1-3600)]]", |
1370 | NO_STR | |
f188f2c4 | 1371 | "Force initial delay for best-path and updates\n" |
838758ac DW |
1372 | "Seconds\n" |
1373 | "Wait for peers to be established\n") | |
f188f2c4 DS |
1374 | { |
1375 | return bgp_update_delay_deconfig_vty(vty); | |
1376 | } | |
1377 | ||
5e242b0d | 1378 | |
ffd0c037 DS |
1379 | static int |
1380 | bgp_wpkt_quanta_config_vty (struct vty *vty, const char *num, char set) | |
cb1faec9 | 1381 | { |
cdc2d765 | 1382 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
cb1faec9 DS |
1383 | |
1384 | if (set) | |
1385 | VTY_GET_INTEGER_RANGE ("write-quanta", bgp->wpkt_quanta, num, | |
4543bbb4 | 1386 | 1, 10000); |
cb1faec9 DS |
1387 | else |
1388 | bgp->wpkt_quanta = BGP_WRITE_PACKET_MAX; | |
1389 | ||
1390 | return CMD_SUCCESS; | |
1391 | } | |
1392 | ||
1393 | int | |
1394 | bgp_config_write_wpkt_quanta (struct vty *vty, struct bgp *bgp) | |
1395 | { | |
1396 | if (bgp->wpkt_quanta != BGP_WRITE_PACKET_MAX) | |
1397 | vty_out (vty, " write-quanta %d%s", | |
1398 | bgp->wpkt_quanta, VTY_NEWLINE); | |
1399 | ||
1400 | return 0; | |
1401 | } | |
1402 | ||
1403 | ||
1404 | /* Update-delay configuration */ | |
1405 | DEFUN (bgp_wpkt_quanta, | |
1406 | bgp_wpkt_quanta_cmd, | |
6147e2c6 | 1407 | "write-quanta (1-10000)", |
cb1faec9 DS |
1408 | "How many packets to write to peer socket per run\n" |
1409 | "Number of packets\n") | |
1410 | { | |
c500ae40 DW |
1411 | int idx_number = 1; |
1412 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
cb1faec9 DS |
1413 | } |
1414 | ||
1415 | /* Update-delay deconfiguration */ | |
1416 | DEFUN (no_bgp_wpkt_quanta, | |
1417 | no_bgp_wpkt_quanta_cmd, | |
6147e2c6 | 1418 | "no write-quanta (1-10000)", |
d7fa34c1 | 1419 | NO_STR |
cb1faec9 DS |
1420 | "How many packets to write to peer socket per run\n" |
1421 | "Number of packets\n") | |
1422 | { | |
c500ae40 DW |
1423 | int idx_number = 2; |
1424 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
cb1faec9 DS |
1425 | } |
1426 | ||
ffd0c037 | 1427 | static int |
3f9c7369 DS |
1428 | bgp_coalesce_config_vty (struct vty *vty, const char *num, char set) |
1429 | { | |
cdc2d765 | 1430 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3f9c7369 DS |
1431 | |
1432 | if (set) | |
1433 | VTY_GET_INTEGER_RANGE ("coalesce-time", bgp->coalesce_time, num, | |
1434 | 0, 4294967295); | |
1435 | else | |
1436 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; | |
1437 | ||
1438 | return CMD_SUCCESS; | |
1439 | } | |
1440 | ||
1441 | int | |
1442 | bgp_config_write_coalesce_time (struct vty *vty, struct bgp *bgp) | |
1443 | { | |
1444 | if (bgp->coalesce_time != BGP_DEFAULT_SUBGROUP_COALESCE_TIME) | |
1445 | vty_out (vty, " coalesce-time %d%s", | |
1446 | bgp->coalesce_time, VTY_NEWLINE); | |
1447 | ||
1448 | return 0; | |
1449 | } | |
1450 | ||
1451 | ||
1452 | DEFUN (bgp_coalesce_time, | |
1453 | bgp_coalesce_time_cmd, | |
6147e2c6 | 1454 | "coalesce-time (0-4294967295)", |
3f9c7369 DS |
1455 | "Subgroup coalesce timer\n" |
1456 | "Subgroup coalesce timer value (in ms)\n") | |
1457 | { | |
c500ae40 DW |
1458 | int idx_number = 1; |
1459 | return bgp_coalesce_config_vty(vty, argv[idx_number]->arg, 1); | |
3f9c7369 DS |
1460 | } |
1461 | ||
1462 | DEFUN (no_bgp_coalesce_time, | |
1463 | no_bgp_coalesce_time_cmd, | |
6147e2c6 | 1464 | "no coalesce-time (0-4294967295)", |
3a2d747c | 1465 | NO_STR |
3f9c7369 DS |
1466 | "Subgroup coalesce timer\n" |
1467 | "Subgroup coalesce timer value (in ms)\n") | |
1468 | { | |
c500ae40 DW |
1469 | int idx_number = 2; |
1470 | return bgp_coalesce_config_vty(vty, argv[idx_number]->arg, 0); | |
3f9c7369 DS |
1471 | } |
1472 | ||
5e242b0d DS |
1473 | /* Maximum-paths configuration */ |
1474 | DEFUN (bgp_maxpaths, | |
1475 | bgp_maxpaths_cmd, | |
9ccf14f7 | 1476 | "maximum-paths (1-255)", |
5e242b0d DS |
1477 | "Forward packets over multiple paths\n" |
1478 | "Number of paths\n") | |
1479 | { | |
c500ae40 DW |
1480 | int idx_number = 1; |
1481 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
1482 | } |
1483 | ||
165b5fff JB |
1484 | DEFUN (bgp_maxpaths_ibgp, |
1485 | bgp_maxpaths_ibgp_cmd, | |
9ccf14f7 | 1486 | "maximum-paths ibgp (1-255)", |
165b5fff JB |
1487 | "Forward packets over multiple paths\n" |
1488 | "iBGP-multipath\n" | |
1489 | "Number of paths\n") | |
1490 | { | |
c500ae40 DW |
1491 | int idx_number = 2; |
1492 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[idx_number]->arg, 0, 1); | |
5e242b0d | 1493 | } |
165b5fff | 1494 | |
5e242b0d DS |
1495 | DEFUN (bgp_maxpaths_ibgp_cluster, |
1496 | bgp_maxpaths_ibgp_cluster_cmd, | |
9ccf14f7 | 1497 | "maximum-paths ibgp (1-255) equal-cluster-length", |
5e242b0d DS |
1498 | "Forward packets over multiple paths\n" |
1499 | "iBGP-multipath\n" | |
1500 | "Number of paths\n" | |
1501 | "Match the cluster length\n") | |
1502 | { | |
c500ae40 DW |
1503 | int idx_number = 2; |
1504 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
5e242b0d | 1505 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); |
165b5fff JB |
1506 | } |
1507 | ||
1508 | DEFUN (no_bgp_maxpaths, | |
1509 | no_bgp_maxpaths_cmd, | |
9ccf14f7 | 1510 | "no maximum-paths [(1-255)]", |
165b5fff JB |
1511 | NO_STR |
1512 | "Forward packets over multiple paths\n" | |
1513 | "Number of paths\n") | |
1514 | { | |
5e242b0d | 1515 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
1516 | } |
1517 | ||
165b5fff JB |
1518 | DEFUN (no_bgp_maxpaths_ibgp, |
1519 | no_bgp_maxpaths_ibgp_cmd, | |
9ccf14f7 | 1520 | "no maximum-paths ibgp [(1-255) [equal-cluster-length]]", |
165b5fff JB |
1521 | NO_STR |
1522 | "Forward packets over multiple paths\n" | |
1523 | "iBGP-multipath\n" | |
838758ac DW |
1524 | "Number of paths\n" |
1525 | "Match the cluster length\n") | |
165b5fff | 1526 | { |
5e242b0d | 1527 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1528 | } |
1529 | ||
165b5fff JB |
1530 | int |
1531 | bgp_config_write_maxpaths (struct vty *vty, struct bgp *bgp, afi_t afi, | |
1532 | safi_t safi, int *write) | |
1533 | { | |
d5b77cc2 | 1534 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) |
165b5fff JB |
1535 | { |
1536 | bgp_config_write_family_header (vty, afi, safi, write); | |
0b960b4d | 1537 | vty_out (vty, " maximum-paths %d%s", |
165b5fff JB |
1538 | bgp->maxpaths[afi][safi].maxpaths_ebgp, VTY_NEWLINE); |
1539 | } | |
1540 | ||
d5b77cc2 | 1541 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) |
165b5fff JB |
1542 | { |
1543 | bgp_config_write_family_header (vty, afi, safi, write); | |
0b960b4d | 1544 | vty_out (vty, " maximum-paths ibgp %d", |
5e242b0d DS |
1545 | bgp->maxpaths[afi][safi].maxpaths_ibgp); |
1546 | if (CHECK_FLAG (bgp->maxpaths[afi][safi].ibgp_flags, | |
1547 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1548 | vty_out (vty, " equal-cluster-length"); | |
1549 | vty_out (vty, "%s", VTY_NEWLINE); | |
165b5fff JB |
1550 | } |
1551 | ||
1552 | return 0; | |
1553 | } | |
6b0655a2 | 1554 | |
718e3744 | 1555 | /* BGP timers. */ |
1556 | ||
1557 | DEFUN (bgp_timers, | |
1558 | bgp_timers_cmd, | |
6147e2c6 | 1559 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1560 | "Adjust routing timers\n" |
1561 | "BGP timers\n" | |
1562 | "Keepalive interval\n" | |
1563 | "Holdtime\n") | |
1564 | { | |
cdc2d765 | 1565 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
1566 | int idx_number = 2; |
1567 | int idx_number_2 = 3; | |
718e3744 | 1568 | unsigned long keepalive = 0; |
1569 | unsigned long holdtime = 0; | |
1570 | ||
c500ae40 DW |
1571 | VTY_GET_INTEGER ("keepalive", keepalive, argv[idx_number]->arg); |
1572 | VTY_GET_INTEGER ("holdtime", holdtime, argv[idx_number_2]->arg); | |
718e3744 | 1573 | |
1574 | /* Holdtime value check. */ | |
1575 | if (holdtime < 3 && holdtime != 0) | |
1576 | { | |
1577 | vty_out (vty, "%% hold time value must be either 0 or greater than 3%s", | |
1578 | VTY_NEWLINE); | |
1579 | return CMD_WARNING; | |
1580 | } | |
1581 | ||
1582 | bgp_timers_set (bgp, keepalive, holdtime); | |
1583 | ||
1584 | return CMD_SUCCESS; | |
1585 | } | |
1586 | ||
1587 | DEFUN (no_bgp_timers, | |
1588 | no_bgp_timers_cmd, | |
838758ac | 1589 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1590 | NO_STR |
1591 | "Adjust routing timers\n" | |
838758ac DW |
1592 | "BGP timers\n" |
1593 | "Keepalive interval\n" | |
1594 | "Holdtime\n") | |
718e3744 | 1595 | { |
cdc2d765 | 1596 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1597 | bgp_timers_unset (bgp); |
1598 | ||
1599 | return CMD_SUCCESS; | |
1600 | } | |
1601 | ||
6b0655a2 | 1602 | |
718e3744 | 1603 | DEFUN (bgp_client_to_client_reflection, |
1604 | bgp_client_to_client_reflection_cmd, | |
1605 | "bgp client-to-client reflection", | |
1606 | "BGP specific commands\n" | |
1607 | "Configure client to client route reflection\n" | |
1608 | "reflection of routes allowed\n") | |
1609 | { | |
cdc2d765 | 1610 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1611 | bgp_flag_unset (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); |
f31fa004 | 1612 | bgp_clear_star_soft_out (vty, bgp->name); |
7aafcaca | 1613 | |
718e3744 | 1614 | return CMD_SUCCESS; |
1615 | } | |
1616 | ||
1617 | DEFUN (no_bgp_client_to_client_reflection, | |
1618 | no_bgp_client_to_client_reflection_cmd, | |
1619 | "no bgp client-to-client reflection", | |
1620 | NO_STR | |
1621 | "BGP specific commands\n" | |
1622 | "Configure client to client route reflection\n" | |
1623 | "reflection of routes allowed\n") | |
1624 | { | |
cdc2d765 | 1625 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1626 | bgp_flag_set (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); |
f31fa004 | 1627 | bgp_clear_star_soft_out (vty, bgp->name); |
7aafcaca | 1628 | |
718e3744 | 1629 | return CMD_SUCCESS; |
1630 | } | |
1631 | ||
1632 | /* "bgp always-compare-med" configuration. */ | |
1633 | DEFUN (bgp_always_compare_med, | |
1634 | bgp_always_compare_med_cmd, | |
1635 | "bgp always-compare-med", | |
1636 | "BGP specific commands\n" | |
1637 | "Allow comparing MED from different neighbors\n") | |
1638 | { | |
cdc2d765 | 1639 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1640 | bgp_flag_set (bgp, BGP_FLAG_ALWAYS_COMPARE_MED); |
7aafcaca DS |
1641 | bgp_recalculate_all_bestpaths (bgp); |
1642 | ||
718e3744 | 1643 | return CMD_SUCCESS; |
1644 | } | |
1645 | ||
1646 | DEFUN (no_bgp_always_compare_med, | |
1647 | no_bgp_always_compare_med_cmd, | |
1648 | "no bgp always-compare-med", | |
1649 | NO_STR | |
1650 | "BGP specific commands\n" | |
1651 | "Allow comparing MED from different neighbors\n") | |
1652 | { | |
cdc2d765 | 1653 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1654 | bgp_flag_unset (bgp, BGP_FLAG_ALWAYS_COMPARE_MED); |
7aafcaca DS |
1655 | bgp_recalculate_all_bestpaths (bgp); |
1656 | ||
718e3744 | 1657 | return CMD_SUCCESS; |
1658 | } | |
6b0655a2 | 1659 | |
718e3744 | 1660 | /* "bgp deterministic-med" configuration. */ |
1661 | DEFUN (bgp_deterministic_med, | |
1662 | bgp_deterministic_med_cmd, | |
1663 | "bgp deterministic-med", | |
1664 | "BGP specific commands\n" | |
1665 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1666 | { | |
cdc2d765 | 1667 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1475ac87 DW |
1668 | |
1669 | if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) | |
1670 | { | |
1671 | bgp_flag_set (bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1672 | bgp_recalculate_all_bestpaths (bgp); | |
1673 | } | |
7aafcaca | 1674 | |
718e3744 | 1675 | return CMD_SUCCESS; |
1676 | } | |
1677 | ||
1678 | DEFUN (no_bgp_deterministic_med, | |
1679 | no_bgp_deterministic_med_cmd, | |
1680 | "no bgp deterministic-med", | |
1681 | NO_STR | |
1682 | "BGP specific commands\n" | |
1683 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1684 | { | |
cdc2d765 | 1685 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
06370dac DW |
1686 | int bestpath_per_as_used; |
1687 | afi_t afi; | |
1688 | safi_t safi; | |
1689 | struct peer *peer; | |
1690 | struct listnode *node, *nnode; | |
718e3744 | 1691 | |
1475ac87 DW |
1692 | if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) |
1693 | { | |
06370dac DW |
1694 | bestpath_per_as_used = 0; |
1695 | ||
1696 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
1697 | { | |
1698 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
1699 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
1700 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) | |
1701 | { | |
1702 | bestpath_per_as_used = 1; | |
1703 | break; | |
1704 | } | |
1705 | ||
1706 | if (bestpath_per_as_used) | |
1707 | break; | |
1708 | } | |
1709 | ||
1710 | if (bestpath_per_as_used) | |
1711 | { | |
1712 | vty_out (vty, "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use%s", | |
1713 | VTY_NEWLINE); | |
1714 | return CMD_WARNING; | |
1715 | } | |
1716 | else | |
1717 | { | |
1718 | bgp_flag_unset (bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1719 | bgp_recalculate_all_bestpaths (bgp); | |
1720 | } | |
1475ac87 | 1721 | } |
7aafcaca | 1722 | |
718e3744 | 1723 | return CMD_SUCCESS; |
1724 | } | |
538621f2 | 1725 | |
1726 | /* "bgp graceful-restart" configuration. */ | |
1727 | DEFUN (bgp_graceful_restart, | |
1728 | bgp_graceful_restart_cmd, | |
1729 | "bgp graceful-restart", | |
1730 | "BGP specific commands\n" | |
1731 | "Graceful restart capability parameters\n") | |
1732 | { | |
cdc2d765 | 1733 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
538621f2 | 1734 | bgp_flag_set (bgp, BGP_FLAG_GRACEFUL_RESTART); |
1735 | return CMD_SUCCESS; | |
1736 | } | |
1737 | ||
1738 | DEFUN (no_bgp_graceful_restart, | |
1739 | no_bgp_graceful_restart_cmd, | |
1740 | "no bgp graceful-restart", | |
1741 | NO_STR | |
1742 | "BGP specific commands\n" | |
1743 | "Graceful restart capability parameters\n") | |
1744 | { | |
cdc2d765 | 1745 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
538621f2 | 1746 | bgp_flag_unset (bgp, BGP_FLAG_GRACEFUL_RESTART); |
1747 | return CMD_SUCCESS; | |
1748 | } | |
1749 | ||
93406d87 | 1750 | DEFUN (bgp_graceful_restart_stalepath_time, |
1751 | bgp_graceful_restart_stalepath_time_cmd, | |
6147e2c6 | 1752 | "bgp graceful-restart stalepath-time (1-3600)", |
93406d87 | 1753 | "BGP specific commands\n" |
1754 | "Graceful restart capability parameters\n" | |
1755 | "Set the max time to hold onto restarting peer's stale paths\n" | |
1756 | "Delay value (seconds)\n") | |
1757 | { | |
cdc2d765 | 1758 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1759 | int idx_number = 3; |
93406d87 | 1760 | u_int32_t stalepath; |
1761 | ||
c500ae40 | 1762 | VTY_GET_INTEGER_RANGE ("stalepath-time", stalepath, argv[idx_number]->arg, 1, 3600); |
93406d87 | 1763 | bgp->stalepath_time = stalepath; |
1764 | return CMD_SUCCESS; | |
1765 | } | |
1766 | ||
eb6f1b41 PG |
1767 | DEFUN (bgp_graceful_restart_restart_time, |
1768 | bgp_graceful_restart_restart_time_cmd, | |
6147e2c6 | 1769 | "bgp graceful-restart restart-time (1-3600)", |
eb6f1b41 PG |
1770 | "BGP specific commands\n" |
1771 | "Graceful restart capability parameters\n" | |
1772 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
1773 | "Delay value (seconds)\n") | |
1774 | { | |
cdc2d765 | 1775 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1776 | int idx_number = 3; |
eb6f1b41 PG |
1777 | u_int32_t restart; |
1778 | ||
c500ae40 | 1779 | VTY_GET_INTEGER_RANGE ("restart-time", restart, argv[idx_number]->arg, 1, 3600); |
eb6f1b41 PG |
1780 | bgp->restart_time = restart; |
1781 | return CMD_SUCCESS; | |
1782 | } | |
1783 | ||
93406d87 | 1784 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
1785 | no_bgp_graceful_restart_stalepath_time_cmd, | |
838758ac | 1786 | "no bgp graceful-restart stalepath-time [(1-3600)]", |
93406d87 | 1787 | NO_STR |
1788 | "BGP specific commands\n" | |
1789 | "Graceful restart capability parameters\n" | |
838758ac DW |
1790 | "Set the max time to hold onto restarting peer's stale paths\n" |
1791 | "Delay value (seconds)\n") | |
93406d87 | 1792 | { |
cdc2d765 | 1793 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 1794 | |
1795 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; | |
1796 | return CMD_SUCCESS; | |
1797 | } | |
1798 | ||
eb6f1b41 PG |
1799 | DEFUN (no_bgp_graceful_restart_restart_time, |
1800 | no_bgp_graceful_restart_restart_time_cmd, | |
838758ac | 1801 | "no bgp graceful-restart restart-time [(1-3600)]", |
eb6f1b41 PG |
1802 | NO_STR |
1803 | "BGP specific commands\n" | |
1804 | "Graceful restart capability parameters\n" | |
838758ac DW |
1805 | "Set the time to wait to delete stale routes before a BGP open message is received\n" |
1806 | "Delay value (seconds)\n") | |
eb6f1b41 | 1807 | { |
cdc2d765 | 1808 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 PG |
1809 | |
1810 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; | |
1811 | return CMD_SUCCESS; | |
1812 | } | |
1813 | ||
43fc21b3 JC |
1814 | DEFUN (bgp_graceful_restart_preserve_fw, |
1815 | bgp_graceful_restart_preserve_fw_cmd, | |
1816 | "bgp graceful-restart preserve-fw-state", | |
1817 | "BGP specific commands\n" | |
1818 | "Graceful restart capability parameters\n" | |
1819 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1820 | { | |
1821 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1822 | bgp_flag_set(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1823 | return CMD_SUCCESS; | |
1824 | } | |
1825 | ||
1826 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
1827 | no_bgp_graceful_restart_preserve_fw_cmd, | |
1828 | "no bgp graceful-restart preserve-fw-state", | |
1829 | NO_STR | |
1830 | "BGP specific commands\n" | |
1831 | "Graceful restart capability parameters\n" | |
1832 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1833 | { | |
1834 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1835 | bgp_flag_unset(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1836 | return CMD_SUCCESS; | |
1837 | } | |
1838 | ||
718e3744 | 1839 | /* "bgp fast-external-failover" configuration. */ |
1840 | DEFUN (bgp_fast_external_failover, | |
1841 | bgp_fast_external_failover_cmd, | |
1842 | "bgp fast-external-failover", | |
1843 | BGP_STR | |
1844 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
1845 | { | |
cdc2d765 | 1846 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1847 | bgp_flag_unset (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); |
1848 | return CMD_SUCCESS; | |
1849 | } | |
1850 | ||
1851 | DEFUN (no_bgp_fast_external_failover, | |
1852 | no_bgp_fast_external_failover_cmd, | |
1853 | "no bgp fast-external-failover", | |
1854 | NO_STR | |
1855 | BGP_STR | |
1856 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
1857 | { | |
cdc2d765 | 1858 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1859 | bgp_flag_set (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); |
1860 | return CMD_SUCCESS; | |
1861 | } | |
6b0655a2 | 1862 | |
718e3744 | 1863 | /* "bgp enforce-first-as" configuration. */ |
1864 | DEFUN (bgp_enforce_first_as, | |
1865 | bgp_enforce_first_as_cmd, | |
1866 | "bgp enforce-first-as", | |
1867 | BGP_STR | |
1868 | "Enforce the first AS for EBGP routes\n") | |
1869 | { | |
cdc2d765 | 1870 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1871 | bgp_flag_set (bgp, BGP_FLAG_ENFORCE_FIRST_AS); |
f31fa004 | 1872 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 1873 | |
718e3744 | 1874 | return CMD_SUCCESS; |
1875 | } | |
1876 | ||
1877 | DEFUN (no_bgp_enforce_first_as, | |
1878 | no_bgp_enforce_first_as_cmd, | |
1879 | "no bgp enforce-first-as", | |
1880 | NO_STR | |
1881 | BGP_STR | |
1882 | "Enforce the first AS for EBGP routes\n") | |
1883 | { | |
cdc2d765 | 1884 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1885 | bgp_flag_unset (bgp, BGP_FLAG_ENFORCE_FIRST_AS); |
f31fa004 | 1886 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 1887 | |
718e3744 | 1888 | return CMD_SUCCESS; |
1889 | } | |
6b0655a2 | 1890 | |
718e3744 | 1891 | /* "bgp bestpath compare-routerid" configuration. */ |
1892 | DEFUN (bgp_bestpath_compare_router_id, | |
1893 | bgp_bestpath_compare_router_id_cmd, | |
1894 | "bgp bestpath compare-routerid", | |
1895 | "BGP specific commands\n" | |
1896 | "Change the default bestpath selection\n" | |
1897 | "Compare router-id for identical EBGP paths\n") | |
1898 | { | |
cdc2d765 | 1899 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1900 | bgp_flag_set (bgp, BGP_FLAG_COMPARE_ROUTER_ID); |
7aafcaca DS |
1901 | bgp_recalculate_all_bestpaths (bgp); |
1902 | ||
718e3744 | 1903 | return CMD_SUCCESS; |
1904 | } | |
1905 | ||
1906 | DEFUN (no_bgp_bestpath_compare_router_id, | |
1907 | no_bgp_bestpath_compare_router_id_cmd, | |
1908 | "no bgp bestpath compare-routerid", | |
1909 | NO_STR | |
1910 | "BGP specific commands\n" | |
1911 | "Change the default bestpath selection\n" | |
1912 | "Compare router-id for identical EBGP paths\n") | |
1913 | { | |
cdc2d765 | 1914 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1915 | bgp_flag_unset (bgp, BGP_FLAG_COMPARE_ROUTER_ID); |
7aafcaca DS |
1916 | bgp_recalculate_all_bestpaths (bgp); |
1917 | ||
718e3744 | 1918 | return CMD_SUCCESS; |
1919 | } | |
6b0655a2 | 1920 | |
718e3744 | 1921 | /* "bgp bestpath as-path ignore" configuration. */ |
1922 | DEFUN (bgp_bestpath_aspath_ignore, | |
1923 | bgp_bestpath_aspath_ignore_cmd, | |
1924 | "bgp bestpath as-path ignore", | |
1925 | "BGP specific commands\n" | |
1926 | "Change the default bestpath selection\n" | |
1927 | "AS-path attribute\n" | |
1928 | "Ignore as-path length in selecting a route\n") | |
1929 | { | |
cdc2d765 | 1930 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1931 | bgp_flag_set (bgp, BGP_FLAG_ASPATH_IGNORE); |
7aafcaca DS |
1932 | bgp_recalculate_all_bestpaths (bgp); |
1933 | ||
718e3744 | 1934 | return CMD_SUCCESS; |
1935 | } | |
1936 | ||
1937 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
1938 | no_bgp_bestpath_aspath_ignore_cmd, | |
1939 | "no bgp bestpath as-path ignore", | |
1940 | NO_STR | |
1941 | "BGP specific commands\n" | |
1942 | "Change the default bestpath selection\n" | |
1943 | "AS-path attribute\n" | |
1944 | "Ignore as-path length in selecting a route\n") | |
1945 | { | |
cdc2d765 | 1946 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1947 | bgp_flag_unset (bgp, BGP_FLAG_ASPATH_IGNORE); |
7aafcaca DS |
1948 | bgp_recalculate_all_bestpaths (bgp); |
1949 | ||
718e3744 | 1950 | return CMD_SUCCESS; |
1951 | } | |
6b0655a2 | 1952 | |
6811845b | 1953 | /* "bgp bestpath as-path confed" configuration. */ |
1954 | DEFUN (bgp_bestpath_aspath_confed, | |
1955 | bgp_bestpath_aspath_confed_cmd, | |
1956 | "bgp bestpath as-path confed", | |
1957 | "BGP specific commands\n" | |
1958 | "Change the default bestpath selection\n" | |
1959 | "AS-path attribute\n" | |
1960 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
1961 | { | |
cdc2d765 | 1962 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6811845b | 1963 | bgp_flag_set (bgp, BGP_FLAG_ASPATH_CONFED); |
7aafcaca DS |
1964 | bgp_recalculate_all_bestpaths (bgp); |
1965 | ||
6811845b | 1966 | return CMD_SUCCESS; |
1967 | } | |
1968 | ||
1969 | DEFUN (no_bgp_bestpath_aspath_confed, | |
1970 | no_bgp_bestpath_aspath_confed_cmd, | |
1971 | "no bgp bestpath as-path confed", | |
1972 | NO_STR | |
1973 | "BGP specific commands\n" | |
1974 | "Change the default bestpath selection\n" | |
1975 | "AS-path attribute\n" | |
1976 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
1977 | { | |
cdc2d765 | 1978 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6811845b | 1979 | bgp_flag_unset (bgp, BGP_FLAG_ASPATH_CONFED); |
7aafcaca DS |
1980 | bgp_recalculate_all_bestpaths (bgp); |
1981 | ||
6811845b | 1982 | return CMD_SUCCESS; |
1983 | } | |
6b0655a2 | 1984 | |
2fdd455c PM |
1985 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
1986 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
1987 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 1988 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
1989 | "BGP specific commands\n" |
1990 | "Change the default bestpath selection\n" | |
1991 | "AS-path attribute\n" | |
1992 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 1993 | "Generate an AS_SET\n" |
16fc1eec DS |
1994 | "Do not generate an AS_SET\n") |
1995 | { | |
cdc2d765 | 1996 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4c4ff4c1 | 1997 | int idx = 0; |
16fc1eec | 1998 | bgp_flag_set (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); |
219178b6 DW |
1999 | |
2000 | /* no-as-set is now the default behavior so we can silently | |
2001 | * ignore it */ | |
4c4ff4c1 | 2002 | if (argv_find (argv, argc, "as-set", &idx)) |
219178b6 DW |
2003 | bgp_flag_set (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
2004 | else | |
2005 | bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET) ; | |
2006 | ||
7aafcaca DS |
2007 | bgp_recalculate_all_bestpaths (bgp); |
2008 | ||
16fc1eec DS |
2009 | return CMD_SUCCESS; |
2010 | } | |
2011 | ||
219178b6 DW |
2012 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
2013 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2014 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2015 | NO_STR |
2016 | "BGP specific commands\n" | |
2017 | "Change the default bestpath selection\n" | |
2018 | "AS-path attribute\n" | |
2019 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2020 | "Generate an AS_SET\n" |
16fc1eec DS |
2021 | "Do not generate an AS_SET\n") |
2022 | { | |
cdc2d765 | 2023 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
16fc1eec | 2024 | bgp_flag_unset (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); |
219178b6 | 2025 | bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
7aafcaca DS |
2026 | bgp_recalculate_all_bestpaths (bgp); |
2027 | ||
2fdd455c PM |
2028 | return CMD_SUCCESS; |
2029 | } | |
6b0655a2 | 2030 | |
848973c7 | 2031 | /* "bgp log-neighbor-changes" configuration. */ |
2032 | DEFUN (bgp_log_neighbor_changes, | |
2033 | bgp_log_neighbor_changes_cmd, | |
2034 | "bgp log-neighbor-changes", | |
2035 | "BGP specific commands\n" | |
2036 | "Log neighbor up/down and reset reason\n") | |
2037 | { | |
cdc2d765 | 2038 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
848973c7 | 2039 | bgp_flag_set (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
2040 | return CMD_SUCCESS; | |
2041 | } | |
2042 | ||
2043 | DEFUN (no_bgp_log_neighbor_changes, | |
2044 | no_bgp_log_neighbor_changes_cmd, | |
2045 | "no bgp log-neighbor-changes", | |
2046 | NO_STR | |
2047 | "BGP specific commands\n" | |
2048 | "Log neighbor up/down and reset reason\n") | |
2049 | { | |
cdc2d765 | 2050 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
848973c7 | 2051 | bgp_flag_unset (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
2052 | return CMD_SUCCESS; | |
2053 | } | |
6b0655a2 | 2054 | |
718e3744 | 2055 | /* "bgp bestpath med" configuration. */ |
2056 | DEFUN (bgp_bestpath_med, | |
2057 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 2058 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2059 | "BGP specific commands\n" |
2060 | "Change the default bestpath selection\n" | |
2061 | "MED attribute\n" | |
2062 | "Compare MED among confederation paths\n" | |
838758ac DW |
2063 | "Treat missing MED as the least preferred one\n" |
2064 | "Treat missing MED as the least preferred one\n" | |
2065 | "Compare MED among confederation paths\n") | |
718e3744 | 2066 | { |
cdc2d765 | 2067 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6cbd1915 QY |
2068 | |
2069 | int idx = 0; | |
2070 | if (argv_find (argv, argc, "confed", &idx)) | |
2071 | bgp_flag_set (bgp, BGP_FLAG_MED_CONFED); | |
2072 | idx = 0; | |
2073 | if (argv_find (argv, argc, "missing-as-worst", &idx)) | |
2074 | bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
e52702f2 | 2075 | |
7aafcaca DS |
2076 | bgp_recalculate_all_bestpaths (bgp); |
2077 | ||
718e3744 | 2078 | return CMD_SUCCESS; |
2079 | } | |
2080 | ||
718e3744 | 2081 | DEFUN (no_bgp_bestpath_med, |
2082 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2083 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2084 | NO_STR |
2085 | "BGP specific commands\n" | |
2086 | "Change the default bestpath selection\n" | |
2087 | "MED attribute\n" | |
2088 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2089 | "Treat missing MED as the least preferred one\n" |
2090 | "Treat missing MED as the least preferred one\n" | |
2091 | "Compare MED among confederation paths\n") | |
718e3744 | 2092 | { |
cdc2d765 | 2093 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
e52702f2 | 2094 | |
6cbd1915 QY |
2095 | int idx = 0; |
2096 | if (argv_find (argv, argc, "confed", &idx)) | |
718e3744 | 2097 | bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED); |
6cbd1915 QY |
2098 | idx = 0; |
2099 | if (argv_find (argv, argc, "missing-as-worst", &idx)) | |
718e3744 | 2100 | bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST); |
2101 | ||
7aafcaca DS |
2102 | bgp_recalculate_all_bestpaths (bgp); |
2103 | ||
718e3744 | 2104 | return CMD_SUCCESS; |
2105 | } | |
2106 | ||
718e3744 | 2107 | /* "no bgp default ipv4-unicast". */ |
2108 | DEFUN (no_bgp_default_ipv4_unicast, | |
2109 | no_bgp_default_ipv4_unicast_cmd, | |
2110 | "no bgp default ipv4-unicast", | |
2111 | NO_STR | |
2112 | "BGP specific commands\n" | |
2113 | "Configure BGP defaults\n" | |
2114 | "Activate ipv4-unicast for a peer by default\n") | |
2115 | { | |
cdc2d765 | 2116 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2117 | bgp_flag_set (bgp, BGP_FLAG_NO_DEFAULT_IPV4); |
2118 | return CMD_SUCCESS; | |
2119 | } | |
2120 | ||
2121 | DEFUN (bgp_default_ipv4_unicast, | |
2122 | bgp_default_ipv4_unicast_cmd, | |
2123 | "bgp default ipv4-unicast", | |
2124 | "BGP specific commands\n" | |
2125 | "Configure BGP defaults\n" | |
2126 | "Activate ipv4-unicast for a peer by default\n") | |
2127 | { | |
cdc2d765 | 2128 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2129 | bgp_flag_unset (bgp, BGP_FLAG_NO_DEFAULT_IPV4); |
2130 | return CMD_SUCCESS; | |
2131 | } | |
6b0655a2 | 2132 | |
04b6bdc0 DW |
2133 | /* Display hostname in certain command outputs */ |
2134 | DEFUN (bgp_default_show_hostname, | |
2135 | bgp_default_show_hostname_cmd, | |
2136 | "bgp default show-hostname", | |
2137 | "BGP specific commands\n" | |
2138 | "Configure BGP defaults\n" | |
2139 | "Show hostname in certain command ouputs\n") | |
2140 | { | |
cdc2d765 | 2141 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
04b6bdc0 DW |
2142 | bgp_flag_set (bgp, BGP_FLAG_SHOW_HOSTNAME); |
2143 | return CMD_SUCCESS; | |
2144 | } | |
2145 | ||
2146 | DEFUN (no_bgp_default_show_hostname, | |
2147 | no_bgp_default_show_hostname_cmd, | |
2148 | "no bgp default show-hostname", | |
2149 | NO_STR | |
2150 | "BGP specific commands\n" | |
2151 | "Configure BGP defaults\n" | |
2152 | "Show hostname in certain command ouputs\n") | |
2153 | { | |
cdc2d765 | 2154 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
04b6bdc0 DW |
2155 | bgp_flag_unset (bgp, BGP_FLAG_SHOW_HOSTNAME); |
2156 | return CMD_SUCCESS; | |
2157 | } | |
2158 | ||
8233ef81 | 2159 | /* "bgp network import-check" configuration. */ |
718e3744 | 2160 | DEFUN (bgp_network_import_check, |
2161 | bgp_network_import_check_cmd, | |
5623e905 | 2162 | "bgp network import-check", |
718e3744 | 2163 | "BGP specific commands\n" |
2164 | "BGP network command\n" | |
5623e905 | 2165 | "Check BGP network route exists in IGP\n") |
718e3744 | 2166 | { |
cdc2d765 | 2167 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
078430f6 DS |
2168 | if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) |
2169 | { | |
2170 | bgp_flag_set (bgp, BGP_FLAG_IMPORT_CHECK); | |
5623e905 | 2171 | bgp_static_redo_import_check(bgp); |
078430f6 DS |
2172 | } |
2173 | ||
718e3744 | 2174 | return CMD_SUCCESS; |
2175 | } | |
2176 | ||
8233ef81 DW |
2177 | ALIAS_HIDDEN (bgp_network_import_check, |
2178 | bgp_network_import_check_exact_cmd, | |
2179 | "bgp network import-check exact", | |
2180 | "BGP specific commands\n" | |
2181 | "BGP network command\n" | |
2182 | "Check BGP network route exists in IGP\n" | |
2183 | "Match route precisely\n") | |
2184 | ||
718e3744 | 2185 | DEFUN (no_bgp_network_import_check, |
2186 | no_bgp_network_import_check_cmd, | |
5623e905 | 2187 | "no bgp network import-check", |
718e3744 | 2188 | NO_STR |
2189 | "BGP specific commands\n" | |
2190 | "BGP network command\n" | |
2191 | "Check BGP network route exists in IGP\n") | |
2192 | { | |
cdc2d765 | 2193 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
078430f6 DS |
2194 | if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) |
2195 | { | |
2196 | bgp_flag_unset (bgp, BGP_FLAG_IMPORT_CHECK); | |
078430f6 DS |
2197 | bgp_static_redo_import_check(bgp); |
2198 | } | |
5623e905 | 2199 | |
718e3744 | 2200 | return CMD_SUCCESS; |
2201 | } | |
6b0655a2 | 2202 | |
718e3744 | 2203 | DEFUN (bgp_default_local_preference, |
2204 | bgp_default_local_preference_cmd, | |
6147e2c6 | 2205 | "bgp default local-preference (0-4294967295)", |
718e3744 | 2206 | "BGP specific commands\n" |
2207 | "Configure BGP defaults\n" | |
2208 | "local preference (higher=more preferred)\n" | |
2209 | "Configure default local preference value\n") | |
2210 | { | |
cdc2d765 | 2211 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2212 | int idx_number = 3; |
718e3744 | 2213 | u_int32_t local_pref; |
2214 | ||
c500ae40 | 2215 | VTY_GET_INTEGER ("local preference", local_pref, argv[idx_number]->arg); |
718e3744 | 2216 | |
2217 | bgp_default_local_preference_set (bgp, local_pref); | |
f31fa004 | 2218 | bgp_clear_star_soft_in (vty, bgp->name); |
718e3744 | 2219 | |
2220 | return CMD_SUCCESS; | |
2221 | } | |
2222 | ||
2223 | DEFUN (no_bgp_default_local_preference, | |
2224 | no_bgp_default_local_preference_cmd, | |
838758ac | 2225 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 2226 | NO_STR |
2227 | "BGP specific commands\n" | |
2228 | "Configure BGP defaults\n" | |
838758ac DW |
2229 | "local preference (higher=more preferred)\n" |
2230 | "Configure default local preference value\n") | |
718e3744 | 2231 | { |
cdc2d765 | 2232 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2233 | bgp_default_local_preference_unset (bgp); |
f31fa004 | 2234 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 2235 | |
718e3744 | 2236 | return CMD_SUCCESS; |
2237 | } | |
2238 | ||
6b0655a2 | 2239 | |
3f9c7369 DS |
2240 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
2241 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 2242 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
2243 | "BGP specific commands\n" |
2244 | "Configure BGP defaults\n" | |
2245 | "subgroup-pkt-queue-max\n" | |
2246 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 2247 | { |
cdc2d765 | 2248 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2249 | int idx_number = 3; |
3f9c7369 | 2250 | u_int32_t max_size; |
8bd9d948 | 2251 | |
c500ae40 | 2252 | VTY_GET_INTEGER ("subgroup packet queue max", max_size, argv[idx_number]->arg); |
3f9c7369 DS |
2253 | |
2254 | bgp_default_subgroup_pkt_queue_max_set (bgp, max_size); | |
2255 | ||
2256 | return CMD_SUCCESS; | |
2257 | } | |
2258 | ||
2259 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
2260 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 2261 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
2262 | NO_STR |
2263 | "BGP specific commands\n" | |
2264 | "Configure BGP defaults\n" | |
838758ac DW |
2265 | "subgroup-pkt-queue-max\n" |
2266 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 2267 | { |
cdc2d765 | 2268 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3f9c7369 DS |
2269 | bgp_default_subgroup_pkt_queue_max_unset (bgp); |
2270 | return CMD_SUCCESS; | |
8bd9d948 DS |
2271 | } |
2272 | ||
813d4307 | 2273 | |
8bd9d948 DS |
2274 | DEFUN (bgp_rr_allow_outbound_policy, |
2275 | bgp_rr_allow_outbound_policy_cmd, | |
2276 | "bgp route-reflector allow-outbound-policy", | |
2277 | "BGP specific commands\n" | |
2278 | "Allow modifications made by out route-map\n" | |
2279 | "on ibgp neighbors\n") | |
2280 | { | |
cdc2d765 | 2281 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 DS |
2282 | |
2283 | if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) | |
2284 | { | |
2285 | bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3f9c7369 | 2286 | update_group_announce_rrclients(bgp); |
f31fa004 | 2287 | bgp_clear_star_soft_out (vty, bgp->name); |
8bd9d948 DS |
2288 | } |
2289 | ||
2290 | return CMD_SUCCESS; | |
2291 | } | |
2292 | ||
2293 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
2294 | no_bgp_rr_allow_outbound_policy_cmd, | |
2295 | "no bgp route-reflector allow-outbound-policy", | |
2296 | NO_STR | |
2297 | "BGP specific commands\n" | |
2298 | "Allow modifications made by out route-map\n" | |
2299 | "on ibgp neighbors\n") | |
2300 | { | |
cdc2d765 | 2301 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 DS |
2302 | |
2303 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) | |
2304 | { | |
2305 | bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3f9c7369 | 2306 | update_group_announce_rrclients(bgp); |
f31fa004 | 2307 | bgp_clear_star_soft_out (vty, bgp->name); |
8bd9d948 DS |
2308 | } |
2309 | ||
2310 | return CMD_SUCCESS; | |
2311 | } | |
2312 | ||
f14e6fdb DS |
2313 | DEFUN (bgp_listen_limit, |
2314 | bgp_listen_limit_cmd, | |
9ccf14f7 | 2315 | "bgp listen limit (1-5000)", |
f14e6fdb DS |
2316 | "BGP specific commands\n" |
2317 | "Configure BGP defaults\n" | |
2318 | "maximum number of BGP Dynamic Neighbors that can be created\n" | |
2319 | "Configure Dynamic Neighbors listen limit value\n") | |
2320 | { | |
cdc2d765 | 2321 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2322 | int idx_number = 3; |
f14e6fdb DS |
2323 | int listen_limit; |
2324 | ||
c500ae40 | 2325 | VTY_GET_INTEGER_RANGE ("listen limit", listen_limit, argv[idx_number]->arg, |
f14e6fdb DS |
2326 | BGP_DYNAMIC_NEIGHBORS_LIMIT_MIN, |
2327 | BGP_DYNAMIC_NEIGHBORS_LIMIT_MAX); | |
2328 | ||
2329 | bgp_listen_limit_set (bgp, listen_limit); | |
2330 | ||
2331 | return CMD_SUCCESS; | |
2332 | } | |
2333 | ||
2334 | DEFUN (no_bgp_listen_limit, | |
2335 | no_bgp_listen_limit_cmd, | |
838758ac | 2336 | "no bgp listen limit [(1-5000)]", |
f14e6fdb DS |
2337 | "BGP specific commands\n" |
2338 | "Configure BGP defaults\n" | |
2339 | "unset maximum number of BGP Dynamic Neighbors that can be created\n" | |
838758ac DW |
2340 | "Configure Dynamic Neighbors listen limit value to default\n" |
2341 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 2342 | { |
cdc2d765 | 2343 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f14e6fdb DS |
2344 | bgp_listen_limit_unset (bgp); |
2345 | return CMD_SUCCESS; | |
2346 | } | |
2347 | ||
2348 | ||
20eb8864 | 2349 | /* |
2350 | * Check if this listen range is already configured. Check for exact | |
2351 | * match or overlap based on input. | |
2352 | */ | |
2353 | static struct peer_group * | |
2354 | listen_range_exists (struct bgp *bgp, struct prefix *range, int exact) | |
2355 | { | |
2356 | struct listnode *node, *nnode; | |
2357 | struct listnode *node1, *nnode1; | |
2358 | struct peer_group *group; | |
2359 | struct prefix *lr; | |
2360 | afi_t afi; | |
2361 | int match; | |
2362 | ||
2363 | afi = family2afi(range->family); | |
2364 | for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) | |
2365 | { | |
2366 | for (ALL_LIST_ELEMENTS (group->listen_range[afi], node1, | |
2367 | nnode1, lr)) | |
2368 | { | |
2369 | if (exact) | |
2370 | match = prefix_same (range, lr); | |
2371 | else | |
2372 | match = (prefix_match (range, lr) || prefix_match (lr, range)); | |
2373 | if (match) | |
2374 | return group; | |
2375 | } | |
2376 | } | |
2377 | ||
2378 | return NULL; | |
2379 | } | |
2380 | ||
f14e6fdb DS |
2381 | DEFUN (bgp_listen_range, |
2382 | bgp_listen_range_cmd, | |
9ccf14f7 | 2383 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
f14e6fdb | 2384 | "BGP specific commands\n" |
d7fa34c1 QY |
2385 | "Configure BGP dynamic neighbors listen range\n" |
2386 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
2387 | NEIGHBOR_ADDR_STR |
2388 | "Member of the peer-group\n" | |
2389 | "Peer-group name\n") | |
f14e6fdb | 2390 | { |
cdc2d765 | 2391 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f14e6fdb | 2392 | struct prefix range; |
20eb8864 | 2393 | struct peer_group *group, *existing_group; |
f14e6fdb DS |
2394 | afi_t afi; |
2395 | int ret; | |
d7fa34c1 | 2396 | int idx = 0; |
f14e6fdb | 2397 | |
d7fa34c1 QY |
2398 | argv_find (argv, argc, "A.B.C.D/M", &idx); |
2399 | argv_find (argv, argc, "X:X::X:X/M", &idx); | |
2400 | char *prefix = argv[idx]->arg; | |
2401 | argv_find (argv, argc, "WORD", &idx); | |
2402 | char *peergroup = argv[idx]->arg; | |
f14e6fdb | 2403 | |
f14e6fdb | 2404 | /* Convert IP prefix string to struct prefix. */ |
d7fa34c1 | 2405 | ret = str2prefix (prefix, &range); |
f14e6fdb DS |
2406 | if (! ret) |
2407 | { | |
2408 | vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE); | |
2409 | return CMD_WARNING; | |
2410 | } | |
2411 | ||
2412 | afi = family2afi(range.family); | |
2413 | ||
f14e6fdb DS |
2414 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6)) |
2415 | { | |
2416 | vty_out (vty, "%% Malformed listen range (link-local address)%s", | |
2417 | VTY_NEWLINE); | |
2418 | return CMD_WARNING; | |
2419 | } | |
f14e6fdb DS |
2420 | |
2421 | apply_mask (&range); | |
2422 | ||
20eb8864 | 2423 | /* Check if same listen range is already configured. */ |
2424 | existing_group = listen_range_exists (bgp, &range, 1); | |
2425 | if (existing_group) | |
2426 | { | |
d7fa34c1 | 2427 | if (strcmp (existing_group->name, peergroup) == 0) |
20eb8864 | 2428 | return CMD_SUCCESS; |
2429 | else | |
2430 | { | |
2431 | vty_out (vty, "%% Same listen range is attached to peer-group %s%s", | |
2432 | existing_group->name, VTY_NEWLINE); | |
2433 | return CMD_WARNING; | |
2434 | } | |
2435 | } | |
2436 | ||
2437 | /* Check if an overlapping listen range exists. */ | |
2438 | if (listen_range_exists (bgp, &range, 0)) | |
2439 | { | |
2440 | vty_out (vty, "%% Listen range overlaps with existing listen range%s", | |
2441 | VTY_NEWLINE); | |
2442 | return CMD_WARNING; | |
2443 | } | |
f14e6fdb | 2444 | |
d7fa34c1 | 2445 | group = peer_group_lookup (bgp, peergroup); |
f14e6fdb DS |
2446 | if (! group) |
2447 | { | |
2448 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
2449 | return CMD_WARNING; | |
2450 | } | |
2451 | ||
2452 | ret = peer_group_listen_range_add(group, &range); | |
2453 | return bgp_vty_return (vty, ret); | |
2454 | } | |
2455 | ||
2456 | DEFUN (no_bgp_listen_range, | |
2457 | no_bgp_listen_range_cmd, | |
d7fa34c1 QY |
2458 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
2459 | NO_STR | |
f14e6fdb | 2460 | "BGP specific commands\n" |
d7fa34c1 QY |
2461 | "Unconfigure BGP dynamic neighbors listen range\n" |
2462 | "Unconfigure BGP dynamic neighbors listen range\n" | |
2463 | NEIGHBOR_ADDR_STR | |
2464 | "Member of the peer-group\n" | |
2465 | "Peer-group name\n") | |
f14e6fdb | 2466 | { |
cdc2d765 | 2467 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f14e6fdb DS |
2468 | struct prefix range; |
2469 | struct peer_group *group; | |
2470 | afi_t afi; | |
2471 | int ret; | |
d7fa34c1 QY |
2472 | int idx = 0; |
2473 | ||
2474 | argv_find (argv, argc, "A.B.C.D/M", &idx); | |
2475 | argv_find (argv, argc, "X:X::X:X/M", &idx); | |
2476 | char *prefix = argv[idx]->arg; | |
2477 | argv_find (argv, argc, "WORD", &idx); | |
2478 | char *peergroup = argv[idx]->arg; | |
f14e6fdb | 2479 | |
c500ae40 | 2480 | // VTY_GET_IPV4_PREFIX ("listen range", range, argv[idx_ipv4_prefixlen]->arg); |
f14e6fdb DS |
2481 | |
2482 | /* Convert IP prefix string to struct prefix. */ | |
d7fa34c1 | 2483 | ret = str2prefix (prefix, &range); |
f14e6fdb DS |
2484 | if (! ret) |
2485 | { | |
2486 | vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE); | |
2487 | return CMD_WARNING; | |
2488 | } | |
2489 | ||
2490 | afi = family2afi(range.family); | |
2491 | ||
f14e6fdb DS |
2492 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6)) |
2493 | { | |
2494 | vty_out (vty, "%% Malformed listen range (link-local address)%s", | |
2495 | VTY_NEWLINE); | |
2496 | return CMD_WARNING; | |
2497 | } | |
f14e6fdb DS |
2498 | |
2499 | apply_mask (&range); | |
2500 | ||
d7fa34c1 | 2501 | group = peer_group_lookup (bgp, peergroup); |
f14e6fdb DS |
2502 | if (! group) |
2503 | { | |
2504 | vty_out (vty, "%% Peer-group does not exist%s", VTY_NEWLINE); | |
2505 | return CMD_WARNING; | |
2506 | } | |
2507 | ||
2508 | ret = peer_group_listen_range_del(group, &range); | |
2509 | return bgp_vty_return (vty, ret); | |
2510 | } | |
2511 | ||
2512 | int | |
2513 | bgp_config_write_listen (struct vty *vty, struct bgp *bgp) | |
2514 | { | |
2515 | struct peer_group *group; | |
2516 | struct listnode *node, *nnode, *rnode, *nrnode; | |
2517 | struct prefix *range; | |
2518 | afi_t afi; | |
4690c7d7 | 2519 | char buf[PREFIX2STR_BUFFER]; |
f14e6fdb DS |
2520 | |
2521 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
2522 | vty_out (vty, " bgp listen limit %d%s", | |
2523 | bgp->dynamic_neighbors_limit, VTY_NEWLINE); | |
2524 | ||
2525 | for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) | |
2526 | { | |
2527 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
2528 | { | |
2529 | for (ALL_LIST_ELEMENTS (group->listen_range[afi], rnode, nrnode, range)) | |
2530 | { | |
2531 | prefix2str(range, buf, sizeof(buf)); | |
2532 | vty_out(vty, " bgp listen range %s peer-group %s%s", | |
2533 | buf, group->name, VTY_NEWLINE); | |
2534 | } | |
2535 | } | |
2536 | } | |
2537 | ||
2538 | return 0; | |
2539 | } | |
2540 | ||
2541 | ||
907f92c8 DS |
2542 | DEFUN (bgp_disable_connected_route_check, |
2543 | bgp_disable_connected_route_check_cmd, | |
2544 | "bgp disable-ebgp-connected-route-check", | |
2545 | "BGP specific commands\n" | |
2546 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2547 | { | |
cdc2d765 | 2548 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
907f92c8 | 2549 | bgp_flag_set (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); |
f31fa004 | 2550 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 2551 | |
907f92c8 DS |
2552 | return CMD_SUCCESS; |
2553 | } | |
2554 | ||
2555 | DEFUN (no_bgp_disable_connected_route_check, | |
2556 | no_bgp_disable_connected_route_check_cmd, | |
2557 | "no bgp disable-ebgp-connected-route-check", | |
2558 | NO_STR | |
2559 | "BGP specific commands\n" | |
2560 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2561 | { | |
cdc2d765 | 2562 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
907f92c8 | 2563 | bgp_flag_unset (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); |
f31fa004 | 2564 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 2565 | |
907f92c8 DS |
2566 | return CMD_SUCCESS; |
2567 | } | |
2568 | ||
2569 | ||
718e3744 | 2570 | static int |
e52702f2 | 2571 | peer_remote_as_vty (struct vty *vty, const char *peer_str, |
fd79ac91 | 2572 | const char *as_str, afi_t afi, safi_t safi) |
718e3744 | 2573 | { |
cdc2d765 | 2574 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2575 | int ret; |
718e3744 | 2576 | as_t as; |
0299c004 | 2577 | int as_type = AS_SPECIFIED; |
718e3744 | 2578 | union sockunion su; |
2579 | ||
7ae5fc81 | 2580 | if (as_str[0] == 'i') |
0299c004 DS |
2581 | { |
2582 | as = 0; | |
2583 | as_type = AS_INTERNAL; | |
2584 | } | |
7ae5fc81 | 2585 | else if (as_str[0] == 'e') |
0299c004 DS |
2586 | { |
2587 | as = 0; | |
2588 | as_type = AS_EXTERNAL; | |
2589 | } | |
2590 | else | |
2591 | { | |
2592 | /* Get AS number. */ | |
2593 | VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX); | |
2594 | } | |
718e3744 | 2595 | |
2596 | /* If peer is peer group, call proper function. */ | |
2597 | ret = str2sockunion (peer_str, &su); | |
2598 | if (ret < 0) | |
2599 | { | |
a80beece | 2600 | /* Check for peer by interface */ |
0299c004 | 2601 | ret = peer_remote_as (bgp, NULL, peer_str, &as, as_type, afi, safi); |
718e3744 | 2602 | if (ret < 0) |
a80beece | 2603 | { |
0299c004 | 2604 | ret = peer_group_remote_as (bgp, peer_str, &as, as_type); |
a80beece DS |
2605 | if (ret < 0) |
2606 | { | |
2607 | vty_out (vty, "%% Create the peer-group or interface first%s", | |
2608 | VTY_NEWLINE); | |
2609 | return CMD_WARNING; | |
2610 | } | |
2611 | return CMD_SUCCESS; | |
2612 | } | |
718e3744 | 2613 | } |
a80beece | 2614 | else |
718e3744 | 2615 | { |
6aeb9e78 | 2616 | if (peer_address_self_check (bgp, &su)) |
a80beece DS |
2617 | { |
2618 | vty_out (vty, "%% Can not configure the local system as neighbor%s", | |
2619 | VTY_NEWLINE); | |
2620 | return CMD_WARNING; | |
2621 | } | |
0299c004 | 2622 | ret = peer_remote_as (bgp, &su, NULL, &as, as_type, afi, safi); |
718e3744 | 2623 | } |
2624 | ||
718e3744 | 2625 | /* This peer belongs to peer group. */ |
2626 | switch (ret) | |
2627 | { | |
2628 | case BGP_ERR_PEER_GROUP_MEMBER: | |
aea339f7 | 2629 | vty_out (vty, "%% Peer-group AS %u. Cannot configure remote-as for member%s", as, VTY_NEWLINE); |
718e3744 | 2630 | return CMD_WARNING; |
718e3744 | 2631 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: |
aea339f7 | 2632 | 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 | 2633 | return CMD_WARNING; |
718e3744 | 2634 | } |
2635 | return bgp_vty_return (vty, ret); | |
2636 | } | |
2637 | ||
2638 | DEFUN (neighbor_remote_as, | |
2639 | neighbor_remote_as_cmd, | |
3a2d747c | 2640 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2641 | NEIGHBOR_STR |
2642 | NEIGHBOR_ADDR_STR2 | |
2643 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 2644 | AS_STR |
3a2d747c QY |
2645 | "Internal BGP peer\n" |
2646 | "External BGP peer\n") | |
718e3744 | 2647 | { |
c500ae40 DW |
2648 | int idx_peer = 1; |
2649 | int idx_remote_as = 3; | |
2650 | return peer_remote_as_vty (vty, argv[idx_peer]->arg, argv[idx_remote_as]->arg, AFI_IP, SAFI_UNICAST); | |
718e3744 | 2651 | } |
6b0655a2 | 2652 | |
4c48cf63 DW |
2653 | static int |
2654 | peer_conf_interface_get (struct vty *vty, const char *conf_if, afi_t afi, | |
b3a39dc5 DD |
2655 | safi_t safi, int v6only, const char *peer_group_name, |
2656 | const char *as_str) | |
a80beece | 2657 | { |
cdc2d765 | 2658 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
b3a39dc5 DD |
2659 | as_t as = 0; |
2660 | int as_type = AS_UNSPECIFIED; | |
a80beece DS |
2661 | struct peer *peer; |
2662 | struct peer_group *group; | |
4c48cf63 DW |
2663 | int ret = 0; |
2664 | union sockunion su; | |
a80beece | 2665 | |
4c48cf63 DW |
2666 | group = peer_group_lookup (bgp, conf_if); |
2667 | ||
a80beece DS |
2668 | if (group) |
2669 | { | |
2670 | vty_out (vty, "%% Name conflict with peer-group %s", VTY_NEWLINE); | |
2671 | return CMD_WARNING; | |
2672 | } | |
2673 | ||
b3a39dc5 DD |
2674 | if (as_str) |
2675 | { | |
7ae5fc81 | 2676 | if (as_str[0] == 'i') |
b3a39dc5 DD |
2677 | { |
2678 | as_type = AS_INTERNAL; | |
2679 | } | |
7ae5fc81 | 2680 | else if (as_str[0] == 'e') |
b3a39dc5 DD |
2681 | { |
2682 | as_type = AS_EXTERNAL; | |
2683 | } | |
2684 | else | |
2685 | { | |
2686 | /* Get AS number. */ | |
2687 | VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX); | |
2688 | as_type = AS_SPECIFIED; | |
2689 | } | |
2690 | } | |
2691 | ||
4c48cf63 DW |
2692 | peer = peer_lookup_by_conf_if (bgp, conf_if); |
2693 | if (!peer) | |
2694 | { | |
2695 | if (bgp_flag_check (bgp, BGP_FLAG_NO_DEFAULT_IPV4) | |
2696 | && afi == AFI_IP && safi == SAFI_UNICAST) | |
b3a39dc5 DD |
2697 | peer = peer_create (NULL, conf_if, bgp, bgp->as, as, as_type, 0, 0, |
2698 | NULL); | |
4c48cf63 | 2699 | else |
b3a39dc5 DD |
2700 | peer = peer_create (NULL, conf_if, bgp, bgp->as, as, as_type, afi, safi, |
2701 | NULL); | |
4c48cf63 DW |
2702 | |
2703 | if (peer && v6only) | |
2704 | SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
4a04e5f7 | 2705 | |
2706 | /* Request zebra to initiate IPv6 RAs on this interface. We do this | |
2707 | * any unnumbered peer in order to not worry about run-time transitions | |
2708 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 address | |
2709 | * gets deleted later etc.) | |
2710 | */ | |
2711 | if (peer->ifp) | |
b3a39dc5 DD |
2712 | { |
2713 | bgp_zebra_initiate_radv (bgp, peer); | |
2714 | } | |
2715 | peer_flag_set (peer, PEER_FLAG_CAPABILITY_ENHE); | |
4c48cf63 DW |
2716 | } |
2717 | else if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) || | |
2718 | (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) | |
2719 | { | |
2720 | if (v6only) | |
2721 | SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2722 | else | |
2723 | UNSET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2724 | ||
2725 | /* v6only flag changed. Reset bgp seesion */ | |
2726 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) | |
2727 | { | |
2728 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
2729 | bgp_notify_send (peer, BGP_NOTIFY_CEASE, | |
2730 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2731 | } | |
2732 | else | |
2733 | bgp_session_reset(peer); | |
2734 | } | |
2735 | ||
a80beece DS |
2736 | if (!peer) |
2737 | return CMD_WARNING; | |
2738 | ||
4c48cf63 DW |
2739 | if (peer_group_name) |
2740 | { | |
2741 | group = peer_group_lookup (bgp, peer_group_name); | |
2742 | if (! group) | |
2743 | { | |
2744 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
2745 | return CMD_WARNING; | |
2746 | } | |
2747 | ||
2748 | ret = peer_group_bind (bgp, &su, peer, group, &as); | |
2749 | } | |
2750 | ||
2751 | return bgp_vty_return (vty, ret); | |
a80beece DS |
2752 | } |
2753 | ||
4c48cf63 DW |
2754 | DEFUN (neighbor_interface_config, |
2755 | neighbor_interface_config_cmd, | |
31500417 | 2756 | "neighbor WORD interface [peer-group WORD]", |
4c48cf63 DW |
2757 | NEIGHBOR_STR |
2758 | "Interface name or neighbor tag\n" | |
31500417 DW |
2759 | "Enable BGP on interface\n" |
2760 | "Member of the peer-group\n" | |
16cedbb0 | 2761 | "Peer-group name\n") |
4c48cf63 | 2762 | { |
c500ae40 | 2763 | int idx_word = 1; |
31500417 DW |
2764 | int idx_peer_group_word = 4; |
2765 | ||
2766 | if (argc > idx_peer_group_word) | |
c500ae40 | 2767 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, |
31500417 | 2768 | argv[idx_peer_group_word]->arg, NULL); |
4c48cf63 | 2769 | else |
c500ae40 | 2770 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, |
b3a39dc5 | 2771 | NULL, NULL); |
4c48cf63 DW |
2772 | } |
2773 | ||
4c48cf63 DW |
2774 | DEFUN (neighbor_interface_config_v6only, |
2775 | neighbor_interface_config_v6only_cmd, | |
31500417 | 2776 | "neighbor WORD interface v6only [peer-group WORD]", |
4c48cf63 DW |
2777 | NEIGHBOR_STR |
2778 | "Interface name or neighbor tag\n" | |
2779 | "Enable BGP on interface\n" | |
31500417 DW |
2780 | "Enable BGP with v6 link-local only\n" |
2781 | "Member of the peer-group\n" | |
16cedbb0 | 2782 | "Peer-group name\n") |
4c48cf63 | 2783 | { |
c500ae40 | 2784 | int idx_word = 1; |
31500417 DW |
2785 | int idx_peer_group_word = 5; |
2786 | ||
2787 | if (argc > idx_peer_group_word) | |
2788 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
2789 | argv[idx_peer_group_word]->arg, NULL); | |
2790 | ||
c500ae40 | 2791 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, |
31500417 | 2792 | NULL, NULL); |
4c48cf63 DW |
2793 | } |
2794 | ||
a80beece | 2795 | |
b3a39dc5 DD |
2796 | DEFUN (neighbor_interface_config_remote_as, |
2797 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 2798 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2799 | NEIGHBOR_STR |
2800 | "Interface name or neighbor tag\n" | |
2801 | "Enable BGP on interface\n" | |
3a2d747c | 2802 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2803 | AS_STR |
3a2d747c QY |
2804 | "Internal BGP peer\n" |
2805 | "External BGP peer\n") | |
b3a39dc5 | 2806 | { |
c500ae40 DW |
2807 | int idx_word = 1; |
2808 | int idx_remote_as = 4; | |
2809 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
2810 | NULL, argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2811 | } |
2812 | ||
2813 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
2814 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 2815 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2816 | NEIGHBOR_STR |
2817 | "Interface name or neighbor tag\n" | |
3a2d747c | 2818 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 2819 | "Enable BGP on interface\n" |
3a2d747c | 2820 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2821 | AS_STR |
3a2d747c QY |
2822 | "Internal BGP peer\n" |
2823 | "External BGP peer\n") | |
b3a39dc5 | 2824 | { |
c500ae40 DW |
2825 | int idx_word = 1; |
2826 | int idx_remote_as = 5; | |
2827 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
2828 | NULL, argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2829 | } |
2830 | ||
718e3744 | 2831 | DEFUN (neighbor_peer_group, |
2832 | neighbor_peer_group_cmd, | |
2833 | "neighbor WORD peer-group", | |
2834 | NEIGHBOR_STR | |
a80beece | 2835 | "Interface name or neighbor tag\n" |
718e3744 | 2836 | "Configure peer-group\n") |
2837 | { | |
cdc2d765 | 2838 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2839 | int idx_word = 1; |
a80beece | 2840 | struct peer *peer; |
718e3744 | 2841 | struct peer_group *group; |
2842 | ||
c500ae40 | 2843 | peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg); |
a80beece DS |
2844 | if (peer) |
2845 | { | |
2846 | vty_out (vty, "%% Name conflict with interface: %s", VTY_NEWLINE); | |
2847 | return CMD_WARNING; | |
2848 | } | |
718e3744 | 2849 | |
c500ae40 | 2850 | group = peer_group_get (bgp, argv[idx_word]->arg); |
718e3744 | 2851 | if (! group) |
2852 | return CMD_WARNING; | |
2853 | ||
2854 | return CMD_SUCCESS; | |
2855 | } | |
2856 | ||
2857 | DEFUN (no_neighbor, | |
2858 | no_neighbor_cmd, | |
dab8cd00 | 2859 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 2860 | NO_STR |
2861 | NEIGHBOR_STR | |
3a2d747c QY |
2862 | NEIGHBOR_ADDR_STR2 |
2863 | "Specify a BGP neighbor\n" | |
2864 | AS_STR | |
2865 | "Internal BGP peer\n" | |
2866 | "External BGP peer\n") | |
718e3744 | 2867 | { |
cdc2d765 | 2868 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2869 | int idx_peer = 2; |
718e3744 | 2870 | int ret; |
2871 | union sockunion su; | |
2872 | struct peer_group *group; | |
2873 | struct peer *peer; | |
1ff9a340 | 2874 | struct peer *other; |
718e3744 | 2875 | |
c500ae40 | 2876 | ret = str2sockunion (argv[idx_peer]->arg, &su); |
718e3744 | 2877 | if (ret < 0) |
2878 | { | |
a80beece | 2879 | /* look up for neighbor by interface name config. */ |
cdc2d765 | 2880 | peer = peer_lookup_by_conf_if (bgp, argv[idx_peer]->arg); |
a80beece DS |
2881 | if (peer) |
2882 | { | |
4a04e5f7 | 2883 | /* Request zebra to terminate IPv6 RAs on this interface. */ |
2884 | if (peer->ifp) | |
2885 | bgp_zebra_terminate_radv (peer->bgp, peer); | |
a80beece DS |
2886 | peer_delete (peer); |
2887 | return CMD_SUCCESS; | |
2888 | } | |
2889 | ||
cdc2d765 | 2890 | group = peer_group_lookup (bgp, argv[idx_peer]->arg); |
718e3744 | 2891 | if (group) |
2892 | peer_group_delete (group); | |
2893 | else | |
2894 | { | |
2895 | vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE); | |
2896 | return CMD_WARNING; | |
2897 | } | |
2898 | } | |
2899 | else | |
2900 | { | |
cdc2d765 | 2901 | peer = peer_lookup (bgp, &su); |
718e3744 | 2902 | if (peer) |
1ff9a340 | 2903 | { |
f14e6fdb DS |
2904 | if (peer_dynamic_neighbor (peer)) |
2905 | { | |
2906 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
2907 | VTY_NEWLINE); | |
2908 | return CMD_WARNING; | |
2909 | } | |
2910 | ||
1ff9a340 DS |
2911 | other = peer->doppelganger; |
2912 | peer_delete (peer); | |
2913 | if (other && other->status != Deleted) | |
2914 | peer_delete(other); | |
2915 | } | |
718e3744 | 2916 | } |
2917 | ||
2918 | return CMD_SUCCESS; | |
2919 | } | |
2920 | ||
a80beece DS |
2921 | DEFUN (no_neighbor_interface_config, |
2922 | no_neighbor_interface_config_cmd, | |
31500417 | 2923 | "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
2924 | NO_STR |
2925 | NEIGHBOR_STR | |
2926 | "Interface name\n" | |
31500417 DW |
2927 | "Configure BGP on interface\n" |
2928 | "Enable BGP with v6 link-local only\n" | |
2929 | "Member of the peer-group\n" | |
16cedbb0 | 2930 | "Peer-group name\n" |
3a2d747c QY |
2931 | "Specify a BGP neighbor\n" |
2932 | AS_STR | |
2933 | "Internal BGP peer\n" | |
2934 | "External BGP peer\n") | |
a80beece | 2935 | { |
cdc2d765 | 2936 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2937 | int idx_word = 2; |
a80beece DS |
2938 | struct peer *peer; |
2939 | ||
2940 | /* look up for neighbor by interface name config. */ | |
cdc2d765 | 2941 | peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg); |
a80beece DS |
2942 | if (peer) |
2943 | { | |
4a04e5f7 | 2944 | /* Request zebra to terminate IPv6 RAs on this interface. */ |
2945 | if (peer->ifp) | |
2946 | bgp_zebra_terminate_radv (peer->bgp, peer); | |
a80beece DS |
2947 | peer_delete (peer); |
2948 | } | |
2949 | else | |
2950 | { | |
2951 | vty_out (vty, "%% Create the bgp interface first%s", VTY_NEWLINE); | |
2952 | return CMD_WARNING; | |
2953 | } | |
2954 | return CMD_SUCCESS; | |
2955 | } | |
2956 | ||
718e3744 | 2957 | DEFUN (no_neighbor_peer_group, |
2958 | no_neighbor_peer_group_cmd, | |
2959 | "no neighbor WORD peer-group", | |
2960 | NO_STR | |
2961 | NEIGHBOR_STR | |
2962 | "Neighbor tag\n" | |
2963 | "Configure peer-group\n") | |
2964 | { | |
cdc2d765 | 2965 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2966 | int idx_word = 2; |
718e3744 | 2967 | struct peer_group *group; |
2968 | ||
cdc2d765 | 2969 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 2970 | if (group) |
2971 | peer_group_delete (group); | |
2972 | else | |
2973 | { | |
2974 | vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE); | |
2975 | return CMD_WARNING; | |
2976 | } | |
2977 | return CMD_SUCCESS; | |
2978 | } | |
2979 | ||
a80beece DS |
2980 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
2981 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 2982 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2983 | NO_STR |
2984 | NEIGHBOR_STR | |
a80beece | 2985 | "Interface name or neighbor tag\n" |
718e3744 | 2986 | "Specify a BGP neighbor\n" |
3a2d747c QY |
2987 | AS_STR |
2988 | "Internal BGP peer\n" | |
2989 | "External BGP peer\n") | |
718e3744 | 2990 | { |
cdc2d765 | 2991 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2992 | int idx_word = 2; |
718e3744 | 2993 | struct peer_group *group; |
a80beece DS |
2994 | struct peer *peer; |
2995 | ||
2996 | /* look up for neighbor by interface name config. */ | |
cdc2d765 | 2997 | peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg); |
a80beece DS |
2998 | if (peer) |
2999 | { | |
0299c004 | 3000 | peer_as_change (peer, 0, AS_SPECIFIED); |
a80beece DS |
3001 | return CMD_SUCCESS; |
3002 | } | |
718e3744 | 3003 | |
cdc2d765 | 3004 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 3005 | if (group) |
3006 | peer_group_remote_as_delete (group); | |
3007 | else | |
3008 | { | |
a80beece | 3009 | vty_out (vty, "%% Create the peer-group or interface first%s", VTY_NEWLINE); |
718e3744 | 3010 | return CMD_WARNING; |
3011 | } | |
3012 | return CMD_SUCCESS; | |
3013 | } | |
6b0655a2 | 3014 | |
718e3744 | 3015 | DEFUN (neighbor_local_as, |
3016 | neighbor_local_as_cmd, | |
9ccf14f7 | 3017 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 3018 | NEIGHBOR_STR |
3019 | NEIGHBOR_ADDR_STR2 | |
3020 | "Specify a local-as number\n" | |
3021 | "AS number used as local AS\n") | |
3022 | { | |
c500ae40 DW |
3023 | int idx_peer = 1; |
3024 | int idx_number = 3; | |
718e3744 | 3025 | struct peer *peer; |
3026 | int ret; | |
e14fda0f | 3027 | as_t as; |
718e3744 | 3028 | |
c500ae40 | 3029 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3030 | if (! peer) |
3031 | return CMD_WARNING; | |
3032 | ||
b6f1faf0 | 3033 | VTY_GET_INTEGER_RANGE ("Local AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); |
e14fda0f | 3034 | ret = peer_local_as_set (peer, as, 0, 0); |
718e3744 | 3035 | return bgp_vty_return (vty, ret); |
3036 | } | |
3037 | ||
3038 | DEFUN (neighbor_local_as_no_prepend, | |
3039 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 3040 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 3041 | NEIGHBOR_STR |
3042 | NEIGHBOR_ADDR_STR2 | |
3043 | "Specify a local-as number\n" | |
3044 | "AS number used as local AS\n" | |
3045 | "Do not prepend local-as to updates from ebgp peers\n") | |
3046 | { | |
c500ae40 DW |
3047 | int idx_peer = 1; |
3048 | int idx_number = 3; | |
718e3744 | 3049 | struct peer *peer; |
3050 | int ret; | |
e14fda0f | 3051 | as_t as; |
718e3744 | 3052 | |
c500ae40 | 3053 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3054 | if (! peer) |
3055 | return CMD_WARNING; | |
3056 | ||
b6f1faf0 | 3057 | VTY_GET_INTEGER_RANGE ("Local AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); |
e14fda0f | 3058 | ret = peer_local_as_set (peer, as, 1, 0); |
718e3744 | 3059 | return bgp_vty_return (vty, ret); |
3060 | } | |
3061 | ||
9d3f9705 AC |
3062 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
3063 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 3064 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
3065 | NEIGHBOR_STR |
3066 | NEIGHBOR_ADDR_STR2 | |
3067 | "Specify a local-as number\n" | |
3068 | "AS number used as local AS\n" | |
3069 | "Do not prepend local-as to updates from ebgp peers\n" | |
3070 | "Do not prepend local-as to updates from ibgp peers\n") | |
3071 | { | |
c500ae40 DW |
3072 | int idx_peer = 1; |
3073 | int idx_number = 3; | |
9d3f9705 AC |
3074 | struct peer *peer; |
3075 | int ret; | |
e14fda0f | 3076 | as_t as; |
9d3f9705 | 3077 | |
c500ae40 | 3078 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
9d3f9705 AC |
3079 | if (! peer) |
3080 | return CMD_WARNING; | |
3081 | ||
b6f1faf0 | 3082 | VTY_GET_INTEGER_RANGE ("Local AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); |
e14fda0f | 3083 | ret = peer_local_as_set (peer, as, 1, 1); |
9d3f9705 AC |
3084 | return bgp_vty_return (vty, ret); |
3085 | } | |
3086 | ||
718e3744 | 3087 | DEFUN (no_neighbor_local_as, |
3088 | no_neighbor_local_as_cmd, | |
a636c635 | 3089 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 3090 | NO_STR |
3091 | NEIGHBOR_STR | |
3092 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
3093 | "Specify a local-as number\n" |
3094 | "AS number used as local AS\n" | |
3095 | "Do not prepend local-as to updates from ebgp peers\n" | |
3096 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 3097 | { |
c500ae40 | 3098 | int idx_peer = 2; |
718e3744 | 3099 | struct peer *peer; |
3100 | int ret; | |
3101 | ||
c500ae40 | 3102 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3103 | if (! peer) |
3104 | return CMD_WARNING; | |
3105 | ||
3106 | ret = peer_local_as_unset (peer); | |
3107 | return bgp_vty_return (vty, ret); | |
3108 | } | |
3109 | ||
718e3744 | 3110 | |
9d3f9705 | 3111 | |
6b0655a2 | 3112 | |
3f9c7369 DS |
3113 | DEFUN (neighbor_solo, |
3114 | neighbor_solo_cmd, | |
9ccf14f7 | 3115 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3116 | NEIGHBOR_STR |
3117 | NEIGHBOR_ADDR_STR2 | |
3118 | "Solo peer - part of its own update group\n") | |
3119 | { | |
c500ae40 | 3120 | int idx_peer = 1; |
3f9c7369 DS |
3121 | struct peer *peer; |
3122 | int ret; | |
3123 | ||
c500ae40 | 3124 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
3f9c7369 DS |
3125 | if (! peer) |
3126 | return CMD_WARNING; | |
3127 | ||
3128 | ret = update_group_adjust_soloness(peer, 1); | |
3129 | return bgp_vty_return (vty, ret); | |
3130 | } | |
3131 | ||
3132 | DEFUN (no_neighbor_solo, | |
3133 | no_neighbor_solo_cmd, | |
9ccf14f7 | 3134 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3135 | NO_STR |
3136 | NEIGHBOR_STR | |
3137 | NEIGHBOR_ADDR_STR2 | |
3138 | "Solo peer - part of its own update group\n") | |
3139 | { | |
c500ae40 | 3140 | int idx_peer = 2; |
3f9c7369 DS |
3141 | struct peer *peer; |
3142 | int ret; | |
3143 | ||
c500ae40 | 3144 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
3f9c7369 DS |
3145 | if (! peer) |
3146 | return CMD_WARNING; | |
3147 | ||
3148 | ret = update_group_adjust_soloness(peer, 0); | |
3149 | return bgp_vty_return (vty, ret); | |
3150 | } | |
3151 | ||
0df7c91f PJ |
3152 | DEFUN (neighbor_password, |
3153 | neighbor_password_cmd, | |
9ccf14f7 | 3154 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
3155 | NEIGHBOR_STR |
3156 | NEIGHBOR_ADDR_STR2 | |
3157 | "Set a password\n" | |
3158 | "The password\n") | |
3159 | { | |
c500ae40 DW |
3160 | int idx_peer = 1; |
3161 | int idx_line = 3; | |
0df7c91f PJ |
3162 | struct peer *peer; |
3163 | int ret; | |
3164 | ||
c500ae40 | 3165 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
0df7c91f PJ |
3166 | if (! peer) |
3167 | return CMD_WARNING; | |
3168 | ||
c500ae40 | 3169 | ret = peer_password_set (peer, argv[idx_line]->arg); |
0df7c91f PJ |
3170 | return bgp_vty_return (vty, ret); |
3171 | } | |
3172 | ||
3173 | DEFUN (no_neighbor_password, | |
3174 | no_neighbor_password_cmd, | |
a636c635 | 3175 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
3176 | NO_STR |
3177 | NEIGHBOR_STR | |
3178 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
3179 | "Set a password\n" |
3180 | "The password\n") | |
0df7c91f | 3181 | { |
c500ae40 | 3182 | int idx_peer = 2; |
0df7c91f PJ |
3183 | struct peer *peer; |
3184 | int ret; | |
3185 | ||
c500ae40 | 3186 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
0df7c91f PJ |
3187 | if (! peer) |
3188 | return CMD_WARNING; | |
3189 | ||
3190 | ret = peer_password_unset (peer); | |
3191 | return bgp_vty_return (vty, ret); | |
3192 | } | |
6b0655a2 | 3193 | |
813d4307 | 3194 | |
718e3744 | 3195 | DEFUN (neighbor_activate, |
3196 | neighbor_activate_cmd, | |
9ccf14f7 | 3197 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3198 | NEIGHBOR_STR |
3199 | NEIGHBOR_ADDR_STR2 | |
3200 | "Enable the Address Family for this Neighbor\n") | |
3201 | { | |
c500ae40 | 3202 | int idx_peer = 1; |
c8560b44 | 3203 | int ret; |
718e3744 | 3204 | struct peer *peer; |
3205 | ||
c500ae40 | 3206 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3207 | if (! peer) |
3208 | return CMD_WARNING; | |
3209 | ||
c8560b44 | 3210 | ret = peer_activate (peer, bgp_node_afi (vty), bgp_node_safi (vty)); |
718e3744 | 3211 | |
c8560b44 DW |
3212 | if (ret) |
3213 | return CMD_WARNING; | |
718e3744 | 3214 | return CMD_SUCCESS; |
3215 | } | |
3216 | ||
3217 | DEFUN (no_neighbor_activate, | |
3218 | no_neighbor_activate_cmd, | |
9ccf14f7 | 3219 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3220 | NO_STR |
3221 | NEIGHBOR_STR | |
3222 | NEIGHBOR_ADDR_STR2 | |
3223 | "Enable the Address Family for this Neighbor\n") | |
3224 | { | |
c500ae40 | 3225 | int idx_peer = 2; |
718e3744 | 3226 | int ret; |
3227 | struct peer *peer; | |
3228 | ||
3229 | /* Lookup peer. */ | |
c500ae40 | 3230 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3231 | if (! peer) |
3232 | return CMD_WARNING; | |
3233 | ||
3234 | ret = peer_deactivate (peer, bgp_node_afi (vty), bgp_node_safi (vty)); | |
3235 | ||
c8560b44 DW |
3236 | if (ret) |
3237 | return CMD_WARNING; | |
3238 | return CMD_SUCCESS; | |
718e3744 | 3239 | } |
6b0655a2 | 3240 | |
718e3744 | 3241 | DEFUN (neighbor_set_peer_group, |
3242 | neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3243 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3244 | NEIGHBOR_STR |
a80beece | 3245 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3246 | "Member of the peer-group\n" |
16cedbb0 | 3247 | "Peer-group name\n") |
718e3744 | 3248 | { |
cdc2d765 | 3249 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
3250 | int idx_peer = 1; |
3251 | int idx_word = 3; | |
718e3744 | 3252 | int ret; |
3253 | as_t as; | |
3254 | union sockunion su; | |
a80beece | 3255 | struct peer *peer; |
718e3744 | 3256 | struct peer_group *group; |
3257 | ||
a80beece | 3258 | peer = NULL; |
718e3744 | 3259 | |
c500ae40 | 3260 | ret = str2sockunion (argv[idx_peer]->arg, &su); |
718e3744 | 3261 | if (ret < 0) |
3262 | { | |
c500ae40 | 3263 | peer = peer_lookup_by_conf_if (bgp, argv[idx_peer]->arg); |
a80beece DS |
3264 | if (!peer) |
3265 | { | |
c500ae40 | 3266 | vty_out (vty, "%% Malformed address or name: %s%s", argv[idx_peer]->arg, VTY_NEWLINE); |
a80beece DS |
3267 | return CMD_WARNING; |
3268 | } | |
3269 | } | |
3270 | else | |
3271 | { | |
6aeb9e78 | 3272 | if (peer_address_self_check (bgp, &su)) |
a80beece DS |
3273 | { |
3274 | vty_out (vty, "%% Can not configure the local system as neighbor%s", | |
3275 | VTY_NEWLINE); | |
3276 | return CMD_WARNING; | |
3277 | } | |
f14e6fdb DS |
3278 | |
3279 | /* Disallow for dynamic neighbor. */ | |
3280 | peer = peer_lookup (bgp, &su); | |
3281 | if (peer && peer_dynamic_neighbor (peer)) | |
3282 | { | |
3283 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
3284 | VTY_NEWLINE); | |
3285 | return CMD_WARNING; | |
3286 | } | |
718e3744 | 3287 | } |
3288 | ||
c500ae40 | 3289 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 3290 | if (! group) |
3291 | { | |
3292 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
3293 | return CMD_WARNING; | |
3294 | } | |
3295 | ||
c8560b44 | 3296 | ret = peer_group_bind (bgp, &su, peer, group, &as); |
718e3744 | 3297 | |
3298 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) | |
3299 | { | |
aea339f7 | 3300 | 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 | 3301 | return CMD_WARNING; |
3302 | } | |
3303 | ||
3304 | return bgp_vty_return (vty, ret); | |
3305 | } | |
3306 | ||
3307 | DEFUN (no_neighbor_set_peer_group, | |
3308 | no_neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3309 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3310 | NO_STR |
3311 | NEIGHBOR_STR | |
a80beece | 3312 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3313 | "Member of the peer-group\n" |
16cedbb0 | 3314 | "Peer-group name\n") |
718e3744 | 3315 | { |
cdc2d765 | 3316 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
3317 | int idx_peer = 2; |
3318 | int idx_word = 4; | |
718e3744 | 3319 | int ret; |
718e3744 | 3320 | struct peer *peer; |
3321 | struct peer_group *group; | |
3322 | ||
c500ae40 | 3323 | peer = peer_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3324 | if (! peer) |
3325 | return CMD_WARNING; | |
3326 | ||
c500ae40 | 3327 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 3328 | if (! group) |
3329 | { | |
3330 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
3331 | return CMD_WARNING; | |
3332 | } | |
3333 | ||
c8560b44 | 3334 | ret = peer_group_unbind (bgp, peer, group); |
718e3744 | 3335 | |
3336 | return bgp_vty_return (vty, ret); | |
3337 | } | |
6b0655a2 | 3338 | |
94f2b392 | 3339 | static int |
e52702f2 | 3340 | peer_flag_modify_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 3341 | u_int16_t flag, int set) |
718e3744 | 3342 | { |
3343 | int ret; | |
3344 | struct peer *peer; | |
3345 | ||
3346 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
3347 | if (! peer) | |
3348 | return CMD_WARNING; | |
3349 | ||
8cdabf90 SK |
3350 | /* |
3351 | * If 'neighbor <interface>', then this is for directly connected peers, | |
3352 | * we should not accept disable-connected-check. | |
3353 | */ | |
3354 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
3355 | vty_out (vty, "%s is directly connected peer, cannot accept disable-" | |
3356 | "connected-check%s", ip_str, VTY_NEWLINE); | |
3357 | return CMD_WARNING; | |
3358 | } | |
3359 | ||
718e3744 | 3360 | if (set) |
3361 | ret = peer_flag_set (peer, flag); | |
3362 | else | |
3363 | ret = peer_flag_unset (peer, flag); | |
3364 | ||
3365 | return bgp_vty_return (vty, ret); | |
3366 | } | |
3367 | ||
94f2b392 | 3368 | static int |
fd79ac91 | 3369 | peer_flag_set_vty (struct vty *vty, const char *ip_str, u_int16_t flag) |
718e3744 | 3370 | { |
3371 | return peer_flag_modify_vty (vty, ip_str, flag, 1); | |
3372 | } | |
3373 | ||
94f2b392 | 3374 | static int |
fd79ac91 | 3375 | peer_flag_unset_vty (struct vty *vty, const char *ip_str, u_int16_t flag) |
718e3744 | 3376 | { |
3377 | return peer_flag_modify_vty (vty, ip_str, flag, 0); | |
3378 | } | |
3379 | ||
3380 | /* neighbor passive. */ | |
3381 | DEFUN (neighbor_passive, | |
3382 | neighbor_passive_cmd, | |
9ccf14f7 | 3383 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3384 | NEIGHBOR_STR |
3385 | NEIGHBOR_ADDR_STR2 | |
3386 | "Don't send open messages to this neighbor\n") | |
3387 | { | |
c500ae40 DW |
3388 | int idx_peer = 1; |
3389 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3390 | } |
3391 | ||
3392 | DEFUN (no_neighbor_passive, | |
3393 | no_neighbor_passive_cmd, | |
9ccf14f7 | 3394 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3395 | NO_STR |
3396 | NEIGHBOR_STR | |
3397 | NEIGHBOR_ADDR_STR2 | |
3398 | "Don't send open messages to this neighbor\n") | |
3399 | { | |
c500ae40 DW |
3400 | int idx_peer = 2; |
3401 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3402 | } |
6b0655a2 | 3403 | |
718e3744 | 3404 | /* neighbor shutdown. */ |
3405 | DEFUN (neighbor_shutdown, | |
3406 | neighbor_shutdown_cmd, | |
9ccf14f7 | 3407 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", |
718e3744 | 3408 | NEIGHBOR_STR |
3409 | NEIGHBOR_ADDR_STR2 | |
3410 | "Administratively shut down this neighbor\n") | |
3411 | { | |
c500ae40 DW |
3412 | int idx_peer = 1; |
3413 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); | |
718e3744 | 3414 | } |
3415 | ||
3416 | DEFUN (no_neighbor_shutdown, | |
3417 | no_neighbor_shutdown_cmd, | |
9ccf14f7 | 3418 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", |
718e3744 | 3419 | NO_STR |
3420 | NEIGHBOR_STR | |
3421 | NEIGHBOR_ADDR_STR2 | |
3422 | "Administratively shut down this neighbor\n") | |
3423 | { | |
c500ae40 DW |
3424 | int idx_peer = 2; |
3425 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); | |
718e3744 | 3426 | } |
6b0655a2 | 3427 | |
718e3744 | 3428 | /* neighbor capability dynamic. */ |
3429 | DEFUN (neighbor_capability_dynamic, | |
3430 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3431 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3432 | NEIGHBOR_STR |
3433 | NEIGHBOR_ADDR_STR2 | |
3434 | "Advertise capability to the peer\n" | |
3435 | "Advertise dynamic capability to this neighbor\n") | |
3436 | { | |
c500ae40 DW |
3437 | int idx_peer = 1; |
3438 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3439 | } |
3440 | ||
3441 | DEFUN (no_neighbor_capability_dynamic, | |
3442 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3443 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3444 | NO_STR |
3445 | NEIGHBOR_STR | |
3446 | NEIGHBOR_ADDR_STR2 | |
3447 | "Advertise capability to the peer\n" | |
3448 | "Advertise dynamic capability to this neighbor\n") | |
3449 | { | |
c500ae40 DW |
3450 | int idx_peer = 2; |
3451 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3452 | } |
6b0655a2 | 3453 | |
718e3744 | 3454 | /* neighbor dont-capability-negotiate */ |
3455 | DEFUN (neighbor_dont_capability_negotiate, | |
3456 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3457 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3458 | NEIGHBOR_STR |
3459 | NEIGHBOR_ADDR_STR2 | |
3460 | "Do not perform capability negotiation\n") | |
3461 | { | |
c500ae40 DW |
3462 | int idx_peer = 1; |
3463 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3464 | } |
3465 | ||
3466 | DEFUN (no_neighbor_dont_capability_negotiate, | |
3467 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3468 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3469 | NO_STR |
3470 | NEIGHBOR_STR | |
3471 | NEIGHBOR_ADDR_STR2 | |
3472 | "Do not perform capability negotiation\n") | |
3473 | { | |
c500ae40 DW |
3474 | int idx_peer = 2; |
3475 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3476 | } |
6b0655a2 | 3477 | |
8a92a8a0 DS |
3478 | /* neighbor capability extended next hop encoding */ |
3479 | DEFUN (neighbor_capability_enhe, | |
3480 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3481 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3482 | NEIGHBOR_STR |
3483 | NEIGHBOR_ADDR_STR2 | |
3484 | "Advertise capability to the peer\n" | |
3485 | "Advertise extended next-hop capability to the peer\n") | |
3486 | { | |
c500ae40 DW |
3487 | int idx_peer = 1; |
3488 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3489 | } |
3490 | ||
3491 | DEFUN (no_neighbor_capability_enhe, | |
3492 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3493 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3494 | NO_STR |
3495 | NEIGHBOR_STR | |
3496 | NEIGHBOR_ADDR_STR2 | |
3497 | "Advertise capability to the peer\n" | |
3498 | "Advertise extended next-hop capability to the peer\n") | |
3499 | { | |
c500ae40 DW |
3500 | int idx_peer = 2; |
3501 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3502 | } |
3503 | ||
94f2b392 | 3504 | static int |
fd79ac91 | 3505 | peer_af_flag_modify_vty (struct vty *vty, const char *peer_str, afi_t afi, |
fee0f4c6 | 3506 | safi_t safi, u_int32_t flag, int set) |
718e3744 | 3507 | { |
3508 | int ret; | |
3509 | struct peer *peer; | |
3510 | ||
3511 | peer = peer_and_group_lookup_vty (vty, peer_str); | |
3512 | if (! peer) | |
3513 | return CMD_WARNING; | |
3514 | ||
3515 | if (set) | |
3516 | ret = peer_af_flag_set (peer, afi, safi, flag); | |
3517 | else | |
3518 | ret = peer_af_flag_unset (peer, afi, safi, flag); | |
3519 | ||
3520 | return bgp_vty_return (vty, ret); | |
3521 | } | |
3522 | ||
94f2b392 | 3523 | static int |
fd79ac91 | 3524 | peer_af_flag_set_vty (struct vty *vty, const char *peer_str, afi_t afi, |
fee0f4c6 | 3525 | safi_t safi, u_int32_t flag) |
718e3744 | 3526 | { |
3527 | return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 1); | |
3528 | } | |
3529 | ||
94f2b392 | 3530 | static int |
fd79ac91 | 3531 | peer_af_flag_unset_vty (struct vty *vty, const char *peer_str, afi_t afi, |
fee0f4c6 | 3532 | safi_t safi, u_int32_t flag) |
718e3744 | 3533 | { |
3534 | return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 0); | |
3535 | } | |
6b0655a2 | 3536 | |
718e3744 | 3537 | /* neighbor capability orf prefix-list. */ |
3538 | DEFUN (neighbor_capability_orf_prefix, | |
3539 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3540 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3541 | NEIGHBOR_STR |
3542 | NEIGHBOR_ADDR_STR2 | |
3543 | "Advertise capability to the peer\n" | |
3544 | "Advertise ORF capability to the peer\n" | |
3545 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3546 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3547 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3548 | "Capability to SEND the ORF to this neighbor\n") | |
3549 | { | |
c500ae40 DW |
3550 | int idx_peer = 1; |
3551 | int idx_send_recv = 5; | |
718e3744 | 3552 | u_int16_t flag = 0; |
3553 | ||
c500ae40 | 3554 | if (strncmp (argv[idx_send_recv]->arg, "s", 1) == 0) |
718e3744 | 3555 | flag = PEER_FLAG_ORF_PREFIX_SM; |
c500ae40 | 3556 | else if (strncmp (argv[idx_send_recv]->arg, "r", 1) == 0) |
718e3744 | 3557 | flag = PEER_FLAG_ORF_PREFIX_RM; |
c500ae40 | 3558 | else if (strncmp (argv[idx_send_recv]->arg, "b", 1) == 0) |
718e3744 | 3559 | flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM; |
3560 | else | |
3561 | return CMD_WARNING; | |
3562 | ||
c500ae40 | 3563 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 3564 | bgp_node_safi (vty), flag); |
3565 | } | |
3566 | ||
3567 | DEFUN (no_neighbor_capability_orf_prefix, | |
3568 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3569 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3570 | NO_STR |
3571 | NEIGHBOR_STR | |
3572 | NEIGHBOR_ADDR_STR2 | |
3573 | "Advertise capability to the peer\n" | |
3574 | "Advertise ORF capability to the peer\n" | |
3575 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3576 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3577 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3578 | "Capability to SEND the ORF to this neighbor\n") | |
3579 | { | |
c500ae40 DW |
3580 | int idx_peer = 2; |
3581 | int idx_send_recv = 6; | |
718e3744 | 3582 | u_int16_t flag = 0; |
3583 | ||
c500ae40 | 3584 | if (strncmp (argv[idx_send_recv]->arg, "s", 1) == 0) |
718e3744 | 3585 | flag = PEER_FLAG_ORF_PREFIX_SM; |
c500ae40 | 3586 | else if (strncmp (argv[idx_send_recv]->arg, "r", 1) == 0) |
718e3744 | 3587 | flag = PEER_FLAG_ORF_PREFIX_RM; |
c500ae40 | 3588 | else if (strncmp (argv[idx_send_recv]->arg, "b", 1) == 0) |
718e3744 | 3589 | flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM; |
3590 | else | |
3591 | return CMD_WARNING; | |
3592 | ||
c500ae40 | 3593 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 3594 | bgp_node_safi (vty), flag); |
3595 | } | |
6b0655a2 | 3596 | |
718e3744 | 3597 | /* neighbor next-hop-self. */ |
3598 | DEFUN (neighbor_nexthop_self, | |
3599 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3600 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3601 | NEIGHBOR_STR |
3602 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3603 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3604 | { |
c500ae40 DW |
3605 | int idx_peer = 1; |
3606 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
a538debe DS |
3607 | bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF); |
3608 | } | |
9e7a53c1 | 3609 | |
a538debe DS |
3610 | /* neighbor next-hop-self. */ |
3611 | DEFUN (neighbor_nexthop_self_force, | |
3612 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 3613 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3614 | NEIGHBOR_STR |
3615 | NEIGHBOR_ADDR_STR2 | |
3616 | "Disable the next hop calculation for this neighbor\n" | |
3617 | "Set the next hop to self for reflected routes\n") | |
3618 | { | |
c500ae40 DW |
3619 | int idx_peer = 1; |
3620 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
a538debe | 3621 | bgp_node_safi (vty), |
88b8ed8d | 3622 | PEER_FLAG_FORCE_NEXTHOP_SELF); |
718e3744 | 3623 | } |
3624 | ||
3625 | DEFUN (no_neighbor_nexthop_self, | |
3626 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3627 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3628 | NO_STR |
3629 | NEIGHBOR_STR | |
3630 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3631 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3632 | { |
c500ae40 DW |
3633 | int idx_peer = 2; |
3634 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
9e7a53c1 | 3635 | bgp_node_safi (vty), |
88b8ed8d | 3636 | PEER_FLAG_NEXTHOP_SELF); |
718e3744 | 3637 | } |
6b0655a2 | 3638 | |
88b8ed8d | 3639 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 3640 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 3641 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3642 | NO_STR |
3643 | NEIGHBOR_STR | |
3644 | NEIGHBOR_ADDR_STR2 | |
3645 | "Disable the next hop calculation for this neighbor\n" | |
3646 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 3647 | { |
c500ae40 DW |
3648 | int idx_peer = 2; |
3649 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
3650 | bgp_node_safi (vty), |
3651 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
3652 | } | |
a538debe | 3653 | |
c7122e14 DS |
3654 | /* neighbor as-override */ |
3655 | DEFUN (neighbor_as_override, | |
3656 | neighbor_as_override_cmd, | |
9ccf14f7 | 3657 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3658 | NEIGHBOR_STR |
3659 | NEIGHBOR_ADDR_STR2 | |
3660 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3661 | { | |
c500ae40 DW |
3662 | int idx_peer = 1; |
3663 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
c7122e14 DS |
3664 | bgp_node_safi (vty), |
3665 | PEER_FLAG_AS_OVERRIDE); | |
3666 | } | |
3667 | ||
3668 | DEFUN (no_neighbor_as_override, | |
3669 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 3670 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3671 | NO_STR |
3672 | NEIGHBOR_STR | |
3673 | NEIGHBOR_ADDR_STR2 | |
3674 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3675 | { | |
c500ae40 DW |
3676 | int idx_peer = 2; |
3677 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
c7122e14 DS |
3678 | bgp_node_safi (vty), |
3679 | PEER_FLAG_AS_OVERRIDE); | |
3680 | } | |
3681 | ||
718e3744 | 3682 | /* neighbor remove-private-AS. */ |
3683 | DEFUN (neighbor_remove_private_as, | |
3684 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3685 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3686 | NEIGHBOR_STR |
3687 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3688 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3689 | { |
c500ae40 DW |
3690 | int idx_peer = 1; |
3691 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3692 | bgp_node_safi (vty), |
3693 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
3694 | } | |
3695 | ||
5000f21c DS |
3696 | DEFUN (neighbor_remove_private_as_all, |
3697 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 3698 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
3699 | NEIGHBOR_STR |
3700 | NEIGHBOR_ADDR_STR2 | |
3701 | "Remove private ASNs in outbound updates\n" | |
3702 | "Apply to all AS numbers") | |
3703 | { | |
c500ae40 DW |
3704 | int idx_peer = 1; |
3705 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5000f21c | 3706 | bgp_node_safi (vty), |
5000f21c DS |
3707 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); |
3708 | } | |
3709 | ||
3710 | DEFUN (neighbor_remove_private_as_replace_as, | |
3711 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 3712 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
3713 | NEIGHBOR_STR |
3714 | NEIGHBOR_ADDR_STR2 | |
3715 | "Remove private ASNs in outbound updates\n" | |
3716 | "Replace private ASNs with our ASN in outbound updates\n") | |
3717 | { | |
c500ae40 DW |
3718 | int idx_peer = 1; |
3719 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5000f21c | 3720 | bgp_node_safi (vty), |
5000f21c DS |
3721 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); |
3722 | } | |
3723 | ||
3724 | DEFUN (neighbor_remove_private_as_all_replace_as, | |
3725 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 3726 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
3727 | NEIGHBOR_STR |
3728 | NEIGHBOR_ADDR_STR2 | |
3729 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3730 | "Apply to all AS numbers\n" |
5000f21c DS |
3731 | "Replace private ASNs with our ASN in outbound updates\n") |
3732 | { | |
c500ae40 DW |
3733 | int idx_peer = 1; |
3734 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5000f21c | 3735 | bgp_node_safi (vty), |
88b8ed8d | 3736 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); |
5000f21c DS |
3737 | } |
3738 | ||
718e3744 | 3739 | DEFUN (no_neighbor_remove_private_as, |
3740 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3741 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3742 | NO_STR |
3743 | NEIGHBOR_STR | |
3744 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3745 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3746 | { |
c500ae40 DW |
3747 | int idx_peer = 2; |
3748 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3749 | bgp_node_safi (vty), |
88b8ed8d | 3750 | PEER_FLAG_REMOVE_PRIVATE_AS); |
718e3744 | 3751 | } |
6b0655a2 | 3752 | |
88b8ed8d | 3753 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 3754 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 3755 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
3756 | NO_STR |
3757 | NEIGHBOR_STR | |
3758 | NEIGHBOR_ADDR_STR2 | |
3759 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3760 | "Apply to all AS numbers\n") |
88b8ed8d | 3761 | { |
c500ae40 DW |
3762 | int idx_peer = 2; |
3763 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
3764 | bgp_node_safi (vty), |
3765 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
3766 | } | |
5000f21c | 3767 | |
88b8ed8d | 3768 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 3769 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 3770 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
3771 | NO_STR |
3772 | NEIGHBOR_STR | |
3773 | NEIGHBOR_ADDR_STR2 | |
3774 | "Remove private ASNs in outbound updates\n" | |
3775 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 3776 | { |
c500ae40 DW |
3777 | int idx_peer = 2; |
3778 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
3779 | bgp_node_safi (vty), |
3780 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
3781 | } | |
5000f21c | 3782 | |
88b8ed8d | 3783 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 3784 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 3785 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
3786 | NO_STR |
3787 | NEIGHBOR_STR | |
3788 | NEIGHBOR_ADDR_STR2 | |
3789 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3790 | "Apply to all AS numbers\n" |
5000f21c | 3791 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 3792 | { |
c500ae40 DW |
3793 | int idx_peer = 2; |
3794 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
3795 | bgp_node_safi (vty), |
3796 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
3797 | } | |
5000f21c DS |
3798 | |
3799 | ||
718e3744 | 3800 | /* neighbor send-community. */ |
3801 | DEFUN (neighbor_send_community, | |
3802 | neighbor_send_community_cmd, | |
9ccf14f7 | 3803 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 3804 | NEIGHBOR_STR |
3805 | NEIGHBOR_ADDR_STR2 | |
3806 | "Send Community attribute to this neighbor\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), | |
718e3744 | 3810 | bgp_node_safi (vty), |
3811 | PEER_FLAG_SEND_COMMUNITY); | |
3812 | } | |
3813 | ||
3814 | DEFUN (no_neighbor_send_community, | |
3815 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 3816 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 3817 | NO_STR |
3818 | NEIGHBOR_STR | |
3819 | NEIGHBOR_ADDR_STR2 | |
3820 | "Send Community attribute to this neighbor\n") | |
3821 | { | |
c500ae40 DW |
3822 | int idx_peer = 2; |
3823 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3824 | bgp_node_safi (vty), |
3825 | PEER_FLAG_SEND_COMMUNITY); | |
3826 | } | |
6b0655a2 | 3827 | |
718e3744 | 3828 | /* neighbor send-community extended. */ |
3829 | DEFUN (neighbor_send_community_type, | |
3830 | neighbor_send_community_type_cmd, | |
57d187bc | 3831 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 3832 | NEIGHBOR_STR |
3833 | NEIGHBOR_ADDR_STR2 | |
3834 | "Send Community attribute to this neighbor\n" | |
3835 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 3836 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 3837 | "Send Extended Community attributes\n" |
57d187bc JS |
3838 | "Send Standard Community attributes\n" |
3839 | "Send Large Community attributes\n") | |
718e3744 | 3840 | { |
4c4ff4c1 QY |
3841 | int idx = 0; |
3842 | u_int32_t flag = 0; | |
718e3744 | 3843 | |
4c4ff4c1 QY |
3844 | char *peer = argv[1]->arg; |
3845 | ||
3846 | if (argv_find (argv, argc, "standard", &idx)) | |
3847 | SET_FLAG (flag, PEER_FLAG_SEND_COMMUNITY); | |
3848 | else if (argv_find (argv, argc, "extended", &idx)) | |
3849 | SET_FLAG (flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
57d187bc JS |
3850 | else if (argv_find (argv, argc, "large", &idx)) |
3851 | SET_FLAG (flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
3852 | else if (argv_find (argv, argc, "both", &idx)) | |
3853 | { | |
3854 | SET_FLAG (flag, PEER_FLAG_SEND_COMMUNITY); | |
3855 | SET_FLAG (flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
3856 | } | |
4c4ff4c1 | 3857 | else |
57d187bc JS |
3858 | { |
3859 | SET_FLAG (flag, PEER_FLAG_SEND_COMMUNITY); | |
3860 | SET_FLAG (flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
3861 | SET_FLAG (flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
3862 | } | |
4c4ff4c1 QY |
3863 | |
3864 | return peer_af_flag_set_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flag); | |
718e3744 | 3865 | } |
3866 | ||
3867 | DEFUN (no_neighbor_send_community_type, | |
3868 | no_neighbor_send_community_type_cmd, | |
57d187bc | 3869 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 3870 | NO_STR |
3871 | NEIGHBOR_STR | |
3872 | NEIGHBOR_ADDR_STR2 | |
3873 | "Send Community attribute to this neighbor\n" | |
3874 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 3875 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 3876 | "Send Extended Community attributes\n" |
57d187bc JS |
3877 | "Send Standard Community attributes\n" |
3878 | "Send Large Community attributes\n") | |
718e3744 | 3879 | { |
c500ae40 DW |
3880 | int idx_peer = 2; |
3881 | int idx_type = 4; | |
3882 | if (strncmp (argv[idx_type]->arg, "s", 1) == 0) | |
3883 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3884 | bgp_node_safi (vty), |
3885 | PEER_FLAG_SEND_COMMUNITY); | |
c500ae40 DW |
3886 | if (strncmp (argv[idx_type]->arg, "e", 1) == 0) |
3887 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3888 | bgp_node_safi (vty), |
3889 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
57d187bc JS |
3890 | if (strncmp (argv[idx_type]->arg, "l", 1) == 0) |
3891 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
3892 | bgp_node_safi (vty), | |
3893 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
3894 | if (strncmp (argv[idx_type]->arg, "b", 1) == 0) | |
3895 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
3896 | bgp_node_safi (vty), | |
3897 | PEER_FLAG_SEND_COMMUNITY | | |
3898 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
718e3744 | 3899 | |
c500ae40 | 3900 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 3901 | bgp_node_safi (vty), |
3902 | (PEER_FLAG_SEND_COMMUNITY | | |
57d187bc JS |
3903 | PEER_FLAG_SEND_EXT_COMMUNITY| |
3904 | PEER_FLAG_SEND_LARGE_COMMUNITY)); | |
718e3744 | 3905 | } |
6b0655a2 | 3906 | |
718e3744 | 3907 | /* neighbor soft-reconfig. */ |
3908 | DEFUN (neighbor_soft_reconfiguration, | |
3909 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 3910 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 3911 | NEIGHBOR_STR |
3912 | NEIGHBOR_ADDR_STR2 | |
3913 | "Per neighbor soft reconfiguration\n" | |
3914 | "Allow inbound soft reconfiguration for this neighbor\n") | |
3915 | { | |
c500ae40 DW |
3916 | int idx_peer = 1; |
3917 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, | |
718e3744 | 3918 | bgp_node_afi (vty), bgp_node_safi (vty), |
3919 | PEER_FLAG_SOFT_RECONFIG); | |
3920 | } | |
3921 | ||
3922 | DEFUN (no_neighbor_soft_reconfiguration, | |
3923 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 3924 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 3925 | NO_STR |
3926 | NEIGHBOR_STR | |
3927 | NEIGHBOR_ADDR_STR2 | |
3928 | "Per neighbor soft reconfiguration\n" | |
3929 | "Allow inbound soft reconfiguration for this neighbor\n") | |
3930 | { | |
c500ae40 DW |
3931 | int idx_peer = 2; |
3932 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, | |
718e3744 | 3933 | bgp_node_afi (vty), bgp_node_safi (vty), |
3934 | PEER_FLAG_SOFT_RECONFIG); | |
3935 | } | |
6b0655a2 | 3936 | |
718e3744 | 3937 | DEFUN (neighbor_route_reflector_client, |
3938 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 3939 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 3940 | NEIGHBOR_STR |
3941 | NEIGHBOR_ADDR_STR2 | |
3942 | "Configure a neighbor as Route Reflector client\n") | |
3943 | { | |
c500ae40 | 3944 | int idx_peer = 1; |
718e3744 | 3945 | struct peer *peer; |
3946 | ||
3947 | ||
c500ae40 | 3948 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3949 | if (! peer) |
3950 | return CMD_WARNING; | |
3951 | ||
c500ae40 | 3952 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 3953 | bgp_node_safi (vty), |
3954 | PEER_FLAG_REFLECTOR_CLIENT); | |
3955 | } | |
3956 | ||
3957 | DEFUN (no_neighbor_route_reflector_client, | |
3958 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 3959 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 3960 | NO_STR |
3961 | NEIGHBOR_STR | |
3962 | NEIGHBOR_ADDR_STR2 | |
3963 | "Configure a neighbor as Route Reflector client\n") | |
3964 | { | |
c500ae40 DW |
3965 | int idx_peer = 2; |
3966 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3967 | bgp_node_safi (vty), |
3968 | PEER_FLAG_REFLECTOR_CLIENT); | |
3969 | } | |
6b0655a2 | 3970 | |
718e3744 | 3971 | /* neighbor route-server-client. */ |
3972 | DEFUN (neighbor_route_server_client, | |
3973 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 3974 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 3975 | NEIGHBOR_STR |
3976 | NEIGHBOR_ADDR_STR2 | |
3977 | "Configure a neighbor as Route Server client\n") | |
3978 | { | |
c500ae40 | 3979 | int idx_peer = 1; |
2a3d5731 DW |
3980 | struct peer *peer; |
3981 | ||
c500ae40 | 3982 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
2a3d5731 DW |
3983 | if (! peer) |
3984 | return CMD_WARNING; | |
c500ae40 | 3985 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
2a3d5731 DW |
3986 | bgp_node_safi (vty), |
3987 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 3988 | } |
3989 | ||
3990 | DEFUN (no_neighbor_route_server_client, | |
3991 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 3992 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 3993 | NO_STR |
3994 | NEIGHBOR_STR | |
3995 | NEIGHBOR_ADDR_STR2 | |
3996 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 3997 | { |
c500ae40 DW |
3998 | int idx_peer = 2; |
3999 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
2a3d5731 DW |
4000 | bgp_node_safi (vty), |
4001 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 4002 | } |
6b0655a2 | 4003 | |
fee0f4c6 | 4004 | DEFUN (neighbor_nexthop_local_unchanged, |
4005 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4006 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4007 | NEIGHBOR_STR |
4008 | NEIGHBOR_ADDR_STR2 | |
4009 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
4010 | "Leave link-local nexthop unchanged for this peer\n") | |
4011 | { | |
c500ae40 DW |
4012 | int idx_peer = 1; |
4013 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
fee0f4c6 | 4014 | bgp_node_safi (vty), |
4015 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED ); | |
4016 | } | |
6b0655a2 | 4017 | |
fee0f4c6 | 4018 | DEFUN (no_neighbor_nexthop_local_unchanged, |
4019 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4020 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4021 | NO_STR |
4022 | NEIGHBOR_STR | |
4023 | NEIGHBOR_ADDR_STR2 | |
4024 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
4025 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 4026 | { |
c500ae40 DW |
4027 | int idx_peer = 2; |
4028 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4029 | bgp_node_safi (vty), |
fee0f4c6 | 4030 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED ); |
718e3744 | 4031 | } |
6b0655a2 | 4032 | |
718e3744 | 4033 | DEFUN (neighbor_attr_unchanged, |
4034 | neighbor_attr_unchanged_cmd, | |
1084263f QY |
4035 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged\ |
4036 | [<\ | |
ddbaf941 QY |
4037 | as-path [<next-hop [med]|med [next-hop]>]|\ |
4038 | next-hop [<as-path [med]|med [as-path]>]|\ | |
4039 | med [<as-path [next-hop]|next-hop [as-path]>]\ | |
1084263f | 4040 | >]", |
718e3744 | 4041 | NEIGHBOR_STR |
4042 | NEIGHBOR_ADDR_STR2 | |
4043 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4044 | "As-path attribute\n" | |
4045 | "Nexthop attribute\n" | |
40e718b5 | 4046 | "Med attribute\n" |
1084263f QY |
4047 | "Med attribute\n" |
4048 | "Nexthop attribute\n" | |
4049 | "Nexthop attribute\n" | |
4050 | "As-path attribute\n" | |
4051 | "Med attribute\n" | |
40e718b5 | 4052 | "Med attribute\n" |
718e3744 | 4053 | "As-path attribute\n" |
1084263f QY |
4054 | "Med attribute\n" |
4055 | "As-path attribute\n" | |
4056 | "Nexthop attribute\n" | |
40e718b5 | 4057 | "Nexthop attribute\n" |
1084263f | 4058 | "As-path attribute\n") |
718e3744 | 4059 | { |
40e718b5 QY |
4060 | int idx = 0; |
4061 | char *peer = argv[1]->arg; | |
4062 | u_int16_t flags = 0; | |
718e3744 | 4063 | |
40e718b5 | 4064 | if (argv_find (argv, argc, "as-path", &idx)) |
718e3744 | 4065 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
40e718b5 QY |
4066 | idx = 0; |
4067 | if (argv_find (argv, argc, "next-hop", &idx)) | |
4068 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4069 | idx = 0; | |
4070 | if (argv_find (argv, argc, "med", &idx)) | |
718e3744 | 4071 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
4072 | ||
40e718b5 QY |
4073 | if (!flags) // no flags means all of them! |
4074 | { | |
718e3744 | 4075 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
718e3744 | 4076 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); |
40e718b5 QY |
4077 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
4078 | } | |
718e3744 | 4079 | |
40e718b5 | 4080 | return peer_af_flag_set_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flags); |
718e3744 | 4081 | } |
4082 | ||
718e3744 | 4083 | DEFUN (no_neighbor_attr_unchanged, |
4084 | no_neighbor_attr_unchanged_cmd, | |
1084263f QY |
4085 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged\ |
4086 | [<\ | |
ddbaf941 QY |
4087 | as-path [<next-hop [med]|med [next-hop]>]|\ |
4088 | next-hop [<as-path [med]|med [as-path]>]|\ | |
4089 | med [<as-path [next-hop]|next-hop [as-path]>]\ | |
1084263f | 4090 | >]", |
e52702f2 | 4091 | NO_STR |
718e3744 | 4092 | NEIGHBOR_STR |
4093 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
4094 | "BGP attribute is propagated unchanged to this neighbor\n" |
4095 | "As-path attribute\n" | |
40e718b5 | 4096 | "Nexthop attribute\n" |
31500417 | 4097 | "Med attribute\n" |
1084263f QY |
4098 | "Med attribute\n" |
4099 | "Nexthop attribute\n" | |
4100 | "Nexthop attribute\n" | |
4101 | "As-path attribute\n" | |
4102 | "Med attribute\n" | |
40e718b5 | 4103 | "Med attribute\n" |
718e3744 | 4104 | "As-path attribute\n" |
1084263f QY |
4105 | "Med attribute\n" |
4106 | "As-path attribute\n" | |
4107 | "Nexthop attribute\n" | |
718e3744 | 4108 | "Nexthop attribute\n" |
1084263f | 4109 | "As-path attribute\n") |
718e3744 | 4110 | { |
40e718b5 QY |
4111 | int idx = 0; |
4112 | char *peer = argv[2]->arg; | |
4113 | u_int16_t flags = 0; | |
718e3744 | 4114 | |
40e718b5 | 4115 | if (argv_find (argv, argc, "as-path", &idx)) |
718e3744 | 4116 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
40e718b5 QY |
4117 | idx = 0; |
4118 | if (argv_find (argv, argc, "next-hop", &idx)) | |
4119 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4120 | idx = 0; | |
4121 | if (argv_find (argv, argc, "med", &idx)) | |
718e3744 | 4122 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
4123 | ||
40e718b5 QY |
4124 | if (!flags) // no flags means all of them! |
4125 | { | |
718e3744 | 4126 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
718e3744 | 4127 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); |
40e718b5 QY |
4128 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
4129 | } | |
718e3744 | 4130 | |
40e718b5 | 4131 | return peer_af_flag_unset_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flags); |
718e3744 | 4132 | } |
4133 | ||
718e3744 | 4134 | |
718e3744 | 4135 | /* EBGP multihop configuration. */ |
94f2b392 | 4136 | static int |
e52702f2 | 4137 | peer_ebgp_multihop_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4138 | const char *ttl_str) |
718e3744 | 4139 | { |
4140 | struct peer *peer; | |
fd79ac91 | 4141 | unsigned int ttl; |
718e3744 | 4142 | |
4143 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4144 | if (! peer) | |
4145 | return CMD_WARNING; | |
4146 | ||
63fa10b5 QY |
4147 | if (peer->conf_if) |
4148 | return bgp_vty_return (vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
4149 | ||
718e3744 | 4150 | if (! ttl_str) |
9b1be336 | 4151 | ttl = MAXTTL; |
718e3744 | 4152 | else |
9b1be336 | 4153 | VTY_GET_INTEGER_RANGE ("TTL", ttl, ttl_str, 1, MAXTTL); |
718e3744 | 4154 | |
89b6d1f8 | 4155 | return bgp_vty_return (vty, peer_ebgp_multihop_set (peer, ttl)); |
718e3744 | 4156 | } |
4157 | ||
94f2b392 | 4158 | static int |
e52702f2 | 4159 | peer_ebgp_multihop_unset_vty (struct vty *vty, const char *ip_str) |
718e3744 | 4160 | { |
4161 | struct peer *peer; | |
4162 | ||
4163 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4164 | if (! peer) | |
4165 | return CMD_WARNING; | |
4166 | ||
89b6d1f8 | 4167 | return bgp_vty_return (vty, peer_ebgp_multihop_unset (peer)); |
718e3744 | 4168 | } |
4169 | ||
4170 | /* neighbor ebgp-multihop. */ | |
4171 | DEFUN (neighbor_ebgp_multihop, | |
4172 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 4173 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 4174 | NEIGHBOR_STR |
4175 | NEIGHBOR_ADDR_STR2 | |
4176 | "Allow EBGP neighbors not on directly connected networks\n") | |
4177 | { | |
c500ae40 DW |
4178 | int idx_peer = 1; |
4179 | return peer_ebgp_multihop_set_vty (vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4180 | } |
4181 | ||
4182 | DEFUN (neighbor_ebgp_multihop_ttl, | |
4183 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 4184 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 4185 | NEIGHBOR_STR |
4186 | NEIGHBOR_ADDR_STR2 | |
4187 | "Allow EBGP neighbors not on directly connected networks\n" | |
4188 | "maximum hop count\n") | |
4189 | { | |
c500ae40 DW |
4190 | int idx_peer = 1; |
4191 | int idx_number = 3; | |
4192 | return peer_ebgp_multihop_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg); | |
718e3744 | 4193 | } |
4194 | ||
4195 | DEFUN (no_neighbor_ebgp_multihop, | |
4196 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 4197 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 4198 | NO_STR |
4199 | NEIGHBOR_STR | |
4200 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4201 | "Allow EBGP neighbors not on directly connected networks\n" |
4202 | "maximum hop count\n") | |
718e3744 | 4203 | { |
c500ae40 DW |
4204 | int idx_peer = 2; |
4205 | return peer_ebgp_multihop_unset_vty (vty, argv[idx_peer]->arg); | |
718e3744 | 4206 | } |
4207 | ||
6b0655a2 | 4208 | |
6ffd2079 | 4209 | /* disable-connected-check */ |
4210 | DEFUN (neighbor_disable_connected_check, | |
4211 | neighbor_disable_connected_check_cmd, | |
a636c635 | 4212 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4213 | NEIGHBOR_STR |
4214 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4215 | "one-hop away EBGP peer using loopback address\n" |
4216 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4217 | { |
c500ae40 DW |
4218 | int idx_peer = 1; |
4219 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4220 | } |
4221 | ||
4222 | DEFUN (no_neighbor_disable_connected_check, | |
4223 | no_neighbor_disable_connected_check_cmd, | |
a636c635 | 4224 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4225 | NO_STR |
4226 | NEIGHBOR_STR | |
4227 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4228 | "one-hop away EBGP peer using loopback address\n" |
4229 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4230 | { |
c500ae40 DW |
4231 | int idx_peer = 2; |
4232 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4233 | } |
4234 | ||
718e3744 | 4235 | DEFUN (neighbor_description, |
4236 | neighbor_description_cmd, | |
e961923c | 4237 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 4238 | NEIGHBOR_STR |
4239 | NEIGHBOR_ADDR_STR2 | |
4240 | "Neighbor specific description\n" | |
4241 | "Up to 80 characters describing this neighbor\n") | |
4242 | { | |
c500ae40 | 4243 | int idx_peer = 1; |
58749582 | 4244 | int idx_line = 3; |
718e3744 | 4245 | struct peer *peer; |
718e3744 | 4246 | char *str; |
718e3744 | 4247 | |
c500ae40 | 4248 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 4249 | if (! peer) |
4250 | return CMD_WARNING; | |
4251 | ||
58749582 | 4252 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 4253 | |
4254 | peer_description_set (peer, str); | |
4255 | ||
3b8b1855 | 4256 | XFREE (MTYPE_TMP, str); |
718e3744 | 4257 | |
4258 | return CMD_SUCCESS; | |
4259 | } | |
4260 | ||
4261 | DEFUN (no_neighbor_description, | |
4262 | no_neighbor_description_cmd, | |
a636c635 | 4263 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description [LINE]", |
718e3744 | 4264 | NO_STR |
4265 | NEIGHBOR_STR | |
4266 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4267 | "Neighbor specific description\n" |
4268 | "Up to 80 characters describing this neighbor\n") | |
718e3744 | 4269 | { |
c500ae40 | 4270 | int idx_peer = 2; |
718e3744 | 4271 | struct peer *peer; |
4272 | ||
c500ae40 | 4273 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 4274 | if (! peer) |
4275 | return CMD_WARNING; | |
4276 | ||
4277 | peer_description_unset (peer); | |
4278 | ||
4279 | return CMD_SUCCESS; | |
4280 | } | |
4281 | ||
6b0655a2 | 4282 | |
718e3744 | 4283 | /* Neighbor update-source. */ |
94f2b392 | 4284 | static int |
e52702f2 | 4285 | peer_update_source_vty (struct vty *vty, const char *peer_str, |
fd79ac91 | 4286 | const char *source_str) |
718e3744 | 4287 | { |
4288 | struct peer *peer; | |
3b69fd51 | 4289 | struct prefix p; |
718e3744 | 4290 | |
4291 | peer = peer_and_group_lookup_vty (vty, peer_str); | |
4292 | if (! peer) | |
4293 | return CMD_WARNING; | |
4294 | ||
a80beece DS |
4295 | if (peer->conf_if) |
4296 | return CMD_WARNING; | |
4297 | ||
718e3744 | 4298 | if (source_str) |
4299 | { | |
c63b83fe JBD |
4300 | union sockunion su; |
4301 | int ret = str2sockunion (source_str, &su); | |
4302 | ||
4303 | if (ret == 0) | |
4304 | peer_update_source_addr_set (peer, &su); | |
718e3744 | 4305 | else |
3b69fd51 DS |
4306 | { |
4307 | if (str2prefix (source_str, &p)) | |
4308 | { | |
4309 | vty_out (vty, "%% Invalid update-source, remove prefix length %s", | |
4310 | VTY_NEWLINE); | |
4311 | return CMD_WARNING; | |
4312 | } | |
4313 | else | |
4314 | peer_update_source_if_set (peer, source_str); | |
4315 | } | |
718e3744 | 4316 | } |
4317 | else | |
4318 | peer_update_source_unset (peer); | |
4319 | ||
4320 | return CMD_SUCCESS; | |
4321 | } | |
4322 | ||
369688c0 PJ |
4323 | #define BGP_UPDATE_SOURCE_HELP_STR \ |
4324 | "IPv4 address\n" \ | |
9a1a331d PJ |
4325 | "IPv6 address\n" \ |
4326 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 4327 | |
718e3744 | 4328 | DEFUN (neighbor_update_source, |
4329 | neighbor_update_source_cmd, | |
9ccf14f7 | 4330 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 4331 | NEIGHBOR_STR |
4332 | NEIGHBOR_ADDR_STR2 | |
4333 | "Source of routing updates\n" | |
369688c0 | 4334 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 4335 | { |
c500ae40 DW |
4336 | int idx_peer = 1; |
4337 | int idx_peer_2 = 3; | |
4338 | return peer_update_source_vty (vty, argv[idx_peer]->arg, argv[idx_peer_2]->arg); | |
718e3744 | 4339 | } |
4340 | ||
4341 | DEFUN (no_neighbor_update_source, | |
4342 | no_neighbor_update_source_cmd, | |
c7178fe7 | 4343 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 4344 | NO_STR |
4345 | NEIGHBOR_STR | |
4346 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
4347 | "Source of routing updates\n" |
4348 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 4349 | { |
c500ae40 DW |
4350 | int idx_peer = 2; |
4351 | return peer_update_source_vty (vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4352 | } |
6b0655a2 | 4353 | |
94f2b392 | 4354 | static int |
e52702f2 QY |
4355 | peer_default_originate_set_vty (struct vty *vty, const char *peer_str, |
4356 | afi_t afi, safi_t safi, | |
fd79ac91 | 4357 | const char *rmap, int set) |
718e3744 | 4358 | { |
4359 | int ret; | |
4360 | struct peer *peer; | |
4361 | ||
4362 | peer = peer_and_group_lookup_vty (vty, peer_str); | |
4363 | if (! peer) | |
4364 | return CMD_WARNING; | |
4365 | ||
4366 | if (set) | |
4367 | ret = peer_default_originate_set (peer, afi, safi, rmap); | |
4368 | else | |
4369 | ret = peer_default_originate_unset (peer, afi, safi); | |
4370 | ||
4371 | return bgp_vty_return (vty, ret); | |
4372 | } | |
4373 | ||
4374 | /* neighbor default-originate. */ | |
4375 | DEFUN (neighbor_default_originate, | |
4376 | neighbor_default_originate_cmd, | |
9ccf14f7 | 4377 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 4378 | NEIGHBOR_STR |
4379 | NEIGHBOR_ADDR_STR2 | |
4380 | "Originate default route to this neighbor\n") | |
4381 | { | |
c500ae40 DW |
4382 | int idx_peer = 1; |
4383 | return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4384 | bgp_node_safi (vty), NULL, 1); |
4385 | } | |
4386 | ||
4387 | DEFUN (neighbor_default_originate_rmap, | |
4388 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 4389 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 4390 | NEIGHBOR_STR |
4391 | NEIGHBOR_ADDR_STR2 | |
4392 | "Originate default route to this neighbor\n" | |
4393 | "Route-map to specify criteria to originate default\n" | |
4394 | "route-map name\n") | |
4395 | { | |
c500ae40 DW |
4396 | int idx_peer = 1; |
4397 | int idx_word = 4; | |
4398 | return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4399 | bgp_node_safi (vty), argv[idx_word]->arg, 1); | |
718e3744 | 4400 | } |
4401 | ||
4402 | DEFUN (no_neighbor_default_originate, | |
4403 | no_neighbor_default_originate_cmd, | |
a636c635 | 4404 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 4405 | NO_STR |
4406 | NEIGHBOR_STR | |
4407 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4408 | "Originate default route to this neighbor\n" |
4409 | "Route-map to specify criteria to originate default\n" | |
4410 | "route-map name\n") | |
718e3744 | 4411 | { |
c500ae40 DW |
4412 | int idx_peer = 2; |
4413 | return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4414 | bgp_node_safi (vty), NULL, 0); |
4415 | } | |
4416 | ||
6b0655a2 | 4417 | |
718e3744 | 4418 | /* Set neighbor's BGP port. */ |
94f2b392 | 4419 | static int |
e52702f2 | 4420 | peer_port_vty (struct vty *vty, const char *ip_str, int afi, |
fd79ac91 | 4421 | const char *port_str) |
718e3744 | 4422 | { |
4423 | struct peer *peer; | |
4424 | u_int16_t port; | |
4425 | struct servent *sp; | |
4426 | ||
4427 | peer = peer_lookup_vty (vty, ip_str); | |
4428 | if (! peer) | |
4429 | return CMD_WARNING; | |
4430 | ||
4431 | if (! port_str) | |
e52702f2 | 4432 | { |
718e3744 | 4433 | sp = getservbyname ("bgp", "tcp"); |
4434 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs (sp->s_port); | |
4435 | } | |
4436 | else | |
4437 | { | |
4438 | VTY_GET_INTEGER("port", port, port_str); | |
4439 | } | |
4440 | ||
4441 | peer_port_set (peer, port); | |
4442 | ||
4443 | return CMD_SUCCESS; | |
4444 | } | |
4445 | ||
f418446b | 4446 | /* Set specified peer's BGP port. */ |
718e3744 | 4447 | DEFUN (neighbor_port, |
4448 | neighbor_port_cmd, | |
9ccf14f7 | 4449 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 4450 | NEIGHBOR_STR |
4451 | NEIGHBOR_ADDR_STR | |
4452 | "Neighbor's BGP port\n" | |
4453 | "TCP port number\n") | |
4454 | { | |
c500ae40 DW |
4455 | int idx_ip = 1; |
4456 | int idx_number = 3; | |
4457 | return peer_port_vty (vty, argv[idx_ip]->arg, AFI_IP, argv[idx_number]->arg); | |
718e3744 | 4458 | } |
4459 | ||
4460 | DEFUN (no_neighbor_port, | |
4461 | no_neighbor_port_cmd, | |
9ccf14f7 | 4462 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 4463 | NO_STR |
4464 | NEIGHBOR_STR | |
4465 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
4466 | "Neighbor's BGP port\n" |
4467 | "TCP port number\n") | |
718e3744 | 4468 | { |
c500ae40 DW |
4469 | int idx_ip = 2; |
4470 | return peer_port_vty (vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 4471 | } |
4472 | ||
6b0655a2 | 4473 | |
718e3744 | 4474 | /* neighbor weight. */ |
94f2b392 | 4475 | static int |
e52702f2 | 4476 | peer_weight_set_vty (struct vty *vty, const char *ip_str, |
d93f7ffc | 4477 | afi_t afi, safi_t safi, |
fd79ac91 | 4478 | const char *weight_str) |
718e3744 | 4479 | { |
1f9a9fff | 4480 | int ret; |
718e3744 | 4481 | struct peer *peer; |
4482 | unsigned long weight; | |
4483 | ||
4484 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4485 | if (! peer) | |
4486 | return CMD_WARNING; | |
4487 | ||
4488 | VTY_GET_INTEGER_RANGE("weight", weight, weight_str, 0, 65535); | |
4489 | ||
d93f7ffc | 4490 | ret = peer_weight_set (peer, afi, safi, weight); |
1f9a9fff | 4491 | return bgp_vty_return (vty, ret); |
718e3744 | 4492 | } |
4493 | ||
94f2b392 | 4494 | static int |
d93f7ffc DW |
4495 | peer_weight_unset_vty (struct vty *vty, const char *ip_str, |
4496 | afi_t afi, safi_t safi) | |
718e3744 | 4497 | { |
1f9a9fff | 4498 | int ret; |
718e3744 | 4499 | struct peer *peer; |
4500 | ||
4501 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4502 | if (! peer) | |
4503 | return CMD_WARNING; | |
4504 | ||
d93f7ffc | 4505 | ret = peer_weight_unset (peer, afi, safi); |
1f9a9fff | 4506 | return bgp_vty_return (vty, ret); |
718e3744 | 4507 | } |
4508 | ||
4509 | DEFUN (neighbor_weight, | |
4510 | neighbor_weight_cmd, | |
9ccf14f7 | 4511 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 4512 | NEIGHBOR_STR |
4513 | NEIGHBOR_ADDR_STR2 | |
4514 | "Set default weight for routes from this neighbor\n" | |
4515 | "default weight\n") | |
4516 | { | |
c500ae40 DW |
4517 | int idx_peer = 1; |
4518 | int idx_number = 3; | |
e52702f2 QY |
4519 | return peer_weight_set_vty (vty, |
4520 | argv[idx_peer]->arg, | |
4521 | bgp_node_afi (vty), | |
4522 | bgp_node_safi (vty), | |
4523 | argv[idx_number]->arg); | |
718e3744 | 4524 | } |
4525 | ||
4526 | DEFUN (no_neighbor_weight, | |
4527 | no_neighbor_weight_cmd, | |
9ccf14f7 | 4528 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 4529 | NO_STR |
4530 | NEIGHBOR_STR | |
4531 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
4532 | "Set default weight for routes from this neighbor\n" |
4533 | "default weight\n") | |
718e3744 | 4534 | { |
c500ae40 | 4535 | int idx_peer = 2; |
e52702f2 | 4536 | return peer_weight_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty)); |
718e3744 | 4537 | } |
4538 | ||
6b0655a2 | 4539 | |
718e3744 | 4540 | /* Override capability negotiation. */ |
4541 | DEFUN (neighbor_override_capability, | |
4542 | neighbor_override_capability_cmd, | |
9ccf14f7 | 4543 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 4544 | NEIGHBOR_STR |
4545 | NEIGHBOR_ADDR_STR2 | |
4546 | "Override capability negotiation result\n") | |
4547 | { | |
c500ae40 DW |
4548 | int idx_peer = 1; |
4549 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 4550 | } |
4551 | ||
4552 | DEFUN (no_neighbor_override_capability, | |
4553 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 4554 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 4555 | NO_STR |
4556 | NEIGHBOR_STR | |
4557 | NEIGHBOR_ADDR_STR2 | |
4558 | "Override capability negotiation result\n") | |
4559 | { | |
c500ae40 DW |
4560 | int idx_peer = 2; |
4561 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 4562 | } |
6b0655a2 | 4563 | |
718e3744 | 4564 | DEFUN (neighbor_strict_capability, |
4565 | neighbor_strict_capability_cmd, | |
9ccf14f7 | 4566 | "neighbor <A.B.C.D|X:X::X:X> strict-capability-match", |
718e3744 | 4567 | NEIGHBOR_STR |
4568 | NEIGHBOR_ADDR_STR | |
4569 | "Strict capability negotiation match\n") | |
4570 | { | |
c500ae40 DW |
4571 | int idx_ip = 1; |
4572 | return peer_flag_set_vty (vty, argv[idx_ip]->arg, PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 4573 | } |
4574 | ||
4575 | DEFUN (no_neighbor_strict_capability, | |
4576 | no_neighbor_strict_capability_cmd, | |
9ccf14f7 | 4577 | "no neighbor <A.B.C.D|X:X::X:X> strict-capability-match", |
718e3744 | 4578 | NO_STR |
4579 | NEIGHBOR_STR | |
4580 | NEIGHBOR_ADDR_STR | |
4581 | "Strict capability negotiation match\n") | |
4582 | { | |
c500ae40 DW |
4583 | int idx_ip = 2; |
4584 | return peer_flag_unset_vty (vty, argv[idx_ip]->arg, PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 4585 | } |
6b0655a2 | 4586 | |
94f2b392 | 4587 | static int |
e52702f2 | 4588 | peer_timers_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4589 | const char *keep_str, const char *hold_str) |
718e3744 | 4590 | { |
4591 | int ret; | |
4592 | struct peer *peer; | |
4593 | u_int32_t keepalive; | |
4594 | u_int32_t holdtime; | |
4595 | ||
4596 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4597 | if (! peer) | |
4598 | return CMD_WARNING; | |
4599 | ||
4600 | VTY_GET_INTEGER_RANGE ("Keepalive", keepalive, keep_str, 0, 65535); | |
4601 | VTY_GET_INTEGER_RANGE ("Holdtime", holdtime, hold_str, 0, 65535); | |
4602 | ||
4603 | ret = peer_timers_set (peer, keepalive, holdtime); | |
4604 | ||
4605 | return bgp_vty_return (vty, ret); | |
4606 | } | |
6b0655a2 | 4607 | |
94f2b392 | 4608 | static int |
fd79ac91 | 4609 | peer_timers_unset_vty (struct vty *vty, const char *ip_str) |
718e3744 | 4610 | { |
4611 | int ret; | |
4612 | struct peer *peer; | |
4613 | ||
0c412461 | 4614 | peer = peer_and_group_lookup_vty (vty, ip_str); |
718e3744 | 4615 | if (! peer) |
4616 | return CMD_WARNING; | |
4617 | ||
4618 | ret = peer_timers_unset (peer); | |
4619 | ||
4620 | return bgp_vty_return (vty, ret); | |
4621 | } | |
4622 | ||
4623 | DEFUN (neighbor_timers, | |
4624 | neighbor_timers_cmd, | |
9ccf14f7 | 4625 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 4626 | NEIGHBOR_STR |
4627 | NEIGHBOR_ADDR_STR2 | |
4628 | "BGP per neighbor timers\n" | |
4629 | "Keepalive interval\n" | |
4630 | "Holdtime\n") | |
4631 | { | |
c500ae40 DW |
4632 | int idx_peer = 1; |
4633 | int idx_number = 3; | |
4634 | int idx_number_2 = 4; | |
4635 | return peer_timers_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg); | |
718e3744 | 4636 | } |
4637 | ||
4638 | DEFUN (no_neighbor_timers, | |
4639 | no_neighbor_timers_cmd, | |
9ccf14f7 | 4640 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 4641 | NO_STR |
4642 | NEIGHBOR_STR | |
4643 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
4644 | "BGP per neighbor timers\n" |
4645 | "Keepalive interval\n" | |
4646 | "Holdtime\n") | |
718e3744 | 4647 | { |
c500ae40 DW |
4648 | int idx_peer = 2; |
4649 | return peer_timers_unset_vty (vty, argv[idx_peer]->arg); | |
718e3744 | 4650 | } |
6b0655a2 | 4651 | |
813d4307 | 4652 | |
94f2b392 | 4653 | static int |
e52702f2 | 4654 | peer_timers_connect_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4655 | const char *time_str) |
718e3744 | 4656 | { |
4657 | int ret; | |
4658 | struct peer *peer; | |
4659 | u_int32_t connect; | |
4660 | ||
966f821c | 4661 | peer = peer_and_group_lookup_vty (vty, ip_str); |
718e3744 | 4662 | if (! peer) |
4663 | return CMD_WARNING; | |
4664 | ||
4665 | VTY_GET_INTEGER_RANGE ("Connect time", connect, time_str, 0, 65535); | |
4666 | ||
4667 | ret = peer_timers_connect_set (peer, connect); | |
4668 | ||
966f821c | 4669 | return bgp_vty_return (vty, ret); |
718e3744 | 4670 | } |
4671 | ||
94f2b392 | 4672 | static int |
fd79ac91 | 4673 | peer_timers_connect_unset_vty (struct vty *vty, const char *ip_str) |
718e3744 | 4674 | { |
4675 | int ret; | |
4676 | struct peer *peer; | |
4677 | ||
4678 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4679 | if (! peer) | |
4680 | return CMD_WARNING; | |
4681 | ||
4682 | ret = peer_timers_connect_unset (peer); | |
4683 | ||
966f821c | 4684 | return bgp_vty_return (vty, ret); |
718e3744 | 4685 | } |
4686 | ||
4687 | DEFUN (neighbor_timers_connect, | |
4688 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 4689 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 4690 | NEIGHBOR_STR |
966f821c | 4691 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4692 | "BGP per neighbor timers\n" |
4693 | "BGP connect timer\n" | |
4694 | "Connect timer\n") | |
4695 | { | |
c500ae40 DW |
4696 | int idx_peer = 1; |
4697 | int idx_number = 4; | |
4698 | return peer_timers_connect_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg); | |
718e3744 | 4699 | } |
4700 | ||
4701 | DEFUN (no_neighbor_timers_connect, | |
4702 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 4703 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 4704 | NO_STR |
4705 | NEIGHBOR_STR | |
966f821c | 4706 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4707 | "BGP per neighbor timers\n" |
8334fd5a DW |
4708 | "BGP connect timer\n" |
4709 | "Connect timer\n") | |
718e3744 | 4710 | { |
c500ae40 DW |
4711 | int idx_peer = 2; |
4712 | return peer_timers_connect_unset_vty (vty, argv[idx_peer]->arg); | |
718e3744 | 4713 | } |
4714 | ||
6b0655a2 | 4715 | |
94f2b392 | 4716 | static int |
e52702f2 QY |
4717 | peer_advertise_interval_vty (struct vty *vty, const char *ip_str, |
4718 | const char *time_str, int set) | |
718e3744 | 4719 | { |
4720 | int ret; | |
4721 | struct peer *peer; | |
4722 | u_int32_t routeadv = 0; | |
4723 | ||
966f821c | 4724 | peer = peer_and_group_lookup_vty (vty, ip_str); |
718e3744 | 4725 | if (! peer) |
4726 | return CMD_WARNING; | |
4727 | ||
4728 | if (time_str) | |
4729 | VTY_GET_INTEGER_RANGE ("advertise interval", routeadv, time_str, 0, 600); | |
4730 | ||
4731 | if (set) | |
4732 | ret = peer_advertise_interval_set (peer, routeadv); | |
4733 | else | |
4734 | ret = peer_advertise_interval_unset (peer); | |
4735 | ||
966f821c | 4736 | return bgp_vty_return (vty, ret); |
718e3744 | 4737 | } |
4738 | ||
4739 | DEFUN (neighbor_advertise_interval, | |
4740 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 4741 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 4742 | NEIGHBOR_STR |
966f821c | 4743 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4744 | "Minimum interval between sending BGP routing updates\n" |
4745 | "time in seconds\n") | |
4746 | { | |
c500ae40 DW |
4747 | int idx_peer = 1; |
4748 | int idx_number = 3; | |
4749 | return peer_advertise_interval_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg, 1); | |
718e3744 | 4750 | } |
4751 | ||
4752 | DEFUN (no_neighbor_advertise_interval, | |
4753 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 4754 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 4755 | NO_STR |
4756 | NEIGHBOR_STR | |
966f821c | 4757 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
4758 | "Minimum interval between sending BGP routing updates\n" |
4759 | "time in seconds\n") | |
718e3744 | 4760 | { |
c500ae40 DW |
4761 | int idx_peer = 2; |
4762 | return peer_advertise_interval_vty (vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 4763 | } |
4764 | ||
6b0655a2 | 4765 | |
518f0eb1 DS |
4766 | /* Time to wait before processing route-map updates */ |
4767 | DEFUN (bgp_set_route_map_delay_timer, | |
4768 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 4769 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
4770 | SET_STR |
4771 | "BGP route-map delay timer\n" | |
4772 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 4773 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 4774 | { |
c500ae40 | 4775 | int idx_number = 3; |
518f0eb1 | 4776 | u_int32_t rmap_delay_timer; |
518f0eb1 | 4777 | |
c500ae40 | 4778 | if (argv[idx_number]->arg) |
518f0eb1 | 4779 | { |
c500ae40 | 4780 | VTY_GET_INTEGER_RANGE ("delay-timer", rmap_delay_timer, argv[idx_number]->arg, 0, 600); |
5fe9f963 | 4781 | bm->rmap_update_timer = rmap_delay_timer; |
518f0eb1 DS |
4782 | |
4783 | /* if the dynamic update handling is being disabled, and a timer is | |
4784 | * running, stop the timer and act as if the timer has already fired. | |
4785 | */ | |
5fe9f963 | 4786 | if (!rmap_delay_timer && bm->t_rmap_update ) |
518f0eb1 | 4787 | { |
5fe9f963 | 4788 | BGP_TIMER_OFF(bm->t_rmap_update); |
4789 | thread_execute (bm->master, bgp_route_map_update_timer, NULL, 0); | |
518f0eb1 DS |
4790 | } |
4791 | return CMD_SUCCESS; | |
4792 | } | |
4793 | else | |
ffd0c037 | 4794 | return CMD_WARNING; |
518f0eb1 DS |
4795 | } |
4796 | ||
4797 | DEFUN (no_bgp_set_route_map_delay_timer, | |
4798 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 4799 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 4800 | NO_STR |
3a2d747c | 4801 | BGP_STR |
518f0eb1 | 4802 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
4803 | "Reset to default time to wait for processing route-map changes\n" |
4804 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 4805 | { |
518f0eb1 | 4806 | |
5fe9f963 | 4807 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 DS |
4808 | |
4809 | return CMD_SUCCESS; | |
4810 | } | |
4811 | ||
f414725f | 4812 | |
718e3744 | 4813 | /* neighbor interface */ |
94f2b392 | 4814 | static int |
fd79ac91 | 4815 | peer_interface_vty (struct vty *vty, const char *ip_str, const char *str) |
718e3744 | 4816 | { |
718e3744 | 4817 | struct peer *peer; |
4818 | ||
4819 | peer = peer_lookup_vty (vty, ip_str); | |
a80beece | 4820 | if (! peer || peer->conf_if) |
718e3744 | 4821 | return CMD_WARNING; |
4822 | ||
4823 | if (str) | |
ffd0c037 | 4824 | peer_interface_set (peer, str); |
718e3744 | 4825 | else |
ffd0c037 | 4826 | peer_interface_unset (peer); |
718e3744 | 4827 | |
4828 | return CMD_SUCCESS; | |
4829 | } | |
4830 | ||
4831 | DEFUN (neighbor_interface, | |
4832 | neighbor_interface_cmd, | |
9ccf14f7 | 4833 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 4834 | NEIGHBOR_STR |
4835 | NEIGHBOR_ADDR_STR | |
4836 | "Interface\n" | |
4837 | "Interface name\n") | |
4838 | { | |
c500ae40 DW |
4839 | int idx_ip = 1; |
4840 | int idx_word = 3; | |
00d7d2d3 | 4841 | return peer_interface_vty (vty, argv[idx_ip]->arg, argv[idx_word]->arg); |
718e3744 | 4842 | } |
4843 | ||
4844 | DEFUN (no_neighbor_interface, | |
4845 | no_neighbor_interface_cmd, | |
9ccf14f7 | 4846 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 4847 | NO_STR |
4848 | NEIGHBOR_STR | |
16cedbb0 | 4849 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4850 | "Interface\n" |
4851 | "Interface name\n") | |
4852 | { | |
c500ae40 DW |
4853 | int idx_peer = 2; |
4854 | return peer_interface_vty (vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4855 | } |
6b0655a2 | 4856 | |
718e3744 | 4857 | /* Set distribute list to the peer. */ |
94f2b392 | 4858 | static int |
e52702f2 | 4859 | peer_distribute_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4860 | afi_t afi, safi_t safi, |
4861 | const char *name_str, const char *direct_str) | |
718e3744 | 4862 | { |
4863 | int ret; | |
4864 | struct peer *peer; | |
4865 | int direct = FILTER_IN; | |
4866 | ||
4867 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4868 | if (! peer) | |
4869 | return CMD_WARNING; | |
4870 | ||
4871 | /* Check filter direction. */ | |
4872 | if (strncmp (direct_str, "i", 1) == 0) | |
4873 | direct = FILTER_IN; | |
4874 | else if (strncmp (direct_str, "o", 1) == 0) | |
4875 | direct = FILTER_OUT; | |
4876 | ||
4877 | ret = peer_distribute_set (peer, afi, safi, direct, name_str); | |
4878 | ||
4879 | return bgp_vty_return (vty, ret); | |
4880 | } | |
4881 | ||
94f2b392 | 4882 | static int |
fd79ac91 | 4883 | peer_distribute_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
4884 | safi_t safi, const char *direct_str) | |
718e3744 | 4885 | { |
4886 | int ret; | |
4887 | struct peer *peer; | |
4888 | int direct = FILTER_IN; | |
4889 | ||
4890 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4891 | if (! peer) | |
4892 | return CMD_WARNING; | |
4893 | ||
4894 | /* Check filter direction. */ | |
4895 | if (strncmp (direct_str, "i", 1) == 0) | |
4896 | direct = FILTER_IN; | |
4897 | else if (strncmp (direct_str, "o", 1) == 0) | |
4898 | direct = FILTER_OUT; | |
4899 | ||
4900 | ret = peer_distribute_unset (peer, afi, safi, direct); | |
4901 | ||
4902 | return bgp_vty_return (vty, ret); | |
4903 | } | |
4904 | ||
4905 | DEFUN (neighbor_distribute_list, | |
4906 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 4907 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 4908 | NEIGHBOR_STR |
4909 | NEIGHBOR_ADDR_STR2 | |
4910 | "Filter updates to/from this neighbor\n" | |
4911 | "IP access-list number\n" | |
4912 | "IP access-list number (expanded range)\n" | |
4913 | "IP Access-list name\n" | |
4914 | "Filter incoming updates\n" | |
4915 | "Filter outgoing updates\n") | |
4916 | { | |
c500ae40 DW |
4917 | int idx_peer = 1; |
4918 | int idx_acl = 3; | |
4919 | int idx_in_out = 4; | |
4920 | return peer_distribute_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4921 | bgp_node_safi (vty), argv[idx_acl]->arg, argv[idx_in_out]->arg); | |
718e3744 | 4922 | } |
4923 | ||
4924 | DEFUN (no_neighbor_distribute_list, | |
4925 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 4926 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 4927 | NO_STR |
4928 | NEIGHBOR_STR | |
4929 | NEIGHBOR_ADDR_STR2 | |
4930 | "Filter updates to/from this neighbor\n" | |
4931 | "IP access-list number\n" | |
4932 | "IP access-list number (expanded range)\n" | |
4933 | "IP Access-list name\n" | |
4934 | "Filter incoming updates\n" | |
4935 | "Filter outgoing updates\n") | |
4936 | { | |
c500ae40 DW |
4937 | int idx_peer = 2; |
4938 | int idx_in_out = 5; | |
4939 | return peer_distribute_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4940 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 4941 | } |
6b0655a2 | 4942 | |
718e3744 | 4943 | /* Set prefix list to the peer. */ |
94f2b392 | 4944 | static int |
fd79ac91 | 4945 | peer_prefix_list_set_vty (struct vty *vty, const char *ip_str, afi_t afi, |
e52702f2 | 4946 | safi_t safi, const char *name_str, |
fd79ac91 | 4947 | const char *direct_str) |
718e3744 | 4948 | { |
4949 | int ret; | |
4950 | struct peer *peer; | |
4951 | int direct = FILTER_IN; | |
4952 | ||
4953 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4954 | if (! peer) | |
4955 | return CMD_WARNING; | |
4956 | ||
4957 | /* Check filter direction. */ | |
4958 | if (strncmp (direct_str, "i", 1) == 0) | |
4959 | direct = FILTER_IN; | |
4960 | else if (strncmp (direct_str, "o", 1) == 0) | |
4961 | direct = FILTER_OUT; | |
4962 | ||
4963 | ret = peer_prefix_list_set (peer, afi, safi, direct, name_str); | |
4964 | ||
4965 | return bgp_vty_return (vty, ret); | |
4966 | } | |
4967 | ||
94f2b392 | 4968 | static int |
fd79ac91 | 4969 | peer_prefix_list_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
4970 | safi_t safi, const char *direct_str) | |
718e3744 | 4971 | { |
4972 | int ret; | |
4973 | struct peer *peer; | |
4974 | int direct = FILTER_IN; | |
4975 | ||
4976 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4977 | if (! peer) | |
4978 | return CMD_WARNING; | |
e52702f2 | 4979 | |
718e3744 | 4980 | /* Check filter direction. */ |
4981 | if (strncmp (direct_str, "i", 1) == 0) | |
4982 | direct = FILTER_IN; | |
4983 | else if (strncmp (direct_str, "o", 1) == 0) | |
4984 | direct = FILTER_OUT; | |
4985 | ||
4986 | ret = peer_prefix_list_unset (peer, afi, safi, direct); | |
4987 | ||
4988 | return bgp_vty_return (vty, ret); | |
4989 | } | |
4990 | ||
4991 | DEFUN (neighbor_prefix_list, | |
4992 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 4993 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 4994 | NEIGHBOR_STR |
4995 | NEIGHBOR_ADDR_STR2 | |
4996 | "Filter updates to/from this neighbor\n" | |
4997 | "Name of a prefix list\n" | |
4998 | "Filter incoming updates\n" | |
4999 | "Filter outgoing updates\n") | |
5000 | { | |
c500ae40 DW |
5001 | int idx_peer = 1; |
5002 | int idx_word = 3; | |
5003 | int idx_in_out = 4; | |
5004 | return peer_prefix_list_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5005 | bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5006 | } |
5007 | ||
5008 | DEFUN (no_neighbor_prefix_list, | |
5009 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 5010 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5011 | NO_STR |
5012 | NEIGHBOR_STR | |
5013 | NEIGHBOR_ADDR_STR2 | |
5014 | "Filter updates to/from this neighbor\n" | |
5015 | "Name of a prefix list\n" | |
5016 | "Filter incoming updates\n" | |
5017 | "Filter outgoing updates\n") | |
5018 | { | |
c500ae40 DW |
5019 | int idx_peer = 2; |
5020 | int idx_in_out = 5; | |
5021 | return peer_prefix_list_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5022 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 5023 | } |
6b0655a2 | 5024 | |
94f2b392 | 5025 | static int |
e52702f2 | 5026 | peer_aslist_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 5027 | afi_t afi, safi_t safi, |
5028 | const char *name_str, const char *direct_str) | |
718e3744 | 5029 | { |
5030 | int ret; | |
5031 | struct peer *peer; | |
5032 | int direct = FILTER_IN; | |
5033 | ||
5034 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5035 | if (! peer) | |
5036 | return CMD_WARNING; | |
5037 | ||
5038 | /* Check filter direction. */ | |
5039 | if (strncmp (direct_str, "i", 1) == 0) | |
5040 | direct = FILTER_IN; | |
5041 | else if (strncmp (direct_str, "o", 1) == 0) | |
5042 | direct = FILTER_OUT; | |
5043 | ||
5044 | ret = peer_aslist_set (peer, afi, safi, direct, name_str); | |
5045 | ||
5046 | return bgp_vty_return (vty, ret); | |
5047 | } | |
5048 | ||
94f2b392 | 5049 | static int |
e52702f2 | 5050 | peer_aslist_unset_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 5051 | afi_t afi, safi_t safi, |
5052 | const char *direct_str) | |
718e3744 | 5053 | { |
5054 | int ret; | |
5055 | struct peer *peer; | |
5056 | int direct = FILTER_IN; | |
5057 | ||
5058 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5059 | if (! peer) | |
5060 | return CMD_WARNING; | |
5061 | ||
5062 | /* Check filter direction. */ | |
5063 | if (strncmp (direct_str, "i", 1) == 0) | |
5064 | direct = FILTER_IN; | |
5065 | else if (strncmp (direct_str, "o", 1) == 0) | |
5066 | direct = FILTER_OUT; | |
5067 | ||
5068 | ret = peer_aslist_unset (peer, afi, safi, direct); | |
5069 | ||
5070 | return bgp_vty_return (vty, ret); | |
5071 | } | |
5072 | ||
5073 | DEFUN (neighbor_filter_list, | |
5074 | neighbor_filter_list_cmd, | |
9ccf14f7 | 5075 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5076 | NEIGHBOR_STR |
5077 | NEIGHBOR_ADDR_STR2 | |
5078 | "Establish BGP filters\n" | |
5079 | "AS path access-list name\n" | |
5080 | "Filter incoming routes\n" | |
5081 | "Filter outgoing routes\n") | |
5082 | { | |
c500ae40 DW |
5083 | int idx_peer = 1; |
5084 | int idx_word = 3; | |
5085 | int idx_in_out = 4; | |
5086 | return peer_aslist_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5087 | bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5088 | } |
5089 | ||
5090 | DEFUN (no_neighbor_filter_list, | |
5091 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 5092 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5093 | NO_STR |
5094 | NEIGHBOR_STR | |
5095 | NEIGHBOR_ADDR_STR2 | |
5096 | "Establish BGP filters\n" | |
5097 | "AS path access-list name\n" | |
5098 | "Filter incoming routes\n" | |
5099 | "Filter outgoing routes\n") | |
5100 | { | |
c500ae40 DW |
5101 | int idx_peer = 2; |
5102 | int idx_in_out = 5; | |
5103 | return peer_aslist_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5104 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 5105 | } |
6b0655a2 | 5106 | |
718e3744 | 5107 | /* Set route-map to the peer. */ |
94f2b392 | 5108 | static int |
e52702f2 | 5109 | peer_route_map_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 5110 | afi_t afi, safi_t safi, |
5111 | const char *name_str, const char *direct_str) | |
718e3744 | 5112 | { |
5113 | int ret; | |
5114 | struct peer *peer; | |
fee0f4c6 | 5115 | int direct = RMAP_IN; |
718e3744 | 5116 | |
5117 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5118 | if (! peer) | |
5119 | return CMD_WARNING; | |
5120 | ||
5121 | /* Check filter direction. */ | |
fee0f4c6 | 5122 | if (strncmp (direct_str, "in", 2) == 0) |
5123 | direct = RMAP_IN; | |
718e3744 | 5124 | else if (strncmp (direct_str, "o", 1) == 0) |
fee0f4c6 | 5125 | direct = RMAP_OUT; |
718e3744 | 5126 | |
5127 | ret = peer_route_map_set (peer, afi, safi, direct, name_str); | |
5128 | ||
5129 | return bgp_vty_return (vty, ret); | |
5130 | } | |
5131 | ||
94f2b392 | 5132 | static int |
fd79ac91 | 5133 | peer_route_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
5134 | safi_t safi, const char *direct_str) | |
718e3744 | 5135 | { |
5136 | int ret; | |
5137 | struct peer *peer; | |
fee0f4c6 | 5138 | int direct = RMAP_IN; |
718e3744 | 5139 | |
5140 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5141 | if (! peer) | |
5142 | return CMD_WARNING; | |
5143 | ||
5144 | /* Check filter direction. */ | |
fee0f4c6 | 5145 | if (strncmp (direct_str, "in", 2) == 0) |
5146 | direct = RMAP_IN; | |
718e3744 | 5147 | else if (strncmp (direct_str, "o", 1) == 0) |
fee0f4c6 | 5148 | direct = RMAP_OUT; |
718e3744 | 5149 | |
5150 | ret = peer_route_map_unset (peer, afi, safi, direct); | |
5151 | ||
5152 | return bgp_vty_return (vty, ret); | |
5153 | } | |
5154 | ||
5155 | DEFUN (neighbor_route_map, | |
5156 | neighbor_route_map_cmd, | |
9ccf14f7 | 5157 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5158 | NEIGHBOR_STR |
5159 | NEIGHBOR_ADDR_STR2 | |
5160 | "Apply route map to neighbor\n" | |
5161 | "Name of route map\n" | |
5162 | "Apply map to incoming routes\n" | |
2a3d5731 | 5163 | "Apply map to outbound routes\n") |
718e3744 | 5164 | { |
c500ae40 DW |
5165 | int idx_peer = 1; |
5166 | int idx_word = 3; | |
5167 | int idx_in_out = 4; | |
5168 | return peer_route_map_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5169 | bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5170 | } |
5171 | ||
5172 | DEFUN (no_neighbor_route_map, | |
5173 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 5174 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5175 | NO_STR |
5176 | NEIGHBOR_STR | |
5177 | NEIGHBOR_ADDR_STR2 | |
5178 | "Apply route map to neighbor\n" | |
5179 | "Name of route map\n" | |
5180 | "Apply map to incoming routes\n" | |
2a3d5731 | 5181 | "Apply map to outbound routes\n") |
718e3744 | 5182 | { |
c500ae40 DW |
5183 | int idx_peer = 2; |
5184 | int idx_in_out = 5; | |
5185 | return peer_route_map_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5186 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 5187 | } |
6b0655a2 | 5188 | |
718e3744 | 5189 | /* Set unsuppress-map to the peer. */ |
94f2b392 | 5190 | static int |
fd79ac91 | 5191 | peer_unsuppress_map_set_vty (struct vty *vty, const char *ip_str, afi_t afi, |
5192 | safi_t safi, const char *name_str) | |
718e3744 | 5193 | { |
5194 | int ret; | |
5195 | struct peer *peer; | |
5196 | ||
5197 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5198 | if (! peer) | |
5199 | return CMD_WARNING; | |
5200 | ||
5201 | ret = peer_unsuppress_map_set (peer, afi, safi, name_str); | |
5202 | ||
5203 | return bgp_vty_return (vty, ret); | |
5204 | } | |
5205 | ||
5206 | /* Unset route-map from the peer. */ | |
94f2b392 | 5207 | static int |
fd79ac91 | 5208 | peer_unsuppress_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
718e3744 | 5209 | safi_t safi) |
5210 | { | |
5211 | int ret; | |
5212 | struct peer *peer; | |
5213 | ||
5214 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5215 | if (! peer) | |
5216 | return CMD_WARNING; | |
5217 | ||
5218 | ret = peer_unsuppress_map_unset (peer, afi, safi); | |
5219 | ||
5220 | return bgp_vty_return (vty, ret); | |
5221 | } | |
5222 | ||
5223 | DEFUN (neighbor_unsuppress_map, | |
5224 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5225 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5226 | NEIGHBOR_STR |
5227 | NEIGHBOR_ADDR_STR2 | |
5228 | "Route-map to selectively unsuppress suppressed routes\n" | |
5229 | "Name of route map\n") | |
5230 | { | |
c500ae40 DW |
5231 | int idx_peer = 1; |
5232 | int idx_word = 3; | |
5233 | return peer_unsuppress_map_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5234 | bgp_node_safi (vty), argv[idx_word]->arg); | |
718e3744 | 5235 | } |
5236 | ||
5237 | DEFUN (no_neighbor_unsuppress_map, | |
5238 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5239 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5240 | NO_STR |
5241 | NEIGHBOR_STR | |
5242 | NEIGHBOR_ADDR_STR2 | |
5243 | "Route-map to selectively unsuppress suppressed routes\n" | |
5244 | "Name of route map\n") | |
5245 | { | |
c500ae40 DW |
5246 | int idx_peer = 2; |
5247 | return peer_unsuppress_map_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 5248 | bgp_node_safi (vty)); |
5249 | } | |
6b0655a2 | 5250 | |
94f2b392 | 5251 | static int |
fd79ac91 | 5252 | peer_maximum_prefix_set_vty (struct vty *vty, const char *ip_str, afi_t afi, |
e52702f2 | 5253 | safi_t safi, const char *num_str, |
0a486e5f | 5254 | const char *threshold_str, int warning, |
5255 | const char *restart_str) | |
718e3744 | 5256 | { |
5257 | int ret; | |
5258 | struct peer *peer; | |
5259 | u_int32_t max; | |
e0701b79 | 5260 | u_char threshold; |
0a486e5f | 5261 | u_int16_t restart; |
718e3744 | 5262 | |
5263 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5264 | if (! peer) | |
5265 | return CMD_WARNING; | |
5266 | ||
e6ec1c36 | 5267 | VTY_GET_INTEGER ("maximum number", max, num_str); |
e0701b79 | 5268 | if (threshold_str) |
5269 | threshold = atoi (threshold_str); | |
5270 | else | |
5271 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 5272 | |
0a486e5f | 5273 | if (restart_str) |
5274 | restart = atoi (restart_str); | |
5275 | else | |
5276 | restart = 0; | |
5277 | ||
5278 | ret = peer_maximum_prefix_set (peer, afi, safi, max, threshold, warning, restart); | |
718e3744 | 5279 | |
5280 | return bgp_vty_return (vty, ret); | |
5281 | } | |
5282 | ||
94f2b392 | 5283 | static int |
fd79ac91 | 5284 | peer_maximum_prefix_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
718e3744 | 5285 | safi_t safi) |
5286 | { | |
5287 | int ret; | |
5288 | struct peer *peer; | |
5289 | ||
5290 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5291 | if (! peer) | |
5292 | return CMD_WARNING; | |
5293 | ||
5294 | ret = peer_maximum_prefix_unset (peer, afi, safi); | |
5295 | ||
5296 | return bgp_vty_return (vty, ret); | |
5297 | } | |
5298 | ||
5299 | /* Maximum number of prefix configuration. prefix count is different | |
5300 | for each peer configuration. So this configuration can be set for | |
5301 | each peer configuration. */ | |
5302 | DEFUN (neighbor_maximum_prefix, | |
5303 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 5304 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 5305 | NEIGHBOR_STR |
5306 | NEIGHBOR_ADDR_STR2 | |
5307 | "Maximum number of prefix accept from this peer\n" | |
5308 | "maximum no. of prefix limit\n") | |
5309 | { | |
c500ae40 DW |
5310 | int idx_peer = 1; |
5311 | int idx_number = 3; | |
5312 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5313 | bgp_node_safi (vty), argv[idx_number]->arg, NULL, 0, | |
0a486e5f | 5314 | NULL); |
718e3744 | 5315 | } |
5316 | ||
e0701b79 | 5317 | DEFUN (neighbor_maximum_prefix_threshold, |
5318 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 5319 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 5320 | NEIGHBOR_STR |
5321 | NEIGHBOR_ADDR_STR2 | |
5322 | "Maximum number of prefix accept from this peer\n" | |
5323 | "maximum no. of prefix limit\n" | |
5324 | "Threshold value (%) at which to generate a warning msg\n") | |
5325 | { | |
c500ae40 DW |
5326 | int idx_peer = 1; |
5327 | int idx_number = 3; | |
5328 | int idx_number_2 = 4; | |
5329 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5330 | bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
0a486e5f | 5331 | NULL); |
5332 | } | |
e0701b79 | 5333 | |
718e3744 | 5334 | DEFUN (neighbor_maximum_prefix_warning, |
5335 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 5336 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 5337 | NEIGHBOR_STR |
5338 | NEIGHBOR_ADDR_STR2 | |
5339 | "Maximum number of prefix accept from this peer\n" | |
5340 | "maximum no. of prefix limit\n" | |
5341 | "Only give warning message when limit is exceeded\n") | |
5342 | { | |
c500ae40 DW |
5343 | int idx_peer = 1; |
5344 | int idx_number = 3; | |
5345 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5346 | bgp_node_safi (vty), argv[idx_number]->arg, NULL, 1, | |
0a486e5f | 5347 | NULL); |
718e3744 | 5348 | } |
5349 | ||
e0701b79 | 5350 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
5351 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 5352 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 5353 | NEIGHBOR_STR |
5354 | NEIGHBOR_ADDR_STR2 | |
5355 | "Maximum number of prefix accept from this peer\n" | |
5356 | "maximum no. of prefix limit\n" | |
5357 | "Threshold value (%) at which to generate a warning msg\n" | |
5358 | "Only give warning message when limit is exceeded\n") | |
5359 | { | |
c500ae40 DW |
5360 | int idx_peer = 1; |
5361 | int idx_number = 3; | |
5362 | int idx_number_2 = 4; | |
5363 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5364 | bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 5365 | } |
5366 | ||
5367 | DEFUN (neighbor_maximum_prefix_restart, | |
5368 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 5369 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 5370 | NEIGHBOR_STR |
5371 | NEIGHBOR_ADDR_STR2 | |
5372 | "Maximum number of prefix accept from this peer\n" | |
5373 | "maximum no. of prefix limit\n" | |
5374 | "Restart bgp connection after limit is exceeded\n" | |
5375 | "Restart interval in minutes") | |
5376 | { | |
c500ae40 DW |
5377 | int idx_peer = 1; |
5378 | int idx_number = 3; | |
5379 | int idx_number_2 = 5; | |
5380 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5381 | bgp_node_safi (vty), argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 5382 | } |
5383 | ||
5384 | DEFUN (neighbor_maximum_prefix_threshold_restart, | |
5385 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 5386 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 5387 | NEIGHBOR_STR |
5388 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5389 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 5390 | "maximum no. of prefix limit\n" |
5391 | "Threshold value (%) at which to generate a warning msg\n" | |
5392 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 5393 | "Restart interval in minutes\n") |
0a486e5f | 5394 | { |
c500ae40 DW |
5395 | int idx_peer = 1; |
5396 | int idx_number = 3; | |
5397 | int idx_number_2 = 4; | |
5398 | int idx_number_3 = 6; | |
5399 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5400 | bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 0, argv[idx_number_3]->arg); | |
0a486e5f | 5401 | } |
e0701b79 | 5402 | |
718e3744 | 5403 | DEFUN (no_neighbor_maximum_prefix, |
5404 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 5405 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 5406 | NO_STR |
5407 | NEIGHBOR_STR | |
5408 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5409 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
5410 | "maximum no. of prefix limit\n" |
5411 | "Threshold value (%) at which to generate a warning msg\n" | |
5412 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 5413 | "Restart interval in minutes\n" |
31500417 | 5414 | "Only give warning message when limit is exceeded\n") |
718e3744 | 5415 | { |
c500ae40 DW |
5416 | int idx_peer = 2; |
5417 | return peer_maximum_prefix_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 5418 | bgp_node_safi (vty)); |
5419 | } | |
e52702f2 | 5420 | |
718e3744 | 5421 | |
718e3744 | 5422 | /* "neighbor allowas-in" */ |
5423 | DEFUN (neighbor_allowas_in, | |
5424 | neighbor_allowas_in_cmd, | |
fd8503f5 | 5425 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 5426 | NEIGHBOR_STR |
5427 | NEIGHBOR_ADDR_STR2 | |
31500417 | 5428 | "Accept as-path with my AS present in it\n" |
fd8503f5 QY |
5429 | "Number of occurances of AS number\n" |
5430 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 5431 | { |
c500ae40 | 5432 | int idx_peer = 1; |
fd8503f5 | 5433 | int idx_number_origin = 3; |
718e3744 | 5434 | int ret; |
aac9ef6c | 5435 | int origin = 0; |
718e3744 | 5436 | struct peer *peer; |
aac9ef6c | 5437 | int allow_num = 0; |
718e3744 | 5438 | |
c500ae40 | 5439 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 5440 | if (! peer) |
5441 | return CMD_WARNING; | |
5442 | ||
fd8503f5 | 5443 | if (argc <= idx_number_origin) |
718e3744 | 5444 | allow_num = 3; |
5445 | else | |
aac9ef6c | 5446 | { |
fd8503f5 | 5447 | if (argv[idx_number_origin]->type == WORD_TKN) |
aac9ef6c DW |
5448 | origin = 1; |
5449 | else | |
fd8503f5 | 5450 | allow_num = atoi (argv[idx_number_origin]->arg); |
aac9ef6c | 5451 | } |
718e3744 | 5452 | |
5453 | ret = peer_allowas_in_set (peer, bgp_node_afi (vty), bgp_node_safi (vty), | |
aac9ef6c | 5454 | allow_num, origin); |
718e3744 | 5455 | |
5456 | return bgp_vty_return (vty, ret); | |
5457 | } | |
5458 | ||
718e3744 | 5459 | DEFUN (no_neighbor_allowas_in, |
5460 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 5461 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 5462 | NO_STR |
5463 | NEIGHBOR_STR | |
5464 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 5465 | "allow local ASN appears in aspath attribute\n" |
fd8503f5 QY |
5466 | "Number of occurances of AS number\n" |
5467 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 5468 | { |
c500ae40 | 5469 | int idx_peer = 2; |
718e3744 | 5470 | int ret; |
5471 | struct peer *peer; | |
5472 | ||
c500ae40 | 5473 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 5474 | if (! peer) |
5475 | return CMD_WARNING; | |
5476 | ||
5477 | ret = peer_allowas_in_unset (peer, bgp_node_afi (vty), bgp_node_safi (vty)); | |
5478 | ||
5479 | return bgp_vty_return (vty, ret); | |
5480 | } | |
6b0655a2 | 5481 | |
fa411a21 NH |
5482 | DEFUN (neighbor_ttl_security, |
5483 | neighbor_ttl_security_cmd, | |
9ccf14f7 | 5484 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
5485 | NEIGHBOR_STR |
5486 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5487 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
5488 | "Specify the maximum number of hops to the BGP peer\n" |
5489 | "Number of hops to BGP peer\n") | |
fa411a21 | 5490 | { |
c500ae40 DW |
5491 | int idx_peer = 1; |
5492 | int idx_number = 4; | |
fa411a21 | 5493 | struct peer *peer; |
89b6d1f8 | 5494 | int gtsm_hops; |
fa411a21 | 5495 | |
c500ae40 | 5496 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
fa411a21 NH |
5497 | if (! peer) |
5498 | return CMD_WARNING; | |
e52702f2 | 5499 | |
c500ae40 | 5500 | VTY_GET_INTEGER_RANGE ("", gtsm_hops, argv[idx_number]->arg, 1, 254); |
fa411a21 | 5501 | |
8cdabf90 SK |
5502 | /* |
5503 | * If 'neighbor swpX', then this is for directly connected peers, | |
5504 | * we should not accept a ttl-security hops value greater than 1. | |
5505 | */ | |
5506 | if (peer->conf_if && (gtsm_hops > 1)) { | |
5507 | vty_out (vty, "%s is directly connected peer, hops cannot exceed 1%s", | |
c500ae40 | 5508 | argv[idx_peer]->arg, VTY_NEWLINE); |
8cdabf90 SK |
5509 | return CMD_WARNING; |
5510 | } | |
5511 | ||
89b6d1f8 | 5512 | return bgp_vty_return (vty, peer_ttl_security_hops_set (peer, gtsm_hops)); |
fa411a21 NH |
5513 | } |
5514 | ||
5515 | DEFUN (no_neighbor_ttl_security, | |
5516 | no_neighbor_ttl_security_cmd, | |
9ccf14f7 | 5517 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
5518 | NO_STR |
5519 | NEIGHBOR_STR | |
5520 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5521 | "BGP ttl-security parameters\n" |
3a2d747c QY |
5522 | "Specify the maximum number of hops to the BGP peer\n" |
5523 | "Number of hops to BGP peer\n") | |
fa411a21 | 5524 | { |
c500ae40 | 5525 | int idx_peer = 2; |
fa411a21 | 5526 | struct peer *peer; |
fa411a21 | 5527 | |
c500ae40 | 5528 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
fa411a21 NH |
5529 | if (! peer) |
5530 | return CMD_WARNING; | |
5531 | ||
89b6d1f8 | 5532 | return bgp_vty_return (vty, peer_ttl_security_hops_unset (peer)); |
fa411a21 | 5533 | } |
6b0655a2 | 5534 | |
adbac85e DW |
5535 | DEFUN (neighbor_addpath_tx_all_paths, |
5536 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 5537 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
5538 | NEIGHBOR_STR |
5539 | NEIGHBOR_ADDR_STR2 | |
5540 | "Use addpath to advertise all paths to a neighbor\n") | |
5541 | { | |
c500ae40 | 5542 | int idx_peer = 1; |
adbac85e DW |
5543 | struct peer *peer; |
5544 | ||
c500ae40 | 5545 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
adbac85e DW |
5546 | if (! peer) |
5547 | return CMD_WARNING; | |
5548 | ||
c500ae40 | 5549 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
adbac85e DW |
5550 | bgp_node_safi (vty), |
5551 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
5552 | } | |
5553 | ||
5554 | DEFUN (no_neighbor_addpath_tx_all_paths, | |
5555 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 5556 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
5557 | NO_STR |
5558 | NEIGHBOR_STR | |
5559 | NEIGHBOR_ADDR_STR2 | |
5560 | "Use addpath to advertise all paths to a neighbor\n") | |
5561 | { | |
c500ae40 DW |
5562 | int idx_peer = 2; |
5563 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
adbac85e DW |
5564 | bgp_node_safi (vty), |
5565 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
5566 | } | |
5567 | ||
06370dac DW |
5568 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
5569 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 5570 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
5571 | NEIGHBOR_STR |
5572 | NEIGHBOR_ADDR_STR2 | |
5573 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
5574 | { | |
c500ae40 | 5575 | int idx_peer = 1; |
06370dac DW |
5576 | struct peer *peer; |
5577 | ||
c500ae40 | 5578 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
06370dac DW |
5579 | if (! peer) |
5580 | return CMD_WARNING; | |
5581 | ||
c500ae40 | 5582 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
06370dac DW |
5583 | bgp_node_safi (vty), |
5584 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
5585 | } | |
5586 | ||
5587 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, | |
5588 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 5589 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
5590 | NO_STR |
5591 | NEIGHBOR_STR | |
5592 | NEIGHBOR_ADDR_STR2 | |
5593 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
5594 | { | |
c500ae40 DW |
5595 | int idx_peer = 2; |
5596 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
06370dac DW |
5597 | bgp_node_safi (vty), |
5598 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
5599 | } | |
5600 | ||
718e3744 | 5601 | DEFUN (address_family_ipv4_safi, |
5602 | address_family_ipv4_safi_cmd, | |
c7f1274b | 5603 | "address-family ipv4 [<unicast|multicast|vpn|encap>]", |
718e3744 | 5604 | "Enter Address Family command mode\n" |
8c3deaae | 5605 | "Address Family\n" |
46f296b4 | 5606 | BGP_SAFI_HELP_STR) |
718e3744 | 5607 | { |
c500ae40 | 5608 | int idx_safi = 2; |
af155bb6 | 5609 | if (argc == (idx_safi + 1)) |
ccbb332a | 5610 | { |
c7f1274b DS |
5611 | switch (bgp_vty_safi_from_arg(argv[idx_safi]->arg)) |
5612 | { | |
5613 | case SAFI_MULTICAST: | |
5614 | vty->node = BGP_IPV4M_NODE; | |
5615 | break; | |
5616 | case SAFI_ENCAP: | |
5617 | vty->node = BGP_ENCAP_NODE; | |
5618 | break; | |
5619 | case SAFI_MPLS_VPN: | |
5620 | vty->node = BGP_VPNV4_NODE; | |
5621 | break; | |
5622 | case SAFI_UNICAST: | |
5623 | default: | |
5624 | vty->node = BGP_IPV4_NODE; | |
5625 | break; | |
5626 | } | |
ccbb332a | 5627 | } |
c7f1274b DS |
5628 | else |
5629 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 5630 | |
5631 | return CMD_SUCCESS; | |
5632 | } | |
5633 | ||
25ffbdc1 | 5634 | DEFUN (address_family_ipv6_safi, |
5635 | address_family_ipv6_safi_cmd, | |
c7f1274b | 5636 | "address-family ipv6 [<unicast|multicast|vpn|encap>]", |
718e3744 | 5637 | "Enter Address Family command mode\n" |
8c3deaae | 5638 | "Address Family\n" |
46f296b4 | 5639 | BGP_SAFI_HELP_STR) |
25ffbdc1 | 5640 | { |
c500ae40 | 5641 | int idx_safi = 2; |
af155bb6 | 5642 | if (argc == (idx_safi + 1)) |
46f296b4 | 5643 | { |
c7f1274b DS |
5644 | switch (bgp_vty_safi_from_arg(argv[idx_safi]->arg)) |
5645 | { | |
5646 | case SAFI_MULTICAST: | |
5647 | vty->node = BGP_IPV6M_NODE; | |
5648 | break; | |
5649 | case SAFI_ENCAP: | |
5650 | vty->node = BGP_ENCAPV6_NODE; | |
5651 | break; | |
5652 | case SAFI_MPLS_VPN: | |
5653 | vty->node = BGP_VPNV6_NODE; | |
5654 | break; | |
5655 | case SAFI_UNICAST: | |
5656 | default: | |
5657 | vty->node = BGP_IPV6_NODE; | |
5658 | break; | |
5659 | } | |
46f296b4 | 5660 | } |
c7f1274b DS |
5661 | else |
5662 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 5663 | |
5664 | return CMD_SUCCESS; | |
5665 | } | |
718e3744 | 5666 | |
d6902373 | 5667 | #ifdef KEEP_OLD_VPN_COMMANDS |
718e3744 | 5668 | DEFUN (address_family_vpnv4, |
5669 | address_family_vpnv4_cmd, | |
8334fd5a | 5670 | "address-family vpnv4 [unicast]", |
718e3744 | 5671 | "Enter Address Family command mode\n" |
8c3deaae | 5672 | "Address Family\n" |
3a2d747c | 5673 | "Address Family modifier\n") |
718e3744 | 5674 | { |
5675 | vty->node = BGP_VPNV4_NODE; | |
5676 | return CMD_SUCCESS; | |
5677 | } | |
5678 | ||
8ecd3266 | 5679 | DEFUN (address_family_vpnv6, |
5680 | address_family_vpnv6_cmd, | |
8334fd5a | 5681 | "address-family vpnv6 [unicast]", |
8ecd3266 | 5682 | "Enter Address Family command mode\n" |
8c3deaae | 5683 | "Address Family\n" |
3a2d747c | 5684 | "Address Family modifier\n") |
8ecd3266 | 5685 | { |
5686 | vty->node = BGP_VPNV6_NODE; | |
5687 | return CMD_SUCCESS; | |
5688 | } | |
c016b6c7 | 5689 | #endif |
d6902373 | 5690 | |
8b1fb8be LB |
5691 | DEFUN (address_family_encap, |
5692 | address_family_encap_cmd, | |
8334fd5a | 5693 | "address-family <encap|encapv4>", |
8b1fb8be | 5694 | "Enter Address Family command mode\n" |
8c3deaae QY |
5695 | "Address Family\n" |
5696 | "Address Family\n") | |
8b1fb8be LB |
5697 | { |
5698 | vty->node = BGP_ENCAP_NODE; | |
5699 | return CMD_SUCCESS; | |
5700 | } | |
5701 | ||
8b1fb8be LB |
5702 | |
5703 | DEFUN (address_family_encapv6, | |
5704 | address_family_encapv6_cmd, | |
5705 | "address-family encapv6", | |
5706 | "Enter Address Family command mode\n" | |
8c3deaae | 5707 | "Address Family\n") |
8b1fb8be LB |
5708 | { |
5709 | vty->node = BGP_ENCAPV6_NODE; | |
5710 | return CMD_SUCCESS; | |
5711 | } | |
5712 | ||
4e0b7b6d PG |
5713 | DEFUN (address_family_evpn, |
5714 | address_family_evpn_cmd, | |
b194703e | 5715 | "address-family <l2vpn evpn>", |
4e0b7b6d | 5716 | "Enter Address Family command mode\n" |
61a51962 PG |
5717 | "EVPN Address family\n" |
5718 | "Layer2 VPN Address family\n" | |
5719 | "Ethernet Virtual Private Network Subsequent Address Family\n") | |
4e0b7b6d | 5720 | { |
4e0b7b6d | 5721 | vty->node = BGP_EVPN_NODE; |
4e0b7b6d PG |
5722 | return CMD_SUCCESS; |
5723 | } | |
5724 | ||
718e3744 | 5725 | DEFUN (exit_address_family, |
5726 | exit_address_family_cmd, | |
5727 | "exit-address-family", | |
5728 | "Exit from Address Family configuration mode\n") | |
5729 | { | |
a8a80d53 | 5730 | if (vty->node == BGP_IPV4_NODE |
5731 | || vty->node == BGP_IPV4M_NODE | |
718e3744 | 5732 | || vty->node == BGP_VPNV4_NODE |
25ffbdc1 | 5733 | || vty->node == BGP_IPV6_NODE |
8ecd3266 | 5734 | || vty->node == BGP_IPV6M_NODE |
8b1fb8be LB |
5735 | || vty->node == BGP_VPNV6_NODE |
5736 | || vty->node == BGP_ENCAP_NODE | |
4e0b7b6d PG |
5737 | || vty->node == BGP_ENCAPV6_NODE |
5738 | || vty->node == BGP_EVPN_NODE) | |
718e3744 | 5739 | vty->node = BGP_NODE; |
5740 | return CMD_SUCCESS; | |
5741 | } | |
6b0655a2 | 5742 | |
8ad7271d DS |
5743 | /* Recalculate bestpath and re-advertise a prefix */ |
5744 | static int | |
01080f7c | 5745 | bgp_clear_prefix (struct vty *vty, const char *view_name, const char *ip_str, |
8ad7271d DS |
5746 | afi_t afi, safi_t safi, struct prefix_rd *prd) |
5747 | { | |
5748 | int ret; | |
5749 | struct prefix match; | |
5750 | struct bgp_node *rn; | |
5751 | struct bgp_node *rm; | |
8ad7271d DS |
5752 | struct bgp *bgp; |
5753 | struct bgp_table *table; | |
5754 | struct bgp_table *rib; | |
5755 | ||
5756 | /* BGP structure lookup. */ | |
5757 | if (view_name) | |
5758 | { | |
5759 | bgp = bgp_lookup_by_name (view_name); | |
5760 | if (bgp == NULL) | |
5761 | { | |
6aeb9e78 | 5762 | vty_out (vty, "%% Can't find BGP instance %s%s", view_name, VTY_NEWLINE); |
8ad7271d DS |
5763 | return CMD_WARNING; |
5764 | } | |
5765 | } | |
5766 | else | |
5767 | { | |
5768 | bgp = bgp_get_default (); | |
5769 | if (bgp == NULL) | |
5770 | { | |
5771 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
5772 | return CMD_WARNING; | |
5773 | } | |
5774 | } | |
5775 | ||
5776 | /* Check IP address argument. */ | |
5777 | ret = str2prefix (ip_str, &match); | |
5778 | if (! ret) | |
5779 | { | |
5780 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); | |
5781 | return CMD_WARNING; | |
5782 | } | |
5783 | ||
5784 | match.family = afi2family (afi); | |
5785 | rib = bgp->rib[afi][safi]; | |
5786 | ||
5787 | if (safi == SAFI_MPLS_VPN) | |
5788 | { | |
5789 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) | |
5790 | { | |
5791 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) | |
5792 | continue; | |
5793 | ||
5794 | if ((table = rn->info) != NULL) | |
5795 | { | |
5796 | if ((rm = bgp_node_match (table, &match)) != NULL) | |
5797 | { | |
5798 | if (rm->p.prefixlen == match.prefixlen) | |
5799 | { | |
5800 | SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR); | |
5801 | bgp_process (bgp, rm, afi, safi); | |
5802 | } | |
5803 | bgp_unlock_node (rm); | |
5804 | } | |
5805 | } | |
5806 | } | |
5807 | } | |
5808 | else | |
5809 | { | |
5810 | if ((rn = bgp_node_match (rib, &match)) != NULL) | |
5811 | { | |
5812 | if (rn->p.prefixlen == match.prefixlen) | |
5813 | { | |
5814 | SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR); | |
5815 | bgp_process (bgp, rn, afi, safi); | |
5816 | } | |
5817 | bgp_unlock_node (rn); | |
5818 | } | |
5819 | } | |
5820 | ||
5821 | return CMD_SUCCESS; | |
5822 | } | |
5823 | ||
b09b5ae0 | 5824 | /* one clear bgp command to rule them all */ |
718e3744 | 5825 | DEFUN (clear_ip_bgp_all, |
5826 | clear_ip_bgp_all_cmd, | |
46f296b4 | 5827 | "clear [ip] bgp [<view|vrf> WORD] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> [<soft [<in|out>]|in [prefix-filter]|out>]", |
718e3744 | 5828 | CLEAR_STR |
5829 | IP_STR | |
5830 | BGP_STR | |
838758ac | 5831 | BGP_INSTANCE_HELP_STR |
b09b5ae0 DW |
5832 | "Clear all peers\n" |
5833 | "BGP neighbor address to clear\n" | |
a80beece | 5834 | "BGP IPv6 neighbor to clear\n" |
838758ac | 5835 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
5836 | "Clear peers with the AS number\n" |
5837 | "Clear all external peers\n" | |
718e3744 | 5838 | "Clear all members of peer-group\n" |
b09b5ae0 | 5839 | "BGP peer-group name\n" |
46f296b4 LB |
5840 | BGP_AFI_HELP_STR |
5841 | BGP_SAFI_HELP_STR | |
b09b5ae0 DW |
5842 | BGP_SOFT_STR |
5843 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
5844 | BGP_SOFT_OUT_STR |
5845 | BGP_SOFT_IN_STR | |
5846 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 5847 | BGP_SOFT_OUT_STR) |
718e3744 | 5848 | { |
cdc2d765 | 5849 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8334fd5a | 5850 | char *vrf = NULL; |
630a298c | 5851 | |
ae19d7dd QY |
5852 | afi_t afi = AFI_IP6; |
5853 | safi_t safi = SAFI_UNICAST; | |
5bf15956 | 5854 | enum clear_sort clr_sort = clear_peer; |
b09b5ae0 DW |
5855 | enum bgp_clear_type clr_type; |
5856 | char *clr_arg = NULL; | |
718e3744 | 5857 | |
ae19d7dd | 5858 | int idx = 0; |
01080f7c | 5859 | |
ae19d7dd QY |
5860 | /* clear [ip] bgp */ |
5861 | if (argv_find (argv, argc, "ip", &idx)) | |
5862 | afi = AFI_IP; | |
5863 | /* [<view|vrf> WORD] */ | |
5864 | if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) | |
838758ac | 5865 | { |
ae19d7dd QY |
5866 | vrf = argv[idx + 1]->arg; |
5867 | idx += 2; | |
838758ac | 5868 | } |
ae19d7dd QY |
5869 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */ |
5870 | if (argv_find (argv, argc, "*", &idx)) | |
b09b5ae0 | 5871 | { |
ae19d7dd | 5872 | clr_sort = clear_all; |
b09b5ae0 | 5873 | } |
ae19d7dd | 5874 | else if (argv_find (argv, argc, "A.B.C.D", &idx)) |
b09b5ae0 DW |
5875 | { |
5876 | clr_sort = clear_peer; | |
ae19d7dd | 5877 | clr_arg = argv[idx]->arg; |
b09b5ae0 | 5878 | } |
ae19d7dd | 5879 | else if (argv_find (argv, argc, "X:X::X:X", &idx)) |
b09b5ae0 | 5880 | { |
ae19d7dd QY |
5881 | clr_sort = clear_peer; |
5882 | clr_arg = argv[idx]->arg; | |
838758ac | 5883 | } |
ae19d7dd | 5884 | else if (argv_find (argv, argc, "peer-group", &idx)) |
b09b5ae0 DW |
5885 | { |
5886 | clr_sort = clear_group; | |
ae19d7dd QY |
5887 | idx++; |
5888 | clr_arg = argv[idx]->arg; | |
718e3744 | 5889 | |
cdc2d765 | 5890 | if (! peer_group_lookup (bgp, clr_arg)) |
b09b5ae0 DW |
5891 | { |
5892 | vty_out (vty, "%% No such peer-group%s", VTY_NEWLINE); | |
ae19d7dd | 5893 | return CMD_WARNING; |
b09b5ae0 DW |
5894 | } |
5895 | } | |
ae19d7dd | 5896 | else if (argv_find (argv, argc, "WORD", &idx)) |
b09b5ae0 | 5897 | { |
cdc2d765 | 5898 | if (peer_lookup_by_conf_if (bgp, argv[idx]->arg)) |
b09b5ae0 DW |
5899 | { |
5900 | clr_sort = clear_peer; | |
ae19d7dd | 5901 | clr_arg = argv[idx]->arg; |
b09b5ae0 DW |
5902 | } |
5903 | else | |
5904 | { | |
5905 | vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE); | |
5906 | return CMD_WARNING; | |
5907 | } | |
5908 | } | |
ae19d7dd QY |
5909 | else if (argv_find (argv, argc, "(1-4294967295)", &idx)) |
5910 | { | |
5911 | clr_sort = clear_as; | |
5912 | clr_arg = argv[idx]->arg; | |
5913 | } | |
5914 | else if (argv_find (argv, argc, "external", &idx)) | |
5915 | { | |
5916 | clr_sort = clear_external; | |
5917 | } | |
46f296b4 LB |
5918 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
5919 | if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) | |
ae19d7dd | 5920 | { |
46f296b4 | 5921 | argv_find_and_parse_safi (argv, argc, &idx, &safi); |
ae19d7dd QY |
5922 | } |
5923 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
5924 | if (argv_find (argv, argc, "soft", &idx)) | |
5925 | { | |
5926 | if (argv_find (argv, argc, "in", &idx) || argv_find (argv, argc, "out", &idx)) | |
5927 | clr_type = strmatch (argv[idx]->text, "in") ? BGP_CLEAR_SOFT_IN : BGP_CLEAR_SOFT_OUT; | |
5928 | else | |
5929 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
5930 | } | |
5931 | else if (argv_find (argv, argc, "in", &idx)) | |
5932 | { | |
5933 | clr_type = argv_find (argv, argc, "prefix-filter", &idx) ? BGP_CLEAR_SOFT_IN_ORF_PREFIX : BGP_CLEAR_SOFT_IN; | |
5934 | } | |
5935 | else if (argv_find (argv, argc, "out", &idx)) | |
5936 | { | |
5daa3e5e | 5937 | clr_type = BGP_CLEAR_SOFT_OUT; |
ae19d7dd QY |
5938 | } |
5939 | else | |
5940 | clr_type = BGP_CLEAR_SOFT_NONE; | |
718e3744 | 5941 | |
b09b5ae0 | 5942 | return bgp_clear_vty (vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); |
838758ac | 5943 | } |
01080f7c | 5944 | |
8ad7271d DS |
5945 | DEFUN (clear_ip_bgp_prefix, |
5946 | clear_ip_bgp_prefix_cmd, | |
838758ac | 5947 | "clear [ip] bgp [<view|vrf> WORD] prefix A.B.C.D/M", |
8ad7271d DS |
5948 | CLEAR_STR |
5949 | IP_STR | |
5950 | BGP_STR | |
838758ac | 5951 | BGP_INSTANCE_HELP_STR |
8ad7271d | 5952 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 5953 | "IPv4 prefix\n") |
8ad7271d | 5954 | { |
8334fd5a | 5955 | char *vrf = NULL; |
630a298c | 5956 | char *prefix = NULL; |
8ad7271d | 5957 | |
630a298c | 5958 | int idx = 0; |
01080f7c | 5959 | |
630a298c QY |
5960 | /* [<view|vrf> WORD] */ |
5961 | if (argv_find (argv, argc, "WORD", &idx)) | |
5962 | vrf = argv[idx]->arg; | |
0c7b1b01 | 5963 | |
630a298c | 5964 | prefix = argv[argc-1]->arg; |
8ad7271d | 5965 | |
630a298c | 5966 | return bgp_clear_prefix (vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 5967 | } |
8ad7271d | 5968 | |
b09b5ae0 DW |
5969 | DEFUN (clear_bgp_ipv6_safi_prefix, |
5970 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 5971 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 5972 | CLEAR_STR |
3a2d747c | 5973 | IP_STR |
718e3744 | 5974 | BGP_STR |
8c3deaae | 5975 | "Address Family\n" |
46f296b4 | 5976 | BGP_SAFI_HELP_STR |
b09b5ae0 | 5977 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 5978 | "IPv6 prefix\n") |
718e3744 | 5979 | { |
b09b5ae0 DW |
5980 | int idx_safi = 3; |
5981 | int idx_ipv6_prefixlen = 5; | |
46f296b4 LB |
5982 | return bgp_clear_prefix (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, |
5983 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), NULL); | |
838758ac | 5984 | } |
01080f7c | 5985 | |
b09b5ae0 DW |
5986 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
5987 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
46f296b4 | 5988 | "clear [ip] bgp <view|vrf> WORD ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 5989 | CLEAR_STR |
3a2d747c | 5990 | IP_STR |
718e3744 | 5991 | BGP_STR |
838758ac | 5992 | BGP_INSTANCE_HELP_STR |
8c3deaae | 5993 | "Address Family\n" |
46f296b4 | 5994 | BGP_SAFI_HELP_STR |
b09b5ae0 | 5995 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 5996 | "IPv6 prefix\n") |
718e3744 | 5997 | { |
b09b5ae0 | 5998 | int idx_word = 3; |
c500ae40 | 5999 | int idx_safi = 5; |
b09b5ae0 | 6000 | int idx_ipv6_prefixlen = 7; |
46f296b4 LB |
6001 | return bgp_clear_prefix (vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, |
6002 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), NULL); | |
718e3744 | 6003 | } |
6004 | ||
b09b5ae0 DW |
6005 | DEFUN (show_bgp_views, |
6006 | show_bgp_views_cmd, | |
d6e3c605 | 6007 | "show [ip] bgp views", |
b09b5ae0 | 6008 | SHOW_STR |
d6e3c605 | 6009 | IP_STR |
01080f7c | 6010 | BGP_STR |
b09b5ae0 | 6011 | "Show the defined BGP views\n") |
01080f7c | 6012 | { |
b09b5ae0 DW |
6013 | struct list *inst = bm->bgp; |
6014 | struct listnode *node; | |
6015 | struct bgp *bgp; | |
01080f7c | 6016 | |
b09b5ae0 DW |
6017 | if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE)) |
6018 | { | |
6019 | vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE); | |
6020 | return CMD_WARNING; | |
6021 | } | |
e52702f2 | 6022 | |
b09b5ae0 DW |
6023 | vty_out (vty, "Defined BGP views:%s", VTY_NEWLINE); |
6024 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) | |
6025 | { | |
6026 | /* Skip VRFs. */ | |
6027 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
6028 | continue; | |
6029 | vty_out (vty, "\t%s (AS%u)%s", | |
6030 | bgp->name ? bgp->name : "(null)", | |
6031 | bgp->as, VTY_NEWLINE); | |
6032 | } | |
e52702f2 | 6033 | |
b09b5ae0 | 6034 | return CMD_SUCCESS; |
e0081f70 ML |
6035 | } |
6036 | ||
8386ac43 | 6037 | DEFUN (show_bgp_vrfs, |
6038 | show_bgp_vrfs_cmd, | |
d6e3c605 | 6039 | "show [ip] bgp vrfs [json]", |
8386ac43 | 6040 | SHOW_STR |
d6e3c605 | 6041 | IP_STR |
8386ac43 | 6042 | BGP_STR |
6043 | "Show BGP VRFs\n" | |
9973d184 | 6044 | JSON_STR) |
8386ac43 | 6045 | { |
6046 | struct list *inst = bm->bgp; | |
6047 | struct listnode *node; | |
6048 | struct bgp *bgp; | |
6049 | u_char uj = use_json(argc, argv); | |
6050 | json_object *json = NULL; | |
6051 | json_object *json_vrfs = NULL; | |
6052 | int count = 0; | |
6053 | static char header[] = "Type Id RouterId #PeersCfg #PeersEstb Name"; | |
6054 | ||
6055 | if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE)) | |
6056 | { | |
6057 | vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE); | |
6058 | return CMD_WARNING; | |
6059 | } | |
6060 | ||
6061 | if (uj) | |
6062 | { | |
6063 | json = json_object_new_object(); | |
6064 | json_vrfs = json_object_new_object(); | |
6065 | } | |
6066 | ||
6067 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) | |
6068 | { | |
6069 | const char *name, *type; | |
6070 | struct peer *peer; | |
6071 | struct listnode *node, *nnode; | |
6072 | int peers_cfg, peers_estb; | |
6073 | json_object *json_vrf = NULL; | |
5c81a5f3 | 6074 | int vrf_id_ui; |
8386ac43 | 6075 | |
6076 | /* Skip Views. */ | |
6077 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
6078 | continue; | |
6079 | ||
6080 | count++; | |
6081 | if (!uj && count == 1) | |
6082 | vty_out (vty, "%s%s", header, VTY_NEWLINE); | |
6083 | ||
6084 | peers_cfg = peers_estb = 0; | |
6085 | if (uj) | |
6086 | json_vrf = json_object_new_object(); | |
6087 | ||
6088 | ||
6089 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
6090 | { | |
6091 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6092 | continue; | |
6093 | peers_cfg++; | |
6094 | if (peer->status == Established) | |
6095 | peers_estb++; | |
6096 | } | |
6097 | ||
6098 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
6099 | { | |
6100 | name = "Default"; | |
6101 | type = "DFLT"; | |
6102 | } | |
6103 | else | |
6104 | { | |
6105 | name = bgp->name; | |
6106 | type = "VRF"; | |
6107 | } | |
6108 | ||
5c81a5f3 | 6109 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id; |
8386ac43 | 6110 | if (uj) |
6111 | { | |
6112 | json_object_string_add(json_vrf, "type", type); | |
5c81a5f3 | 6113 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); |
8386ac43 | 6114 | json_object_string_add(json_vrf, "routerId", inet_ntoa (bgp->router_id)); |
6115 | json_object_int_add(json_vrf, "numConfiguredPeers", peers_cfg); | |
6116 | json_object_int_add(json_vrf, "numEstablishedPeers", peers_estb); | |
6117 | ||
6118 | json_object_object_add(json_vrfs, name, json_vrf); | |
6119 | } | |
6120 | else | |
5c81a5f3 | 6121 | vty_out (vty, "%4s %-5d %-16s %9u %10u %s%s", |
6122 | type, vrf_id_ui, inet_ntoa (bgp->router_id), | |
8386ac43 | 6123 | peers_cfg, peers_estb, name, |
6124 | VTY_NEWLINE); | |
6125 | } | |
6126 | ||
6127 | if (uj) | |
6128 | { | |
6129 | json_object_object_add(json, "vrfs", json_vrfs); | |
6130 | ||
6131 | json_object_int_add(json, "totalVrfs", count); | |
6132 | ||
2aac5767 | 6133 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
8386ac43 | 6134 | json_object_free(json); |
6135 | } | |
6136 | else | |
6137 | { | |
6138 | if (count) | |
6139 | vty_out (vty, "%sTotal number of VRFs (including default): %d%s", | |
6140 | VTY_NEWLINE, count, VTY_NEWLINE); | |
6141 | } | |
6142 | ||
6143 | return CMD_SUCCESS; | |
6144 | } | |
6145 | ||
f412b39a | 6146 | DEFUN (show_bgp_memory, |
4bf6a362 | 6147 | show_bgp_memory_cmd, |
7fa12b13 | 6148 | "show [ip] bgp memory", |
4bf6a362 | 6149 | SHOW_STR |
3a2d747c | 6150 | IP_STR |
4bf6a362 PJ |
6151 | BGP_STR |
6152 | "Global BGP memory statistics\n") | |
6153 | { | |
6154 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
6155 | unsigned long count; | |
e52702f2 | 6156 | |
4bf6a362 PJ |
6157 | /* RIB related usage stats */ |
6158 | count = mtype_stats_alloc (MTYPE_BGP_NODE); | |
6159 | vty_out (vty, "%ld RIB nodes, using %s of memory%s", count, | |
6160 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6161 | count * sizeof (struct bgp_node)), | |
6162 | VTY_NEWLINE); | |
e52702f2 | 6163 | |
4bf6a362 PJ |
6164 | count = mtype_stats_alloc (MTYPE_BGP_ROUTE); |
6165 | vty_out (vty, "%ld BGP routes, using %s of memory%s", count, | |
6166 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6167 | count * sizeof (struct bgp_info)), | |
6168 | VTY_NEWLINE); | |
fb982c25 PJ |
6169 | if ((count = mtype_stats_alloc (MTYPE_BGP_ROUTE_EXTRA))) |
6170 | vty_out (vty, "%ld BGP route ancillaries, using %s of memory%s", count, | |
6171 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6172 | count * sizeof (struct bgp_info_extra)), | |
6173 | VTY_NEWLINE); | |
e52702f2 | 6174 | |
4bf6a362 PJ |
6175 | if ((count = mtype_stats_alloc (MTYPE_BGP_STATIC))) |
6176 | vty_out (vty, "%ld Static routes, using %s of memory%s", count, | |
6177 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6178 | count * sizeof (struct bgp_static)), | |
6179 | VTY_NEWLINE); | |
3f9c7369 DS |
6180 | |
6181 | if ((count = mtype_stats_alloc (MTYPE_BGP_PACKET))) | |
6182 | vty_out (vty, "%ld Packets, using %s of memory%s", count, | |
6183 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6184 | count * sizeof (struct bpacket)), | |
6185 | VTY_NEWLINE); | |
e52702f2 | 6186 | |
4bf6a362 PJ |
6187 | /* Adj-In/Out */ |
6188 | if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_IN))) | |
6189 | vty_out (vty, "%ld Adj-In entries, using %s of memory%s", count, | |
6190 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6191 | count * sizeof (struct bgp_adj_in)), | |
6192 | VTY_NEWLINE); | |
6193 | if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_OUT))) | |
6194 | vty_out (vty, "%ld Adj-Out entries, using %s of memory%s", count, | |
6195 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6196 | count * sizeof (struct bgp_adj_out)), | |
6197 | VTY_NEWLINE); | |
e52702f2 | 6198 | |
4bf6a362 PJ |
6199 | if ((count = mtype_stats_alloc (MTYPE_BGP_NEXTHOP_CACHE))) |
6200 | vty_out (vty, "%ld Nexthop cache entries, using %s of memory%s", count, | |
6201 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6202 | count * sizeof (struct bgp_nexthop_cache)), | |
6203 | VTY_NEWLINE); | |
6204 | ||
6205 | if ((count = mtype_stats_alloc (MTYPE_BGP_DAMP_INFO))) | |
6206 | vty_out (vty, "%ld Dampening entries, using %s of memory%s", count, | |
6207 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6208 | count * sizeof (struct bgp_damp_info)), | |
6209 | VTY_NEWLINE); | |
6210 | ||
6211 | /* Attributes */ | |
6212 | count = attr_count(); | |
e52702f2 QY |
6213 | vty_out (vty, "%ld BGP attributes, using %s of memory%s", count, |
6214 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6215 | count * sizeof(struct attr)), | |
4bf6a362 | 6216 | VTY_NEWLINE); |
fb982c25 | 6217 | if ((count = mtype_stats_alloc (MTYPE_ATTR_EXTRA))) |
e52702f2 QY |
6218 | vty_out (vty, "%ld BGP extra attributes, using %s of memory%s", count, |
6219 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6220 | count * sizeof(struct attr_extra)), | |
fb982c25 | 6221 | VTY_NEWLINE); |
e52702f2 | 6222 | |
4bf6a362 PJ |
6223 | if ((count = attr_unknown_count())) |
6224 | vty_out (vty, "%ld unknown attributes%s", count, VTY_NEWLINE); | |
e52702f2 | 6225 | |
4bf6a362 PJ |
6226 | /* AS_PATH attributes */ |
6227 | count = aspath_count (); | |
6228 | vty_out (vty, "%ld BGP AS-PATH entries, using %s of memory%s", count, | |
6229 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6230 | count * sizeof (struct aspath)), | |
6231 | VTY_NEWLINE); | |
e52702f2 | 6232 | |
4bf6a362 PJ |
6233 | count = mtype_stats_alloc (MTYPE_AS_SEG); |
6234 | vty_out (vty, "%ld BGP AS-PATH segments, using %s of memory%s", count, | |
6235 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6236 | count * sizeof (struct assegment)), | |
6237 | VTY_NEWLINE); | |
e52702f2 | 6238 | |
4bf6a362 PJ |
6239 | /* Other attributes */ |
6240 | if ((count = community_count ())) | |
6241 | vty_out (vty, "%ld BGP community entries, using %s of memory%s", count, | |
6242 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6243 | count * sizeof (struct community)), | |
6244 | VTY_NEWLINE); | |
6245 | if ((count = mtype_stats_alloc (MTYPE_ECOMMUNITY))) | |
6246 | vty_out (vty, "%ld BGP community entries, using %s of memory%s", count, | |
6247 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6248 | count * sizeof (struct ecommunity)), | |
6249 | VTY_NEWLINE); | |
57d187bc JS |
6250 | if ((count = mtype_stats_alloc (MTYPE_LCOMMUNITY))) |
6251 | vty_out (vty, "%ld BGP large-community entries, using %s of memory%s", | |
2acb4ac2 | 6252 | count, |
57d187bc JS |
6253 | mtype_memstr (memstrbuf, sizeof (memstrbuf), |
6254 | count * sizeof (struct lcommunity)), | |
6255 | VTY_NEWLINE); | |
e52702f2 | 6256 | |
4bf6a362 PJ |
6257 | if ((count = mtype_stats_alloc (MTYPE_CLUSTER))) |
6258 | vty_out (vty, "%ld Cluster lists, using %s of memory%s", count, | |
6259 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6260 | count * sizeof (struct cluster_list)), | |
6261 | VTY_NEWLINE); | |
e52702f2 | 6262 | |
4bf6a362 PJ |
6263 | /* Peer related usage */ |
6264 | count = mtype_stats_alloc (MTYPE_BGP_PEER); | |
6265 | vty_out (vty, "%ld peers, using %s of memory%s", count, | |
6266 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6267 | count * sizeof (struct peer)), | |
6268 | VTY_NEWLINE); | |
e52702f2 | 6269 | |
4a1ab8e4 | 6270 | if ((count = mtype_stats_alloc (MTYPE_PEER_GROUP))) |
4bf6a362 PJ |
6271 | vty_out (vty, "%ld peer groups, using %s of memory%s", count, |
6272 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6273 | count * sizeof (struct peer_group)), | |
6274 | VTY_NEWLINE); | |
e52702f2 | 6275 | |
4bf6a362 PJ |
6276 | /* Other */ |
6277 | if ((count = mtype_stats_alloc (MTYPE_HASH))) | |
6278 | vty_out (vty, "%ld hash tables, using %s of memory%s", count, | |
6279 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6280 | count * sizeof (struct hash)), | |
6281 | VTY_NEWLINE); | |
6282 | if ((count = mtype_stats_alloc (MTYPE_HASH_BACKET))) | |
6283 | vty_out (vty, "%ld hash buckets, using %s of memory%s", count, | |
6284 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6285 | count * sizeof (struct hash_backet)), | |
6286 | VTY_NEWLINE); | |
6287 | if ((count = mtype_stats_alloc (MTYPE_BGP_REGEXP))) | |
6288 | vty_out (vty, "%ld compiled regexes, using %s of memory%s", count, | |
6289 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6290 | count * sizeof (regex_t)), | |
6291 | VTY_NEWLINE); | |
6292 | return CMD_SUCCESS; | |
6293 | } | |
fee0f4c6 | 6294 | |
718e3744 | 6295 | /* Show BGP peer's summary information. */ |
94f2b392 | 6296 | static int |
b05a1c8b | 6297 | bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi, |
9f689658 | 6298 | u_char use_json, json_object *json) |
718e3744 | 6299 | { |
6300 | struct peer *peer; | |
1eb8ef25 | 6301 | struct listnode *node, *nnode; |
f14e6fdb DS |
6302 | unsigned int count = 0, dn_count = 0; |
6303 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
f933309e DW |
6304 | char neighbor_buf[VTY_BUFSIZ]; |
6305 | int neighbor_col_default_width = 16; | |
718e3744 | 6306 | int len; |
f933309e | 6307 | int max_neighbor_width = 0; |
ffd0c037 DS |
6308 | json_object *json_peer = NULL; |
6309 | json_object *json_peers = NULL; | |
718e3744 | 6310 | |
b05a1c8b DS |
6311 | if (use_json) |
6312 | { | |
9f689658 DD |
6313 | if (json == NULL) |
6314 | json = json_object_new_object(); | |
6315 | ||
f1aa5d8a | 6316 | json_peers = json_object_new_object(); |
b05a1c8b | 6317 | } |
f933309e DW |
6318 | else |
6319 | { | |
6320 | /* Loop over all neighbors that will be displayed to determine how many | |
6321 | * characters are needed for the Neighbor column | |
6322 | */ | |
6323 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
6324 | { | |
6325 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6326 | continue; | |
6327 | ||
6328 | if (peer->afc[afi][safi]) | |
6329 | { | |
c9d5bd27 DS |
6330 | memset(dn_flag, '\0', sizeof(dn_flag)); |
6331 | if (peer_dynamic_neighbor(peer)) | |
6332 | dn_flag[0] = '*'; | |
6333 | ||
f933309e DW |
6334 | if (peer->hostname && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) |
6335 | sprintf(neighbor_buf, "%s%s(%s) ", dn_flag, peer->hostname, peer->host); | |
6336 | else | |
6337 | sprintf(neighbor_buf, "%s%s ", dn_flag, peer->host); | |
6338 | ||
6339 | len = strlen(neighbor_buf); | |
6340 | ||
6341 | if (len > max_neighbor_width) | |
6342 | max_neighbor_width = len; | |
6343 | } | |
6344 | } | |
6345 | ||
6346 | /* Originally we displayed the Neighbor column as 16 | |
6347 | * characters wide so make that the default | |
6348 | */ | |
6349 | if (max_neighbor_width < neighbor_col_default_width) | |
6350 | max_neighbor_width = neighbor_col_default_width; | |
6351 | } | |
b05a1c8b | 6352 | |
1eb8ef25 | 6353 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
718e3744 | 6354 | { |
1ff9a340 DS |
6355 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
6356 | continue; | |
6357 | ||
718e3744 | 6358 | if (peer->afc[afi][safi]) |
6359 | { | |
b05a1c8b | 6360 | if (!count) |
4bf6a362 PJ |
6361 | { |
6362 | unsigned long ents; | |
6363 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
5c81a5f3 | 6364 | int vrf_id_ui; |
6365 | ||
6366 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id; | |
b05a1c8b | 6367 | |
4bf6a362 | 6368 | /* Usage summary and header */ |
b05a1c8b DS |
6369 | if (use_json) |
6370 | { | |
62d6dca0 | 6371 | json_object_string_add(json, "routerId", inet_ntoa (bgp->router_id)); |
f1aa5d8a | 6372 | json_object_int_add(json, "as", bgp->as); |
9f689658 DD |
6373 | json_object_int_add(json, "vrfId", vrf_id_ui); |
6374 | json_object_string_add(json, "vrfName", | |
6375 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
6376 | ? "Default" : bgp->name); | |
b05a1c8b DS |
6377 | } |
6378 | else | |
6379 | { | |
6380 | vty_out (vty, | |
5c81a5f3 | 6381 | "BGP router identifier %s, local AS number %u vrf-id %d", |
6382 | inet_ntoa (bgp->router_id), bgp->as, vrf_id_ui); | |
6aeb9e78 | 6383 | vty_out (vty, "%s", VTY_NEWLINE); |
b05a1c8b DS |
6384 | } |
6385 | ||
f188f2c4 DS |
6386 | if (bgp_update_delay_configured(bgp)) |
6387 | { | |
b05a1c8b | 6388 | if (use_json) |
f188f2c4 | 6389 | { |
62d6dca0 | 6390 | json_object_int_add(json, "updateDelayLimit", bgp->v_update_delay); |
b05a1c8b DS |
6391 | |
6392 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
62d6dca0 | 6393 | json_object_int_add(json, "updateDelayEstablishWait", bgp->v_establish_wait); |
b05a1c8b DS |
6394 | |
6395 | if (bgp_update_delay_active(bgp)) | |
6396 | { | |
62d6dca0 DS |
6397 | json_object_string_add(json, "updateDelayFirstNeighbor", bgp->update_delay_begin_time); |
6398 | json_object_boolean_true_add(json, "updateDelayInProgress"); | |
b05a1c8b DS |
6399 | } |
6400 | else | |
6401 | { | |
6402 | if (bgp->update_delay_over) | |
6403 | { | |
62d6dca0 | 6404 | json_object_string_add(json, "updateDelayFirstNeighbor", |
f1aa5d8a | 6405 | bgp->update_delay_begin_time); |
62d6dca0 | 6406 | json_object_string_add(json, "updateDelayBestpathResumed", |
f1aa5d8a | 6407 | bgp->update_delay_end_time); |
62d6dca0 | 6408 | json_object_string_add(json, "updateDelayZebraUpdateResume", |
f1aa5d8a | 6409 | bgp->update_delay_zebra_resume_time); |
62d6dca0 | 6410 | json_object_string_add(json, "updateDelayPeerUpdateResume", |
f1aa5d8a | 6411 | bgp->update_delay_peers_resume_time); |
b05a1c8b DS |
6412 | } |
6413 | } | |
f188f2c4 DS |
6414 | } |
6415 | else | |
6416 | { | |
b05a1c8b DS |
6417 | vty_out (vty, "Read-only mode update-delay limit: %d seconds%s", |
6418 | bgp->v_update_delay, VTY_NEWLINE); | |
6419 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
6420 | vty_out (vty, " Establish wait: %d seconds%s", | |
6421 | bgp->v_establish_wait, VTY_NEWLINE); | |
6422 | ||
6423 | if (bgp_update_delay_active(bgp)) | |
f188f2c4 DS |
6424 | { |
6425 | vty_out (vty, " First neighbor established: %s%s", | |
6426 | bgp->update_delay_begin_time, VTY_NEWLINE); | |
b05a1c8b DS |
6427 | vty_out (vty, " Delay in progress%s", VTY_NEWLINE); |
6428 | } | |
6429 | else | |
6430 | { | |
6431 | if (bgp->update_delay_over) | |
6432 | { | |
6433 | vty_out (vty, " First neighbor established: %s%s", | |
6434 | bgp->update_delay_begin_time, VTY_NEWLINE); | |
6435 | vty_out (vty, " Best-paths resumed: %s%s", | |
6436 | bgp->update_delay_end_time, VTY_NEWLINE); | |
6437 | vty_out (vty, " zebra update resumed: %s%s", | |
6438 | bgp->update_delay_zebra_resume_time, VTY_NEWLINE); | |
6439 | vty_out (vty, " peers update resumed: %s%s", | |
6440 | bgp->update_delay_peers_resume_time, VTY_NEWLINE); | |
6441 | } | |
f188f2c4 DS |
6442 | } |
6443 | } | |
6444 | } | |
4bf6a362 | 6445 | |
b05a1c8b DS |
6446 | if (use_json) |
6447 | { | |
6448 | if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active) | |
62d6dca0 | 6449 | json_object_boolean_true_add(json, "maxMedOnStartup"); |
b05a1c8b | 6450 | if (bgp->v_maxmed_admin) |
62d6dca0 | 6451 | json_object_boolean_true_add(json, "maxMedAdministrative"); |
b05a1c8b | 6452 | |
62d6dca0 | 6453 | json_object_int_add(json, "tableVersion", bgp_table_version(bgp->rib[afi][safi])); |
b05a1c8b DS |
6454 | |
6455 | ents = bgp_table_count (bgp->rib[afi][safi]); | |
62d6dca0 DS |
6456 | json_object_int_add(json, "ribCount", ents); |
6457 | json_object_int_add(json, "ribMemory", ents * sizeof (struct bgp_node)); | |
b05a1c8b DS |
6458 | |
6459 | ents = listcount (bgp->peer); | |
62d6dca0 DS |
6460 | json_object_int_add(json, "peerCount", ents); |
6461 | json_object_int_add(json, "peerMemory", ents * sizeof (struct peer)); | |
b05a1c8b | 6462 | |
b05a1c8b DS |
6463 | if ((ents = listcount (bgp->group))) |
6464 | { | |
62d6dca0 DS |
6465 | json_object_int_add(json, "peerGroupCount", ents); |
6466 | json_object_int_add(json, "peerGroupMemory", ents * sizeof (struct peer_group)); | |
b05a1c8b | 6467 | } |
3f9c7369 | 6468 | |
b05a1c8b | 6469 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) |
62d6dca0 | 6470 | json_object_boolean_true_add(json, "dampeningEnabled"); |
b05a1c8b DS |
6471 | } |
6472 | else | |
6473 | { | |
6474 | if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active) | |
6475 | vty_out (vty, "Max-med on-startup active%s", VTY_NEWLINE); | |
6476 | if (bgp->v_maxmed_admin) | |
6477 | vty_out (vty, "Max-med administrative active%s", VTY_NEWLINE); | |
6478 | ||
ffd0c037 | 6479 | vty_out(vty, "BGP table version %" PRIu64 "%s", |
b05a1c8b DS |
6480 | bgp_table_version(bgp->rib[afi][safi]), VTY_NEWLINE); |
6481 | ||
6482 | ents = bgp_table_count (bgp->rib[afi][safi]); | |
6483 | vty_out (vty, "RIB entries %ld, using %s of memory%s", ents, | |
6484 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6485 | ents * sizeof (struct bgp_node)), | |
6486 | VTY_NEWLINE); | |
6487 | ||
6488 | /* Peer related usage */ | |
6489 | ents = listcount (bgp->peer); | |
6490 | vty_out (vty, "Peers %ld, using %s of memory%s", | |
6491 | ents, | |
6492 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6493 | ents * sizeof (struct peer)), | |
6494 | VTY_NEWLINE); | |
6495 | ||
b05a1c8b DS |
6496 | if ((ents = listcount (bgp->group))) |
6497 | vty_out (vty, "Peer groups %ld, using %s of memory%s", ents, | |
6498 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6499 | ents * sizeof (struct peer_group)), | |
6500 | VTY_NEWLINE); | |
6501 | ||
6502 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) | |
6503 | vty_out (vty, "Dampening enabled.%s", VTY_NEWLINE); | |
6504 | vty_out (vty, "%s", VTY_NEWLINE); | |
f933309e DW |
6505 | |
6506 | /* Subtract 8 here because 'Neighbor' is 8 characters */ | |
6507 | vty_out (vty, "Neighbor"); | |
6508 | vty_out (vty, "%*s", max_neighbor_width - 8, " "); | |
6509 | vty_out (vty, "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd%s", VTY_NEWLINE); | |
b05a1c8b | 6510 | } |
4bf6a362 | 6511 | } |
e52702f2 | 6512 | |
b05a1c8b | 6513 | count++; |
718e3744 | 6514 | |
b05a1c8b DS |
6515 | if (use_json) |
6516 | { | |
6517 | json_peer = json_object_new_object(); | |
f14e6fdb | 6518 | |
b05a1c8b | 6519 | if (peer_dynamic_neighbor(peer)) |
62d6dca0 | 6520 | json_object_boolean_true_add(json_peer, "dynamicPeer"); |
b05a1c8b | 6521 | |
04b6bdc0 DW |
6522 | if (peer->hostname) |
6523 | json_object_string_add(json_peer, "hostname", peer->hostname); | |
6524 | ||
6525 | if (peer->domainname) | |
6526 | json_object_string_add(json_peer, "domainname", peer->domainname); | |
6527 | ||
62d6dca0 | 6528 | json_object_int_add(json_peer, "remoteAs", peer->as); |
f1aa5d8a | 6529 | json_object_int_add(json_peer, "version", 4); |
62d6dca0 | 6530 | json_object_int_add(json_peer, "msgRcvd", |
f1aa5d8a DS |
6531 | peer->open_in + peer->update_in + peer->keepalive_in |
6532 | + peer->notify_in + peer->refresh_in | |
6533 | + peer->dynamic_cap_in); | |
62d6dca0 | 6534 | json_object_int_add(json_peer, "msgSent", |
f1aa5d8a DS |
6535 | peer->open_out + peer->update_out + peer->keepalive_out |
6536 | + peer->notify_out + peer->refresh_out | |
6537 | + peer->dynamic_cap_out); | |
6538 | ||
62d6dca0 | 6539 | json_object_int_add(json_peer, "tableVersion", peer->version[afi][safi]); |
f1aa5d8a DS |
6540 | json_object_int_add(json_peer, "outq", peer->obuf->count); |
6541 | json_object_int_add(json_peer, "inq", 0); | |
856ca177 | 6542 | peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, use_json, json_peer); |
62d6dca0 | 6543 | json_object_int_add(json_peer, "prefixReceivedCount", peer->pcount[afi][safi]); |
b05a1c8b DS |
6544 | |
6545 | if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) | |
f1aa5d8a | 6546 | json_object_string_add(json_peer, "state", "Idle (Admin)"); |
b05a1c8b | 6547 | else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) |
f1aa5d8a | 6548 | json_object_string_add(json_peer, "state", "Idle (PfxCt)"); |
b05a1c8b | 6549 | else |
f1aa5d8a | 6550 | json_object_string_add(json_peer, "state", LOOKUP(bgp_status_msg, peer->status)); |
b05a1c8b | 6551 | |
f1aa5d8a | 6552 | if (peer->conf_if) |
62d6dca0 | 6553 | json_object_string_add(json_peer, "idType", "interface"); |
f1aa5d8a | 6554 | else if (peer->su.sa.sa_family == AF_INET) |
62d6dca0 | 6555 | json_object_string_add(json_peer, "idType", "ipv4"); |
f1aa5d8a | 6556 | else if (peer->su.sa.sa_family == AF_INET6) |
62d6dca0 | 6557 | json_object_string_add(json_peer, "idType", "ipv6"); |
b05a1c8b | 6558 | |
f1aa5d8a | 6559 | json_object_object_add(json_peers, peer->host, json_peer); |
b05a1c8b DS |
6560 | } |
6561 | else | |
6562 | { | |
6563 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
6564 | if (peer_dynamic_neighbor(peer)) | |
6565 | { | |
6566 | dn_count++; | |
6567 | dn_flag[0] = '*'; | |
6568 | } | |
6569 | ||
04b6bdc0 DW |
6570 | if (peer->hostname && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) |
6571 | len = vty_out (vty, "%s%s(%s)", dn_flag, peer->hostname, | |
6572 | peer->host); | |
6573 | else | |
6574 | len = vty_out (vty, "%s%s", dn_flag, peer->host); | |
b05a1c8b | 6575 | |
f933309e DW |
6576 | /* pad the neighbor column with spaces */ |
6577 | if (len < max_neighbor_width) | |
6578 | vty_out (vty, "%*s", max_neighbor_width - len, " "); | |
b05a1c8b | 6579 | |
f933309e | 6580 | vty_out (vty, "4 %10u %7d %7d %8" PRIu64 " %4d %4zd %8s", |
b05a1c8b DS |
6581 | peer->as, |
6582 | peer->open_in + peer->update_in + peer->keepalive_in | |
6583 | + peer->notify_in + peer->refresh_in | |
6584 | + peer->dynamic_cap_in, | |
6585 | peer->open_out + peer->update_out + peer->keepalive_out | |
6586 | + peer->notify_out + peer->refresh_out | |
6587 | + peer->dynamic_cap_out, | |
6588 | peer->version[afi][safi], | |
6589 | 0, | |
f933309e | 6590 | peer->obuf->count, |
856ca177 | 6591 | peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL)); |
b05a1c8b DS |
6592 | |
6593 | if (peer->status == Established) | |
46f8c104 | 6594 | vty_out (vty, " %12ld", peer->pcount[afi][safi]); |
b05a1c8b DS |
6595 | else |
6596 | { | |
6597 | if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) | |
6598 | vty_out (vty, " Idle (Admin)"); | |
6599 | else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) | |
6600 | vty_out (vty, " Idle (PfxCt)"); | |
6601 | else | |
f933309e | 6602 | vty_out (vty, " %12s", LOOKUP(bgp_status_msg, peer->status)); |
b05a1c8b DS |
6603 | } |
6604 | vty_out (vty, "%s", VTY_NEWLINE); | |
6605 | } | |
718e3744 | 6606 | } |
6607 | } | |
6608 | ||
b05a1c8b DS |
6609 | if (use_json) |
6610 | { | |
6611 | json_object_object_add(json, "peers", json_peers); | |
14151a32 | 6612 | |
62d6dca0 DS |
6613 | json_object_int_add(json, "totalPeers", count); |
6614 | json_object_int_add(json, "dynamicPeers", dn_count); | |
14151a32 | 6615 | |
2aac5767 | 6616 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
f1aa5d8a | 6617 | json_object_free(json); |
b05a1c8b DS |
6618 | } |
6619 | else | |
f14e6fdb | 6620 | { |
b05a1c8b DS |
6621 | if (count) |
6622 | vty_out (vty, "%sTotal number of neighbors %d%s", VTY_NEWLINE, | |
6623 | count, VTY_NEWLINE); | |
6624 | else | |
9f689658 DD |
6625 | { |
6626 | if (use_json) | |
6627 | vty_out(vty, "{\"error\": {\"message\": \"No %s neighbor configured\"}}%s", | |
46f296b4 | 6628 | afi_safi_print(afi, safi), VTY_NEWLINE); |
9f689658 DD |
6629 | else |
6630 | vty_out (vty, "No %s neighbor is configured%s", | |
46f296b4 | 6631 | afi_safi_print(afi, safi), VTY_NEWLINE); |
9f689658 | 6632 | } |
b05a1c8b | 6633 | |
9f689658 | 6634 | if (dn_count && ! use_json) |
b05a1c8b DS |
6635 | { |
6636 | vty_out(vty, "* - dynamic neighbor%s", VTY_NEWLINE); | |
6637 | vty_out(vty, | |
6638 | "%d dynamic neighbor(s), limit %d%s", | |
6639 | dn_count, bgp->dynamic_neighbors_limit, VTY_NEWLINE); | |
6640 | } | |
f14e6fdb DS |
6641 | } |
6642 | ||
718e3744 | 6643 | return CMD_SUCCESS; |
6644 | } | |
6645 | ||
27162734 LB |
6646 | static void |
6647 | bgp_show_summary_afi_safi (struct vty *vty, struct bgp *bgp, int afi, int safi, | |
6648 | u_char use_json, json_object *json) | |
6649 | { | |
6650 | int is_first = 1; | |
6651 | int afi_wildcard = (afi == AFI_MAX); | |
6652 | int safi_wildcard = (safi == SAFI_MAX); | |
6653 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
6654 | if (use_json && is_wildcard) | |
6655 | vty_out (vty, "{%s", VTY_NEWLINE); | |
6656 | if (afi_wildcard) | |
6657 | afi = 1; /* AFI_IP */ | |
6658 | while (afi < AFI_MAX) | |
6659 | { | |
6660 | if (safi_wildcard) | |
6661 | safi = 1; /* SAFI_UNICAST */ | |
6662 | while (safi < SAFI_MAX) | |
6663 | { | |
6664 | if (is_wildcard) | |
6665 | { | |
6666 | if (use_json) | |
6667 | { | |
6668 | json = json_object_new_object(); | |
6669 | ||
6670 | if (! is_first) | |
6671 | vty_out (vty, ",%s", VTY_NEWLINE); | |
6672 | else | |
6673 | is_first = 0; | |
6674 | ||
6675 | vty_out(vty, "\"%s\":", afi_safi_json(afi, safi)); | |
6676 | } | |
6677 | else | |
6678 | { | |
6679 | vty_out (vty, "%s%s Summary:%s", | |
6680 | VTY_NEWLINE, afi_safi_print(afi, safi), VTY_NEWLINE); | |
6681 | } | |
6682 | } | |
6683 | bgp_show_summary (vty, bgp, afi, safi, use_json, json); | |
f62a5c33 LB |
6684 | safi++; |
6685 | if (safi == SAFI_RESERVED_4 || | |
6686 | safi == SAFI_RESERVED_5) /* handle special cases to match zebra.h */ | |
6687 | safi++; | |
27162734 LB |
6688 | if (! safi_wildcard) |
6689 | safi = SAFI_MAX; | |
6690 | } | |
6691 | afi++; | |
6692 | if (! afi_wildcard || | |
5ef6cd69 | 6693 | afi == AFI_L2VPN) /* special case, not handled yet */ |
27162734 LB |
6694 | afi = AFI_MAX; |
6695 | } | |
6696 | ||
6697 | if (use_json && is_wildcard) | |
6698 | vty_out (vty, "}%s", VTY_NEWLINE); | |
6699 | ||
6700 | } | |
6701 | ||
f186de26 | 6702 | static void |
6703 | bgp_show_all_instances_summary_vty (struct vty *vty, afi_t afi, safi_t safi, | |
6704 | u_char use_json) | |
6705 | { | |
6706 | struct listnode *node, *nnode; | |
6707 | struct bgp *bgp; | |
9f689658 DD |
6708 | json_object *json = NULL; |
6709 | int is_first = 1; | |
6710 | ||
6711 | if (use_json) | |
6712 | vty_out (vty, "{%s", VTY_NEWLINE); | |
f186de26 | 6713 | |
6714 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) | |
6715 | { | |
9f689658 DD |
6716 | if (use_json) |
6717 | { | |
4fb25c53 | 6718 | json = json_object_new_object(); |
9f689658 DD |
6719 | |
6720 | if (! is_first) | |
6721 | vty_out (vty, ",%s", VTY_NEWLINE); | |
6722 | else | |
6723 | is_first = 0; | |
6724 | ||
6725 | vty_out(vty, "\"%s\":", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
6726 | ? "Default" : bgp->name); | |
6727 | } | |
6728 | else | |
6729 | { | |
6730 | vty_out (vty, "%sInstance %s:%s", | |
6731 | VTY_NEWLINE, | |
6732 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
6733 | ? "Default" : bgp->name, VTY_NEWLINE); | |
6734 | } | |
27162734 | 6735 | bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, json); |
f186de26 | 6736 | } |
9f689658 DD |
6737 | |
6738 | if (use_json) | |
6739 | vty_out (vty, "}%s", VTY_NEWLINE); | |
6740 | ||
f186de26 | 6741 | } |
6742 | ||
4fb25c53 DW |
6743 | static int |
6744 | bgp_show_summary_vty (struct vty *vty, const char *name, | |
6745 | afi_t afi, safi_t safi, u_char use_json) | |
6746 | { | |
6747 | struct bgp *bgp; | |
6748 | ||
6749 | if (name) | |
6750 | { | |
6751 | if (strmatch(name, "all")) | |
6752 | { | |
6753 | bgp_show_all_instances_summary_vty (vty, afi, safi, use_json); | |
6754 | return CMD_SUCCESS; | |
6755 | } | |
6756 | else | |
6757 | { | |
6758 | bgp = bgp_lookup_by_name (name); | |
6759 | ||
6760 | if (! bgp) | |
6761 | { | |
6762 | if (use_json) | |
6763 | vty_out (vty, "{}%s", VTY_NEWLINE); | |
6764 | else | |
6765 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
6766 | return CMD_WARNING; | |
6767 | } | |
6768 | ||
27162734 | 6769 | bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, NULL); |
4fb25c53 DW |
6770 | return CMD_SUCCESS; |
6771 | } | |
6772 | } | |
6773 | ||
6774 | bgp = bgp_get_default (); | |
6775 | ||
6776 | if (bgp) | |
27162734 | 6777 | bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, NULL); |
4fb25c53 DW |
6778 | |
6779 | return CMD_SUCCESS; | |
6780 | } | |
6781 | ||
716b2d8a | 6782 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 6783 | DEFUN (show_ip_bgp_summary, |
718e3744 | 6784 | show_ip_bgp_summary_cmd, |
46f296b4 | 6785 | "show [ip] bgp [<view|vrf> WORD] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] summary [json]", |
718e3744 | 6786 | SHOW_STR |
6787 | IP_STR | |
6788 | BGP_STR | |
8386ac43 | 6789 | BGP_INSTANCE_HELP_STR |
46f296b4 LB |
6790 | BGP_AFI_HELP_STR |
6791 | BGP_SAFI_HELP_STR | |
b05a1c8b | 6792 | "Summary of BGP neighbor status\n" |
9973d184 | 6793 | JSON_STR) |
718e3744 | 6794 | { |
74ca3d33 | 6795 | char *vrf = NULL; |
27162734 LB |
6796 | afi_t afi = AFI_MAX; |
6797 | safi_t safi = SAFI_MAX; | |
ae19d7dd QY |
6798 | |
6799 | int idx = 0; | |
6800 | ||
6801 | /* show [ip] bgp */ | |
6802 | if (argv_find (argv, argc, "ip", &idx)) | |
6803 | afi = AFI_IP; | |
6804 | /* [<view|vrf> WORD] */ | |
6805 | if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) | |
6806 | vrf = argv[++idx]->arg; | |
46f296b4 LB |
6807 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
6808 | if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) | |
ae19d7dd | 6809 | { |
46f296b4 | 6810 | argv_find_and_parse_safi (argv, argc, &idx, &safi); |
91d37724 QY |
6811 | } |
6812 | ||
ae19d7dd | 6813 | int uj = use_json (argc, argv); |
74ca3d33 DW |
6814 | |
6815 | return bgp_show_summary_vty (vty, vrf, afi, safi, uj); | |
718e3744 | 6816 | } |
6817 | ||
fd79ac91 | 6818 | const char * |
538621f2 | 6819 | afi_safi_print (afi_t afi, safi_t safi) |
6820 | { | |
6821 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
6822 | return "IPv4 Unicast"; | |
6823 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
6824 | return "IPv4 Multicast"; | |
6825 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
46f296b4 | 6826 | return "IPv4 VPN"; |
8b1fb8be | 6827 | else if (afi == AFI_IP && safi == SAFI_ENCAP) |
46f296b4 | 6828 | return "IPv4 Encap"; |
538621f2 | 6829 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
6830 | return "IPv6 Unicast"; | |
6831 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
6832 | return "IPv6 Multicast"; | |
945c8fe9 | 6833 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) |
46f296b4 | 6834 | return "IPv6 VPN"; |
8b1fb8be | 6835 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) |
46f296b4 | 6836 | return "IPv6 Encap"; |
3d6c0dfa PG |
6837 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) |
6838 | return "L2VPN EVPN"; | |
538621f2 | 6839 | else |
6840 | return "Unknown"; | |
6841 | } | |
6842 | ||
27162734 LB |
6843 | const char * |
6844 | afi_safi_json (afi_t afi, safi_t safi) | |
6845 | { | |
6846 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
6847 | return "IPv4Unicast"; | |
6848 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
6849 | return "IPv4Multicast"; | |
6850 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
6851 | return "IPv4VPN"; | |
6852 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
6853 | return "IPv4Encap"; | |
6854 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
6855 | return "IPv6Unicast"; | |
6856 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
6857 | return "IPv6Multicast"; | |
6858 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
6859 | return "IPv6VPN"; | |
6860 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
6861 | return "IPv6Encap"; | |
3d6c0dfa PG |
6862 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) |
6863 | return "L2VPN EVPN"; | |
27162734 LB |
6864 | else |
6865 | return "Unknown"; | |
6866 | } | |
6867 | ||
718e3744 | 6868 | /* Show BGP peer's information. */ |
6869 | enum show_type | |
6870 | { | |
6871 | show_all, | |
6872 | show_peer | |
6873 | }; | |
6874 | ||
94f2b392 | 6875 | static void |
856ca177 MS |
6876 | bgp_show_peer_afi_orf_cap (struct vty *vty, struct peer *p, afi_t afi, safi_t safi, |
6877 | u_int16_t adv_smcap, u_int16_t adv_rmcap, u_int16_t rcv_smcap, | |
6878 | u_int16_t rcv_rmcap, u_char use_json, json_object *json_pref) | |
718e3744 | 6879 | { |
6880 | /* Send-Mode */ | |
6881 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) | |
6882 | || CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
6883 | { | |
856ca177 MS |
6884 | if (use_json) |
6885 | { | |
6886 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
6887 | json_object_string_add(json_pref, "sendMode", "advertisedAndReceived"); | |
6888 | else if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)) | |
6889 | json_object_string_add(json_pref, "sendMode", "advertised"); | |
6890 | else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
6891 | json_object_string_add(json_pref, "sendMode", "received"); | |
6892 | } | |
6893 | else | |
6894 | { | |
6895 | vty_out (vty, " Send-mode: "); | |
6896 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)) | |
6897 | vty_out (vty, "advertised"); | |
6898 | if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
6899 | vty_out (vty, "%sreceived", | |
6900 | CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) ? | |
6901 | ", " : ""); | |
6902 | vty_out (vty, "%s", VTY_NEWLINE); | |
6903 | } | |
718e3744 | 6904 | } |
6905 | ||
6906 | /* Receive-Mode */ | |
6907 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) | |
6908 | || CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
6909 | { | |
856ca177 MS |
6910 | if (use_json) |
6911 | { | |
6912 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
6913 | json_object_string_add(json_pref, "recvMode", "advertisedAndReceived"); | |
6914 | else if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)) | |
6915 | json_object_string_add(json_pref, "recvMode", "advertised"); | |
6916 | else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
6917 | json_object_string_add(json_pref, "recvMode", "received"); | |
6918 | } | |
6919 | else | |
6920 | { | |
6921 | vty_out (vty, " Receive-mode: "); | |
6922 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)) | |
6923 | vty_out (vty, "advertised"); | |
6924 | if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
6925 | vty_out (vty, "%sreceived", | |
6926 | CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) ? | |
6927 | ", " : ""); | |
6928 | vty_out (vty, "%s", VTY_NEWLINE); | |
6929 | } | |
718e3744 | 6930 | } |
6931 | } | |
6932 | ||
94f2b392 | 6933 | static void |
856ca177 MS |
6934 | bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi, |
6935 | u_char use_json, json_object *json_neigh) | |
718e3744 | 6936 | { |
6937 | struct bgp_filter *filter; | |
3f9c7369 | 6938 | struct peer_af *paf; |
718e3744 | 6939 | char orf_pfx_name[BUFSIZ]; |
6940 | int orf_pfx_count; | |
856ca177 MS |
6941 | json_object *json_af = NULL; |
6942 | json_object *json_prefA = NULL; | |
6943 | json_object *json_prefB = NULL; | |
6944 | json_object *json_addr = NULL; | |
718e3744 | 6945 | |
856ca177 MS |
6946 | if (use_json) |
6947 | { | |
6948 | json_addr = json_object_new_object(); | |
6949 | json_af = json_object_new_object(); | |
856ca177 | 6950 | filter = &p->filter[afi][safi]; |
718e3744 | 6951 | |
c8560b44 | 6952 | if (peer_group_active(p)) |
856ca177 | 6953 | json_object_string_add(json_addr, "peerGroupMember", p->group->name); |
538621f2 | 6954 | |
856ca177 MS |
6955 | paf = peer_af_find(p, afi, safi); |
6956 | if (paf && PAF_SUBGRP(paf)) | |
6957 | { | |
6958 | json_object_int_add(json_addr, "updateGroupId", PAF_UPDGRP(paf)->id); | |
6959 | json_object_int_add(json_addr, "subGroupId", PAF_SUBGRP(paf)->id); | |
6960 | json_object_int_add(json_addr, "packetQueueLength", bpacket_queue_virtual_length(paf)); | |
6961 | } | |
6962 | ||
6963 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
6964 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
6965 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
6966 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)) | |
6967 | { | |
6968 | json_object_int_add(json_af, "orfType", ORF_TYPE_PREFIX); | |
b6df4090 | 6969 | json_prefA = json_object_new_object(); |
856ca177 MS |
6970 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, |
6971 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
6972 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
6973 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
6974 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, json_prefA); | |
6975 | json_object_object_add(json_af, "orfPrefixList", json_prefA); | |
6976 | } | |
6977 | ||
6978 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
6979 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
6980 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
6981 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
6982 | { | |
6983 | json_object_int_add(json_af, "orfOldType", ORF_TYPE_PREFIX_OLD); | |
b6df4090 | 6984 | json_prefB = json_object_new_object(); |
856ca177 MS |
6985 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, |
6986 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
6987 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
6988 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
6989 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, json_prefB); | |
6990 | json_object_object_add(json_af, "orfOldPrefixList", json_prefB); | |
6991 | } | |
6992 | ||
6993 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
6994 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
6995 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
6996 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
6997 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV) | |
6998 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
6999 | json_object_object_add(json_addr, "afDependentCap", json_af); | |
b6df4090 DS |
7000 | else |
7001 | json_object_free(json_af); | |
856ca177 MS |
7002 | |
7003 | sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
7004 | orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json); | |
7005 | ||
7006 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND) | |
7007 | || orf_pfx_count) | |
7008 | { | |
7009 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)) | |
7010 | json_object_boolean_true_add(json_neigh, "orfSent"); | |
7011 | if (orf_pfx_count) | |
7012 | json_object_int_add(json_addr, "orfRecvCounter", orf_pfx_count); | |
7013 | } | |
7014 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) | |
7015 | json_object_string_add(json_addr, "orfFirstUpdate", "deferredUntilORFOrRouteRefreshRecvd"); | |
7016 | ||
7017 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) | |
7018 | json_object_boolean_true_add(json_addr, "routeReflectorClient"); | |
7019 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
7020 | json_object_boolean_true_add(json_addr, "routeServerClient"); | |
7021 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
7022 | json_object_boolean_true_add(json_addr, "inboundSoftConfigPermit"); | |
7023 | ||
88b8ed8d DW |
7024 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) |
7025 | json_object_boolean_true_add(json_addr, "privateAsNumsAllReplacedInUpdatesToNbr"); | |
7026 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
856ca177 | 7027 | json_object_boolean_true_add(json_addr, "privateAsNumsReplacedInUpdatesToNbr"); |
88b8ed8d DW |
7028 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) |
7029 | json_object_boolean_true_add(json_addr, "privateAsNumsAllRemovedInUpdatesToNbr"); | |
856ca177 MS |
7030 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS)) |
7031 | json_object_boolean_true_add(json_addr, "privateAsNumsRemovedInUpdatesToNbr"); | |
7032 | ||
adbac85e DW |
7033 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS)) |
7034 | json_object_boolean_true_add(json_addr, "addpathTxAllPaths"); | |
7035 | ||
06370dac DW |
7036 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) |
7037 | json_object_boolean_true_add(json_addr, "addpathTxBestpathPerAS"); | |
7038 | ||
856ca177 MS |
7039 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) |
7040 | json_object_string_add(json_addr, "overrideASNsInOutboundUpdates", "ifAspathEqualRemoteAs"); | |
7041 | ||
7042 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) || | |
7043 | CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
7044 | json_object_boolean_true_add(json_addr, "routerAlwaysNextHop"); | |
7045 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED)) | |
7046 | json_object_boolean_true_add(json_addr, "unchangedAsPathPropogatedToNbr"); | |
7047 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)) | |
7048 | json_object_boolean_true_add(json_addr, "unchangedNextHopPropogatedToNbr"); | |
7049 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
7050 | json_object_boolean_true_add(json_addr, "unchangedMedPropogatedToNbr"); | |
718e3744 | 7051 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) |
856ca177 MS |
7052 | || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) |
7053 | { | |
7054 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
7055 | && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7056 | json_object_string_add(json_addr, "commAttriSentToNbr", "extendedAndStandard"); | |
7057 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7058 | json_object_string_add(json_addr, "commAttriSentToNbr", "extended"); | |
7059 | else | |
7060 | json_object_string_add(json_addr, "commAttriSentToNbr", "standard"); | |
7061 | } | |
7062 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) | |
7063 | { | |
7064 | if (p->default_rmap[afi][safi].name) | |
7065 | json_object_string_add(json_addr, "defaultRouteMap", p->default_rmap[afi][safi].name); | |
7066 | ||
7067 | if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
7068 | json_object_boolean_true_add(json_addr, "defaultSent"); | |
7069 | else | |
7070 | json_object_boolean_true_add(json_addr, "defaultNotSent"); | |
7071 | } | |
7072 | ||
7073 | if (filter->plist[FILTER_IN].name | |
7074 | || filter->dlist[FILTER_IN].name | |
7075 | || filter->aslist[FILTER_IN].name | |
7076 | || filter->map[RMAP_IN].name) | |
7077 | json_object_boolean_true_add(json_addr, "inboundPathPolicyConfig"); | |
7078 | if (filter->plist[FILTER_OUT].name | |
7079 | || filter->dlist[FILTER_OUT].name | |
7080 | || filter->aslist[FILTER_OUT].name | |
7081 | || filter->map[RMAP_OUT].name | |
7082 | || filter->usmap.name) | |
7083 | json_object_boolean_true_add(json_addr, "outboundPathPolicyConfig"); | |
856ca177 MS |
7084 | |
7085 | /* prefix-list */ | |
7086 | if (filter->plist[FILTER_IN].name) | |
7087 | json_object_string_add(json_addr, "incomingUpdatePrefixFilterList", filter->plist[FILTER_IN].name); | |
7088 | if (filter->plist[FILTER_OUT].name) | |
7089 | json_object_string_add(json_addr, "outgoingUpdatePrefixFilterList", filter->plist[FILTER_OUT].name); | |
7090 | ||
7091 | /* distribute-list */ | |
7092 | if (filter->dlist[FILTER_IN].name) | |
7093 | json_object_string_add(json_addr, "incomingUpdateNetworkFilterList", filter->dlist[FILTER_IN].name); | |
7094 | if (filter->dlist[FILTER_OUT].name) | |
7095 | json_object_string_add(json_addr, "outgoingUpdateNetworkFilterList", filter->dlist[FILTER_OUT].name); | |
7096 | ||
7097 | /* filter-list. */ | |
7098 | if (filter->aslist[FILTER_IN].name) | |
7099 | json_object_string_add(json_addr, "incomingUpdateAsPathFilterList", filter->aslist[FILTER_IN].name); | |
7100 | if (filter->aslist[FILTER_OUT].name) | |
7101 | json_object_string_add(json_addr, "outgoingUpdateAsPathFilterList", filter->aslist[FILTER_OUT].name); | |
7102 | ||
7103 | /* route-map. */ | |
7104 | if (filter->map[RMAP_IN].name) | |
7105 | json_object_string_add(json_addr, "routeMapForIncomingAdvertisements", filter->map[RMAP_IN].name); | |
7106 | if (filter->map[RMAP_OUT].name) | |
7107 | json_object_string_add(json_addr, "routeMapForOutgoingAdvertisements", filter->map[RMAP_OUT].name); | |
856ca177 MS |
7108 | |
7109 | /* unsuppress-map */ | |
7110 | if (filter->usmap.name) | |
7111 | json_object_string_add(json_addr, "selectiveUnsuppressRouteMap", filter->usmap.name); | |
7112 | ||
7113 | /* Receive prefix count */ | |
7114 | json_object_int_add(json_addr, "acceptedPrefixCounter", p->pcount[afi][safi]); | |
7115 | ||
7116 | /* Maximum prefix */ | |
7117 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) | |
7118 | { | |
7119 | json_object_int_add(json_addr, "prefixAllowedMax", p->pmax[afi][safi]); | |
7120 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) | |
7121 | json_object_boolean_true_add(json_addr, "prefixAllowedMaxWarning"); | |
7122 | json_object_int_add(json_addr, "prefixAllowedWarningThresh", p->pmax_threshold[afi][safi]); | |
7123 | if (p->pmax_restart[afi][safi]) | |
7124 | json_object_int_add(json_addr, "prefixAllowedRestartIntervalMsecs", p->pmax_restart[afi][safi] * 60000); | |
7125 | } | |
7126 | json_object_object_add(json_neigh, afi_safi_print (afi, safi), json_addr); | |
7127 | ||
7128 | } | |
7129 | else | |
7130 | { | |
7131 | filter = &p->filter[afi][safi]; | |
7132 | ||
7133 | vty_out (vty, " For address family: %s%s", afi_safi_print (afi, safi), | |
7134 | VTY_NEWLINE); | |
7135 | ||
c8560b44 | 7136 | if (peer_group_active(p)) |
856ca177 MS |
7137 | vty_out (vty, " %s peer-group member%s", p->group->name, VTY_NEWLINE); |
7138 | ||
7139 | paf = peer_af_find(p, afi, safi); | |
7140 | if (paf && PAF_SUBGRP(paf)) | |
7141 | { | |
7142 | vty_out (vty, " Update group %" PRIu64 ", subgroup %" PRIu64 "%s", | |
7143 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id, VTY_NEWLINE); | |
7144 | vty_out (vty, " Packet Queue length %d%s", | |
7145 | bpacket_queue_virtual_length(paf), VTY_NEWLINE); | |
7146 | } | |
718e3744 | 7147 | else |
856ca177 MS |
7148 | { |
7149 | vty_out(vty, " Not part of any update group%s", VTY_NEWLINE); | |
7150 | } | |
7151 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7152 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
7153 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7154 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7155 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV) | |
7156 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7157 | vty_out (vty, " AF-dependant capabilities:%s", VTY_NEWLINE); | |
7158 | ||
7159 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7160 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
7161 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7162 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)) | |
7163 | { | |
7164 | vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s", | |
7165 | ORF_TYPE_PREFIX, VTY_NEWLINE); | |
7166 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, | |
7167 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
7168 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7169 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
7170 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
7171 | } | |
7172 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7173 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7174 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7175 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7176 | { | |
7177 | vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s", | |
7178 | ORF_TYPE_PREFIX_OLD, VTY_NEWLINE); | |
7179 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, | |
7180 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
7181 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7182 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
7183 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
7184 | } | |
718e3744 | 7185 | |
856ca177 MS |
7186 | sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi); |
7187 | orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json); | |
718e3744 | 7188 | |
856ca177 MS |
7189 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND) |
7190 | || orf_pfx_count) | |
7191 | { | |
7192 | vty_out (vty, " Outbound Route Filter (ORF):"); | |
7193 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)) | |
7194 | vty_out (vty, " sent;"); | |
7195 | if (orf_pfx_count) | |
7196 | vty_out (vty, " received (%d entries)", orf_pfx_count); | |
7197 | vty_out (vty, "%s", VTY_NEWLINE); | |
7198 | } | |
7199 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) | |
7200 | vty_out (vty, " First update is deferred until ORF or ROUTE-REFRESH is received%s", VTY_NEWLINE); | |
7201 | ||
7202 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) | |
7203 | vty_out (vty, " Route-Reflector Client%s", VTY_NEWLINE); | |
7204 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
7205 | vty_out (vty, " Route-Server Client%s", VTY_NEWLINE); | |
7206 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
7207 | vty_out (vty, " Inbound soft reconfiguration allowed%s", VTY_NEWLINE); | |
7208 | ||
88b8ed8d DW |
7209 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) |
7210 | vty_out (vty, " Private AS numbers (all) replaced in updates to this neighbor%s", VTY_NEWLINE); | |
7211 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
856ca177 | 7212 | vty_out (vty, " Private AS numbers replaced in updates to this neighbor%s", VTY_NEWLINE); |
88b8ed8d DW |
7213 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) |
7214 | vty_out (vty, " Private AS numbers (all) removed in updates to this neighbor%s", VTY_NEWLINE); | |
856ca177 MS |
7215 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS)) |
7216 | vty_out (vty, " Private AS numbers removed in updates to this neighbor%s", VTY_NEWLINE); | |
7217 | ||
adbac85e DW |
7218 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS)) |
7219 | vty_out (vty, " Advertise all paths via addpath%s", VTY_NEWLINE); | |
7220 | ||
06370dac DW |
7221 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) |
7222 | vty_out (vty, " Advertise bestpath per AS via addpath%s", VTY_NEWLINE); | |
7223 | ||
856ca177 MS |
7224 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) |
7225 | vty_out (vty, " Override ASNs in outbound updates if aspath equals remote-as%s", VTY_NEWLINE); | |
7226 | ||
7227 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) || | |
7228 | CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
7229 | vty_out (vty, " NEXT_HOP is always this router%s", VTY_NEWLINE); | |
7230 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED)) | |
7231 | vty_out (vty, " AS_PATH is propagated unchanged to this neighbor%s", VTY_NEWLINE); | |
7232 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)) | |
7233 | vty_out (vty, " NEXT_HOP is propagated unchanged to this neighbor%s", VTY_NEWLINE); | |
7234 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
7235 | vty_out (vty, " MED is propagated unchanged to this neighbor%s", VTY_NEWLINE); | |
7236 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
57d187bc JS |
7237 | || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY) |
7238 | || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
856ca177 MS |
7239 | { |
7240 | vty_out (vty, " Community attribute sent to this neighbor"); | |
7241 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
57d187bc JS |
7242 | && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY) |
7243 | && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
7244 | vty_out (vty, "(all)%s", VTY_NEWLINE); | |
7245 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
7246 | vty_out (vty, "(large)%s", VTY_NEWLINE); | |
856ca177 MS |
7247 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) |
7248 | vty_out (vty, "(extended)%s", VTY_NEWLINE); | |
7249 | else | |
7250 | vty_out (vty, "(standard)%s", VTY_NEWLINE); | |
7251 | } | |
7252 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) | |
7253 | { | |
7254 | vty_out (vty, " Default information originate,"); | |
7255 | ||
7256 | if (p->default_rmap[afi][safi].name) | |
7257 | vty_out (vty, " default route-map %s%s,", | |
7258 | p->default_rmap[afi][safi].map ? "*" : "", | |
7259 | p->default_rmap[afi][safi].name); | |
7260 | if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
7261 | vty_out (vty, " default sent%s", VTY_NEWLINE); | |
7262 | else | |
7263 | vty_out (vty, " default not sent%s", VTY_NEWLINE); | |
7264 | } | |
718e3744 | 7265 | |
856ca177 MS |
7266 | if (filter->plist[FILTER_IN].name |
7267 | || filter->dlist[FILTER_IN].name | |
7268 | || filter->aslist[FILTER_IN].name | |
7269 | || filter->map[RMAP_IN].name) | |
7270 | vty_out (vty, " Inbound path policy configured%s", VTY_NEWLINE); | |
7271 | if (filter->plist[FILTER_OUT].name | |
7272 | || filter->dlist[FILTER_OUT].name | |
7273 | || filter->aslist[FILTER_OUT].name | |
7274 | || filter->map[RMAP_OUT].name | |
7275 | || filter->usmap.name) | |
7276 | vty_out (vty, " Outbound path policy configured%s", VTY_NEWLINE); | |
856ca177 MS |
7277 | |
7278 | /* prefix-list */ | |
7279 | if (filter->plist[FILTER_IN].name) | |
7280 | vty_out (vty, " Incoming update prefix filter list is %s%s%s", | |
7281 | filter->plist[FILTER_IN].plist ? "*" : "", | |
7282 | filter->plist[FILTER_IN].name, | |
7283 | VTY_NEWLINE); | |
7284 | if (filter->plist[FILTER_OUT].name) | |
7285 | vty_out (vty, " Outgoing update prefix filter list is %s%s%s", | |
7286 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
7287 | filter->plist[FILTER_OUT].name, | |
7288 | VTY_NEWLINE); | |
7289 | ||
7290 | /* distribute-list */ | |
7291 | if (filter->dlist[FILTER_IN].name) | |
7292 | vty_out (vty, " Incoming update network filter list is %s%s%s", | |
7293 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
7294 | filter->dlist[FILTER_IN].name, | |
7295 | VTY_NEWLINE); | |
7296 | if (filter->dlist[FILTER_OUT].name) | |
7297 | vty_out (vty, " Outgoing update network filter list is %s%s%s", | |
7298 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
7299 | filter->dlist[FILTER_OUT].name, | |
7300 | VTY_NEWLINE); | |
7301 | ||
7302 | /* filter-list. */ | |
7303 | if (filter->aslist[FILTER_IN].name) | |
7304 | vty_out (vty, " Incoming update AS path filter list is %s%s%s", | |
7305 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
7306 | filter->aslist[FILTER_IN].name, | |
7307 | VTY_NEWLINE); | |
7308 | if (filter->aslist[FILTER_OUT].name) | |
7309 | vty_out (vty, " Outgoing update AS path filter list is %s%s%s", | |
7310 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
7311 | filter->aslist[FILTER_OUT].name, | |
7312 | VTY_NEWLINE); | |
7313 | ||
7314 | /* route-map. */ | |
7315 | if (filter->map[RMAP_IN].name) | |
7316 | vty_out (vty, " Route map for incoming advertisements is %s%s%s", | |
7317 | filter->map[RMAP_IN].map ? "*" : "", | |
7318 | filter->map[RMAP_IN].name, | |
7319 | VTY_NEWLINE); | |
7320 | if (filter->map[RMAP_OUT].name) | |
7321 | vty_out (vty, " Route map for outgoing advertisements is %s%s%s", | |
7322 | filter->map[RMAP_OUT].map ? "*" : "", | |
7323 | filter->map[RMAP_OUT].name, | |
7324 | VTY_NEWLINE); | |
856ca177 MS |
7325 | |
7326 | /* unsuppress-map */ | |
7327 | if (filter->usmap.name) | |
7328 | vty_out (vty, " Route map for selective unsuppress is %s%s%s", | |
7329 | filter->usmap.map ? "*" : "", | |
7330 | filter->usmap.name, VTY_NEWLINE); | |
7331 | ||
7332 | /* Receive prefix count */ | |
7333 | vty_out (vty, " %ld accepted prefixes%s", p->pcount[afi][safi], VTY_NEWLINE); | |
7334 | ||
7335 | /* Maximum prefix */ | |
7336 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) | |
7337 | { | |
7338 | vty_out (vty, " Maximum prefixes allowed %ld%s%s", p->pmax[afi][safi], | |
7339 | CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING) | |
7340 | ? " (warning-only)" : "", VTY_NEWLINE); | |
7341 | vty_out (vty, " Threshold for warning message %d%%", | |
7342 | p->pmax_threshold[afi][safi]); | |
7343 | if (p->pmax_restart[afi][safi]) | |
7344 | vty_out (vty, ", restart interval %d min", p->pmax_restart[afi][safi]); | |
7345 | vty_out (vty, "%s", VTY_NEWLINE); | |
7346 | } | |
718e3744 | 7347 | |
0a486e5f | 7348 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 7349 | } |
718e3744 | 7350 | } |
7351 | ||
94f2b392 | 7352 | static void |
e8f7da3a | 7353 | bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *json) |
718e3744 | 7354 | { |
7355 | struct bgp *bgp; | |
4690c7d7 | 7356 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; |
718e3744 | 7357 | char timebuf[BGP_UPTIME_LEN]; |
f14e6fdb | 7358 | char dn_flag[2]; |
3a8c7ba1 DW |
7359 | const char *subcode_str; |
7360 | const char *code_str; | |
538621f2 | 7361 | afi_t afi; |
7362 | safi_t safi; | |
d6661008 DS |
7363 | u_int16_t i; |
7364 | u_char *msg; | |
e8f7da3a | 7365 | json_object *json_neigh = NULL; |
718e3744 | 7366 | |
7367 | bgp = p->bgp; | |
7368 | ||
e8f7da3a DW |
7369 | if (use_json) |
7370 | json_neigh = json_object_new_object(); | |
7371 | ||
517cd68a DS |
7372 | memset (dn_flag, '\0', sizeof (dn_flag)); |
7373 | if (!p->conf_if && peer_dynamic_neighbor (p)) | |
7374 | dn_flag[0] = '*'; | |
7375 | ||
856ca177 | 7376 | if (!use_json) |
f14e6fdb | 7377 | { |
856ca177 MS |
7378 | if (p->conf_if) /* Configured interface name. */ |
7379 | vty_out (vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
7380 | BGP_PEER_SU_UNSPEC(p) ? "None" : | |
7381 | sockunion2str (&p->su, buf, SU_ADDRSTRLEN)); | |
7382 | else /* Configured IP address. */ | |
74ef1672 | 7383 | vty_out (vty, "BGP neighbor is %s%s, ", dn_flag, p->host); |
f14e6fdb DS |
7384 | } |
7385 | ||
856ca177 MS |
7386 | if (use_json) |
7387 | { | |
7388 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
7389 | json_object_string_add(json_neigh, "bgpNeighborAddr", "none"); | |
7390 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
7391 | json_object_string_add(json_neigh, "bgpNeighborAddr", sockunion2str (&p->su, buf, SU_ADDRSTRLEN)); | |
7392 | ||
7393 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
7394 | ||
7395 | if (p->change_local_as) | |
7396 | json_object_int_add(json_neigh, "localAs", p->change_local_as); | |
7397 | else | |
7398 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
7399 | ||
7400 | if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
7401 | json_object_boolean_true_add(json_neigh, "localAsNoPrepend"); | |
66b199b2 | 7402 | |
856ca177 MS |
7403 | if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) |
7404 | json_object_boolean_true_add(json_neigh, "localAsReplaceAs"); | |
7405 | } | |
7406 | else | |
7407 | { | |
f8cfafda DS |
7408 | if ((p->as_type == AS_SPECIFIED) || |
7409 | (p->as_type == AS_EXTERNAL) || | |
7410 | (p->as_type == AS_INTERNAL)) | |
7411 | vty_out (vty, "remote AS %u, ", p->as); | |
7412 | else | |
7413 | vty_out (vty, "remote AS Unspecified, "); | |
856ca177 MS |
7414 | vty_out (vty, "local AS %u%s%s, ", |
7415 | p->change_local_as ? p->change_local_as : p->local_as, | |
7416 | CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ? | |
7417 | " no-prepend" : "", | |
7418 | CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) ? | |
7419 | " replace-as" : ""); | |
7420 | } | |
66b199b2 DS |
7421 | /* peer type internal, external, confed-internal or confed-external */ |
7422 | if (p->as == p->local_as) | |
7423 | { | |
856ca177 MS |
7424 | if (use_json) |
7425 | { | |
7426 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
7427 | json_object_boolean_true_add(json_neigh, "nbrConfedInternalLink"); | |
7428 | else | |
7429 | json_object_boolean_true_add(json_neigh, "nbrInternalLink"); | |
7430 | } | |
66b199b2 | 7431 | else |
856ca177 MS |
7432 | { |
7433 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
7434 | vty_out (vty, "confed-internal link%s", VTY_NEWLINE); | |
7435 | else | |
7436 | vty_out (vty, "internal link%s", VTY_NEWLINE); | |
7437 | } | |
66b199b2 DS |
7438 | } |
7439 | else | |
7440 | { | |
856ca177 MS |
7441 | if (use_json) |
7442 | { | |
7443 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
7444 | json_object_boolean_true_add(json_neigh, "nbrConfedExternalLink"); | |
7445 | else | |
7446 | json_object_boolean_true_add(json_neigh, "nbrExternalLink"); | |
7447 | } | |
66b199b2 | 7448 | else |
856ca177 MS |
7449 | { |
7450 | if (bgp_confederation_peers_check(bgp, p->as)) | |
7451 | vty_out (vty, "confed-external link%s", VTY_NEWLINE); | |
7452 | else | |
7453 | vty_out (vty, "external link%s", VTY_NEWLINE); | |
7454 | } | |
66b199b2 | 7455 | } |
718e3744 | 7456 | |
7457 | /* Description. */ | |
7458 | if (p->desc) | |
856ca177 MS |
7459 | { |
7460 | if (use_json) | |
7461 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
7462 | else | |
7463 | vty_out (vty, " Description: %s%s", p->desc, VTY_NEWLINE); | |
7464 | } | |
6410e93a | 7465 | |
04b6bdc0 DW |
7466 | if (p->hostname) |
7467 | { | |
d1570739 DW |
7468 | if (use_json) |
7469 | { | |
7470 | if (p->hostname) | |
7471 | json_object_string_add(json_neigh, "hostname", p->hostname); | |
7472 | ||
7473 | if (p->domainname) | |
7474 | json_object_string_add(json_neigh, "domainname", p->domainname); | |
7475 | } | |
04b6bdc0 | 7476 | else |
d1570739 DW |
7477 | { |
7478 | if (p->domainname && (p->domainname[0] != '\0')) | |
7479 | vty_out(vty, "Hostname: %s.%s%s", p->hostname, p->domainname, | |
7480 | VTY_NEWLINE); | |
7481 | else | |
7482 | vty_out(vty, "Hostname: %s%s", p->hostname, VTY_NEWLINE); | |
7483 | } | |
7484 | ||
04b6bdc0 DW |
7485 | } |
7486 | ||
c744aa9f | 7487 | /* Peer-group */ |
718e3744 | 7488 | if (p->group) |
f14e6fdb | 7489 | { |
856ca177 MS |
7490 | if (use_json) |
7491 | { | |
7492 | json_object_string_add(json_neigh, "peerGroup", p->group->name); | |
7493 | ||
7494 | if (dn_flag[0]) | |
7495 | { | |
40ee54a7 | 7496 | struct prefix prefix, *range = NULL; |
f14e6fdb | 7497 | |
40ee54a7 TT |
7498 | sockunion2hostprefix(&(p->su), &prefix); |
7499 | range = peer_group_lookup_dynamic_neighbor_range (p->group, &prefix); | |
856ca177 MS |
7500 | |
7501 | if (range) | |
7502 | { | |
7503 | prefix2str(range, buf1, sizeof(buf1)); | |
7504 | json_object_string_add(json_neigh, "peerSubnetRangeGroup", buf1); | |
7505 | } | |
7506 | } | |
7507 | } | |
7508 | else | |
f14e6fdb | 7509 | { |
856ca177 MS |
7510 | vty_out (vty, " Member of peer-group %s for session parameters%s", |
7511 | p->group->name, VTY_NEWLINE); | |
f14e6fdb | 7512 | |
856ca177 | 7513 | if (dn_flag[0]) |
f14e6fdb | 7514 | { |
40ee54a7 | 7515 | struct prefix prefix, *range = NULL; |
856ca177 | 7516 | |
40ee54a7 TT |
7517 | sockunion2hostprefix(&(p->su), &prefix); |
7518 | range = peer_group_lookup_dynamic_neighbor_range (p->group, &prefix); | |
856ca177 MS |
7519 | |
7520 | if (range) | |
7521 | { | |
7522 | prefix2str(range, buf1, sizeof(buf1)); | |
7523 | vty_out (vty, " Belongs to the subnet range group: %s%s", buf1, VTY_NEWLINE); | |
7524 | } | |
f14e6fdb DS |
7525 | } |
7526 | } | |
7527 | } | |
718e3744 | 7528 | |
856ca177 MS |
7529 | if (use_json) |
7530 | { | |
7531 | /* Administrative shutdown. */ | |
7532 | if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN)) | |
7533 | json_object_boolean_true_add(json_neigh, "adminShutDown"); | |
718e3744 | 7534 | |
856ca177 MS |
7535 | /* BGP Version. */ |
7536 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
389e3fe0 | 7537 | json_object_string_add(json_neigh, "remoteRouterId", |
44b8cd53 | 7538 | inet_ntop (AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
718e3744 | 7539 | |
856ca177 MS |
7540 | /* Confederation */ |
7541 | if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION) && bgp_confederation_peers_check (bgp, p->as)) | |
7542 | json_object_boolean_true_add(json_neigh, "nbrCommonAdmin"); | |
7543 | ||
7544 | /* Status. */ | |
7545 | json_object_string_add(json_neigh, "bgpState", LOOKUP (bgp_status_msg, p->status)); | |
7546 | ||
7547 | if (p->status == Established) | |
7548 | { | |
7549 | time_t uptime; | |
7550 | struct tm *tm; | |
7551 | ||
7552 | uptime = bgp_clock(); | |
7553 | uptime -= p->uptime; | |
7554 | tm = gmtime(&uptime); | |
7555 | ||
7556 | json_object_int_add(json_neigh, "bgpTimerUp", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); | |
7557 | } | |
7558 | ||
7559 | else if (p->status == Active) | |
7560 | { | |
7561 | if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE)) | |
7562 | json_object_string_add(json_neigh, "bgpStateIs", "passive"); | |
7563 | else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT)) | |
7564 | json_object_string_add(json_neigh, "bgpStateIs", "passiveNSF"); | |
7565 | } | |
7566 | ||
7567 | /* read timer */ | |
7568 | time_t uptime; | |
7569 | struct tm *tm; | |
7570 | ||
7571 | uptime = bgp_clock(); | |
7572 | uptime -= p->readtime; | |
7573 | tm = gmtime(&uptime); | |
7574 | json_object_int_add(json_neigh, "bgpTimerLastRead", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); | |
7575 | ||
7576 | uptime = bgp_clock(); | |
7577 | uptime -= p->last_write; | |
7578 | tm = gmtime(&uptime); | |
39e871e6 ST |
7579 | json_object_int_add(json_neigh, "bgpTimerLastWrite", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); |
7580 | ||
7581 | uptime = bgp_clock(); | |
7582 | uptime -= p->update_time; | |
7583 | tm = gmtime(&uptime); | |
7584 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", | |
7585 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); | |
856ca177 MS |
7586 | |
7587 | /* Configured timer values. */ | |
7588 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", p->v_holdtime * 1000); | |
7589 | json_object_int_add(json_neigh, "bgpTimerKeepAliveIntervalMsecs", p->v_keepalive * 1000); | |
7590 | ||
7591 | if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER)) | |
7592 | { | |
7593 | json_object_int_add(json_neigh, "bgpTimerConfiguredHoldTimeMsecs", p->holdtime * 1000); | |
7594 | json_object_int_add(json_neigh, "bgpTimerConfiguredKeepAliveIntervalMsecs", p->keepalive * 1000); | |
7595 | } | |
93406d87 | 7596 | } |
856ca177 MS |
7597 | else |
7598 | { | |
7599 | /* Administrative shutdown. */ | |
7600 | if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN)) | |
7601 | vty_out (vty, " Administratively shut down%s", VTY_NEWLINE); | |
7602 | ||
7603 | /* BGP Version. */ | |
7604 | vty_out (vty, " BGP version 4"); | |
389e3fe0 | 7605 | vty_out (vty, ", remote router ID %s%s", |
44b8cd53 | 7606 | inet_ntop (AF_INET, &p->remote_id, buf1, sizeof(buf1)), |
856ca177 MS |
7607 | VTY_NEWLINE); |
7608 | ||
7609 | /* Confederation */ | |
7610 | if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION) | |
7611 | && bgp_confederation_peers_check (bgp, p->as)) | |
7612 | vty_out (vty, " Neighbor under common administration%s", VTY_NEWLINE); | |
e52702f2 | 7613 | |
856ca177 MS |
7614 | /* Status. */ |
7615 | vty_out (vty, " BGP state = %s", LOOKUP (bgp_status_msg, p->status)); | |
718e3744 | 7616 | |
856ca177 MS |
7617 | if (p->status == Established) |
7618 | vty_out (vty, ", up for %8s", peer_uptime (p->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL)); | |
7619 | ||
7620 | else if (p->status == Active) | |
7621 | { | |
7622 | if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE)) | |
7623 | vty_out (vty, " (passive)"); | |
7624 | else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT)) | |
7625 | vty_out (vty, " (NSF passive)"); | |
7626 | } | |
7627 | vty_out (vty, "%s", VTY_NEWLINE); | |
93406d87 | 7628 | |
856ca177 MS |
7629 | /* read timer */ |
7630 | vty_out (vty, " Last read %s", peer_uptime (p->readtime, timebuf, BGP_UPTIME_LEN, 0, NULL)); | |
7631 | vty_out (vty, ", Last write %s%s", | |
7632 | peer_uptime (p->last_write, timebuf, BGP_UPTIME_LEN, 0, NULL), VTY_NEWLINE); | |
7633 | ||
7634 | /* Configured timer values. */ | |
7635 | vty_out (vty, " Hold time is %d, keepalive interval is %d seconds%s", | |
7636 | p->v_holdtime, p->v_keepalive, VTY_NEWLINE); | |
7637 | if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER)) | |
7638 | { | |
7639 | vty_out (vty, " Configured hold time is %d", p->holdtime); | |
7640 | vty_out (vty, ", keepalive interval is %d seconds%s", | |
7641 | p->keepalive, VTY_NEWLINE); | |
7642 | } | |
7643 | } | |
718e3744 | 7644 | /* Capability. */ |
e52702f2 | 7645 | if (p->status == Established) |
718e3744 | 7646 | { |
538621f2 | 7647 | if (p->cap |
718e3744 | 7648 | || p->afc_adv[AFI_IP][SAFI_UNICAST] |
7649 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
7650 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
7651 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
718e3744 | 7652 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] |
7653 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
7654 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
7655 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
945c8fe9 LB |
7656 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] |
7657 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
8b1fb8be LB |
7658 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] |
7659 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
8b1fb8be LB |
7660 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
7661 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
718e3744 | 7662 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
7663 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) | |
7664 | { | |
856ca177 MS |
7665 | if (use_json) |
7666 | { | |
7667 | json_object *json_cap = NULL; | |
7668 | ||
7669 | json_cap = json_object_new_object(); | |
7670 | ||
7671 | /* AS4 */ | |
7672 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV) | |
7673 | || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
7674 | { | |
7675 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) && CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)) | |
7676 | json_object_string_add(json_cap, "4byteAs", "advertisedAndReceived"); | |
7677 | else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
7678 | json_object_string_add(json_cap, "4byteAs", "advertised"); | |
7679 | else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)) | |
7680 | json_object_string_add(json_cap, "4byteAs", "received"); | |
7681 | } | |
7682 | ||
7683 | /* AddPath */ | |
7684 | if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV) | |
7685 | || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV)) | |
7686 | { | |
7687 | json_object *json_add = NULL; | |
7688 | const char *print_store; | |
718e3744 | 7689 | |
856ca177 | 7690 | json_add = json_object_new_object(); |
a82478b9 | 7691 | |
856ca177 MS |
7692 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) |
7693 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7694 | { | |
7695 | json_object *json_sub = NULL; | |
7696 | json_sub = json_object_new_object(); | |
7697 | print_store = afi_safi_print (afi, safi); | |
7698 | ||
7699 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) || | |
7700 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) | |
7701 | { | |
7702 | 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)) | |
7703 | json_object_boolean_true_add(json_sub, "txAdvertisedAndReceived"); | |
7704 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV)) | |
7705 | json_object_boolean_true_add(json_sub, "txAdvertised"); | |
7706 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) | |
7707 | json_object_boolean_true_add(json_sub, "txReceived"); | |
7708 | } | |
7709 | ||
7710 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) || | |
7711 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) | |
7712 | { | |
7713 | 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)) | |
7714 | json_object_boolean_true_add(json_sub, "rxAdvertisedAndReceived"); | |
7715 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV)) | |
7716 | json_object_boolean_true_add(json_sub, "rxAdvertised"); | |
7717 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) | |
7718 | json_object_boolean_true_add(json_sub, "rxReceived"); | |
7719 | } | |
7720 | ||
7721 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) || | |
7722 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV) || | |
7723 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) || | |
7724 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) | |
7725 | json_object_object_add(json_add, print_store, json_sub); | |
b6df4090 DS |
7726 | else |
7727 | json_object_free(json_sub); | |
856ca177 | 7728 | } |
a82478b9 | 7729 | |
856ca177 MS |
7730 | json_object_object_add(json_cap, "addPath", json_add); |
7731 | } | |
7732 | ||
7733 | /* Dynamic */ | |
7734 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV) | |
7735 | || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
7736 | { | |
7737 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) && CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)) | |
7738 | json_object_string_add(json_cap, "dynamic", "advertisedAndReceived"); | |
7739 | else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
7740 | json_object_string_add(json_cap, "dynamic", "advertised"); | |
7741 | else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)) | |
7742 | json_object_string_add(json_cap, "dynamic", "received"); | |
7743 | } | |
7744 | ||
7745 | /* Extended nexthop */ | |
7746 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV) | |
7747 | || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
7748 | { | |
7749 | json_object *json_nxt = NULL; | |
7750 | const char *print_store; | |
7751 | ||
856ca177 MS |
7752 | |
7753 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) && CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
7754 | json_object_string_add(json_cap, "extendedNexthop", "advertisedAndReceived"); | |
7755 | else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
7756 | json_object_string_add(json_cap, "extendedNexthop", "advertised"); | |
7757 | else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
7758 | json_object_string_add(json_cap, "extendedNexthop", "received"); | |
7759 | ||
7760 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
7761 | { | |
b6df4090 DS |
7762 | json_nxt = json_object_new_object(); |
7763 | ||
856ca177 MS |
7764 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) |
7765 | { | |
7766 | if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV)) | |
7767 | { | |
7768 | print_store = afi_safi_print (AFI_IP, safi); | |
7769 | json_object_string_add(json_nxt, print_store, "recieved"); | |
7770 | } | |
7771 | } | |
7772 | json_object_object_add(json_cap, "extendedNexthopFamililesByPeer", json_nxt); | |
7773 | } | |
7774 | } | |
7775 | ||
7776 | /* Route Refresh */ | |
7777 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) | |
7778 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) | |
7779 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
7780 | { | |
7781 | 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))) | |
7782 | { | |
7783 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) | |
7784 | json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOldNew"); | |
7785 | else | |
7786 | { | |
7787 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
7788 | json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOld"); | |
7789 | else | |
7790 | json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedNew"); | |
7791 | } | |
7792 | } | |
7793 | else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)) | |
7794 | json_object_string_add(json_cap, "routeRefresh", "advertised"); | |
7795 | else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
7796 | json_object_string_add(json_cap, "routeRefresh", "received"); | |
7797 | } | |
7798 | ||
7799 | /* Multiprotocol Extensions */ | |
7800 | json_object *json_multi = NULL; | |
7801 | json_multi = json_object_new_object(); | |
7802 | ||
7803 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7804 | { | |
7805 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7806 | { | |
7807 | if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi]) | |
7808 | { | |
7809 | json_object *json_exten = NULL; | |
7810 | json_exten = json_object_new_object(); | |
7811 | ||
7812 | if (p->afc_adv[afi][safi] && p->afc_recv[afi][safi]) | |
7813 | json_object_boolean_true_add(json_exten, "advertisedAndReceived"); | |
7814 | else if (p->afc_adv[afi][safi]) | |
7815 | json_object_boolean_true_add(json_exten, "advertised"); | |
7816 | else if (p->afc_recv[afi][safi]) | |
7817 | json_object_boolean_true_add(json_exten, "received"); | |
7818 | ||
7819 | json_object_object_add(json_multi, afi_safi_print (afi, safi), json_exten); | |
7820 | } | |
7821 | } | |
7822 | } | |
7823 | json_object_object_add(json_cap, "multiprotocolExtensions", json_multi); | |
7824 | ||
7825 | /* Gracefull Restart */ | |
7826 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV) | |
7827 | || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
7828 | { | |
7829 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) && CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) | |
7830 | json_object_string_add(json_cap, "gracefulRestart", "advertisedAndReceived"); | |
7831 | else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
7832 | json_object_string_add(json_cap, "gracefulRestartCapability", "advertised"); | |
7833 | else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) | |
7834 | json_object_string_add(json_cap, "gracefulRestartCapability", "received"); | |
7835 | ||
7836 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) | |
7837 | { | |
7838 | int restart_af_count = 0; | |
7839 | json_object *json_restart = NULL; | |
7840 | json_restart = json_object_new_object(); | |
7841 | ||
7842 | json_object_int_add(json_cap, "gracefulRestartRemoteTimerMsecs", p->v_gr_restart * 1000); | |
7843 | ||
7844 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7845 | { | |
7846 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7847 | { | |
7848 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV)) | |
7849 | { | |
7850 | json_object *json_sub = NULL; | |
7851 | json_sub = json_object_new_object(); | |
7852 | ||
7853 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV)) | |
7854 | json_object_boolean_true_add(json_sub, "preserved"); | |
7855 | restart_af_count++; | |
7856 | json_object_object_add(json_restart, afi_safi_print (afi, safi), json_sub); | |
7857 | } | |
7858 | } | |
7859 | } | |
7860 | if (! restart_af_count) | |
b6df4090 | 7861 | { |
856ca177 | 7862 | json_object_string_add(json_cap, "addressFamiliesByPeer", "none"); |
b6df4090 DS |
7863 | json_object_free(json_restart); |
7864 | } | |
856ca177 MS |
7865 | else |
7866 | json_object_object_add(json_cap, "addressFamiliesByPeer", json_restart); | |
7867 | } | |
7868 | } | |
7869 | json_object_object_add(json_neigh, "neighborCapabilities", json_cap); | |
7870 | } | |
7871 | else | |
7872 | { | |
7873 | vty_out (vty, " Neighbor capabilities:%s", VTY_NEWLINE); | |
7874 | ||
7875 | /* AS4 */ | |
7876 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV) | |
7877 | || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
7878 | { | |
7879 | vty_out (vty, " 4 Byte AS:"); | |
7880 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
7881 | vty_out (vty, " advertised"); | |
7882 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)) | |
7883 | vty_out (vty, " %sreceived", | |
7884 | CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) ? "and " : ""); | |
7885 | vty_out (vty, "%s", VTY_NEWLINE); | |
7886 | } | |
7887 | ||
7888 | /* AddPath */ | |
7889 | if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV) | |
7890 | || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV)) | |
7891 | { | |
7892 | vty_out (vty, " AddPath:%s", VTY_NEWLINE); | |
a82478b9 | 7893 | |
856ca177 MS |
7894 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) |
7895 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
a82478b9 | 7896 | { |
856ca177 MS |
7897 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) || |
7898 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) | |
7899 | { | |
7900 | vty_out (vty, " %s: TX ", afi_safi_print (afi, safi)); | |
a82478b9 | 7901 | |
856ca177 MS |
7902 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV)) |
7903 | vty_out (vty, "advertised %s", afi_safi_print (afi, safi)); | |
a82478b9 | 7904 | |
856ca177 MS |
7905 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) |
7906 | vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ? " and " : "" ); | |
a82478b9 | 7907 | |
856ca177 MS |
7908 | vty_out (vty, "%s", VTY_NEWLINE); |
7909 | } | |
a82478b9 | 7910 | |
856ca177 | 7911 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) || |
a82478b9 | 7912 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) |
856ca177 MS |
7913 | { |
7914 | vty_out (vty, " %s: RX ", afi_safi_print (afi, safi)); | |
a82478b9 | 7915 | |
856ca177 MS |
7916 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV)) |
7917 | vty_out (vty, "advertised %s", afi_safi_print (afi, safi)); | |
a82478b9 | 7918 | |
856ca177 MS |
7919 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) |
7920 | vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ? " and " : "" ); | |
a82478b9 | 7921 | |
856ca177 MS |
7922 | vty_out (vty, "%s", VTY_NEWLINE); |
7923 | } | |
a82478b9 | 7924 | } |
856ca177 | 7925 | } |
a82478b9 | 7926 | |
856ca177 MS |
7927 | /* Dynamic */ |
7928 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV) | |
7929 | || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
7930 | { | |
7931 | vty_out (vty, " Dynamic:"); | |
7932 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
7933 | vty_out (vty, " advertised"); | |
7934 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)) | |
7935 | vty_out (vty, " %sreceived", | |
7936 | CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) ? "and " : ""); | |
7937 | vty_out (vty, "%s", VTY_NEWLINE); | |
7938 | } | |
7939 | ||
7940 | /* Extended nexthop */ | |
7941 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV) | |
7942 | || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
7943 | { | |
7944 | vty_out (vty, " Extended nexthop:"); | |
7945 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
7946 | vty_out (vty, " advertised"); | |
7947 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
7948 | vty_out (vty, " %sreceived", | |
7949 | CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) ? "and " : ""); | |
7950 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 7951 | |
856ca177 MS |
7952 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) |
7953 | { | |
7954 | vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE); | |
7955 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7956 | if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV)) | |
7957 | vty_out (vty, " %s%s", | |
7958 | afi_safi_print (AFI_IP, safi), VTY_NEWLINE); | |
7959 | } | |
7960 | } | |
8a92a8a0 | 7961 | |
856ca177 MS |
7962 | /* Route Refresh */ |
7963 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) | |
7964 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) | |
7965 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
7966 | { | |
7967 | vty_out (vty, " Route refresh:"); | |
7968 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)) | |
7969 | vty_out (vty, " advertised"); | |
7970 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) | |
7971 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
7972 | vty_out (vty, " %sreceived(%s)", | |
7973 | CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) ? "and " : "", | |
7974 | (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) | |
7975 | && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) ? | |
7976 | "old & new" : CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) ? "old" : "new"); | |
8a92a8a0 | 7977 | |
856ca177 MS |
7978 | vty_out (vty, "%s", VTY_NEWLINE); |
7979 | } | |
718e3744 | 7980 | |
856ca177 MS |
7981 | /* Multiprotocol Extensions */ |
7982 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7983 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7984 | if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi]) | |
7985 | { | |
8c3deaae | 7986 | vty_out (vty, " Address Family %s:", afi_safi_print (afi, safi)); |
856ca177 MS |
7987 | if (p->afc_adv[afi][safi]) |
7988 | vty_out (vty, " advertised"); | |
7989 | if (p->afc_recv[afi][safi]) | |
7990 | vty_out (vty, " %sreceived", p->afc_adv[afi][safi] ? "and " : ""); | |
7991 | vty_out (vty, "%s", VTY_NEWLINE); | |
7992 | } | |
538621f2 | 7993 | |
04b6bdc0 DW |
7994 | /* Hostname capability */ |
7995 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV) || | |
7996 | CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) | |
7997 | { | |
7998 | vty_out (vty, " Hostname Capability:"); | |
7999 | if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV)) | |
8000 | vty_out (vty, " advertised"); | |
8001 | if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_RCV)) | |
8002 | vty_out (vty, " %sreceived", | |
8003 | CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV) ? "and " : ""); | |
8004 | vty_out (vty, "%s", VTY_NEWLINE); | |
8005 | } | |
8006 | ||
856ca177 MS |
8007 | /* Gracefull Restart */ |
8008 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV) | |
8009 | || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
8010 | { | |
8011 | vty_out (vty, " Graceful Restart Capabilty:"); | |
8012 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
538621f2 | 8013 | vty_out (vty, " advertised"); |
856ca177 MS |
8014 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) |
8015 | vty_out (vty, " %sreceived", | |
8016 | CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) ? "and " : ""); | |
8017 | vty_out (vty, "%s", VTY_NEWLINE); | |
538621f2 | 8018 | |
856ca177 MS |
8019 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) |
8020 | { | |
8021 | int restart_af_count = 0; | |
8022 | ||
8023 | vty_out (vty, " Remote Restart timer is %d seconds%s", | |
8024 | p->v_gr_restart, VTY_NEWLINE); | |
8025 | vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE); | |
8026 | ||
8027 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8028 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8029 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV)) | |
8030 | { | |
8031 | vty_out (vty, "%s%s(%s)", restart_af_count ? ", " : "", | |
8032 | afi_safi_print (afi, safi), | |
8033 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV) ? | |
8034 | "preserved" : "not preserved"); | |
8035 | restart_af_count++; | |
8036 | } | |
8037 | if (! restart_af_count) | |
8038 | vty_out (vty, "none"); | |
8039 | vty_out (vty, "%s", VTY_NEWLINE); | |
8040 | } | |
8041 | } | |
8042 | } | |
718e3744 | 8043 | } |
8044 | } | |
8045 | ||
93406d87 | 8046 | /* graceful restart information */ |
8047 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV) | |
8048 | || p->t_gr_restart | |
8049 | || p->t_gr_stale) | |
8050 | { | |
856ca177 MS |
8051 | json_object *json_grace = NULL; |
8052 | json_object *json_grace_send = NULL; | |
8053 | json_object *json_grace_recv = NULL; | |
93406d87 | 8054 | int eor_send_af_count = 0; |
8055 | int eor_receive_af_count = 0; | |
8056 | ||
856ca177 MS |
8057 | if (use_json) |
8058 | { | |
8059 | json_grace = json_object_new_object(); | |
8060 | json_grace_send = json_object_new_object(); | |
8061 | json_grace_recv = json_object_new_object(); | |
8062 | ||
8063 | if (p->status == Established) | |
8064 | { | |
8065 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8066 | { | |
8067 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8068 | { | |
8069 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND)) | |
8070 | { | |
8071 | json_object_boolean_true_add(json_grace_send, afi_safi_print (afi, safi)); | |
8072 | eor_send_af_count++; | |
8073 | } | |
8074 | } | |
8075 | } | |
8076 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8077 | { | |
8078 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8079 | { | |
8080 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED)) | |
8081 | { | |
8082 | json_object_boolean_true_add(json_grace_recv, afi_safi_print (afi, safi)); | |
8083 | eor_receive_af_count++; | |
8084 | } | |
8085 | } | |
8086 | } | |
8087 | } | |
8088 | ||
8089 | json_object_object_add(json_grace, "endOfRibSend", json_grace_send); | |
8090 | json_object_object_add(json_grace, "endOfRibRecv", json_grace_recv); | |
8091 | ||
8092 | if (p->t_gr_restart) | |
8093 | json_object_int_add(json_grace, "gracefulRestartTimerMsecs", thread_timer_remain_second (p->t_gr_restart) * 1000); | |
8094 | ||
8095 | if (p->t_gr_stale) | |
8096 | json_object_int_add(json_grace, "gracefulStalepathTimerMsecs", thread_timer_remain_second (p->t_gr_stale) * 1000); | |
8097 | ||
8098 | json_object_object_add(json_neigh, "gracefulRestartInfo", json_grace); | |
8099 | } | |
8100 | else | |
8101 | { | |
8102 | vty_out (vty, " Graceful restart informations:%s", VTY_NEWLINE); | |
8103 | if (p->status == Established) | |
8104 | { | |
8105 | vty_out (vty, " End-of-RIB send: "); | |
8106 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8107 | { | |
8108 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8109 | { | |
8110 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND)) | |
8111 | { | |
8112 | vty_out (vty, "%s%s", eor_send_af_count ? ", " : "", | |
8113 | afi_safi_print (afi, safi)); | |
8114 | eor_send_af_count++; | |
8115 | } | |
8116 | } | |
8117 | } | |
8118 | vty_out (vty, "%s", VTY_NEWLINE); | |
8119 | vty_out (vty, " End-of-RIB received: "); | |
8120 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8121 | { | |
8122 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8123 | { | |
8124 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED)) | |
8125 | { | |
8126 | vty_out (vty, "%s%s", eor_receive_af_count ? ", " : "", | |
8127 | afi_safi_print (afi, safi)); | |
8128 | eor_receive_af_count++; | |
8129 | } | |
8130 | } | |
8131 | } | |
8132 | vty_out (vty, "%s", VTY_NEWLINE); | |
8133 | } | |
93406d87 | 8134 | |
856ca177 MS |
8135 | if (p->t_gr_restart) |
8136 | vty_out (vty, " The remaining time of restart timer is %ld%s", | |
8137 | thread_timer_remain_second (p->t_gr_restart), VTY_NEWLINE); | |
e52702f2 | 8138 | |
856ca177 MS |
8139 | if (p->t_gr_stale) |
8140 | vty_out (vty, " The remaining time of stalepath timer is %ld%s", | |
8141 | thread_timer_remain_second (p->t_gr_stale), VTY_NEWLINE); | |
8142 | } | |
8143 | } | |
8144 | if (use_json) | |
8145 | { | |
8146 | json_object *json_stat = NULL; | |
8147 | json_stat = json_object_new_object(); | |
8148 | /* Packet counts. */ | |
8149 | json_object_int_add(json_stat, "depthInq", 0); | |
8150 | json_object_int_add(json_stat, "depthOutq", (unsigned long) p->obuf->count); | |
8151 | json_object_int_add(json_stat, "opensSent", p->open_out); | |
8152 | json_object_int_add(json_stat, "opensRecv", p->open_in); | |
8153 | json_object_int_add(json_stat, "notificationsSent", p->notify_out); | |
8154 | json_object_int_add(json_stat, "notificationsRecv", p->notify_in); | |
8155 | json_object_int_add(json_stat, "updatesSent", p->update_out); | |
8156 | json_object_int_add(json_stat, "updatesRecv", p->update_in); | |
8157 | json_object_int_add(json_stat, "keepalivesSent", p->keepalive_out); | |
8158 | json_object_int_add(json_stat, "keepalivesRecv", p->keepalive_in); | |
8159 | json_object_int_add(json_stat, "routeRefreshSent", p->refresh_out); | |
8160 | json_object_int_add(json_stat, "routeRefreshRecv", p->refresh_in); | |
8161 | json_object_int_add(json_stat, "capabilitySent", p->dynamic_cap_out); | |
8162 | json_object_int_add(json_stat, "capabilityRecv", p->dynamic_cap_in); | |
8163 | 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); | |
8164 | 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); | |
8165 | json_object_object_add(json_neigh, "messageStats", json_stat); | |
8166 | } | |
8167 | else | |
8168 | { | |
8169 | /* Packet counts. */ | |
8170 | vty_out (vty, " Message statistics:%s", VTY_NEWLINE); | |
8171 | vty_out (vty, " Inq depth is 0%s", VTY_NEWLINE); | |
8172 | vty_out (vty, " Outq depth is %lu%s", (unsigned long) p->obuf->count, VTY_NEWLINE); | |
8173 | vty_out (vty, " Sent Rcvd%s", VTY_NEWLINE); | |
8174 | vty_out (vty, " Opens: %10d %10d%s", p->open_out, p->open_in, VTY_NEWLINE); | |
8175 | vty_out (vty, " Notifications: %10d %10d%s", p->notify_out, p->notify_in, VTY_NEWLINE); | |
8176 | vty_out (vty, " Updates: %10d %10d%s", p->update_out, p->update_in, VTY_NEWLINE); | |
8177 | vty_out (vty, " Keepalives: %10d %10d%s", p->keepalive_out, p->keepalive_in, VTY_NEWLINE); | |
8178 | vty_out (vty, " Route Refresh: %10d %10d%s", p->refresh_out, p->refresh_in, VTY_NEWLINE); | |
8179 | vty_out (vty, " Capability: %10d %10d%s", p->dynamic_cap_out, p->dynamic_cap_in, VTY_NEWLINE); | |
8180 | vty_out (vty, " Total: %10d %10d%s", p->open_out + p->notify_out + | |
8181 | p->update_out + p->keepalive_out + p->refresh_out + p->dynamic_cap_out, | |
8182 | p->open_in + p->notify_in + p->update_in + p->keepalive_in + p->refresh_in + | |
8183 | p->dynamic_cap_in, VTY_NEWLINE); | |
718e3744 | 8184 | } |
8185 | ||
856ca177 MS |
8186 | if (use_json) |
8187 | { | |
8188 | /* advertisement-interval */ | |
8189 | json_object_int_add(json_neigh, "minBtwnAdvertisementRunsTimerMsecs", p->v_routeadv * 1000); | |
718e3744 | 8190 | |
856ca177 MS |
8191 | /* Update-source. */ |
8192 | if (p->update_if || p->update_source) | |
8193 | { | |
8194 | if (p->update_if) | |
8195 | json_object_string_add(json_neigh, "updateSource", p->update_if); | |
8196 | else if (p->update_source) | |
8197 | json_object_string_add(json_neigh, "updateSource", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN)); | |
8198 | } | |
856ca177 MS |
8199 | } |
8200 | else | |
8201 | { | |
8202 | /* advertisement-interval */ | |
8203 | vty_out (vty, " Minimum time between advertisement runs is %d seconds%s", | |
8204 | p->v_routeadv, VTY_NEWLINE); | |
8205 | ||
8206 | /* Update-source. */ | |
8207 | if (p->update_if || p->update_source) | |
8208 | { | |
8209 | vty_out (vty, " Update source is "); | |
8210 | if (p->update_if) | |
8211 | vty_out (vty, "%s", p->update_if); | |
8212 | else if (p->update_source) | |
8213 | vty_out (vty, "%s", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN)); | |
8214 | vty_out (vty, "%s", VTY_NEWLINE); | |
8215 | } | |
8216 | ||
856ca177 MS |
8217 | vty_out (vty, "%s", VTY_NEWLINE); |
8218 | } | |
718e3744 | 8219 | |
8220 | /* Address Family Information */ | |
856ca177 MS |
8221 | json_object *json_hold = NULL; |
8222 | ||
8223 | if (use_json) | |
8224 | json_hold = json_object_new_object(); | |
8225 | ||
538621f2 | 8226 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) |
8227 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8228 | if (p->afc[afi][safi]) | |
856ca177 | 8229 | bgp_show_peer_afi (vty, p, afi, safi, use_json, json_hold); |
718e3744 | 8230 | |
856ca177 MS |
8231 | if (use_json) |
8232 | { | |
58433ae6 | 8233 | json_object_object_add(json_neigh, "addressFamilyInfo", json_hold); |
e08ac8b7 DW |
8234 | json_object_int_add(json_neigh, "connectionsEstablished", p->established); |
8235 | json_object_int_add(json_neigh, "connectionsDropped", p->dropped); | |
856ca177 MS |
8236 | } |
8237 | else | |
8238 | vty_out (vty, " Connections established %d; dropped %d%s", p->established, p->dropped, | |
8239 | VTY_NEWLINE); | |
718e3744 | 8240 | |
d6661008 | 8241 | if (! p->last_reset) |
856ca177 MS |
8242 | { |
8243 | if (use_json) | |
e08ac8b7 | 8244 | json_object_string_add(json_neigh, "lastReset", "never"); |
856ca177 MS |
8245 | else |
8246 | vty_out (vty, " Last reset never%s", VTY_NEWLINE); | |
8247 | } | |
e0701b79 | 8248 | else |
d6661008 | 8249 | { |
856ca177 MS |
8250 | if (use_json) |
8251 | { | |
8252 | time_t uptime; | |
8253 | struct tm *tm; | |
8254 | ||
8255 | uptime = bgp_clock(); | |
8256 | uptime -= p->resettime; | |
8257 | tm = gmtime(&uptime); | |
e08ac8b7 DW |
8258 | json_object_int_add(json_neigh, "lastResetTimerMsecs", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); |
8259 | json_object_string_add(json_neigh, "lastResetDueTo", peer_down_str[(int) p->last_reset]); | |
cca1dda8 DD |
8260 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND || |
8261 | p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) | |
856ca177 | 8262 | { |
39e871e6 | 8263 | char errorcodesubcode_hexstr[5]; |
cca1dda8 DD |
8264 | char errorcodesubcode_str[256]; |
8265 | ||
8266 | code_str = bgp_notify_code_str(p->notify.code); | |
8267 | subcode_str = bgp_notify_subcode_str(p->notify.code, p->notify.subcode); | |
8268 | ||
39e871e6 | 8269 | sprintf(errorcodesubcode_hexstr, "%02X%02X", p->notify.code, p->notify.subcode); |
e08ac8b7 | 8270 | json_object_string_add(json_neigh, "lastErrorCodeSubcode", errorcodesubcode_hexstr); |
cca1dda8 DD |
8271 | snprintf(errorcodesubcode_str, 255, "%s%s", code_str, subcode_str); |
8272 | json_object_string_add(json_neigh, "lastNotificationReason", errorcodesubcode_str); | |
856ca177 MS |
8273 | } |
8274 | } | |
8275 | else | |
d6661008 | 8276 | { |
3a8c7ba1 DW |
8277 | vty_out (vty, " Last reset %s, ", |
8278 | peer_uptime (p->resettime, timebuf, BGP_UPTIME_LEN, 0, NULL)); | |
8279 | ||
8280 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND || | |
8281 | p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) | |
8282 | { | |
8283 | code_str = bgp_notify_code_str(p->notify.code); | |
8284 | subcode_str = bgp_notify_subcode_str(p->notify.code, p->notify.subcode); | |
8285 | vty_out (vty, "due to NOTIFICATION %s (%s%s)%s", | |
8286 | p->last_reset == PEER_DOWN_NOTIFY_SEND ? "sent" : "received", | |
8287 | code_str, subcode_str, VTY_NEWLINE); | |
8288 | } | |
8289 | else | |
8290 | { | |
8291 | vty_out (vty, "due to %s%s", | |
8292 | peer_down_str[(int) p->last_reset], VTY_NEWLINE); | |
8293 | } | |
856ca177 MS |
8294 | |
8295 | if (p->last_reset_cause_size) | |
d6661008 | 8296 | { |
856ca177 MS |
8297 | msg = p->last_reset_cause; |
8298 | vty_out(vty, " Message received that caused BGP to send a NOTIFICATION:%s ", VTY_NEWLINE); | |
8299 | for (i = 1; i <= p->last_reset_cause_size; i++) | |
8300 | { | |
8301 | vty_out(vty, "%02X", *msg++); | |
d6661008 | 8302 | |
856ca177 MS |
8303 | if (i != p->last_reset_cause_size) |
8304 | { | |
8305 | if (i % 16 == 0) | |
8306 | { | |
8307 | vty_out(vty, "%s ", VTY_NEWLINE); | |
8308 | } | |
8309 | else if (i % 4 == 0) | |
8310 | { | |
8311 | vty_out(vty, " "); | |
8312 | } | |
8313 | } | |
8314 | } | |
8315 | vty_out(vty, "%s", VTY_NEWLINE); | |
d6661008 | 8316 | } |
d6661008 DS |
8317 | } |
8318 | } | |
848973c7 | 8319 | |
718e3744 | 8320 | if (CHECK_FLAG (p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) |
8321 | { | |
856ca177 | 8322 | if (use_json) |
e08ac8b7 | 8323 | json_object_boolean_true_add(json_neigh, "prefixesConfigExceedMax"); |
856ca177 MS |
8324 | else |
8325 | vty_out (vty, " Peer had exceeded the max. no. of prefixes configured.%s", VTY_NEWLINE); | |
0a486e5f | 8326 | |
8327 | if (p->t_pmax_restart) | |
856ca177 MS |
8328 | { |
8329 | if (use_json) | |
8330 | { | |
e08ac8b7 DW |
8331 | json_object_boolean_true_add(json_neigh, "reducePrefixNumFrom"); |
8332 | json_object_int_add(json_neigh, "restartInTimerMsec", thread_timer_remain_second (p->t_pmax_restart) * 1000); | |
856ca177 MS |
8333 | } |
8334 | else | |
8335 | vty_out (vty, " Reduce the no. of prefix from %s, will restart in %ld seconds%s", | |
8336 | p->host, thread_timer_remain_second (p->t_pmax_restart), | |
8337 | VTY_NEWLINE); | |
8338 | } | |
0a486e5f | 8339 | else |
856ca177 MS |
8340 | { |
8341 | if (use_json) | |
e08ac8b7 | 8342 | json_object_boolean_true_add(json_neigh, "reducePrefixNumAndClearIpBgp"); |
856ca177 MS |
8343 | else |
8344 | vty_out (vty, " Reduce the no. of prefix and clear ip bgp %s to restore peering%s", | |
8345 | p->host, VTY_NEWLINE); | |
8346 | } | |
718e3744 | 8347 | } |
8348 | ||
f5a4827d | 8349 | /* EBGP Multihop and GTSM */ |
6d85b15b | 8350 | if (p->sort != BGP_PEER_IBGP) |
f5a4827d | 8351 | { |
856ca177 MS |
8352 | if (use_json) |
8353 | { | |
8354 | if (p->gtsm_hops > 0) | |
8355 | json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->gtsm_hops); | |
8356 | else if (p->ttl > 1) | |
8357 | json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->ttl); | |
8358 | } | |
8359 | else | |
8360 | { | |
8361 | if (p->gtsm_hops > 0) | |
8362 | vty_out (vty, " External BGP neighbor may be up to %d hops away.%s", | |
8363 | p->gtsm_hops, VTY_NEWLINE); | |
8364 | else if (p->ttl > 1) | |
8365 | vty_out (vty, " External BGP neighbor may be up to %d hops away.%s", | |
8366 | p->ttl, VTY_NEWLINE); | |
8367 | } | |
f5a4827d | 8368 | } |
5d804b43 PM |
8369 | else |
8370 | { | |
8371 | if (p->gtsm_hops > 0) | |
856ca177 MS |
8372 | { |
8373 | if (use_json) | |
8374 | json_object_int_add(json_neigh, "internalBgpNbrMaxHopsAway", p->gtsm_hops); | |
8375 | else | |
8376 | vty_out (vty, " Internal BGP neighbor may be up to %d hops away.%s", | |
8377 | p->gtsm_hops, VTY_NEWLINE); | |
8378 | } | |
5d804b43 | 8379 | } |
718e3744 | 8380 | |
8381 | /* Local address. */ | |
8382 | if (p->su_local) | |
8383 | { | |
856ca177 MS |
8384 | if (use_json) |
8385 | { | |
8386 | json_object_string_add(json_neigh, "hostLocal", sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN)); | |
8387 | json_object_int_add(json_neigh, "portLocal", ntohs (p->su_local->sin.sin_port)); | |
8388 | } | |
8389 | else | |
8390 | vty_out (vty, "Local host: %s, Local port: %d%s", | |
8391 | sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN), | |
8392 | ntohs (p->su_local->sin.sin_port), | |
8393 | VTY_NEWLINE); | |
718e3744 | 8394 | } |
e52702f2 | 8395 | |
718e3744 | 8396 | /* Remote address. */ |
8397 | if (p->su_remote) | |
8398 | { | |
856ca177 MS |
8399 | if (use_json) |
8400 | { | |
8401 | json_object_string_add(json_neigh, "hostForeign", sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN)); | |
8402 | json_object_int_add(json_neigh, "portForeign", ntohs (p->su_remote->sin.sin_port)); | |
8403 | } | |
8404 | else | |
8405 | vty_out (vty, "Foreign host: %s, Foreign port: %d%s", | |
718e3744 | 8406 | sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN), |
8407 | ntohs (p->su_remote->sin.sin_port), | |
8408 | VTY_NEWLINE); | |
8409 | } | |
8410 | ||
8411 | /* Nexthop display. */ | |
8412 | if (p->su_local) | |
8413 | { | |
856ca177 MS |
8414 | if (use_json) |
8415 | { | |
389e3fe0 | 8416 | json_object_string_add(json_neigh, "nexthop", |
44b8cd53 | 8417 | inet_ntop (AF_INET, &p->nexthop.v4, buf1, sizeof(buf1))); |
389e3fe0 | 8418 | json_object_string_add(json_neigh, "nexthopGlobal", |
44b8cd53 | 8419 | inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, sizeof(buf1))); |
389e3fe0 | 8420 | json_object_string_add(json_neigh, "nexthopLocal", |
44b8cd53 | 8421 | inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, sizeof(buf1))); |
856ca177 MS |
8422 | if (p->shared_network) |
8423 | json_object_string_add(json_neigh, "bgpConnection", "sharedNetwork"); | |
8424 | else | |
8425 | json_object_string_add(json_neigh, "bgpConnection", "nonSharedNetwork"); | |
856ca177 MS |
8426 | } |
8427 | else | |
8428 | { | |
8429 | vty_out (vty, "Nexthop: %s%s", | |
44b8cd53 DL |
8430 | inet_ntop (AF_INET, &p->nexthop.v4, buf1, sizeof(buf1)), |
8431 | VTY_NEWLINE); | |
856ca177 | 8432 | vty_out (vty, "Nexthop global: %s%s", |
44b8cd53 DL |
8433 | inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, sizeof(buf1)), |
8434 | VTY_NEWLINE); | |
856ca177 | 8435 | vty_out (vty, "Nexthop local: %s%s", |
44b8cd53 DL |
8436 | inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, sizeof(buf1)), |
8437 | VTY_NEWLINE); | |
856ca177 | 8438 | vty_out (vty, "BGP connection: %s%s", |
44b8cd53 DL |
8439 | p->shared_network ? "shared network" : "non shared network", |
8440 | VTY_NEWLINE); | |
856ca177 | 8441 | } |
718e3744 | 8442 | } |
8443 | ||
8444 | /* Timer information. */ | |
856ca177 MS |
8445 | if (use_json) |
8446 | { | |
39e871e6 | 8447 | json_object_int_add(json_neigh, "connectRetryTimer", p->v_connect); |
dd9275d6 ST |
8448 | if (p->status == Established && p->rtt) |
8449 | json_object_int_add(json_neigh, "estimatedRttInMsecs", p->rtt); | |
856ca177 MS |
8450 | if (p->t_start) |
8451 | json_object_int_add(json_neigh, "nextStartTimerDueInMsecs", thread_timer_remain_second (p->t_start) * 1000); | |
8452 | if (p->t_connect) | |
8453 | json_object_int_add(json_neigh, "nextConnectTimerDueInMsecs", thread_timer_remain_second (p->t_connect) * 1000); | |
8454 | if (p->t_routeadv) | |
8455 | { | |
8456 | json_object_int_add(json_neigh, "mraiInterval", p->v_routeadv); | |
8457 | json_object_int_add(json_neigh, "mraiTimerExpireInMsecs", thread_timer_remain_second (p->t_routeadv) * 1000); | |
8458 | } | |
cb1faec9 | 8459 | |
856ca177 MS |
8460 | if (p->t_read) |
8461 | json_object_string_add(json_neigh, "readThread", "on"); | |
8462 | else | |
8463 | json_object_string_add(json_neigh, "readThread", "off"); | |
8464 | if (p->t_write) | |
8465 | json_object_string_add(json_neigh, "writeThread", "on"); | |
8466 | else | |
8467 | json_object_string_add(json_neigh, "writeThread", "off"); | |
8468 | } | |
8469 | else | |
8470 | { | |
39e871e6 ST |
8471 | vty_out (vty, "BGP Connect Retry Timer in Seconds: %d%s", |
8472 | p->v_connect, VTY_NEWLINE); | |
dd9275d6 ST |
8473 | if (p->status == Established && p->rtt) |
8474 | vty_out (vty, "Estimated round trip time: %d ms%s", | |
8475 | p->rtt, VTY_NEWLINE); | |
856ca177 MS |
8476 | if (p->t_start) |
8477 | vty_out (vty, "Next start timer due in %ld seconds%s", | |
8478 | thread_timer_remain_second (p->t_start), VTY_NEWLINE); | |
8479 | if (p->t_connect) | |
8480 | vty_out (vty, "Next connect timer due in %ld seconds%s", | |
8481 | thread_timer_remain_second (p->t_connect), VTY_NEWLINE); | |
8482 | if (p->t_routeadv) | |
8483 | vty_out (vty, "MRAI (interval %u) timer expires in %ld seconds%s", | |
8484 | p->v_routeadv, thread_timer_remain_second (p->t_routeadv), | |
8485 | VTY_NEWLINE); | |
8486 | ||
8487 | vty_out (vty, "Read thread: %s Write thread: %s%s", | |
8488 | p->t_read ? "on" : "off", | |
8489 | p->t_write ? "on" : "off", | |
8490 | VTY_NEWLINE); | |
8491 | } | |
718e3744 | 8492 | |
8493 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
8494 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
856ca177 MS |
8495 | bgp_capability_vty_out (vty, p, use_json, json_neigh); |
8496 | ||
8497 | if (!use_json) | |
8498 | vty_out (vty, "%s", VTY_NEWLINE); | |
c43ed2e4 DS |
8499 | |
8500 | /* BFD information. */ | |
856ca177 MS |
8501 | bgp_bfd_show_info(vty, p, use_json, json_neigh); |
8502 | ||
8503 | if (use_json) | |
8504 | { | |
8505 | if (p->conf_if) /* Configured interface name. */ | |
8506 | json_object_object_add(json, p->conf_if, json_neigh); | |
8507 | else /* Configured IP address. */ | |
8508 | json_object_object_add(json, p->host, json_neigh); | |
8509 | } | |
718e3744 | 8510 | } |
8511 | ||
94f2b392 | 8512 | static int |
856ca177 MS |
8513 | bgp_show_neighbor (struct vty *vty, struct bgp *bgp, enum show_type type, |
8514 | union sockunion *su, const char *conf_if, u_char use_json, json_object *json) | |
718e3744 | 8515 | { |
1eb8ef25 | 8516 | struct listnode *node, *nnode; |
718e3744 | 8517 | struct peer *peer; |
8518 | int find = 0; | |
8519 | ||
1eb8ef25 | 8520 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
718e3744 | 8521 | { |
1ff9a340 DS |
8522 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
8523 | continue; | |
8524 | ||
718e3744 | 8525 | switch (type) |
856ca177 MS |
8526 | { |
8527 | case show_all: | |
e8f7da3a | 8528 | bgp_show_peer (vty, peer, use_json, json); |
856ca177 MS |
8529 | break; |
8530 | case show_peer: | |
8531 | if (conf_if) | |
8532 | { | |
4873b3b9 DW |
8533 | if ((peer->conf_if && !strcmp(peer->conf_if, conf_if)) || |
8534 | (peer->hostname && !strcmp(peer->hostname, conf_if))) | |
856ca177 MS |
8535 | { |
8536 | find = 1; | |
e8f7da3a | 8537 | bgp_show_peer (vty, peer, use_json, json); |
856ca177 MS |
8538 | } |
8539 | } | |
8540 | else | |
8541 | { | |
8542 | if (sockunion_same (&peer->su, su)) | |
8543 | { | |
8544 | find = 1; | |
e8f7da3a | 8545 | bgp_show_peer (vty, peer, use_json, json); |
856ca177 MS |
8546 | } |
8547 | } | |
8548 | break; | |
718e3744 | 8549 | } |
8550 | } | |
8551 | ||
8552 | if (type == show_peer && ! find) | |
856ca177 MS |
8553 | { |
8554 | if (use_json) | |
8555 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
8556 | else | |
8557 | vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE); | |
8558 | } | |
8559 | ||
8560 | if (use_json) | |
8561 | { | |
2aac5767 | 8562 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
856ca177 MS |
8563 | json_object_free(json); |
8564 | } | |
8565 | else | |
8566 | { | |
8567 | vty_out (vty, "%s", VTY_NEWLINE); | |
8568 | } | |
8569 | ||
718e3744 | 8570 | return CMD_SUCCESS; |
8571 | } | |
8572 | ||
f186de26 | 8573 | static void |
8574 | bgp_show_all_instances_neighbors_vty (struct vty *vty, u_char use_json) | |
8575 | { | |
8576 | struct listnode *node, *nnode; | |
8577 | struct bgp *bgp; | |
8578 | json_object *json = NULL; | |
9f689658 DD |
8579 | int is_first = 1; |
8580 | ||
8581 | if (use_json) | |
8582 | vty_out (vty, "{%s", VTY_NEWLINE); | |
f186de26 | 8583 | |
8584 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) | |
8585 | { | |
f186de26 | 8586 | if (use_json) |
9f689658 DD |
8587 | { |
8588 | if (!(json = json_object_new_object())) | |
8589 | { | |
8590 | zlog_err("Unable to allocate memory for JSON object"); | |
8591 | vty_out (vty, | |
8592 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}%s", | |
8593 | VTY_NEWLINE); | |
8594 | return; | |
8595 | } | |
8596 | ||
8597 | json_object_int_add(json, "vrfId", | |
8598 | (bgp->vrf_id == VRF_UNKNOWN) | |
8599 | ? -1 : bgp->vrf_id); | |
8600 | json_object_string_add(json, "vrfName", | |
8601 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
8602 | ? "Default" : bgp->name); | |
8603 | ||
8604 | if (! is_first) | |
8605 | vty_out (vty, ",%s", VTY_NEWLINE); | |
8606 | else | |
8607 | is_first = 0; | |
8608 | ||
8609 | vty_out(vty, "\"%s\":", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
8610 | ? "Default" : bgp->name); | |
8611 | } | |
8612 | else | |
8613 | { | |
8614 | vty_out (vty, "%sInstance %s:%s", | |
8615 | VTY_NEWLINE, | |
8616 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
8617 | ? "Default" : bgp->name, | |
8618 | VTY_NEWLINE); | |
8619 | } | |
f186de26 | 8620 | bgp_show_neighbor (vty, bgp, show_all, NULL, NULL, use_json, json); |
8621 | } | |
9f689658 DD |
8622 | |
8623 | if (use_json) | |
8624 | vty_out (vty, "}%s", VTY_NEWLINE); | |
f186de26 | 8625 | } |
8626 | ||
4fb25c53 DW |
8627 | static int |
8628 | bgp_show_neighbor_vty (struct vty *vty, const char *name, | |
8629 | enum show_type type, const char *ip_str, u_char use_json) | |
8630 | { | |
8631 | int ret; | |
8632 | struct bgp *bgp; | |
8633 | union sockunion su; | |
8634 | json_object *json = NULL; | |
8635 | ||
8636 | if (use_json) | |
8637 | json = json_object_new_object(); | |
8638 | ||
8639 | if (name) | |
8640 | { | |
8641 | if (strmatch(name, "all")) | |
8642 | { | |
8643 | bgp_show_all_instances_neighbors_vty (vty, use_json); | |
8644 | return CMD_SUCCESS; | |
8645 | } | |
8646 | else | |
8647 | { | |
8648 | bgp = bgp_lookup_by_name (name); | |
8649 | if (! bgp) | |
8650 | { | |
8651 | if (use_json) | |
8652 | { | |
8653 | json_object_boolean_true_add(json, "bgpNoSuchInstance"); | |
e52702f2 | 8654 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
4fb25c53 DW |
8655 | json_object_free(json); |
8656 | } | |
8657 | else | |
8658 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
8659 | ||
8660 | return CMD_WARNING; | |
8661 | } | |
8662 | } | |
8663 | } | |
8664 | else | |
8665 | { | |
8666 | bgp = bgp_get_default (); | |
8667 | } | |
8668 | ||
8669 | if (bgp) | |
8670 | { | |
8671 | if (ip_str) | |
8672 | { | |
8673 | ret = str2sockunion (ip_str, &su); | |
8674 | if (ret < 0) | |
8675 | bgp_show_neighbor (vty, bgp, type, NULL, ip_str, use_json, json); | |
8676 | else | |
8677 | bgp_show_neighbor (vty, bgp, type, &su, NULL, use_json, json); | |
8678 | } | |
8679 | else | |
8680 | { | |
8681 | bgp_show_neighbor (vty, bgp, type, NULL, NULL, use_json, json); | |
8682 | } | |
8683 | } | |
8684 | ||
8685 | return CMD_SUCCESS; | |
8686 | } | |
8687 | ||
716b2d8a | 8688 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 8689 | DEFUN (show_ip_bgp_neighbors, |
8690 | show_ip_bgp_neighbors_cmd, | |
91d37724 | 8691 | "show [ip] bgp [<view|vrf> WORD] [<ipv4|ipv6|vpnv4 <all|rd ASN:nn_or_IP-address:nn>>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 8692 | SHOW_STR |
8693 | IP_STR | |
8694 | BGP_STR | |
f2a8972b | 8695 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
8696 | "Address Family\n" |
8697 | "Address Family\n" | |
91d37724 QY |
8698 | "Address Family\n" |
8699 | "Display information about all VPNv4 NLRIs\n" | |
8700 | "Display information for a route distinguisher\n" | |
8701 | "VPN Route Distinguisher\n" | |
718e3744 | 8702 | "Detailed information on TCP and BGP neighbor connections\n" |
8703 | "Neighbor to display information about\n" | |
a80beece | 8704 | "Neighbor to display information about\n" |
91d37724 | 8705 | "Neighbor on BGP configured interface\n" |
9973d184 | 8706 | JSON_STR) |
718e3744 | 8707 | { |
5bf15956 DW |
8708 | char *vrf = NULL; |
8709 | char *sh_arg = NULL; | |
8710 | enum show_type sh_type; | |
718e3744 | 8711 | |
5bf15956 | 8712 | u_char uj = use_json(argc, argv); |
718e3744 | 8713 | |
630a298c | 8714 | int idx = 0; |
718e3744 | 8715 | |
630a298c QY |
8716 | if (argv_find (argv, argc, "WORD", &idx)) |
8717 | vrf = argv[idx]->arg; | |
718e3744 | 8718 | |
91d37724 QY |
8719 | if (argv_find (argv, argc, "A.B.C.D", &idx) || |
8720 | argv_find (argv, argc, "X:X::X:X", &idx) || | |
630a298c QY |
8721 | argv_find (argv, argc, "WORD", &idx)) |
8722 | { | |
8723 | sh_type = show_peer; | |
8724 | sh_arg = argv[idx]->arg; | |
8725 | } | |
5bf15956 | 8726 | else |
630a298c | 8727 | sh_type = show_all; |
856ca177 | 8728 | |
5bf15956 | 8729 | return bgp_show_neighbor_vty (vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 8730 | } |
8731 | ||
716b2d8a | 8732 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 8733 | paths' and `show ip mbgp paths'. Those functions results are the |
8734 | same.*/ | |
f412b39a | 8735 | DEFUN (show_ip_bgp_paths, |
718e3744 | 8736 | show_ip_bgp_paths_cmd, |
46f296b4 | 8737 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 8738 | SHOW_STR |
8739 | IP_STR | |
8740 | BGP_STR | |
46f296b4 | 8741 | BGP_SAFI_HELP_STR |
718e3744 | 8742 | "Path information\n") |
8743 | { | |
8744 | vty_out (vty, "Address Refcnt Path%s", VTY_NEWLINE); | |
8745 | aspath_print_all_vty (vty); | |
8746 | return CMD_SUCCESS; | |
8747 | } | |
8748 | ||
718e3744 | 8749 | #include "hash.h" |
8750 | ||
94f2b392 | 8751 | static void |
718e3744 | 8752 | community_show_all_iterator (struct hash_backet *backet, struct vty *vty) |
8753 | { | |
8754 | struct community *com; | |
8755 | ||
8756 | com = (struct community *) backet->data; | |
6c4f4e6e | 8757 | vty_out (vty, "[%p] (%ld) %s%s", (void *)backet, com->refcnt, |
718e3744 | 8758 | community_str (com), VTY_NEWLINE); |
8759 | } | |
8760 | ||
8761 | /* Show BGP's community internal data. */ | |
f412b39a | 8762 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 8763 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 8764 | "show [ip] bgp community-info", |
718e3744 | 8765 | SHOW_STR |
8766 | IP_STR | |
8767 | BGP_STR | |
8768 | "List all bgp community information\n") | |
8769 | { | |
8770 | vty_out (vty, "Address Refcnt Community%s", VTY_NEWLINE); | |
8771 | ||
e52702f2 | 8772 | hash_iterate (community_hash (), |
718e3744 | 8773 | (void (*) (struct hash_backet *, void *)) |
8774 | community_show_all_iterator, | |
8775 | vty); | |
8776 | ||
8777 | return CMD_SUCCESS; | |
8778 | } | |
8779 | ||
57d187bc JS |
8780 | static void |
8781 | lcommunity_show_all_iterator (struct hash_backet *backet, struct vty *vty) | |
8782 | { | |
8783 | struct lcommunity *lcom; | |
8784 | ||
8785 | lcom = (struct lcommunity *) backet->data; | |
8786 | vty_out (vty, "[%p] (%ld) %s%s", (void *)backet, lcom->refcnt, | |
2acb4ac2 | 8787 | lcommunity_str (lcom), VTY_NEWLINE); |
57d187bc JS |
8788 | } |
8789 | ||
8790 | /* Show BGP's community internal data. */ | |
8791 | DEFUN (show_ip_bgp_lcommunity_info, | |
8792 | show_ip_bgp_lcommunity_info_cmd, | |
8793 | "show ip bgp large-community-info", | |
8794 | SHOW_STR | |
8795 | IP_STR | |
8796 | BGP_STR | |
8797 | "List all bgp large-community information\n") | |
8798 | { | |
8799 | vty_out (vty, "Address Refcnt Large-community%s", VTY_NEWLINE); | |
8800 | ||
8801 | hash_iterate (lcommunity_hash (), | |
2acb4ac2 DL |
8802 | (void (*) (struct hash_backet *, void *)) |
8803 | lcommunity_show_all_iterator, | |
8804 | vty); | |
57d187bc JS |
8805 | |
8806 | return CMD_SUCCESS; | |
8807 | } | |
8808 | ||
8809 | ||
f412b39a | 8810 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 8811 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 8812 | "show [ip] bgp attribute-info", |
718e3744 | 8813 | SHOW_STR |
8814 | IP_STR | |
8815 | BGP_STR | |
8816 | "List all bgp attribute information\n") | |
8817 | { | |
8818 | attr_show_all (vty); | |
8819 | return CMD_SUCCESS; | |
8820 | } | |
6b0655a2 | 8821 | |
f186de26 | 8822 | static void |
8823 | bgp_show_all_instances_updgrps_vty (struct vty *vty, afi_t afi, safi_t safi) | |
8824 | { | |
8825 | struct listnode *node, *nnode; | |
8826 | struct bgp *bgp; | |
8827 | ||
8828 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) | |
8829 | { | |
8830 | vty_out (vty, "%sInstance %s:%s", | |
8831 | VTY_NEWLINE, | |
8832 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) ? "Default" : bgp->name, | |
8833 | VTY_NEWLINE); | |
8834 | update_group_show(bgp, afi, safi, vty, 0); | |
8835 | } | |
8836 | } | |
8837 | ||
4fb25c53 DW |
8838 | static int |
8839 | bgp_show_update_groups(struct vty *vty, const char *name, | |
8840 | int afi, int safi, | |
8841 | uint64_t subgrp_id) | |
8842 | { | |
8843 | struct bgp *bgp; | |
8844 | ||
8845 | if (name) | |
8846 | { | |
8847 | if (strmatch (name, "all")) | |
8848 | { | |
8849 | bgp_show_all_instances_updgrps_vty (vty, afi, safi); | |
8850 | return CMD_SUCCESS; | |
8851 | } | |
8852 | else | |
8853 | { | |
8854 | bgp = bgp_lookup_by_name (name); | |
8855 | } | |
8856 | } | |
8857 | else | |
8858 | { | |
8859 | bgp = bgp_get_default (); | |
8860 | } | |
8861 | ||
8862 | if (bgp) | |
8863 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
8864 | return CMD_SUCCESS; | |
8865 | } | |
8866 | ||
8fe8a7f6 DS |
8867 | DEFUN (show_ip_bgp_updgrps, |
8868 | show_ip_bgp_updgrps_cmd, | |
c9e571b4 | 8869 | "show [ip] bgp [<view|vrf> WORD] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 8870 | SHOW_STR |
8871 | IP_STR | |
8872 | BGP_STR | |
8873 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 8874 | BGP_AFI_HELP_STR |
46f296b4 | 8875 | BGP_SAFI_HELP_STR |
5bf15956 DW |
8876 | "Detailed info about dynamic update groups\n" |
8877 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 8878 | { |
5bf15956 | 8879 | char *vrf = NULL; |
ae19d7dd QY |
8880 | afi_t afi = AFI_IP6; |
8881 | safi_t safi = SAFI_UNICAST; | |
5bf15956 DW |
8882 | uint64_t subgrp_id = 0; |
8883 | ||
ae19d7dd QY |
8884 | int idx = 0; |
8885 | ||
8886 | /* show [ip] bgp */ | |
8887 | if (argv_find (argv, argc, "ip", &idx)) | |
8888 | afi = AFI_IP; | |
8889 | /* [<view|vrf> WORD] */ | |
8890 | if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) | |
8891 | vrf = argv[++idx]->arg; | |
c9e571b4 LB |
8892 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
8893 | if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) | |
8894 | { | |
8895 | argv_find_and_parse_safi (argv, argc, &idx, &safi); | |
8896 | } | |
5bf15956 | 8897 | |
ae19d7dd QY |
8898 | /* get subgroup id, if provided */ |
8899 | idx = argc - 1; | |
8900 | if (argv[idx]->type == VARIABLE_TKN) | |
8901 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx]->arg); | |
5bf15956 DW |
8902 | |
8903 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); | |
8fe8a7f6 DS |
8904 | } |
8905 | ||
f186de26 | 8906 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
8907 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 8908 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 8909 | SHOW_STR |
716b2d8a | 8910 | IP_STR |
f186de26 | 8911 | BGP_STR |
8912 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 8913 | "Detailed info about dynamic update groups\n") |
f186de26 | 8914 | { |
8915 | bgp_show_all_instances_updgrps_vty (vty, AFI_IP6, SAFI_UNICAST); | |
8916 | return CMD_SUCCESS; | |
8917 | } | |
8918 | ||
5bf15956 DW |
8919 | DEFUN (show_bgp_updgrps_stats, |
8920 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 8921 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 8922 | SHOW_STR |
716b2d8a | 8923 | IP_STR |
3f9c7369 | 8924 | BGP_STR |
0c7b1b01 | 8925 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
8926 | "Statistics\n") |
8927 | { | |
8928 | struct bgp *bgp; | |
8929 | ||
8930 | bgp = bgp_get_default(); | |
8931 | if (bgp) | |
8932 | update_group_show_stats(bgp, vty); | |
8933 | ||
8934 | return CMD_SUCCESS; | |
8935 | } | |
8936 | ||
8386ac43 | 8937 | DEFUN (show_bgp_instance_updgrps_stats, |
8938 | show_bgp_instance_updgrps_stats_cmd, | |
716b2d8a | 8939 | "show [ip] bgp <view|vrf> WORD update-groups statistics", |
8386ac43 | 8940 | SHOW_STR |
716b2d8a | 8941 | IP_STR |
8386ac43 | 8942 | BGP_STR |
8943 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 8944 | "Detailed info about dynamic update groups\n" |
8386ac43 | 8945 | "Statistics\n") |
8946 | { | |
c500ae40 | 8947 | int idx_word = 3; |
8386ac43 | 8948 | struct bgp *bgp; |
8949 | ||
c500ae40 | 8950 | bgp = bgp_lookup_by_name (argv[idx_word]->arg); |
8386ac43 | 8951 | if (bgp) |
8952 | update_group_show_stats(bgp, vty); | |
8953 | ||
8954 | return CMD_SUCCESS; | |
8955 | } | |
8956 | ||
3f9c7369 | 8957 | static void |
8386ac43 | 8958 | show_bgp_updgrps_adj_info_aux (struct vty *vty, const char *name, |
8959 | afi_t afi, safi_t safi, | |
f43e655e | 8960 | const char *what, uint64_t subgrp_id) |
3f9c7369 DS |
8961 | { |
8962 | struct bgp *bgp; | |
8386ac43 | 8963 | |
8964 | if (name) | |
8965 | bgp = bgp_lookup_by_name (name); | |
8966 | else | |
8967 | bgp = bgp_get_default (); | |
8968 | ||
3f9c7369 DS |
8969 | if (bgp) |
8970 | { | |
8971 | if (!strcmp(what, "advertise-queue")) | |
8972 | update_group_show_adj_queue(bgp, afi, safi, vty, subgrp_id); | |
8973 | else if (!strcmp(what, "advertised-routes")) | |
8974 | update_group_show_advertised(bgp, afi, safi, vty, subgrp_id); | |
8975 | else if (!strcmp(what, "packet-queue")) | |
8976 | update_group_show_packet_queue(bgp, afi, safi, vty, subgrp_id); | |
8977 | } | |
8978 | } | |
8979 | ||
8980 | DEFUN (show_ip_bgp_updgrps_adj, | |
8981 | show_ip_bgp_updgrps_adj_cmd, | |
716b2d8a | 8982 | "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 DS |
8983 | SHOW_STR |
8984 | IP_STR | |
8985 | BGP_STR | |
0c7b1b01 | 8986 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
8987 | "Advertisement queue\n" |
8988 | "Announced routes\n" | |
8989 | "Packet queue\n") | |
8fe8a7f6 | 8990 | |
3f9c7369 | 8991 | { |
c500ae40 DW |
8992 | int idx_type = 4; |
8993 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
8386ac43 | 8994 | return CMD_SUCCESS; |
8995 | } | |
8996 | ||
8997 | DEFUN (show_ip_bgp_instance_updgrps_adj, | |
8998 | show_ip_bgp_instance_updgrps_adj_cmd, | |
716b2d8a | 8999 | "show [ip] bgp <view|vrf> WORD update-groups <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 9000 | SHOW_STR |
9001 | IP_STR | |
9002 | BGP_STR | |
9003 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 9004 | "Detailed info about dynamic update groups\n" |
8386ac43 | 9005 | "Advertisement queue\n" |
9006 | "Announced routes\n" | |
9007 | "Packet queue\n") | |
9008 | ||
9009 | { | |
c500ae40 DW |
9010 | int idx_word = 4; |
9011 | int idx_type = 6; | |
9012 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
3f9c7369 DS |
9013 | return CMD_SUCCESS; |
9014 | } | |
9015 | ||
9016 | DEFUN (show_bgp_updgrps_afi_adj, | |
9017 | show_bgp_updgrps_afi_adj_cmd, | |
46f296b4 | 9018 | "show [ip] bgp "BGP_AFI_SAFI_CMD_STR" update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 9019 | SHOW_STR |
716b2d8a | 9020 | IP_STR |
3f9c7369 | 9021 | BGP_STR |
46f296b4 | 9022 | BGP_AFI_SAFI_HELP_STR |
0c7b1b01 | 9023 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
9024 | "Advertisement queue\n" |
9025 | "Announced routes\n" | |
8fe8a7f6 DS |
9026 | "Packet queue\n" |
9027 | "Specific subgroup info wanted for\n") | |
3f9c7369 | 9028 | { |
c500ae40 DW |
9029 | int idx_afi = 2; |
9030 | int idx_safi = 3; | |
9031 | int idx_type = 5; | |
46f296b4 LB |
9032 | show_bgp_updgrps_adj_info_aux(vty, NULL, |
9033 | bgp_vty_afi_from_arg(argv[idx_afi]->arg), | |
9034 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), | |
9035 | argv[idx_type]->arg, 0); | |
8fe8a7f6 | 9036 | return CMD_SUCCESS; |
3f9c7369 DS |
9037 | } |
9038 | ||
9039 | DEFUN (show_bgp_updgrps_adj, | |
9040 | show_bgp_updgrps_adj_cmd, | |
716b2d8a | 9041 | "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 9042 | SHOW_STR |
716b2d8a | 9043 | IP_STR |
3f9c7369 | 9044 | BGP_STR |
0c7b1b01 | 9045 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
9046 | "Advertisement queue\n" |
9047 | "Announced routes\n" | |
9048 | "Packet queue\n") | |
9049 | { | |
c500ae40 DW |
9050 | int idx_type = 3; |
9051 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
8386ac43 | 9052 | return CMD_SUCCESS; |
9053 | } | |
9054 | ||
9055 | DEFUN (show_bgp_instance_updgrps_adj, | |
9056 | show_bgp_instance_updgrps_adj_cmd, | |
716b2d8a | 9057 | "show [ip] bgp <view|vrf> WORD update-groups <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 9058 | SHOW_STR |
716b2d8a | 9059 | IP_STR |
8386ac43 | 9060 | BGP_STR |
9061 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 9062 | "Detailed info about dynamic update groups\n" |
8386ac43 | 9063 | "Advertisement queue\n" |
9064 | "Announced routes\n" | |
9065 | "Packet queue\n") | |
9066 | { | |
c500ae40 DW |
9067 | int idx_word = 3; |
9068 | int idx_type = 5; | |
9069 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
3f9c7369 DS |
9070 | return CMD_SUCCESS; |
9071 | } | |
9072 | ||
9073 | DEFUN (show_ip_bgp_updgrps_adj_s, | |
8fe8a7f6 | 9074 | show_ip_bgp_updgrps_adj_s_cmd, |
716b2d8a | 9075 | "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 DS |
9076 | SHOW_STR |
9077 | IP_STR | |
9078 | BGP_STR | |
0c7b1b01 | 9079 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 | 9080 | "Specific subgroup to display info for\n" |
3f9c7369 DS |
9081 | "Advertisement queue\n" |
9082 | "Announced routes\n" | |
9083 | "Packet queue\n") | |
3f9c7369 | 9084 | |
3f9c7369 | 9085 | { |
5bf15956 | 9086 | int idx_subgroup_id = 4; |
c500ae40 | 9087 | int idx_type = 5; |
f43e655e | 9088 | uint64_t subgrp_id; |
8fe8a7f6 | 9089 | |
5bf15956 | 9090 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8fe8a7f6 | 9091 | |
5bf15956 | 9092 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
8386ac43 | 9093 | return CMD_SUCCESS; |
9094 | } | |
9095 | ||
9096 | DEFUN (show_ip_bgp_instance_updgrps_adj_s, | |
9097 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
716b2d8a | 9098 | "show [ip] bgp <view|vrf> WORD update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 9099 | SHOW_STR |
9100 | IP_STR | |
9101 | BGP_STR | |
9102 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 9103 | "Detailed info about dynamic update groups\n" |
8386ac43 | 9104 | "Specific subgroup to display info for\n" |
9105 | "Advertisement queue\n" | |
9106 | "Announced routes\n" | |
9107 | "Packet queue\n") | |
9108 | ||
9109 | { | |
5bf15956 DW |
9110 | int idx_vrf = 4; |
9111 | int idx_subgroup_id = 6; | |
c500ae40 | 9112 | int idx_type = 7; |
f43e655e | 9113 | uint64_t subgrp_id; |
8386ac43 | 9114 | |
5bf15956 | 9115 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8386ac43 | 9116 | |
5bf15956 | 9117 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
3f9c7369 DS |
9118 | return CMD_SUCCESS; |
9119 | } | |
9120 | ||
8fe8a7f6 DS |
9121 | DEFUN (show_bgp_updgrps_afi_adj_s, |
9122 | show_bgp_updgrps_afi_adj_s_cmd, | |
46f296b4 | 9123 | "show [ip] bgp "BGP_AFI_SAFI_CMD_STR" update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 9124 | SHOW_STR |
716b2d8a | 9125 | IP_STR |
3f9c7369 | 9126 | BGP_STR |
46f296b4 | 9127 | BGP_AFI_SAFI_HELP_STR |
0c7b1b01 | 9128 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 | 9129 | "Specific subgroup to display info for\n" |
3f9c7369 DS |
9130 | "Advertisement queue\n" |
9131 | "Announced routes\n" | |
8fe8a7f6 DS |
9132 | "Packet queue\n" |
9133 | "Specific subgroup info wanted for\n") | |
3f9c7369 | 9134 | { |
c500ae40 DW |
9135 | int idx_afi = 2; |
9136 | int idx_safi = 3; | |
5bf15956 | 9137 | int idx_subgroup_id = 5; |
c500ae40 | 9138 | int idx_type = 6; |
f43e655e | 9139 | uint64_t subgrp_id; |
3f9c7369 | 9140 | |
5bf15956 | 9141 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8fe8a7f6 | 9142 | |
46f296b4 LB |
9143 | show_bgp_updgrps_adj_info_aux(vty, NULL, |
9144 | bgp_vty_afi_from_arg(argv[idx_afi]->arg), | |
9145 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), | |
9146 | argv[idx_type]->arg, subgrp_id); | |
8fe8a7f6 | 9147 | return CMD_SUCCESS; |
3f9c7369 DS |
9148 | } |
9149 | ||
8fe8a7f6 DS |
9150 | DEFUN (show_bgp_updgrps_adj_s, |
9151 | show_bgp_updgrps_adj_s_cmd, | |
716b2d8a | 9152 | "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8fe8a7f6 | 9153 | SHOW_STR |
716b2d8a | 9154 | IP_STR |
8fe8a7f6 | 9155 | BGP_STR |
0c7b1b01 | 9156 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 DS |
9157 | "Specific subgroup to display info for\n" |
9158 | "Advertisement queue\n" | |
9159 | "Announced routes\n" | |
9160 | "Packet queue\n") | |
9161 | { | |
5bf15956 | 9162 | int idx_subgroup_id = 3; |
c500ae40 | 9163 | int idx_type = 4; |
f43e655e | 9164 | uint64_t subgrp_id; |
8fe8a7f6 | 9165 | |
5bf15956 | 9166 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8fe8a7f6 | 9167 | |
5bf15956 | 9168 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
8fe8a7f6 DS |
9169 | return CMD_SUCCESS; |
9170 | } | |
9171 | ||
8386ac43 | 9172 | DEFUN (show_bgp_instance_updgrps_adj_s, |
9173 | show_bgp_instance_updgrps_adj_s_cmd, | |
716b2d8a | 9174 | "show [ip] bgp <view|vrf> WORD update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 9175 | SHOW_STR |
716b2d8a | 9176 | IP_STR |
8386ac43 | 9177 | BGP_STR |
9178 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 9179 | "Detailed info about dynamic update groups\n" |
8386ac43 | 9180 | "Specific subgroup to display info for\n" |
9181 | "Advertisement queue\n" | |
9182 | "Announced routes\n" | |
9183 | "Packet queue\n") | |
9184 | { | |
5bf15956 DW |
9185 | int idx_vrf = 3; |
9186 | int idx_subgroup_id = 5; | |
c500ae40 | 9187 | int idx_type = 6; |
f43e655e | 9188 | uint64_t subgrp_id; |
8386ac43 | 9189 | |
5bf15956 | 9190 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8386ac43 | 9191 | |
5bf15956 | 9192 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
8386ac43 | 9193 | return CMD_SUCCESS; |
9194 | } | |
9195 | ||
9196 | ||
8fe8a7f6 | 9197 | |
f14e6fdb DS |
9198 | static int |
9199 | bgp_show_one_peer_group (struct vty *vty, struct peer_group *group) | |
9200 | { | |
9201 | struct listnode *node, *nnode; | |
9202 | struct prefix *range; | |
9203 | struct peer *conf; | |
9204 | struct peer *peer; | |
4690c7d7 | 9205 | char buf[PREFIX2STR_BUFFER]; |
f14e6fdb DS |
9206 | afi_t afi; |
9207 | safi_t safi; | |
ffd0c037 DS |
9208 | const char *peer_status; |
9209 | const char *af_str; | |
f14e6fdb DS |
9210 | int lr_count; |
9211 | int dynamic; | |
9212 | int af_cfgd; | |
9213 | ||
9214 | conf = group->conf; | |
9215 | ||
0299c004 DS |
9216 | if (conf->as_type == AS_SPECIFIED || |
9217 | conf->as_type == AS_EXTERNAL) { | |
66b199b2 | 9218 | vty_out (vty, "%sBGP peer-group %s, remote AS %d%s", |
f14e6fdb | 9219 | VTY_NEWLINE, group->name, conf->as, VTY_NEWLINE); |
0299c004 | 9220 | } else if (conf->as_type == AS_INTERNAL) { |
66b199b2 | 9221 | vty_out (vty, "%sBGP peer-group %s, remote AS %d%s", |
0299c004 | 9222 | VTY_NEWLINE, group->name, group->bgp->as, VTY_NEWLINE); |
66b199b2 DS |
9223 | } else { |
9224 | vty_out (vty, "%sBGP peer-group %s%s", | |
9225 | VTY_NEWLINE, group->name, VTY_NEWLINE); | |
0299c004 | 9226 | } |
f14e6fdb | 9227 | |
0299c004 | 9228 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
f14e6fdb DS |
9229 | vty_out (vty, " Peer-group type is internal%s", VTY_NEWLINE); |
9230 | else | |
9231 | vty_out (vty, " Peer-group type is external%s", VTY_NEWLINE); | |
9232 | ||
9233 | /* Display AFs configured. */ | |
9234 | vty_out (vty, " Configured address-families:"); | |
9235 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
9236 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
9237 | { | |
9238 | if (conf->afc[afi][safi]) | |
9239 | { | |
9240 | af_cfgd = 1; | |
9241 | vty_out (vty, " %s;", afi_safi_print(afi, safi)); | |
9242 | } | |
9243 | } | |
9244 | if (!af_cfgd) | |
9245 | vty_out (vty, " none%s", VTY_NEWLINE); | |
9246 | else | |
9247 | vty_out (vty, "%s", VTY_NEWLINE); | |
9248 | ||
9249 | /* Display listen ranges (for dynamic neighbors), if any */ | |
9250 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
9251 | { | |
9252 | if (afi == AFI_IP) | |
9253 | af_str = "IPv4"; | |
9254 | else if (afi == AFI_IP6) | |
9255 | af_str = "IPv6"; | |
45ef4300 DL |
9256 | else |
9257 | af_str = "???"; | |
f14e6fdb DS |
9258 | lr_count = listcount(group->listen_range[afi]); |
9259 | if (lr_count) | |
9260 | { | |
9261 | vty_out(vty, | |
9262 | " %d %s listen range(s)%s", | |
9263 | lr_count, af_str, VTY_NEWLINE); | |
9264 | ||
9265 | ||
9266 | for (ALL_LIST_ELEMENTS (group->listen_range[afi], node, | |
9267 | nnode, range)) | |
9268 | { | |
9269 | prefix2str(range, buf, sizeof(buf)); | |
9270 | vty_out(vty, " %s%s", buf, VTY_NEWLINE); | |
9271 | } | |
9272 | } | |
9273 | } | |
9274 | ||
9275 | /* Display group members and their status */ | |
9276 | if (listcount(group->peer)) | |
9277 | { | |
9278 | vty_out (vty, " Peer-group members:%s", VTY_NEWLINE); | |
9279 | for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) | |
9280 | { | |
9281 | if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) | |
9282 | peer_status = "Idle (Admin)"; | |
9283 | else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) | |
9284 | peer_status = "Idle (PfxCt)"; | |
9285 | else | |
9286 | peer_status = LOOKUP(bgp_status_msg, peer->status); | |
9287 | ||
9288 | dynamic = peer_dynamic_neighbor(peer); | |
9289 | vty_out (vty, " %s %s %s %s", | |
9290 | peer->host, dynamic ? "(dynamic)" : "", | |
9291 | peer_status, VTY_NEWLINE); | |
9292 | } | |
9293 | } | |
9294 | ||
9295 | return CMD_SUCCESS; | |
9296 | } | |
9297 | ||
9298 | /* Show BGP peer group's information. */ | |
9299 | enum show_group_type | |
9300 | { | |
9301 | show_all_groups, | |
9302 | show_peer_group | |
9303 | }; | |
9304 | ||
9305 | static int | |
9306 | bgp_show_peer_group (struct vty *vty, struct bgp *bgp, | |
9307 | enum show_group_type type, const char *group_name) | |
9308 | { | |
9309 | struct listnode *node, *nnode; | |
9310 | struct peer_group *group; | |
9311 | int find = 0; | |
9312 | ||
9313 | for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) | |
9314 | { | |
9315 | switch (type) | |
9316 | { | |
9317 | case show_all_groups: | |
9318 | bgp_show_one_peer_group (vty, group); | |
9319 | break; | |
9320 | case show_peer_group: | |
9321 | if (group_name && (strcmp(group->name, group_name) == 0)) | |
9322 | { | |
9323 | find = 1; | |
9324 | bgp_show_one_peer_group (vty, group); | |
9325 | } | |
9326 | break; | |
9327 | } | |
9328 | } | |
9329 | ||
9330 | if (type == show_peer_group && ! find) | |
6d9e66dc | 9331 | vty_out (vty, "%% No such peer-group%s", VTY_NEWLINE); |
f14e6fdb DS |
9332 | |
9333 | return CMD_SUCCESS; | |
9334 | } | |
9335 | ||
9336 | static int | |
9337 | bgp_show_peer_group_vty (struct vty *vty, const char *name, | |
9338 | enum show_group_type type, const char *group_name) | |
9339 | { | |
9340 | struct bgp *bgp; | |
9341 | int ret = CMD_SUCCESS; | |
9342 | ||
9343 | if (name) | |
8386ac43 | 9344 | bgp = bgp_lookup_by_name (name); |
9345 | else | |
9346 | bgp = bgp_get_default (); | |
f14e6fdb | 9347 | |
8386ac43 | 9348 | if (! bgp) |
9349 | { | |
9350 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
9351 | return CMD_WARNING; | |
f14e6fdb DS |
9352 | } |
9353 | ||
8386ac43 | 9354 | ret = bgp_show_peer_group (vty, bgp, type, group_name); |
f14e6fdb DS |
9355 | |
9356 | return ret; | |
9357 | } | |
9358 | ||
9359 | DEFUN (show_ip_bgp_peer_groups, | |
9360 | show_ip_bgp_peer_groups_cmd, | |
f2a8972b | 9361 | "show [ip] bgp [<view|vrf> WORD] peer-group [PGNAME]", |
f14e6fdb DS |
9362 | SHOW_STR |
9363 | IP_STR | |
9364 | BGP_STR | |
8386ac43 | 9365 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
9366 | "Detailed information on BGP peer groups\n" |
9367 | "Peer group name\n") | |
f14e6fdb | 9368 | { |
d6e3c605 QY |
9369 | char *vrf, *pg; |
9370 | vrf = pg = NULL; | |
9371 | int idx = 0; | |
f14e6fdb | 9372 | |
f2a8972b | 9373 | vrf = argv_find (argv, argc, "WORD", &idx) ? argv[idx]->arg : NULL; |
d6e3c605 | 9374 | pg = argv_find (argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 9375 | |
d6e3c605 | 9376 | return bgp_show_peer_group_vty (vty, vrf, show_all_groups, pg); |
f14e6fdb | 9377 | } |
3f9c7369 | 9378 | |
d6e3c605 | 9379 | |
718e3744 | 9380 | /* Redistribute VTY commands. */ |
9381 | ||
718e3744 | 9382 | DEFUN (bgp_redistribute_ipv4, |
9383 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 9384 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 9385 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9386 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 9387 | { |
cdc2d765 | 9388 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 9389 | int idx_protocol = 1; |
718e3744 | 9390 | int type; |
9391 | ||
6d681bd8 QY |
9392 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9393 | if (type < 0) | |
718e3744 | 9394 | { |
9395 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9396 | return CMD_WARNING; | |
9397 | } | |
cdc2d765 DL |
9398 | bgp_redist_add(bgp, AFI_IP, type, 0); |
9399 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); | |
718e3744 | 9400 | } |
9401 | ||
9402 | DEFUN (bgp_redistribute_ipv4_rmap, | |
9403 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 9404 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 9405 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9406 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 9407 | "Route map reference\n" |
9408 | "Pointer to route-map entries\n") | |
9409 | { | |
cdc2d765 | 9410 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9411 | int idx_protocol = 1; |
9412 | int idx_word = 3; | |
718e3744 | 9413 | int type; |
7c8ff89e | 9414 | struct bgp_redist *red; |
718e3744 | 9415 | |
6d681bd8 QY |
9416 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9417 | if (type < 0) | |
718e3744 | 9418 | { |
9419 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9420 | return CMD_WARNING; | |
9421 | } | |
9422 | ||
cdc2d765 | 9423 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
c500ae40 | 9424 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9425 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); |
718e3744 | 9426 | } |
9427 | ||
9428 | DEFUN (bgp_redistribute_ipv4_metric, | |
9429 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 9430 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 9431 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9432 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 9433 | "Metric for redistributed routes\n" |
9434 | "Default metric\n") | |
9435 | { | |
cdc2d765 | 9436 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9437 | int idx_protocol = 1; |
9438 | int idx_number = 3; | |
718e3744 | 9439 | int type; |
9440 | u_int32_t metric; | |
7c8ff89e | 9441 | struct bgp_redist *red; |
718e3744 | 9442 | |
6d681bd8 QY |
9443 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9444 | if (type < 0) | |
718e3744 | 9445 | { |
9446 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9447 | return CMD_WARNING; | |
9448 | } | |
c500ae40 | 9449 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9450 | |
cdc2d765 DL |
9451 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
9452 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
9453 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); | |
718e3744 | 9454 | } |
9455 | ||
9456 | DEFUN (bgp_redistribute_ipv4_rmap_metric, | |
9457 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 9458 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 9459 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9460 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 9461 | "Route map reference\n" |
9462 | "Pointer to route-map entries\n" | |
9463 | "Metric for redistributed routes\n" | |
9464 | "Default metric\n") | |
9465 | { | |
cdc2d765 | 9466 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9467 | int idx_protocol = 1; |
9468 | int idx_word = 3; | |
9469 | int idx_number = 5; | |
718e3744 | 9470 | int type; |
9471 | u_int32_t metric; | |
7c8ff89e | 9472 | struct bgp_redist *red; |
718e3744 | 9473 | |
6d681bd8 QY |
9474 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9475 | if (type < 0) | |
718e3744 | 9476 | { |
9477 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9478 | return CMD_WARNING; | |
9479 | } | |
c500ae40 | 9480 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9481 | |
cdc2d765 | 9482 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
c500ae40 | 9483 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 DL |
9484 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
9485 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); | |
718e3744 | 9486 | } |
9487 | ||
9488 | DEFUN (bgp_redistribute_ipv4_metric_rmap, | |
9489 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 9490 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 9491 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9492 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 9493 | "Metric for redistributed routes\n" |
9494 | "Default metric\n" | |
9495 | "Route map reference\n" | |
9496 | "Pointer to route-map entries\n") | |
9497 | { | |
cdc2d765 | 9498 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9499 | int idx_protocol = 1; |
9500 | int idx_number = 3; | |
9501 | int idx_word = 5; | |
718e3744 | 9502 | int type; |
9503 | u_int32_t metric; | |
7c8ff89e | 9504 | struct bgp_redist *red; |
718e3744 | 9505 | |
6d681bd8 QY |
9506 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9507 | if (type < 0) | |
718e3744 | 9508 | { |
9509 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9510 | return CMD_WARNING; | |
9511 | } | |
c500ae40 | 9512 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9513 | |
cdc2d765 DL |
9514 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
9515 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
c500ae40 | 9516 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9517 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); |
718e3744 | 9518 | } |
9519 | ||
7c8ff89e DS |
9520 | DEFUN (bgp_redistribute_ipv4_ospf, |
9521 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 9522 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
9523 | "Redistribute information from another routing protocol\n" |
9524 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9525 | "Non-main Kernel Routing Table\n" |
9526 | "Instance ID/Table ID\n") | |
7c8ff89e | 9527 | { |
cdc2d765 | 9528 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9529 | int idx_ospf_table = 1; |
9530 | int idx_number = 2; | |
7c8ff89e | 9531 | u_short instance; |
7a4bb9c5 | 9532 | u_short protocol; |
7c8ff89e | 9533 | |
c500ae40 | 9534 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
7a4bb9c5 | 9535 | |
c500ae40 | 9536 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9537 | protocol = ZEBRA_ROUTE_OSPF; |
9538 | else | |
9539 | protocol = ZEBRA_ROUTE_TABLE; | |
9540 | ||
cdc2d765 DL |
9541 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
9542 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
9543 | } |
9544 | ||
9545 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, | |
9546 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 9547 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
9548 | "Redistribute information from another routing protocol\n" |
9549 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9550 | "Non-main Kernel Routing Table\n" |
9551 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
9552 | "Route map reference\n" |
9553 | "Pointer to route-map entries\n") | |
9554 | { | |
cdc2d765 | 9555 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9556 | int idx_ospf_table = 1; |
9557 | int idx_number = 2; | |
9558 | int idx_word = 4; | |
7c8ff89e DS |
9559 | struct bgp_redist *red; |
9560 | u_short instance; | |
7a4bb9c5 | 9561 | int protocol; |
7c8ff89e | 9562 | |
c500ae40 | 9563 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9564 | protocol = ZEBRA_ROUTE_OSPF; |
9565 | else | |
9566 | protocol = ZEBRA_ROUTE_TABLE; | |
9567 | ||
c500ae40 | 9568 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
cdc2d765 | 9569 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
c500ae40 | 9570 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9571 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); |
7c8ff89e DS |
9572 | } |
9573 | ||
9574 | DEFUN (bgp_redistribute_ipv4_ospf_metric, | |
9575 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 9576 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
9577 | "Redistribute information from another routing protocol\n" |
9578 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9579 | "Non-main Kernel Routing Table\n" |
9580 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
9581 | "Metric for redistributed routes\n" |
9582 | "Default metric\n") | |
9583 | { | |
cdc2d765 | 9584 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9585 | int idx_ospf_table = 1; |
9586 | int idx_number = 2; | |
9587 | int idx_number_2 = 4; | |
7c8ff89e DS |
9588 | u_int32_t metric; |
9589 | struct bgp_redist *red; | |
9590 | u_short instance; | |
7a4bb9c5 | 9591 | int protocol; |
7c8ff89e | 9592 | |
c500ae40 | 9593 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9594 | protocol = ZEBRA_ROUTE_OSPF; |
9595 | else | |
9596 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 9597 | |
c500ae40 DW |
9598 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
9599 | VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); | |
7a4bb9c5 | 9600 | |
cdc2d765 DL |
9601 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
9602 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
9603 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
9604 | } |
9605 | ||
9606 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, | |
9607 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 9608 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
9609 | "Redistribute information from another routing protocol\n" |
9610 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9611 | "Non-main Kernel Routing Table\n" |
9612 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
9613 | "Route map reference\n" |
9614 | "Pointer to route-map entries\n" | |
9615 | "Metric for redistributed routes\n" | |
9616 | "Default metric\n") | |
9617 | { | |
cdc2d765 | 9618 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9619 | int idx_ospf_table = 1; |
9620 | int idx_number = 2; | |
9621 | int idx_word = 4; | |
9622 | int idx_number_2 = 6; | |
7c8ff89e DS |
9623 | u_int32_t metric; |
9624 | struct bgp_redist *red; | |
9625 | u_short instance; | |
7a4bb9c5 | 9626 | int protocol; |
7c8ff89e | 9627 | |
c500ae40 | 9628 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9629 | protocol = ZEBRA_ROUTE_OSPF; |
9630 | else | |
9631 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 9632 | |
c500ae40 DW |
9633 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
9634 | VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); | |
7a4bb9c5 | 9635 | |
cdc2d765 | 9636 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
c500ae40 | 9637 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 DL |
9638 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); |
9639 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
9640 | } |
9641 | ||
9642 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, | |
9643 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 9644 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
9645 | "Redistribute information from another routing protocol\n" |
9646 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9647 | "Non-main Kernel Routing Table\n" |
9648 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
9649 | "Metric for redistributed routes\n" |
9650 | "Default metric\n" | |
9651 | "Route map reference\n" | |
9652 | "Pointer to route-map entries\n") | |
9653 | { | |
cdc2d765 | 9654 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9655 | int idx_ospf_table = 1; |
9656 | int idx_number = 2; | |
9657 | int idx_number_2 = 4; | |
9658 | int idx_word = 6; | |
7c8ff89e DS |
9659 | u_int32_t metric; |
9660 | struct bgp_redist *red; | |
9661 | u_short instance; | |
7a4bb9c5 | 9662 | int protocol; |
7c8ff89e | 9663 | |
c500ae40 | 9664 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9665 | protocol = ZEBRA_ROUTE_OSPF; |
9666 | else | |
9667 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 9668 | |
c500ae40 DW |
9669 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
9670 | VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); | |
7a4bb9c5 | 9671 | |
cdc2d765 DL |
9672 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
9673 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
c500ae40 | 9674 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9675 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); |
7c8ff89e DS |
9676 | } |
9677 | ||
9678 | DEFUN (no_bgp_redistribute_ipv4_ospf, | |
9679 | no_bgp_redistribute_ipv4_ospf_cmd, | |
d04c479d | 9680 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", |
7c8ff89e DS |
9681 | NO_STR |
9682 | "Redistribute information from another routing protocol\n" | |
9683 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 9684 | "Non-main Kernel Routing Table\n" |
31500417 DW |
9685 | "Instance ID/Table ID\n" |
9686 | "Metric for redistributed routes\n" | |
9687 | "Default metric\n" | |
9688 | "Route map reference\n" | |
9689 | "Pointer to route-map entries\n") | |
7c8ff89e | 9690 | { |
cdc2d765 | 9691 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9692 | int idx_ospf_table = 2; |
9693 | int idx_number = 3; | |
7c8ff89e | 9694 | u_short instance; |
7a4bb9c5 DS |
9695 | int protocol; |
9696 | ||
c500ae40 | 9697 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9698 | protocol = ZEBRA_ROUTE_OSPF; |
9699 | else | |
9700 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 9701 | |
c500ae40 | 9702 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
cdc2d765 | 9703 | return bgp_redistribute_unset (bgp, AFI_IP, protocol, instance); |
7c8ff89e DS |
9704 | } |
9705 | ||
718e3744 | 9706 | DEFUN (no_bgp_redistribute_ipv4, |
9707 | no_bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 9708 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 9709 | NO_STR |
9710 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 9711 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
9712 | "Metric for redistributed routes\n" |
9713 | "Default metric\n" | |
9714 | "Route map reference\n" | |
9715 | "Pointer to route-map entries\n") | |
718e3744 | 9716 | { |
cdc2d765 | 9717 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 9718 | int idx_protocol = 2; |
718e3744 | 9719 | int type; |
9720 | ||
6d681bd8 QY |
9721 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9722 | if (type < 0) | |
718e3744 | 9723 | { |
9724 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9725 | return CMD_WARNING; | |
9726 | } | |
cdc2d765 | 9727 | return bgp_redistribute_unset (bgp, AFI_IP, type, 0); |
718e3744 | 9728 | } |
9729 | ||
718e3744 | 9730 | DEFUN (bgp_redistribute_ipv6, |
9731 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 9732 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 9733 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9734 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 9735 | { |
cdc2d765 | 9736 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 9737 | int idx_protocol = 1; |
718e3744 | 9738 | int type; |
9739 | ||
6d681bd8 QY |
9740 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9741 | if (type < 0) | |
718e3744 | 9742 | { |
9743 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9744 | return CMD_WARNING; | |
9745 | } | |
9746 | ||
cdc2d765 DL |
9747 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
9748 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); | |
718e3744 | 9749 | } |
9750 | ||
9751 | DEFUN (bgp_redistribute_ipv6_rmap, | |
9752 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 9753 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 9754 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9755 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 9756 | "Route map reference\n" |
9757 | "Pointer to route-map entries\n") | |
9758 | { | |
cdc2d765 | 9759 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9760 | int idx_protocol = 1; |
9761 | int idx_word = 3; | |
718e3744 | 9762 | int type; |
7c8ff89e | 9763 | struct bgp_redist *red; |
718e3744 | 9764 | |
6d681bd8 QY |
9765 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9766 | if (type < 0) | |
718e3744 | 9767 | { |
9768 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9769 | return CMD_WARNING; | |
9770 | } | |
9771 | ||
cdc2d765 | 9772 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
c500ae40 | 9773 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9774 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); |
718e3744 | 9775 | } |
9776 | ||
9777 | DEFUN (bgp_redistribute_ipv6_metric, | |
9778 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 9779 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 9780 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9781 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 9782 | "Metric for redistributed routes\n" |
9783 | "Default metric\n") | |
9784 | { | |
cdc2d765 | 9785 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9786 | int idx_protocol = 1; |
9787 | int idx_number = 3; | |
718e3744 | 9788 | int type; |
9789 | u_int32_t metric; | |
7c8ff89e | 9790 | struct bgp_redist *red; |
718e3744 | 9791 | |
6d681bd8 QY |
9792 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9793 | if (type < 0) | |
718e3744 | 9794 | { |
9795 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9796 | return CMD_WARNING; | |
9797 | } | |
c500ae40 | 9798 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9799 | |
cdc2d765 DL |
9800 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
9801 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
9802 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); | |
718e3744 | 9803 | } |
9804 | ||
9805 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
9806 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 9807 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 9808 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9809 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 9810 | "Route map reference\n" |
9811 | "Pointer to route-map entries\n" | |
9812 | "Metric for redistributed routes\n" | |
9813 | "Default metric\n") | |
9814 | { | |
cdc2d765 | 9815 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9816 | int idx_protocol = 1; |
9817 | int idx_word = 3; | |
9818 | int idx_number = 5; | |
718e3744 | 9819 | int type; |
9820 | u_int32_t metric; | |
7c8ff89e | 9821 | struct bgp_redist *red; |
718e3744 | 9822 | |
6d681bd8 QY |
9823 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9824 | if (type < 0) | |
718e3744 | 9825 | { |
9826 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9827 | return CMD_WARNING; | |
9828 | } | |
c500ae40 | 9829 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9830 | |
cdc2d765 | 9831 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
c500ae40 | 9832 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 DL |
9833 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); |
9834 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); | |
718e3744 | 9835 | } |
9836 | ||
9837 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
9838 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 9839 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 9840 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9841 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 9842 | "Metric for redistributed routes\n" |
9843 | "Default metric\n" | |
9844 | "Route map reference\n" | |
9845 | "Pointer to route-map entries\n") | |
9846 | { | |
cdc2d765 | 9847 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9848 | int idx_protocol = 1; |
9849 | int idx_number = 3; | |
9850 | int idx_word = 5; | |
718e3744 | 9851 | int type; |
9852 | u_int32_t metric; | |
7c8ff89e | 9853 | struct bgp_redist *red; |
718e3744 | 9854 | |
6d681bd8 QY |
9855 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9856 | if (type < 0) | |
718e3744 | 9857 | { |
9858 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9859 | return CMD_WARNING; | |
9860 | } | |
c500ae40 | 9861 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9862 | |
cdc2d765 DL |
9863 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
9864 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, metric); | |
c500ae40 | 9865 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9866 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); |
718e3744 | 9867 | } |
9868 | ||
9869 | DEFUN (no_bgp_redistribute_ipv6, | |
9870 | no_bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 9871 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 9872 | NO_STR |
9873 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 9874 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
9875 | "Metric for redistributed routes\n" |
9876 | "Default metric\n" | |
9877 | "Route map reference\n" | |
9878 | "Pointer to route-map entries\n") | |
718e3744 | 9879 | { |
cdc2d765 | 9880 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 9881 | int idx_protocol = 2; |
718e3744 | 9882 | int type; |
9883 | ||
6d681bd8 QY |
9884 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9885 | if (type < 0) | |
718e3744 | 9886 | { |
9887 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9888 | return CMD_WARNING; | |
9889 | } | |
9890 | ||
cdc2d765 | 9891 | return bgp_redistribute_unset (bgp, AFI_IP6, type, 0); |
718e3744 | 9892 | } |
6b0655a2 | 9893 | |
718e3744 | 9894 | int |
9895 | bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi, | |
9896 | safi_t safi, int *write) | |
9897 | { | |
9898 | int i; | |
718e3744 | 9899 | |
9900 | /* Unicast redistribution only. */ | |
9901 | if (safi != SAFI_UNICAST) | |
9902 | return 0; | |
9903 | ||
9904 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) | |
9905 | { | |
9906 | /* Redistribute BGP does not make sense. */ | |
7c8ff89e | 9907 | if (i != ZEBRA_ROUTE_BGP) |
718e3744 | 9908 | { |
7c8ff89e DS |
9909 | struct list *red_list; |
9910 | struct listnode *node; | |
9911 | struct bgp_redist *red; | |
718e3744 | 9912 | |
7c8ff89e DS |
9913 | red_list = bgp->redist[afi][i]; |
9914 | if (!red_list) | |
9915 | continue; | |
718e3744 | 9916 | |
7c8ff89e DS |
9917 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) |
9918 | { | |
9919 | /* Display "address-family" when it is not yet diplayed. */ | |
9920 | bgp_config_write_family_header (vty, afi, safi, write); | |
9921 | ||
9922 | /* "redistribute" configuration. */ | |
0b960b4d | 9923 | vty_out (vty, " redistribute %s", zebra_route_string(i)); |
7c8ff89e DS |
9924 | if (red->instance) |
9925 | vty_out (vty, " %d", red->instance); | |
9926 | if (red->redist_metric_flag) | |
9927 | vty_out (vty, " metric %u", red->redist_metric); | |
9928 | if (red->rmap.name) | |
9929 | vty_out (vty, " route-map %s", red->rmap.name); | |
9930 | vty_out (vty, "%s", VTY_NEWLINE); | |
9931 | } | |
718e3744 | 9932 | } |
9933 | } | |
9934 | return *write; | |
9935 | } | |
6b0655a2 | 9936 | |
718e3744 | 9937 | /* BGP node structure. */ |
7fc626de | 9938 | static struct cmd_node bgp_node = |
718e3744 | 9939 | { |
9940 | BGP_NODE, | |
9941 | "%s(config-router)# ", | |
9942 | 1, | |
9943 | }; | |
9944 | ||
7fc626de | 9945 | static struct cmd_node bgp_ipv4_unicast_node = |
718e3744 | 9946 | { |
9947 | BGP_IPV4_NODE, | |
9948 | "%s(config-router-af)# ", | |
9949 | 1, | |
9950 | }; | |
9951 | ||
7fc626de | 9952 | static struct cmd_node bgp_ipv4_multicast_node = |
718e3744 | 9953 | { |
9954 | BGP_IPV4M_NODE, | |
9955 | "%s(config-router-af)# ", | |
9956 | 1, | |
9957 | }; | |
9958 | ||
7fc626de | 9959 | static struct cmd_node bgp_ipv6_unicast_node = |
718e3744 | 9960 | { |
9961 | BGP_IPV6_NODE, | |
9962 | "%s(config-router-af)# ", | |
9963 | 1, | |
9964 | }; | |
9965 | ||
7fc626de | 9966 | static struct cmd_node bgp_ipv6_multicast_node = |
25ffbdc1 | 9967 | { |
9968 | BGP_IPV6M_NODE, | |
9969 | "%s(config-router-af)# ", | |
9970 | 1, | |
9971 | }; | |
9972 | ||
7fc626de | 9973 | static struct cmd_node bgp_vpnv4_node = |
718e3744 | 9974 | { |
9975 | BGP_VPNV4_NODE, | |
9976 | "%s(config-router-af)# ", | |
9977 | 1 | |
9978 | }; | |
6b0655a2 | 9979 | |
8ecd3266 | 9980 | static struct cmd_node bgp_vpnv6_node = |
9981 | { | |
9982 | BGP_VPNV6_NODE, | |
9983 | "%s(config-router-af-vpnv6)# ", | |
9984 | 1 | |
9985 | }; | |
9986 | ||
8b1fb8be LB |
9987 | static struct cmd_node bgp_encap_node = |
9988 | { | |
9989 | BGP_ENCAP_NODE, | |
9990 | "%s(config-router-af-encap)# ", | |
9991 | 1 | |
9992 | }; | |
9993 | ||
9994 | static struct cmd_node bgp_encapv6_node = | |
9995 | { | |
9996 | BGP_ENCAPV6_NODE, | |
9997 | "%s(config-router-af-encapv6)# ", | |
9998 | 1 | |
9999 | }; | |
10000 | ||
4e0b7b6d PG |
10001 | static struct cmd_node bgp_evpn_node = |
10002 | { | |
10003 | BGP_EVPN_NODE, | |
10004 | "%s(config-router-evpn)# ", | |
10005 | 1 | |
10006 | }; | |
10007 | ||
1f8ae70b | 10008 | static void community_list_vty (void); |
10009 | ||
718e3744 | 10010 | void |
94f2b392 | 10011 | bgp_vty_init (void) |
718e3744 | 10012 | { |
718e3744 | 10013 | /* Install bgp top node. */ |
10014 | install_node (&bgp_node, bgp_config_write); | |
10015 | install_node (&bgp_ipv4_unicast_node, NULL); | |
10016 | install_node (&bgp_ipv4_multicast_node, NULL); | |
10017 | install_node (&bgp_ipv6_unicast_node, NULL); | |
25ffbdc1 | 10018 | install_node (&bgp_ipv6_multicast_node, NULL); |
718e3744 | 10019 | install_node (&bgp_vpnv4_node, NULL); |
8ecd3266 | 10020 | install_node (&bgp_vpnv6_node, NULL); |
8b1fb8be LB |
10021 | install_node (&bgp_encap_node, NULL); |
10022 | install_node (&bgp_encapv6_node, NULL); | |
4e0b7b6d | 10023 | install_node (&bgp_evpn_node, NULL); |
718e3744 | 10024 | |
10025 | /* Install default VTY commands to new nodes. */ | |
10026 | install_default (BGP_NODE); | |
10027 | install_default (BGP_IPV4_NODE); | |
10028 | install_default (BGP_IPV4M_NODE); | |
10029 | install_default (BGP_IPV6_NODE); | |
25ffbdc1 | 10030 | install_default (BGP_IPV6M_NODE); |
718e3744 | 10031 | install_default (BGP_VPNV4_NODE); |
8ecd3266 | 10032 | install_default (BGP_VPNV6_NODE); |
8b1fb8be LB |
10033 | install_default (BGP_ENCAP_NODE); |
10034 | install_default (BGP_ENCAPV6_NODE); | |
4e0b7b6d | 10035 | install_default (BGP_EVPN_NODE); |
e52702f2 | 10036 | |
718e3744 | 10037 | /* "bgp multiple-instance" commands. */ |
10038 | install_element (CONFIG_NODE, &bgp_multiple_instance_cmd); | |
10039 | install_element (CONFIG_NODE, &no_bgp_multiple_instance_cmd); | |
10040 | ||
10041 | /* "bgp config-type" commands. */ | |
10042 | install_element (CONFIG_NODE, &bgp_config_type_cmd); | |
8c3deaae | 10043 | install_element (CONFIG_NODE, &no_bgp_config_type_cmd); |
718e3744 | 10044 | |
5fe9f963 | 10045 | /* bgp route-map delay-timer commands. */ |
10046 | install_element (CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
10047 | install_element (CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
5fe9f963 | 10048 | |
718e3744 | 10049 | /* Dummy commands (Currently not supported) */ |
10050 | install_element (BGP_NODE, &no_synchronization_cmd); | |
10051 | install_element (BGP_NODE, &no_auto_summary_cmd); | |
10052 | ||
10053 | /* "router bgp" commands. */ | |
10054 | install_element (CONFIG_NODE, &router_bgp_cmd); | |
718e3744 | 10055 | |
10056 | /* "no router bgp" commands. */ | |
10057 | install_element (CONFIG_NODE, &no_router_bgp_cmd); | |
718e3744 | 10058 | |
10059 | /* "bgp router-id" commands. */ | |
10060 | install_element (BGP_NODE, &bgp_router_id_cmd); | |
10061 | install_element (BGP_NODE, &no_bgp_router_id_cmd); | |
718e3744 | 10062 | |
10063 | /* "bgp cluster-id" commands. */ | |
10064 | install_element (BGP_NODE, &bgp_cluster_id_cmd); | |
718e3744 | 10065 | install_element (BGP_NODE, &no_bgp_cluster_id_cmd); |
718e3744 | 10066 | |
10067 | /* "bgp confederation" commands. */ | |
10068 | install_element (BGP_NODE, &bgp_confederation_identifier_cmd); | |
10069 | install_element (BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
718e3744 | 10070 | |
10071 | /* "bgp confederation peers" commands. */ | |
10072 | install_element (BGP_NODE, &bgp_confederation_peers_cmd); | |
10073 | install_element (BGP_NODE, &no_bgp_confederation_peers_cmd); | |
10074 | ||
abc920f8 DS |
10075 | /* bgp max-med command */ |
10076 | install_element (BGP_NODE, &bgp_maxmed_admin_cmd); | |
10077 | install_element (BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
10078 | install_element (BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
abc920f8 DS |
10079 | install_element (BGP_NODE, &bgp_maxmed_onstartup_cmd); |
10080 | install_element (BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
abc920f8 | 10081 | install_element (BGP_NODE, &bgp_maxmed_onstartup_medv_cmd); |
abc920f8 | 10082 | |
907f92c8 DS |
10083 | /* bgp disable-ebgp-connected-nh-check */ |
10084 | install_element (BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
10085 | install_element (BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
10086 | ||
f188f2c4 DS |
10087 | /* bgp update-delay command */ |
10088 | install_element (BGP_NODE, &bgp_update_delay_cmd); | |
10089 | install_element (BGP_NODE, &no_bgp_update_delay_cmd); | |
10090 | install_element (BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
f188f2c4 | 10091 | |
cb1faec9 DS |
10092 | install_element (BGP_NODE, &bgp_wpkt_quanta_cmd); |
10093 | install_element (BGP_NODE, &no_bgp_wpkt_quanta_cmd); | |
10094 | ||
3f9c7369 DS |
10095 | install_element (BGP_NODE, &bgp_coalesce_time_cmd); |
10096 | install_element (BGP_NODE, &no_bgp_coalesce_time_cmd); | |
10097 | ||
165b5fff JB |
10098 | /* "maximum-paths" commands. */ |
10099 | install_element (BGP_NODE, &bgp_maxpaths_cmd); | |
10100 | install_element (BGP_NODE, &no_bgp_maxpaths_cmd); | |
165b5fff JB |
10101 | install_element (BGP_IPV4_NODE, &bgp_maxpaths_cmd); |
10102 | install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
431aa9f9 DS |
10103 | install_element (BGP_IPV6_NODE, &bgp_maxpaths_cmd); |
10104 | install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
165b5fff | 10105 | install_element (BGP_NODE, &bgp_maxpaths_ibgp_cmd); |
5e242b0d | 10106 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_cmd); |
165b5fff | 10107 | install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_cmd); |
165b5fff | 10108 | install_element (BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); |
5e242b0d | 10109 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); |
165b5fff | 10110 | install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); |
431aa9f9 | 10111 | install_element (BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); |
5e242b0d | 10112 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); |
431aa9f9 | 10113 | install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); |
165b5fff | 10114 | |
718e3744 | 10115 | /* "timers bgp" commands. */ |
10116 | install_element (BGP_NODE, &bgp_timers_cmd); | |
10117 | install_element (BGP_NODE, &no_bgp_timers_cmd); | |
718e3744 | 10118 | |
5fe9f963 | 10119 | /* route-map delay-timer commands - per instance for backwards compat. */ |
518f0eb1 DS |
10120 | install_element (BGP_NODE, &bgp_set_route_map_delay_timer_cmd); |
10121 | install_element (BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
10122 | ||
718e3744 | 10123 | /* "bgp client-to-client reflection" commands */ |
10124 | install_element (BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
10125 | install_element (BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
10126 | ||
10127 | /* "bgp always-compare-med" commands */ | |
10128 | install_element (BGP_NODE, &bgp_always_compare_med_cmd); | |
10129 | install_element (BGP_NODE, &no_bgp_always_compare_med_cmd); | |
e52702f2 | 10130 | |
718e3744 | 10131 | /* "bgp deterministic-med" commands */ |
10132 | install_element (BGP_NODE, &bgp_deterministic_med_cmd); | |
10133 | install_element (BGP_NODE, &no_bgp_deterministic_med_cmd); | |
538621f2 | 10134 | |
538621f2 | 10135 | /* "bgp graceful-restart" commands */ |
10136 | install_element (BGP_NODE, &bgp_graceful_restart_cmd); | |
10137 | install_element (BGP_NODE, &no_bgp_graceful_restart_cmd); | |
93406d87 | 10138 | install_element (BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
10139 | install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
eb6f1b41 PG |
10140 | install_element (BGP_NODE, &bgp_graceful_restart_restart_time_cmd); |
10141 | install_element (BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
e52702f2 | 10142 | |
43fc21b3 JC |
10143 | install_element (BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
10144 | install_element (BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
10145 | ||
718e3744 | 10146 | /* "bgp fast-external-failover" commands */ |
10147 | install_element (BGP_NODE, &bgp_fast_external_failover_cmd); | |
10148 | install_element (BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
10149 | ||
10150 | /* "bgp enforce-first-as" commands */ | |
10151 | install_element (BGP_NODE, &bgp_enforce_first_as_cmd); | |
10152 | install_element (BGP_NODE, &no_bgp_enforce_first_as_cmd); | |
10153 | ||
10154 | /* "bgp bestpath compare-routerid" commands */ | |
10155 | install_element (BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
10156 | install_element (BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
10157 | ||
10158 | /* "bgp bestpath as-path ignore" commands */ | |
10159 | install_element (BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
10160 | install_element (BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
10161 | ||
6811845b | 10162 | /* "bgp bestpath as-path confed" commands */ |
10163 | install_element (BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
10164 | install_element (BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
10165 | ||
2fdd455c PM |
10166 | /* "bgp bestpath as-path multipath-relax" commands */ |
10167 | install_element (BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
10168 | install_element (BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
10169 | ||
848973c7 | 10170 | /* "bgp log-neighbor-changes" commands */ |
10171 | install_element (BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
10172 | install_element (BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
10173 | ||
718e3744 | 10174 | /* "bgp bestpath med" commands */ |
10175 | install_element (BGP_NODE, &bgp_bestpath_med_cmd); | |
718e3744 | 10176 | install_element (BGP_NODE, &no_bgp_bestpath_med_cmd); |
718e3744 | 10177 | |
10178 | /* "no bgp default ipv4-unicast" commands. */ | |
10179 | install_element (BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
10180 | install_element (BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
e52702f2 | 10181 | |
718e3744 | 10182 | /* "bgp network import-check" commands. */ |
10183 | install_element (BGP_NODE, &bgp_network_import_check_cmd); | |
8233ef81 | 10184 | install_element (BGP_NODE, &bgp_network_import_check_exact_cmd); |
718e3744 | 10185 | install_element (BGP_NODE, &no_bgp_network_import_check_cmd); |
10186 | ||
10187 | /* "bgp default local-preference" commands. */ | |
10188 | install_element (BGP_NODE, &bgp_default_local_preference_cmd); | |
10189 | install_element (BGP_NODE, &no_bgp_default_local_preference_cmd); | |
718e3744 | 10190 | |
04b6bdc0 DW |
10191 | /* bgp default show-hostname */ |
10192 | install_element (BGP_NODE, &bgp_default_show_hostname_cmd); | |
10193 | install_element (BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
10194 | ||
3f9c7369 DS |
10195 | /* "bgp default subgroup-pkt-queue-max" commands. */ |
10196 | install_element (BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
10197 | install_element (BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
10198 | ||
8bd9d948 DS |
10199 | /* bgp ibgp-allow-policy-mods command */ |
10200 | install_element (BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
10201 | install_element (BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
10202 | ||
f14e6fdb DS |
10203 | /* "bgp listen limit" commands. */ |
10204 | install_element (BGP_NODE, &bgp_listen_limit_cmd); | |
10205 | install_element (BGP_NODE, &no_bgp_listen_limit_cmd); | |
10206 | ||
10207 | /* "bgp listen range" commands. */ | |
10208 | install_element (BGP_NODE, &bgp_listen_range_cmd); | |
10209 | install_element (BGP_NODE, &no_bgp_listen_range_cmd); | |
10210 | ||
718e3744 | 10211 | /* "neighbor remote-as" commands. */ |
10212 | install_element (BGP_NODE, &neighbor_remote_as_cmd); | |
a80beece | 10213 | install_element (BGP_NODE, &neighbor_interface_config_cmd); |
4c48cf63 | 10214 | install_element (BGP_NODE, &neighbor_interface_config_v6only_cmd); |
b3a39dc5 DD |
10215 | install_element (BGP_NODE, &neighbor_interface_config_remote_as_cmd); |
10216 | install_element (BGP_NODE, &neighbor_interface_v6only_config_remote_as_cmd); | |
718e3744 | 10217 | install_element (BGP_NODE, &no_neighbor_cmd); |
a80beece | 10218 | install_element (BGP_NODE, &no_neighbor_interface_config_cmd); |
718e3744 | 10219 | |
10220 | /* "neighbor peer-group" commands. */ | |
10221 | install_element (BGP_NODE, &neighbor_peer_group_cmd); | |
10222 | install_element (BGP_NODE, &no_neighbor_peer_group_cmd); | |
a80beece | 10223 | install_element (BGP_NODE, &no_neighbor_interface_peer_group_remote_as_cmd); |
718e3744 | 10224 | |
10225 | /* "neighbor local-as" commands. */ | |
10226 | install_element (BGP_NODE, &neighbor_local_as_cmd); | |
10227 | install_element (BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
9d3f9705 | 10228 | install_element (BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); |
718e3744 | 10229 | install_element (BGP_NODE, &no_neighbor_local_as_cmd); |
718e3744 | 10230 | |
3f9c7369 DS |
10231 | /* "neighbor solo" commands. */ |
10232 | install_element (BGP_NODE, &neighbor_solo_cmd); | |
10233 | install_element (BGP_NODE, &no_neighbor_solo_cmd); | |
10234 | ||
0df7c91f PJ |
10235 | /* "neighbor password" commands. */ |
10236 | install_element (BGP_NODE, &neighbor_password_cmd); | |
10237 | install_element (BGP_NODE, &no_neighbor_password_cmd); | |
10238 | ||
718e3744 | 10239 | /* "neighbor activate" commands. */ |
10240 | install_element (BGP_NODE, &neighbor_activate_cmd); | |
10241 | install_element (BGP_IPV4_NODE, &neighbor_activate_cmd); | |
10242 | install_element (BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
10243 | install_element (BGP_IPV6_NODE, &neighbor_activate_cmd); | |
25ffbdc1 | 10244 | install_element (BGP_IPV6M_NODE, &neighbor_activate_cmd); |
718e3744 | 10245 | install_element (BGP_VPNV4_NODE, &neighbor_activate_cmd); |
8ecd3266 | 10246 | install_element (BGP_VPNV6_NODE, &neighbor_activate_cmd); |
8b1fb8be LB |
10247 | install_element (BGP_ENCAP_NODE, &neighbor_activate_cmd); |
10248 | install_element (BGP_ENCAPV6_NODE, &neighbor_activate_cmd); | |
4e0b7b6d | 10249 | install_element (BGP_EVPN_NODE, &neighbor_activate_cmd); |
718e3744 | 10250 | |
10251 | /* "no neighbor activate" commands. */ | |
10252 | install_element (BGP_NODE, &no_neighbor_activate_cmd); | |
10253 | install_element (BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
10254 | install_element (BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
10255 | install_element (BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
25ffbdc1 | 10256 | install_element (BGP_IPV6M_NODE, &no_neighbor_activate_cmd); |
718e3744 | 10257 | install_element (BGP_VPNV4_NODE, &no_neighbor_activate_cmd); |
8ecd3266 | 10258 | install_element (BGP_VPNV6_NODE, &no_neighbor_activate_cmd); |
8b1fb8be LB |
10259 | install_element (BGP_ENCAP_NODE, &no_neighbor_activate_cmd); |
10260 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_activate_cmd); | |
4e0b7b6d | 10261 | install_element (BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
718e3744 | 10262 | |
c8560b44 DW |
10263 | /* "neighbor peer-group" set commands. |
10264 | * Long term we should only accept this command under BGP_NODE and not all of | |
10265 | * the afi/safi sub-contexts. For now though we need to accept it for backwards | |
10266 | * compatibility. This changed when we stopped requiring that peers be assigned | |
10267 | * to their peer-group under each address-family sub-context. | |
10268 | */ | |
718e3744 | 10269 | install_element (BGP_NODE, &neighbor_set_peer_group_cmd); |
10270 | install_element (BGP_IPV4_NODE, &neighbor_set_peer_group_cmd); | |
10271 | install_element (BGP_IPV4M_NODE, &neighbor_set_peer_group_cmd); | |
10272 | install_element (BGP_IPV6_NODE, &neighbor_set_peer_group_cmd); | |
25ffbdc1 | 10273 | install_element (BGP_IPV6M_NODE, &neighbor_set_peer_group_cmd); |
a58545bb | 10274 | install_element (BGP_VPNV4_NODE, &neighbor_set_peer_group_cmd); |
8ecd3266 | 10275 | install_element (BGP_VPNV6_NODE, &neighbor_set_peer_group_cmd); |
8b1fb8be LB |
10276 | install_element (BGP_ENCAP_NODE, &neighbor_set_peer_group_cmd); |
10277 | install_element (BGP_ENCAPV6_NODE, &neighbor_set_peer_group_cmd); | |
c8560b44 | 10278 | |
718e3744 | 10279 | /* "no neighbor peer-group unset" commands. */ |
10280 | install_element (BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
10281 | install_element (BGP_IPV4_NODE, &no_neighbor_set_peer_group_cmd); | |
10282 | install_element (BGP_IPV4M_NODE, &no_neighbor_set_peer_group_cmd); | |
10283 | install_element (BGP_IPV6_NODE, &no_neighbor_set_peer_group_cmd); | |
25ffbdc1 | 10284 | install_element (BGP_IPV6M_NODE, &no_neighbor_set_peer_group_cmd); |
a58545bb | 10285 | install_element (BGP_VPNV4_NODE, &no_neighbor_set_peer_group_cmd); |
8ecd3266 | 10286 | install_element (BGP_VPNV6_NODE, &no_neighbor_set_peer_group_cmd); |
8b1fb8be LB |
10287 | install_element (BGP_ENCAP_NODE, &no_neighbor_set_peer_group_cmd); |
10288 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_set_peer_group_cmd); | |
e52702f2 | 10289 | |
718e3744 | 10290 | /* "neighbor softreconfiguration inbound" commands.*/ |
10291 | install_element (BGP_NODE, &neighbor_soft_reconfiguration_cmd); | |
10292 | install_element (BGP_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
10293 | install_element (BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
10294 | install_element (BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
10295 | install_element (BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
10296 | install_element (BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
10297 | install_element (BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
10298 | install_element (BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
25ffbdc1 | 10299 | install_element (BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); |
10300 | install_element (BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
a58545bb | 10301 | install_element (BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); |
10302 | install_element (BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
8ecd3266 | 10303 | install_element (BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); |
10304 | install_element (BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
8b1fb8be LB |
10305 | install_element (BGP_ENCAP_NODE, &neighbor_soft_reconfiguration_cmd); |
10306 | install_element (BGP_ENCAP_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
10307 | install_element (BGP_ENCAPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
10308 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
718e3744 | 10309 | |
10310 | /* "neighbor attribute-unchanged" commands. */ | |
10311 | install_element (BGP_NODE, &neighbor_attr_unchanged_cmd); | |
718e3744 | 10312 | install_element (BGP_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10313 | install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 10314 | install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10315 | install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 10316 | install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10317 | install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 10318 | install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); |
25ffbdc1 | 10319 | install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); |
25ffbdc1 | 10320 | install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10321 | install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 10322 | install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); |
8ecd3266 | 10323 | install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); |
8ecd3266 | 10324 | install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); |
8ecd3266 | 10325 | |
8b1fb8be | 10326 | install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged_cmd); |
8b1fb8be | 10327 | install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged_cmd); |
8b1fb8be LB |
10328 | |
10329 | install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged_cmd); | |
8b1fb8be | 10330 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10331 | |
4e0b7b6d PG |
10332 | install_element (BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); |
10333 | install_element (BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
10334 | ||
fee0f4c6 | 10335 | /* "nexthop-local unchanged" commands */ |
10336 | install_element (BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
10337 | install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_local_unchanged_cmd); | |
10338 | ||
718e3744 | 10339 | /* "neighbor next-hop-self" commands. */ |
10340 | install_element (BGP_NODE, &neighbor_nexthop_self_cmd); | |
10341 | install_element (BGP_NODE, &no_neighbor_nexthop_self_cmd); | |
10342 | install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
10343 | install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
10344 | install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
10345 | install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
10346 | install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
10347 | install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
25ffbdc1 | 10348 | install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); |
10349 | install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
718e3744 | 10350 | install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); |
10351 | install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
8ecd3266 | 10352 | install_element (BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); |
10353 | install_element (BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
8b1fb8be LB |
10354 | install_element (BGP_ENCAP_NODE, &neighbor_nexthop_self_cmd); |
10355 | install_element (BGP_ENCAP_NODE, &no_neighbor_nexthop_self_cmd); | |
10356 | install_element (BGP_ENCAPV6_NODE, &neighbor_nexthop_self_cmd); | |
10357 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
718e3744 | 10358 | |
a538debe DS |
10359 | /* "neighbor next-hop-self force" commands. */ |
10360 | install_element (BGP_NODE, &neighbor_nexthop_self_force_cmd); | |
10361 | install_element (BGP_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10362 | install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); | |
10363 | install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10364 | install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); | |
10365 | install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10366 | install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); | |
10367 | install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10368 | install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); | |
10369 | install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10370 | install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); | |
10371 | install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
8ecd3266 | 10372 | install_element (BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
10373 | install_element (BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
a538debe | 10374 | |
c7122e14 DS |
10375 | /* "neighbor as-override" commands. */ |
10376 | install_element (BGP_NODE, &neighbor_as_override_cmd); | |
10377 | install_element (BGP_NODE, &no_neighbor_as_override_cmd); | |
10378 | install_element (BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
10379 | install_element (BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
10380 | install_element (BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
10381 | install_element (BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
10382 | install_element (BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
10383 | install_element (BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
10384 | install_element (BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
10385 | install_element (BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
10386 | install_element (BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
10387 | install_element (BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
8ecd3266 | 10388 | install_element (BGP_VPNV6_NODE, &neighbor_as_override_cmd); |
10389 | install_element (BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
c7122e14 | 10390 | |
718e3744 | 10391 | /* "neighbor remove-private-AS" commands. */ |
10392 | install_element (BGP_NODE, &neighbor_remove_private_as_cmd); | |
10393 | install_element (BGP_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10394 | install_element (BGP_NODE, &neighbor_remove_private_as_all_cmd); |
10395 | install_element (BGP_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10396 | install_element (BGP_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10397 | install_element (BGP_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10398 | install_element (BGP_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10399 | install_element (BGP_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 10400 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); |
10401 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10402 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); |
10403 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10404 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10405 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10406 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10407 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 10408 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); |
10409 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10410 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); |
10411 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10412 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10413 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10414 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10415 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 10416 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); |
10417 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10418 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); |
10419 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10420 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10421 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10422 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10423 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
25ffbdc1 | 10424 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); |
10425 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10426 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); |
10427 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10428 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10429 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10430 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10431 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 10432 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); |
10433 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10434 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); |
10435 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10436 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10437 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10438 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10439 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
8ecd3266 | 10440 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); |
10441 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
10442 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
10443 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10444 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10445 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10446 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10447 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
8b1fb8be LB |
10448 | install_element (BGP_ENCAP_NODE, &neighbor_remove_private_as_cmd); |
10449 | install_element (BGP_ENCAP_NODE, &no_neighbor_remove_private_as_cmd); | |
10450 | install_element (BGP_ENCAPV6_NODE, &neighbor_remove_private_as_cmd); | |
10451 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
718e3744 | 10452 | |
10453 | /* "neighbor send-community" commands.*/ | |
10454 | install_element (BGP_NODE, &neighbor_send_community_cmd); | |
10455 | install_element (BGP_NODE, &neighbor_send_community_type_cmd); | |
10456 | install_element (BGP_NODE, &no_neighbor_send_community_cmd); | |
10457 | install_element (BGP_NODE, &no_neighbor_send_community_type_cmd); | |
10458 | install_element (BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
10459 | install_element (BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
10460 | install_element (BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
10461 | install_element (BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
10462 | install_element (BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
10463 | install_element (BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
10464 | install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
10465 | install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
10466 | install_element (BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
10467 | install_element (BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
10468 | install_element (BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
10469 | install_element (BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
25ffbdc1 | 10470 | install_element (BGP_IPV6M_NODE, &neighbor_send_community_cmd); |
10471 | install_element (BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
10472 | install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
10473 | install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
718e3744 | 10474 | install_element (BGP_VPNV4_NODE, &neighbor_send_community_cmd); |
10475 | install_element (BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
10476 | install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
10477 | install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
8ecd3266 | 10478 | install_element (BGP_VPNV6_NODE, &neighbor_send_community_cmd); |
10479 | install_element (BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
10480 | install_element (BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
10481 | install_element (BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
8b1fb8be LB |
10482 | install_element (BGP_ENCAP_NODE, &neighbor_send_community_cmd); |
10483 | install_element (BGP_ENCAP_NODE, &neighbor_send_community_type_cmd); | |
10484 | install_element (BGP_ENCAP_NODE, &no_neighbor_send_community_cmd); | |
10485 | install_element (BGP_ENCAP_NODE, &no_neighbor_send_community_type_cmd); | |
10486 | install_element (BGP_ENCAPV6_NODE, &neighbor_send_community_cmd); | |
10487 | install_element (BGP_ENCAPV6_NODE, &neighbor_send_community_type_cmd); | |
10488 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_send_community_cmd); | |
10489 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_send_community_type_cmd); | |
718e3744 | 10490 | |
10491 | /* "neighbor route-reflector" commands.*/ | |
10492 | install_element (BGP_NODE, &neighbor_route_reflector_client_cmd); | |
10493 | install_element (BGP_NODE, &no_neighbor_route_reflector_client_cmd); | |
10494 | install_element (BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
10495 | install_element (BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
10496 | install_element (BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
10497 | install_element (BGP_IPV4M_NODE, &no_neighbor_route_reflector_client_cmd); | |
10498 | install_element (BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
10499 | install_element (BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
25ffbdc1 | 10500 | install_element (BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); |
10501 | install_element (BGP_IPV6M_NODE, &no_neighbor_route_reflector_client_cmd); | |
718e3744 | 10502 | install_element (BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); |
10503 | install_element (BGP_VPNV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
8ecd3266 | 10504 | install_element (BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); |
10505 | install_element (BGP_VPNV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
8b1fb8be LB |
10506 | install_element (BGP_ENCAP_NODE, &neighbor_route_reflector_client_cmd); |
10507 | install_element (BGP_ENCAP_NODE, &no_neighbor_route_reflector_client_cmd); | |
10508 | install_element (BGP_ENCAPV6_NODE, &neighbor_route_reflector_client_cmd); | |
10509 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
718e3744 | 10510 | |
10511 | /* "neighbor route-server" commands.*/ | |
10512 | install_element (BGP_NODE, &neighbor_route_server_client_cmd); | |
10513 | install_element (BGP_NODE, &no_neighbor_route_server_client_cmd); | |
10514 | install_element (BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
10515 | install_element (BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
10516 | install_element (BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
10517 | install_element (BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
10518 | install_element (BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
10519 | install_element (BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
25ffbdc1 | 10520 | install_element (BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); |
10521 | install_element (BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
718e3744 | 10522 | install_element (BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); |
10523 | install_element (BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
8ecd3266 | 10524 | install_element (BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); |
10525 | install_element (BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
8b1fb8be LB |
10526 | install_element (BGP_ENCAP_NODE, &neighbor_route_server_client_cmd); |
10527 | install_element (BGP_ENCAP_NODE, &no_neighbor_route_server_client_cmd); | |
10528 | install_element (BGP_ENCAPV6_NODE, &neighbor_route_server_client_cmd); | |
10529 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_server_client_cmd); | |
718e3744 | 10530 | |
adbac85e DW |
10531 | /* "neighbor addpath-tx-all-paths" commands.*/ |
10532 | install_element (BGP_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10533 | install_element (BGP_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10534 | install_element (BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10535 | install_element (BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10536 | install_element (BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10537 | install_element (BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10538 | install_element (BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10539 | install_element (BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10540 | install_element (BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10541 | install_element (BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10542 | install_element (BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10543 | install_element (BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
8ecd3266 | 10544 | install_element (BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); |
10545 | install_element (BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
adbac85e | 10546 | |
06370dac DW |
10547 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ |
10548 | install_element (BGP_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10549 | install_element (BGP_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10550 | install_element (BGP_IPV4_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10551 | install_element (BGP_IPV4_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10552 | install_element (BGP_IPV4M_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10553 | install_element (BGP_IPV4M_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10554 | install_element (BGP_IPV6_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10555 | install_element (BGP_IPV6_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10556 | install_element (BGP_IPV6M_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10557 | install_element (BGP_IPV6M_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10558 | install_element (BGP_VPNV4_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10559 | install_element (BGP_VPNV4_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
8ecd3266 | 10560 | install_element (BGP_VPNV6_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); |
10561 | install_element (BGP_VPNV6_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
06370dac | 10562 | |
718e3744 | 10563 | /* "neighbor passive" commands. */ |
10564 | install_element (BGP_NODE, &neighbor_passive_cmd); | |
10565 | install_element (BGP_NODE, &no_neighbor_passive_cmd); | |
10566 | ||
d5a5c8f0 | 10567 | |
718e3744 | 10568 | /* "neighbor shutdown" commands. */ |
10569 | install_element (BGP_NODE, &neighbor_shutdown_cmd); | |
10570 | install_element (BGP_NODE, &no_neighbor_shutdown_cmd); | |
10571 | ||
8a92a8a0 DS |
10572 | /* "neighbor capability extended-nexthop" commands.*/ |
10573 | install_element (BGP_NODE, &neighbor_capability_enhe_cmd); | |
10574 | install_element (BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
10575 | ||
718e3744 | 10576 | /* "neighbor capability orf prefix-list" commands.*/ |
10577 | install_element (BGP_NODE, &neighbor_capability_orf_prefix_cmd); | |
10578 | install_element (BGP_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
10579 | install_element (BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
10580 | install_element (BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
10581 | install_element (BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
10582 | install_element (BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
10583 | install_element (BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
10584 | install_element (BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
25ffbdc1 | 10585 | install_element (BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); |
10586 | install_element (BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
718e3744 | 10587 | |
10588 | /* "neighbor capability dynamic" commands.*/ | |
10589 | install_element (BGP_NODE, &neighbor_capability_dynamic_cmd); | |
10590 | install_element (BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
10591 | ||
10592 | /* "neighbor dont-capability-negotiate" commands. */ | |
10593 | install_element (BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
10594 | install_element (BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
10595 | ||
10596 | /* "neighbor ebgp-multihop" commands. */ | |
10597 | install_element (BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
10598 | install_element (BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
10599 | install_element (BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
718e3744 | 10600 | |
6ffd2079 | 10601 | /* "neighbor disable-connected-check" commands. */ |
10602 | install_element (BGP_NODE, &neighbor_disable_connected_check_cmd); | |
10603 | install_element (BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
718e3744 | 10604 | |
10605 | /* "neighbor description" commands. */ | |
10606 | install_element (BGP_NODE, &neighbor_description_cmd); | |
10607 | install_element (BGP_NODE, &no_neighbor_description_cmd); | |
718e3744 | 10608 | |
10609 | /* "neighbor update-source" commands. "*/ | |
10610 | install_element (BGP_NODE, &neighbor_update_source_cmd); | |
10611 | install_element (BGP_NODE, &no_neighbor_update_source_cmd); | |
10612 | ||
10613 | /* "neighbor default-originate" commands. */ | |
10614 | install_element (BGP_NODE, &neighbor_default_originate_cmd); | |
10615 | install_element (BGP_NODE, &neighbor_default_originate_rmap_cmd); | |
10616 | install_element (BGP_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 10617 | install_element (BGP_IPV4_NODE, &neighbor_default_originate_cmd); |
10618 | install_element (BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
10619 | install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 10620 | install_element (BGP_IPV4M_NODE, &neighbor_default_originate_cmd); |
10621 | install_element (BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
10622 | install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 10623 | install_element (BGP_IPV6_NODE, &neighbor_default_originate_cmd); |
10624 | install_element (BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
10625 | install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
25ffbdc1 | 10626 | install_element (BGP_IPV6M_NODE, &neighbor_default_originate_cmd); |
10627 | install_element (BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
10628 | install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 10629 | |
10630 | /* "neighbor port" commands. */ | |
10631 | install_element (BGP_NODE, &neighbor_port_cmd); | |
10632 | install_element (BGP_NODE, &no_neighbor_port_cmd); | |
718e3744 | 10633 | |
10634 | /* "neighbor weight" commands. */ | |
10635 | install_element (BGP_NODE, &neighbor_weight_cmd); | |
10636 | install_element (BGP_NODE, &no_neighbor_weight_cmd); | |
718e3744 | 10637 | |
d93f7ffc DW |
10638 | install_element (BGP_IPV4_NODE, &neighbor_weight_cmd); |
10639 | install_element (BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10640 | install_element (BGP_IPV4M_NODE, &neighbor_weight_cmd); |
10641 | install_element (BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10642 | install_element (BGP_IPV6_NODE, &neighbor_weight_cmd); |
10643 | install_element (BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10644 | install_element (BGP_IPV6M_NODE, &neighbor_weight_cmd); |
10645 | install_element (BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10646 | install_element (BGP_VPNV4_NODE, &neighbor_weight_cmd); |
10647 | install_element (BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10648 | install_element (BGP_VPNV6_NODE, &neighbor_weight_cmd); |
10649 | install_element (BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10650 | install_element (BGP_ENCAP_NODE, &neighbor_weight_cmd); |
10651 | install_element (BGP_ENCAP_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10652 | install_element (BGP_ENCAPV6_NODE, &neighbor_weight_cmd); |
10653 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_weight_cmd); | |
718e3744 | 10654 | |
10655 | /* "neighbor override-capability" commands. */ | |
10656 | install_element (BGP_NODE, &neighbor_override_capability_cmd); | |
10657 | install_element (BGP_NODE, &no_neighbor_override_capability_cmd); | |
10658 | ||
10659 | /* "neighbor strict-capability-match" commands. */ | |
10660 | install_element (BGP_NODE, &neighbor_strict_capability_cmd); | |
10661 | install_element (BGP_NODE, &no_neighbor_strict_capability_cmd); | |
10662 | ||
10663 | /* "neighbor timers" commands. */ | |
10664 | install_element (BGP_NODE, &neighbor_timers_cmd); | |
10665 | install_element (BGP_NODE, &no_neighbor_timers_cmd); | |
10666 | ||
10667 | /* "neighbor timers connect" commands. */ | |
10668 | install_element (BGP_NODE, &neighbor_timers_connect_cmd); | |
10669 | install_element (BGP_NODE, &no_neighbor_timers_connect_cmd); | |
718e3744 | 10670 | |
10671 | /* "neighbor advertisement-interval" commands. */ | |
10672 | install_element (BGP_NODE, &neighbor_advertise_interval_cmd); | |
10673 | install_element (BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
718e3744 | 10674 | |
718e3744 | 10675 | /* "neighbor interface" commands. */ |
10676 | install_element (BGP_NODE, &neighbor_interface_cmd); | |
10677 | install_element (BGP_NODE, &no_neighbor_interface_cmd); | |
10678 | ||
10679 | /* "neighbor distribute" commands. */ | |
10680 | install_element (BGP_NODE, &neighbor_distribute_list_cmd); | |
10681 | install_element (BGP_NODE, &no_neighbor_distribute_list_cmd); | |
10682 | install_element (BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
10683 | install_element (BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
10684 | install_element (BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
10685 | install_element (BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
10686 | install_element (BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
10687 | install_element (BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
25ffbdc1 | 10688 | install_element (BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); |
10689 | install_element (BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
718e3744 | 10690 | install_element (BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); |
10691 | install_element (BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
8ecd3266 | 10692 | install_element (BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); |
10693 | install_element (BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
8b1fb8be LB |
10694 | install_element (BGP_ENCAP_NODE, &neighbor_distribute_list_cmd); |
10695 | install_element (BGP_ENCAP_NODE, &no_neighbor_distribute_list_cmd); | |
10696 | install_element (BGP_ENCAPV6_NODE, &neighbor_distribute_list_cmd); | |
10697 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_distribute_list_cmd); | |
718e3744 | 10698 | |
10699 | /* "neighbor prefix-list" commands. */ | |
10700 | install_element (BGP_NODE, &neighbor_prefix_list_cmd); | |
10701 | install_element (BGP_NODE, &no_neighbor_prefix_list_cmd); | |
10702 | install_element (BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
10703 | install_element (BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
10704 | install_element (BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
10705 | install_element (BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
10706 | install_element (BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
10707 | install_element (BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
25ffbdc1 | 10708 | install_element (BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); |
10709 | install_element (BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
718e3744 | 10710 | install_element (BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); |
10711 | install_element (BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
8ecd3266 | 10712 | install_element (BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); |
10713 | install_element (BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
8b1fb8be LB |
10714 | install_element (BGP_ENCAP_NODE, &neighbor_prefix_list_cmd); |
10715 | install_element (BGP_ENCAP_NODE, &no_neighbor_prefix_list_cmd); | |
10716 | install_element (BGP_ENCAPV6_NODE, &neighbor_prefix_list_cmd); | |
10717 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_prefix_list_cmd); | |
718e3744 | 10718 | |
10719 | /* "neighbor filter-list" commands. */ | |
10720 | install_element (BGP_NODE, &neighbor_filter_list_cmd); | |
10721 | install_element (BGP_NODE, &no_neighbor_filter_list_cmd); | |
10722 | install_element (BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
10723 | install_element (BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
10724 | install_element (BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
10725 | install_element (BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
10726 | install_element (BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
10727 | install_element (BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
25ffbdc1 | 10728 | install_element (BGP_IPV6M_NODE, &neighbor_filter_list_cmd); |
10729 | install_element (BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
718e3744 | 10730 | install_element (BGP_VPNV4_NODE, &neighbor_filter_list_cmd); |
10731 | install_element (BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
8ecd3266 | 10732 | install_element (BGP_VPNV6_NODE, &neighbor_filter_list_cmd); |
10733 | install_element (BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
8b1fb8be LB |
10734 | install_element (BGP_ENCAP_NODE, &neighbor_filter_list_cmd); |
10735 | install_element (BGP_ENCAP_NODE, &no_neighbor_filter_list_cmd); | |
10736 | install_element (BGP_ENCAPV6_NODE, &neighbor_filter_list_cmd); | |
10737 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_filter_list_cmd); | |
718e3744 | 10738 | |
10739 | /* "neighbor route-map" commands. */ | |
10740 | install_element (BGP_NODE, &neighbor_route_map_cmd); | |
10741 | install_element (BGP_NODE, &no_neighbor_route_map_cmd); | |
10742 | install_element (BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
10743 | install_element (BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
10744 | install_element (BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
10745 | install_element (BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
10746 | install_element (BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
10747 | install_element (BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
25ffbdc1 | 10748 | install_element (BGP_IPV6M_NODE, &neighbor_route_map_cmd); |
10749 | install_element (BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
718e3744 | 10750 | install_element (BGP_VPNV4_NODE, &neighbor_route_map_cmd); |
10751 | install_element (BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
8ecd3266 | 10752 | install_element (BGP_VPNV6_NODE, &neighbor_route_map_cmd); |
10753 | install_element (BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
8b1fb8be LB |
10754 | install_element (BGP_ENCAP_NODE, &neighbor_route_map_cmd); |
10755 | install_element (BGP_ENCAP_NODE, &no_neighbor_route_map_cmd); | |
10756 | install_element (BGP_ENCAPV6_NODE, &neighbor_route_map_cmd); | |
10757 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_map_cmd); | |
718e3744 | 10758 | |
10759 | /* "neighbor unsuppress-map" commands. */ | |
10760 | install_element (BGP_NODE, &neighbor_unsuppress_map_cmd); | |
10761 | install_element (BGP_NODE, &no_neighbor_unsuppress_map_cmd); | |
10762 | install_element (BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
10763 | install_element (BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
10764 | install_element (BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
10765 | install_element (BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
10766 | install_element (BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
10767 | install_element (BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
25ffbdc1 | 10768 | install_element (BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); |
10769 | install_element (BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
a58545bb | 10770 | install_element (BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); |
bb86c601 | 10771 | install_element (BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); |
8ecd3266 | 10772 | install_element (BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); |
bb86c601 | 10773 | install_element (BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); |
8b1fb8be LB |
10774 | install_element (BGP_ENCAP_NODE, &neighbor_unsuppress_map_cmd); |
10775 | install_element (BGP_ENCAP_NODE, &no_neighbor_unsuppress_map_cmd); | |
10776 | install_element (BGP_ENCAPV6_NODE, &neighbor_unsuppress_map_cmd); | |
10777 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
718e3744 | 10778 | |
10779 | /* "neighbor maximum-prefix" commands. */ | |
10780 | install_element (BGP_NODE, &neighbor_maximum_prefix_cmd); | |
e0701b79 | 10781 | install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 10782 | install_element (BGP_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 10783 | install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 10784 | install_element (BGP_NODE, &neighbor_maximum_prefix_restart_cmd); |
10785 | install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 10786 | install_element (BGP_NODE, &no_neighbor_maximum_prefix_cmd); |
718e3744 | 10787 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 10788 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 10789 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 10790 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 10791 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); |
10792 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 10793 | install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); |
718e3744 | 10794 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 10795 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 10796 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 10797 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 10798 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); |
10799 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 10800 | install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); |
718e3744 | 10801 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 10802 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 10803 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 10804 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 10805 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); |
10806 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 10807 | install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); |
25ffbdc1 | 10808 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); |
10809 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
10810 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
10811 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
10812 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
10813 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
10814 | install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
718e3744 | 10815 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 10816 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 10817 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 10818 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 10819 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); |
10820 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 10821 | install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); |
8ecd3266 | 10822 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); |
10823 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
10824 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
10825 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
10826 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
10827 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
10828 | install_element (BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
718e3744 | 10829 | |
8b1fb8be LB |
10830 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_cmd); |
10831 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
10832 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_warning_cmd); | |
10833 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
10834 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_restart_cmd); | |
10835 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
10836 | install_element (BGP_ENCAP_NODE, &no_neighbor_maximum_prefix_cmd); | |
8b1fb8be LB |
10837 | |
10838 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_cmd); | |
10839 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
10840 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
10841 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
10842 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
10843 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
10844 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
8b1fb8be | 10845 | |
718e3744 | 10846 | /* "neighbor allowas-in" */ |
10847 | install_element (BGP_NODE, &neighbor_allowas_in_cmd); | |
718e3744 | 10848 | install_element (BGP_NODE, &no_neighbor_allowas_in_cmd); |
10849 | install_element (BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
718e3744 | 10850 | install_element (BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); |
10851 | install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
718e3744 | 10852 | install_element (BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); |
10853 | install_element (BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
718e3744 | 10854 | install_element (BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); |
25ffbdc1 | 10855 | install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); |
25ffbdc1 | 10856 | install_element (BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); |
718e3744 | 10857 | install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); |
718e3744 | 10858 | install_element (BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); |
8ecd3266 | 10859 | install_element (BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); |
8ecd3266 | 10860 | install_element (BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); |
8b1fb8be | 10861 | install_element (BGP_ENCAP_NODE, &neighbor_allowas_in_cmd); |
8b1fb8be LB |
10862 | install_element (BGP_ENCAP_NODE, &no_neighbor_allowas_in_cmd); |
10863 | install_element (BGP_ENCAPV6_NODE, &neighbor_allowas_in_cmd); | |
8b1fb8be | 10864 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_allowas_in_cmd); |
718e3744 | 10865 | |
10866 | /* address-family commands. */ | |
718e3744 | 10867 | install_element (BGP_NODE, &address_family_ipv4_safi_cmd); |
25ffbdc1 | 10868 | install_element (BGP_NODE, &address_family_ipv6_safi_cmd); |
d6902373 | 10869 | #ifdef KEEP_OLD_VPN_COMMANDS |
718e3744 | 10870 | install_element (BGP_NODE, &address_family_vpnv4_cmd); |
8b1fb8be | 10871 | install_element (BGP_NODE, &address_family_vpnv6_cmd); |
d6902373 | 10872 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be LB |
10873 | |
10874 | install_element (BGP_NODE, &address_family_encap_cmd); | |
8b1fb8be | 10875 | install_element (BGP_NODE, &address_family_encapv6_cmd); |
8b1fb8be | 10876 | |
4e0b7b6d PG |
10877 | install_element (BGP_NODE, &address_family_evpn_cmd); |
10878 | ||
718e3744 | 10879 | /* "exit-address-family" command. */ |
10880 | install_element (BGP_IPV4_NODE, &exit_address_family_cmd); | |
10881 | install_element (BGP_IPV4M_NODE, &exit_address_family_cmd); | |
10882 | install_element (BGP_IPV6_NODE, &exit_address_family_cmd); | |
25ffbdc1 | 10883 | install_element (BGP_IPV6M_NODE, &exit_address_family_cmd); |
718e3744 | 10884 | install_element (BGP_VPNV4_NODE, &exit_address_family_cmd); |
8ecd3266 | 10885 | install_element (BGP_VPNV6_NODE, &exit_address_family_cmd); |
8b1fb8be LB |
10886 | install_element (BGP_ENCAP_NODE, &exit_address_family_cmd); |
10887 | install_element (BGP_ENCAPV6_NODE, &exit_address_family_cmd); | |
4e0b7b6d | 10888 | install_element (BGP_EVPN_NODE, &exit_address_family_cmd); |
718e3744 | 10889 | |
10890 | /* "clear ip bgp commands" */ | |
10891 | install_element (ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
718e3744 | 10892 | |
8ad7271d DS |
10893 | /* clear ip bgp prefix */ |
10894 | install_element (ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
10895 | install_element (ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
01080f7c | 10896 | install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); |
8ad7271d | 10897 | |
716b2d8a | 10898 | /* "show [ip] bgp summary" commands. */ |
f186de26 | 10899 | install_element (VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); |
8386ac43 | 10900 | install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_cmd); |
8386ac43 | 10901 | install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_s_cmd); |
271ad8d5 | 10902 | install_element (VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
e52702f2 | 10903 | install_element (VIEW_NODE, &show_bgp_updgrps_adj_cmd); |
e52702f2 | 10904 | install_element (VIEW_NODE, &show_bgp_updgrps_adj_s_cmd); |
271ad8d5 | 10905 | install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_cmd); |
e52702f2 | 10906 | install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_s_cmd); |
8c3deaae | 10907 | install_element (VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
271ad8d5 QY |
10908 | install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_cmd); |
10909 | install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); | |
10910 | install_element (VIEW_NODE, &show_ip_bgp_summary_cmd); | |
10911 | install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_cmd); | |
10912 | install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_s_cmd); | |
10913 | install_element (VIEW_NODE, &show_ip_bgp_updgrps_cmd); | |
e3e29b32 | 10914 | |
716b2d8a | 10915 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 10916 | install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd); |
718e3744 | 10917 | |
716b2d8a | 10918 | /* "show [ip] bgp peer-group" commands. */ |
f14e6fdb | 10919 | install_element (VIEW_NODE, &show_ip_bgp_peer_groups_cmd); |
f14e6fdb | 10920 | |
716b2d8a | 10921 | /* "show [ip] bgp paths" commands. */ |
718e3744 | 10922 | install_element (VIEW_NODE, &show_ip_bgp_paths_cmd); |
718e3744 | 10923 | |
716b2d8a | 10924 | /* "show [ip] bgp community" commands. */ |
718e3744 | 10925 | install_element (VIEW_NODE, &show_ip_bgp_community_info_cmd); |
718e3744 | 10926 | |
57d187bc JS |
10927 | /* "show ip bgp large-community" commands. */ |
10928 | install_element (VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
716b2d8a | 10929 | /* "show [ip] bgp attribute-info" commands. */ |
718e3744 | 10930 | install_element (VIEW_NODE, &show_ip_bgp_attr_info_cmd); |
718e3744 | 10931 | |
10932 | /* "redistribute" commands. */ | |
10933 | install_element (BGP_NODE, &bgp_redistribute_ipv4_cmd); | |
10934 | install_element (BGP_NODE, &no_bgp_redistribute_ipv4_cmd); | |
10935 | install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
718e3744 | 10936 | install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_cmd); |
718e3744 | 10937 | install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); |
10938 | install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
7c8ff89e DS |
10939 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_cmd); |
10940 | install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
10941 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
7c8ff89e | 10942 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); |
7c8ff89e | 10943 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); |
7c8ff89e | 10944 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); |
919e0666 DW |
10945 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); |
10946 | install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
10947 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
919e0666 | 10948 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); |
919e0666 DW |
10949 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); |
10950 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
919e0666 DW |
10951 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); |
10952 | install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
10953 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
919e0666 | 10954 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); |
919e0666 | 10955 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); |
919e0666 | 10956 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); |
718e3744 | 10957 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); |
10958 | install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
10959 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
718e3744 | 10960 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); |
718e3744 | 10961 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); |
10962 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
718e3744 | 10963 | |
fa411a21 NH |
10964 | /* ttl_security commands */ |
10965 | install_element (BGP_NODE, &neighbor_ttl_security_cmd); | |
10966 | install_element (BGP_NODE, &no_neighbor_ttl_security_cmd); | |
10967 | ||
716b2d8a | 10968 | /* "show [ip] bgp memory" commands. */ |
4bf6a362 | 10969 | install_element (VIEW_NODE, &show_bgp_memory_cmd); |
e52702f2 | 10970 | |
716b2d8a | 10971 | /* "show [ip] bgp views" commands. */ |
e0081f70 | 10972 | install_element (VIEW_NODE, &show_bgp_views_cmd); |
e52702f2 | 10973 | |
716b2d8a | 10974 | /* "show [ip] bgp vrfs" commands. */ |
8386ac43 | 10975 | install_element (VIEW_NODE, &show_bgp_vrfs_cmd); |
e52702f2 | 10976 | |
718e3744 | 10977 | /* Community-list. */ |
10978 | community_list_vty (); | |
10979 | } | |
6b0655a2 | 10980 | |
718e3744 | 10981 | #include "memory.h" |
10982 | #include "bgp_regex.h" | |
10983 | #include "bgp_clist.h" | |
10984 | #include "bgp_ecommunity.h" | |
10985 | ||
10986 | /* VTY functions. */ | |
10987 | ||
10988 | /* Direction value to string conversion. */ | |
94f2b392 | 10989 | static const char * |
718e3744 | 10990 | community_direct_str (int direct) |
10991 | { | |
10992 | switch (direct) | |
10993 | { | |
10994 | case COMMUNITY_DENY: | |
10995 | return "deny"; | |
718e3744 | 10996 | case COMMUNITY_PERMIT: |
10997 | return "permit"; | |
718e3744 | 10998 | default: |
10999 | return "unknown"; | |
718e3744 | 11000 | } |
11001 | } | |
11002 | ||
11003 | /* Display error string. */ | |
94f2b392 | 11004 | static void |
718e3744 | 11005 | community_list_perror (struct vty *vty, int ret) |
11006 | { | |
11007 | switch (ret) | |
11008 | { | |
11009 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
b729294c | 11010 | vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE); |
718e3744 | 11011 | break; |
11012 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
11013 | vty_out (vty, "%% Malformed community-list value%s", VTY_NEWLINE); | |
11014 | break; | |
11015 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
11016 | vty_out (vty, "%% Community name conflict, previously defined as standard community%s", VTY_NEWLINE); | |
11017 | break; | |
11018 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
11019 | vty_out (vty, "%% Community name conflict, previously defined as expanded community%s", VTY_NEWLINE); | |
11020 | break; | |
11021 | } | |
11022 | } | |
11023 | ||
5bf15956 DW |
11024 | /* "community-list" keyword help string. */ |
11025 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
11026 | ||
718e3744 | 11027 | |
5bf15956 | 11028 | /* ip community-list standard */ |
718e3744 | 11029 | DEFUN (ip_community_list_standard, |
11030 | ip_community_list_standard_cmd, | |
e961923c | 11031 | "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 11032 | IP_STR |
11033 | COMMUNITY_LIST_STR | |
11034 | "Community list number (standard)\n" | |
5bf15956 | 11035 | "Add an standard community-list entry\n" |
718e3744 | 11036 | "Community list name\n" |
11037 | "Specify community to reject\n" | |
11038 | "Specify community to accept\n" | |
11039 | COMMUNITY_VAL_STR) | |
11040 | { | |
42f914d4 QY |
11041 | char *cl_name_or_number = NULL; |
11042 | int direct = 0; | |
11043 | int style = COMMUNITY_LIST_STANDARD; | |
11044 | ||
11045 | int idx = 0; | |
11046 | argv_find (argv, argc, "(1-99)", &idx); | |
11047 | argv_find (argv, argc, "WORD", &idx); | |
11048 | cl_name_or_number = argv[idx]->arg; | |
11049 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11050 | argv_find (argv, argc, "AA:NN", &idx); | |
11051 | char *str = argv_concat (argv, argc, idx); | |
11052 | ||
11053 | int ret = community_list_set (bgp_clist, cl_name_or_number, str, direct, style); | |
11054 | ||
11055 | XFREE (MTYPE_TMP, str); | |
11056 | ||
11057 | if (ret < 0) | |
11058 | { | |
11059 | /* Display error string. */ | |
11060 | community_list_perror (vty, ret); | |
11061 | return CMD_WARNING; | |
11062 | } | |
11063 | ||
11064 | return CMD_SUCCESS; | |
718e3744 | 11065 | } |
11066 | ||
fee6e4e4 | 11067 | DEFUN (no_ip_community_list_standard_all, |
11068 | no_ip_community_list_standard_all_cmd, | |
e961923c | 11069 | "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 11070 | NO_STR |
11071 | IP_STR | |
11072 | COMMUNITY_LIST_STR | |
11073 | "Community list number (standard)\n" | |
5bf15956 DW |
11074 | "Add an standard community-list entry\n" |
11075 | "Community list name\n" | |
718e3744 | 11076 | "Specify community to reject\n" |
11077 | "Specify community to accept\n" | |
11078 | COMMUNITY_VAL_STR) | |
11079 | { | |
42f914d4 QY |
11080 | int delete_all = 0; |
11081 | ||
11082 | char *cl_name_or_number = NULL; | |
11083 | int direct = 0; | |
11084 | int style = COMMUNITY_LIST_STANDARD; | |
11085 | ||
11086 | int idx = 0; | |
11087 | argv_find (argv, argc, "(1-99)", &idx); | |
11088 | argv_find (argv, argc, "WORD", &idx); | |
11089 | cl_name_or_number = argv[idx]->arg; | |
11090 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11091 | argv_find (argv, argc, "AA:NN", &idx); | |
11092 | char *str = argv_concat (argv, argc, idx); | |
11093 | ||
11094 | int ret = community_list_unset (bgp_clist, cl_name_or_number, str, direct, style, delete_all); | |
11095 | ||
daf9ddbb DS |
11096 | XFREE (MTYPE_TMP, str); |
11097 | ||
42f914d4 QY |
11098 | if (ret < 0) |
11099 | { | |
11100 | community_list_perror (vty, ret); | |
11101 | return CMD_WARNING; | |
11102 | } | |
11103 | ||
11104 | return CMD_SUCCESS; | |
718e3744 | 11105 | } |
11106 | ||
5bf15956 DW |
11107 | /* ip community-list expanded */ |
11108 | DEFUN (ip_community_list_expanded_all, | |
11109 | ip_community_list_expanded_all_cmd, | |
42f914d4 | 11110 | "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 11111 | IP_STR |
11112 | COMMUNITY_LIST_STR | |
11113 | "Community list number (expanded)\n" | |
5bf15956 | 11114 | "Add an expanded community-list entry\n" |
718e3744 | 11115 | "Community list name\n" |
11116 | "Specify community to reject\n" | |
11117 | "Specify community to accept\n" | |
11118 | COMMUNITY_VAL_STR) | |
11119 | { | |
42f914d4 QY |
11120 | char *cl_name_or_number = NULL; |
11121 | int direct = 0; | |
11122 | int style = COMMUNITY_LIST_EXPANDED; | |
11123 | ||
11124 | int idx = 0; | |
11125 | argv_find (argv, argc, "(100-500)", &idx); | |
11126 | argv_find (argv, argc, "WORD", &idx); | |
11127 | cl_name_or_number = argv[idx]->arg; | |
11128 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11129 | argv_find (argv, argc, "AA:NN", &idx); | |
11130 | char *str = argv_concat (argv, argc, idx); | |
11131 | ||
11132 | int ret = community_list_set (bgp_clist, cl_name_or_number, str, direct, style); | |
11133 | ||
11134 | XFREE (MTYPE_TMP, str); | |
11135 | ||
11136 | if (ret < 0) | |
11137 | { | |
11138 | /* Display error string. */ | |
11139 | community_list_perror (vty, ret); | |
11140 | return CMD_WARNING; | |
11141 | } | |
11142 | ||
11143 | return CMD_SUCCESS; | |
718e3744 | 11144 | } |
11145 | ||
5bf15956 DW |
11146 | DEFUN (no_ip_community_list_expanded_all, |
11147 | no_ip_community_list_expanded_all_cmd, | |
42f914d4 | 11148 | "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 11149 | NO_STR |
11150 | IP_STR | |
11151 | COMMUNITY_LIST_STR | |
5bf15956 DW |
11152 | "Community list number (expanded)\n" |
11153 | "Add an expanded community-list entry\n" | |
718e3744 | 11154 | "Community list name\n" |
11155 | "Specify community to reject\n" | |
11156 | "Specify community to accept\n" | |
5bf15956 | 11157 | COMMUNITY_VAL_STR) |
718e3744 | 11158 | { |
42f914d4 QY |
11159 | int delete_all = 0; |
11160 | ||
11161 | char *cl_name_or_number = NULL; | |
11162 | int direct = 0; | |
11163 | int style = COMMUNITY_LIST_EXPANDED; | |
11164 | ||
11165 | int idx = 0; | |
11166 | argv_find (argv, argc, "(100-500)", &idx); | |
11167 | argv_find (argv, argc, "WORD", &idx); | |
11168 | cl_name_or_number = argv[idx]->arg; | |
11169 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11170 | argv_find (argv, argc, "AA:NN", &idx); | |
11171 | char *str = argv_concat (argv, argc, idx); | |
11172 | ||
11173 | int ret = community_list_unset (bgp_clist, cl_name_or_number, str, direct, style, delete_all); | |
11174 | ||
daf9ddbb DS |
11175 | XFREE (MTYPE_TMP, str); |
11176 | ||
42f914d4 QY |
11177 | if (ret < 0) |
11178 | { | |
11179 | community_list_perror (vty, ret); | |
11180 | return CMD_WARNING; | |
11181 | } | |
11182 | ||
11183 | return CMD_SUCCESS; | |
718e3744 | 11184 | } |
11185 | ||
94f2b392 | 11186 | static void |
718e3744 | 11187 | community_list_show (struct vty *vty, struct community_list *list) |
11188 | { | |
11189 | struct community_entry *entry; | |
11190 | ||
11191 | for (entry = list->head; entry; entry = entry->next) | |
11192 | { | |
11193 | if (entry == list->head) | |
11194 | { | |
11195 | if (all_digit (list->name)) | |
11196 | vty_out (vty, "Community %s list %s%s", | |
11197 | entry->style == COMMUNITY_LIST_STANDARD ? | |
11198 | "standard" : "(expanded) access", | |
11199 | list->name, VTY_NEWLINE); | |
11200 | else | |
11201 | vty_out (vty, "Named Community %s list %s%s", | |
11202 | entry->style == COMMUNITY_LIST_STANDARD ? | |
11203 | "standard" : "expanded", | |
11204 | list->name, VTY_NEWLINE); | |
11205 | } | |
11206 | if (entry->any) | |
11207 | vty_out (vty, " %s%s", | |
11208 | community_direct_str (entry->direct), VTY_NEWLINE); | |
11209 | else | |
11210 | vty_out (vty, " %s %s%s", | |
11211 | community_direct_str (entry->direct), | |
11212 | entry->style == COMMUNITY_LIST_STANDARD | |
11213 | ? community_str (entry->u.com) : entry->config, | |
11214 | VTY_NEWLINE); | |
11215 | } | |
11216 | } | |
11217 | ||
11218 | DEFUN (show_ip_community_list, | |
11219 | show_ip_community_list_cmd, | |
11220 | "show ip community-list", | |
11221 | SHOW_STR | |
11222 | IP_STR | |
11223 | "List community-list\n") | |
11224 | { | |
11225 | struct community_list *list; | |
11226 | struct community_list_master *cm; | |
11227 | ||
fee6e4e4 | 11228 | cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER); |
718e3744 | 11229 | if (! cm) |
11230 | return CMD_SUCCESS; | |
11231 | ||
11232 | for (list = cm->num.head; list; list = list->next) | |
11233 | community_list_show (vty, list); | |
11234 | ||
11235 | for (list = cm->str.head; list; list = list->next) | |
11236 | community_list_show (vty, list); | |
11237 | ||
11238 | return CMD_SUCCESS; | |
11239 | } | |
11240 | ||
11241 | DEFUN (show_ip_community_list_arg, | |
11242 | show_ip_community_list_arg_cmd, | |
6147e2c6 | 11243 | "show ip community-list <(1-500)|WORD>", |
718e3744 | 11244 | SHOW_STR |
11245 | IP_STR | |
11246 | "List community-list\n" | |
11247 | "Community-list number\n" | |
11248 | "Community-list name\n") | |
11249 | { | |
c500ae40 | 11250 | int idx_comm_list = 3; |
718e3744 | 11251 | struct community_list *list; |
11252 | ||
c500ae40 | 11253 | list = community_list_lookup (bgp_clist, argv[idx_comm_list]->arg, COMMUNITY_LIST_MASTER); |
718e3744 | 11254 | if (! list) |
11255 | { | |
b729294c | 11256 | vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE); |
718e3744 | 11257 | return CMD_WARNING; |
11258 | } | |
11259 | ||
11260 | community_list_show (vty, list); | |
11261 | ||
11262 | return CMD_SUCCESS; | |
11263 | } | |
6b0655a2 | 11264 | |
57d187bc JS |
11265 | /* |
11266 | * Large Community code. | |
11267 | */ | |
11268 | static int | |
11269 | lcommunity_list_set_vty (struct vty *vty, int argc, struct cmd_token **argv, | |
2acb4ac2 | 11270 | int style, int reject_all_digit_name) |
57d187bc JS |
11271 | { |
11272 | int ret; | |
11273 | int direct; | |
11274 | char *str; | |
11275 | int idx = 0; | |
11276 | char *cl_name; | |
11277 | ||
11278 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11279 | ||
11280 | /* All digit name check. */ | |
11281 | idx = 0; | |
11282 | argv_find (argv, argc, "WORD", &idx); | |
11283 | argv_find (argv, argc, "(1-99)", &idx); | |
11284 | argv_find (argv, argc, "(100-500)", &idx); | |
11285 | cl_name = argv[idx]->arg; | |
11286 | if (reject_all_digit_name && all_digit (cl_name)) | |
11287 | { | |
11288 | vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE); | |
11289 | return CMD_WARNING; | |
11290 | } | |
11291 | ||
11292 | argv_find (argv, argc, "AA:BB:CC", &idx); | |
11293 | argv_find (argv, argc, "LINE", &idx); | |
11294 | /* Concat community string argument. */ | |
11295 | if (idx) | |
11296 | str = argv_concat (argv, argc, idx); | |
11297 | else | |
11298 | str = NULL; | |
11299 | ||
11300 | ret = lcommunity_list_set (bgp_clist, cl_name, str, direct, style); | |
11301 | ||
11302 | /* Free temporary community list string allocated by | |
11303 | argv_concat(). */ | |
11304 | if (str) | |
11305 | XFREE (MTYPE_TMP, str); | |
11306 | ||
11307 | if (ret < 0) | |
11308 | { | |
11309 | community_list_perror (vty, ret); | |
11310 | return CMD_WARNING; | |
11311 | } | |
11312 | return CMD_SUCCESS; | |
11313 | } | |
11314 | ||
11315 | static int | |
11316 | lcommunity_list_unset_vty (struct vty *vty, int argc, struct cmd_token **argv, | |
2acb4ac2 | 11317 | int style) |
57d187bc JS |
11318 | { |
11319 | int ret; | |
11320 | int direct = 0; | |
11321 | char *str = NULL; | |
11322 | int idx = 0; | |
11323 | ||
11324 | argv_find (argv, argc, "permit", &idx); | |
11325 | argv_find (argv, argc, "deny", &idx); | |
11326 | ||
11327 | if (idx) | |
11328 | { | |
11329 | /* Check the list direct. */ | |
11330 | if (strncmp (argv[idx]->arg, "p", 1) == 0) | |
2acb4ac2 | 11331 | direct = COMMUNITY_PERMIT; |
57d187bc | 11332 | else |
2acb4ac2 | 11333 | direct = COMMUNITY_DENY; |
57d187bc JS |
11334 | |
11335 | idx = 0; | |
11336 | argv_find (argv, argc, "LINE", &idx); | |
11337 | argv_find (argv, argc, "AA:AA:NN", &idx); | |
11338 | /* Concat community string argument. */ | |
11339 | str = argv_concat (argv, argc, idx); | |
11340 | } | |
11341 | ||
11342 | idx = 0; | |
11343 | argv_find (argv, argc, "(1-99)", &idx); | |
11344 | argv_find (argv, argc, "(100-500)", &idx); | |
11345 | argv_find (argv, argc, "WORD", &idx); | |
11346 | ||
11347 | /* Unset community list. */ | |
11348 | ret = lcommunity_list_unset (bgp_clist, argv[idx]->arg, str, direct, style); | |
11349 | ||
11350 | /* Free temporary community list string allocated by | |
11351 | argv_concat(). */ | |
11352 | if (str) | |
11353 | XFREE (MTYPE_TMP, str); | |
11354 | ||
11355 | if (ret < 0) | |
11356 | { | |
11357 | community_list_perror (vty, ret); | |
11358 | return CMD_WARNING; | |
11359 | } | |
11360 | ||
11361 | return CMD_SUCCESS; | |
11362 | } | |
11363 | ||
11364 | /* "large-community-list" keyword help string. */ | |
11365 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
11366 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
11367 | ||
11368 | DEFUN (ip_lcommunity_list_standard, | |
11369 | ip_lcommunity_list_standard_cmd, | |
52951b63 DS |
11370 | "ip large-community-list (1-99) <deny|permit>", |
11371 | IP_STR | |
11372 | LCOMMUNITY_LIST_STR | |
11373 | "Large Community list number (standard)\n" | |
11374 | "Specify large community to reject\n" | |
11375 | "Specify large community to accept\n" | |
11376 | LCOMMUNITY_VAL_STR) | |
11377 | { | |
11378 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD, 0); | |
11379 | } | |
11380 | ||
11381 | DEFUN (ip_lcommunity_list_standard1, | |
11382 | ip_lcommunity_list_standard1_cmd, | |
11383 | "ip large-community-list (1-99) <deny|permit> AA:BB:CC...", | |
57d187bc JS |
11384 | IP_STR |
11385 | LCOMMUNITY_LIST_STR | |
11386 | "Large Community list number (standard)\n" | |
11387 | "Specify large community to reject\n" | |
11388 | "Specify large community to accept\n" | |
11389 | LCOMMUNITY_VAL_STR) | |
11390 | { | |
11391 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD, 0); | |
11392 | } | |
11393 | ||
11394 | DEFUN (ip_lcommunity_list_expanded, | |
11395 | ip_lcommunity_list_expanded_cmd, | |
11396 | "ip large-community-list (100-500) <deny|permit> LINE...", | |
11397 | IP_STR | |
11398 | LCOMMUNITY_LIST_STR | |
11399 | "Large Community list number (expanded)\n" | |
11400 | "Specify large community to reject\n" | |
11401 | "Specify large community to accept\n" | |
11402 | "An ordered list as a regular-expression\n") | |
11403 | { | |
11404 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED, 0); | |
11405 | } | |
11406 | ||
11407 | DEFUN (ip_lcommunity_list_name_standard, | |
11408 | ip_lcommunity_list_name_standard_cmd, | |
52951b63 DS |
11409 | "ip large-community-list standard WORD <deny|permit>", |
11410 | IP_STR | |
11411 | LCOMMUNITY_LIST_STR | |
11412 | "Specify standard large-community-list\n" | |
11413 | "Large Community list name\n" | |
11414 | "Specify large community to reject\n" | |
11415 | "Specify large community to accept\n") | |
11416 | { | |
11417 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD, 1); | |
11418 | } | |
11419 | ||
11420 | DEFUN (ip_lcommunity_list_name_standard1, | |
11421 | ip_lcommunity_list_name_standard1_cmd, | |
11422 | "ip large-community-list standard WORD <deny|permit> AA:BB:CC...", | |
57d187bc JS |
11423 | IP_STR |
11424 | LCOMMUNITY_LIST_STR | |
11425 | "Specify standard large-community-list\n" | |
11426 | "Large Community list name\n" | |
11427 | "Specify large community to reject\n" | |
11428 | "Specify large community to accept\n" | |
11429 | LCOMMUNITY_VAL_STR) | |
11430 | { | |
11431 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD, 1); | |
11432 | } | |
11433 | ||
11434 | DEFUN (ip_lcommunity_list_name_expanded, | |
11435 | ip_lcommunity_list_name_expanded_cmd, | |
11436 | "ip large-community-list expanded WORD <deny|permit> LINE...", | |
11437 | IP_STR | |
11438 | LCOMMUNITY_LIST_STR | |
11439 | "Specify expanded large-community-list\n" | |
11440 | "Large Community list name\n" | |
11441 | "Specify large community to reject\n" | |
11442 | "Specify large community to accept\n" | |
11443 | "An ordered list as a regular-expression\n") | |
11444 | { | |
11445 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED, 1); | |
11446 | } | |
11447 | ||
11448 | DEFUN (no_ip_lcommunity_list_standard_all, | |
11449 | no_ip_lcommunity_list_standard_all_cmd, | |
11450 | "no ip large-community-list <(1-99)|(100-500)|WORD>", | |
11451 | NO_STR | |
11452 | IP_STR | |
11453 | LCOMMUNITY_LIST_STR | |
11454 | "Large Community list number (standard)\n" | |
11455 | "Large Community list number (expanded)\n" | |
11456 | "Large Community list name\n") | |
11457 | { | |
11458 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD); | |
11459 | } | |
11460 | ||
11461 | DEFUN (no_ip_lcommunity_list_name_expanded_all, | |
11462 | no_ip_lcommunity_list_name_expanded_all_cmd, | |
11463 | "no ip large-community-list expanded WORD", | |
11464 | NO_STR | |
11465 | IP_STR | |
11466 | LCOMMUNITY_LIST_STR | |
11467 | "Specify expanded large-community-list\n" | |
11468 | "Large Community list name\n") | |
11469 | { | |
11470 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED); | |
11471 | } | |
11472 | ||
11473 | DEFUN (no_ip_lcommunity_list_standard, | |
11474 | no_ip_lcommunity_list_standard_cmd, | |
11475 | "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...", | |
11476 | NO_STR | |
11477 | IP_STR | |
11478 | LCOMMUNITY_LIST_STR | |
11479 | "Large Community list number (standard)\n" | |
11480 | "Specify large community to reject\n" | |
11481 | "Specify large community to accept\n" | |
11482 | LCOMMUNITY_VAL_STR) | |
11483 | { | |
11484 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD); | |
11485 | } | |
11486 | ||
11487 | DEFUN (no_ip_lcommunity_list_expanded, | |
11488 | no_ip_lcommunity_list_expanded_cmd, | |
11489 | "no ip large-community-list (100-500) <deny|permit> LINE...", | |
11490 | NO_STR | |
11491 | IP_STR | |
11492 | LCOMMUNITY_LIST_STR | |
11493 | "Large Community list number (expanded)\n" | |
11494 | "Specify large community to reject\n" | |
11495 | "Specify large community to accept\n" | |
11496 | "An ordered list as a regular-expression\n") | |
11497 | { | |
11498 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED); | |
11499 | } | |
11500 | ||
11501 | DEFUN (no_ip_lcommunity_list_name_standard, | |
11502 | no_ip_lcommunity_list_name_standard_cmd, | |
11503 | "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...", | |
11504 | NO_STR | |
11505 | IP_STR | |
11506 | LCOMMUNITY_LIST_STR | |
11507 | "Specify standard large-community-list\n" | |
11508 | "Large Community list name\n" | |
11509 | "Specify large community to reject\n" | |
11510 | "Specify large community to accept\n" | |
11511 | LCOMMUNITY_VAL_STR) | |
11512 | { | |
11513 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD); | |
11514 | } | |
11515 | ||
11516 | DEFUN (no_ip_lcommunity_list_name_expanded, | |
11517 | no_ip_lcommunity_list_name_expanded_cmd, | |
11518 | "no ip large-community-list expanded WORD <deny|permit> LINE...", | |
11519 | NO_STR | |
11520 | IP_STR | |
11521 | LCOMMUNITY_LIST_STR | |
11522 | "Specify expanded large-community-list\n" | |
11523 | "Large community list name\n" | |
11524 | "Specify large community to reject\n" | |
11525 | "Specify large community to accept\n" | |
11526 | "An ordered list as a regular-expression\n") | |
11527 | { | |
11528 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED); | |
11529 | } | |
11530 | ||
11531 | static void | |
11532 | lcommunity_list_show (struct vty *vty, struct community_list *list) | |
11533 | { | |
11534 | struct community_entry *entry; | |
11535 | ||
11536 | for (entry = list->head; entry; entry = entry->next) | |
11537 | { | |
11538 | if (entry == list->head) | |
2acb4ac2 DL |
11539 | { |
11540 | if (all_digit (list->name)) | |
11541 | vty_out (vty, "Large community %s list %s%s", | |
11542 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
11543 | "standard" : "(expanded) access", | |
11544 | list->name, VTY_NEWLINE); | |
11545 | else | |
11546 | vty_out (vty, "Named large community %s list %s%s", | |
11547 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
11548 | "standard" : "expanded", | |
11549 | list->name, VTY_NEWLINE); | |
11550 | } | |
57d187bc | 11551 | if (entry->any) |
2acb4ac2 DL |
11552 | vty_out (vty, " %s%s", |
11553 | community_direct_str (entry->direct), VTY_NEWLINE); | |
57d187bc | 11554 | else |
2acb4ac2 DL |
11555 | vty_out (vty, " %s %s%s", |
11556 | community_direct_str (entry->direct), | |
11557 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
11558 | entry->u.ecom->str : entry->config, | |
11559 | VTY_NEWLINE); | |
57d187bc JS |
11560 | } |
11561 | } | |
11562 | ||
11563 | DEFUN (show_ip_lcommunity_list, | |
11564 | show_ip_lcommunity_list_cmd, | |
11565 | "show ip large-community-list", | |
11566 | SHOW_STR | |
11567 | IP_STR | |
11568 | "List large-community list\n") | |
11569 | { | |
11570 | struct community_list *list; | |
11571 | struct community_list_master *cm; | |
11572 | ||
11573 | cm = community_list_master_lookup (bgp_clist, LARGE_COMMUNITY_LIST_MASTER); | |
11574 | if (! cm) | |
11575 | return CMD_SUCCESS; | |
11576 | ||
11577 | for (list = cm->num.head; list; list = list->next) | |
11578 | lcommunity_list_show (vty, list); | |
11579 | ||
11580 | for (list = cm->str.head; list; list = list->next) | |
11581 | lcommunity_list_show (vty, list); | |
11582 | ||
11583 | return CMD_SUCCESS; | |
11584 | } | |
11585 | ||
11586 | DEFUN (show_ip_lcommunity_list_arg, | |
11587 | show_ip_lcommunity_list_arg_cmd, | |
11588 | "show ip large-community-list <(1-500)|WORD>", | |
11589 | SHOW_STR | |
11590 | IP_STR | |
11591 | "List large-community list\n" | |
11592 | "large-community-list number\n" | |
11593 | "large-community-list name\n") | |
11594 | { | |
11595 | struct community_list *list; | |
11596 | ||
11597 | list = community_list_lookup (bgp_clist, argv[3]->arg, LARGE_COMMUNITY_LIST_MASTER); | |
11598 | if (! list) | |
11599 | { | |
11600 | vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE); | |
11601 | return CMD_WARNING; | |
11602 | } | |
11603 | ||
11604 | lcommunity_list_show (vty, list); | |
11605 | ||
11606 | return CMD_SUCCESS; | |
11607 | } | |
11608 | ||
718e3744 | 11609 | /* "extcommunity-list" keyword help string. */ |
11610 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
11611 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
11612 | ||
11613 | DEFUN (ip_extcommunity_list_standard, | |
11614 | ip_extcommunity_list_standard_cmd, | |
e961923c | 11615 | "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 11616 | IP_STR |
11617 | EXTCOMMUNITY_LIST_STR | |
11618 | "Extended Community list number (standard)\n" | |
718e3744 | 11619 | "Specify standard extcommunity-list\n" |
5bf15956 | 11620 | "Community list name\n" |
718e3744 | 11621 | "Specify community to reject\n" |
11622 | "Specify community to accept\n" | |
11623 | EXTCOMMUNITY_VAL_STR) | |
11624 | { | |
42f914d4 QY |
11625 | int style = EXTCOMMUNITY_LIST_STANDARD; |
11626 | int direct = 0; | |
11627 | char *cl_number_or_name = NULL; | |
11628 | ||
11629 | int idx = 0; | |
11630 | argv_find (argv, argc, "(1-99)", &idx); | |
11631 | argv_find (argv, argc, "WORD", &idx); | |
11632 | cl_number_or_name = argv[idx]->arg; | |
11633 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11634 | argv_find (argv, argc, "AA:NN", &idx); | |
11635 | char *str = argv_concat (argv, argc, idx); | |
11636 | ||
11637 | int ret = extcommunity_list_set (bgp_clist, cl_number_or_name, str, direct, style); | |
11638 | ||
11639 | XFREE (MTYPE_TMP, str); | |
11640 | ||
11641 | if (ret < 0) | |
11642 | { | |
11643 | community_list_perror (vty, ret); | |
11644 | return CMD_WARNING; | |
11645 | } | |
11646 | ||
11647 | return CMD_SUCCESS; | |
718e3744 | 11648 | } |
11649 | ||
718e3744 | 11650 | DEFUN (ip_extcommunity_list_name_expanded, |
11651 | ip_extcommunity_list_name_expanded_cmd, | |
e961923c | 11652 | "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 11653 | IP_STR |
11654 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 11655 | "Extended Community list number (expanded)\n" |
718e3744 | 11656 | "Specify expanded extcommunity-list\n" |
11657 | "Extended Community list name\n" | |
11658 | "Specify community to reject\n" | |
11659 | "Specify community to accept\n" | |
11660 | "An ordered list as a regular-expression\n") | |
11661 | { | |
42f914d4 QY |
11662 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
11663 | int direct = 0; | |
11664 | char *cl_number_or_name = NULL; | |
11665 | ||
11666 | int idx = 0; | |
11667 | argv_find (argv, argc, "(100-500)", &idx); | |
11668 | argv_find (argv, argc, "WORD", &idx); | |
11669 | cl_number_or_name = argv[idx]->arg; | |
11670 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11671 | argv_find (argv, argc, "LINE", &idx); | |
11672 | char *str = argv_concat (argv, argc, idx); | |
11673 | ||
11674 | int ret = extcommunity_list_set (bgp_clist, cl_number_or_name, str, direct, style); | |
11675 | ||
11676 | XFREE (MTYPE_TMP, str); | |
11677 | ||
11678 | if (ret < 0) | |
11679 | { | |
11680 | community_list_perror (vty, ret); | |
11681 | return CMD_WARNING; | |
11682 | } | |
11683 | ||
11684 | return CMD_SUCCESS; | |
718e3744 | 11685 | } |
11686 | ||
fee6e4e4 | 11687 | DEFUN (no_ip_extcommunity_list_standard_all, |
11688 | no_ip_extcommunity_list_standard_all_cmd, | |
e961923c | 11689 | "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
813d4307 DW |
11690 | NO_STR |
11691 | IP_STR | |
11692 | EXTCOMMUNITY_LIST_STR | |
11693 | "Extended Community list number (standard)\n" | |
718e3744 | 11694 | "Specify standard extcommunity-list\n" |
5bf15956 | 11695 | "Community list name\n" |
718e3744 | 11696 | "Specify community to reject\n" |
11697 | "Specify community to accept\n" | |
11698 | EXTCOMMUNITY_VAL_STR) | |
11699 | { | |
42f914d4 QY |
11700 | int deleteall = 0; |
11701 | ||
11702 | int style = EXTCOMMUNITY_LIST_STANDARD; | |
11703 | int direct = 0; | |
11704 | char *cl_number_or_name = NULL; | |
11705 | ||
11706 | int idx = 0; | |
11707 | argv_find (argv, argc, "(1-99)", &idx); | |
11708 | argv_find (argv, argc, "WORD", &idx); | |
11709 | cl_number_or_name = argv[idx]->arg; | |
11710 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11711 | argv_find (argv, argc, "AA:NN", &idx); | |
11712 | char *str = argv_concat (argv, argc, idx); | |
11713 | ||
11714 | int ret = extcommunity_list_unset (bgp_clist, cl_number_or_name, str, direct, style, deleteall); | |
11715 | ||
11716 | XFREE (MTYPE_TMP, str); | |
11717 | ||
11718 | if (ret < 0) | |
11719 | { | |
11720 | community_list_perror (vty, ret); | |
11721 | return CMD_WARNING; | |
11722 | } | |
11723 | ||
11724 | return CMD_SUCCESS; | |
718e3744 | 11725 | } |
11726 | ||
5bf15956 DW |
11727 | DEFUN (no_ip_extcommunity_list_expanded_all, |
11728 | no_ip_extcommunity_list_expanded_all_cmd, | |
e961923c | 11729 | "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 11730 | NO_STR |
11731 | IP_STR | |
11732 | EXTCOMMUNITY_LIST_STR | |
11733 | "Extended Community list number (expanded)\n" | |
718e3744 | 11734 | "Specify expanded extcommunity-list\n" |
5bf15956 | 11735 | "Extended Community list name\n" |
718e3744 | 11736 | "Specify community to reject\n" |
11737 | "Specify community to accept\n" | |
11738 | "An ordered list as a regular-expression\n") | |
11739 | { | |
42f914d4 QY |
11740 | int deleteall = 0; |
11741 | ||
11742 | int style = EXTCOMMUNITY_LIST_EXPANDED; | |
11743 | int direct = 0; | |
11744 | char *cl_number_or_name = NULL; | |
11745 | ||
11746 | int idx = 0; | |
11747 | argv_find (argv, argc, "(100-500)", &idx); | |
11748 | argv_find (argv, argc, "WORD", &idx); | |
11749 | cl_number_or_name = argv[idx]->arg; | |
11750 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11751 | argv_find (argv, argc, "LINE", &idx); | |
11752 | char *str = argv_concat (argv, argc, idx); | |
11753 | ||
11754 | int ret = extcommunity_list_unset (bgp_clist, cl_number_or_name, str, direct, style, deleteall); | |
11755 | ||
11756 | XFREE (MTYPE_TMP, str); | |
11757 | ||
11758 | if (ret < 0) | |
11759 | { | |
11760 | community_list_perror (vty, ret); | |
11761 | return CMD_WARNING; | |
11762 | } | |
11763 | ||
11764 | return CMD_SUCCESS; | |
718e3744 | 11765 | } |
11766 | ||
94f2b392 | 11767 | static void |
718e3744 | 11768 | extcommunity_list_show (struct vty *vty, struct community_list *list) |
11769 | { | |
11770 | struct community_entry *entry; | |
11771 | ||
11772 | for (entry = list->head; entry; entry = entry->next) | |
11773 | { | |
11774 | if (entry == list->head) | |
11775 | { | |
11776 | if (all_digit (list->name)) | |
11777 | vty_out (vty, "Extended community %s list %s%s", | |
11778 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
11779 | "standard" : "(expanded) access", | |
11780 | list->name, VTY_NEWLINE); | |
11781 | else | |
11782 | vty_out (vty, "Named extended community %s list %s%s", | |
11783 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
11784 | "standard" : "expanded", | |
11785 | list->name, VTY_NEWLINE); | |
11786 | } | |
11787 | if (entry->any) | |
11788 | vty_out (vty, " %s%s", | |
11789 | community_direct_str (entry->direct), VTY_NEWLINE); | |
11790 | else | |
11791 | vty_out (vty, " %s %s%s", | |
11792 | community_direct_str (entry->direct), | |
11793 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
11794 | entry->u.ecom->str : entry->config, | |
11795 | VTY_NEWLINE); | |
11796 | } | |
11797 | } | |
11798 | ||
11799 | DEFUN (show_ip_extcommunity_list, | |
11800 | show_ip_extcommunity_list_cmd, | |
11801 | "show ip extcommunity-list", | |
11802 | SHOW_STR | |
11803 | IP_STR | |
11804 | "List extended-community list\n") | |
11805 | { | |
11806 | struct community_list *list; | |
11807 | struct community_list_master *cm; | |
11808 | ||
fee6e4e4 | 11809 | cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
718e3744 | 11810 | if (! cm) |
11811 | return CMD_SUCCESS; | |
11812 | ||
11813 | for (list = cm->num.head; list; list = list->next) | |
11814 | extcommunity_list_show (vty, list); | |
11815 | ||
11816 | for (list = cm->str.head; list; list = list->next) | |
11817 | extcommunity_list_show (vty, list); | |
11818 | ||
11819 | return CMD_SUCCESS; | |
11820 | } | |
11821 | ||
11822 | DEFUN (show_ip_extcommunity_list_arg, | |
11823 | show_ip_extcommunity_list_arg_cmd, | |
6147e2c6 | 11824 | "show ip extcommunity-list <(1-500)|WORD>", |
718e3744 | 11825 | SHOW_STR |
11826 | IP_STR | |
11827 | "List extended-community list\n" | |
11828 | "Extcommunity-list number\n" | |
11829 | "Extcommunity-list name\n") | |
11830 | { | |
c500ae40 | 11831 | int idx_comm_list = 3; |
718e3744 | 11832 | struct community_list *list; |
11833 | ||
c500ae40 | 11834 | list = community_list_lookup (bgp_clist, argv[idx_comm_list]->arg, EXTCOMMUNITY_LIST_MASTER); |
718e3744 | 11835 | if (! list) |
11836 | { | |
b729294c | 11837 | vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE); |
718e3744 | 11838 | return CMD_WARNING; |
11839 | } | |
11840 | ||
11841 | extcommunity_list_show (vty, list); | |
11842 | ||
11843 | return CMD_SUCCESS; | |
11844 | } | |
6b0655a2 | 11845 | |
718e3744 | 11846 | /* Return configuration string of community-list entry. */ |
fd79ac91 | 11847 | static const char * |
718e3744 | 11848 | community_list_config_str (struct community_entry *entry) |
11849 | { | |
fd79ac91 | 11850 | const char *str; |
718e3744 | 11851 | |
11852 | if (entry->any) | |
11853 | str = ""; | |
11854 | else | |
11855 | { | |
11856 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
11857 | str = community_str (entry->u.com); | |
11858 | else | |
11859 | str = entry->config; | |
11860 | } | |
11861 | return str; | |
11862 | } | |
11863 | ||
11864 | /* Display community-list and extcommunity-list configuration. */ | |
94f2b392 | 11865 | static int |
718e3744 | 11866 | community_list_config_write (struct vty *vty) |
11867 | { | |
11868 | struct community_list *list; | |
11869 | struct community_entry *entry; | |
11870 | struct community_list_master *cm; | |
11871 | int write = 0; | |
11872 | ||
11873 | /* Community-list. */ | |
fee6e4e4 | 11874 | cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER); |
718e3744 | 11875 | |
11876 | for (list = cm->num.head; list; list = list->next) | |
11877 | for (entry = list->head; entry; entry = entry->next) | |
11878 | { | |
fee6e4e4 | 11879 | vty_out (vty, "ip community-list %s %s %s%s", |
11880 | list->name, community_direct_str (entry->direct), | |
11881 | community_list_config_str (entry), | |
11882 | VTY_NEWLINE); | |
718e3744 | 11883 | write++; |
11884 | } | |
11885 | for (list = cm->str.head; list; list = list->next) | |
11886 | for (entry = list->head; entry; entry = entry->next) | |
11887 | { | |
11888 | vty_out (vty, "ip community-list %s %s %s %s%s", | |
11889 | entry->style == COMMUNITY_LIST_STANDARD | |
11890 | ? "standard" : "expanded", | |
11891 | list->name, community_direct_str (entry->direct), | |
11892 | community_list_config_str (entry), | |
11893 | VTY_NEWLINE); | |
11894 | write++; | |
11895 | } | |
11896 | ||
11897 | /* Extcommunity-list. */ | |
fee6e4e4 | 11898 | cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
718e3744 | 11899 | |
11900 | for (list = cm->num.head; list; list = list->next) | |
11901 | for (entry = list->head; entry; entry = entry->next) | |
11902 | { | |
fee6e4e4 | 11903 | vty_out (vty, "ip extcommunity-list %s %s %s%s", |
11904 | list->name, community_direct_str (entry->direct), | |
11905 | community_list_config_str (entry), VTY_NEWLINE); | |
718e3744 | 11906 | write++; |
11907 | } | |
11908 | for (list = cm->str.head; list; list = list->next) | |
11909 | for (entry = list->head; entry; entry = entry->next) | |
11910 | { | |
11911 | vty_out (vty, "ip extcommunity-list %s %s %s %s%s", | |
11912 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
11913 | ? "standard" : "expanded", | |
11914 | list->name, community_direct_str (entry->direct), | |
11915 | community_list_config_str (entry), VTY_NEWLINE); | |
11916 | write++; | |
11917 | } | |
57d187bc JS |
11918 | |
11919 | ||
11920 | /* lcommunity-list. */ | |
11921 | cm = community_list_master_lookup (bgp_clist, LARGE_COMMUNITY_LIST_MASTER); | |
11922 | ||
11923 | for (list = cm->num.head; list; list = list->next) | |
11924 | for (entry = list->head; entry; entry = entry->next) | |
11925 | { | |
2acb4ac2 DL |
11926 | vty_out (vty, "ip large-community-list %s %s %s%s", |
11927 | list->name, community_direct_str (entry->direct), | |
11928 | community_list_config_str (entry), VTY_NEWLINE); | |
11929 | write++; | |
57d187bc JS |
11930 | } |
11931 | for (list = cm->str.head; list; list = list->next) | |
11932 | for (entry = list->head; entry; entry = entry->next) | |
11933 | { | |
2acb4ac2 DL |
11934 | vty_out (vty, "ip large-community-list %s %s %s %s%s", |
11935 | entry->style == LARGE_COMMUNITY_LIST_STANDARD | |
11936 | ? "standard" : "expanded", | |
11937 | list->name, community_direct_str (entry->direct), | |
11938 | community_list_config_str (entry), VTY_NEWLINE); | |
11939 | write++; | |
57d187bc JS |
11940 | } |
11941 | ||
718e3744 | 11942 | return write; |
11943 | } | |
11944 | ||
7fc626de | 11945 | static struct cmd_node community_list_node = |
718e3744 | 11946 | { |
11947 | COMMUNITY_LIST_NODE, | |
11948 | "", | |
11949 | 1 /* Export to vtysh. */ | |
11950 | }; | |
11951 | ||
94f2b392 | 11952 | static void |
11953 | community_list_vty (void) | |
718e3744 | 11954 | { |
11955 | install_node (&community_list_node, community_list_config_write); | |
11956 | ||
11957 | /* Community-list. */ | |
718e3744 | 11958 | install_element (CONFIG_NODE, &ip_community_list_standard_cmd); |
d7d73ffc | 11959 | install_element (CONFIG_NODE, &ip_community_list_expanded_all_cmd); |
fee6e4e4 | 11960 | install_element (CONFIG_NODE, &no_ip_community_list_standard_all_cmd); |
11961 | install_element (CONFIG_NODE, &no_ip_community_list_expanded_all_cmd); | |
718e3744 | 11962 | install_element (VIEW_NODE, &show_ip_community_list_cmd); |
11963 | install_element (VIEW_NODE, &show_ip_community_list_arg_cmd); | |
718e3744 | 11964 | |
11965 | /* Extcommunity-list. */ | |
11966 | install_element (CONFIG_NODE, &ip_extcommunity_list_standard_cmd); | |
718e3744 | 11967 | install_element (CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd); |
fee6e4e4 | 11968 | install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd); |
11969 | install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd); | |
718e3744 | 11970 | install_element (VIEW_NODE, &show_ip_extcommunity_list_cmd); |
11971 | install_element (VIEW_NODE, &show_ip_extcommunity_list_arg_cmd); | |
57d187bc JS |
11972 | |
11973 | /* Large Community List */ | |
11974 | install_element (CONFIG_NODE, &ip_lcommunity_list_standard_cmd); | |
52951b63 | 11975 | install_element (CONFIG_NODE, &ip_lcommunity_list_standard1_cmd); |
57d187bc JS |
11976 | install_element (CONFIG_NODE, &ip_lcommunity_list_expanded_cmd); |
11977 | install_element (CONFIG_NODE, &ip_lcommunity_list_name_standard_cmd); | |
52951b63 | 11978 | install_element (CONFIG_NODE, &ip_lcommunity_list_name_standard1_cmd); |
57d187bc JS |
11979 | install_element (CONFIG_NODE, &ip_lcommunity_list_name_expanded_cmd); |
11980 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_standard_all_cmd); | |
11981 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_all_cmd); | |
11982 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_standard_cmd); | |
11983 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_expanded_cmd); | |
11984 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_name_standard_cmd); | |
11985 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_cmd); | |
11986 | install_element (VIEW_NODE, &show_ip_lcommunity_list_cmd); | |
11987 | install_element (VIEW_NODE, &show_ip_lcommunity_list_arg_cmd); | |
5bf15956 | 11988 | } |