]>
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 | 216 | /* |
f212a857 | 217 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 218 | * |
f212a857 DS |
219 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
220 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
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 | |
f212a857 | 241 | * bgp -> Pointer to the bgp data structure we need to fill in. |
7eeee51e DS |
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 |
f212a857 DS |
250 | bgp_vty_find_and_parse_afi_safi_bgp (struct vty *vty, struct cmd_token **argv, int argc, int *idx, |
251 | afi_t *afi, safi_t *safi, struct bgp **bgp) | |
af462945 DS |
252 | { |
253 | char *vrf_name = NULL; | |
254 | ||
b4898a38 DS |
255 | assert (afi); |
256 | assert (safi); | |
f212a857 | 257 | assert (bgp); |
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 | 266 | |
f212a857 DS |
267 | if (strmatch (vrf_name, "all")) |
268 | *bgp = NULL; | |
af462945 | 269 | else |
f212a857 DS |
270 | { |
271 | *bgp = bgp_lookup_by_name (vrf_name); | |
272 | if (!*bgp) | |
273 | { | |
274 | vty_out (vty, "View/Vrf specified is unknown: %s%s", vrf_name, VTY_NEWLINE); | |
275 | *idx = 0; | |
276 | return 0; | |
277 | } | |
278 | } | |
af462945 | 279 | } |
f212a857 | 280 | else |
af462945 | 281 | { |
f212a857 DS |
282 | *bgp = bgp_get_default (); |
283 | if (!*bgp) | |
284 | { | |
285 | vty_out (vty, "Unable to find default BGP instance%s", VTY_NEWLINE); | |
286 | *idx = 0; | |
287 | return 0; | |
288 | } | |
af462945 | 289 | } |
9317e17d | 290 | |
f212a857 DS |
291 | if (argv_find_and_parse_afi (argv, argc, idx, afi)) |
292 | argv_find_and_parse_safi (argv, argc, idx, safi); | |
293 | ||
9317e17d DS |
294 | *idx += 1; |
295 | return *idx; | |
af462945 DS |
296 | } |
297 | ||
94f2b392 | 298 | static int |
6aeb9e78 | 299 | peer_address_self_check (struct bgp *bgp, union sockunion *su) |
718e3744 | 300 | { |
301 | struct interface *ifp = NULL; | |
302 | ||
303 | if (su->sa.sa_family == AF_INET) | |
6aeb9e78 | 304 | ifp = if_lookup_by_ipv4_exact (&su->sin.sin_addr, bgp->vrf_id); |
718e3744 | 305 | else if (su->sa.sa_family == AF_INET6) |
f2345335 | 306 | ifp = if_lookup_by_ipv6_exact (&su->sin6.sin6_addr, |
6aeb9e78 | 307 | su->sin6.sin6_scope_id, bgp->vrf_id); |
718e3744 | 308 | |
309 | if (ifp) | |
310 | return 1; | |
311 | ||
312 | return 0; | |
313 | } | |
314 | ||
315 | /* Utility function for looking up peer from VTY. */ | |
f14e6fdb DS |
316 | /* This is used only for configuration, so disallow if attempted on |
317 | * a dynamic neighbor. | |
318 | */ | |
94f2b392 | 319 | static struct peer * |
fd79ac91 | 320 | peer_lookup_vty (struct vty *vty, const char *ip_str) |
718e3744 | 321 | { |
cdc2d765 | 322 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); |
718e3744 | 323 | int ret; |
718e3744 | 324 | union sockunion su; |
325 | struct peer *peer; | |
326 | ||
cdc2d765 DL |
327 | if (!bgp) { |
328 | return NULL; | |
329 | } | |
718e3744 | 330 | |
331 | ret = str2sockunion (ip_str, &su); | |
332 | if (ret < 0) | |
333 | { | |
a80beece DS |
334 | peer = peer_lookup_by_conf_if (bgp, ip_str); |
335 | if (!peer) | |
336 | { | |
04b6bdc0 DW |
337 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) == NULL) |
338 | { | |
339 | vty_out (vty, "%% Malformed address or name: %s%s", ip_str, VTY_NEWLINE); | |
340 | return NULL; | |
341 | } | |
a80beece | 342 | } |
718e3744 | 343 | } |
a80beece | 344 | else |
718e3744 | 345 | { |
a80beece DS |
346 | peer = peer_lookup (bgp, &su); |
347 | if (! peer) | |
348 | { | |
349 | vty_out (vty, "%% Specify remote-as or peer-group commands first%s", | |
350 | VTY_NEWLINE); | |
351 | return NULL; | |
352 | } | |
f14e6fdb DS |
353 | if (peer_dynamic_neighbor (peer)) |
354 | { | |
355 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
356 | VTY_NEWLINE); | |
357 | return NULL; | |
358 | } | |
359 | ||
718e3744 | 360 | } |
361 | return peer; | |
362 | } | |
363 | ||
364 | /* Utility function for looking up peer or peer group. */ | |
f14e6fdb DS |
365 | /* This is used only for configuration, so disallow if attempted on |
366 | * a dynamic neighbor. | |
367 | */ | |
c43ed2e4 | 368 | struct peer * |
fd79ac91 | 369 | peer_and_group_lookup_vty (struct vty *vty, const char *peer_str) |
718e3744 | 370 | { |
cdc2d765 | 371 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); |
718e3744 | 372 | int ret; |
718e3744 | 373 | union sockunion su; |
f14e6fdb DS |
374 | struct peer *peer = NULL; |
375 | struct peer_group *group = NULL; | |
718e3744 | 376 | |
cdc2d765 DL |
377 | if (!bgp) { |
378 | return NULL; | |
379 | } | |
718e3744 | 380 | |
381 | ret = str2sockunion (peer_str, &su); | |
382 | if (ret == 0) | |
383 | { | |
f14e6fdb | 384 | /* IP address, locate peer. */ |
718e3744 | 385 | peer = peer_lookup (bgp, &su); |
718e3744 | 386 | } |
387 | else | |
388 | { | |
f14e6fdb | 389 | /* Not IP, could match either peer configured on interface or a group. */ |
a80beece | 390 | peer = peer_lookup_by_conf_if (bgp, peer_str); |
f14e6fdb DS |
391 | if (!peer) |
392 | group = peer_group_lookup (bgp, peer_str); | |
393 | } | |
a80beece | 394 | |
f14e6fdb DS |
395 | if (peer) |
396 | { | |
397 | if (peer_dynamic_neighbor (peer)) | |
398 | { | |
399 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
400 | VTY_NEWLINE); | |
401 | return NULL; | |
402 | } | |
403 | ||
404 | return peer; | |
718e3744 | 405 | } |
406 | ||
f14e6fdb DS |
407 | if (group) |
408 | return group->conf; | |
409 | ||
718e3744 | 410 | vty_out (vty, "%% Specify remote-as or peer-group commands first%s", |
411 | VTY_NEWLINE); | |
412 | ||
413 | return NULL; | |
414 | } | |
415 | ||
c43ed2e4 | 416 | int |
718e3744 | 417 | bgp_vty_return (struct vty *vty, int ret) |
418 | { | |
fd79ac91 | 419 | const char *str = NULL; |
718e3744 | 420 | |
421 | switch (ret) | |
422 | { | |
423 | case BGP_ERR_INVALID_VALUE: | |
424 | str = "Invalid value"; | |
425 | break; | |
426 | case BGP_ERR_INVALID_FLAG: | |
427 | str = "Invalid flag"; | |
428 | break; | |
718e3744 | 429 | case BGP_ERR_PEER_GROUP_SHUTDOWN: |
430 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
431 | break; | |
718e3744 | 432 | case BGP_ERR_PEER_FLAG_CONFLICT: |
433 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
434 | break; | |
718e3744 | 435 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: |
436 | str = "Specify remote-as or peer-group remote AS first"; | |
437 | break; | |
438 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
439 | str = "Cannot change the peer-group. Deconfigure first"; | |
440 | break; | |
441 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
4c48cf63 | 442 | str = "Peer is not a member of this peer-group"; |
718e3744 | 443 | break; |
444 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
445 | str = "Prefix/distribute list can not co-exist"; | |
446 | break; | |
447 | case BGP_ERR_NOT_INTERNAL_PEER: | |
448 | str = "Invalid command. Not an internal neighbor"; | |
449 | break; | |
450 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
5000f21c | 451 | str = "remove-private-AS cannot be configured for IBGP peers"; |
718e3744 | 452 | break; |
453 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
454 | str = "Local-AS allowed only for EBGP peers"; | |
455 | break; | |
456 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
457 | str = "Cannot have local-as same as BGP AS number"; | |
458 | break; | |
0df7c91f PJ |
459 | case BGP_ERR_TCPSIG_FAILED: |
460 | str = "Error while applying TCP-Sig to session(s)"; | |
461 | break; | |
fa411a21 NH |
462 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: |
463 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
464 | break; | |
f5a4827d SH |
465 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: |
466 | str = "ttl-security only allowed for EBGP peers"; | |
467 | break; | |
c7122e14 DS |
468 | case BGP_ERR_AS_OVERRIDE: |
469 | str = "as-override cannot be configured for IBGP peers"; | |
470 | break; | |
f14e6fdb DS |
471 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: |
472 | str = "Invalid limit for number of dynamic neighbors"; | |
473 | break; | |
474 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
475 | str = "Dynamic neighbor listen range already exists"; | |
476 | break; | |
477 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
478 | str = "Operation not allowed on a dynamic neighbor"; | |
479 | break; | |
63fa10b5 QY |
480 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: |
481 | str = "Operation not allowed on a directly connected neighbor"; | |
482 | break; | |
718e3744 | 483 | } |
484 | if (str) | |
485 | { | |
486 | vty_out (vty, "%% %s%s", str, VTY_NEWLINE); | |
487 | return CMD_WARNING; | |
488 | } | |
489 | return CMD_SUCCESS; | |
490 | } | |
491 | ||
7aafcaca DS |
492 | /* BGP clear sort. */ |
493 | enum clear_sort | |
494 | { | |
495 | clear_all, | |
496 | clear_peer, | |
497 | clear_group, | |
498 | clear_external, | |
499 | clear_as | |
500 | }; | |
501 | ||
7aafcaca DS |
502 | static void |
503 | bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi, | |
504 | safi_t safi, int error) | |
505 | { | |
506 | switch (error) | |
507 | { | |
508 | case BGP_ERR_AF_UNCONFIGURED: | |
509 | vty_out (vty, | |
46f296b4 LB |
510 | "%%BGP: Enable %s address family for the neighbor %s%s", |
511 | afi_safi_print(afi, safi), peer->host, VTY_NEWLINE); | |
7aafcaca DS |
512 | break; |
513 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
514 | 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); | |
515 | break; | |
516 | default: | |
517 | break; | |
518 | } | |
519 | } | |
520 | ||
521 | /* `clear ip bgp' functions. */ | |
522 | static int | |
523 | bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, | |
524 | enum clear_sort sort,enum bgp_clear_type stype, const char *arg) | |
525 | { | |
526 | int ret; | |
527 | struct peer *peer; | |
528 | struct listnode *node, *nnode; | |
529 | ||
530 | /* Clear all neighbors. */ | |
531 | /* | |
532 | * Pass along pointer to next node to peer_clear() when walking all nodes | |
533 | * on the BGP instance as that may get freed if it is a doppelganger | |
534 | */ | |
535 | if (sort == clear_all) | |
536 | { | |
537 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
538 | { | |
539 | if (stype == BGP_CLEAR_SOFT_NONE) | |
540 | ret = peer_clear (peer, &nnode); | |
541 | else if (peer->afc[afi][safi]) | |
542 | ret = peer_clear_soft (peer, afi, safi, stype); | |
543 | else | |
544 | ret = 0; | |
545 | ||
546 | if (ret < 0) | |
547 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
548 | } | |
549 | ||
550 | /* This is to apply read-only mode on this clear. */ | |
551 | if (stype == BGP_CLEAR_SOFT_NONE) | |
552 | bgp->update_delay_over = 0; | |
553 | ||
554 | return CMD_SUCCESS; | |
555 | } | |
556 | ||
557 | /* Clear specified neighbors. */ | |
558 | if (sort == clear_peer) | |
559 | { | |
560 | union sockunion su; | |
561 | int ret; | |
562 | ||
563 | /* Make sockunion for lookup. */ | |
564 | ret = str2sockunion (arg, &su); | |
565 | if (ret < 0) | |
566 | { | |
567 | peer = peer_lookup_by_conf_if (bgp, arg); | |
568 | if (!peer) | |
569 | { | |
04b6bdc0 DW |
570 | peer = peer_lookup_by_hostname(bgp, arg); |
571 | if (!peer) | |
572 | { | |
573 | vty_out (vty, "Malformed address or name: %s%s", arg, VTY_NEWLINE); | |
574 | return CMD_WARNING; | |
575 | } | |
7aafcaca DS |
576 | } |
577 | } | |
578 | else | |
579 | { | |
580 | peer = peer_lookup (bgp, &su); | |
581 | if (! peer) | |
582 | { | |
583 | vty_out (vty, "%%BGP: Unknown neighbor - \"%s\"%s", arg, VTY_NEWLINE); | |
584 | return CMD_WARNING; | |
585 | } | |
586 | } | |
587 | ||
588 | if (stype == BGP_CLEAR_SOFT_NONE) | |
589 | ret = peer_clear (peer, NULL); | |
590 | else | |
591 | ret = peer_clear_soft (peer, afi, safi, stype); | |
592 | ||
593 | if (ret < 0) | |
594 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
595 | ||
596 | return CMD_SUCCESS; | |
597 | } | |
598 | ||
599 | /* Clear all peer-group members. */ | |
600 | if (sort == clear_group) | |
601 | { | |
602 | struct peer_group *group; | |
603 | ||
604 | group = peer_group_lookup (bgp, arg); | |
605 | if (! group) | |
606 | { | |
607 | vty_out (vty, "%%BGP: No such peer-group %s%s", arg, VTY_NEWLINE); | |
608 | return CMD_WARNING; | |
609 | } | |
610 | ||
611 | for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) | |
612 | { | |
613 | if (stype == BGP_CLEAR_SOFT_NONE) | |
614 | { | |
18f1dc06 | 615 | peer_clear (peer, NULL); |
7aafcaca DS |
616 | continue; |
617 | } | |
618 | ||
c8560b44 | 619 | if (! peer->afc[afi][safi]) |
7aafcaca DS |
620 | continue; |
621 | ||
622 | ret = peer_clear_soft (peer, afi, safi, stype); | |
623 | ||
624 | if (ret < 0) | |
625 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
626 | } | |
627 | return CMD_SUCCESS; | |
628 | } | |
629 | ||
630 | if (sort == clear_external) | |
631 | { | |
632 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
633 | { | |
634 | if (peer->sort == BGP_PEER_IBGP) | |
635 | continue; | |
636 | ||
637 | if (stype == BGP_CLEAR_SOFT_NONE) | |
638 | ret = peer_clear (peer, &nnode); | |
639 | else | |
640 | ret = peer_clear_soft (peer, afi, safi, stype); | |
641 | ||
642 | if (ret < 0) | |
643 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
644 | } | |
645 | return CMD_SUCCESS; | |
646 | } | |
647 | ||
648 | if (sort == clear_as) | |
649 | { | |
650 | as_t as; | |
651 | int find = 0; | |
652 | ||
653 | VTY_GET_INTEGER_RANGE ("AS", as, arg, 1, BGP_AS4_MAX); | |
654 | ||
655 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
656 | { | |
657 | if (peer->as != as) | |
658 | continue; | |
659 | ||
660 | find = 1; | |
661 | if (stype == BGP_CLEAR_SOFT_NONE) | |
662 | ret = peer_clear (peer, &nnode); | |
663 | else | |
664 | ret = peer_clear_soft (peer, afi, safi, stype); | |
665 | ||
666 | if (ret < 0) | |
667 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
668 | } | |
669 | if (! find) | |
670 | vty_out (vty, "%%BGP: No peer is configured with AS %s%s", arg, | |
671 | VTY_NEWLINE); | |
672 | return CMD_SUCCESS; | |
673 | } | |
674 | ||
675 | return CMD_SUCCESS; | |
676 | } | |
677 | ||
678 | static int | |
679 | bgp_clear_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi, | |
680 | enum clear_sort sort, enum bgp_clear_type stype, | |
681 | const char *arg) | |
682 | { | |
683 | struct bgp *bgp; | |
684 | ||
685 | /* BGP structure lookup. */ | |
686 | if (name) | |
687 | { | |
688 | bgp = bgp_lookup_by_name (name); | |
689 | if (bgp == NULL) | |
690 | { | |
6aeb9e78 | 691 | vty_out (vty, "Can't find BGP instance %s%s", name, VTY_NEWLINE); |
7aafcaca DS |
692 | return CMD_WARNING; |
693 | } | |
694 | } | |
695 | else | |
696 | { | |
f31fa004 | 697 | bgp = bgp_get_default (); |
7aafcaca DS |
698 | if (bgp == NULL) |
699 | { | |
700 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
701 | return CMD_WARNING; | |
702 | } | |
703 | } | |
704 | ||
705 | return bgp_clear (vty, bgp, afi, safi, sort, stype, arg); | |
706 | } | |
707 | ||
708 | /* clear soft inbound */ | |
709 | static void | |
f31fa004 | 710 | bgp_clear_star_soft_in (struct vty *vty, const char *name) |
7aafcaca | 711 | { |
b09b5ae0 | 712 | bgp_clear_vty (vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
7aafcaca | 713 | BGP_CLEAR_SOFT_IN, NULL); |
f31fa004 | 714 | bgp_clear_vty (vty, name, AFI_IP6, SAFI_UNICAST, clear_all, |
7aafcaca | 715 | BGP_CLEAR_SOFT_IN, NULL); |
7aafcaca DS |
716 | } |
717 | ||
718 | /* clear soft outbound */ | |
719 | static void | |
f31fa004 | 720 | bgp_clear_star_soft_out (struct vty *vty, const char *name) |
7aafcaca | 721 | { |
f31fa004 | 722 | bgp_clear_vty (vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
7aafcaca | 723 | BGP_CLEAR_SOFT_OUT, NULL); |
f31fa004 | 724 | bgp_clear_vty (vty, name, AFI_IP6, SAFI_UNICAST, clear_all, |
7aafcaca | 725 | BGP_CLEAR_SOFT_OUT, NULL); |
7aafcaca DS |
726 | } |
727 | ||
728 | ||
718e3744 | 729 | /* BGP global configuration. */ |
730 | ||
731 | DEFUN (bgp_multiple_instance_func, | |
732 | bgp_multiple_instance_cmd, | |
733 | "bgp multiple-instance", | |
734 | BGP_STR | |
735 | "Enable bgp multiple instance\n") | |
736 | { | |
737 | bgp_option_set (BGP_OPT_MULTIPLE_INSTANCE); | |
738 | return CMD_SUCCESS; | |
739 | } | |
740 | ||
741 | DEFUN (no_bgp_multiple_instance, | |
742 | no_bgp_multiple_instance_cmd, | |
743 | "no bgp multiple-instance", | |
744 | NO_STR | |
745 | BGP_STR | |
746 | "BGP multiple instance\n") | |
747 | { | |
748 | int ret; | |
749 | ||
750 | ret = bgp_option_unset (BGP_OPT_MULTIPLE_INSTANCE); | |
751 | if (ret < 0) | |
752 | { | |
753 | vty_out (vty, "%% There are more than two BGP instances%s", VTY_NEWLINE); | |
754 | return CMD_WARNING; | |
755 | } | |
756 | return CMD_SUCCESS; | |
757 | } | |
758 | ||
759 | DEFUN (bgp_config_type, | |
760 | bgp_config_type_cmd, | |
6147e2c6 | 761 | "bgp config-type <cisco|zebra>", |
718e3744 | 762 | BGP_STR |
763 | "Configuration type\n" | |
764 | "cisco\n" | |
765 | "zebra\n") | |
766 | { | |
c500ae40 DW |
767 | int idx_vendor = 2; |
768 | if (strncmp (argv[idx_vendor]->arg, "c", 1) == 0) | |
718e3744 | 769 | bgp_option_set (BGP_OPT_CONFIG_CISCO); |
770 | else | |
771 | bgp_option_unset (BGP_OPT_CONFIG_CISCO); | |
772 | ||
773 | return CMD_SUCCESS; | |
774 | } | |
775 | ||
776 | DEFUN (no_bgp_config_type, | |
777 | no_bgp_config_type_cmd, | |
c7178fe7 | 778 | "no bgp config-type [<cisco|zebra>]", |
718e3744 | 779 | NO_STR |
780 | BGP_STR | |
838758ac DW |
781 | "Display configuration type\n" |
782 | "cisco\n" | |
783 | "zebra\n") | |
718e3744 | 784 | { |
785 | bgp_option_unset (BGP_OPT_CONFIG_CISCO); | |
786 | return CMD_SUCCESS; | |
787 | } | |
788 | ||
813d4307 | 789 | |
718e3744 | 790 | DEFUN (no_synchronization, |
791 | no_synchronization_cmd, | |
792 | "no synchronization", | |
793 | NO_STR | |
794 | "Perform IGP synchronization\n") | |
795 | { | |
796 | return CMD_SUCCESS; | |
797 | } | |
798 | ||
799 | DEFUN (no_auto_summary, | |
800 | no_auto_summary_cmd, | |
801 | "no auto-summary", | |
802 | NO_STR | |
803 | "Enable automatic network number summarization\n") | |
804 | { | |
805 | return CMD_SUCCESS; | |
806 | } | |
3d515fd9 | 807 | |
718e3744 | 808 | /* "router bgp" commands. */ |
505e5056 | 809 | DEFUN_NOSH (router_bgp, |
f412b39a | 810 | router_bgp_cmd, |
31500417 | 811 | "router bgp [(1-4294967295) [<view|vrf> WORD]]", |
718e3744 | 812 | ROUTER_STR |
813 | BGP_STR | |
31500417 DW |
814 | AS_STR |
815 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 816 | { |
31500417 DW |
817 | int idx_asn = 2; |
818 | int idx_view_vrf = 3; | |
819 | int idx_vrf = 4; | |
718e3744 | 820 | int ret; |
821 | as_t as; | |
822 | struct bgp *bgp; | |
fd79ac91 | 823 | const char *name = NULL; |
ad4cbda1 | 824 | enum bgp_instance_type inst_type; |
718e3744 | 825 | |
2385a876 | 826 | // "router bgp" without an ASN |
31500417 | 827 | if (argc == 2) |
2385a876 | 828 | { |
6aeb9e78 | 829 | //Pending: Make VRF option available for ASN less config |
2385a876 | 830 | bgp = bgp_get_default(); |
718e3744 | 831 | |
2385a876 DW |
832 | if (bgp == NULL) |
833 | { | |
834 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
835 | return CMD_WARNING; | |
836 | } | |
718e3744 | 837 | |
2385a876 DW |
838 | if (listcount(bm->bgp) > 1) |
839 | { | |
840 | vty_out (vty, "%% Multiple BGP processes are configured%s", VTY_NEWLINE); | |
841 | return CMD_WARNING; | |
842 | } | |
843 | } | |
844 | ||
845 | // "router bgp X" | |
846 | else | |
718e3744 | 847 | { |
31500417 | 848 | VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_asn]->arg, 1, BGP_AS4_MAX); |
2385a876 | 849 | |
ad4cbda1 | 850 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; |
31500417 | 851 | if (argc > 3) |
ad4cbda1 | 852 | { |
31500417 DW |
853 | name = argv[idx_vrf]->arg; |
854 | ||
e52702f2 | 855 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) |
ad4cbda1 | 856 | inst_type = BGP_INSTANCE_TYPE_VRF; |
e52702f2 | 857 | else if (!strcmp(argv[idx_view_vrf]->text, "view")) |
ad4cbda1 | 858 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
859 | } | |
2385a876 | 860 | |
ad4cbda1 | 861 | ret = bgp_get (&bgp, &as, name, inst_type); |
2385a876 DW |
862 | switch (ret) |
863 | { | |
864 | case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET: | |
865 | vty_out (vty, "Please specify 'bgp multiple-instance' first%s", | |
866 | VTY_NEWLINE); | |
867 | return CMD_WARNING; | |
868 | case BGP_ERR_AS_MISMATCH: | |
869 | vty_out (vty, "BGP is already running; AS is %u%s", as, VTY_NEWLINE); | |
870 | return CMD_WARNING; | |
871 | case BGP_ERR_INSTANCE_MISMATCH: | |
6aeb9e78 | 872 | vty_out (vty, "BGP instance name and AS number mismatch%s", VTY_NEWLINE); |
2385a876 DW |
873 | vty_out (vty, "BGP instance is already running; AS is %u%s", |
874 | as, VTY_NEWLINE); | |
875 | return CMD_WARNING; | |
876 | } | |
6aeb9e78 DS |
877 | |
878 | /* Pending: handle when user tries to change a view to vrf n vv. */ | |
718e3744 | 879 | } |
880 | ||
cdc2d765 | 881 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); |
718e3744 | 882 | |
883 | return CMD_SUCCESS; | |
884 | } | |
885 | ||
718e3744 | 886 | /* "no router bgp" commands. */ |
887 | DEFUN (no_router_bgp, | |
888 | no_router_bgp_cmd, | |
31500417 | 889 | "no router bgp [(1-4294967295) [<view|vrf> WORD]]", |
718e3744 | 890 | NO_STR |
891 | ROUTER_STR | |
892 | BGP_STR | |
31500417 DW |
893 | AS_STR |
894 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 895 | { |
31500417 | 896 | int idx_asn = 3; |
31500417 | 897 | int idx_vrf = 5; |
718e3744 | 898 | as_t as; |
899 | struct bgp *bgp; | |
fd79ac91 | 900 | const char *name = NULL; |
718e3744 | 901 | |
7fb21a9f | 902 | // "no router bgp" without an ASN |
31500417 | 903 | if (argc == 3) |
7fb21a9f QY |
904 | { |
905 | //Pending: Make VRF option available for ASN less config | |
906 | bgp = bgp_get_default(); | |
718e3744 | 907 | |
7fb21a9f QY |
908 | if (bgp == NULL) |
909 | { | |
910 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
911 | return CMD_WARNING; | |
912 | } | |
913 | ||
914 | if (listcount(bm->bgp) > 1) | |
915 | { | |
916 | vty_out (vty, "%% Multiple BGP processes are configured%s", VTY_NEWLINE); | |
917 | return CMD_WARNING; | |
918 | } | |
919 | } | |
920 | else | |
718e3744 | 921 | { |
31500417 | 922 | VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_asn]->arg, 1, BGP_AS4_MAX); |
7fb21a9f | 923 | |
31500417 DW |
924 | if (argc > 4) |
925 | name = argv[idx_vrf]->arg; | |
7fb21a9f QY |
926 | |
927 | /* Lookup bgp structure. */ | |
928 | bgp = bgp_lookup (as, name); | |
929 | if (! bgp) | |
930 | { | |
931 | vty_out (vty, "%% Can't find BGP instance%s", VTY_NEWLINE); | |
932 | return CMD_WARNING; | |
933 | } | |
718e3744 | 934 | } |
935 | ||
936 | bgp_delete (bgp); | |
937 | ||
938 | return CMD_SUCCESS; | |
939 | } | |
940 | ||
6b0655a2 | 941 | |
7fb21a9f | 942 | |
718e3744 | 943 | /* BGP router-id. */ |
944 | ||
945 | DEFUN (bgp_router_id, | |
946 | bgp_router_id_cmd, | |
947 | "bgp router-id A.B.C.D", | |
948 | BGP_STR | |
949 | "Override configured router identifier\n" | |
950 | "Manually configured router identifier\n") | |
951 | { | |
cdc2d765 | 952 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 953 | int idx_ipv4 = 2; |
718e3744 | 954 | int ret; |
955 | struct in_addr id; | |
718e3744 | 956 | |
c500ae40 | 957 | ret = inet_aton (argv[idx_ipv4]->arg, &id); |
718e3744 | 958 | if (! ret) |
959 | { | |
960 | vty_out (vty, "%% Malformed bgp router identifier%s", VTY_NEWLINE); | |
961 | return CMD_WARNING; | |
962 | } | |
963 | ||
0e6cb743 | 964 | bgp_router_id_static_set (bgp, id); |
718e3744 | 965 | |
966 | return CMD_SUCCESS; | |
967 | } | |
968 | ||
969 | DEFUN (no_bgp_router_id, | |
970 | no_bgp_router_id_cmd, | |
31500417 | 971 | "no bgp router-id [A.B.C.D]", |
718e3744 | 972 | NO_STR |
973 | BGP_STR | |
31500417 DW |
974 | "Override configured router identifier\n" |
975 | "Manually configured router identifier\n") | |
718e3744 | 976 | { |
cdc2d765 | 977 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
31500417 | 978 | int idx_router_id = 3; |
718e3744 | 979 | int ret; |
980 | struct in_addr id; | |
718e3744 | 981 | |
31500417 | 982 | if (argc > idx_router_id) |
718e3744 | 983 | { |
31500417 | 984 | ret = inet_aton (argv[idx_router_id]->arg, &id); |
718e3744 | 985 | if (! ret) |
e018c7cc SK |
986 | { |
987 | vty_out (vty, "%% Malformed BGP router identifier%s", VTY_NEWLINE); | |
988 | return CMD_WARNING; | |
989 | } | |
718e3744 | 990 | |
18a6dce6 | 991 | if (! IPV4_ADDR_SAME (&bgp->router_id_static, &id)) |
e018c7cc SK |
992 | { |
993 | vty_out (vty, "%% BGP router-id doesn't match%s", VTY_NEWLINE); | |
994 | return CMD_WARNING; | |
995 | } | |
718e3744 | 996 | } |
997 | ||
0e6cb743 DL |
998 | id.s_addr = 0; |
999 | bgp_router_id_static_set (bgp, id); | |
718e3744 | 1000 | |
1001 | return CMD_SUCCESS; | |
1002 | } | |
1003 | ||
6b0655a2 | 1004 | |
718e3744 | 1005 | /* BGP Cluster ID. */ |
718e3744 | 1006 | DEFUN (bgp_cluster_id, |
1007 | bgp_cluster_id_cmd, | |
838758ac | 1008 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", |
718e3744 | 1009 | BGP_STR |
1010 | "Configure Route-Reflector Cluster-id\n" | |
838758ac DW |
1011 | "Route-Reflector Cluster-id in IP address format\n" |
1012 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1013 | { |
cdc2d765 | 1014 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1015 | int idx_ipv4 = 2; |
718e3744 | 1016 | int ret; |
718e3744 | 1017 | struct in_addr cluster; |
1018 | ||
c500ae40 | 1019 | ret = inet_aton (argv[idx_ipv4]->arg, &cluster); |
718e3744 | 1020 | if (! ret) |
1021 | { | |
1022 | vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE); | |
1023 | return CMD_WARNING; | |
1024 | } | |
1025 | ||
1026 | bgp_cluster_id_set (bgp, &cluster); | |
f31fa004 | 1027 | bgp_clear_star_soft_out (vty, bgp->name); |
718e3744 | 1028 | |
1029 | return CMD_SUCCESS; | |
1030 | } | |
1031 | ||
718e3744 | 1032 | DEFUN (no_bgp_cluster_id, |
1033 | no_bgp_cluster_id_cmd, | |
c7178fe7 | 1034 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", |
718e3744 | 1035 | NO_STR |
1036 | BGP_STR | |
838758ac DW |
1037 | "Configure Route-Reflector Cluster-id\n" |
1038 | "Route-Reflector Cluster-id in IP address format\n" | |
1039 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1040 | { |
cdc2d765 | 1041 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1042 | bgp_cluster_id_unset (bgp); |
f31fa004 | 1043 | bgp_clear_star_soft_out (vty, bgp->name); |
718e3744 | 1044 | |
1045 | return CMD_SUCCESS; | |
1046 | } | |
1047 | ||
718e3744 | 1048 | DEFUN (bgp_confederation_identifier, |
1049 | bgp_confederation_identifier_cmd, | |
9ccf14f7 | 1050 | "bgp confederation identifier (1-4294967295)", |
718e3744 | 1051 | "BGP specific commands\n" |
1052 | "AS confederation parameters\n" | |
1053 | "AS number\n" | |
1054 | "Set routing domain confederation AS\n") | |
1055 | { | |
cdc2d765 | 1056 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1057 | int idx_number = 3; |
718e3744 | 1058 | as_t as; |
1059 | ||
c500ae40 | 1060 | VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); |
718e3744 | 1061 | |
1062 | bgp_confederation_id_set (bgp, as); | |
1063 | ||
1064 | return CMD_SUCCESS; | |
1065 | } | |
1066 | ||
1067 | DEFUN (no_bgp_confederation_identifier, | |
1068 | no_bgp_confederation_identifier_cmd, | |
838758ac | 1069 | "no bgp confederation identifier [(1-4294967295)]", |
718e3744 | 1070 | NO_STR |
1071 | "BGP specific commands\n" | |
1072 | "AS confederation parameters\n" | |
3a2d747c QY |
1073 | "AS number\n" |
1074 | "Set routing domain confederation AS\n") | |
718e3744 | 1075 | { |
cdc2d765 | 1076 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1077 | bgp_confederation_id_unset (bgp); |
1078 | ||
1079 | return CMD_SUCCESS; | |
1080 | } | |
1081 | ||
718e3744 | 1082 | DEFUN (bgp_confederation_peers, |
1083 | bgp_confederation_peers_cmd, | |
12dcf78e | 1084 | "bgp confederation peers (1-4294967295)...", |
718e3744 | 1085 | "BGP specific commands\n" |
1086 | "AS confederation parameters\n" | |
1087 | "Peer ASs in BGP confederation\n" | |
1088 | AS_STR) | |
1089 | { | |
cdc2d765 | 1090 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
58749582 | 1091 | int idx_asn = 3; |
718e3744 | 1092 | as_t as; |
1093 | int i; | |
1094 | ||
58749582 | 1095 | for (i = idx_asn; i < argc; i++) |
718e3744 | 1096 | { |
afec25d9 | 1097 | VTY_GET_INTEGER_RANGE ("AS", as, argv[i]->arg, 1, BGP_AS4_MAX); |
718e3744 | 1098 | |
1099 | if (bgp->as == as) | |
1100 | { | |
1101 | vty_out (vty, "%% Local member-AS not allowed in confed peer list%s", | |
1102 | VTY_NEWLINE); | |
1103 | continue; | |
1104 | } | |
1105 | ||
1106 | bgp_confederation_peers_add (bgp, as); | |
1107 | } | |
1108 | return CMD_SUCCESS; | |
1109 | } | |
1110 | ||
1111 | DEFUN (no_bgp_confederation_peers, | |
1112 | no_bgp_confederation_peers_cmd, | |
e83a9414 | 1113 | "no bgp confederation peers (1-4294967295)...", |
718e3744 | 1114 | NO_STR |
1115 | "BGP specific commands\n" | |
1116 | "AS confederation parameters\n" | |
1117 | "Peer ASs in BGP confederation\n" | |
1118 | AS_STR) | |
1119 | { | |
cdc2d765 | 1120 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
58749582 | 1121 | int idx_asn = 4; |
718e3744 | 1122 | as_t as; |
1123 | int i; | |
1124 | ||
58749582 | 1125 | for (i = idx_asn; i < argc; i++) |
718e3744 | 1126 | { |
afec25d9 | 1127 | VTY_GET_INTEGER_RANGE ("AS", as, argv[i]->arg, 1, BGP_AS4_MAX); |
0b2aa3a0 | 1128 | |
718e3744 | 1129 | bgp_confederation_peers_remove (bgp, as); |
1130 | } | |
1131 | return CMD_SUCCESS; | |
1132 | } | |
6b0655a2 | 1133 | |
5e242b0d DS |
1134 | /** |
1135 | * Central routine for maximum-paths configuration. | |
1136 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1137 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1138 | */ | |
ffd0c037 DS |
1139 | static int |
1140 | bgp_maxpaths_config_vty (struct vty *vty, int peer_type, const char *mpaths, | |
5e242b0d | 1141 | u_int16_t options, int set) |
165b5fff | 1142 | { |
cdc2d765 | 1143 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4c9dee98 | 1144 | u_int16_t maxpaths = 0; |
165b5fff | 1145 | int ret; |
5e242b0d DS |
1146 | afi_t afi; |
1147 | safi_t safi; | |
165b5fff | 1148 | |
5e242b0d DS |
1149 | afi = bgp_node_afi (vty); |
1150 | safi = bgp_node_safi (vty); | |
165b5fff | 1151 | |
5e242b0d | 1152 | if (set) |
4c9dee98 | 1153 | { |
c59f2066 | 1154 | maxpaths = strtol(mpaths, NULL, 10); |
37fe7731 DS |
1155 | if (maxpaths > multipath_num) |
1156 | { | |
1157 | vty_out (vty, | |
1158 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", | |
1159 | maxpaths, multipath_num); | |
1160 | return CMD_WARNING; | |
1161 | } | |
dff6764a | 1162 | ret = bgp_maximum_paths_set (bgp, afi, safi, peer_type, maxpaths, options); |
4c9dee98 | 1163 | } |
5e242b0d DS |
1164 | else |
1165 | ret = bgp_maximum_paths_unset (bgp, afi, safi, peer_type); | |
165b5fff | 1166 | |
165b5fff JB |
1167 | if (ret < 0) |
1168 | { | |
1169 | vty_out (vty, | |
5e242b0d DS |
1170 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u%s", |
1171 | (set == 1) ? "" : "un", | |
1172 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1173 | maxpaths, afi, safi, VTY_NEWLINE); | |
165b5fff JB |
1174 | return CMD_WARNING; |
1175 | } | |
1176 | ||
7aafcaca DS |
1177 | bgp_recalculate_all_bestpaths (bgp); |
1178 | ||
165b5fff JB |
1179 | return CMD_SUCCESS; |
1180 | } | |
1181 | ||
abc920f8 DS |
1182 | DEFUN (bgp_maxmed_admin, |
1183 | bgp_maxmed_admin_cmd, | |
1184 | "bgp max-med administrative ", | |
1185 | BGP_STR | |
1186 | "Advertise routes with max-med\n" | |
1187 | "Administratively applied, for an indefinite period\n") | |
1188 | { | |
cdc2d765 | 1189 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 DS |
1190 | |
1191 | bgp->v_maxmed_admin = 1; | |
1192 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1193 | ||
1194 | bgp_maxmed_update(bgp); | |
1195 | ||
1196 | return CMD_SUCCESS; | |
1197 | } | |
1198 | ||
1199 | DEFUN (bgp_maxmed_admin_medv, | |
1200 | bgp_maxmed_admin_medv_cmd, | |
6147e2c6 | 1201 | "bgp max-med administrative (0-4294967294)", |
abc920f8 DS |
1202 | BGP_STR |
1203 | "Advertise routes with max-med\n" | |
1204 | "Administratively applied, for an indefinite period\n" | |
1205 | "Max MED value to be used\n") | |
1206 | { | |
cdc2d765 | 1207 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1208 | int idx_number = 3; |
abc920f8 DS |
1209 | |
1210 | bgp->v_maxmed_admin = 1; | |
c500ae40 | 1211 | VTY_GET_INTEGER ("max-med admin med-value", bgp->maxmed_admin_value, argv[idx_number]->arg); |
abc920f8 DS |
1212 | |
1213 | bgp_maxmed_update(bgp); | |
1214 | ||
1215 | return CMD_SUCCESS; | |
1216 | } | |
1217 | ||
1218 | DEFUN (no_bgp_maxmed_admin, | |
1219 | no_bgp_maxmed_admin_cmd, | |
8334fd5a | 1220 | "no bgp max-med administrative [(0-4294967294)]", |
abc920f8 DS |
1221 | NO_STR |
1222 | BGP_STR | |
1223 | "Advertise routes with max-med\n" | |
838758ac DW |
1224 | "Administratively applied, for an indefinite period\n" |
1225 | "Max MED value to be used\n") | |
abc920f8 | 1226 | { |
cdc2d765 | 1227 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 DS |
1228 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; |
1229 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 DS |
1230 | bgp_maxmed_update(bgp); |
1231 | ||
1232 | return CMD_SUCCESS; | |
1233 | } | |
1234 | ||
abc920f8 DS |
1235 | DEFUN (bgp_maxmed_onstartup, |
1236 | bgp_maxmed_onstartup_cmd, | |
6147e2c6 | 1237 | "bgp max-med on-startup (5-86400)", |
abc920f8 DS |
1238 | BGP_STR |
1239 | "Advertise routes with max-med\n" | |
1240 | "Effective on a startup\n" | |
1241 | "Time (seconds) period for max-med\n") | |
1242 | { | |
cdc2d765 | 1243 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1244 | int idx_number = 3; |
c500ae40 | 1245 | VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[idx_number]->arg); |
abc920f8 | 1246 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; |
abc920f8 DS |
1247 | bgp_maxmed_update(bgp); |
1248 | ||
1249 | return CMD_SUCCESS; | |
1250 | } | |
1251 | ||
1252 | DEFUN (bgp_maxmed_onstartup_medv, | |
1253 | bgp_maxmed_onstartup_medv_cmd, | |
6147e2c6 | 1254 | "bgp max-med on-startup (5-86400) (0-4294967294)", |
abc920f8 DS |
1255 | BGP_STR |
1256 | "Advertise routes with max-med\n" | |
1257 | "Effective on a startup\n" | |
1258 | "Time (seconds) period for max-med\n" | |
1259 | "Max MED value to be used\n") | |
1260 | { | |
cdc2d765 | 1261 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
1262 | int idx_number = 3; |
1263 | int idx_number_2 = 4; | |
c500ae40 DW |
1264 | VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[idx_number]->arg); |
1265 | VTY_GET_INTEGER ("max-med on-startup med-value", bgp->maxmed_onstartup_value, argv[idx_number_2]->arg); | |
abc920f8 DS |
1266 | bgp_maxmed_update(bgp); |
1267 | ||
1268 | return CMD_SUCCESS; | |
1269 | } | |
1270 | ||
1271 | DEFUN (no_bgp_maxmed_onstartup, | |
1272 | no_bgp_maxmed_onstartup_cmd, | |
8334fd5a | 1273 | "no bgp max-med on-startup [(5-86400) [(0-4294967294)]]", |
abc920f8 DS |
1274 | NO_STR |
1275 | BGP_STR | |
1276 | "Advertise routes with max-med\n" | |
838758ac DW |
1277 | "Effective on a startup\n" |
1278 | "Time (seconds) period for max-med\n" | |
1279 | "Max MED value to be used\n") | |
abc920f8 | 1280 | { |
cdc2d765 | 1281 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 DS |
1282 | |
1283 | /* Cancel max-med onstartup if its on */ | |
1284 | if (bgp->t_maxmed_onstartup) | |
1285 | { | |
1286 | THREAD_TIMER_OFF (bgp->t_maxmed_onstartup); | |
1287 | bgp->maxmed_onstartup_over = 1; | |
1288 | } | |
1289 | ||
1290 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; | |
1291 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
1292 | ||
1293 | bgp_maxmed_update(bgp); | |
1294 | ||
1295 | return CMD_SUCCESS; | |
1296 | } | |
1297 | ||
f188f2c4 DS |
1298 | static int |
1299 | bgp_update_delay_config_vty (struct vty *vty, const char *delay, | |
1300 | const char *wait) | |
1301 | { | |
cdc2d765 | 1302 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 DS |
1303 | u_int16_t update_delay; |
1304 | u_int16_t establish_wait; | |
1305 | ||
f188f2c4 DS |
1306 | VTY_GET_INTEGER_RANGE ("update-delay", update_delay, delay, |
1307 | BGP_UPDATE_DELAY_MIN, BGP_UPDATE_DELAY_MAX); | |
1308 | ||
1309 | if (!wait) /* update-delay <delay> */ | |
1310 | { | |
1311 | bgp->v_update_delay = update_delay; | |
1312 | bgp->v_establish_wait = bgp->v_update_delay; | |
1313 | return CMD_SUCCESS; | |
1314 | } | |
1315 | ||
1316 | /* update-delay <delay> <establish-wait> */ | |
1317 | establish_wait = atoi (wait); | |
1318 | if (update_delay < establish_wait) | |
1319 | { | |
1320 | vty_out (vty, "%%Failed: update-delay less than the establish-wait!%s", | |
1321 | VTY_NEWLINE); | |
1322 | return CMD_WARNING; | |
1323 | } | |
1324 | ||
1325 | bgp->v_update_delay = update_delay; | |
1326 | bgp->v_establish_wait = establish_wait; | |
1327 | ||
1328 | return CMD_SUCCESS; | |
1329 | } | |
1330 | ||
1331 | static int | |
1332 | bgp_update_delay_deconfig_vty (struct vty *vty) | |
1333 | { | |
cdc2d765 | 1334 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 DS |
1335 | |
1336 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; | |
1337 | bgp->v_establish_wait = bgp->v_update_delay; | |
1338 | ||
1339 | return CMD_SUCCESS; | |
1340 | } | |
1341 | ||
1342 | int | |
1343 | bgp_config_write_update_delay (struct vty *vty, struct bgp *bgp) | |
1344 | { | |
1345 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) | |
1346 | { | |
1347 | vty_out (vty, " update-delay %d", bgp->v_update_delay); | |
1348 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1349 | vty_out (vty, " %d", bgp->v_establish_wait); | |
1350 | vty_out (vty, "%s", VTY_NEWLINE); | |
1351 | } | |
1352 | ||
1353 | return 0; | |
1354 | } | |
1355 | ||
1356 | ||
1357 | /* Update-delay configuration */ | |
1358 | DEFUN (bgp_update_delay, | |
1359 | bgp_update_delay_cmd, | |
6147e2c6 | 1360 | "update-delay (0-3600)", |
f188f2c4 DS |
1361 | "Force initial delay for best-path and updates\n" |
1362 | "Seconds\n") | |
1363 | { | |
c500ae40 DW |
1364 | int idx_number = 1; |
1365 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); | |
f188f2c4 DS |
1366 | } |
1367 | ||
1368 | DEFUN (bgp_update_delay_establish_wait, | |
1369 | bgp_update_delay_establish_wait_cmd, | |
6147e2c6 | 1370 | "update-delay (0-3600) (1-3600)", |
f188f2c4 DS |
1371 | "Force initial delay for best-path and updates\n" |
1372 | "Seconds\n" | |
1373 | "Wait for peers to be established\n" | |
1374 | "Seconds\n") | |
1375 | { | |
c500ae40 DW |
1376 | int idx_number = 1; |
1377 | int idx_number_2 = 2; | |
1378 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, argv[idx_number_2]->arg); | |
f188f2c4 DS |
1379 | } |
1380 | ||
1381 | /* Update-delay deconfiguration */ | |
1382 | DEFUN (no_bgp_update_delay, | |
1383 | no_bgp_update_delay_cmd, | |
838758ac DW |
1384 | "no update-delay [(0-3600) [(1-3600)]]", |
1385 | NO_STR | |
f188f2c4 | 1386 | "Force initial delay for best-path and updates\n" |
838758ac DW |
1387 | "Seconds\n" |
1388 | "Wait for peers to be established\n") | |
f188f2c4 DS |
1389 | { |
1390 | return bgp_update_delay_deconfig_vty(vty); | |
1391 | } | |
1392 | ||
5e242b0d | 1393 | |
ffd0c037 DS |
1394 | static int |
1395 | bgp_wpkt_quanta_config_vty (struct vty *vty, const char *num, char set) | |
cb1faec9 | 1396 | { |
cdc2d765 | 1397 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
cb1faec9 DS |
1398 | |
1399 | if (set) | |
1400 | VTY_GET_INTEGER_RANGE ("write-quanta", bgp->wpkt_quanta, num, | |
4543bbb4 | 1401 | 1, 10000); |
cb1faec9 DS |
1402 | else |
1403 | bgp->wpkt_quanta = BGP_WRITE_PACKET_MAX; | |
1404 | ||
1405 | return CMD_SUCCESS; | |
1406 | } | |
1407 | ||
1408 | int | |
1409 | bgp_config_write_wpkt_quanta (struct vty *vty, struct bgp *bgp) | |
1410 | { | |
1411 | if (bgp->wpkt_quanta != BGP_WRITE_PACKET_MAX) | |
1412 | vty_out (vty, " write-quanta %d%s", | |
1413 | bgp->wpkt_quanta, VTY_NEWLINE); | |
1414 | ||
1415 | return 0; | |
1416 | } | |
1417 | ||
1418 | ||
1419 | /* Update-delay configuration */ | |
1420 | DEFUN (bgp_wpkt_quanta, | |
1421 | bgp_wpkt_quanta_cmd, | |
6147e2c6 | 1422 | "write-quanta (1-10000)", |
cb1faec9 DS |
1423 | "How many packets to write to peer socket per run\n" |
1424 | "Number of packets\n") | |
1425 | { | |
c500ae40 DW |
1426 | int idx_number = 1; |
1427 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
cb1faec9 DS |
1428 | } |
1429 | ||
1430 | /* Update-delay deconfiguration */ | |
1431 | DEFUN (no_bgp_wpkt_quanta, | |
1432 | no_bgp_wpkt_quanta_cmd, | |
6147e2c6 | 1433 | "no write-quanta (1-10000)", |
d7fa34c1 | 1434 | NO_STR |
cb1faec9 DS |
1435 | "How many packets to write to peer socket per run\n" |
1436 | "Number of packets\n") | |
1437 | { | |
c500ae40 DW |
1438 | int idx_number = 2; |
1439 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
cb1faec9 DS |
1440 | } |
1441 | ||
ffd0c037 | 1442 | static int |
3f9c7369 DS |
1443 | bgp_coalesce_config_vty (struct vty *vty, const char *num, char set) |
1444 | { | |
cdc2d765 | 1445 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3f9c7369 DS |
1446 | |
1447 | if (set) | |
1448 | VTY_GET_INTEGER_RANGE ("coalesce-time", bgp->coalesce_time, num, | |
1449 | 0, 4294967295); | |
1450 | else | |
1451 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; | |
1452 | ||
1453 | return CMD_SUCCESS; | |
1454 | } | |
1455 | ||
1456 | int | |
1457 | bgp_config_write_coalesce_time (struct vty *vty, struct bgp *bgp) | |
1458 | { | |
1459 | if (bgp->coalesce_time != BGP_DEFAULT_SUBGROUP_COALESCE_TIME) | |
1460 | vty_out (vty, " coalesce-time %d%s", | |
1461 | bgp->coalesce_time, VTY_NEWLINE); | |
1462 | ||
1463 | return 0; | |
1464 | } | |
1465 | ||
1466 | ||
1467 | DEFUN (bgp_coalesce_time, | |
1468 | bgp_coalesce_time_cmd, | |
6147e2c6 | 1469 | "coalesce-time (0-4294967295)", |
3f9c7369 DS |
1470 | "Subgroup coalesce timer\n" |
1471 | "Subgroup coalesce timer value (in ms)\n") | |
1472 | { | |
c500ae40 DW |
1473 | int idx_number = 1; |
1474 | return bgp_coalesce_config_vty(vty, argv[idx_number]->arg, 1); | |
3f9c7369 DS |
1475 | } |
1476 | ||
1477 | DEFUN (no_bgp_coalesce_time, | |
1478 | no_bgp_coalesce_time_cmd, | |
6147e2c6 | 1479 | "no coalesce-time (0-4294967295)", |
3a2d747c | 1480 | NO_STR |
3f9c7369 DS |
1481 | "Subgroup coalesce timer\n" |
1482 | "Subgroup coalesce timer value (in ms)\n") | |
1483 | { | |
c500ae40 DW |
1484 | int idx_number = 2; |
1485 | return bgp_coalesce_config_vty(vty, argv[idx_number]->arg, 0); | |
3f9c7369 DS |
1486 | } |
1487 | ||
5e242b0d DS |
1488 | /* Maximum-paths configuration */ |
1489 | DEFUN (bgp_maxpaths, | |
1490 | bgp_maxpaths_cmd, | |
9ccf14f7 | 1491 | "maximum-paths (1-255)", |
5e242b0d DS |
1492 | "Forward packets over multiple paths\n" |
1493 | "Number of paths\n") | |
1494 | { | |
c500ae40 DW |
1495 | int idx_number = 1; |
1496 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
1497 | } |
1498 | ||
165b5fff JB |
1499 | DEFUN (bgp_maxpaths_ibgp, |
1500 | bgp_maxpaths_ibgp_cmd, | |
9ccf14f7 | 1501 | "maximum-paths ibgp (1-255)", |
165b5fff JB |
1502 | "Forward packets over multiple paths\n" |
1503 | "iBGP-multipath\n" | |
1504 | "Number of paths\n") | |
1505 | { | |
c500ae40 DW |
1506 | int idx_number = 2; |
1507 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[idx_number]->arg, 0, 1); | |
5e242b0d | 1508 | } |
165b5fff | 1509 | |
5e242b0d DS |
1510 | DEFUN (bgp_maxpaths_ibgp_cluster, |
1511 | bgp_maxpaths_ibgp_cluster_cmd, | |
9ccf14f7 | 1512 | "maximum-paths ibgp (1-255) equal-cluster-length", |
5e242b0d DS |
1513 | "Forward packets over multiple paths\n" |
1514 | "iBGP-multipath\n" | |
1515 | "Number of paths\n" | |
1516 | "Match the cluster length\n") | |
1517 | { | |
c500ae40 DW |
1518 | int idx_number = 2; |
1519 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
5e242b0d | 1520 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); |
165b5fff JB |
1521 | } |
1522 | ||
1523 | DEFUN (no_bgp_maxpaths, | |
1524 | no_bgp_maxpaths_cmd, | |
9ccf14f7 | 1525 | "no maximum-paths [(1-255)]", |
165b5fff JB |
1526 | NO_STR |
1527 | "Forward packets over multiple paths\n" | |
1528 | "Number of paths\n") | |
1529 | { | |
5e242b0d | 1530 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
1531 | } |
1532 | ||
165b5fff JB |
1533 | DEFUN (no_bgp_maxpaths_ibgp, |
1534 | no_bgp_maxpaths_ibgp_cmd, | |
9ccf14f7 | 1535 | "no maximum-paths ibgp [(1-255) [equal-cluster-length]]", |
165b5fff JB |
1536 | NO_STR |
1537 | "Forward packets over multiple paths\n" | |
1538 | "iBGP-multipath\n" | |
838758ac DW |
1539 | "Number of paths\n" |
1540 | "Match the cluster length\n") | |
165b5fff | 1541 | { |
5e242b0d | 1542 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1543 | } |
1544 | ||
165b5fff JB |
1545 | int |
1546 | bgp_config_write_maxpaths (struct vty *vty, struct bgp *bgp, afi_t afi, | |
1547 | safi_t safi, int *write) | |
1548 | { | |
d5b77cc2 | 1549 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) |
165b5fff JB |
1550 | { |
1551 | bgp_config_write_family_header (vty, afi, safi, write); | |
0b960b4d | 1552 | vty_out (vty, " maximum-paths %d%s", |
165b5fff JB |
1553 | bgp->maxpaths[afi][safi].maxpaths_ebgp, VTY_NEWLINE); |
1554 | } | |
1555 | ||
d5b77cc2 | 1556 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) |
165b5fff JB |
1557 | { |
1558 | bgp_config_write_family_header (vty, afi, safi, write); | |
0b960b4d | 1559 | vty_out (vty, " maximum-paths ibgp %d", |
5e242b0d DS |
1560 | bgp->maxpaths[afi][safi].maxpaths_ibgp); |
1561 | if (CHECK_FLAG (bgp->maxpaths[afi][safi].ibgp_flags, | |
1562 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1563 | vty_out (vty, " equal-cluster-length"); | |
1564 | vty_out (vty, "%s", VTY_NEWLINE); | |
165b5fff JB |
1565 | } |
1566 | ||
1567 | return 0; | |
1568 | } | |
6b0655a2 | 1569 | |
718e3744 | 1570 | /* BGP timers. */ |
1571 | ||
1572 | DEFUN (bgp_timers, | |
1573 | bgp_timers_cmd, | |
6147e2c6 | 1574 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1575 | "Adjust routing timers\n" |
1576 | "BGP timers\n" | |
1577 | "Keepalive interval\n" | |
1578 | "Holdtime\n") | |
1579 | { | |
cdc2d765 | 1580 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
1581 | int idx_number = 2; |
1582 | int idx_number_2 = 3; | |
718e3744 | 1583 | unsigned long keepalive = 0; |
1584 | unsigned long holdtime = 0; | |
1585 | ||
c500ae40 DW |
1586 | VTY_GET_INTEGER ("keepalive", keepalive, argv[idx_number]->arg); |
1587 | VTY_GET_INTEGER ("holdtime", holdtime, argv[idx_number_2]->arg); | |
718e3744 | 1588 | |
1589 | /* Holdtime value check. */ | |
1590 | if (holdtime < 3 && holdtime != 0) | |
1591 | { | |
1592 | vty_out (vty, "%% hold time value must be either 0 or greater than 3%s", | |
1593 | VTY_NEWLINE); | |
1594 | return CMD_WARNING; | |
1595 | } | |
1596 | ||
1597 | bgp_timers_set (bgp, keepalive, holdtime); | |
1598 | ||
1599 | return CMD_SUCCESS; | |
1600 | } | |
1601 | ||
1602 | DEFUN (no_bgp_timers, | |
1603 | no_bgp_timers_cmd, | |
838758ac | 1604 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1605 | NO_STR |
1606 | "Adjust routing timers\n" | |
838758ac DW |
1607 | "BGP timers\n" |
1608 | "Keepalive interval\n" | |
1609 | "Holdtime\n") | |
718e3744 | 1610 | { |
cdc2d765 | 1611 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1612 | bgp_timers_unset (bgp); |
1613 | ||
1614 | return CMD_SUCCESS; | |
1615 | } | |
1616 | ||
6b0655a2 | 1617 | |
718e3744 | 1618 | DEFUN (bgp_client_to_client_reflection, |
1619 | bgp_client_to_client_reflection_cmd, | |
1620 | "bgp client-to-client reflection", | |
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_unset (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 | DEFUN (no_bgp_client_to_client_reflection, | |
1633 | no_bgp_client_to_client_reflection_cmd, | |
1634 | "no bgp client-to-client reflection", | |
1635 | NO_STR | |
1636 | "BGP specific commands\n" | |
1637 | "Configure client to client route reflection\n" | |
1638 | "reflection of routes allowed\n") | |
1639 | { | |
cdc2d765 | 1640 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1641 | bgp_flag_set (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); |
f31fa004 | 1642 | bgp_clear_star_soft_out (vty, bgp->name); |
7aafcaca | 1643 | |
718e3744 | 1644 | return CMD_SUCCESS; |
1645 | } | |
1646 | ||
1647 | /* "bgp always-compare-med" configuration. */ | |
1648 | DEFUN (bgp_always_compare_med, | |
1649 | bgp_always_compare_med_cmd, | |
1650 | "bgp always-compare-med", | |
1651 | "BGP specific commands\n" | |
1652 | "Allow comparing MED from different neighbors\n") | |
1653 | { | |
cdc2d765 | 1654 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1655 | bgp_flag_set (bgp, BGP_FLAG_ALWAYS_COMPARE_MED); |
7aafcaca DS |
1656 | bgp_recalculate_all_bestpaths (bgp); |
1657 | ||
718e3744 | 1658 | return CMD_SUCCESS; |
1659 | } | |
1660 | ||
1661 | DEFUN (no_bgp_always_compare_med, | |
1662 | no_bgp_always_compare_med_cmd, | |
1663 | "no bgp always-compare-med", | |
1664 | NO_STR | |
1665 | "BGP specific commands\n" | |
1666 | "Allow comparing MED from different neighbors\n") | |
1667 | { | |
cdc2d765 | 1668 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1669 | bgp_flag_unset (bgp, BGP_FLAG_ALWAYS_COMPARE_MED); |
7aafcaca DS |
1670 | bgp_recalculate_all_bestpaths (bgp); |
1671 | ||
718e3744 | 1672 | return CMD_SUCCESS; |
1673 | } | |
6b0655a2 | 1674 | |
718e3744 | 1675 | /* "bgp deterministic-med" configuration. */ |
1676 | DEFUN (bgp_deterministic_med, | |
1677 | bgp_deterministic_med_cmd, | |
1678 | "bgp deterministic-med", | |
1679 | "BGP specific commands\n" | |
1680 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1681 | { | |
cdc2d765 | 1682 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1475ac87 DW |
1683 | |
1684 | if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) | |
1685 | { | |
1686 | bgp_flag_set (bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1687 | bgp_recalculate_all_bestpaths (bgp); | |
1688 | } | |
7aafcaca | 1689 | |
718e3744 | 1690 | return CMD_SUCCESS; |
1691 | } | |
1692 | ||
1693 | DEFUN (no_bgp_deterministic_med, | |
1694 | no_bgp_deterministic_med_cmd, | |
1695 | "no bgp deterministic-med", | |
1696 | NO_STR | |
1697 | "BGP specific commands\n" | |
1698 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1699 | { | |
cdc2d765 | 1700 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
06370dac DW |
1701 | int bestpath_per_as_used; |
1702 | afi_t afi; | |
1703 | safi_t safi; | |
1704 | struct peer *peer; | |
1705 | struct listnode *node, *nnode; | |
718e3744 | 1706 | |
1475ac87 DW |
1707 | if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) |
1708 | { | |
06370dac DW |
1709 | bestpath_per_as_used = 0; |
1710 | ||
1711 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
1712 | { | |
1713 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
1714 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
1715 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) | |
1716 | { | |
1717 | bestpath_per_as_used = 1; | |
1718 | break; | |
1719 | } | |
1720 | ||
1721 | if (bestpath_per_as_used) | |
1722 | break; | |
1723 | } | |
1724 | ||
1725 | if (bestpath_per_as_used) | |
1726 | { | |
1727 | vty_out (vty, "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use%s", | |
1728 | VTY_NEWLINE); | |
1729 | return CMD_WARNING; | |
1730 | } | |
1731 | else | |
1732 | { | |
1733 | bgp_flag_unset (bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1734 | bgp_recalculate_all_bestpaths (bgp); | |
1735 | } | |
1475ac87 | 1736 | } |
7aafcaca | 1737 | |
718e3744 | 1738 | return CMD_SUCCESS; |
1739 | } | |
538621f2 | 1740 | |
1741 | /* "bgp graceful-restart" configuration. */ | |
1742 | DEFUN (bgp_graceful_restart, | |
1743 | bgp_graceful_restart_cmd, | |
1744 | "bgp graceful-restart", | |
1745 | "BGP specific commands\n" | |
1746 | "Graceful restart capability parameters\n") | |
1747 | { | |
cdc2d765 | 1748 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
538621f2 | 1749 | bgp_flag_set (bgp, BGP_FLAG_GRACEFUL_RESTART); |
1750 | return CMD_SUCCESS; | |
1751 | } | |
1752 | ||
1753 | DEFUN (no_bgp_graceful_restart, | |
1754 | no_bgp_graceful_restart_cmd, | |
1755 | "no bgp graceful-restart", | |
1756 | NO_STR | |
1757 | "BGP specific commands\n" | |
1758 | "Graceful restart capability parameters\n") | |
1759 | { | |
cdc2d765 | 1760 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
538621f2 | 1761 | bgp_flag_unset (bgp, BGP_FLAG_GRACEFUL_RESTART); |
1762 | return CMD_SUCCESS; | |
1763 | } | |
1764 | ||
93406d87 | 1765 | DEFUN (bgp_graceful_restart_stalepath_time, |
1766 | bgp_graceful_restart_stalepath_time_cmd, | |
6147e2c6 | 1767 | "bgp graceful-restart stalepath-time (1-3600)", |
93406d87 | 1768 | "BGP specific commands\n" |
1769 | "Graceful restart capability parameters\n" | |
1770 | "Set the max time to hold onto restarting peer's stale paths\n" | |
1771 | "Delay value (seconds)\n") | |
1772 | { | |
cdc2d765 | 1773 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1774 | int idx_number = 3; |
93406d87 | 1775 | u_int32_t stalepath; |
1776 | ||
c500ae40 | 1777 | VTY_GET_INTEGER_RANGE ("stalepath-time", stalepath, argv[idx_number]->arg, 1, 3600); |
93406d87 | 1778 | bgp->stalepath_time = stalepath; |
1779 | return CMD_SUCCESS; | |
1780 | } | |
1781 | ||
eb6f1b41 PG |
1782 | DEFUN (bgp_graceful_restart_restart_time, |
1783 | bgp_graceful_restart_restart_time_cmd, | |
6147e2c6 | 1784 | "bgp graceful-restart restart-time (1-3600)", |
eb6f1b41 PG |
1785 | "BGP specific commands\n" |
1786 | "Graceful restart capability parameters\n" | |
1787 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
1788 | "Delay value (seconds)\n") | |
1789 | { | |
cdc2d765 | 1790 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1791 | int idx_number = 3; |
eb6f1b41 PG |
1792 | u_int32_t restart; |
1793 | ||
c500ae40 | 1794 | VTY_GET_INTEGER_RANGE ("restart-time", restart, argv[idx_number]->arg, 1, 3600); |
eb6f1b41 PG |
1795 | bgp->restart_time = restart; |
1796 | return CMD_SUCCESS; | |
1797 | } | |
1798 | ||
93406d87 | 1799 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
1800 | no_bgp_graceful_restart_stalepath_time_cmd, | |
838758ac | 1801 | "no bgp graceful-restart stalepath-time [(1-3600)]", |
93406d87 | 1802 | NO_STR |
1803 | "BGP specific commands\n" | |
1804 | "Graceful restart capability parameters\n" | |
838758ac DW |
1805 | "Set the max time to hold onto restarting peer's stale paths\n" |
1806 | "Delay value (seconds)\n") | |
93406d87 | 1807 | { |
cdc2d765 | 1808 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 1809 | |
1810 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; | |
1811 | return CMD_SUCCESS; | |
1812 | } | |
1813 | ||
eb6f1b41 PG |
1814 | DEFUN (no_bgp_graceful_restart_restart_time, |
1815 | no_bgp_graceful_restart_restart_time_cmd, | |
838758ac | 1816 | "no bgp graceful-restart restart-time [(1-3600)]", |
eb6f1b41 PG |
1817 | NO_STR |
1818 | "BGP specific commands\n" | |
1819 | "Graceful restart capability parameters\n" | |
838758ac DW |
1820 | "Set the time to wait to delete stale routes before a BGP open message is received\n" |
1821 | "Delay value (seconds)\n") | |
eb6f1b41 | 1822 | { |
cdc2d765 | 1823 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 PG |
1824 | |
1825 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; | |
1826 | return CMD_SUCCESS; | |
1827 | } | |
1828 | ||
43fc21b3 JC |
1829 | DEFUN (bgp_graceful_restart_preserve_fw, |
1830 | bgp_graceful_restart_preserve_fw_cmd, | |
1831 | "bgp graceful-restart preserve-fw-state", | |
1832 | "BGP specific commands\n" | |
1833 | "Graceful restart capability parameters\n" | |
1834 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1835 | { | |
1836 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1837 | bgp_flag_set(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1838 | return CMD_SUCCESS; | |
1839 | } | |
1840 | ||
1841 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
1842 | no_bgp_graceful_restart_preserve_fw_cmd, | |
1843 | "no bgp graceful-restart preserve-fw-state", | |
1844 | NO_STR | |
1845 | "BGP specific commands\n" | |
1846 | "Graceful restart capability parameters\n" | |
1847 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1848 | { | |
1849 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1850 | bgp_flag_unset(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1851 | return CMD_SUCCESS; | |
1852 | } | |
1853 | ||
718e3744 | 1854 | /* "bgp fast-external-failover" configuration. */ |
1855 | DEFUN (bgp_fast_external_failover, | |
1856 | bgp_fast_external_failover_cmd, | |
1857 | "bgp fast-external-failover", | |
1858 | BGP_STR | |
1859 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
1860 | { | |
cdc2d765 | 1861 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1862 | bgp_flag_unset (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); |
1863 | return CMD_SUCCESS; | |
1864 | } | |
1865 | ||
1866 | DEFUN (no_bgp_fast_external_failover, | |
1867 | no_bgp_fast_external_failover_cmd, | |
1868 | "no bgp fast-external-failover", | |
1869 | NO_STR | |
1870 | BGP_STR | |
1871 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
1872 | { | |
cdc2d765 | 1873 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1874 | bgp_flag_set (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); |
1875 | return CMD_SUCCESS; | |
1876 | } | |
6b0655a2 | 1877 | |
718e3744 | 1878 | /* "bgp enforce-first-as" configuration. */ |
1879 | DEFUN (bgp_enforce_first_as, | |
1880 | bgp_enforce_first_as_cmd, | |
1881 | "bgp enforce-first-as", | |
1882 | BGP_STR | |
1883 | "Enforce the first AS for EBGP routes\n") | |
1884 | { | |
cdc2d765 | 1885 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1886 | bgp_flag_set (bgp, BGP_FLAG_ENFORCE_FIRST_AS); |
f31fa004 | 1887 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 1888 | |
718e3744 | 1889 | return CMD_SUCCESS; |
1890 | } | |
1891 | ||
1892 | DEFUN (no_bgp_enforce_first_as, | |
1893 | no_bgp_enforce_first_as_cmd, | |
1894 | "no bgp enforce-first-as", | |
1895 | NO_STR | |
1896 | BGP_STR | |
1897 | "Enforce the first AS for EBGP routes\n") | |
1898 | { | |
cdc2d765 | 1899 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1900 | bgp_flag_unset (bgp, BGP_FLAG_ENFORCE_FIRST_AS); |
f31fa004 | 1901 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 1902 | |
718e3744 | 1903 | return CMD_SUCCESS; |
1904 | } | |
6b0655a2 | 1905 | |
718e3744 | 1906 | /* "bgp bestpath compare-routerid" configuration. */ |
1907 | DEFUN (bgp_bestpath_compare_router_id, | |
1908 | bgp_bestpath_compare_router_id_cmd, | |
1909 | "bgp bestpath compare-routerid", | |
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_set (bgp, BGP_FLAG_COMPARE_ROUTER_ID); |
7aafcaca DS |
1916 | bgp_recalculate_all_bestpaths (bgp); |
1917 | ||
718e3744 | 1918 | return CMD_SUCCESS; |
1919 | } | |
1920 | ||
1921 | DEFUN (no_bgp_bestpath_compare_router_id, | |
1922 | no_bgp_bestpath_compare_router_id_cmd, | |
1923 | "no bgp bestpath compare-routerid", | |
1924 | NO_STR | |
1925 | "BGP specific commands\n" | |
1926 | "Change the default bestpath selection\n" | |
1927 | "Compare router-id for identical EBGP paths\n") | |
1928 | { | |
cdc2d765 | 1929 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1930 | bgp_flag_unset (bgp, BGP_FLAG_COMPARE_ROUTER_ID); |
7aafcaca DS |
1931 | bgp_recalculate_all_bestpaths (bgp); |
1932 | ||
718e3744 | 1933 | return CMD_SUCCESS; |
1934 | } | |
6b0655a2 | 1935 | |
718e3744 | 1936 | /* "bgp bestpath as-path ignore" configuration. */ |
1937 | DEFUN (bgp_bestpath_aspath_ignore, | |
1938 | bgp_bestpath_aspath_ignore_cmd, | |
1939 | "bgp bestpath as-path ignore", | |
1940 | "BGP specific commands\n" | |
1941 | "Change the default bestpath selection\n" | |
1942 | "AS-path attribute\n" | |
1943 | "Ignore as-path length in selecting a route\n") | |
1944 | { | |
cdc2d765 | 1945 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1946 | bgp_flag_set (bgp, BGP_FLAG_ASPATH_IGNORE); |
7aafcaca DS |
1947 | bgp_recalculate_all_bestpaths (bgp); |
1948 | ||
718e3744 | 1949 | return CMD_SUCCESS; |
1950 | } | |
1951 | ||
1952 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
1953 | no_bgp_bestpath_aspath_ignore_cmd, | |
1954 | "no bgp bestpath as-path ignore", | |
1955 | NO_STR | |
1956 | "BGP specific commands\n" | |
1957 | "Change the default bestpath selection\n" | |
1958 | "AS-path attribute\n" | |
1959 | "Ignore as-path length in selecting a route\n") | |
1960 | { | |
cdc2d765 | 1961 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1962 | bgp_flag_unset (bgp, BGP_FLAG_ASPATH_IGNORE); |
7aafcaca DS |
1963 | bgp_recalculate_all_bestpaths (bgp); |
1964 | ||
718e3744 | 1965 | return CMD_SUCCESS; |
1966 | } | |
6b0655a2 | 1967 | |
6811845b | 1968 | /* "bgp bestpath as-path confed" configuration. */ |
1969 | DEFUN (bgp_bestpath_aspath_confed, | |
1970 | bgp_bestpath_aspath_confed_cmd, | |
1971 | "bgp bestpath as-path confed", | |
1972 | "BGP specific commands\n" | |
1973 | "Change the default bestpath selection\n" | |
1974 | "AS-path attribute\n" | |
1975 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
1976 | { | |
cdc2d765 | 1977 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6811845b | 1978 | bgp_flag_set (bgp, BGP_FLAG_ASPATH_CONFED); |
7aafcaca DS |
1979 | bgp_recalculate_all_bestpaths (bgp); |
1980 | ||
6811845b | 1981 | return CMD_SUCCESS; |
1982 | } | |
1983 | ||
1984 | DEFUN (no_bgp_bestpath_aspath_confed, | |
1985 | no_bgp_bestpath_aspath_confed_cmd, | |
1986 | "no bgp bestpath as-path confed", | |
1987 | NO_STR | |
1988 | "BGP specific commands\n" | |
1989 | "Change the default bestpath selection\n" | |
1990 | "AS-path attribute\n" | |
1991 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
1992 | { | |
cdc2d765 | 1993 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6811845b | 1994 | bgp_flag_unset (bgp, BGP_FLAG_ASPATH_CONFED); |
7aafcaca DS |
1995 | bgp_recalculate_all_bestpaths (bgp); |
1996 | ||
6811845b | 1997 | return CMD_SUCCESS; |
1998 | } | |
6b0655a2 | 1999 | |
2fdd455c PM |
2000 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
2001 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
2002 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2003 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2004 | "BGP specific commands\n" |
2005 | "Change the default bestpath selection\n" | |
2006 | "AS-path attribute\n" | |
2007 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2008 | "Generate an AS_SET\n" |
16fc1eec DS |
2009 | "Do not generate an AS_SET\n") |
2010 | { | |
cdc2d765 | 2011 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4c4ff4c1 | 2012 | int idx = 0; |
16fc1eec | 2013 | bgp_flag_set (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); |
219178b6 DW |
2014 | |
2015 | /* no-as-set is now the default behavior so we can silently | |
2016 | * ignore it */ | |
4c4ff4c1 | 2017 | if (argv_find (argv, argc, "as-set", &idx)) |
219178b6 DW |
2018 | bgp_flag_set (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
2019 | else | |
2020 | bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET) ; | |
2021 | ||
7aafcaca DS |
2022 | bgp_recalculate_all_bestpaths (bgp); |
2023 | ||
16fc1eec DS |
2024 | return CMD_SUCCESS; |
2025 | } | |
2026 | ||
219178b6 DW |
2027 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
2028 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2029 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2030 | NO_STR |
2031 | "BGP specific commands\n" | |
2032 | "Change the default bestpath selection\n" | |
2033 | "AS-path attribute\n" | |
2034 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2035 | "Generate an AS_SET\n" |
16fc1eec DS |
2036 | "Do not generate an AS_SET\n") |
2037 | { | |
cdc2d765 | 2038 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
16fc1eec | 2039 | bgp_flag_unset (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); |
219178b6 | 2040 | bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
7aafcaca DS |
2041 | bgp_recalculate_all_bestpaths (bgp); |
2042 | ||
2fdd455c PM |
2043 | return CMD_SUCCESS; |
2044 | } | |
6b0655a2 | 2045 | |
848973c7 | 2046 | /* "bgp log-neighbor-changes" configuration. */ |
2047 | DEFUN (bgp_log_neighbor_changes, | |
2048 | bgp_log_neighbor_changes_cmd, | |
2049 | "bgp log-neighbor-changes", | |
2050 | "BGP specific commands\n" | |
2051 | "Log neighbor up/down and reset reason\n") | |
2052 | { | |
cdc2d765 | 2053 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
848973c7 | 2054 | bgp_flag_set (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
2055 | return CMD_SUCCESS; | |
2056 | } | |
2057 | ||
2058 | DEFUN (no_bgp_log_neighbor_changes, | |
2059 | no_bgp_log_neighbor_changes_cmd, | |
2060 | "no bgp log-neighbor-changes", | |
2061 | NO_STR | |
2062 | "BGP specific commands\n" | |
2063 | "Log neighbor up/down and reset reason\n") | |
2064 | { | |
cdc2d765 | 2065 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
848973c7 | 2066 | bgp_flag_unset (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
2067 | return CMD_SUCCESS; | |
2068 | } | |
6b0655a2 | 2069 | |
718e3744 | 2070 | /* "bgp bestpath med" configuration. */ |
2071 | DEFUN (bgp_bestpath_med, | |
2072 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 2073 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2074 | "BGP specific commands\n" |
2075 | "Change the default bestpath selection\n" | |
2076 | "MED attribute\n" | |
2077 | "Compare MED among confederation paths\n" | |
838758ac DW |
2078 | "Treat missing MED as the least preferred one\n" |
2079 | "Treat missing MED as the least preferred one\n" | |
2080 | "Compare MED among confederation paths\n") | |
718e3744 | 2081 | { |
cdc2d765 | 2082 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6cbd1915 QY |
2083 | |
2084 | int idx = 0; | |
2085 | if (argv_find (argv, argc, "confed", &idx)) | |
2086 | bgp_flag_set (bgp, BGP_FLAG_MED_CONFED); | |
2087 | idx = 0; | |
2088 | if (argv_find (argv, argc, "missing-as-worst", &idx)) | |
2089 | bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
e52702f2 | 2090 | |
7aafcaca DS |
2091 | bgp_recalculate_all_bestpaths (bgp); |
2092 | ||
718e3744 | 2093 | return CMD_SUCCESS; |
2094 | } | |
2095 | ||
718e3744 | 2096 | DEFUN (no_bgp_bestpath_med, |
2097 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2098 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2099 | NO_STR |
2100 | "BGP specific commands\n" | |
2101 | "Change the default bestpath selection\n" | |
2102 | "MED attribute\n" | |
2103 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2104 | "Treat missing MED as the least preferred one\n" |
2105 | "Treat missing MED as the least preferred one\n" | |
2106 | "Compare MED among confederation paths\n") | |
718e3744 | 2107 | { |
cdc2d765 | 2108 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
e52702f2 | 2109 | |
6cbd1915 QY |
2110 | int idx = 0; |
2111 | if (argv_find (argv, argc, "confed", &idx)) | |
718e3744 | 2112 | bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED); |
6cbd1915 QY |
2113 | idx = 0; |
2114 | if (argv_find (argv, argc, "missing-as-worst", &idx)) | |
718e3744 | 2115 | bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST); |
2116 | ||
7aafcaca DS |
2117 | bgp_recalculate_all_bestpaths (bgp); |
2118 | ||
718e3744 | 2119 | return CMD_SUCCESS; |
2120 | } | |
2121 | ||
718e3744 | 2122 | /* "no bgp default ipv4-unicast". */ |
2123 | DEFUN (no_bgp_default_ipv4_unicast, | |
2124 | no_bgp_default_ipv4_unicast_cmd, | |
2125 | "no bgp default ipv4-unicast", | |
2126 | NO_STR | |
2127 | "BGP specific commands\n" | |
2128 | "Configure BGP defaults\n" | |
2129 | "Activate ipv4-unicast for a peer by default\n") | |
2130 | { | |
cdc2d765 | 2131 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2132 | bgp_flag_set (bgp, BGP_FLAG_NO_DEFAULT_IPV4); |
2133 | return CMD_SUCCESS; | |
2134 | } | |
2135 | ||
2136 | DEFUN (bgp_default_ipv4_unicast, | |
2137 | bgp_default_ipv4_unicast_cmd, | |
2138 | "bgp default ipv4-unicast", | |
2139 | "BGP specific commands\n" | |
2140 | "Configure BGP defaults\n" | |
2141 | "Activate ipv4-unicast for a peer by default\n") | |
2142 | { | |
cdc2d765 | 2143 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2144 | bgp_flag_unset (bgp, BGP_FLAG_NO_DEFAULT_IPV4); |
2145 | return CMD_SUCCESS; | |
2146 | } | |
6b0655a2 | 2147 | |
04b6bdc0 DW |
2148 | /* Display hostname in certain command outputs */ |
2149 | DEFUN (bgp_default_show_hostname, | |
2150 | bgp_default_show_hostname_cmd, | |
2151 | "bgp default show-hostname", | |
2152 | "BGP specific commands\n" | |
2153 | "Configure BGP defaults\n" | |
2154 | "Show hostname in certain command ouputs\n") | |
2155 | { | |
cdc2d765 | 2156 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
04b6bdc0 DW |
2157 | bgp_flag_set (bgp, BGP_FLAG_SHOW_HOSTNAME); |
2158 | return CMD_SUCCESS; | |
2159 | } | |
2160 | ||
2161 | DEFUN (no_bgp_default_show_hostname, | |
2162 | no_bgp_default_show_hostname_cmd, | |
2163 | "no bgp default show-hostname", | |
2164 | NO_STR | |
2165 | "BGP specific commands\n" | |
2166 | "Configure BGP defaults\n" | |
2167 | "Show hostname in certain command ouputs\n") | |
2168 | { | |
cdc2d765 | 2169 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
04b6bdc0 DW |
2170 | bgp_flag_unset (bgp, BGP_FLAG_SHOW_HOSTNAME); |
2171 | return CMD_SUCCESS; | |
2172 | } | |
2173 | ||
8233ef81 | 2174 | /* "bgp network import-check" configuration. */ |
718e3744 | 2175 | DEFUN (bgp_network_import_check, |
2176 | bgp_network_import_check_cmd, | |
5623e905 | 2177 | "bgp network import-check", |
718e3744 | 2178 | "BGP specific commands\n" |
2179 | "BGP network command\n" | |
5623e905 | 2180 | "Check BGP network route exists in IGP\n") |
718e3744 | 2181 | { |
cdc2d765 | 2182 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
078430f6 DS |
2183 | if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) |
2184 | { | |
2185 | bgp_flag_set (bgp, BGP_FLAG_IMPORT_CHECK); | |
5623e905 | 2186 | bgp_static_redo_import_check(bgp); |
078430f6 DS |
2187 | } |
2188 | ||
718e3744 | 2189 | return CMD_SUCCESS; |
2190 | } | |
2191 | ||
8233ef81 DW |
2192 | ALIAS_HIDDEN (bgp_network_import_check, |
2193 | bgp_network_import_check_exact_cmd, | |
2194 | "bgp network import-check exact", | |
2195 | "BGP specific commands\n" | |
2196 | "BGP network command\n" | |
2197 | "Check BGP network route exists in IGP\n" | |
2198 | "Match route precisely\n") | |
2199 | ||
718e3744 | 2200 | DEFUN (no_bgp_network_import_check, |
2201 | no_bgp_network_import_check_cmd, | |
5623e905 | 2202 | "no bgp network import-check", |
718e3744 | 2203 | NO_STR |
2204 | "BGP specific commands\n" | |
2205 | "BGP network command\n" | |
2206 | "Check BGP network route exists in IGP\n") | |
2207 | { | |
cdc2d765 | 2208 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
078430f6 DS |
2209 | if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) |
2210 | { | |
2211 | bgp_flag_unset (bgp, BGP_FLAG_IMPORT_CHECK); | |
078430f6 DS |
2212 | bgp_static_redo_import_check(bgp); |
2213 | } | |
5623e905 | 2214 | |
718e3744 | 2215 | return CMD_SUCCESS; |
2216 | } | |
6b0655a2 | 2217 | |
718e3744 | 2218 | DEFUN (bgp_default_local_preference, |
2219 | bgp_default_local_preference_cmd, | |
6147e2c6 | 2220 | "bgp default local-preference (0-4294967295)", |
718e3744 | 2221 | "BGP specific commands\n" |
2222 | "Configure BGP defaults\n" | |
2223 | "local preference (higher=more preferred)\n" | |
2224 | "Configure default local preference value\n") | |
2225 | { | |
cdc2d765 | 2226 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2227 | int idx_number = 3; |
718e3744 | 2228 | u_int32_t local_pref; |
2229 | ||
c500ae40 | 2230 | VTY_GET_INTEGER ("local preference", local_pref, argv[idx_number]->arg); |
718e3744 | 2231 | |
2232 | bgp_default_local_preference_set (bgp, local_pref); | |
f31fa004 | 2233 | bgp_clear_star_soft_in (vty, bgp->name); |
718e3744 | 2234 | |
2235 | return CMD_SUCCESS; | |
2236 | } | |
2237 | ||
2238 | DEFUN (no_bgp_default_local_preference, | |
2239 | no_bgp_default_local_preference_cmd, | |
838758ac | 2240 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 2241 | NO_STR |
2242 | "BGP specific commands\n" | |
2243 | "Configure BGP defaults\n" | |
838758ac DW |
2244 | "local preference (higher=more preferred)\n" |
2245 | "Configure default local preference value\n") | |
718e3744 | 2246 | { |
cdc2d765 | 2247 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2248 | bgp_default_local_preference_unset (bgp); |
f31fa004 | 2249 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 2250 | |
718e3744 | 2251 | return CMD_SUCCESS; |
2252 | } | |
2253 | ||
6b0655a2 | 2254 | |
3f9c7369 DS |
2255 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
2256 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 2257 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
2258 | "BGP specific commands\n" |
2259 | "Configure BGP defaults\n" | |
2260 | "subgroup-pkt-queue-max\n" | |
2261 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 2262 | { |
cdc2d765 | 2263 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2264 | int idx_number = 3; |
3f9c7369 | 2265 | u_int32_t max_size; |
8bd9d948 | 2266 | |
c500ae40 | 2267 | VTY_GET_INTEGER ("subgroup packet queue max", max_size, argv[idx_number]->arg); |
3f9c7369 DS |
2268 | |
2269 | bgp_default_subgroup_pkt_queue_max_set (bgp, max_size); | |
2270 | ||
2271 | return CMD_SUCCESS; | |
2272 | } | |
2273 | ||
2274 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
2275 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 2276 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
2277 | NO_STR |
2278 | "BGP specific commands\n" | |
2279 | "Configure BGP defaults\n" | |
838758ac DW |
2280 | "subgroup-pkt-queue-max\n" |
2281 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 2282 | { |
cdc2d765 | 2283 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3f9c7369 DS |
2284 | bgp_default_subgroup_pkt_queue_max_unset (bgp); |
2285 | return CMD_SUCCESS; | |
8bd9d948 DS |
2286 | } |
2287 | ||
813d4307 | 2288 | |
8bd9d948 DS |
2289 | DEFUN (bgp_rr_allow_outbound_policy, |
2290 | bgp_rr_allow_outbound_policy_cmd, | |
2291 | "bgp route-reflector allow-outbound-policy", | |
2292 | "BGP specific commands\n" | |
2293 | "Allow modifications made by out route-map\n" | |
2294 | "on ibgp neighbors\n") | |
2295 | { | |
cdc2d765 | 2296 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 DS |
2297 | |
2298 | if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) | |
2299 | { | |
2300 | bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3f9c7369 | 2301 | update_group_announce_rrclients(bgp); |
f31fa004 | 2302 | bgp_clear_star_soft_out (vty, bgp->name); |
8bd9d948 DS |
2303 | } |
2304 | ||
2305 | return CMD_SUCCESS; | |
2306 | } | |
2307 | ||
2308 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
2309 | no_bgp_rr_allow_outbound_policy_cmd, | |
2310 | "no bgp route-reflector allow-outbound-policy", | |
2311 | NO_STR | |
2312 | "BGP specific commands\n" | |
2313 | "Allow modifications made by out route-map\n" | |
2314 | "on ibgp neighbors\n") | |
2315 | { | |
cdc2d765 | 2316 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 DS |
2317 | |
2318 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) | |
2319 | { | |
2320 | bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3f9c7369 | 2321 | update_group_announce_rrclients(bgp); |
f31fa004 | 2322 | bgp_clear_star_soft_out (vty, bgp->name); |
8bd9d948 DS |
2323 | } |
2324 | ||
2325 | return CMD_SUCCESS; | |
2326 | } | |
2327 | ||
f14e6fdb DS |
2328 | DEFUN (bgp_listen_limit, |
2329 | bgp_listen_limit_cmd, | |
9ccf14f7 | 2330 | "bgp listen limit (1-5000)", |
f14e6fdb DS |
2331 | "BGP specific commands\n" |
2332 | "Configure BGP defaults\n" | |
2333 | "maximum number of BGP Dynamic Neighbors that can be created\n" | |
2334 | "Configure Dynamic Neighbors listen limit value\n") | |
2335 | { | |
cdc2d765 | 2336 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2337 | int idx_number = 3; |
f14e6fdb DS |
2338 | int listen_limit; |
2339 | ||
c500ae40 | 2340 | VTY_GET_INTEGER_RANGE ("listen limit", listen_limit, argv[idx_number]->arg, |
f14e6fdb DS |
2341 | BGP_DYNAMIC_NEIGHBORS_LIMIT_MIN, |
2342 | BGP_DYNAMIC_NEIGHBORS_LIMIT_MAX); | |
2343 | ||
2344 | bgp_listen_limit_set (bgp, listen_limit); | |
2345 | ||
2346 | return CMD_SUCCESS; | |
2347 | } | |
2348 | ||
2349 | DEFUN (no_bgp_listen_limit, | |
2350 | no_bgp_listen_limit_cmd, | |
838758ac | 2351 | "no bgp listen limit [(1-5000)]", |
f14e6fdb DS |
2352 | "BGP specific commands\n" |
2353 | "Configure BGP defaults\n" | |
2354 | "unset maximum number of BGP Dynamic Neighbors that can be created\n" | |
838758ac DW |
2355 | "Configure Dynamic Neighbors listen limit value to default\n" |
2356 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 2357 | { |
cdc2d765 | 2358 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f14e6fdb DS |
2359 | bgp_listen_limit_unset (bgp); |
2360 | return CMD_SUCCESS; | |
2361 | } | |
2362 | ||
2363 | ||
20eb8864 | 2364 | /* |
2365 | * Check if this listen range is already configured. Check for exact | |
2366 | * match or overlap based on input. | |
2367 | */ | |
2368 | static struct peer_group * | |
2369 | listen_range_exists (struct bgp *bgp, struct prefix *range, int exact) | |
2370 | { | |
2371 | struct listnode *node, *nnode; | |
2372 | struct listnode *node1, *nnode1; | |
2373 | struct peer_group *group; | |
2374 | struct prefix *lr; | |
2375 | afi_t afi; | |
2376 | int match; | |
2377 | ||
2378 | afi = family2afi(range->family); | |
2379 | for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) | |
2380 | { | |
2381 | for (ALL_LIST_ELEMENTS (group->listen_range[afi], node1, | |
2382 | nnode1, lr)) | |
2383 | { | |
2384 | if (exact) | |
2385 | match = prefix_same (range, lr); | |
2386 | else | |
2387 | match = (prefix_match (range, lr) || prefix_match (lr, range)); | |
2388 | if (match) | |
2389 | return group; | |
2390 | } | |
2391 | } | |
2392 | ||
2393 | return NULL; | |
2394 | } | |
2395 | ||
f14e6fdb DS |
2396 | DEFUN (bgp_listen_range, |
2397 | bgp_listen_range_cmd, | |
9ccf14f7 | 2398 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
f14e6fdb | 2399 | "BGP specific commands\n" |
d7fa34c1 QY |
2400 | "Configure BGP dynamic neighbors listen range\n" |
2401 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
2402 | NEIGHBOR_ADDR_STR |
2403 | "Member of the peer-group\n" | |
2404 | "Peer-group name\n") | |
f14e6fdb | 2405 | { |
cdc2d765 | 2406 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f14e6fdb | 2407 | struct prefix range; |
20eb8864 | 2408 | struct peer_group *group, *existing_group; |
f14e6fdb DS |
2409 | afi_t afi; |
2410 | int ret; | |
d7fa34c1 | 2411 | int idx = 0; |
f14e6fdb | 2412 | |
d7fa34c1 QY |
2413 | argv_find (argv, argc, "A.B.C.D/M", &idx); |
2414 | argv_find (argv, argc, "X:X::X:X/M", &idx); | |
2415 | char *prefix = argv[idx]->arg; | |
2416 | argv_find (argv, argc, "WORD", &idx); | |
2417 | char *peergroup = argv[idx]->arg; | |
f14e6fdb | 2418 | |
f14e6fdb | 2419 | /* Convert IP prefix string to struct prefix. */ |
d7fa34c1 | 2420 | ret = str2prefix (prefix, &range); |
f14e6fdb DS |
2421 | if (! ret) |
2422 | { | |
2423 | vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE); | |
2424 | return CMD_WARNING; | |
2425 | } | |
2426 | ||
2427 | afi = family2afi(range.family); | |
2428 | ||
f14e6fdb DS |
2429 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6)) |
2430 | { | |
2431 | vty_out (vty, "%% Malformed listen range (link-local address)%s", | |
2432 | VTY_NEWLINE); | |
2433 | return CMD_WARNING; | |
2434 | } | |
f14e6fdb DS |
2435 | |
2436 | apply_mask (&range); | |
2437 | ||
20eb8864 | 2438 | /* Check if same listen range is already configured. */ |
2439 | existing_group = listen_range_exists (bgp, &range, 1); | |
2440 | if (existing_group) | |
2441 | { | |
d7fa34c1 | 2442 | if (strcmp (existing_group->name, peergroup) == 0) |
20eb8864 | 2443 | return CMD_SUCCESS; |
2444 | else | |
2445 | { | |
2446 | vty_out (vty, "%% Same listen range is attached to peer-group %s%s", | |
2447 | existing_group->name, VTY_NEWLINE); | |
2448 | return CMD_WARNING; | |
2449 | } | |
2450 | } | |
2451 | ||
2452 | /* Check if an overlapping listen range exists. */ | |
2453 | if (listen_range_exists (bgp, &range, 0)) | |
2454 | { | |
2455 | vty_out (vty, "%% Listen range overlaps with existing listen range%s", | |
2456 | VTY_NEWLINE); | |
2457 | return CMD_WARNING; | |
2458 | } | |
f14e6fdb | 2459 | |
d7fa34c1 | 2460 | group = peer_group_lookup (bgp, peergroup); |
f14e6fdb DS |
2461 | if (! group) |
2462 | { | |
2463 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
2464 | return CMD_WARNING; | |
2465 | } | |
2466 | ||
2467 | ret = peer_group_listen_range_add(group, &range); | |
2468 | return bgp_vty_return (vty, ret); | |
2469 | } | |
2470 | ||
2471 | DEFUN (no_bgp_listen_range, | |
2472 | no_bgp_listen_range_cmd, | |
d7fa34c1 QY |
2473 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
2474 | NO_STR | |
f14e6fdb | 2475 | "BGP specific commands\n" |
d7fa34c1 QY |
2476 | "Unconfigure BGP dynamic neighbors listen range\n" |
2477 | "Unconfigure BGP dynamic neighbors listen range\n" | |
2478 | NEIGHBOR_ADDR_STR | |
2479 | "Member of the peer-group\n" | |
2480 | "Peer-group name\n") | |
f14e6fdb | 2481 | { |
cdc2d765 | 2482 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f14e6fdb DS |
2483 | struct prefix range; |
2484 | struct peer_group *group; | |
2485 | afi_t afi; | |
2486 | int ret; | |
d7fa34c1 QY |
2487 | int idx = 0; |
2488 | ||
2489 | argv_find (argv, argc, "A.B.C.D/M", &idx); | |
2490 | argv_find (argv, argc, "X:X::X:X/M", &idx); | |
2491 | char *prefix = argv[idx]->arg; | |
2492 | argv_find (argv, argc, "WORD", &idx); | |
2493 | char *peergroup = argv[idx]->arg; | |
f14e6fdb | 2494 | |
c500ae40 | 2495 | // VTY_GET_IPV4_PREFIX ("listen range", range, argv[idx_ipv4_prefixlen]->arg); |
f14e6fdb DS |
2496 | |
2497 | /* Convert IP prefix string to struct prefix. */ | |
d7fa34c1 | 2498 | ret = str2prefix (prefix, &range); |
f14e6fdb DS |
2499 | if (! ret) |
2500 | { | |
2501 | vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE); | |
2502 | return CMD_WARNING; | |
2503 | } | |
2504 | ||
2505 | afi = family2afi(range.family); | |
2506 | ||
f14e6fdb DS |
2507 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6)) |
2508 | { | |
2509 | vty_out (vty, "%% Malformed listen range (link-local address)%s", | |
2510 | VTY_NEWLINE); | |
2511 | return CMD_WARNING; | |
2512 | } | |
f14e6fdb DS |
2513 | |
2514 | apply_mask (&range); | |
2515 | ||
d7fa34c1 | 2516 | group = peer_group_lookup (bgp, peergroup); |
f14e6fdb DS |
2517 | if (! group) |
2518 | { | |
2519 | vty_out (vty, "%% Peer-group does not exist%s", VTY_NEWLINE); | |
2520 | return CMD_WARNING; | |
2521 | } | |
2522 | ||
2523 | ret = peer_group_listen_range_del(group, &range); | |
2524 | return bgp_vty_return (vty, ret); | |
2525 | } | |
2526 | ||
2527 | int | |
2528 | bgp_config_write_listen (struct vty *vty, struct bgp *bgp) | |
2529 | { | |
2530 | struct peer_group *group; | |
2531 | struct listnode *node, *nnode, *rnode, *nrnode; | |
2532 | struct prefix *range; | |
2533 | afi_t afi; | |
4690c7d7 | 2534 | char buf[PREFIX2STR_BUFFER]; |
f14e6fdb DS |
2535 | |
2536 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
2537 | vty_out (vty, " bgp listen limit %d%s", | |
2538 | bgp->dynamic_neighbors_limit, VTY_NEWLINE); | |
2539 | ||
2540 | for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) | |
2541 | { | |
2542 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
2543 | { | |
2544 | for (ALL_LIST_ELEMENTS (group->listen_range[afi], rnode, nrnode, range)) | |
2545 | { | |
2546 | prefix2str(range, buf, sizeof(buf)); | |
2547 | vty_out(vty, " bgp listen range %s peer-group %s%s", | |
2548 | buf, group->name, VTY_NEWLINE); | |
2549 | } | |
2550 | } | |
2551 | } | |
2552 | ||
2553 | return 0; | |
2554 | } | |
2555 | ||
2556 | ||
907f92c8 DS |
2557 | DEFUN (bgp_disable_connected_route_check, |
2558 | bgp_disable_connected_route_check_cmd, | |
2559 | "bgp disable-ebgp-connected-route-check", | |
2560 | "BGP specific commands\n" | |
2561 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2562 | { | |
cdc2d765 | 2563 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
907f92c8 | 2564 | bgp_flag_set (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); |
f31fa004 | 2565 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 2566 | |
907f92c8 DS |
2567 | return CMD_SUCCESS; |
2568 | } | |
2569 | ||
2570 | DEFUN (no_bgp_disable_connected_route_check, | |
2571 | no_bgp_disable_connected_route_check_cmd, | |
2572 | "no bgp disable-ebgp-connected-route-check", | |
2573 | NO_STR | |
2574 | "BGP specific commands\n" | |
2575 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2576 | { | |
cdc2d765 | 2577 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
907f92c8 | 2578 | bgp_flag_unset (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); |
f31fa004 | 2579 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 2580 | |
907f92c8 DS |
2581 | return CMD_SUCCESS; |
2582 | } | |
2583 | ||
2584 | ||
718e3744 | 2585 | static int |
e52702f2 | 2586 | peer_remote_as_vty (struct vty *vty, const char *peer_str, |
fd79ac91 | 2587 | const char *as_str, afi_t afi, safi_t safi) |
718e3744 | 2588 | { |
cdc2d765 | 2589 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2590 | int ret; |
718e3744 | 2591 | as_t as; |
0299c004 | 2592 | int as_type = AS_SPECIFIED; |
718e3744 | 2593 | union sockunion su; |
2594 | ||
7ae5fc81 | 2595 | if (as_str[0] == 'i') |
0299c004 DS |
2596 | { |
2597 | as = 0; | |
2598 | as_type = AS_INTERNAL; | |
2599 | } | |
7ae5fc81 | 2600 | else if (as_str[0] == 'e') |
0299c004 DS |
2601 | { |
2602 | as = 0; | |
2603 | as_type = AS_EXTERNAL; | |
2604 | } | |
2605 | else | |
2606 | { | |
2607 | /* Get AS number. */ | |
2608 | VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX); | |
2609 | } | |
718e3744 | 2610 | |
2611 | /* If peer is peer group, call proper function. */ | |
2612 | ret = str2sockunion (peer_str, &su); | |
2613 | if (ret < 0) | |
2614 | { | |
a80beece | 2615 | /* Check for peer by interface */ |
0299c004 | 2616 | ret = peer_remote_as (bgp, NULL, peer_str, &as, as_type, afi, safi); |
718e3744 | 2617 | if (ret < 0) |
a80beece | 2618 | { |
0299c004 | 2619 | ret = peer_group_remote_as (bgp, peer_str, &as, as_type); |
a80beece DS |
2620 | if (ret < 0) |
2621 | { | |
2622 | vty_out (vty, "%% Create the peer-group or interface first%s", | |
2623 | VTY_NEWLINE); | |
2624 | return CMD_WARNING; | |
2625 | } | |
2626 | return CMD_SUCCESS; | |
2627 | } | |
718e3744 | 2628 | } |
a80beece | 2629 | else |
718e3744 | 2630 | { |
6aeb9e78 | 2631 | if (peer_address_self_check (bgp, &su)) |
a80beece DS |
2632 | { |
2633 | vty_out (vty, "%% Can not configure the local system as neighbor%s", | |
2634 | VTY_NEWLINE); | |
2635 | return CMD_WARNING; | |
2636 | } | |
0299c004 | 2637 | ret = peer_remote_as (bgp, &su, NULL, &as, as_type, afi, safi); |
718e3744 | 2638 | } |
2639 | ||
718e3744 | 2640 | /* This peer belongs to peer group. */ |
2641 | switch (ret) | |
2642 | { | |
2643 | case BGP_ERR_PEER_GROUP_MEMBER: | |
aea339f7 | 2644 | vty_out (vty, "%% Peer-group AS %u. Cannot configure remote-as for member%s", as, VTY_NEWLINE); |
718e3744 | 2645 | return CMD_WARNING; |
718e3744 | 2646 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: |
aea339f7 | 2647 | 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 | 2648 | return CMD_WARNING; |
718e3744 | 2649 | } |
2650 | return bgp_vty_return (vty, ret); | |
2651 | } | |
2652 | ||
2653 | DEFUN (neighbor_remote_as, | |
2654 | neighbor_remote_as_cmd, | |
3a2d747c | 2655 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2656 | NEIGHBOR_STR |
2657 | NEIGHBOR_ADDR_STR2 | |
2658 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 2659 | AS_STR |
3a2d747c QY |
2660 | "Internal BGP peer\n" |
2661 | "External BGP peer\n") | |
718e3744 | 2662 | { |
c500ae40 DW |
2663 | int idx_peer = 1; |
2664 | int idx_remote_as = 3; | |
2665 | return peer_remote_as_vty (vty, argv[idx_peer]->arg, argv[idx_remote_as]->arg, AFI_IP, SAFI_UNICAST); | |
718e3744 | 2666 | } |
6b0655a2 | 2667 | |
4c48cf63 DW |
2668 | static int |
2669 | peer_conf_interface_get (struct vty *vty, const char *conf_if, afi_t afi, | |
b3a39dc5 DD |
2670 | safi_t safi, int v6only, const char *peer_group_name, |
2671 | const char *as_str) | |
a80beece | 2672 | { |
cdc2d765 | 2673 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
b3a39dc5 DD |
2674 | as_t as = 0; |
2675 | int as_type = AS_UNSPECIFIED; | |
a80beece DS |
2676 | struct peer *peer; |
2677 | struct peer_group *group; | |
4c48cf63 DW |
2678 | int ret = 0; |
2679 | union sockunion su; | |
a80beece | 2680 | |
4c48cf63 DW |
2681 | group = peer_group_lookup (bgp, conf_if); |
2682 | ||
a80beece DS |
2683 | if (group) |
2684 | { | |
2685 | vty_out (vty, "%% Name conflict with peer-group %s", VTY_NEWLINE); | |
2686 | return CMD_WARNING; | |
2687 | } | |
2688 | ||
b3a39dc5 DD |
2689 | if (as_str) |
2690 | { | |
7ae5fc81 | 2691 | if (as_str[0] == 'i') |
b3a39dc5 DD |
2692 | { |
2693 | as_type = AS_INTERNAL; | |
2694 | } | |
7ae5fc81 | 2695 | else if (as_str[0] == 'e') |
b3a39dc5 DD |
2696 | { |
2697 | as_type = AS_EXTERNAL; | |
2698 | } | |
2699 | else | |
2700 | { | |
2701 | /* Get AS number. */ | |
2702 | VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX); | |
2703 | as_type = AS_SPECIFIED; | |
2704 | } | |
2705 | } | |
2706 | ||
4c48cf63 DW |
2707 | peer = peer_lookup_by_conf_if (bgp, conf_if); |
2708 | if (!peer) | |
2709 | { | |
2710 | if (bgp_flag_check (bgp, BGP_FLAG_NO_DEFAULT_IPV4) | |
2711 | && afi == AFI_IP && safi == SAFI_UNICAST) | |
b3a39dc5 DD |
2712 | peer = peer_create (NULL, conf_if, bgp, bgp->as, as, as_type, 0, 0, |
2713 | NULL); | |
4c48cf63 | 2714 | else |
b3a39dc5 DD |
2715 | peer = peer_create (NULL, conf_if, bgp, bgp->as, as, as_type, afi, safi, |
2716 | NULL); | |
4c48cf63 DW |
2717 | |
2718 | if (peer && v6only) | |
2719 | SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
4a04e5f7 | 2720 | |
2721 | /* Request zebra to initiate IPv6 RAs on this interface. We do this | |
2722 | * any unnumbered peer in order to not worry about run-time transitions | |
2723 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 address | |
2724 | * gets deleted later etc.) | |
2725 | */ | |
2726 | if (peer->ifp) | |
b3a39dc5 DD |
2727 | { |
2728 | bgp_zebra_initiate_radv (bgp, peer); | |
2729 | } | |
2730 | peer_flag_set (peer, PEER_FLAG_CAPABILITY_ENHE); | |
4c48cf63 DW |
2731 | } |
2732 | else if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) || | |
2733 | (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) | |
2734 | { | |
2735 | if (v6only) | |
2736 | SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2737 | else | |
2738 | UNSET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2739 | ||
2740 | /* v6only flag changed. Reset bgp seesion */ | |
2741 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) | |
2742 | { | |
2743 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
2744 | bgp_notify_send (peer, BGP_NOTIFY_CEASE, | |
2745 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2746 | } | |
2747 | else | |
2748 | bgp_session_reset(peer); | |
2749 | } | |
2750 | ||
a80beece DS |
2751 | if (!peer) |
2752 | return CMD_WARNING; | |
2753 | ||
4c48cf63 DW |
2754 | if (peer_group_name) |
2755 | { | |
2756 | group = peer_group_lookup (bgp, peer_group_name); | |
2757 | if (! group) | |
2758 | { | |
2759 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
2760 | return CMD_WARNING; | |
2761 | } | |
2762 | ||
2763 | ret = peer_group_bind (bgp, &su, peer, group, &as); | |
2764 | } | |
2765 | ||
2766 | return bgp_vty_return (vty, ret); | |
a80beece DS |
2767 | } |
2768 | ||
4c48cf63 DW |
2769 | DEFUN (neighbor_interface_config, |
2770 | neighbor_interface_config_cmd, | |
31500417 | 2771 | "neighbor WORD interface [peer-group WORD]", |
4c48cf63 DW |
2772 | NEIGHBOR_STR |
2773 | "Interface name or neighbor tag\n" | |
31500417 DW |
2774 | "Enable BGP on interface\n" |
2775 | "Member of the peer-group\n" | |
16cedbb0 | 2776 | "Peer-group name\n") |
4c48cf63 | 2777 | { |
c500ae40 | 2778 | int idx_word = 1; |
31500417 DW |
2779 | int idx_peer_group_word = 4; |
2780 | ||
2781 | if (argc > idx_peer_group_word) | |
c500ae40 | 2782 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, |
31500417 | 2783 | argv[idx_peer_group_word]->arg, NULL); |
4c48cf63 | 2784 | else |
c500ae40 | 2785 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, |
b3a39dc5 | 2786 | NULL, NULL); |
4c48cf63 DW |
2787 | } |
2788 | ||
4c48cf63 DW |
2789 | DEFUN (neighbor_interface_config_v6only, |
2790 | neighbor_interface_config_v6only_cmd, | |
31500417 | 2791 | "neighbor WORD interface v6only [peer-group WORD]", |
4c48cf63 DW |
2792 | NEIGHBOR_STR |
2793 | "Interface name or neighbor tag\n" | |
2794 | "Enable BGP on interface\n" | |
31500417 DW |
2795 | "Enable BGP with v6 link-local only\n" |
2796 | "Member of the peer-group\n" | |
16cedbb0 | 2797 | "Peer-group name\n") |
4c48cf63 | 2798 | { |
c500ae40 | 2799 | int idx_word = 1; |
31500417 DW |
2800 | int idx_peer_group_word = 5; |
2801 | ||
2802 | if (argc > idx_peer_group_word) | |
2803 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
2804 | argv[idx_peer_group_word]->arg, NULL); | |
2805 | ||
c500ae40 | 2806 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, |
31500417 | 2807 | NULL, NULL); |
4c48cf63 DW |
2808 | } |
2809 | ||
a80beece | 2810 | |
b3a39dc5 DD |
2811 | DEFUN (neighbor_interface_config_remote_as, |
2812 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 2813 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2814 | NEIGHBOR_STR |
2815 | "Interface name or neighbor tag\n" | |
2816 | "Enable BGP on interface\n" | |
3a2d747c | 2817 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2818 | AS_STR |
3a2d747c QY |
2819 | "Internal BGP peer\n" |
2820 | "External BGP peer\n") | |
b3a39dc5 | 2821 | { |
c500ae40 DW |
2822 | int idx_word = 1; |
2823 | int idx_remote_as = 4; | |
2824 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
2825 | NULL, argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2826 | } |
2827 | ||
2828 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
2829 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 2830 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2831 | NEIGHBOR_STR |
2832 | "Interface name or neighbor tag\n" | |
3a2d747c | 2833 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 2834 | "Enable BGP on interface\n" |
3a2d747c | 2835 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2836 | AS_STR |
3a2d747c QY |
2837 | "Internal BGP peer\n" |
2838 | "External BGP peer\n") | |
b3a39dc5 | 2839 | { |
c500ae40 DW |
2840 | int idx_word = 1; |
2841 | int idx_remote_as = 5; | |
2842 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
2843 | NULL, argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2844 | } |
2845 | ||
718e3744 | 2846 | DEFUN (neighbor_peer_group, |
2847 | neighbor_peer_group_cmd, | |
2848 | "neighbor WORD peer-group", | |
2849 | NEIGHBOR_STR | |
a80beece | 2850 | "Interface name or neighbor tag\n" |
718e3744 | 2851 | "Configure peer-group\n") |
2852 | { | |
cdc2d765 | 2853 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2854 | int idx_word = 1; |
a80beece | 2855 | struct peer *peer; |
718e3744 | 2856 | struct peer_group *group; |
2857 | ||
c500ae40 | 2858 | peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg); |
a80beece DS |
2859 | if (peer) |
2860 | { | |
2861 | vty_out (vty, "%% Name conflict with interface: %s", VTY_NEWLINE); | |
2862 | return CMD_WARNING; | |
2863 | } | |
718e3744 | 2864 | |
c500ae40 | 2865 | group = peer_group_get (bgp, argv[idx_word]->arg); |
718e3744 | 2866 | if (! group) |
2867 | return CMD_WARNING; | |
2868 | ||
2869 | return CMD_SUCCESS; | |
2870 | } | |
2871 | ||
2872 | DEFUN (no_neighbor, | |
2873 | no_neighbor_cmd, | |
dab8cd00 | 2874 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 2875 | NO_STR |
2876 | NEIGHBOR_STR | |
3a2d747c QY |
2877 | NEIGHBOR_ADDR_STR2 |
2878 | "Specify a BGP neighbor\n" | |
2879 | AS_STR | |
2880 | "Internal BGP peer\n" | |
2881 | "External BGP peer\n") | |
718e3744 | 2882 | { |
cdc2d765 | 2883 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2884 | int idx_peer = 2; |
718e3744 | 2885 | int ret; |
2886 | union sockunion su; | |
2887 | struct peer_group *group; | |
2888 | struct peer *peer; | |
1ff9a340 | 2889 | struct peer *other; |
718e3744 | 2890 | |
c500ae40 | 2891 | ret = str2sockunion (argv[idx_peer]->arg, &su); |
718e3744 | 2892 | if (ret < 0) |
2893 | { | |
a80beece | 2894 | /* look up for neighbor by interface name config. */ |
cdc2d765 | 2895 | peer = peer_lookup_by_conf_if (bgp, argv[idx_peer]->arg); |
a80beece DS |
2896 | if (peer) |
2897 | { | |
4a04e5f7 | 2898 | /* Request zebra to terminate IPv6 RAs on this interface. */ |
2899 | if (peer->ifp) | |
2900 | bgp_zebra_terminate_radv (peer->bgp, peer); | |
a80beece DS |
2901 | peer_delete (peer); |
2902 | return CMD_SUCCESS; | |
2903 | } | |
2904 | ||
cdc2d765 | 2905 | group = peer_group_lookup (bgp, argv[idx_peer]->arg); |
718e3744 | 2906 | if (group) |
2907 | peer_group_delete (group); | |
2908 | else | |
2909 | { | |
2910 | vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE); | |
2911 | return CMD_WARNING; | |
2912 | } | |
2913 | } | |
2914 | else | |
2915 | { | |
cdc2d765 | 2916 | peer = peer_lookup (bgp, &su); |
718e3744 | 2917 | if (peer) |
1ff9a340 | 2918 | { |
f14e6fdb DS |
2919 | if (peer_dynamic_neighbor (peer)) |
2920 | { | |
2921 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
2922 | VTY_NEWLINE); | |
2923 | return CMD_WARNING; | |
2924 | } | |
2925 | ||
1ff9a340 DS |
2926 | other = peer->doppelganger; |
2927 | peer_delete (peer); | |
2928 | if (other && other->status != Deleted) | |
2929 | peer_delete(other); | |
2930 | } | |
718e3744 | 2931 | } |
2932 | ||
2933 | return CMD_SUCCESS; | |
2934 | } | |
2935 | ||
a80beece DS |
2936 | DEFUN (no_neighbor_interface_config, |
2937 | no_neighbor_interface_config_cmd, | |
31500417 | 2938 | "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
2939 | NO_STR |
2940 | NEIGHBOR_STR | |
2941 | "Interface name\n" | |
31500417 DW |
2942 | "Configure BGP on interface\n" |
2943 | "Enable BGP with v6 link-local only\n" | |
2944 | "Member of the peer-group\n" | |
16cedbb0 | 2945 | "Peer-group name\n" |
3a2d747c QY |
2946 | "Specify a BGP neighbor\n" |
2947 | AS_STR | |
2948 | "Internal BGP peer\n" | |
2949 | "External BGP peer\n") | |
a80beece | 2950 | { |
cdc2d765 | 2951 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2952 | int idx_word = 2; |
a80beece DS |
2953 | struct peer *peer; |
2954 | ||
2955 | /* look up for neighbor by interface name config. */ | |
cdc2d765 | 2956 | peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg); |
a80beece DS |
2957 | if (peer) |
2958 | { | |
4a04e5f7 | 2959 | /* Request zebra to terminate IPv6 RAs on this interface. */ |
2960 | if (peer->ifp) | |
2961 | bgp_zebra_terminate_radv (peer->bgp, peer); | |
a80beece DS |
2962 | peer_delete (peer); |
2963 | } | |
2964 | else | |
2965 | { | |
2966 | vty_out (vty, "%% Create the bgp interface first%s", VTY_NEWLINE); | |
2967 | return CMD_WARNING; | |
2968 | } | |
2969 | return CMD_SUCCESS; | |
2970 | } | |
2971 | ||
718e3744 | 2972 | DEFUN (no_neighbor_peer_group, |
2973 | no_neighbor_peer_group_cmd, | |
2974 | "no neighbor WORD peer-group", | |
2975 | NO_STR | |
2976 | NEIGHBOR_STR | |
2977 | "Neighbor tag\n" | |
2978 | "Configure peer-group\n") | |
2979 | { | |
cdc2d765 | 2980 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2981 | int idx_word = 2; |
718e3744 | 2982 | struct peer_group *group; |
2983 | ||
cdc2d765 | 2984 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 2985 | if (group) |
2986 | peer_group_delete (group); | |
2987 | else | |
2988 | { | |
2989 | vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE); | |
2990 | return CMD_WARNING; | |
2991 | } | |
2992 | return CMD_SUCCESS; | |
2993 | } | |
2994 | ||
a80beece DS |
2995 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
2996 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 2997 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2998 | NO_STR |
2999 | NEIGHBOR_STR | |
a80beece | 3000 | "Interface name or neighbor tag\n" |
718e3744 | 3001 | "Specify a BGP neighbor\n" |
3a2d747c QY |
3002 | AS_STR |
3003 | "Internal BGP peer\n" | |
3004 | "External BGP peer\n") | |
718e3744 | 3005 | { |
cdc2d765 | 3006 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 3007 | int idx_word = 2; |
718e3744 | 3008 | struct peer_group *group; |
a80beece DS |
3009 | struct peer *peer; |
3010 | ||
3011 | /* look up for neighbor by interface name config. */ | |
cdc2d765 | 3012 | peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg); |
a80beece DS |
3013 | if (peer) |
3014 | { | |
0299c004 | 3015 | peer_as_change (peer, 0, AS_SPECIFIED); |
a80beece DS |
3016 | return CMD_SUCCESS; |
3017 | } | |
718e3744 | 3018 | |
cdc2d765 | 3019 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 3020 | if (group) |
3021 | peer_group_remote_as_delete (group); | |
3022 | else | |
3023 | { | |
a80beece | 3024 | vty_out (vty, "%% Create the peer-group or interface first%s", VTY_NEWLINE); |
718e3744 | 3025 | return CMD_WARNING; |
3026 | } | |
3027 | return CMD_SUCCESS; | |
3028 | } | |
6b0655a2 | 3029 | |
718e3744 | 3030 | DEFUN (neighbor_local_as, |
3031 | neighbor_local_as_cmd, | |
9ccf14f7 | 3032 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 3033 | NEIGHBOR_STR |
3034 | NEIGHBOR_ADDR_STR2 | |
3035 | "Specify a local-as number\n" | |
3036 | "AS number used as local AS\n") | |
3037 | { | |
c500ae40 DW |
3038 | int idx_peer = 1; |
3039 | int idx_number = 3; | |
718e3744 | 3040 | struct peer *peer; |
3041 | int ret; | |
e14fda0f | 3042 | as_t as; |
718e3744 | 3043 | |
c500ae40 | 3044 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3045 | if (! peer) |
3046 | return CMD_WARNING; | |
3047 | ||
b6f1faf0 | 3048 | VTY_GET_INTEGER_RANGE ("Local AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); |
e14fda0f | 3049 | ret = peer_local_as_set (peer, as, 0, 0); |
718e3744 | 3050 | return bgp_vty_return (vty, ret); |
3051 | } | |
3052 | ||
3053 | DEFUN (neighbor_local_as_no_prepend, | |
3054 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 3055 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 3056 | NEIGHBOR_STR |
3057 | NEIGHBOR_ADDR_STR2 | |
3058 | "Specify a local-as number\n" | |
3059 | "AS number used as local AS\n" | |
3060 | "Do not prepend local-as to updates from ebgp peers\n") | |
3061 | { | |
c500ae40 DW |
3062 | int idx_peer = 1; |
3063 | int idx_number = 3; | |
718e3744 | 3064 | struct peer *peer; |
3065 | int ret; | |
e14fda0f | 3066 | as_t as; |
718e3744 | 3067 | |
c500ae40 | 3068 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3069 | if (! peer) |
3070 | return CMD_WARNING; | |
3071 | ||
b6f1faf0 | 3072 | VTY_GET_INTEGER_RANGE ("Local AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); |
e14fda0f | 3073 | ret = peer_local_as_set (peer, as, 1, 0); |
718e3744 | 3074 | return bgp_vty_return (vty, ret); |
3075 | } | |
3076 | ||
9d3f9705 AC |
3077 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
3078 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 3079 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
3080 | NEIGHBOR_STR |
3081 | NEIGHBOR_ADDR_STR2 | |
3082 | "Specify a local-as number\n" | |
3083 | "AS number used as local AS\n" | |
3084 | "Do not prepend local-as to updates from ebgp peers\n" | |
3085 | "Do not prepend local-as to updates from ibgp peers\n") | |
3086 | { | |
c500ae40 DW |
3087 | int idx_peer = 1; |
3088 | int idx_number = 3; | |
9d3f9705 AC |
3089 | struct peer *peer; |
3090 | int ret; | |
e14fda0f | 3091 | as_t as; |
9d3f9705 | 3092 | |
c500ae40 | 3093 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
9d3f9705 AC |
3094 | if (! peer) |
3095 | return CMD_WARNING; | |
3096 | ||
b6f1faf0 | 3097 | VTY_GET_INTEGER_RANGE ("Local AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); |
e14fda0f | 3098 | ret = peer_local_as_set (peer, as, 1, 1); |
9d3f9705 AC |
3099 | return bgp_vty_return (vty, ret); |
3100 | } | |
3101 | ||
718e3744 | 3102 | DEFUN (no_neighbor_local_as, |
3103 | no_neighbor_local_as_cmd, | |
a636c635 | 3104 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 3105 | NO_STR |
3106 | NEIGHBOR_STR | |
3107 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
3108 | "Specify a local-as number\n" |
3109 | "AS number used as local AS\n" | |
3110 | "Do not prepend local-as to updates from ebgp peers\n" | |
3111 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 3112 | { |
c500ae40 | 3113 | int idx_peer = 2; |
718e3744 | 3114 | struct peer *peer; |
3115 | int ret; | |
3116 | ||
c500ae40 | 3117 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3118 | if (! peer) |
3119 | return CMD_WARNING; | |
3120 | ||
3121 | ret = peer_local_as_unset (peer); | |
3122 | return bgp_vty_return (vty, ret); | |
3123 | } | |
3124 | ||
718e3744 | 3125 | |
9d3f9705 | 3126 | |
6b0655a2 | 3127 | |
3f9c7369 DS |
3128 | DEFUN (neighbor_solo, |
3129 | neighbor_solo_cmd, | |
9ccf14f7 | 3130 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3131 | NEIGHBOR_STR |
3132 | NEIGHBOR_ADDR_STR2 | |
3133 | "Solo peer - part of its own update group\n") | |
3134 | { | |
c500ae40 | 3135 | int idx_peer = 1; |
3f9c7369 DS |
3136 | struct peer *peer; |
3137 | int ret; | |
3138 | ||
c500ae40 | 3139 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
3f9c7369 DS |
3140 | if (! peer) |
3141 | return CMD_WARNING; | |
3142 | ||
3143 | ret = update_group_adjust_soloness(peer, 1); | |
3144 | return bgp_vty_return (vty, ret); | |
3145 | } | |
3146 | ||
3147 | DEFUN (no_neighbor_solo, | |
3148 | no_neighbor_solo_cmd, | |
9ccf14f7 | 3149 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3150 | NO_STR |
3151 | NEIGHBOR_STR | |
3152 | NEIGHBOR_ADDR_STR2 | |
3153 | "Solo peer - part of its own update group\n") | |
3154 | { | |
c500ae40 | 3155 | int idx_peer = 2; |
3f9c7369 DS |
3156 | struct peer *peer; |
3157 | int ret; | |
3158 | ||
c500ae40 | 3159 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
3f9c7369 DS |
3160 | if (! peer) |
3161 | return CMD_WARNING; | |
3162 | ||
3163 | ret = update_group_adjust_soloness(peer, 0); | |
3164 | return bgp_vty_return (vty, ret); | |
3165 | } | |
3166 | ||
0df7c91f PJ |
3167 | DEFUN (neighbor_password, |
3168 | neighbor_password_cmd, | |
9ccf14f7 | 3169 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
3170 | NEIGHBOR_STR |
3171 | NEIGHBOR_ADDR_STR2 | |
3172 | "Set a password\n" | |
3173 | "The password\n") | |
3174 | { | |
c500ae40 DW |
3175 | int idx_peer = 1; |
3176 | int idx_line = 3; | |
0df7c91f PJ |
3177 | struct peer *peer; |
3178 | int ret; | |
3179 | ||
c500ae40 | 3180 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
0df7c91f PJ |
3181 | if (! peer) |
3182 | return CMD_WARNING; | |
3183 | ||
c500ae40 | 3184 | ret = peer_password_set (peer, argv[idx_line]->arg); |
0df7c91f PJ |
3185 | return bgp_vty_return (vty, ret); |
3186 | } | |
3187 | ||
3188 | DEFUN (no_neighbor_password, | |
3189 | no_neighbor_password_cmd, | |
a636c635 | 3190 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
3191 | NO_STR |
3192 | NEIGHBOR_STR | |
3193 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
3194 | "Set a password\n" |
3195 | "The password\n") | |
0df7c91f | 3196 | { |
c500ae40 | 3197 | int idx_peer = 2; |
0df7c91f PJ |
3198 | struct peer *peer; |
3199 | int ret; | |
3200 | ||
c500ae40 | 3201 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
0df7c91f PJ |
3202 | if (! peer) |
3203 | return CMD_WARNING; | |
3204 | ||
3205 | ret = peer_password_unset (peer); | |
3206 | return bgp_vty_return (vty, ret); | |
3207 | } | |
6b0655a2 | 3208 | |
813d4307 | 3209 | |
718e3744 | 3210 | DEFUN (neighbor_activate, |
3211 | neighbor_activate_cmd, | |
9ccf14f7 | 3212 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3213 | NEIGHBOR_STR |
3214 | NEIGHBOR_ADDR_STR2 | |
3215 | "Enable the Address Family for this Neighbor\n") | |
3216 | { | |
c500ae40 | 3217 | int idx_peer = 1; |
c8560b44 | 3218 | int ret; |
718e3744 | 3219 | struct peer *peer; |
3220 | ||
c500ae40 | 3221 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3222 | if (! peer) |
3223 | return CMD_WARNING; | |
3224 | ||
c8560b44 | 3225 | ret = peer_activate (peer, bgp_node_afi (vty), bgp_node_safi (vty)); |
718e3744 | 3226 | |
c8560b44 DW |
3227 | if (ret) |
3228 | return CMD_WARNING; | |
718e3744 | 3229 | return CMD_SUCCESS; |
3230 | } | |
3231 | ||
3232 | DEFUN (no_neighbor_activate, | |
3233 | no_neighbor_activate_cmd, | |
9ccf14f7 | 3234 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3235 | NO_STR |
3236 | NEIGHBOR_STR | |
3237 | NEIGHBOR_ADDR_STR2 | |
3238 | "Enable the Address Family for this Neighbor\n") | |
3239 | { | |
c500ae40 | 3240 | int idx_peer = 2; |
718e3744 | 3241 | int ret; |
3242 | struct peer *peer; | |
3243 | ||
3244 | /* Lookup peer. */ | |
c500ae40 | 3245 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3246 | if (! peer) |
3247 | return CMD_WARNING; | |
3248 | ||
3249 | ret = peer_deactivate (peer, bgp_node_afi (vty), bgp_node_safi (vty)); | |
3250 | ||
c8560b44 DW |
3251 | if (ret) |
3252 | return CMD_WARNING; | |
3253 | return CMD_SUCCESS; | |
718e3744 | 3254 | } |
6b0655a2 | 3255 | |
718e3744 | 3256 | DEFUN (neighbor_set_peer_group, |
3257 | neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3258 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3259 | NEIGHBOR_STR |
a80beece | 3260 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3261 | "Member of the peer-group\n" |
16cedbb0 | 3262 | "Peer-group name\n") |
718e3744 | 3263 | { |
cdc2d765 | 3264 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
3265 | int idx_peer = 1; |
3266 | int idx_word = 3; | |
718e3744 | 3267 | int ret; |
3268 | as_t as; | |
3269 | union sockunion su; | |
a80beece | 3270 | struct peer *peer; |
718e3744 | 3271 | struct peer_group *group; |
3272 | ||
a80beece | 3273 | peer = NULL; |
718e3744 | 3274 | |
c500ae40 | 3275 | ret = str2sockunion (argv[idx_peer]->arg, &su); |
718e3744 | 3276 | if (ret < 0) |
3277 | { | |
c500ae40 | 3278 | peer = peer_lookup_by_conf_if (bgp, argv[idx_peer]->arg); |
a80beece DS |
3279 | if (!peer) |
3280 | { | |
c500ae40 | 3281 | vty_out (vty, "%% Malformed address or name: %s%s", argv[idx_peer]->arg, VTY_NEWLINE); |
a80beece DS |
3282 | return CMD_WARNING; |
3283 | } | |
3284 | } | |
3285 | else | |
3286 | { | |
6aeb9e78 | 3287 | if (peer_address_self_check (bgp, &su)) |
a80beece DS |
3288 | { |
3289 | vty_out (vty, "%% Can not configure the local system as neighbor%s", | |
3290 | VTY_NEWLINE); | |
3291 | return CMD_WARNING; | |
3292 | } | |
f14e6fdb DS |
3293 | |
3294 | /* Disallow for dynamic neighbor. */ | |
3295 | peer = peer_lookup (bgp, &su); | |
3296 | if (peer && peer_dynamic_neighbor (peer)) | |
3297 | { | |
3298 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
3299 | VTY_NEWLINE); | |
3300 | return CMD_WARNING; | |
3301 | } | |
718e3744 | 3302 | } |
3303 | ||
c500ae40 | 3304 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 3305 | if (! group) |
3306 | { | |
3307 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
3308 | return CMD_WARNING; | |
3309 | } | |
3310 | ||
c8560b44 | 3311 | ret = peer_group_bind (bgp, &su, peer, group, &as); |
718e3744 | 3312 | |
3313 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) | |
3314 | { | |
aea339f7 | 3315 | 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 | 3316 | return CMD_WARNING; |
3317 | } | |
3318 | ||
3319 | return bgp_vty_return (vty, ret); | |
3320 | } | |
3321 | ||
3322 | DEFUN (no_neighbor_set_peer_group, | |
3323 | no_neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3324 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3325 | NO_STR |
3326 | NEIGHBOR_STR | |
a80beece | 3327 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3328 | "Member of the peer-group\n" |
16cedbb0 | 3329 | "Peer-group name\n") |
718e3744 | 3330 | { |
cdc2d765 | 3331 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
3332 | int idx_peer = 2; |
3333 | int idx_word = 4; | |
718e3744 | 3334 | int ret; |
718e3744 | 3335 | struct peer *peer; |
3336 | struct peer_group *group; | |
3337 | ||
c500ae40 | 3338 | peer = peer_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3339 | if (! peer) |
3340 | return CMD_WARNING; | |
3341 | ||
c500ae40 | 3342 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 3343 | if (! group) |
3344 | { | |
3345 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
3346 | return CMD_WARNING; | |
3347 | } | |
3348 | ||
c8560b44 | 3349 | ret = peer_group_unbind (bgp, peer, group); |
718e3744 | 3350 | |
3351 | return bgp_vty_return (vty, ret); | |
3352 | } | |
6b0655a2 | 3353 | |
94f2b392 | 3354 | static int |
e52702f2 | 3355 | peer_flag_modify_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 3356 | u_int16_t flag, int set) |
718e3744 | 3357 | { |
3358 | int ret; | |
3359 | struct peer *peer; | |
3360 | ||
3361 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
3362 | if (! peer) | |
3363 | return CMD_WARNING; | |
3364 | ||
8cdabf90 SK |
3365 | /* |
3366 | * If 'neighbor <interface>', then this is for directly connected peers, | |
3367 | * we should not accept disable-connected-check. | |
3368 | */ | |
3369 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
3370 | vty_out (vty, "%s is directly connected peer, cannot accept disable-" | |
3371 | "connected-check%s", ip_str, VTY_NEWLINE); | |
3372 | return CMD_WARNING; | |
3373 | } | |
3374 | ||
718e3744 | 3375 | if (set) |
3376 | ret = peer_flag_set (peer, flag); | |
3377 | else | |
3378 | ret = peer_flag_unset (peer, flag); | |
3379 | ||
3380 | return bgp_vty_return (vty, ret); | |
3381 | } | |
3382 | ||
94f2b392 | 3383 | static int |
fd79ac91 | 3384 | peer_flag_set_vty (struct vty *vty, const char *ip_str, u_int16_t flag) |
718e3744 | 3385 | { |
3386 | return peer_flag_modify_vty (vty, ip_str, flag, 1); | |
3387 | } | |
3388 | ||
94f2b392 | 3389 | static int |
fd79ac91 | 3390 | peer_flag_unset_vty (struct vty *vty, const char *ip_str, u_int16_t flag) |
718e3744 | 3391 | { |
3392 | return peer_flag_modify_vty (vty, ip_str, flag, 0); | |
3393 | } | |
3394 | ||
3395 | /* neighbor passive. */ | |
3396 | DEFUN (neighbor_passive, | |
3397 | neighbor_passive_cmd, | |
9ccf14f7 | 3398 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3399 | NEIGHBOR_STR |
3400 | NEIGHBOR_ADDR_STR2 | |
3401 | "Don't send open messages to this neighbor\n") | |
3402 | { | |
c500ae40 DW |
3403 | int idx_peer = 1; |
3404 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3405 | } |
3406 | ||
3407 | DEFUN (no_neighbor_passive, | |
3408 | no_neighbor_passive_cmd, | |
9ccf14f7 | 3409 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3410 | NO_STR |
3411 | NEIGHBOR_STR | |
3412 | NEIGHBOR_ADDR_STR2 | |
3413 | "Don't send open messages to this neighbor\n") | |
3414 | { | |
c500ae40 DW |
3415 | int idx_peer = 2; |
3416 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3417 | } |
6b0655a2 | 3418 | |
718e3744 | 3419 | /* neighbor shutdown. */ |
73d70fa6 DL |
3420 | DEFUN (neighbor_shutdown_msg, |
3421 | neighbor_shutdown_msg_cmd, | |
3422 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
718e3744 | 3423 | NEIGHBOR_STR |
3424 | NEIGHBOR_ADDR_STR2 | |
73d70fa6 DL |
3425 | "Administratively shut down this neighbor\n" |
3426 | "Add a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3427 | "Shutdown message\n") | |
718e3744 | 3428 | { |
c500ae40 | 3429 | int idx_peer = 1; |
73d70fa6 DL |
3430 | |
3431 | if (argc >= 5) | |
3432 | { | |
3433 | struct peer *peer = peer_lookup_vty (vty, argv[idx_peer]->arg); | |
3434 | char *message; | |
3435 | ||
3436 | message = argv_concat (argv, argc, 4); | |
3437 | peer_tx_shutdown_message_set (peer, message); | |
3438 | XFREE (MTYPE_TMP, message); | |
3439 | } | |
3440 | ||
c500ae40 | 3441 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 3442 | } |
3443 | ||
73d70fa6 DL |
3444 | ALIAS (neighbor_shutdown_msg, |
3445 | neighbor_shutdown_cmd, | |
3446 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
718e3744 | 3447 | NEIGHBOR_STR |
3448 | NEIGHBOR_ADDR_STR2 | |
3449 | "Administratively shut down this neighbor\n") | |
73d70fa6 DL |
3450 | |
3451 | DEFUN (no_neighbor_shutdown_msg, | |
3452 | no_neighbor_shutdown_msg_cmd, | |
3453 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
3454 | NO_STR | |
3455 | NEIGHBOR_STR | |
3456 | NEIGHBOR_ADDR_STR2 | |
3457 | "Administratively shut down this neighbor\n" | |
3458 | "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3459 | "Shutdown message\n") | |
718e3744 | 3460 | { |
c500ae40 | 3461 | int idx_peer = 2; |
73d70fa6 DL |
3462 | |
3463 | struct peer *peer = peer_lookup_vty (vty, argv[idx_peer]->arg); | |
3464 | peer_tx_shutdown_message_unset (peer); | |
3465 | ||
c500ae40 | 3466 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 3467 | } |
6b0655a2 | 3468 | |
73d70fa6 DL |
3469 | ALIAS (no_neighbor_shutdown_msg, |
3470 | no_neighbor_shutdown_cmd, | |
3471 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3472 | NO_STR | |
3473 | NEIGHBOR_STR | |
3474 | NEIGHBOR_ADDR_STR2 | |
3475 | "Administratively shut down this neighbor\n") | |
3476 | ||
718e3744 | 3477 | /* neighbor capability dynamic. */ |
3478 | DEFUN (neighbor_capability_dynamic, | |
3479 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3480 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3481 | NEIGHBOR_STR |
3482 | NEIGHBOR_ADDR_STR2 | |
3483 | "Advertise capability to the peer\n" | |
3484 | "Advertise dynamic capability to this neighbor\n") | |
3485 | { | |
c500ae40 DW |
3486 | int idx_peer = 1; |
3487 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3488 | } |
3489 | ||
3490 | DEFUN (no_neighbor_capability_dynamic, | |
3491 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3492 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3493 | NO_STR |
3494 | NEIGHBOR_STR | |
3495 | NEIGHBOR_ADDR_STR2 | |
3496 | "Advertise capability to the peer\n" | |
3497 | "Advertise dynamic capability to this neighbor\n") | |
3498 | { | |
c500ae40 DW |
3499 | int idx_peer = 2; |
3500 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3501 | } |
6b0655a2 | 3502 | |
718e3744 | 3503 | /* neighbor dont-capability-negotiate */ |
3504 | DEFUN (neighbor_dont_capability_negotiate, | |
3505 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3506 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3507 | NEIGHBOR_STR |
3508 | NEIGHBOR_ADDR_STR2 | |
3509 | "Do not perform capability negotiation\n") | |
3510 | { | |
c500ae40 DW |
3511 | int idx_peer = 1; |
3512 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3513 | } |
3514 | ||
3515 | DEFUN (no_neighbor_dont_capability_negotiate, | |
3516 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3517 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3518 | NO_STR |
3519 | NEIGHBOR_STR | |
3520 | NEIGHBOR_ADDR_STR2 | |
3521 | "Do not perform capability negotiation\n") | |
3522 | { | |
c500ae40 DW |
3523 | int idx_peer = 2; |
3524 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3525 | } |
6b0655a2 | 3526 | |
8a92a8a0 DS |
3527 | /* neighbor capability extended next hop encoding */ |
3528 | DEFUN (neighbor_capability_enhe, | |
3529 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3530 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3531 | NEIGHBOR_STR |
3532 | NEIGHBOR_ADDR_STR2 | |
3533 | "Advertise capability to the peer\n" | |
3534 | "Advertise extended next-hop capability to the peer\n") | |
3535 | { | |
c500ae40 DW |
3536 | int idx_peer = 1; |
3537 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3538 | } |
3539 | ||
3540 | DEFUN (no_neighbor_capability_enhe, | |
3541 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3542 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3543 | NO_STR |
3544 | NEIGHBOR_STR | |
3545 | NEIGHBOR_ADDR_STR2 | |
3546 | "Advertise capability to the peer\n" | |
3547 | "Advertise extended next-hop capability to the peer\n") | |
3548 | { | |
c500ae40 DW |
3549 | int idx_peer = 2; |
3550 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3551 | } |
3552 | ||
94f2b392 | 3553 | static int |
fd79ac91 | 3554 | peer_af_flag_modify_vty (struct vty *vty, const char *peer_str, afi_t afi, |
fee0f4c6 | 3555 | safi_t safi, u_int32_t flag, int set) |
718e3744 | 3556 | { |
3557 | int ret; | |
3558 | struct peer *peer; | |
3559 | ||
3560 | peer = peer_and_group_lookup_vty (vty, peer_str); | |
3561 | if (! peer) | |
3562 | return CMD_WARNING; | |
3563 | ||
3564 | if (set) | |
3565 | ret = peer_af_flag_set (peer, afi, safi, flag); | |
3566 | else | |
3567 | ret = peer_af_flag_unset (peer, afi, safi, flag); | |
3568 | ||
3569 | return bgp_vty_return (vty, ret); | |
3570 | } | |
3571 | ||
94f2b392 | 3572 | static int |
fd79ac91 | 3573 | peer_af_flag_set_vty (struct vty *vty, const char *peer_str, afi_t afi, |
fee0f4c6 | 3574 | safi_t safi, u_int32_t flag) |
718e3744 | 3575 | { |
3576 | return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 1); | |
3577 | } | |
3578 | ||
94f2b392 | 3579 | static int |
fd79ac91 | 3580 | peer_af_flag_unset_vty (struct vty *vty, const char *peer_str, afi_t afi, |
fee0f4c6 | 3581 | safi_t safi, u_int32_t flag) |
718e3744 | 3582 | { |
3583 | return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 0); | |
3584 | } | |
6b0655a2 | 3585 | |
718e3744 | 3586 | /* neighbor capability orf prefix-list. */ |
3587 | DEFUN (neighbor_capability_orf_prefix, | |
3588 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3589 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3590 | NEIGHBOR_STR |
3591 | NEIGHBOR_ADDR_STR2 | |
3592 | "Advertise capability to the peer\n" | |
3593 | "Advertise ORF capability to the peer\n" | |
3594 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3595 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3596 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3597 | "Capability to SEND the ORF to this neighbor\n") | |
3598 | { | |
c500ae40 DW |
3599 | int idx_peer = 1; |
3600 | int idx_send_recv = 5; | |
718e3744 | 3601 | u_int16_t flag = 0; |
3602 | ||
c500ae40 | 3603 | if (strncmp (argv[idx_send_recv]->arg, "s", 1) == 0) |
718e3744 | 3604 | flag = PEER_FLAG_ORF_PREFIX_SM; |
c500ae40 | 3605 | else if (strncmp (argv[idx_send_recv]->arg, "r", 1) == 0) |
718e3744 | 3606 | flag = PEER_FLAG_ORF_PREFIX_RM; |
c500ae40 | 3607 | else if (strncmp (argv[idx_send_recv]->arg, "b", 1) == 0) |
718e3744 | 3608 | flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM; |
3609 | else | |
3610 | return CMD_WARNING; | |
3611 | ||
c500ae40 | 3612 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 3613 | bgp_node_safi (vty), flag); |
3614 | } | |
3615 | ||
3616 | DEFUN (no_neighbor_capability_orf_prefix, | |
3617 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3618 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3619 | NO_STR |
3620 | NEIGHBOR_STR | |
3621 | NEIGHBOR_ADDR_STR2 | |
3622 | "Advertise capability to the peer\n" | |
3623 | "Advertise ORF capability to the peer\n" | |
3624 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3625 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3626 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3627 | "Capability to SEND the ORF to this neighbor\n") | |
3628 | { | |
c500ae40 DW |
3629 | int idx_peer = 2; |
3630 | int idx_send_recv = 6; | |
718e3744 | 3631 | u_int16_t flag = 0; |
3632 | ||
c500ae40 | 3633 | if (strncmp (argv[idx_send_recv]->arg, "s", 1) == 0) |
718e3744 | 3634 | flag = PEER_FLAG_ORF_PREFIX_SM; |
c500ae40 | 3635 | else if (strncmp (argv[idx_send_recv]->arg, "r", 1) == 0) |
718e3744 | 3636 | flag = PEER_FLAG_ORF_PREFIX_RM; |
c500ae40 | 3637 | else if (strncmp (argv[idx_send_recv]->arg, "b", 1) == 0) |
718e3744 | 3638 | flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM; |
3639 | else | |
3640 | return CMD_WARNING; | |
3641 | ||
c500ae40 | 3642 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 3643 | bgp_node_safi (vty), flag); |
3644 | } | |
6b0655a2 | 3645 | |
718e3744 | 3646 | /* neighbor next-hop-self. */ |
3647 | DEFUN (neighbor_nexthop_self, | |
3648 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3649 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3650 | NEIGHBOR_STR |
3651 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3652 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3653 | { |
c500ae40 DW |
3654 | int idx_peer = 1; |
3655 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
a538debe DS |
3656 | bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF); |
3657 | } | |
9e7a53c1 | 3658 | |
a538debe DS |
3659 | /* neighbor next-hop-self. */ |
3660 | DEFUN (neighbor_nexthop_self_force, | |
3661 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 3662 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3663 | NEIGHBOR_STR |
3664 | NEIGHBOR_ADDR_STR2 | |
3665 | "Disable the next hop calculation for this neighbor\n" | |
3666 | "Set the next hop to self for reflected routes\n") | |
3667 | { | |
c500ae40 DW |
3668 | int idx_peer = 1; |
3669 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
a538debe | 3670 | bgp_node_safi (vty), |
88b8ed8d | 3671 | PEER_FLAG_FORCE_NEXTHOP_SELF); |
718e3744 | 3672 | } |
3673 | ||
3674 | DEFUN (no_neighbor_nexthop_self, | |
3675 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3676 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3677 | NO_STR |
3678 | NEIGHBOR_STR | |
3679 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3680 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3681 | { |
c500ae40 DW |
3682 | int idx_peer = 2; |
3683 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
9e7a53c1 | 3684 | bgp_node_safi (vty), |
88b8ed8d | 3685 | PEER_FLAG_NEXTHOP_SELF); |
718e3744 | 3686 | } |
6b0655a2 | 3687 | |
88b8ed8d | 3688 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 3689 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 3690 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3691 | NO_STR |
3692 | NEIGHBOR_STR | |
3693 | NEIGHBOR_ADDR_STR2 | |
3694 | "Disable the next hop calculation for this neighbor\n" | |
3695 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 3696 | { |
c500ae40 DW |
3697 | int idx_peer = 2; |
3698 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
3699 | bgp_node_safi (vty), |
3700 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
3701 | } | |
a538debe | 3702 | |
c7122e14 DS |
3703 | /* neighbor as-override */ |
3704 | DEFUN (neighbor_as_override, | |
3705 | neighbor_as_override_cmd, | |
9ccf14f7 | 3706 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3707 | NEIGHBOR_STR |
3708 | NEIGHBOR_ADDR_STR2 | |
3709 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3710 | { | |
c500ae40 DW |
3711 | int idx_peer = 1; |
3712 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
c7122e14 DS |
3713 | bgp_node_safi (vty), |
3714 | PEER_FLAG_AS_OVERRIDE); | |
3715 | } | |
3716 | ||
3717 | DEFUN (no_neighbor_as_override, | |
3718 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 3719 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3720 | NO_STR |
3721 | NEIGHBOR_STR | |
3722 | NEIGHBOR_ADDR_STR2 | |
3723 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3724 | { | |
c500ae40 DW |
3725 | int idx_peer = 2; |
3726 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
c7122e14 DS |
3727 | bgp_node_safi (vty), |
3728 | PEER_FLAG_AS_OVERRIDE); | |
3729 | } | |
3730 | ||
718e3744 | 3731 | /* neighbor remove-private-AS. */ |
3732 | DEFUN (neighbor_remove_private_as, | |
3733 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3734 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3735 | NEIGHBOR_STR |
3736 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3737 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3738 | { |
c500ae40 DW |
3739 | int idx_peer = 1; |
3740 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3741 | bgp_node_safi (vty), |
3742 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
3743 | } | |
3744 | ||
5000f21c DS |
3745 | DEFUN (neighbor_remove_private_as_all, |
3746 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 3747 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
3748 | NEIGHBOR_STR |
3749 | NEIGHBOR_ADDR_STR2 | |
3750 | "Remove private ASNs in outbound updates\n" | |
3751 | "Apply to all AS numbers") | |
3752 | { | |
c500ae40 DW |
3753 | int idx_peer = 1; |
3754 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5000f21c | 3755 | bgp_node_safi (vty), |
5000f21c DS |
3756 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); |
3757 | } | |
3758 | ||
3759 | DEFUN (neighbor_remove_private_as_replace_as, | |
3760 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 3761 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
3762 | NEIGHBOR_STR |
3763 | NEIGHBOR_ADDR_STR2 | |
3764 | "Remove private ASNs in outbound updates\n" | |
3765 | "Replace private ASNs with our ASN in outbound updates\n") | |
3766 | { | |
c500ae40 DW |
3767 | int idx_peer = 1; |
3768 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5000f21c | 3769 | bgp_node_safi (vty), |
5000f21c DS |
3770 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); |
3771 | } | |
3772 | ||
3773 | DEFUN (neighbor_remove_private_as_all_replace_as, | |
3774 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 3775 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
3776 | NEIGHBOR_STR |
3777 | NEIGHBOR_ADDR_STR2 | |
3778 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3779 | "Apply to all AS numbers\n" |
5000f21c DS |
3780 | "Replace private ASNs with our ASN in outbound updates\n") |
3781 | { | |
c500ae40 DW |
3782 | int idx_peer = 1; |
3783 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5000f21c | 3784 | bgp_node_safi (vty), |
88b8ed8d | 3785 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); |
5000f21c DS |
3786 | } |
3787 | ||
718e3744 | 3788 | DEFUN (no_neighbor_remove_private_as, |
3789 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3790 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3791 | NO_STR |
3792 | NEIGHBOR_STR | |
3793 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3794 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3795 | { |
c500ae40 DW |
3796 | int idx_peer = 2; |
3797 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3798 | bgp_node_safi (vty), |
88b8ed8d | 3799 | PEER_FLAG_REMOVE_PRIVATE_AS); |
718e3744 | 3800 | } |
6b0655a2 | 3801 | |
88b8ed8d | 3802 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 3803 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 3804 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
3805 | NO_STR |
3806 | NEIGHBOR_STR | |
3807 | NEIGHBOR_ADDR_STR2 | |
3808 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3809 | "Apply to all AS numbers\n") |
88b8ed8d | 3810 | { |
c500ae40 DW |
3811 | int idx_peer = 2; |
3812 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
3813 | bgp_node_safi (vty), |
3814 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
3815 | } | |
5000f21c | 3816 | |
88b8ed8d | 3817 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 3818 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 3819 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
3820 | NO_STR |
3821 | NEIGHBOR_STR | |
3822 | NEIGHBOR_ADDR_STR2 | |
3823 | "Remove private ASNs in outbound updates\n" | |
3824 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 3825 | { |
c500ae40 DW |
3826 | int idx_peer = 2; |
3827 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
3828 | bgp_node_safi (vty), |
3829 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
3830 | } | |
5000f21c | 3831 | |
88b8ed8d | 3832 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 3833 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 3834 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
3835 | NO_STR |
3836 | NEIGHBOR_STR | |
3837 | NEIGHBOR_ADDR_STR2 | |
3838 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3839 | "Apply to all AS numbers\n" |
5000f21c | 3840 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 3841 | { |
c500ae40 DW |
3842 | int idx_peer = 2; |
3843 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
3844 | bgp_node_safi (vty), |
3845 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
3846 | } | |
5000f21c DS |
3847 | |
3848 | ||
718e3744 | 3849 | /* neighbor send-community. */ |
3850 | DEFUN (neighbor_send_community, | |
3851 | neighbor_send_community_cmd, | |
9ccf14f7 | 3852 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 3853 | NEIGHBOR_STR |
3854 | NEIGHBOR_ADDR_STR2 | |
3855 | "Send Community attribute to this neighbor\n") | |
3856 | { | |
c500ae40 DW |
3857 | int idx_peer = 1; |
3858 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3859 | bgp_node_safi (vty), |
3860 | PEER_FLAG_SEND_COMMUNITY); | |
3861 | } | |
3862 | ||
3863 | DEFUN (no_neighbor_send_community, | |
3864 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 3865 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 3866 | NO_STR |
3867 | NEIGHBOR_STR | |
3868 | NEIGHBOR_ADDR_STR2 | |
3869 | "Send Community attribute to this neighbor\n") | |
3870 | { | |
c500ae40 DW |
3871 | int idx_peer = 2; |
3872 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3873 | bgp_node_safi (vty), |
3874 | PEER_FLAG_SEND_COMMUNITY); | |
3875 | } | |
6b0655a2 | 3876 | |
718e3744 | 3877 | /* neighbor send-community extended. */ |
3878 | DEFUN (neighbor_send_community_type, | |
3879 | neighbor_send_community_type_cmd, | |
57d187bc | 3880 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 3881 | NEIGHBOR_STR |
3882 | NEIGHBOR_ADDR_STR2 | |
3883 | "Send Community attribute to this neighbor\n" | |
3884 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 3885 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 3886 | "Send Extended Community attributes\n" |
57d187bc JS |
3887 | "Send Standard Community attributes\n" |
3888 | "Send Large Community attributes\n") | |
718e3744 | 3889 | { |
4c4ff4c1 QY |
3890 | int idx = 0; |
3891 | u_int32_t flag = 0; | |
718e3744 | 3892 | |
4c4ff4c1 QY |
3893 | char *peer = argv[1]->arg; |
3894 | ||
3895 | if (argv_find (argv, argc, "standard", &idx)) | |
3896 | SET_FLAG (flag, PEER_FLAG_SEND_COMMUNITY); | |
3897 | else if (argv_find (argv, argc, "extended", &idx)) | |
3898 | SET_FLAG (flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
57d187bc JS |
3899 | else if (argv_find (argv, argc, "large", &idx)) |
3900 | SET_FLAG (flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
3901 | else if (argv_find (argv, argc, "both", &idx)) | |
3902 | { | |
3903 | SET_FLAG (flag, PEER_FLAG_SEND_COMMUNITY); | |
3904 | SET_FLAG (flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
3905 | } | |
4c4ff4c1 | 3906 | else |
57d187bc JS |
3907 | { |
3908 | SET_FLAG (flag, PEER_FLAG_SEND_COMMUNITY); | |
3909 | SET_FLAG (flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
3910 | SET_FLAG (flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
3911 | } | |
4c4ff4c1 QY |
3912 | |
3913 | return peer_af_flag_set_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flag); | |
718e3744 | 3914 | } |
3915 | ||
3916 | DEFUN (no_neighbor_send_community_type, | |
3917 | no_neighbor_send_community_type_cmd, | |
57d187bc | 3918 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 3919 | NO_STR |
3920 | NEIGHBOR_STR | |
3921 | NEIGHBOR_ADDR_STR2 | |
3922 | "Send Community attribute to this neighbor\n" | |
3923 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 3924 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 3925 | "Send Extended Community attributes\n" |
57d187bc JS |
3926 | "Send Standard Community attributes\n" |
3927 | "Send Large Community attributes\n") | |
718e3744 | 3928 | { |
c500ae40 DW |
3929 | int idx_peer = 2; |
3930 | int idx_type = 4; | |
3931 | if (strncmp (argv[idx_type]->arg, "s", 1) == 0) | |
3932 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3933 | bgp_node_safi (vty), |
3934 | PEER_FLAG_SEND_COMMUNITY); | |
c500ae40 DW |
3935 | if (strncmp (argv[idx_type]->arg, "e", 1) == 0) |
3936 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3937 | bgp_node_safi (vty), |
3938 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
57d187bc JS |
3939 | if (strncmp (argv[idx_type]->arg, "l", 1) == 0) |
3940 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
3941 | bgp_node_safi (vty), | |
3942 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
3943 | if (strncmp (argv[idx_type]->arg, "b", 1) == 0) | |
3944 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
3945 | bgp_node_safi (vty), | |
3946 | PEER_FLAG_SEND_COMMUNITY | | |
3947 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
718e3744 | 3948 | |
c500ae40 | 3949 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 3950 | bgp_node_safi (vty), |
3951 | (PEER_FLAG_SEND_COMMUNITY | | |
57d187bc JS |
3952 | PEER_FLAG_SEND_EXT_COMMUNITY| |
3953 | PEER_FLAG_SEND_LARGE_COMMUNITY)); | |
718e3744 | 3954 | } |
6b0655a2 | 3955 | |
718e3744 | 3956 | /* neighbor soft-reconfig. */ |
3957 | DEFUN (neighbor_soft_reconfiguration, | |
3958 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 3959 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 3960 | NEIGHBOR_STR |
3961 | NEIGHBOR_ADDR_STR2 | |
3962 | "Per neighbor soft reconfiguration\n" | |
3963 | "Allow inbound soft reconfiguration for this neighbor\n") | |
3964 | { | |
c500ae40 DW |
3965 | int idx_peer = 1; |
3966 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, | |
718e3744 | 3967 | bgp_node_afi (vty), bgp_node_safi (vty), |
3968 | PEER_FLAG_SOFT_RECONFIG); | |
3969 | } | |
3970 | ||
3971 | DEFUN (no_neighbor_soft_reconfiguration, | |
3972 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 3973 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 3974 | NO_STR |
3975 | NEIGHBOR_STR | |
3976 | NEIGHBOR_ADDR_STR2 | |
3977 | "Per neighbor soft reconfiguration\n" | |
3978 | "Allow inbound soft reconfiguration for this neighbor\n") | |
3979 | { | |
c500ae40 DW |
3980 | int idx_peer = 2; |
3981 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, | |
718e3744 | 3982 | bgp_node_afi (vty), bgp_node_safi (vty), |
3983 | PEER_FLAG_SOFT_RECONFIG); | |
3984 | } | |
6b0655a2 | 3985 | |
718e3744 | 3986 | DEFUN (neighbor_route_reflector_client, |
3987 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 3988 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 3989 | NEIGHBOR_STR |
3990 | NEIGHBOR_ADDR_STR2 | |
3991 | "Configure a neighbor as Route Reflector client\n") | |
3992 | { | |
c500ae40 | 3993 | int idx_peer = 1; |
718e3744 | 3994 | struct peer *peer; |
3995 | ||
3996 | ||
c500ae40 | 3997 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3998 | if (! peer) |
3999 | return CMD_WARNING; | |
4000 | ||
c500ae40 | 4001 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 4002 | bgp_node_safi (vty), |
4003 | PEER_FLAG_REFLECTOR_CLIENT); | |
4004 | } | |
4005 | ||
4006 | DEFUN (no_neighbor_route_reflector_client, | |
4007 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4008 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4009 | NO_STR |
4010 | NEIGHBOR_STR | |
4011 | NEIGHBOR_ADDR_STR2 | |
4012 | "Configure a neighbor as Route Reflector client\n") | |
4013 | { | |
c500ae40 DW |
4014 | int idx_peer = 2; |
4015 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4016 | bgp_node_safi (vty), |
4017 | PEER_FLAG_REFLECTOR_CLIENT); | |
4018 | } | |
6b0655a2 | 4019 | |
718e3744 | 4020 | /* neighbor route-server-client. */ |
4021 | DEFUN (neighbor_route_server_client, | |
4022 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 4023 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4024 | NEIGHBOR_STR |
4025 | NEIGHBOR_ADDR_STR2 | |
4026 | "Configure a neighbor as Route Server client\n") | |
4027 | { | |
c500ae40 | 4028 | int idx_peer = 1; |
2a3d5731 DW |
4029 | struct peer *peer; |
4030 | ||
c500ae40 | 4031 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
2a3d5731 DW |
4032 | if (! peer) |
4033 | return CMD_WARNING; | |
c500ae40 | 4034 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
2a3d5731 DW |
4035 | bgp_node_safi (vty), |
4036 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 4037 | } |
4038 | ||
4039 | DEFUN (no_neighbor_route_server_client, | |
4040 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 4041 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4042 | NO_STR |
4043 | NEIGHBOR_STR | |
4044 | NEIGHBOR_ADDR_STR2 | |
4045 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 4046 | { |
c500ae40 DW |
4047 | int idx_peer = 2; |
4048 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
2a3d5731 DW |
4049 | bgp_node_safi (vty), |
4050 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 4051 | } |
6b0655a2 | 4052 | |
fee0f4c6 | 4053 | DEFUN (neighbor_nexthop_local_unchanged, |
4054 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4055 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4056 | NEIGHBOR_STR |
4057 | NEIGHBOR_ADDR_STR2 | |
4058 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
4059 | "Leave link-local nexthop unchanged for this peer\n") | |
4060 | { | |
c500ae40 DW |
4061 | int idx_peer = 1; |
4062 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
fee0f4c6 | 4063 | bgp_node_safi (vty), |
4064 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED ); | |
4065 | } | |
6b0655a2 | 4066 | |
fee0f4c6 | 4067 | DEFUN (no_neighbor_nexthop_local_unchanged, |
4068 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4069 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4070 | NO_STR |
4071 | NEIGHBOR_STR | |
4072 | NEIGHBOR_ADDR_STR2 | |
4073 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
4074 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 4075 | { |
c500ae40 DW |
4076 | int idx_peer = 2; |
4077 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4078 | bgp_node_safi (vty), |
fee0f4c6 | 4079 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED ); |
718e3744 | 4080 | } |
6b0655a2 | 4081 | |
718e3744 | 4082 | DEFUN (neighbor_attr_unchanged, |
4083 | neighbor_attr_unchanged_cmd, | |
1084263f QY |
4084 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged\ |
4085 | [<\ | |
ddbaf941 QY |
4086 | as-path [<next-hop [med]|med [next-hop]>]|\ |
4087 | next-hop [<as-path [med]|med [as-path]>]|\ | |
4088 | med [<as-path [next-hop]|next-hop [as-path]>]\ | |
1084263f | 4089 | >]", |
718e3744 | 4090 | NEIGHBOR_STR |
4091 | NEIGHBOR_ADDR_STR2 | |
4092 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4093 | "As-path attribute\n" | |
4094 | "Nexthop attribute\n" | |
40e718b5 | 4095 | "Med attribute\n" |
1084263f QY |
4096 | "Med attribute\n" |
4097 | "Nexthop attribute\n" | |
4098 | "Nexthop attribute\n" | |
4099 | "As-path attribute\n" | |
4100 | "Med attribute\n" | |
40e718b5 | 4101 | "Med attribute\n" |
718e3744 | 4102 | "As-path attribute\n" |
1084263f QY |
4103 | "Med attribute\n" |
4104 | "As-path attribute\n" | |
4105 | "Nexthop attribute\n" | |
40e718b5 | 4106 | "Nexthop attribute\n" |
1084263f | 4107 | "As-path attribute\n") |
718e3744 | 4108 | { |
40e718b5 QY |
4109 | int idx = 0; |
4110 | char *peer = argv[1]->arg; | |
4111 | u_int16_t flags = 0; | |
718e3744 | 4112 | |
40e718b5 | 4113 | if (argv_find (argv, argc, "as-path", &idx)) |
718e3744 | 4114 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
40e718b5 QY |
4115 | idx = 0; |
4116 | if (argv_find (argv, argc, "next-hop", &idx)) | |
4117 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4118 | idx = 0; | |
4119 | if (argv_find (argv, argc, "med", &idx)) | |
718e3744 | 4120 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
4121 | ||
40e718b5 QY |
4122 | if (!flags) // no flags means all of them! |
4123 | { | |
718e3744 | 4124 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
718e3744 | 4125 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); |
40e718b5 QY |
4126 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
4127 | } | |
718e3744 | 4128 | |
40e718b5 | 4129 | return peer_af_flag_set_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flags); |
718e3744 | 4130 | } |
4131 | ||
718e3744 | 4132 | DEFUN (no_neighbor_attr_unchanged, |
4133 | no_neighbor_attr_unchanged_cmd, | |
1084263f QY |
4134 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged\ |
4135 | [<\ | |
ddbaf941 QY |
4136 | as-path [<next-hop [med]|med [next-hop]>]|\ |
4137 | next-hop [<as-path [med]|med [as-path]>]|\ | |
4138 | med [<as-path [next-hop]|next-hop [as-path]>]\ | |
1084263f | 4139 | >]", |
e52702f2 | 4140 | NO_STR |
718e3744 | 4141 | NEIGHBOR_STR |
4142 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
4143 | "BGP attribute is propagated unchanged to this neighbor\n" |
4144 | "As-path attribute\n" | |
40e718b5 | 4145 | "Nexthop attribute\n" |
31500417 | 4146 | "Med attribute\n" |
1084263f QY |
4147 | "Med attribute\n" |
4148 | "Nexthop attribute\n" | |
4149 | "Nexthop attribute\n" | |
4150 | "As-path attribute\n" | |
4151 | "Med attribute\n" | |
40e718b5 | 4152 | "Med attribute\n" |
718e3744 | 4153 | "As-path attribute\n" |
1084263f QY |
4154 | "Med attribute\n" |
4155 | "As-path attribute\n" | |
4156 | "Nexthop attribute\n" | |
718e3744 | 4157 | "Nexthop attribute\n" |
1084263f | 4158 | "As-path attribute\n") |
718e3744 | 4159 | { |
40e718b5 QY |
4160 | int idx = 0; |
4161 | char *peer = argv[2]->arg; | |
4162 | u_int16_t flags = 0; | |
718e3744 | 4163 | |
40e718b5 | 4164 | if (argv_find (argv, argc, "as-path", &idx)) |
718e3744 | 4165 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
40e718b5 QY |
4166 | idx = 0; |
4167 | if (argv_find (argv, argc, "next-hop", &idx)) | |
4168 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4169 | idx = 0; | |
4170 | if (argv_find (argv, argc, "med", &idx)) | |
718e3744 | 4171 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
4172 | ||
40e718b5 QY |
4173 | if (!flags) // no flags means all of them! |
4174 | { | |
718e3744 | 4175 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
718e3744 | 4176 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); |
40e718b5 QY |
4177 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
4178 | } | |
718e3744 | 4179 | |
40e718b5 | 4180 | return peer_af_flag_unset_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flags); |
718e3744 | 4181 | } |
4182 | ||
718e3744 | 4183 | |
718e3744 | 4184 | /* EBGP multihop configuration. */ |
94f2b392 | 4185 | static int |
e52702f2 | 4186 | peer_ebgp_multihop_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4187 | const char *ttl_str) |
718e3744 | 4188 | { |
4189 | struct peer *peer; | |
fd79ac91 | 4190 | unsigned int ttl; |
718e3744 | 4191 | |
4192 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4193 | if (! peer) | |
4194 | return CMD_WARNING; | |
4195 | ||
63fa10b5 QY |
4196 | if (peer->conf_if) |
4197 | return bgp_vty_return (vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
4198 | ||
718e3744 | 4199 | if (! ttl_str) |
9b1be336 | 4200 | ttl = MAXTTL; |
718e3744 | 4201 | else |
9b1be336 | 4202 | VTY_GET_INTEGER_RANGE ("TTL", ttl, ttl_str, 1, MAXTTL); |
718e3744 | 4203 | |
89b6d1f8 | 4204 | return bgp_vty_return (vty, peer_ebgp_multihop_set (peer, ttl)); |
718e3744 | 4205 | } |
4206 | ||
94f2b392 | 4207 | static int |
e52702f2 | 4208 | peer_ebgp_multihop_unset_vty (struct vty *vty, const char *ip_str) |
718e3744 | 4209 | { |
4210 | struct peer *peer; | |
4211 | ||
4212 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4213 | if (! peer) | |
4214 | return CMD_WARNING; | |
4215 | ||
89b6d1f8 | 4216 | return bgp_vty_return (vty, peer_ebgp_multihop_unset (peer)); |
718e3744 | 4217 | } |
4218 | ||
4219 | /* neighbor ebgp-multihop. */ | |
4220 | DEFUN (neighbor_ebgp_multihop, | |
4221 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 4222 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 4223 | NEIGHBOR_STR |
4224 | NEIGHBOR_ADDR_STR2 | |
4225 | "Allow EBGP neighbors not on directly connected networks\n") | |
4226 | { | |
c500ae40 DW |
4227 | int idx_peer = 1; |
4228 | return peer_ebgp_multihop_set_vty (vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4229 | } |
4230 | ||
4231 | DEFUN (neighbor_ebgp_multihop_ttl, | |
4232 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 4233 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 4234 | NEIGHBOR_STR |
4235 | NEIGHBOR_ADDR_STR2 | |
4236 | "Allow EBGP neighbors not on directly connected networks\n" | |
4237 | "maximum hop count\n") | |
4238 | { | |
c500ae40 DW |
4239 | int idx_peer = 1; |
4240 | int idx_number = 3; | |
4241 | return peer_ebgp_multihop_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg); | |
718e3744 | 4242 | } |
4243 | ||
4244 | DEFUN (no_neighbor_ebgp_multihop, | |
4245 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 4246 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 4247 | NO_STR |
4248 | NEIGHBOR_STR | |
4249 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4250 | "Allow EBGP neighbors not on directly connected networks\n" |
4251 | "maximum hop count\n") | |
718e3744 | 4252 | { |
c500ae40 DW |
4253 | int idx_peer = 2; |
4254 | return peer_ebgp_multihop_unset_vty (vty, argv[idx_peer]->arg); | |
718e3744 | 4255 | } |
4256 | ||
6b0655a2 | 4257 | |
6ffd2079 | 4258 | /* disable-connected-check */ |
4259 | DEFUN (neighbor_disable_connected_check, | |
4260 | neighbor_disable_connected_check_cmd, | |
a636c635 | 4261 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4262 | NEIGHBOR_STR |
4263 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4264 | "one-hop away EBGP peer using loopback address\n" |
4265 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4266 | { |
c500ae40 DW |
4267 | int idx_peer = 1; |
4268 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4269 | } |
4270 | ||
4271 | DEFUN (no_neighbor_disable_connected_check, | |
4272 | no_neighbor_disable_connected_check_cmd, | |
a636c635 | 4273 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4274 | NO_STR |
4275 | NEIGHBOR_STR | |
4276 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4277 | "one-hop away EBGP peer using loopback address\n" |
4278 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4279 | { |
c500ae40 DW |
4280 | int idx_peer = 2; |
4281 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4282 | } |
4283 | ||
718e3744 | 4284 | DEFUN (neighbor_description, |
4285 | neighbor_description_cmd, | |
e961923c | 4286 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 4287 | NEIGHBOR_STR |
4288 | NEIGHBOR_ADDR_STR2 | |
4289 | "Neighbor specific description\n" | |
4290 | "Up to 80 characters describing this neighbor\n") | |
4291 | { | |
c500ae40 | 4292 | int idx_peer = 1; |
58749582 | 4293 | int idx_line = 3; |
718e3744 | 4294 | struct peer *peer; |
718e3744 | 4295 | char *str; |
718e3744 | 4296 | |
c500ae40 | 4297 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 4298 | if (! peer) |
4299 | return CMD_WARNING; | |
4300 | ||
58749582 | 4301 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 4302 | |
4303 | peer_description_set (peer, str); | |
4304 | ||
3b8b1855 | 4305 | XFREE (MTYPE_TMP, str); |
718e3744 | 4306 | |
4307 | return CMD_SUCCESS; | |
4308 | } | |
4309 | ||
4310 | DEFUN (no_neighbor_description, | |
4311 | no_neighbor_description_cmd, | |
a636c635 | 4312 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description [LINE]", |
718e3744 | 4313 | NO_STR |
4314 | NEIGHBOR_STR | |
4315 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4316 | "Neighbor specific description\n" |
4317 | "Up to 80 characters describing this neighbor\n") | |
718e3744 | 4318 | { |
c500ae40 | 4319 | int idx_peer = 2; |
718e3744 | 4320 | struct peer *peer; |
4321 | ||
c500ae40 | 4322 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 4323 | if (! peer) |
4324 | return CMD_WARNING; | |
4325 | ||
4326 | peer_description_unset (peer); | |
4327 | ||
4328 | return CMD_SUCCESS; | |
4329 | } | |
4330 | ||
6b0655a2 | 4331 | |
718e3744 | 4332 | /* Neighbor update-source. */ |
94f2b392 | 4333 | static int |
e52702f2 | 4334 | peer_update_source_vty (struct vty *vty, const char *peer_str, |
fd79ac91 | 4335 | const char *source_str) |
718e3744 | 4336 | { |
4337 | struct peer *peer; | |
3b69fd51 | 4338 | struct prefix p; |
718e3744 | 4339 | |
4340 | peer = peer_and_group_lookup_vty (vty, peer_str); | |
4341 | if (! peer) | |
4342 | return CMD_WARNING; | |
4343 | ||
a80beece DS |
4344 | if (peer->conf_if) |
4345 | return CMD_WARNING; | |
4346 | ||
718e3744 | 4347 | if (source_str) |
4348 | { | |
c63b83fe JBD |
4349 | union sockunion su; |
4350 | int ret = str2sockunion (source_str, &su); | |
4351 | ||
4352 | if (ret == 0) | |
4353 | peer_update_source_addr_set (peer, &su); | |
718e3744 | 4354 | else |
3b69fd51 DS |
4355 | { |
4356 | if (str2prefix (source_str, &p)) | |
4357 | { | |
4358 | vty_out (vty, "%% Invalid update-source, remove prefix length %s", | |
4359 | VTY_NEWLINE); | |
4360 | return CMD_WARNING; | |
4361 | } | |
4362 | else | |
4363 | peer_update_source_if_set (peer, source_str); | |
4364 | } | |
718e3744 | 4365 | } |
4366 | else | |
4367 | peer_update_source_unset (peer); | |
4368 | ||
4369 | return CMD_SUCCESS; | |
4370 | } | |
4371 | ||
369688c0 PJ |
4372 | #define BGP_UPDATE_SOURCE_HELP_STR \ |
4373 | "IPv4 address\n" \ | |
9a1a331d PJ |
4374 | "IPv6 address\n" \ |
4375 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 4376 | |
718e3744 | 4377 | DEFUN (neighbor_update_source, |
4378 | neighbor_update_source_cmd, | |
9ccf14f7 | 4379 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 4380 | NEIGHBOR_STR |
4381 | NEIGHBOR_ADDR_STR2 | |
4382 | "Source of routing updates\n" | |
369688c0 | 4383 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 4384 | { |
c500ae40 DW |
4385 | int idx_peer = 1; |
4386 | int idx_peer_2 = 3; | |
4387 | return peer_update_source_vty (vty, argv[idx_peer]->arg, argv[idx_peer_2]->arg); | |
718e3744 | 4388 | } |
4389 | ||
4390 | DEFUN (no_neighbor_update_source, | |
4391 | no_neighbor_update_source_cmd, | |
c7178fe7 | 4392 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 4393 | NO_STR |
4394 | NEIGHBOR_STR | |
4395 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
4396 | "Source of routing updates\n" |
4397 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 4398 | { |
c500ae40 DW |
4399 | int idx_peer = 2; |
4400 | return peer_update_source_vty (vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4401 | } |
6b0655a2 | 4402 | |
94f2b392 | 4403 | static int |
e52702f2 QY |
4404 | peer_default_originate_set_vty (struct vty *vty, const char *peer_str, |
4405 | afi_t afi, safi_t safi, | |
fd79ac91 | 4406 | const char *rmap, int set) |
718e3744 | 4407 | { |
4408 | int ret; | |
4409 | struct peer *peer; | |
4410 | ||
4411 | peer = peer_and_group_lookup_vty (vty, peer_str); | |
4412 | if (! peer) | |
4413 | return CMD_WARNING; | |
4414 | ||
4415 | if (set) | |
4416 | ret = peer_default_originate_set (peer, afi, safi, rmap); | |
4417 | else | |
4418 | ret = peer_default_originate_unset (peer, afi, safi); | |
4419 | ||
4420 | return bgp_vty_return (vty, ret); | |
4421 | } | |
4422 | ||
4423 | /* neighbor default-originate. */ | |
4424 | DEFUN (neighbor_default_originate, | |
4425 | neighbor_default_originate_cmd, | |
9ccf14f7 | 4426 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 4427 | NEIGHBOR_STR |
4428 | NEIGHBOR_ADDR_STR2 | |
4429 | "Originate default route to this neighbor\n") | |
4430 | { | |
c500ae40 DW |
4431 | int idx_peer = 1; |
4432 | return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4433 | bgp_node_safi (vty), NULL, 1); |
4434 | } | |
4435 | ||
4436 | DEFUN (neighbor_default_originate_rmap, | |
4437 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 4438 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 4439 | NEIGHBOR_STR |
4440 | NEIGHBOR_ADDR_STR2 | |
4441 | "Originate default route to this neighbor\n" | |
4442 | "Route-map to specify criteria to originate default\n" | |
4443 | "route-map name\n") | |
4444 | { | |
c500ae40 DW |
4445 | int idx_peer = 1; |
4446 | int idx_word = 4; | |
4447 | return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4448 | bgp_node_safi (vty), argv[idx_word]->arg, 1); | |
718e3744 | 4449 | } |
4450 | ||
4451 | DEFUN (no_neighbor_default_originate, | |
4452 | no_neighbor_default_originate_cmd, | |
a636c635 | 4453 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 4454 | NO_STR |
4455 | NEIGHBOR_STR | |
4456 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4457 | "Originate default route to this neighbor\n" |
4458 | "Route-map to specify criteria to originate default\n" | |
4459 | "route-map name\n") | |
718e3744 | 4460 | { |
c500ae40 DW |
4461 | int idx_peer = 2; |
4462 | return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4463 | bgp_node_safi (vty), NULL, 0); |
4464 | } | |
4465 | ||
6b0655a2 | 4466 | |
718e3744 | 4467 | /* Set neighbor's BGP port. */ |
94f2b392 | 4468 | static int |
e52702f2 | 4469 | peer_port_vty (struct vty *vty, const char *ip_str, int afi, |
fd79ac91 | 4470 | const char *port_str) |
718e3744 | 4471 | { |
4472 | struct peer *peer; | |
4473 | u_int16_t port; | |
4474 | struct servent *sp; | |
4475 | ||
4476 | peer = peer_lookup_vty (vty, ip_str); | |
4477 | if (! peer) | |
4478 | return CMD_WARNING; | |
4479 | ||
4480 | if (! port_str) | |
e52702f2 | 4481 | { |
718e3744 | 4482 | sp = getservbyname ("bgp", "tcp"); |
4483 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs (sp->s_port); | |
4484 | } | |
4485 | else | |
4486 | { | |
4487 | VTY_GET_INTEGER("port", port, port_str); | |
4488 | } | |
4489 | ||
4490 | peer_port_set (peer, port); | |
4491 | ||
4492 | return CMD_SUCCESS; | |
4493 | } | |
4494 | ||
f418446b | 4495 | /* Set specified peer's BGP port. */ |
718e3744 | 4496 | DEFUN (neighbor_port, |
4497 | neighbor_port_cmd, | |
9ccf14f7 | 4498 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 4499 | NEIGHBOR_STR |
4500 | NEIGHBOR_ADDR_STR | |
4501 | "Neighbor's BGP port\n" | |
4502 | "TCP port number\n") | |
4503 | { | |
c500ae40 DW |
4504 | int idx_ip = 1; |
4505 | int idx_number = 3; | |
4506 | return peer_port_vty (vty, argv[idx_ip]->arg, AFI_IP, argv[idx_number]->arg); | |
718e3744 | 4507 | } |
4508 | ||
4509 | DEFUN (no_neighbor_port, | |
4510 | no_neighbor_port_cmd, | |
9ccf14f7 | 4511 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 4512 | NO_STR |
4513 | NEIGHBOR_STR | |
4514 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
4515 | "Neighbor's BGP port\n" |
4516 | "TCP port number\n") | |
718e3744 | 4517 | { |
c500ae40 DW |
4518 | int idx_ip = 2; |
4519 | return peer_port_vty (vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 4520 | } |
4521 | ||
6b0655a2 | 4522 | |
718e3744 | 4523 | /* neighbor weight. */ |
94f2b392 | 4524 | static int |
e52702f2 | 4525 | peer_weight_set_vty (struct vty *vty, const char *ip_str, |
d93f7ffc | 4526 | afi_t afi, safi_t safi, |
fd79ac91 | 4527 | const char *weight_str) |
718e3744 | 4528 | { |
1f9a9fff | 4529 | int ret; |
718e3744 | 4530 | struct peer *peer; |
4531 | unsigned long weight; | |
4532 | ||
4533 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4534 | if (! peer) | |
4535 | return CMD_WARNING; | |
4536 | ||
4537 | VTY_GET_INTEGER_RANGE("weight", weight, weight_str, 0, 65535); | |
4538 | ||
d93f7ffc | 4539 | ret = peer_weight_set (peer, afi, safi, weight); |
1f9a9fff | 4540 | return bgp_vty_return (vty, ret); |
718e3744 | 4541 | } |
4542 | ||
94f2b392 | 4543 | static int |
d93f7ffc DW |
4544 | peer_weight_unset_vty (struct vty *vty, const char *ip_str, |
4545 | afi_t afi, safi_t safi) | |
718e3744 | 4546 | { |
1f9a9fff | 4547 | int ret; |
718e3744 | 4548 | struct peer *peer; |
4549 | ||
4550 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4551 | if (! peer) | |
4552 | return CMD_WARNING; | |
4553 | ||
d93f7ffc | 4554 | ret = peer_weight_unset (peer, afi, safi); |
1f9a9fff | 4555 | return bgp_vty_return (vty, ret); |
718e3744 | 4556 | } |
4557 | ||
4558 | DEFUN (neighbor_weight, | |
4559 | neighbor_weight_cmd, | |
9ccf14f7 | 4560 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 4561 | NEIGHBOR_STR |
4562 | NEIGHBOR_ADDR_STR2 | |
4563 | "Set default weight for routes from this neighbor\n" | |
4564 | "default weight\n") | |
4565 | { | |
c500ae40 DW |
4566 | int idx_peer = 1; |
4567 | int idx_number = 3; | |
e52702f2 QY |
4568 | return peer_weight_set_vty (vty, |
4569 | argv[idx_peer]->arg, | |
4570 | bgp_node_afi (vty), | |
4571 | bgp_node_safi (vty), | |
4572 | argv[idx_number]->arg); | |
718e3744 | 4573 | } |
4574 | ||
4575 | DEFUN (no_neighbor_weight, | |
4576 | no_neighbor_weight_cmd, | |
9ccf14f7 | 4577 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 4578 | NO_STR |
4579 | NEIGHBOR_STR | |
4580 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
4581 | "Set default weight for routes from this neighbor\n" |
4582 | "default weight\n") | |
718e3744 | 4583 | { |
c500ae40 | 4584 | int idx_peer = 2; |
e52702f2 | 4585 | return peer_weight_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty)); |
718e3744 | 4586 | } |
4587 | ||
6b0655a2 | 4588 | |
718e3744 | 4589 | /* Override capability negotiation. */ |
4590 | DEFUN (neighbor_override_capability, | |
4591 | neighbor_override_capability_cmd, | |
9ccf14f7 | 4592 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 4593 | NEIGHBOR_STR |
4594 | NEIGHBOR_ADDR_STR2 | |
4595 | "Override capability negotiation result\n") | |
4596 | { | |
c500ae40 DW |
4597 | int idx_peer = 1; |
4598 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 4599 | } |
4600 | ||
4601 | DEFUN (no_neighbor_override_capability, | |
4602 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 4603 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 4604 | NO_STR |
4605 | NEIGHBOR_STR | |
4606 | NEIGHBOR_ADDR_STR2 | |
4607 | "Override capability negotiation result\n") | |
4608 | { | |
c500ae40 DW |
4609 | int idx_peer = 2; |
4610 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 4611 | } |
6b0655a2 | 4612 | |
718e3744 | 4613 | DEFUN (neighbor_strict_capability, |
4614 | neighbor_strict_capability_cmd, | |
9ccf14f7 | 4615 | "neighbor <A.B.C.D|X:X::X:X> strict-capability-match", |
718e3744 | 4616 | NEIGHBOR_STR |
4617 | NEIGHBOR_ADDR_STR | |
4618 | "Strict capability negotiation match\n") | |
4619 | { | |
c500ae40 DW |
4620 | int idx_ip = 1; |
4621 | return peer_flag_set_vty (vty, argv[idx_ip]->arg, PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 4622 | } |
4623 | ||
4624 | DEFUN (no_neighbor_strict_capability, | |
4625 | no_neighbor_strict_capability_cmd, | |
9ccf14f7 | 4626 | "no neighbor <A.B.C.D|X:X::X:X> strict-capability-match", |
718e3744 | 4627 | NO_STR |
4628 | NEIGHBOR_STR | |
4629 | NEIGHBOR_ADDR_STR | |
4630 | "Strict capability negotiation match\n") | |
4631 | { | |
c500ae40 DW |
4632 | int idx_ip = 2; |
4633 | return peer_flag_unset_vty (vty, argv[idx_ip]->arg, PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 4634 | } |
6b0655a2 | 4635 | |
94f2b392 | 4636 | static int |
e52702f2 | 4637 | peer_timers_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4638 | const char *keep_str, const char *hold_str) |
718e3744 | 4639 | { |
4640 | int ret; | |
4641 | struct peer *peer; | |
4642 | u_int32_t keepalive; | |
4643 | u_int32_t holdtime; | |
4644 | ||
4645 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4646 | if (! peer) | |
4647 | return CMD_WARNING; | |
4648 | ||
4649 | VTY_GET_INTEGER_RANGE ("Keepalive", keepalive, keep_str, 0, 65535); | |
4650 | VTY_GET_INTEGER_RANGE ("Holdtime", holdtime, hold_str, 0, 65535); | |
4651 | ||
4652 | ret = peer_timers_set (peer, keepalive, holdtime); | |
4653 | ||
4654 | return bgp_vty_return (vty, ret); | |
4655 | } | |
6b0655a2 | 4656 | |
94f2b392 | 4657 | static int |
fd79ac91 | 4658 | peer_timers_unset_vty (struct vty *vty, const char *ip_str) |
718e3744 | 4659 | { |
4660 | int ret; | |
4661 | struct peer *peer; | |
4662 | ||
0c412461 | 4663 | peer = peer_and_group_lookup_vty (vty, ip_str); |
718e3744 | 4664 | if (! peer) |
4665 | return CMD_WARNING; | |
4666 | ||
4667 | ret = peer_timers_unset (peer); | |
4668 | ||
4669 | return bgp_vty_return (vty, ret); | |
4670 | } | |
4671 | ||
4672 | DEFUN (neighbor_timers, | |
4673 | neighbor_timers_cmd, | |
9ccf14f7 | 4674 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 4675 | NEIGHBOR_STR |
4676 | NEIGHBOR_ADDR_STR2 | |
4677 | "BGP per neighbor timers\n" | |
4678 | "Keepalive interval\n" | |
4679 | "Holdtime\n") | |
4680 | { | |
c500ae40 DW |
4681 | int idx_peer = 1; |
4682 | int idx_number = 3; | |
4683 | int idx_number_2 = 4; | |
4684 | return peer_timers_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg); | |
718e3744 | 4685 | } |
4686 | ||
4687 | DEFUN (no_neighbor_timers, | |
4688 | no_neighbor_timers_cmd, | |
9ccf14f7 | 4689 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 4690 | NO_STR |
4691 | NEIGHBOR_STR | |
4692 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
4693 | "BGP per neighbor timers\n" |
4694 | "Keepalive interval\n" | |
4695 | "Holdtime\n") | |
718e3744 | 4696 | { |
c500ae40 DW |
4697 | int idx_peer = 2; |
4698 | return peer_timers_unset_vty (vty, argv[idx_peer]->arg); | |
718e3744 | 4699 | } |
6b0655a2 | 4700 | |
813d4307 | 4701 | |
94f2b392 | 4702 | static int |
e52702f2 | 4703 | peer_timers_connect_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4704 | const char *time_str) |
718e3744 | 4705 | { |
4706 | int ret; | |
4707 | struct peer *peer; | |
4708 | u_int32_t connect; | |
4709 | ||
966f821c | 4710 | peer = peer_and_group_lookup_vty (vty, ip_str); |
718e3744 | 4711 | if (! peer) |
4712 | return CMD_WARNING; | |
4713 | ||
4714 | VTY_GET_INTEGER_RANGE ("Connect time", connect, time_str, 0, 65535); | |
4715 | ||
4716 | ret = peer_timers_connect_set (peer, connect); | |
4717 | ||
966f821c | 4718 | return bgp_vty_return (vty, ret); |
718e3744 | 4719 | } |
4720 | ||
94f2b392 | 4721 | static int |
fd79ac91 | 4722 | peer_timers_connect_unset_vty (struct vty *vty, const char *ip_str) |
718e3744 | 4723 | { |
4724 | int ret; | |
4725 | struct peer *peer; | |
4726 | ||
4727 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4728 | if (! peer) | |
4729 | return CMD_WARNING; | |
4730 | ||
4731 | ret = peer_timers_connect_unset (peer); | |
4732 | ||
966f821c | 4733 | return bgp_vty_return (vty, ret); |
718e3744 | 4734 | } |
4735 | ||
4736 | DEFUN (neighbor_timers_connect, | |
4737 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 4738 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 4739 | NEIGHBOR_STR |
966f821c | 4740 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4741 | "BGP per neighbor timers\n" |
4742 | "BGP connect timer\n" | |
4743 | "Connect timer\n") | |
4744 | { | |
c500ae40 DW |
4745 | int idx_peer = 1; |
4746 | int idx_number = 4; | |
4747 | return peer_timers_connect_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg); | |
718e3744 | 4748 | } |
4749 | ||
4750 | DEFUN (no_neighbor_timers_connect, | |
4751 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 4752 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 4753 | NO_STR |
4754 | NEIGHBOR_STR | |
966f821c | 4755 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4756 | "BGP per neighbor timers\n" |
8334fd5a DW |
4757 | "BGP connect timer\n" |
4758 | "Connect timer\n") | |
718e3744 | 4759 | { |
c500ae40 DW |
4760 | int idx_peer = 2; |
4761 | return peer_timers_connect_unset_vty (vty, argv[idx_peer]->arg); | |
718e3744 | 4762 | } |
4763 | ||
6b0655a2 | 4764 | |
94f2b392 | 4765 | static int |
e52702f2 QY |
4766 | peer_advertise_interval_vty (struct vty *vty, const char *ip_str, |
4767 | const char *time_str, int set) | |
718e3744 | 4768 | { |
4769 | int ret; | |
4770 | struct peer *peer; | |
4771 | u_int32_t routeadv = 0; | |
4772 | ||
966f821c | 4773 | peer = peer_and_group_lookup_vty (vty, ip_str); |
718e3744 | 4774 | if (! peer) |
4775 | return CMD_WARNING; | |
4776 | ||
4777 | if (time_str) | |
4778 | VTY_GET_INTEGER_RANGE ("advertise interval", routeadv, time_str, 0, 600); | |
4779 | ||
4780 | if (set) | |
4781 | ret = peer_advertise_interval_set (peer, routeadv); | |
4782 | else | |
4783 | ret = peer_advertise_interval_unset (peer); | |
4784 | ||
966f821c | 4785 | return bgp_vty_return (vty, ret); |
718e3744 | 4786 | } |
4787 | ||
4788 | DEFUN (neighbor_advertise_interval, | |
4789 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 4790 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 4791 | NEIGHBOR_STR |
966f821c | 4792 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4793 | "Minimum interval between sending BGP routing updates\n" |
4794 | "time in seconds\n") | |
4795 | { | |
c500ae40 DW |
4796 | int idx_peer = 1; |
4797 | int idx_number = 3; | |
4798 | return peer_advertise_interval_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg, 1); | |
718e3744 | 4799 | } |
4800 | ||
4801 | DEFUN (no_neighbor_advertise_interval, | |
4802 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 4803 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 4804 | NO_STR |
4805 | NEIGHBOR_STR | |
966f821c | 4806 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
4807 | "Minimum interval between sending BGP routing updates\n" |
4808 | "time in seconds\n") | |
718e3744 | 4809 | { |
c500ae40 DW |
4810 | int idx_peer = 2; |
4811 | return peer_advertise_interval_vty (vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 4812 | } |
4813 | ||
6b0655a2 | 4814 | |
518f0eb1 DS |
4815 | /* Time to wait before processing route-map updates */ |
4816 | DEFUN (bgp_set_route_map_delay_timer, | |
4817 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 4818 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
4819 | SET_STR |
4820 | "BGP route-map delay timer\n" | |
4821 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 4822 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 4823 | { |
c500ae40 | 4824 | int idx_number = 3; |
518f0eb1 | 4825 | u_int32_t rmap_delay_timer; |
518f0eb1 | 4826 | |
c500ae40 | 4827 | if (argv[idx_number]->arg) |
518f0eb1 | 4828 | { |
c500ae40 | 4829 | VTY_GET_INTEGER_RANGE ("delay-timer", rmap_delay_timer, argv[idx_number]->arg, 0, 600); |
5fe9f963 | 4830 | bm->rmap_update_timer = rmap_delay_timer; |
518f0eb1 DS |
4831 | |
4832 | /* if the dynamic update handling is being disabled, and a timer is | |
4833 | * running, stop the timer and act as if the timer has already fired. | |
4834 | */ | |
5fe9f963 | 4835 | if (!rmap_delay_timer && bm->t_rmap_update ) |
518f0eb1 | 4836 | { |
5fe9f963 | 4837 | BGP_TIMER_OFF(bm->t_rmap_update); |
4838 | thread_execute (bm->master, bgp_route_map_update_timer, NULL, 0); | |
518f0eb1 DS |
4839 | } |
4840 | return CMD_SUCCESS; | |
4841 | } | |
4842 | else | |
ffd0c037 | 4843 | return CMD_WARNING; |
518f0eb1 DS |
4844 | } |
4845 | ||
4846 | DEFUN (no_bgp_set_route_map_delay_timer, | |
4847 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 4848 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 4849 | NO_STR |
3a2d747c | 4850 | BGP_STR |
518f0eb1 | 4851 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
4852 | "Reset to default time to wait for processing route-map changes\n" |
4853 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 4854 | { |
518f0eb1 | 4855 | |
5fe9f963 | 4856 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 DS |
4857 | |
4858 | return CMD_SUCCESS; | |
4859 | } | |
4860 | ||
f414725f | 4861 | |
718e3744 | 4862 | /* neighbor interface */ |
94f2b392 | 4863 | static int |
fd79ac91 | 4864 | peer_interface_vty (struct vty *vty, const char *ip_str, const char *str) |
718e3744 | 4865 | { |
718e3744 | 4866 | struct peer *peer; |
4867 | ||
4868 | peer = peer_lookup_vty (vty, ip_str); | |
a80beece | 4869 | if (! peer || peer->conf_if) |
718e3744 | 4870 | return CMD_WARNING; |
4871 | ||
4872 | if (str) | |
ffd0c037 | 4873 | peer_interface_set (peer, str); |
718e3744 | 4874 | else |
ffd0c037 | 4875 | peer_interface_unset (peer); |
718e3744 | 4876 | |
4877 | return CMD_SUCCESS; | |
4878 | } | |
4879 | ||
4880 | DEFUN (neighbor_interface, | |
4881 | neighbor_interface_cmd, | |
9ccf14f7 | 4882 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 4883 | NEIGHBOR_STR |
4884 | NEIGHBOR_ADDR_STR | |
4885 | "Interface\n" | |
4886 | "Interface name\n") | |
4887 | { | |
c500ae40 DW |
4888 | int idx_ip = 1; |
4889 | int idx_word = 3; | |
00d7d2d3 | 4890 | return peer_interface_vty (vty, argv[idx_ip]->arg, argv[idx_word]->arg); |
718e3744 | 4891 | } |
4892 | ||
4893 | DEFUN (no_neighbor_interface, | |
4894 | no_neighbor_interface_cmd, | |
9ccf14f7 | 4895 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 4896 | NO_STR |
4897 | NEIGHBOR_STR | |
16cedbb0 | 4898 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4899 | "Interface\n" |
4900 | "Interface name\n") | |
4901 | { | |
c500ae40 DW |
4902 | int idx_peer = 2; |
4903 | return peer_interface_vty (vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4904 | } |
6b0655a2 | 4905 | |
718e3744 | 4906 | /* Set distribute list to the peer. */ |
94f2b392 | 4907 | static int |
e52702f2 | 4908 | peer_distribute_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4909 | afi_t afi, safi_t safi, |
4910 | const char *name_str, const char *direct_str) | |
718e3744 | 4911 | { |
4912 | int ret; | |
4913 | struct peer *peer; | |
4914 | int direct = FILTER_IN; | |
4915 | ||
4916 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4917 | if (! peer) | |
4918 | return CMD_WARNING; | |
4919 | ||
4920 | /* Check filter direction. */ | |
4921 | if (strncmp (direct_str, "i", 1) == 0) | |
4922 | direct = FILTER_IN; | |
4923 | else if (strncmp (direct_str, "o", 1) == 0) | |
4924 | direct = FILTER_OUT; | |
4925 | ||
4926 | ret = peer_distribute_set (peer, afi, safi, direct, name_str); | |
4927 | ||
4928 | return bgp_vty_return (vty, ret); | |
4929 | } | |
4930 | ||
94f2b392 | 4931 | static int |
fd79ac91 | 4932 | peer_distribute_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
4933 | safi_t safi, const char *direct_str) | |
718e3744 | 4934 | { |
4935 | int ret; | |
4936 | struct peer *peer; | |
4937 | int direct = FILTER_IN; | |
4938 | ||
4939 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4940 | if (! peer) | |
4941 | return CMD_WARNING; | |
4942 | ||
4943 | /* Check filter direction. */ | |
4944 | if (strncmp (direct_str, "i", 1) == 0) | |
4945 | direct = FILTER_IN; | |
4946 | else if (strncmp (direct_str, "o", 1) == 0) | |
4947 | direct = FILTER_OUT; | |
4948 | ||
4949 | ret = peer_distribute_unset (peer, afi, safi, direct); | |
4950 | ||
4951 | return bgp_vty_return (vty, ret); | |
4952 | } | |
4953 | ||
4954 | DEFUN (neighbor_distribute_list, | |
4955 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 4956 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 4957 | NEIGHBOR_STR |
4958 | NEIGHBOR_ADDR_STR2 | |
4959 | "Filter updates to/from this neighbor\n" | |
4960 | "IP access-list number\n" | |
4961 | "IP access-list number (expanded range)\n" | |
4962 | "IP Access-list name\n" | |
4963 | "Filter incoming updates\n" | |
4964 | "Filter outgoing updates\n") | |
4965 | { | |
c500ae40 DW |
4966 | int idx_peer = 1; |
4967 | int idx_acl = 3; | |
4968 | int idx_in_out = 4; | |
4969 | return peer_distribute_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4970 | bgp_node_safi (vty), argv[idx_acl]->arg, argv[idx_in_out]->arg); | |
718e3744 | 4971 | } |
4972 | ||
4973 | DEFUN (no_neighbor_distribute_list, | |
4974 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 4975 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 4976 | NO_STR |
4977 | NEIGHBOR_STR | |
4978 | NEIGHBOR_ADDR_STR2 | |
4979 | "Filter updates to/from this neighbor\n" | |
4980 | "IP access-list number\n" | |
4981 | "IP access-list number (expanded range)\n" | |
4982 | "IP Access-list name\n" | |
4983 | "Filter incoming updates\n" | |
4984 | "Filter outgoing updates\n") | |
4985 | { | |
c500ae40 DW |
4986 | int idx_peer = 2; |
4987 | int idx_in_out = 5; | |
4988 | return peer_distribute_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4989 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 4990 | } |
6b0655a2 | 4991 | |
718e3744 | 4992 | /* Set prefix list to the peer. */ |
94f2b392 | 4993 | static int |
fd79ac91 | 4994 | peer_prefix_list_set_vty (struct vty *vty, const char *ip_str, afi_t afi, |
e52702f2 | 4995 | safi_t safi, const char *name_str, |
fd79ac91 | 4996 | const char *direct_str) |
718e3744 | 4997 | { |
4998 | int ret; | |
4999 | struct peer *peer; | |
5000 | int direct = FILTER_IN; | |
5001 | ||
5002 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5003 | if (! peer) | |
5004 | return CMD_WARNING; | |
5005 | ||
5006 | /* Check filter direction. */ | |
5007 | if (strncmp (direct_str, "i", 1) == 0) | |
5008 | direct = FILTER_IN; | |
5009 | else if (strncmp (direct_str, "o", 1) == 0) | |
5010 | direct = FILTER_OUT; | |
5011 | ||
5012 | ret = peer_prefix_list_set (peer, afi, safi, direct, name_str); | |
5013 | ||
5014 | return bgp_vty_return (vty, ret); | |
5015 | } | |
5016 | ||
94f2b392 | 5017 | static int |
fd79ac91 | 5018 | peer_prefix_list_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
5019 | safi_t safi, const char *direct_str) | |
718e3744 | 5020 | { |
5021 | int ret; | |
5022 | struct peer *peer; | |
5023 | int direct = FILTER_IN; | |
5024 | ||
5025 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5026 | if (! peer) | |
5027 | return CMD_WARNING; | |
e52702f2 | 5028 | |
718e3744 | 5029 | /* Check filter direction. */ |
5030 | if (strncmp (direct_str, "i", 1) == 0) | |
5031 | direct = FILTER_IN; | |
5032 | else if (strncmp (direct_str, "o", 1) == 0) | |
5033 | direct = FILTER_OUT; | |
5034 | ||
5035 | ret = peer_prefix_list_unset (peer, afi, safi, direct); | |
5036 | ||
5037 | return bgp_vty_return (vty, ret); | |
5038 | } | |
5039 | ||
5040 | DEFUN (neighbor_prefix_list, | |
5041 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 5042 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5043 | NEIGHBOR_STR |
5044 | NEIGHBOR_ADDR_STR2 | |
5045 | "Filter updates to/from this neighbor\n" | |
5046 | "Name of a prefix list\n" | |
5047 | "Filter incoming updates\n" | |
5048 | "Filter outgoing updates\n") | |
5049 | { | |
c500ae40 DW |
5050 | int idx_peer = 1; |
5051 | int idx_word = 3; | |
5052 | int idx_in_out = 4; | |
5053 | return peer_prefix_list_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5054 | bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5055 | } |
5056 | ||
5057 | DEFUN (no_neighbor_prefix_list, | |
5058 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 5059 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5060 | NO_STR |
5061 | NEIGHBOR_STR | |
5062 | NEIGHBOR_ADDR_STR2 | |
5063 | "Filter updates to/from this neighbor\n" | |
5064 | "Name of a prefix list\n" | |
5065 | "Filter incoming updates\n" | |
5066 | "Filter outgoing updates\n") | |
5067 | { | |
c500ae40 DW |
5068 | int idx_peer = 2; |
5069 | int idx_in_out = 5; | |
5070 | return peer_prefix_list_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5071 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 5072 | } |
6b0655a2 | 5073 | |
94f2b392 | 5074 | static int |
e52702f2 | 5075 | peer_aslist_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 5076 | afi_t afi, safi_t safi, |
5077 | const char *name_str, const char *direct_str) | |
718e3744 | 5078 | { |
5079 | int ret; | |
5080 | struct peer *peer; | |
5081 | int direct = FILTER_IN; | |
5082 | ||
5083 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5084 | if (! peer) | |
5085 | return CMD_WARNING; | |
5086 | ||
5087 | /* Check filter direction. */ | |
5088 | if (strncmp (direct_str, "i", 1) == 0) | |
5089 | direct = FILTER_IN; | |
5090 | else if (strncmp (direct_str, "o", 1) == 0) | |
5091 | direct = FILTER_OUT; | |
5092 | ||
5093 | ret = peer_aslist_set (peer, afi, safi, direct, name_str); | |
5094 | ||
5095 | return bgp_vty_return (vty, ret); | |
5096 | } | |
5097 | ||
94f2b392 | 5098 | static int |
e52702f2 | 5099 | peer_aslist_unset_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 5100 | afi_t afi, safi_t safi, |
5101 | const char *direct_str) | |
718e3744 | 5102 | { |
5103 | int ret; | |
5104 | struct peer *peer; | |
5105 | int direct = FILTER_IN; | |
5106 | ||
5107 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5108 | if (! peer) | |
5109 | return CMD_WARNING; | |
5110 | ||
5111 | /* Check filter direction. */ | |
5112 | if (strncmp (direct_str, "i", 1) == 0) | |
5113 | direct = FILTER_IN; | |
5114 | else if (strncmp (direct_str, "o", 1) == 0) | |
5115 | direct = FILTER_OUT; | |
5116 | ||
5117 | ret = peer_aslist_unset (peer, afi, safi, direct); | |
5118 | ||
5119 | return bgp_vty_return (vty, ret); | |
5120 | } | |
5121 | ||
5122 | DEFUN (neighbor_filter_list, | |
5123 | neighbor_filter_list_cmd, | |
9ccf14f7 | 5124 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5125 | NEIGHBOR_STR |
5126 | NEIGHBOR_ADDR_STR2 | |
5127 | "Establish BGP filters\n" | |
5128 | "AS path access-list name\n" | |
5129 | "Filter incoming routes\n" | |
5130 | "Filter outgoing routes\n") | |
5131 | { | |
c500ae40 DW |
5132 | int idx_peer = 1; |
5133 | int idx_word = 3; | |
5134 | int idx_in_out = 4; | |
5135 | return peer_aslist_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5136 | bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5137 | } |
5138 | ||
5139 | DEFUN (no_neighbor_filter_list, | |
5140 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 5141 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5142 | NO_STR |
5143 | NEIGHBOR_STR | |
5144 | NEIGHBOR_ADDR_STR2 | |
5145 | "Establish BGP filters\n" | |
5146 | "AS path access-list name\n" | |
5147 | "Filter incoming routes\n" | |
5148 | "Filter outgoing routes\n") | |
5149 | { | |
c500ae40 DW |
5150 | int idx_peer = 2; |
5151 | int idx_in_out = 5; | |
5152 | return peer_aslist_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5153 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 5154 | } |
6b0655a2 | 5155 | |
718e3744 | 5156 | /* Set route-map to the peer. */ |
94f2b392 | 5157 | static int |
e52702f2 | 5158 | peer_route_map_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 5159 | afi_t afi, safi_t safi, |
5160 | const char *name_str, const char *direct_str) | |
718e3744 | 5161 | { |
5162 | int ret; | |
5163 | struct peer *peer; | |
fee0f4c6 | 5164 | int direct = RMAP_IN; |
718e3744 | 5165 | |
5166 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5167 | if (! peer) | |
5168 | return CMD_WARNING; | |
5169 | ||
5170 | /* Check filter direction. */ | |
fee0f4c6 | 5171 | if (strncmp (direct_str, "in", 2) == 0) |
5172 | direct = RMAP_IN; | |
718e3744 | 5173 | else if (strncmp (direct_str, "o", 1) == 0) |
fee0f4c6 | 5174 | direct = RMAP_OUT; |
718e3744 | 5175 | |
5176 | ret = peer_route_map_set (peer, afi, safi, direct, name_str); | |
5177 | ||
5178 | return bgp_vty_return (vty, ret); | |
5179 | } | |
5180 | ||
94f2b392 | 5181 | static int |
fd79ac91 | 5182 | peer_route_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
5183 | safi_t safi, const char *direct_str) | |
718e3744 | 5184 | { |
5185 | int ret; | |
5186 | struct peer *peer; | |
fee0f4c6 | 5187 | int direct = RMAP_IN; |
718e3744 | 5188 | |
5189 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5190 | if (! peer) | |
5191 | return CMD_WARNING; | |
5192 | ||
5193 | /* Check filter direction. */ | |
fee0f4c6 | 5194 | if (strncmp (direct_str, "in", 2) == 0) |
5195 | direct = RMAP_IN; | |
718e3744 | 5196 | else if (strncmp (direct_str, "o", 1) == 0) |
fee0f4c6 | 5197 | direct = RMAP_OUT; |
718e3744 | 5198 | |
5199 | ret = peer_route_map_unset (peer, afi, safi, direct); | |
5200 | ||
5201 | return bgp_vty_return (vty, ret); | |
5202 | } | |
5203 | ||
5204 | DEFUN (neighbor_route_map, | |
5205 | neighbor_route_map_cmd, | |
9ccf14f7 | 5206 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5207 | NEIGHBOR_STR |
5208 | NEIGHBOR_ADDR_STR2 | |
5209 | "Apply route map to neighbor\n" | |
5210 | "Name of route map\n" | |
5211 | "Apply map to incoming routes\n" | |
2a3d5731 | 5212 | "Apply map to outbound routes\n") |
718e3744 | 5213 | { |
c500ae40 DW |
5214 | int idx_peer = 1; |
5215 | int idx_word = 3; | |
5216 | int idx_in_out = 4; | |
5217 | return peer_route_map_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5218 | bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5219 | } |
5220 | ||
5221 | DEFUN (no_neighbor_route_map, | |
5222 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 5223 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5224 | NO_STR |
5225 | NEIGHBOR_STR | |
5226 | NEIGHBOR_ADDR_STR2 | |
5227 | "Apply route map to neighbor\n" | |
5228 | "Name of route map\n" | |
5229 | "Apply map to incoming routes\n" | |
2a3d5731 | 5230 | "Apply map to outbound routes\n") |
718e3744 | 5231 | { |
c500ae40 DW |
5232 | int idx_peer = 2; |
5233 | int idx_in_out = 5; | |
5234 | return peer_route_map_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5235 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 5236 | } |
6b0655a2 | 5237 | |
718e3744 | 5238 | /* Set unsuppress-map to the peer. */ |
94f2b392 | 5239 | static int |
fd79ac91 | 5240 | peer_unsuppress_map_set_vty (struct vty *vty, const char *ip_str, afi_t afi, |
5241 | safi_t safi, const char *name_str) | |
718e3744 | 5242 | { |
5243 | int ret; | |
5244 | struct peer *peer; | |
5245 | ||
5246 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5247 | if (! peer) | |
5248 | return CMD_WARNING; | |
5249 | ||
5250 | ret = peer_unsuppress_map_set (peer, afi, safi, name_str); | |
5251 | ||
5252 | return bgp_vty_return (vty, ret); | |
5253 | } | |
5254 | ||
5255 | /* Unset route-map from the peer. */ | |
94f2b392 | 5256 | static int |
fd79ac91 | 5257 | peer_unsuppress_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
718e3744 | 5258 | safi_t safi) |
5259 | { | |
5260 | int ret; | |
5261 | struct peer *peer; | |
5262 | ||
5263 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5264 | if (! peer) | |
5265 | return CMD_WARNING; | |
5266 | ||
5267 | ret = peer_unsuppress_map_unset (peer, afi, safi); | |
5268 | ||
5269 | return bgp_vty_return (vty, ret); | |
5270 | } | |
5271 | ||
5272 | DEFUN (neighbor_unsuppress_map, | |
5273 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5274 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5275 | NEIGHBOR_STR |
5276 | NEIGHBOR_ADDR_STR2 | |
5277 | "Route-map to selectively unsuppress suppressed routes\n" | |
5278 | "Name of route map\n") | |
5279 | { | |
c500ae40 DW |
5280 | int idx_peer = 1; |
5281 | int idx_word = 3; | |
5282 | return peer_unsuppress_map_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5283 | bgp_node_safi (vty), argv[idx_word]->arg); | |
718e3744 | 5284 | } |
5285 | ||
5286 | DEFUN (no_neighbor_unsuppress_map, | |
5287 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5288 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5289 | NO_STR |
5290 | NEIGHBOR_STR | |
5291 | NEIGHBOR_ADDR_STR2 | |
5292 | "Route-map to selectively unsuppress suppressed routes\n" | |
5293 | "Name of route map\n") | |
5294 | { | |
c500ae40 DW |
5295 | int idx_peer = 2; |
5296 | return peer_unsuppress_map_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 5297 | bgp_node_safi (vty)); |
5298 | } | |
6b0655a2 | 5299 | |
94f2b392 | 5300 | static int |
fd79ac91 | 5301 | peer_maximum_prefix_set_vty (struct vty *vty, const char *ip_str, afi_t afi, |
e52702f2 | 5302 | safi_t safi, const char *num_str, |
0a486e5f | 5303 | const char *threshold_str, int warning, |
5304 | const char *restart_str) | |
718e3744 | 5305 | { |
5306 | int ret; | |
5307 | struct peer *peer; | |
5308 | u_int32_t max; | |
e0701b79 | 5309 | u_char threshold; |
0a486e5f | 5310 | u_int16_t restart; |
718e3744 | 5311 | |
5312 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5313 | if (! peer) | |
5314 | return CMD_WARNING; | |
5315 | ||
e6ec1c36 | 5316 | VTY_GET_INTEGER ("maximum number", max, num_str); |
e0701b79 | 5317 | if (threshold_str) |
5318 | threshold = atoi (threshold_str); | |
5319 | else | |
5320 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 5321 | |
0a486e5f | 5322 | if (restart_str) |
5323 | restart = atoi (restart_str); | |
5324 | else | |
5325 | restart = 0; | |
5326 | ||
5327 | ret = peer_maximum_prefix_set (peer, afi, safi, max, threshold, warning, restart); | |
718e3744 | 5328 | |
5329 | return bgp_vty_return (vty, ret); | |
5330 | } | |
5331 | ||
94f2b392 | 5332 | static int |
fd79ac91 | 5333 | peer_maximum_prefix_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
718e3744 | 5334 | safi_t safi) |
5335 | { | |
5336 | int ret; | |
5337 | struct peer *peer; | |
5338 | ||
5339 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5340 | if (! peer) | |
5341 | return CMD_WARNING; | |
5342 | ||
5343 | ret = peer_maximum_prefix_unset (peer, afi, safi); | |
5344 | ||
5345 | return bgp_vty_return (vty, ret); | |
5346 | } | |
5347 | ||
5348 | /* Maximum number of prefix configuration. prefix count is different | |
5349 | for each peer configuration. So this configuration can be set for | |
5350 | each peer configuration. */ | |
5351 | DEFUN (neighbor_maximum_prefix, | |
5352 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 5353 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 5354 | NEIGHBOR_STR |
5355 | NEIGHBOR_ADDR_STR2 | |
5356 | "Maximum number of prefix accept from this peer\n" | |
5357 | "maximum no. of prefix limit\n") | |
5358 | { | |
c500ae40 DW |
5359 | int idx_peer = 1; |
5360 | int idx_number = 3; | |
5361 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5362 | bgp_node_safi (vty), argv[idx_number]->arg, NULL, 0, | |
0a486e5f | 5363 | NULL); |
718e3744 | 5364 | } |
5365 | ||
e0701b79 | 5366 | DEFUN (neighbor_maximum_prefix_threshold, |
5367 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 5368 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 5369 | NEIGHBOR_STR |
5370 | NEIGHBOR_ADDR_STR2 | |
5371 | "Maximum number of prefix accept from this peer\n" | |
5372 | "maximum no. of prefix limit\n" | |
5373 | "Threshold value (%) at which to generate a warning msg\n") | |
5374 | { | |
c500ae40 DW |
5375 | int idx_peer = 1; |
5376 | int idx_number = 3; | |
5377 | int idx_number_2 = 4; | |
5378 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5379 | bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
0a486e5f | 5380 | NULL); |
5381 | } | |
e0701b79 | 5382 | |
718e3744 | 5383 | DEFUN (neighbor_maximum_prefix_warning, |
5384 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 5385 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 5386 | NEIGHBOR_STR |
5387 | NEIGHBOR_ADDR_STR2 | |
5388 | "Maximum number of prefix accept from this peer\n" | |
5389 | "maximum no. of prefix limit\n" | |
5390 | "Only give warning message when limit is exceeded\n") | |
5391 | { | |
c500ae40 DW |
5392 | int idx_peer = 1; |
5393 | int idx_number = 3; | |
5394 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5395 | bgp_node_safi (vty), argv[idx_number]->arg, NULL, 1, | |
0a486e5f | 5396 | NULL); |
718e3744 | 5397 | } |
5398 | ||
e0701b79 | 5399 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
5400 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 5401 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 5402 | NEIGHBOR_STR |
5403 | NEIGHBOR_ADDR_STR2 | |
5404 | "Maximum number of prefix accept from this peer\n" | |
5405 | "maximum no. of prefix limit\n" | |
5406 | "Threshold value (%) at which to generate a warning msg\n" | |
5407 | "Only give warning message when limit is exceeded\n") | |
5408 | { | |
c500ae40 DW |
5409 | int idx_peer = 1; |
5410 | int idx_number = 3; | |
5411 | int idx_number_2 = 4; | |
5412 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5413 | bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 5414 | } |
5415 | ||
5416 | DEFUN (neighbor_maximum_prefix_restart, | |
5417 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 5418 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 5419 | NEIGHBOR_STR |
5420 | NEIGHBOR_ADDR_STR2 | |
5421 | "Maximum number of prefix accept from this peer\n" | |
5422 | "maximum no. of prefix limit\n" | |
5423 | "Restart bgp connection after limit is exceeded\n" | |
5424 | "Restart interval in minutes") | |
5425 | { | |
c500ae40 DW |
5426 | int idx_peer = 1; |
5427 | int idx_number = 3; | |
5428 | int idx_number_2 = 5; | |
5429 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5430 | bgp_node_safi (vty), argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 5431 | } |
5432 | ||
5433 | DEFUN (neighbor_maximum_prefix_threshold_restart, | |
5434 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 5435 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 5436 | NEIGHBOR_STR |
5437 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5438 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 5439 | "maximum no. of prefix limit\n" |
5440 | "Threshold value (%) at which to generate a warning msg\n" | |
5441 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 5442 | "Restart interval in minutes\n") |
0a486e5f | 5443 | { |
c500ae40 DW |
5444 | int idx_peer = 1; |
5445 | int idx_number = 3; | |
5446 | int idx_number_2 = 4; | |
5447 | int idx_number_3 = 6; | |
5448 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5449 | bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 0, argv[idx_number_3]->arg); | |
0a486e5f | 5450 | } |
e0701b79 | 5451 | |
718e3744 | 5452 | DEFUN (no_neighbor_maximum_prefix, |
5453 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 5454 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 5455 | NO_STR |
5456 | NEIGHBOR_STR | |
5457 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5458 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
5459 | "maximum no. of prefix limit\n" |
5460 | "Threshold value (%) at which to generate a warning msg\n" | |
5461 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 5462 | "Restart interval in minutes\n" |
31500417 | 5463 | "Only give warning message when limit is exceeded\n") |
718e3744 | 5464 | { |
c500ae40 DW |
5465 | int idx_peer = 2; |
5466 | return peer_maximum_prefix_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 5467 | bgp_node_safi (vty)); |
5468 | } | |
e52702f2 | 5469 | |
718e3744 | 5470 | |
718e3744 | 5471 | /* "neighbor allowas-in" */ |
5472 | DEFUN (neighbor_allowas_in, | |
5473 | neighbor_allowas_in_cmd, | |
fd8503f5 | 5474 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 5475 | NEIGHBOR_STR |
5476 | NEIGHBOR_ADDR_STR2 | |
31500417 | 5477 | "Accept as-path with my AS present in it\n" |
fd8503f5 QY |
5478 | "Number of occurances of AS number\n" |
5479 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 5480 | { |
c500ae40 | 5481 | int idx_peer = 1; |
fd8503f5 | 5482 | int idx_number_origin = 3; |
718e3744 | 5483 | int ret; |
aac9ef6c | 5484 | int origin = 0; |
718e3744 | 5485 | struct peer *peer; |
aac9ef6c | 5486 | int allow_num = 0; |
718e3744 | 5487 | |
c500ae40 | 5488 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 5489 | if (! peer) |
5490 | return CMD_WARNING; | |
5491 | ||
fd8503f5 | 5492 | if (argc <= idx_number_origin) |
718e3744 | 5493 | allow_num = 3; |
5494 | else | |
aac9ef6c | 5495 | { |
fd8503f5 | 5496 | if (argv[idx_number_origin]->type == WORD_TKN) |
aac9ef6c DW |
5497 | origin = 1; |
5498 | else | |
fd8503f5 | 5499 | allow_num = atoi (argv[idx_number_origin]->arg); |
aac9ef6c | 5500 | } |
718e3744 | 5501 | |
5502 | ret = peer_allowas_in_set (peer, bgp_node_afi (vty), bgp_node_safi (vty), | |
aac9ef6c | 5503 | allow_num, origin); |
718e3744 | 5504 | |
5505 | return bgp_vty_return (vty, ret); | |
5506 | } | |
5507 | ||
718e3744 | 5508 | DEFUN (no_neighbor_allowas_in, |
5509 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 5510 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 5511 | NO_STR |
5512 | NEIGHBOR_STR | |
5513 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 5514 | "allow local ASN appears in aspath attribute\n" |
fd8503f5 QY |
5515 | "Number of occurances of AS number\n" |
5516 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 5517 | { |
c500ae40 | 5518 | int idx_peer = 2; |
718e3744 | 5519 | int ret; |
5520 | struct peer *peer; | |
5521 | ||
c500ae40 | 5522 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 5523 | if (! peer) |
5524 | return CMD_WARNING; | |
5525 | ||
5526 | ret = peer_allowas_in_unset (peer, bgp_node_afi (vty), bgp_node_safi (vty)); | |
5527 | ||
5528 | return bgp_vty_return (vty, ret); | |
5529 | } | |
6b0655a2 | 5530 | |
fa411a21 NH |
5531 | DEFUN (neighbor_ttl_security, |
5532 | neighbor_ttl_security_cmd, | |
9ccf14f7 | 5533 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
5534 | NEIGHBOR_STR |
5535 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5536 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
5537 | "Specify the maximum number of hops to the BGP peer\n" |
5538 | "Number of hops to BGP peer\n") | |
fa411a21 | 5539 | { |
c500ae40 DW |
5540 | int idx_peer = 1; |
5541 | int idx_number = 4; | |
fa411a21 | 5542 | struct peer *peer; |
89b6d1f8 | 5543 | int gtsm_hops; |
fa411a21 | 5544 | |
c500ae40 | 5545 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
fa411a21 NH |
5546 | if (! peer) |
5547 | return CMD_WARNING; | |
e52702f2 | 5548 | |
c500ae40 | 5549 | VTY_GET_INTEGER_RANGE ("", gtsm_hops, argv[idx_number]->arg, 1, 254); |
fa411a21 | 5550 | |
8cdabf90 SK |
5551 | /* |
5552 | * If 'neighbor swpX', then this is for directly connected peers, | |
5553 | * we should not accept a ttl-security hops value greater than 1. | |
5554 | */ | |
5555 | if (peer->conf_if && (gtsm_hops > 1)) { | |
5556 | vty_out (vty, "%s is directly connected peer, hops cannot exceed 1%s", | |
c500ae40 | 5557 | argv[idx_peer]->arg, VTY_NEWLINE); |
8cdabf90 SK |
5558 | return CMD_WARNING; |
5559 | } | |
5560 | ||
89b6d1f8 | 5561 | return bgp_vty_return (vty, peer_ttl_security_hops_set (peer, gtsm_hops)); |
fa411a21 NH |
5562 | } |
5563 | ||
5564 | DEFUN (no_neighbor_ttl_security, | |
5565 | no_neighbor_ttl_security_cmd, | |
9ccf14f7 | 5566 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
5567 | NO_STR |
5568 | NEIGHBOR_STR | |
5569 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5570 | "BGP ttl-security parameters\n" |
3a2d747c QY |
5571 | "Specify the maximum number of hops to the BGP peer\n" |
5572 | "Number of hops to BGP peer\n") | |
fa411a21 | 5573 | { |
c500ae40 | 5574 | int idx_peer = 2; |
fa411a21 | 5575 | struct peer *peer; |
fa411a21 | 5576 | |
c500ae40 | 5577 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
fa411a21 NH |
5578 | if (! peer) |
5579 | return CMD_WARNING; | |
5580 | ||
89b6d1f8 | 5581 | return bgp_vty_return (vty, peer_ttl_security_hops_unset (peer)); |
fa411a21 | 5582 | } |
6b0655a2 | 5583 | |
adbac85e DW |
5584 | DEFUN (neighbor_addpath_tx_all_paths, |
5585 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 5586 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
5587 | NEIGHBOR_STR |
5588 | NEIGHBOR_ADDR_STR2 | |
5589 | "Use addpath to advertise all paths to a neighbor\n") | |
5590 | { | |
c500ae40 | 5591 | int idx_peer = 1; |
adbac85e DW |
5592 | struct peer *peer; |
5593 | ||
c500ae40 | 5594 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
adbac85e DW |
5595 | if (! peer) |
5596 | return CMD_WARNING; | |
5597 | ||
c500ae40 | 5598 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
adbac85e DW |
5599 | bgp_node_safi (vty), |
5600 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
5601 | } | |
5602 | ||
5603 | DEFUN (no_neighbor_addpath_tx_all_paths, | |
5604 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 5605 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
5606 | NO_STR |
5607 | NEIGHBOR_STR | |
5608 | NEIGHBOR_ADDR_STR2 | |
5609 | "Use addpath to advertise all paths to a neighbor\n") | |
5610 | { | |
c500ae40 DW |
5611 | int idx_peer = 2; |
5612 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
adbac85e DW |
5613 | bgp_node_safi (vty), |
5614 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
5615 | } | |
5616 | ||
06370dac DW |
5617 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
5618 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 5619 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
5620 | NEIGHBOR_STR |
5621 | NEIGHBOR_ADDR_STR2 | |
5622 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
5623 | { | |
c500ae40 | 5624 | int idx_peer = 1; |
06370dac DW |
5625 | struct peer *peer; |
5626 | ||
c500ae40 | 5627 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
06370dac DW |
5628 | if (! peer) |
5629 | return CMD_WARNING; | |
5630 | ||
c500ae40 | 5631 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
06370dac DW |
5632 | bgp_node_safi (vty), |
5633 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
5634 | } | |
5635 | ||
5636 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, | |
5637 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 5638 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
5639 | NO_STR |
5640 | NEIGHBOR_STR | |
5641 | NEIGHBOR_ADDR_STR2 | |
5642 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
5643 | { | |
c500ae40 DW |
5644 | int idx_peer = 2; |
5645 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
06370dac DW |
5646 | bgp_node_safi (vty), |
5647 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
5648 | } | |
5649 | ||
505e5056 | 5650 | DEFUN_NOSH (address_family_ipv4_safi, |
718e3744 | 5651 | address_family_ipv4_safi_cmd, |
c7f1274b | 5652 | "address-family ipv4 [<unicast|multicast|vpn|encap>]", |
718e3744 | 5653 | "Enter Address Family command mode\n" |
8c3deaae | 5654 | "Address Family\n" |
46f296b4 | 5655 | BGP_SAFI_HELP_STR) |
718e3744 | 5656 | { |
c500ae40 | 5657 | int idx_safi = 2; |
af155bb6 | 5658 | if (argc == (idx_safi + 1)) |
ccbb332a | 5659 | { |
c7f1274b DS |
5660 | switch (bgp_vty_safi_from_arg(argv[idx_safi]->arg)) |
5661 | { | |
5662 | case SAFI_MULTICAST: | |
5663 | vty->node = BGP_IPV4M_NODE; | |
5664 | break; | |
5665 | case SAFI_ENCAP: | |
5666 | vty->node = BGP_ENCAP_NODE; | |
5667 | break; | |
5668 | case SAFI_MPLS_VPN: | |
5669 | vty->node = BGP_VPNV4_NODE; | |
5670 | break; | |
5671 | case SAFI_UNICAST: | |
5672 | default: | |
5673 | vty->node = BGP_IPV4_NODE; | |
5674 | break; | |
5675 | } | |
ccbb332a | 5676 | } |
c7f1274b DS |
5677 | else |
5678 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 5679 | |
5680 | return CMD_SUCCESS; | |
5681 | } | |
5682 | ||
505e5056 | 5683 | DEFUN_NOSH (address_family_ipv6_safi, |
25ffbdc1 | 5684 | address_family_ipv6_safi_cmd, |
c7f1274b | 5685 | "address-family ipv6 [<unicast|multicast|vpn|encap>]", |
718e3744 | 5686 | "Enter Address Family command mode\n" |
8c3deaae | 5687 | "Address Family\n" |
46f296b4 | 5688 | BGP_SAFI_HELP_STR) |
25ffbdc1 | 5689 | { |
c500ae40 | 5690 | int idx_safi = 2; |
af155bb6 | 5691 | if (argc == (idx_safi + 1)) |
46f296b4 | 5692 | { |
c7f1274b DS |
5693 | switch (bgp_vty_safi_from_arg(argv[idx_safi]->arg)) |
5694 | { | |
5695 | case SAFI_MULTICAST: | |
5696 | vty->node = BGP_IPV6M_NODE; | |
5697 | break; | |
5698 | case SAFI_ENCAP: | |
5699 | vty->node = BGP_ENCAPV6_NODE; | |
5700 | break; | |
5701 | case SAFI_MPLS_VPN: | |
5702 | vty->node = BGP_VPNV6_NODE; | |
5703 | break; | |
5704 | case SAFI_UNICAST: | |
5705 | default: | |
5706 | vty->node = BGP_IPV6_NODE; | |
5707 | break; | |
5708 | } | |
46f296b4 | 5709 | } |
c7f1274b DS |
5710 | else |
5711 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 5712 | |
5713 | return CMD_SUCCESS; | |
5714 | } | |
718e3744 | 5715 | |
d6902373 | 5716 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 5717 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 5718 | address_family_vpnv4_cmd, |
8334fd5a | 5719 | "address-family vpnv4 [unicast]", |
718e3744 | 5720 | "Enter Address Family command mode\n" |
8c3deaae | 5721 | "Address Family\n" |
3a2d747c | 5722 | "Address Family modifier\n") |
718e3744 | 5723 | { |
5724 | vty->node = BGP_VPNV4_NODE; | |
5725 | return CMD_SUCCESS; | |
5726 | } | |
5727 | ||
505e5056 | 5728 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 5729 | address_family_vpnv6_cmd, |
8334fd5a | 5730 | "address-family vpnv6 [unicast]", |
8ecd3266 | 5731 | "Enter Address Family command mode\n" |
8c3deaae | 5732 | "Address Family\n" |
3a2d747c | 5733 | "Address Family modifier\n") |
8ecd3266 | 5734 | { |
5735 | vty->node = BGP_VPNV6_NODE; | |
5736 | return CMD_SUCCESS; | |
5737 | } | |
c016b6c7 | 5738 | #endif |
d6902373 | 5739 | |
505e5056 | 5740 | DEFUN_NOSH (address_family_encap, |
8b1fb8be | 5741 | address_family_encap_cmd, |
8334fd5a | 5742 | "address-family <encap|encapv4>", |
8b1fb8be | 5743 | "Enter Address Family command mode\n" |
8c3deaae QY |
5744 | "Address Family\n" |
5745 | "Address Family\n") | |
8b1fb8be LB |
5746 | { |
5747 | vty->node = BGP_ENCAP_NODE; | |
5748 | return CMD_SUCCESS; | |
5749 | } | |
5750 | ||
8b1fb8be | 5751 | |
505e5056 | 5752 | DEFUN_NOSH (address_family_encapv6, |
8b1fb8be LB |
5753 | address_family_encapv6_cmd, |
5754 | "address-family encapv6", | |
5755 | "Enter Address Family command mode\n" | |
8c3deaae | 5756 | "Address Family\n") |
8b1fb8be LB |
5757 | { |
5758 | vty->node = BGP_ENCAPV6_NODE; | |
5759 | return CMD_SUCCESS; | |
5760 | } | |
5761 | ||
505e5056 | 5762 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 5763 | address_family_evpn_cmd, |
b194703e | 5764 | "address-family <l2vpn evpn>", |
4e0b7b6d | 5765 | "Enter Address Family command mode\n" |
61a51962 PG |
5766 | "EVPN Address family\n" |
5767 | "Layer2 VPN Address family\n" | |
5768 | "Ethernet Virtual Private Network Subsequent Address Family\n") | |
4e0b7b6d | 5769 | { |
4e0b7b6d | 5770 | vty->node = BGP_EVPN_NODE; |
4e0b7b6d PG |
5771 | return CMD_SUCCESS; |
5772 | } | |
5773 | ||
505e5056 | 5774 | DEFUN_NOSH (exit_address_family, |
718e3744 | 5775 | exit_address_family_cmd, |
5776 | "exit-address-family", | |
5777 | "Exit from Address Family configuration mode\n") | |
5778 | { | |
a8a80d53 | 5779 | if (vty->node == BGP_IPV4_NODE |
5780 | || vty->node == BGP_IPV4M_NODE | |
718e3744 | 5781 | || vty->node == BGP_VPNV4_NODE |
25ffbdc1 | 5782 | || vty->node == BGP_IPV6_NODE |
8ecd3266 | 5783 | || vty->node == BGP_IPV6M_NODE |
8b1fb8be LB |
5784 | || vty->node == BGP_VPNV6_NODE |
5785 | || vty->node == BGP_ENCAP_NODE | |
4e0b7b6d PG |
5786 | || vty->node == BGP_ENCAPV6_NODE |
5787 | || vty->node == BGP_EVPN_NODE) | |
718e3744 | 5788 | vty->node = BGP_NODE; |
5789 | return CMD_SUCCESS; | |
5790 | } | |
6b0655a2 | 5791 | |
8ad7271d DS |
5792 | /* Recalculate bestpath and re-advertise a prefix */ |
5793 | static int | |
01080f7c | 5794 | bgp_clear_prefix (struct vty *vty, const char *view_name, const char *ip_str, |
8ad7271d DS |
5795 | afi_t afi, safi_t safi, struct prefix_rd *prd) |
5796 | { | |
5797 | int ret; | |
5798 | struct prefix match; | |
5799 | struct bgp_node *rn; | |
5800 | struct bgp_node *rm; | |
8ad7271d DS |
5801 | struct bgp *bgp; |
5802 | struct bgp_table *table; | |
5803 | struct bgp_table *rib; | |
5804 | ||
5805 | /* BGP structure lookup. */ | |
5806 | if (view_name) | |
5807 | { | |
5808 | bgp = bgp_lookup_by_name (view_name); | |
5809 | if (bgp == NULL) | |
5810 | { | |
6aeb9e78 | 5811 | vty_out (vty, "%% Can't find BGP instance %s%s", view_name, VTY_NEWLINE); |
8ad7271d DS |
5812 | return CMD_WARNING; |
5813 | } | |
5814 | } | |
5815 | else | |
5816 | { | |
5817 | bgp = bgp_get_default (); | |
5818 | if (bgp == NULL) | |
5819 | { | |
5820 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
5821 | return CMD_WARNING; | |
5822 | } | |
5823 | } | |
5824 | ||
5825 | /* Check IP address argument. */ | |
5826 | ret = str2prefix (ip_str, &match); | |
5827 | if (! ret) | |
5828 | { | |
5829 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); | |
5830 | return CMD_WARNING; | |
5831 | } | |
5832 | ||
5833 | match.family = afi2family (afi); | |
5834 | rib = bgp->rib[afi][safi]; | |
5835 | ||
5836 | if (safi == SAFI_MPLS_VPN) | |
5837 | { | |
5838 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) | |
5839 | { | |
5840 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) | |
5841 | continue; | |
5842 | ||
5843 | if ((table = rn->info) != NULL) | |
5844 | { | |
5845 | if ((rm = bgp_node_match (table, &match)) != NULL) | |
5846 | { | |
5847 | if (rm->p.prefixlen == match.prefixlen) | |
5848 | { | |
5849 | SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR); | |
5850 | bgp_process (bgp, rm, afi, safi); | |
5851 | } | |
5852 | bgp_unlock_node (rm); | |
5853 | } | |
5854 | } | |
5855 | } | |
5856 | } | |
5857 | else | |
5858 | { | |
5859 | if ((rn = bgp_node_match (rib, &match)) != NULL) | |
5860 | { | |
5861 | if (rn->p.prefixlen == match.prefixlen) | |
5862 | { | |
5863 | SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR); | |
5864 | bgp_process (bgp, rn, afi, safi); | |
5865 | } | |
5866 | bgp_unlock_node (rn); | |
5867 | } | |
5868 | } | |
5869 | ||
5870 | return CMD_SUCCESS; | |
5871 | } | |
5872 | ||
b09b5ae0 | 5873 | /* one clear bgp command to rule them all */ |
718e3744 | 5874 | DEFUN (clear_ip_bgp_all, |
5875 | clear_ip_bgp_all_cmd, | |
46f296b4 | 5876 | "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 | 5877 | CLEAR_STR |
5878 | IP_STR | |
5879 | BGP_STR | |
838758ac | 5880 | BGP_INSTANCE_HELP_STR |
b09b5ae0 DW |
5881 | "Clear all peers\n" |
5882 | "BGP neighbor address to clear\n" | |
a80beece | 5883 | "BGP IPv6 neighbor to clear\n" |
838758ac | 5884 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
5885 | "Clear peers with the AS number\n" |
5886 | "Clear all external peers\n" | |
718e3744 | 5887 | "Clear all members of peer-group\n" |
b09b5ae0 | 5888 | "BGP peer-group name\n" |
46f296b4 LB |
5889 | BGP_AFI_HELP_STR |
5890 | BGP_SAFI_HELP_STR | |
b09b5ae0 DW |
5891 | BGP_SOFT_STR |
5892 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
5893 | BGP_SOFT_OUT_STR |
5894 | BGP_SOFT_IN_STR | |
5895 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 5896 | BGP_SOFT_OUT_STR) |
718e3744 | 5897 | { |
cdc2d765 | 5898 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8334fd5a | 5899 | char *vrf = NULL; |
630a298c | 5900 | |
ae19d7dd QY |
5901 | afi_t afi = AFI_IP6; |
5902 | safi_t safi = SAFI_UNICAST; | |
5bf15956 | 5903 | enum clear_sort clr_sort = clear_peer; |
b09b5ae0 DW |
5904 | enum bgp_clear_type clr_type; |
5905 | char *clr_arg = NULL; | |
718e3744 | 5906 | |
ae19d7dd | 5907 | int idx = 0; |
01080f7c | 5908 | |
ae19d7dd QY |
5909 | /* clear [ip] bgp */ |
5910 | if (argv_find (argv, argc, "ip", &idx)) | |
5911 | afi = AFI_IP; | |
5912 | /* [<view|vrf> WORD] */ | |
5913 | if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) | |
838758ac | 5914 | { |
ae19d7dd QY |
5915 | vrf = argv[idx + 1]->arg; |
5916 | idx += 2; | |
838758ac | 5917 | } |
ae19d7dd QY |
5918 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */ |
5919 | if (argv_find (argv, argc, "*", &idx)) | |
b09b5ae0 | 5920 | { |
ae19d7dd | 5921 | clr_sort = clear_all; |
b09b5ae0 | 5922 | } |
ae19d7dd | 5923 | else if (argv_find (argv, argc, "A.B.C.D", &idx)) |
b09b5ae0 DW |
5924 | { |
5925 | clr_sort = clear_peer; | |
ae19d7dd | 5926 | clr_arg = argv[idx]->arg; |
b09b5ae0 | 5927 | } |
ae19d7dd | 5928 | else if (argv_find (argv, argc, "X:X::X:X", &idx)) |
b09b5ae0 | 5929 | { |
ae19d7dd QY |
5930 | clr_sort = clear_peer; |
5931 | clr_arg = argv[idx]->arg; | |
838758ac | 5932 | } |
ae19d7dd | 5933 | else if (argv_find (argv, argc, "peer-group", &idx)) |
b09b5ae0 DW |
5934 | { |
5935 | clr_sort = clear_group; | |
ae19d7dd QY |
5936 | idx++; |
5937 | clr_arg = argv[idx]->arg; | |
718e3744 | 5938 | |
cdc2d765 | 5939 | if (! peer_group_lookup (bgp, clr_arg)) |
b09b5ae0 DW |
5940 | { |
5941 | vty_out (vty, "%% No such peer-group%s", VTY_NEWLINE); | |
ae19d7dd | 5942 | return CMD_WARNING; |
b09b5ae0 DW |
5943 | } |
5944 | } | |
ae19d7dd | 5945 | else if (argv_find (argv, argc, "WORD", &idx)) |
b09b5ae0 | 5946 | { |
cdc2d765 | 5947 | if (peer_lookup_by_conf_if (bgp, argv[idx]->arg)) |
b09b5ae0 DW |
5948 | { |
5949 | clr_sort = clear_peer; | |
ae19d7dd | 5950 | clr_arg = argv[idx]->arg; |
b09b5ae0 DW |
5951 | } |
5952 | else | |
5953 | { | |
5954 | vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE); | |
5955 | return CMD_WARNING; | |
5956 | } | |
5957 | } | |
ae19d7dd QY |
5958 | else if (argv_find (argv, argc, "(1-4294967295)", &idx)) |
5959 | { | |
5960 | clr_sort = clear_as; | |
5961 | clr_arg = argv[idx]->arg; | |
5962 | } | |
5963 | else if (argv_find (argv, argc, "external", &idx)) | |
5964 | { | |
5965 | clr_sort = clear_external; | |
5966 | } | |
46f296b4 LB |
5967 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
5968 | if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) | |
ae19d7dd | 5969 | { |
46f296b4 | 5970 | argv_find_and_parse_safi (argv, argc, &idx, &safi); |
ae19d7dd QY |
5971 | } |
5972 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
5973 | if (argv_find (argv, argc, "soft", &idx)) | |
5974 | { | |
5975 | if (argv_find (argv, argc, "in", &idx) || argv_find (argv, argc, "out", &idx)) | |
5976 | clr_type = strmatch (argv[idx]->text, "in") ? BGP_CLEAR_SOFT_IN : BGP_CLEAR_SOFT_OUT; | |
5977 | else | |
5978 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
5979 | } | |
5980 | else if (argv_find (argv, argc, "in", &idx)) | |
5981 | { | |
5982 | clr_type = argv_find (argv, argc, "prefix-filter", &idx) ? BGP_CLEAR_SOFT_IN_ORF_PREFIX : BGP_CLEAR_SOFT_IN; | |
5983 | } | |
5984 | else if (argv_find (argv, argc, "out", &idx)) | |
5985 | { | |
5daa3e5e | 5986 | clr_type = BGP_CLEAR_SOFT_OUT; |
ae19d7dd QY |
5987 | } |
5988 | else | |
5989 | clr_type = BGP_CLEAR_SOFT_NONE; | |
718e3744 | 5990 | |
b09b5ae0 | 5991 | return bgp_clear_vty (vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); |
838758ac | 5992 | } |
01080f7c | 5993 | |
8ad7271d DS |
5994 | DEFUN (clear_ip_bgp_prefix, |
5995 | clear_ip_bgp_prefix_cmd, | |
838758ac | 5996 | "clear [ip] bgp [<view|vrf> WORD] prefix A.B.C.D/M", |
8ad7271d DS |
5997 | CLEAR_STR |
5998 | IP_STR | |
5999 | BGP_STR | |
838758ac | 6000 | BGP_INSTANCE_HELP_STR |
8ad7271d | 6001 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 6002 | "IPv4 prefix\n") |
8ad7271d | 6003 | { |
8334fd5a | 6004 | char *vrf = NULL; |
630a298c | 6005 | char *prefix = NULL; |
8ad7271d | 6006 | |
630a298c | 6007 | int idx = 0; |
01080f7c | 6008 | |
630a298c QY |
6009 | /* [<view|vrf> WORD] */ |
6010 | if (argv_find (argv, argc, "WORD", &idx)) | |
6011 | vrf = argv[idx]->arg; | |
0c7b1b01 | 6012 | |
630a298c | 6013 | prefix = argv[argc-1]->arg; |
8ad7271d | 6014 | |
630a298c | 6015 | return bgp_clear_prefix (vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 6016 | } |
8ad7271d | 6017 | |
b09b5ae0 DW |
6018 | DEFUN (clear_bgp_ipv6_safi_prefix, |
6019 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 6020 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 6021 | CLEAR_STR |
3a2d747c | 6022 | IP_STR |
718e3744 | 6023 | BGP_STR |
8c3deaae | 6024 | "Address Family\n" |
46f296b4 | 6025 | BGP_SAFI_HELP_STR |
b09b5ae0 | 6026 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 6027 | "IPv6 prefix\n") |
718e3744 | 6028 | { |
b09b5ae0 DW |
6029 | int idx_safi = 3; |
6030 | int idx_ipv6_prefixlen = 5; | |
46f296b4 LB |
6031 | return bgp_clear_prefix (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, |
6032 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), NULL); | |
838758ac | 6033 | } |
01080f7c | 6034 | |
b09b5ae0 DW |
6035 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
6036 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
46f296b4 | 6037 | "clear [ip] bgp <view|vrf> WORD ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 6038 | CLEAR_STR |
3a2d747c | 6039 | IP_STR |
718e3744 | 6040 | BGP_STR |
838758ac | 6041 | BGP_INSTANCE_HELP_STR |
8c3deaae | 6042 | "Address Family\n" |
46f296b4 | 6043 | BGP_SAFI_HELP_STR |
b09b5ae0 | 6044 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 6045 | "IPv6 prefix\n") |
718e3744 | 6046 | { |
b09b5ae0 | 6047 | int idx_word = 3; |
c500ae40 | 6048 | int idx_safi = 5; |
b09b5ae0 | 6049 | int idx_ipv6_prefixlen = 7; |
46f296b4 LB |
6050 | return bgp_clear_prefix (vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, |
6051 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), NULL); | |
718e3744 | 6052 | } |
6053 | ||
b09b5ae0 DW |
6054 | DEFUN (show_bgp_views, |
6055 | show_bgp_views_cmd, | |
d6e3c605 | 6056 | "show [ip] bgp views", |
b09b5ae0 | 6057 | SHOW_STR |
d6e3c605 | 6058 | IP_STR |
01080f7c | 6059 | BGP_STR |
b09b5ae0 | 6060 | "Show the defined BGP views\n") |
01080f7c | 6061 | { |
b09b5ae0 DW |
6062 | struct list *inst = bm->bgp; |
6063 | struct listnode *node; | |
6064 | struct bgp *bgp; | |
01080f7c | 6065 | |
b09b5ae0 DW |
6066 | if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE)) |
6067 | { | |
6068 | vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE); | |
6069 | return CMD_WARNING; | |
6070 | } | |
e52702f2 | 6071 | |
b09b5ae0 DW |
6072 | vty_out (vty, "Defined BGP views:%s", VTY_NEWLINE); |
6073 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) | |
6074 | { | |
6075 | /* Skip VRFs. */ | |
6076 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
6077 | continue; | |
6078 | vty_out (vty, "\t%s (AS%u)%s", | |
6079 | bgp->name ? bgp->name : "(null)", | |
6080 | bgp->as, VTY_NEWLINE); | |
6081 | } | |
e52702f2 | 6082 | |
b09b5ae0 | 6083 | return CMD_SUCCESS; |
e0081f70 ML |
6084 | } |
6085 | ||
8386ac43 | 6086 | DEFUN (show_bgp_vrfs, |
6087 | show_bgp_vrfs_cmd, | |
d6e3c605 | 6088 | "show [ip] bgp vrfs [json]", |
8386ac43 | 6089 | SHOW_STR |
d6e3c605 | 6090 | IP_STR |
8386ac43 | 6091 | BGP_STR |
6092 | "Show BGP VRFs\n" | |
9973d184 | 6093 | JSON_STR) |
8386ac43 | 6094 | { |
6095 | struct list *inst = bm->bgp; | |
6096 | struct listnode *node; | |
6097 | struct bgp *bgp; | |
6098 | u_char uj = use_json(argc, argv); | |
6099 | json_object *json = NULL; | |
6100 | json_object *json_vrfs = NULL; | |
6101 | int count = 0; | |
6102 | static char header[] = "Type Id RouterId #PeersCfg #PeersEstb Name"; | |
6103 | ||
6104 | if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE)) | |
6105 | { | |
6106 | vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE); | |
6107 | return CMD_WARNING; | |
6108 | } | |
6109 | ||
6110 | if (uj) | |
6111 | { | |
6112 | json = json_object_new_object(); | |
6113 | json_vrfs = json_object_new_object(); | |
6114 | } | |
6115 | ||
6116 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) | |
6117 | { | |
6118 | const char *name, *type; | |
6119 | struct peer *peer; | |
6120 | struct listnode *node, *nnode; | |
6121 | int peers_cfg, peers_estb; | |
6122 | json_object *json_vrf = NULL; | |
5c81a5f3 | 6123 | int vrf_id_ui; |
8386ac43 | 6124 | |
6125 | /* Skip Views. */ | |
6126 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
6127 | continue; | |
6128 | ||
6129 | count++; | |
6130 | if (!uj && count == 1) | |
6131 | vty_out (vty, "%s%s", header, VTY_NEWLINE); | |
6132 | ||
6133 | peers_cfg = peers_estb = 0; | |
6134 | if (uj) | |
6135 | json_vrf = json_object_new_object(); | |
6136 | ||
6137 | ||
6138 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
6139 | { | |
6140 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6141 | continue; | |
6142 | peers_cfg++; | |
6143 | if (peer->status == Established) | |
6144 | peers_estb++; | |
6145 | } | |
6146 | ||
6147 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
6148 | { | |
6149 | name = "Default"; | |
6150 | type = "DFLT"; | |
6151 | } | |
6152 | else | |
6153 | { | |
6154 | name = bgp->name; | |
6155 | type = "VRF"; | |
6156 | } | |
6157 | ||
5c81a5f3 | 6158 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id; |
8386ac43 | 6159 | if (uj) |
6160 | { | |
6161 | json_object_string_add(json_vrf, "type", type); | |
5c81a5f3 | 6162 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); |
8386ac43 | 6163 | json_object_string_add(json_vrf, "routerId", inet_ntoa (bgp->router_id)); |
6164 | json_object_int_add(json_vrf, "numConfiguredPeers", peers_cfg); | |
6165 | json_object_int_add(json_vrf, "numEstablishedPeers", peers_estb); | |
6166 | ||
6167 | json_object_object_add(json_vrfs, name, json_vrf); | |
6168 | } | |
6169 | else | |
5c81a5f3 | 6170 | vty_out (vty, "%4s %-5d %-16s %9u %10u %s%s", |
6171 | type, vrf_id_ui, inet_ntoa (bgp->router_id), | |
8386ac43 | 6172 | peers_cfg, peers_estb, name, |
6173 | VTY_NEWLINE); | |
6174 | } | |
6175 | ||
6176 | if (uj) | |
6177 | { | |
6178 | json_object_object_add(json, "vrfs", json_vrfs); | |
6179 | ||
6180 | json_object_int_add(json, "totalVrfs", count); | |
6181 | ||
2aac5767 | 6182 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
8386ac43 | 6183 | json_object_free(json); |
6184 | } | |
6185 | else | |
6186 | { | |
6187 | if (count) | |
6188 | vty_out (vty, "%sTotal number of VRFs (including default): %d%s", | |
6189 | VTY_NEWLINE, count, VTY_NEWLINE); | |
6190 | } | |
6191 | ||
6192 | return CMD_SUCCESS; | |
6193 | } | |
6194 | ||
f412b39a | 6195 | DEFUN (show_bgp_memory, |
4bf6a362 | 6196 | show_bgp_memory_cmd, |
7fa12b13 | 6197 | "show [ip] bgp memory", |
4bf6a362 | 6198 | SHOW_STR |
3a2d747c | 6199 | IP_STR |
4bf6a362 PJ |
6200 | BGP_STR |
6201 | "Global BGP memory statistics\n") | |
6202 | { | |
6203 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
6204 | unsigned long count; | |
e52702f2 | 6205 | |
4bf6a362 PJ |
6206 | /* RIB related usage stats */ |
6207 | count = mtype_stats_alloc (MTYPE_BGP_NODE); | |
6208 | vty_out (vty, "%ld RIB nodes, using %s of memory%s", count, | |
6209 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6210 | count * sizeof (struct bgp_node)), | |
6211 | VTY_NEWLINE); | |
e52702f2 | 6212 | |
4bf6a362 PJ |
6213 | count = mtype_stats_alloc (MTYPE_BGP_ROUTE); |
6214 | vty_out (vty, "%ld BGP routes, using %s of memory%s", count, | |
6215 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6216 | count * sizeof (struct bgp_info)), | |
6217 | VTY_NEWLINE); | |
fb982c25 PJ |
6218 | if ((count = mtype_stats_alloc (MTYPE_BGP_ROUTE_EXTRA))) |
6219 | vty_out (vty, "%ld BGP route ancillaries, using %s of memory%s", count, | |
6220 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6221 | count * sizeof (struct bgp_info_extra)), | |
6222 | VTY_NEWLINE); | |
e52702f2 | 6223 | |
4bf6a362 PJ |
6224 | if ((count = mtype_stats_alloc (MTYPE_BGP_STATIC))) |
6225 | vty_out (vty, "%ld Static routes, using %s of memory%s", count, | |
6226 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6227 | count * sizeof (struct bgp_static)), | |
6228 | VTY_NEWLINE); | |
3f9c7369 DS |
6229 | |
6230 | if ((count = mtype_stats_alloc (MTYPE_BGP_PACKET))) | |
6231 | vty_out (vty, "%ld Packets, using %s of memory%s", count, | |
6232 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6233 | count * sizeof (struct bpacket)), | |
6234 | VTY_NEWLINE); | |
e52702f2 | 6235 | |
4bf6a362 PJ |
6236 | /* Adj-In/Out */ |
6237 | if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_IN))) | |
6238 | vty_out (vty, "%ld Adj-In entries, using %s of memory%s", count, | |
6239 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6240 | count * sizeof (struct bgp_adj_in)), | |
6241 | VTY_NEWLINE); | |
6242 | if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_OUT))) | |
6243 | vty_out (vty, "%ld Adj-Out entries, using %s of memory%s", count, | |
6244 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6245 | count * sizeof (struct bgp_adj_out)), | |
6246 | VTY_NEWLINE); | |
e52702f2 | 6247 | |
4bf6a362 PJ |
6248 | if ((count = mtype_stats_alloc (MTYPE_BGP_NEXTHOP_CACHE))) |
6249 | vty_out (vty, "%ld Nexthop cache entries, using %s of memory%s", count, | |
6250 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6251 | count * sizeof (struct bgp_nexthop_cache)), | |
6252 | VTY_NEWLINE); | |
6253 | ||
6254 | if ((count = mtype_stats_alloc (MTYPE_BGP_DAMP_INFO))) | |
6255 | vty_out (vty, "%ld Dampening entries, using %s of memory%s", count, | |
6256 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6257 | count * sizeof (struct bgp_damp_info)), | |
6258 | VTY_NEWLINE); | |
6259 | ||
6260 | /* Attributes */ | |
6261 | count = attr_count(); | |
e52702f2 QY |
6262 | vty_out (vty, "%ld BGP attributes, using %s of memory%s", count, |
6263 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6264 | count * sizeof(struct attr)), | |
4bf6a362 | 6265 | VTY_NEWLINE); |
fb982c25 | 6266 | if ((count = mtype_stats_alloc (MTYPE_ATTR_EXTRA))) |
e52702f2 QY |
6267 | vty_out (vty, "%ld BGP extra attributes, using %s of memory%s", count, |
6268 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6269 | count * sizeof(struct attr_extra)), | |
fb982c25 | 6270 | VTY_NEWLINE); |
e52702f2 | 6271 | |
4bf6a362 PJ |
6272 | if ((count = attr_unknown_count())) |
6273 | vty_out (vty, "%ld unknown attributes%s", count, VTY_NEWLINE); | |
e52702f2 | 6274 | |
4bf6a362 PJ |
6275 | /* AS_PATH attributes */ |
6276 | count = aspath_count (); | |
6277 | vty_out (vty, "%ld BGP AS-PATH entries, using %s of memory%s", count, | |
6278 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6279 | count * sizeof (struct aspath)), | |
6280 | VTY_NEWLINE); | |
e52702f2 | 6281 | |
4bf6a362 PJ |
6282 | count = mtype_stats_alloc (MTYPE_AS_SEG); |
6283 | vty_out (vty, "%ld BGP AS-PATH segments, using %s of memory%s", count, | |
6284 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6285 | count * sizeof (struct assegment)), | |
6286 | VTY_NEWLINE); | |
e52702f2 | 6287 | |
4bf6a362 PJ |
6288 | /* Other attributes */ |
6289 | if ((count = community_count ())) | |
6290 | vty_out (vty, "%ld BGP community entries, using %s of memory%s", count, | |
6291 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6292 | count * sizeof (struct community)), | |
6293 | VTY_NEWLINE); | |
6294 | if ((count = mtype_stats_alloc (MTYPE_ECOMMUNITY))) | |
6295 | vty_out (vty, "%ld BGP community entries, using %s of memory%s", count, | |
6296 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6297 | count * sizeof (struct ecommunity)), | |
6298 | VTY_NEWLINE); | |
57d187bc JS |
6299 | if ((count = mtype_stats_alloc (MTYPE_LCOMMUNITY))) |
6300 | vty_out (vty, "%ld BGP large-community entries, using %s of memory%s", | |
2acb4ac2 | 6301 | count, |
57d187bc JS |
6302 | mtype_memstr (memstrbuf, sizeof (memstrbuf), |
6303 | count * sizeof (struct lcommunity)), | |
6304 | VTY_NEWLINE); | |
e52702f2 | 6305 | |
4bf6a362 PJ |
6306 | if ((count = mtype_stats_alloc (MTYPE_CLUSTER))) |
6307 | vty_out (vty, "%ld Cluster lists, using %s of memory%s", count, | |
6308 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6309 | count * sizeof (struct cluster_list)), | |
6310 | VTY_NEWLINE); | |
e52702f2 | 6311 | |
4bf6a362 PJ |
6312 | /* Peer related usage */ |
6313 | count = mtype_stats_alloc (MTYPE_BGP_PEER); | |
6314 | vty_out (vty, "%ld peers, using %s of memory%s", count, | |
6315 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6316 | count * sizeof (struct peer)), | |
6317 | VTY_NEWLINE); | |
e52702f2 | 6318 | |
4a1ab8e4 | 6319 | if ((count = mtype_stats_alloc (MTYPE_PEER_GROUP))) |
4bf6a362 PJ |
6320 | vty_out (vty, "%ld peer groups, using %s of memory%s", count, |
6321 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6322 | count * sizeof (struct peer_group)), | |
6323 | VTY_NEWLINE); | |
e52702f2 | 6324 | |
4bf6a362 PJ |
6325 | /* Other */ |
6326 | if ((count = mtype_stats_alloc (MTYPE_HASH))) | |
6327 | vty_out (vty, "%ld hash tables, using %s of memory%s", count, | |
6328 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6329 | count * sizeof (struct hash)), | |
6330 | VTY_NEWLINE); | |
6331 | if ((count = mtype_stats_alloc (MTYPE_HASH_BACKET))) | |
6332 | vty_out (vty, "%ld hash buckets, using %s of memory%s", count, | |
6333 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6334 | count * sizeof (struct hash_backet)), | |
6335 | VTY_NEWLINE); | |
6336 | if ((count = mtype_stats_alloc (MTYPE_BGP_REGEXP))) | |
6337 | vty_out (vty, "%ld compiled regexes, using %s of memory%s", count, | |
6338 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6339 | count * sizeof (regex_t)), | |
6340 | VTY_NEWLINE); | |
6341 | return CMD_SUCCESS; | |
6342 | } | |
fee0f4c6 | 6343 | |
718e3744 | 6344 | /* Show BGP peer's summary information. */ |
94f2b392 | 6345 | static int |
b05a1c8b | 6346 | bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi, |
9f689658 | 6347 | u_char use_json, json_object *json) |
718e3744 | 6348 | { |
6349 | struct peer *peer; | |
1eb8ef25 | 6350 | struct listnode *node, *nnode; |
f14e6fdb DS |
6351 | unsigned int count = 0, dn_count = 0; |
6352 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
f933309e DW |
6353 | char neighbor_buf[VTY_BUFSIZ]; |
6354 | int neighbor_col_default_width = 16; | |
718e3744 | 6355 | int len; |
f933309e | 6356 | int max_neighbor_width = 0; |
ffd0c037 DS |
6357 | json_object *json_peer = NULL; |
6358 | json_object *json_peers = NULL; | |
718e3744 | 6359 | |
b05a1c8b DS |
6360 | if (use_json) |
6361 | { | |
9f689658 DD |
6362 | if (json == NULL) |
6363 | json = json_object_new_object(); | |
6364 | ||
f1aa5d8a | 6365 | json_peers = json_object_new_object(); |
b05a1c8b | 6366 | } |
f933309e DW |
6367 | else |
6368 | { | |
6369 | /* Loop over all neighbors that will be displayed to determine how many | |
6370 | * characters are needed for the Neighbor column | |
6371 | */ | |
6372 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
6373 | { | |
6374 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6375 | continue; | |
6376 | ||
6377 | if (peer->afc[afi][safi]) | |
6378 | { | |
c9d5bd27 DS |
6379 | memset(dn_flag, '\0', sizeof(dn_flag)); |
6380 | if (peer_dynamic_neighbor(peer)) | |
6381 | dn_flag[0] = '*'; | |
6382 | ||
f933309e DW |
6383 | if (peer->hostname && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) |
6384 | sprintf(neighbor_buf, "%s%s(%s) ", dn_flag, peer->hostname, peer->host); | |
6385 | else | |
6386 | sprintf(neighbor_buf, "%s%s ", dn_flag, peer->host); | |
6387 | ||
6388 | len = strlen(neighbor_buf); | |
6389 | ||
6390 | if (len > max_neighbor_width) | |
6391 | max_neighbor_width = len; | |
6392 | } | |
6393 | } | |
6394 | ||
6395 | /* Originally we displayed the Neighbor column as 16 | |
6396 | * characters wide so make that the default | |
6397 | */ | |
6398 | if (max_neighbor_width < neighbor_col_default_width) | |
6399 | max_neighbor_width = neighbor_col_default_width; | |
6400 | } | |
b05a1c8b | 6401 | |
1eb8ef25 | 6402 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
718e3744 | 6403 | { |
1ff9a340 DS |
6404 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
6405 | continue; | |
6406 | ||
718e3744 | 6407 | if (peer->afc[afi][safi]) |
6408 | { | |
b05a1c8b | 6409 | if (!count) |
4bf6a362 PJ |
6410 | { |
6411 | unsigned long ents; | |
6412 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
5c81a5f3 | 6413 | int vrf_id_ui; |
6414 | ||
6415 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id; | |
b05a1c8b | 6416 | |
4bf6a362 | 6417 | /* Usage summary and header */ |
b05a1c8b DS |
6418 | if (use_json) |
6419 | { | |
62d6dca0 | 6420 | json_object_string_add(json, "routerId", inet_ntoa (bgp->router_id)); |
f1aa5d8a | 6421 | json_object_int_add(json, "as", bgp->as); |
9f689658 DD |
6422 | json_object_int_add(json, "vrfId", vrf_id_ui); |
6423 | json_object_string_add(json, "vrfName", | |
6424 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
6425 | ? "Default" : bgp->name); | |
b05a1c8b DS |
6426 | } |
6427 | else | |
6428 | { | |
6429 | vty_out (vty, | |
5c81a5f3 | 6430 | "BGP router identifier %s, local AS number %u vrf-id %d", |
6431 | inet_ntoa (bgp->router_id), bgp->as, vrf_id_ui); | |
6aeb9e78 | 6432 | vty_out (vty, "%s", VTY_NEWLINE); |
b05a1c8b DS |
6433 | } |
6434 | ||
f188f2c4 DS |
6435 | if (bgp_update_delay_configured(bgp)) |
6436 | { | |
b05a1c8b | 6437 | if (use_json) |
f188f2c4 | 6438 | { |
62d6dca0 | 6439 | json_object_int_add(json, "updateDelayLimit", bgp->v_update_delay); |
b05a1c8b DS |
6440 | |
6441 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
62d6dca0 | 6442 | json_object_int_add(json, "updateDelayEstablishWait", bgp->v_establish_wait); |
b05a1c8b DS |
6443 | |
6444 | if (bgp_update_delay_active(bgp)) | |
6445 | { | |
62d6dca0 DS |
6446 | json_object_string_add(json, "updateDelayFirstNeighbor", bgp->update_delay_begin_time); |
6447 | json_object_boolean_true_add(json, "updateDelayInProgress"); | |
b05a1c8b DS |
6448 | } |
6449 | else | |
6450 | { | |
6451 | if (bgp->update_delay_over) | |
6452 | { | |
62d6dca0 | 6453 | json_object_string_add(json, "updateDelayFirstNeighbor", |
f1aa5d8a | 6454 | bgp->update_delay_begin_time); |
62d6dca0 | 6455 | json_object_string_add(json, "updateDelayBestpathResumed", |
f1aa5d8a | 6456 | bgp->update_delay_end_time); |
62d6dca0 | 6457 | json_object_string_add(json, "updateDelayZebraUpdateResume", |
f1aa5d8a | 6458 | bgp->update_delay_zebra_resume_time); |
62d6dca0 | 6459 | json_object_string_add(json, "updateDelayPeerUpdateResume", |
f1aa5d8a | 6460 | bgp->update_delay_peers_resume_time); |
b05a1c8b DS |
6461 | } |
6462 | } | |
f188f2c4 DS |
6463 | } |
6464 | else | |
6465 | { | |
b05a1c8b DS |
6466 | vty_out (vty, "Read-only mode update-delay limit: %d seconds%s", |
6467 | bgp->v_update_delay, VTY_NEWLINE); | |
6468 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
6469 | vty_out (vty, " Establish wait: %d seconds%s", | |
6470 | bgp->v_establish_wait, VTY_NEWLINE); | |
6471 | ||
6472 | if (bgp_update_delay_active(bgp)) | |
f188f2c4 DS |
6473 | { |
6474 | vty_out (vty, " First neighbor established: %s%s", | |
6475 | bgp->update_delay_begin_time, VTY_NEWLINE); | |
b05a1c8b DS |
6476 | vty_out (vty, " Delay in progress%s", VTY_NEWLINE); |
6477 | } | |
6478 | else | |
6479 | { | |
6480 | if (bgp->update_delay_over) | |
6481 | { | |
6482 | vty_out (vty, " First neighbor established: %s%s", | |
6483 | bgp->update_delay_begin_time, VTY_NEWLINE); | |
6484 | vty_out (vty, " Best-paths resumed: %s%s", | |
6485 | bgp->update_delay_end_time, VTY_NEWLINE); | |
6486 | vty_out (vty, " zebra update resumed: %s%s", | |
6487 | bgp->update_delay_zebra_resume_time, VTY_NEWLINE); | |
6488 | vty_out (vty, " peers update resumed: %s%s", | |
6489 | bgp->update_delay_peers_resume_time, VTY_NEWLINE); | |
6490 | } | |
f188f2c4 DS |
6491 | } |
6492 | } | |
6493 | } | |
4bf6a362 | 6494 | |
b05a1c8b DS |
6495 | if (use_json) |
6496 | { | |
6497 | if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active) | |
62d6dca0 | 6498 | json_object_boolean_true_add(json, "maxMedOnStartup"); |
b05a1c8b | 6499 | if (bgp->v_maxmed_admin) |
62d6dca0 | 6500 | json_object_boolean_true_add(json, "maxMedAdministrative"); |
b05a1c8b | 6501 | |
62d6dca0 | 6502 | json_object_int_add(json, "tableVersion", bgp_table_version(bgp->rib[afi][safi])); |
b05a1c8b DS |
6503 | |
6504 | ents = bgp_table_count (bgp->rib[afi][safi]); | |
62d6dca0 DS |
6505 | json_object_int_add(json, "ribCount", ents); |
6506 | json_object_int_add(json, "ribMemory", ents * sizeof (struct bgp_node)); | |
b05a1c8b DS |
6507 | |
6508 | ents = listcount (bgp->peer); | |
62d6dca0 DS |
6509 | json_object_int_add(json, "peerCount", ents); |
6510 | json_object_int_add(json, "peerMemory", ents * sizeof (struct peer)); | |
b05a1c8b | 6511 | |
b05a1c8b DS |
6512 | if ((ents = listcount (bgp->group))) |
6513 | { | |
62d6dca0 DS |
6514 | json_object_int_add(json, "peerGroupCount", ents); |
6515 | json_object_int_add(json, "peerGroupMemory", ents * sizeof (struct peer_group)); | |
b05a1c8b | 6516 | } |
3f9c7369 | 6517 | |
b05a1c8b | 6518 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) |
62d6dca0 | 6519 | json_object_boolean_true_add(json, "dampeningEnabled"); |
b05a1c8b DS |
6520 | } |
6521 | else | |
6522 | { | |
6523 | if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active) | |
6524 | vty_out (vty, "Max-med on-startup active%s", VTY_NEWLINE); | |
6525 | if (bgp->v_maxmed_admin) | |
6526 | vty_out (vty, "Max-med administrative active%s", VTY_NEWLINE); | |
6527 | ||
ffd0c037 | 6528 | vty_out(vty, "BGP table version %" PRIu64 "%s", |
b05a1c8b DS |
6529 | bgp_table_version(bgp->rib[afi][safi]), VTY_NEWLINE); |
6530 | ||
6531 | ents = bgp_table_count (bgp->rib[afi][safi]); | |
6532 | vty_out (vty, "RIB entries %ld, using %s of memory%s", ents, | |
6533 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6534 | ents * sizeof (struct bgp_node)), | |
6535 | VTY_NEWLINE); | |
6536 | ||
6537 | /* Peer related usage */ | |
6538 | ents = listcount (bgp->peer); | |
6539 | vty_out (vty, "Peers %ld, using %s of memory%s", | |
6540 | ents, | |
6541 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6542 | ents * sizeof (struct peer)), | |
6543 | VTY_NEWLINE); | |
6544 | ||
b05a1c8b DS |
6545 | if ((ents = listcount (bgp->group))) |
6546 | vty_out (vty, "Peer groups %ld, using %s of memory%s", ents, | |
6547 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6548 | ents * sizeof (struct peer_group)), | |
6549 | VTY_NEWLINE); | |
6550 | ||
6551 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) | |
6552 | vty_out (vty, "Dampening enabled.%s", VTY_NEWLINE); | |
6553 | vty_out (vty, "%s", VTY_NEWLINE); | |
f933309e DW |
6554 | |
6555 | /* Subtract 8 here because 'Neighbor' is 8 characters */ | |
6556 | vty_out (vty, "Neighbor"); | |
6557 | vty_out (vty, "%*s", max_neighbor_width - 8, " "); | |
6558 | vty_out (vty, "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd%s", VTY_NEWLINE); | |
b05a1c8b | 6559 | } |
4bf6a362 | 6560 | } |
e52702f2 | 6561 | |
b05a1c8b | 6562 | count++; |
718e3744 | 6563 | |
b05a1c8b DS |
6564 | if (use_json) |
6565 | { | |
6566 | json_peer = json_object_new_object(); | |
f14e6fdb | 6567 | |
b05a1c8b | 6568 | if (peer_dynamic_neighbor(peer)) |
62d6dca0 | 6569 | json_object_boolean_true_add(json_peer, "dynamicPeer"); |
b05a1c8b | 6570 | |
04b6bdc0 DW |
6571 | if (peer->hostname) |
6572 | json_object_string_add(json_peer, "hostname", peer->hostname); | |
6573 | ||
6574 | if (peer->domainname) | |
6575 | json_object_string_add(json_peer, "domainname", peer->domainname); | |
6576 | ||
62d6dca0 | 6577 | json_object_int_add(json_peer, "remoteAs", peer->as); |
f1aa5d8a | 6578 | json_object_int_add(json_peer, "version", 4); |
62d6dca0 | 6579 | json_object_int_add(json_peer, "msgRcvd", |
f1aa5d8a DS |
6580 | peer->open_in + peer->update_in + peer->keepalive_in |
6581 | + peer->notify_in + peer->refresh_in | |
6582 | + peer->dynamic_cap_in); | |
62d6dca0 | 6583 | json_object_int_add(json_peer, "msgSent", |
f1aa5d8a DS |
6584 | peer->open_out + peer->update_out + peer->keepalive_out |
6585 | + peer->notify_out + peer->refresh_out | |
6586 | + peer->dynamic_cap_out); | |
6587 | ||
62d6dca0 | 6588 | json_object_int_add(json_peer, "tableVersion", peer->version[afi][safi]); |
f1aa5d8a DS |
6589 | json_object_int_add(json_peer, "outq", peer->obuf->count); |
6590 | json_object_int_add(json_peer, "inq", 0); | |
856ca177 | 6591 | peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, use_json, json_peer); |
62d6dca0 | 6592 | json_object_int_add(json_peer, "prefixReceivedCount", peer->pcount[afi][safi]); |
b05a1c8b DS |
6593 | |
6594 | if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) | |
f1aa5d8a | 6595 | json_object_string_add(json_peer, "state", "Idle (Admin)"); |
b05a1c8b | 6596 | else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) |
f1aa5d8a | 6597 | json_object_string_add(json_peer, "state", "Idle (PfxCt)"); |
b05a1c8b | 6598 | else |
f1aa5d8a | 6599 | json_object_string_add(json_peer, "state", LOOKUP(bgp_status_msg, peer->status)); |
b05a1c8b | 6600 | |
f1aa5d8a | 6601 | if (peer->conf_if) |
62d6dca0 | 6602 | json_object_string_add(json_peer, "idType", "interface"); |
f1aa5d8a | 6603 | else if (peer->su.sa.sa_family == AF_INET) |
62d6dca0 | 6604 | json_object_string_add(json_peer, "idType", "ipv4"); |
f1aa5d8a | 6605 | else if (peer->su.sa.sa_family == AF_INET6) |
62d6dca0 | 6606 | json_object_string_add(json_peer, "idType", "ipv6"); |
b05a1c8b | 6607 | |
f1aa5d8a | 6608 | json_object_object_add(json_peers, peer->host, json_peer); |
b05a1c8b DS |
6609 | } |
6610 | else | |
6611 | { | |
6612 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
6613 | if (peer_dynamic_neighbor(peer)) | |
6614 | { | |
6615 | dn_count++; | |
6616 | dn_flag[0] = '*'; | |
6617 | } | |
6618 | ||
04b6bdc0 DW |
6619 | if (peer->hostname && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) |
6620 | len = vty_out (vty, "%s%s(%s)", dn_flag, peer->hostname, | |
6621 | peer->host); | |
6622 | else | |
6623 | len = vty_out (vty, "%s%s", dn_flag, peer->host); | |
b05a1c8b | 6624 | |
f933309e DW |
6625 | /* pad the neighbor column with spaces */ |
6626 | if (len < max_neighbor_width) | |
6627 | vty_out (vty, "%*s", max_neighbor_width - len, " "); | |
b05a1c8b | 6628 | |
f933309e | 6629 | vty_out (vty, "4 %10u %7d %7d %8" PRIu64 " %4d %4zd %8s", |
b05a1c8b DS |
6630 | peer->as, |
6631 | peer->open_in + peer->update_in + peer->keepalive_in | |
6632 | + peer->notify_in + peer->refresh_in | |
6633 | + peer->dynamic_cap_in, | |
6634 | peer->open_out + peer->update_out + peer->keepalive_out | |
6635 | + peer->notify_out + peer->refresh_out | |
6636 | + peer->dynamic_cap_out, | |
6637 | peer->version[afi][safi], | |
6638 | 0, | |
f933309e | 6639 | peer->obuf->count, |
856ca177 | 6640 | peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL)); |
b05a1c8b DS |
6641 | |
6642 | if (peer->status == Established) | |
46f8c104 | 6643 | vty_out (vty, " %12ld", peer->pcount[afi][safi]); |
b05a1c8b DS |
6644 | else |
6645 | { | |
6646 | if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) | |
6647 | vty_out (vty, " Idle (Admin)"); | |
6648 | else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) | |
6649 | vty_out (vty, " Idle (PfxCt)"); | |
6650 | else | |
f933309e | 6651 | vty_out (vty, " %12s", LOOKUP(bgp_status_msg, peer->status)); |
b05a1c8b DS |
6652 | } |
6653 | vty_out (vty, "%s", VTY_NEWLINE); | |
6654 | } | |
718e3744 | 6655 | } |
6656 | } | |
6657 | ||
b05a1c8b DS |
6658 | if (use_json) |
6659 | { | |
6660 | json_object_object_add(json, "peers", json_peers); | |
14151a32 | 6661 | |
62d6dca0 DS |
6662 | json_object_int_add(json, "totalPeers", count); |
6663 | json_object_int_add(json, "dynamicPeers", dn_count); | |
14151a32 | 6664 | |
2aac5767 | 6665 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
f1aa5d8a | 6666 | json_object_free(json); |
b05a1c8b DS |
6667 | } |
6668 | else | |
f14e6fdb | 6669 | { |
b05a1c8b DS |
6670 | if (count) |
6671 | vty_out (vty, "%sTotal number of neighbors %d%s", VTY_NEWLINE, | |
6672 | count, VTY_NEWLINE); | |
6673 | else | |
9f689658 DD |
6674 | { |
6675 | if (use_json) | |
6676 | vty_out(vty, "{\"error\": {\"message\": \"No %s neighbor configured\"}}%s", | |
46f296b4 | 6677 | afi_safi_print(afi, safi), VTY_NEWLINE); |
9f689658 DD |
6678 | else |
6679 | vty_out (vty, "No %s neighbor is configured%s", | |
46f296b4 | 6680 | afi_safi_print(afi, safi), VTY_NEWLINE); |
9f689658 | 6681 | } |
b05a1c8b | 6682 | |
9f689658 | 6683 | if (dn_count && ! use_json) |
b05a1c8b DS |
6684 | { |
6685 | vty_out(vty, "* - dynamic neighbor%s", VTY_NEWLINE); | |
6686 | vty_out(vty, | |
6687 | "%d dynamic neighbor(s), limit %d%s", | |
6688 | dn_count, bgp->dynamic_neighbors_limit, VTY_NEWLINE); | |
6689 | } | |
f14e6fdb DS |
6690 | } |
6691 | ||
718e3744 | 6692 | return CMD_SUCCESS; |
6693 | } | |
6694 | ||
798c3572 DS |
6695 | /* |
6696 | * Return if we have a peer configured to use this afi/safi | |
6697 | */ | |
6698 | static int | |
6699 | bgp_show_summary_afi_safi_peer_exists (struct bgp *bgp, int afi, int safi) | |
6700 | { | |
6701 | struct listnode *node; | |
6702 | struct peer *peer; | |
6703 | ||
6704 | for (ALL_LIST_ELEMENTS_RO (bgp->peer, node, peer)) | |
6705 | { | |
6706 | if (!CHECK_FLAG (peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6707 | continue; | |
6708 | ||
6709 | if (peer->afc[afi][safi]) | |
6710 | return 1; | |
6711 | } | |
6712 | ||
6713 | return 0; | |
6714 | } | |
6715 | ||
27162734 LB |
6716 | static void |
6717 | bgp_show_summary_afi_safi (struct vty *vty, struct bgp *bgp, int afi, int safi, | |
6718 | u_char use_json, json_object *json) | |
6719 | { | |
6720 | int is_first = 1; | |
6721 | int afi_wildcard = (afi == AFI_MAX); | |
6722 | int safi_wildcard = (safi == SAFI_MAX); | |
6723 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
798c3572 | 6724 | |
27162734 LB |
6725 | if (use_json && is_wildcard) |
6726 | vty_out (vty, "{%s", VTY_NEWLINE); | |
6727 | if (afi_wildcard) | |
6728 | afi = 1; /* AFI_IP */ | |
6729 | while (afi < AFI_MAX) | |
6730 | { | |
6731 | if (safi_wildcard) | |
6732 | safi = 1; /* SAFI_UNICAST */ | |
6733 | while (safi < SAFI_MAX) | |
6734 | { | |
798c3572 | 6735 | if (bgp_show_summary_afi_safi_peer_exists (bgp, afi, safi)) |
27162734 | 6736 | { |
798c3572 | 6737 | if (is_wildcard) |
27162734 | 6738 | { |
798c3572 DS |
6739 | /* |
6740 | * So limit output to those afi/safi pairs that | |
6741 | * actualy have something interesting in them | |
6742 | */ | |
6743 | if (use_json) | |
6744 | { | |
6745 | json = json_object_new_object(); | |
27162734 | 6746 | |
798c3572 DS |
6747 | if (! is_first) |
6748 | vty_out (vty, ",%s", VTY_NEWLINE); | |
6749 | else | |
6750 | is_first = 0; | |
27162734 | 6751 | |
798c3572 DS |
6752 | vty_out(vty, "\"%s\":", afi_safi_json(afi, safi)); |
6753 | } | |
6754 | else | |
6755 | { | |
6756 | vty_out (vty, "%s%s Summary:%s", | |
6757 | VTY_NEWLINE, afi_safi_print(afi, safi), VTY_NEWLINE); | |
6758 | } | |
27162734 | 6759 | } |
798c3572 | 6760 | bgp_show_summary (vty, bgp, afi, safi, use_json, json); |
27162734 | 6761 | } |
f62a5c33 LB |
6762 | safi++; |
6763 | if (safi == SAFI_RESERVED_4 || | |
6764 | safi == SAFI_RESERVED_5) /* handle special cases to match zebra.h */ | |
6765 | safi++; | |
27162734 LB |
6766 | if (! safi_wildcard) |
6767 | safi = SAFI_MAX; | |
6768 | } | |
6769 | afi++; | |
6770 | if (! afi_wildcard || | |
5ef6cd69 | 6771 | afi == AFI_L2VPN) /* special case, not handled yet */ |
27162734 LB |
6772 | afi = AFI_MAX; |
6773 | } | |
6774 | ||
6775 | if (use_json && is_wildcard) | |
6776 | vty_out (vty, "}%s", VTY_NEWLINE); | |
6777 | ||
6778 | } | |
6779 | ||
f186de26 | 6780 | static void |
6781 | bgp_show_all_instances_summary_vty (struct vty *vty, afi_t afi, safi_t safi, | |
6782 | u_char use_json) | |
6783 | { | |
6784 | struct listnode *node, *nnode; | |
6785 | struct bgp *bgp; | |
9f689658 DD |
6786 | json_object *json = NULL; |
6787 | int is_first = 1; | |
6788 | ||
6789 | if (use_json) | |
6790 | vty_out (vty, "{%s", VTY_NEWLINE); | |
f186de26 | 6791 | |
6792 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) | |
6793 | { | |
9f689658 DD |
6794 | if (use_json) |
6795 | { | |
4fb25c53 | 6796 | json = json_object_new_object(); |
9f689658 DD |
6797 | |
6798 | if (! is_first) | |
6799 | vty_out (vty, ",%s", VTY_NEWLINE); | |
6800 | else | |
6801 | is_first = 0; | |
6802 | ||
6803 | vty_out(vty, "\"%s\":", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
6804 | ? "Default" : bgp->name); | |
6805 | } | |
6806 | else | |
6807 | { | |
6808 | vty_out (vty, "%sInstance %s:%s", | |
6809 | VTY_NEWLINE, | |
6810 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
6811 | ? "Default" : bgp->name, VTY_NEWLINE); | |
6812 | } | |
27162734 | 6813 | bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, json); |
f186de26 | 6814 | } |
9f689658 DD |
6815 | |
6816 | if (use_json) | |
6817 | vty_out (vty, "}%s", VTY_NEWLINE); | |
6818 | ||
f186de26 | 6819 | } |
6820 | ||
4fb25c53 DW |
6821 | static int |
6822 | bgp_show_summary_vty (struct vty *vty, const char *name, | |
6823 | afi_t afi, safi_t safi, u_char use_json) | |
6824 | { | |
6825 | struct bgp *bgp; | |
6826 | ||
6827 | if (name) | |
6828 | { | |
6829 | if (strmatch(name, "all")) | |
6830 | { | |
6831 | bgp_show_all_instances_summary_vty (vty, afi, safi, use_json); | |
6832 | return CMD_SUCCESS; | |
6833 | } | |
6834 | else | |
6835 | { | |
6836 | bgp = bgp_lookup_by_name (name); | |
6837 | ||
6838 | if (! bgp) | |
6839 | { | |
6840 | if (use_json) | |
6841 | vty_out (vty, "{}%s", VTY_NEWLINE); | |
6842 | else | |
6843 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
6844 | return CMD_WARNING; | |
6845 | } | |
6846 | ||
27162734 | 6847 | bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, NULL); |
4fb25c53 DW |
6848 | return CMD_SUCCESS; |
6849 | } | |
6850 | } | |
6851 | ||
6852 | bgp = bgp_get_default (); | |
6853 | ||
6854 | if (bgp) | |
27162734 | 6855 | bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, NULL); |
4fb25c53 DW |
6856 | |
6857 | return CMD_SUCCESS; | |
6858 | } | |
6859 | ||
716b2d8a | 6860 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 6861 | DEFUN (show_ip_bgp_summary, |
718e3744 | 6862 | show_ip_bgp_summary_cmd, |
46f296b4 | 6863 | "show [ip] bgp [<view|vrf> WORD] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] summary [json]", |
718e3744 | 6864 | SHOW_STR |
6865 | IP_STR | |
6866 | BGP_STR | |
8386ac43 | 6867 | BGP_INSTANCE_HELP_STR |
46f296b4 LB |
6868 | BGP_AFI_HELP_STR |
6869 | BGP_SAFI_HELP_STR | |
b05a1c8b | 6870 | "Summary of BGP neighbor status\n" |
9973d184 | 6871 | JSON_STR) |
718e3744 | 6872 | { |
74ca3d33 | 6873 | char *vrf = NULL; |
27162734 LB |
6874 | afi_t afi = AFI_MAX; |
6875 | safi_t safi = SAFI_MAX; | |
ae19d7dd QY |
6876 | |
6877 | int idx = 0; | |
6878 | ||
6879 | /* show [ip] bgp */ | |
6880 | if (argv_find (argv, argc, "ip", &idx)) | |
6881 | afi = AFI_IP; | |
6882 | /* [<view|vrf> WORD] */ | |
6883 | if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) | |
6884 | vrf = argv[++idx]->arg; | |
46f296b4 LB |
6885 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
6886 | if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) | |
ae19d7dd | 6887 | { |
46f296b4 | 6888 | argv_find_and_parse_safi (argv, argc, &idx, &safi); |
91d37724 QY |
6889 | } |
6890 | ||
ae19d7dd | 6891 | int uj = use_json (argc, argv); |
74ca3d33 DW |
6892 | |
6893 | return bgp_show_summary_vty (vty, vrf, afi, safi, uj); | |
718e3744 | 6894 | } |
6895 | ||
fd79ac91 | 6896 | const char * |
538621f2 | 6897 | afi_safi_print (afi_t afi, safi_t safi) |
6898 | { | |
6899 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
6900 | return "IPv4 Unicast"; | |
6901 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
6902 | return "IPv4 Multicast"; | |
6903 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
46f296b4 | 6904 | return "IPv4 VPN"; |
8b1fb8be | 6905 | else if (afi == AFI_IP && safi == SAFI_ENCAP) |
46f296b4 | 6906 | return "IPv4 Encap"; |
538621f2 | 6907 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
6908 | return "IPv6 Unicast"; | |
6909 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
6910 | return "IPv6 Multicast"; | |
945c8fe9 | 6911 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) |
46f296b4 | 6912 | return "IPv6 VPN"; |
8b1fb8be | 6913 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) |
46f296b4 | 6914 | return "IPv6 Encap"; |
3d6c0dfa PG |
6915 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) |
6916 | return "L2VPN EVPN"; | |
538621f2 | 6917 | else |
6918 | return "Unknown"; | |
6919 | } | |
6920 | ||
27162734 LB |
6921 | const char * |
6922 | afi_safi_json (afi_t afi, safi_t safi) | |
6923 | { | |
6924 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
6925 | return "IPv4Unicast"; | |
6926 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
6927 | return "IPv4Multicast"; | |
6928 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
6929 | return "IPv4VPN"; | |
6930 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
6931 | return "IPv4Encap"; | |
6932 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
6933 | return "IPv6Unicast"; | |
6934 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
6935 | return "IPv6Multicast"; | |
6936 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
6937 | return "IPv6VPN"; | |
6938 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
6939 | return "IPv6Encap"; | |
3d6c0dfa PG |
6940 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) |
6941 | return "L2VPN EVPN"; | |
27162734 LB |
6942 | else |
6943 | return "Unknown"; | |
6944 | } | |
6945 | ||
718e3744 | 6946 | /* Show BGP peer's information. */ |
6947 | enum show_type | |
6948 | { | |
6949 | show_all, | |
6950 | show_peer | |
6951 | }; | |
6952 | ||
94f2b392 | 6953 | static void |
856ca177 MS |
6954 | bgp_show_peer_afi_orf_cap (struct vty *vty, struct peer *p, afi_t afi, safi_t safi, |
6955 | u_int16_t adv_smcap, u_int16_t adv_rmcap, u_int16_t rcv_smcap, | |
6956 | u_int16_t rcv_rmcap, u_char use_json, json_object *json_pref) | |
718e3744 | 6957 | { |
6958 | /* Send-Mode */ | |
6959 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) | |
6960 | || CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
6961 | { | |
856ca177 MS |
6962 | if (use_json) |
6963 | { | |
6964 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
6965 | json_object_string_add(json_pref, "sendMode", "advertisedAndReceived"); | |
6966 | else if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)) | |
6967 | json_object_string_add(json_pref, "sendMode", "advertised"); | |
6968 | else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
6969 | json_object_string_add(json_pref, "sendMode", "received"); | |
6970 | } | |
6971 | else | |
6972 | { | |
6973 | vty_out (vty, " Send-mode: "); | |
6974 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)) | |
6975 | vty_out (vty, "advertised"); | |
6976 | if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
6977 | vty_out (vty, "%sreceived", | |
6978 | CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) ? | |
6979 | ", " : ""); | |
6980 | vty_out (vty, "%s", VTY_NEWLINE); | |
6981 | } | |
718e3744 | 6982 | } |
6983 | ||
6984 | /* Receive-Mode */ | |
6985 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) | |
6986 | || CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
6987 | { | |
856ca177 MS |
6988 | if (use_json) |
6989 | { | |
6990 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
6991 | json_object_string_add(json_pref, "recvMode", "advertisedAndReceived"); | |
6992 | else if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)) | |
6993 | json_object_string_add(json_pref, "recvMode", "advertised"); | |
6994 | else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
6995 | json_object_string_add(json_pref, "recvMode", "received"); | |
6996 | } | |
6997 | else | |
6998 | { | |
6999 | vty_out (vty, " Receive-mode: "); | |
7000 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)) | |
7001 | vty_out (vty, "advertised"); | |
7002 | if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
7003 | vty_out (vty, "%sreceived", | |
7004 | CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) ? | |
7005 | ", " : ""); | |
7006 | vty_out (vty, "%s", VTY_NEWLINE); | |
7007 | } | |
718e3744 | 7008 | } |
7009 | } | |
7010 | ||
94f2b392 | 7011 | static void |
856ca177 MS |
7012 | bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi, |
7013 | u_char use_json, json_object *json_neigh) | |
718e3744 | 7014 | { |
7015 | struct bgp_filter *filter; | |
3f9c7369 | 7016 | struct peer_af *paf; |
718e3744 | 7017 | char orf_pfx_name[BUFSIZ]; |
7018 | int orf_pfx_count; | |
856ca177 MS |
7019 | json_object *json_af = NULL; |
7020 | json_object *json_prefA = NULL; | |
7021 | json_object *json_prefB = NULL; | |
7022 | json_object *json_addr = NULL; | |
718e3744 | 7023 | |
856ca177 MS |
7024 | if (use_json) |
7025 | { | |
7026 | json_addr = json_object_new_object(); | |
7027 | json_af = json_object_new_object(); | |
856ca177 | 7028 | filter = &p->filter[afi][safi]; |
718e3744 | 7029 | |
c8560b44 | 7030 | if (peer_group_active(p)) |
856ca177 | 7031 | json_object_string_add(json_addr, "peerGroupMember", p->group->name); |
538621f2 | 7032 | |
856ca177 MS |
7033 | paf = peer_af_find(p, afi, safi); |
7034 | if (paf && PAF_SUBGRP(paf)) | |
7035 | { | |
7036 | json_object_int_add(json_addr, "updateGroupId", PAF_UPDGRP(paf)->id); | |
7037 | json_object_int_add(json_addr, "subGroupId", PAF_SUBGRP(paf)->id); | |
7038 | json_object_int_add(json_addr, "packetQueueLength", bpacket_queue_virtual_length(paf)); | |
7039 | } | |
7040 | ||
7041 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7042 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
7043 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7044 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)) | |
7045 | { | |
7046 | json_object_int_add(json_af, "orfType", ORF_TYPE_PREFIX); | |
b6df4090 | 7047 | json_prefA = json_object_new_object(); |
856ca177 MS |
7048 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, |
7049 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
7050 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7051 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
7052 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, json_prefA); | |
7053 | json_object_object_add(json_af, "orfPrefixList", json_prefA); | |
7054 | } | |
7055 | ||
7056 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7057 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7058 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7059 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7060 | { | |
7061 | json_object_int_add(json_af, "orfOldType", ORF_TYPE_PREFIX_OLD); | |
b6df4090 | 7062 | json_prefB = json_object_new_object(); |
856ca177 MS |
7063 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, |
7064 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
7065 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7066 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
7067 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, json_prefB); | |
7068 | json_object_object_add(json_af, "orfOldPrefixList", json_prefB); | |
7069 | } | |
7070 | ||
7071 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7072 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
7073 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7074 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7075 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV) | |
7076 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7077 | json_object_object_add(json_addr, "afDependentCap", json_af); | |
b6df4090 DS |
7078 | else |
7079 | json_object_free(json_af); | |
856ca177 MS |
7080 | |
7081 | sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
7082 | orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json); | |
7083 | ||
7084 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND) | |
7085 | || orf_pfx_count) | |
7086 | { | |
7087 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)) | |
7088 | json_object_boolean_true_add(json_neigh, "orfSent"); | |
7089 | if (orf_pfx_count) | |
7090 | json_object_int_add(json_addr, "orfRecvCounter", orf_pfx_count); | |
7091 | } | |
7092 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) | |
7093 | json_object_string_add(json_addr, "orfFirstUpdate", "deferredUntilORFOrRouteRefreshRecvd"); | |
7094 | ||
7095 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) | |
7096 | json_object_boolean_true_add(json_addr, "routeReflectorClient"); | |
7097 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
7098 | json_object_boolean_true_add(json_addr, "routeServerClient"); | |
7099 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
7100 | json_object_boolean_true_add(json_addr, "inboundSoftConfigPermit"); | |
7101 | ||
88b8ed8d DW |
7102 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) |
7103 | json_object_boolean_true_add(json_addr, "privateAsNumsAllReplacedInUpdatesToNbr"); | |
7104 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
856ca177 | 7105 | json_object_boolean_true_add(json_addr, "privateAsNumsReplacedInUpdatesToNbr"); |
88b8ed8d DW |
7106 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) |
7107 | json_object_boolean_true_add(json_addr, "privateAsNumsAllRemovedInUpdatesToNbr"); | |
856ca177 MS |
7108 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS)) |
7109 | json_object_boolean_true_add(json_addr, "privateAsNumsRemovedInUpdatesToNbr"); | |
7110 | ||
adbac85e DW |
7111 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS)) |
7112 | json_object_boolean_true_add(json_addr, "addpathTxAllPaths"); | |
7113 | ||
06370dac DW |
7114 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) |
7115 | json_object_boolean_true_add(json_addr, "addpathTxBestpathPerAS"); | |
7116 | ||
856ca177 MS |
7117 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) |
7118 | json_object_string_add(json_addr, "overrideASNsInOutboundUpdates", "ifAspathEqualRemoteAs"); | |
7119 | ||
7120 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) || | |
7121 | CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
7122 | json_object_boolean_true_add(json_addr, "routerAlwaysNextHop"); | |
7123 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED)) | |
7124 | json_object_boolean_true_add(json_addr, "unchangedAsPathPropogatedToNbr"); | |
7125 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)) | |
7126 | json_object_boolean_true_add(json_addr, "unchangedNextHopPropogatedToNbr"); | |
7127 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
7128 | json_object_boolean_true_add(json_addr, "unchangedMedPropogatedToNbr"); | |
718e3744 | 7129 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) |
856ca177 MS |
7130 | || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) |
7131 | { | |
7132 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
7133 | && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7134 | json_object_string_add(json_addr, "commAttriSentToNbr", "extendedAndStandard"); | |
7135 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7136 | json_object_string_add(json_addr, "commAttriSentToNbr", "extended"); | |
7137 | else | |
7138 | json_object_string_add(json_addr, "commAttriSentToNbr", "standard"); | |
7139 | } | |
7140 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) | |
7141 | { | |
7142 | if (p->default_rmap[afi][safi].name) | |
7143 | json_object_string_add(json_addr, "defaultRouteMap", p->default_rmap[afi][safi].name); | |
7144 | ||
7145 | if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
7146 | json_object_boolean_true_add(json_addr, "defaultSent"); | |
7147 | else | |
7148 | json_object_boolean_true_add(json_addr, "defaultNotSent"); | |
7149 | } | |
7150 | ||
7151 | if (filter->plist[FILTER_IN].name | |
7152 | || filter->dlist[FILTER_IN].name | |
7153 | || filter->aslist[FILTER_IN].name | |
7154 | || filter->map[RMAP_IN].name) | |
7155 | json_object_boolean_true_add(json_addr, "inboundPathPolicyConfig"); | |
7156 | if (filter->plist[FILTER_OUT].name | |
7157 | || filter->dlist[FILTER_OUT].name | |
7158 | || filter->aslist[FILTER_OUT].name | |
7159 | || filter->map[RMAP_OUT].name | |
7160 | || filter->usmap.name) | |
7161 | json_object_boolean_true_add(json_addr, "outboundPathPolicyConfig"); | |
856ca177 MS |
7162 | |
7163 | /* prefix-list */ | |
7164 | if (filter->plist[FILTER_IN].name) | |
7165 | json_object_string_add(json_addr, "incomingUpdatePrefixFilterList", filter->plist[FILTER_IN].name); | |
7166 | if (filter->plist[FILTER_OUT].name) | |
7167 | json_object_string_add(json_addr, "outgoingUpdatePrefixFilterList", filter->plist[FILTER_OUT].name); | |
7168 | ||
7169 | /* distribute-list */ | |
7170 | if (filter->dlist[FILTER_IN].name) | |
7171 | json_object_string_add(json_addr, "incomingUpdateNetworkFilterList", filter->dlist[FILTER_IN].name); | |
7172 | if (filter->dlist[FILTER_OUT].name) | |
7173 | json_object_string_add(json_addr, "outgoingUpdateNetworkFilterList", filter->dlist[FILTER_OUT].name); | |
7174 | ||
7175 | /* filter-list. */ | |
7176 | if (filter->aslist[FILTER_IN].name) | |
7177 | json_object_string_add(json_addr, "incomingUpdateAsPathFilterList", filter->aslist[FILTER_IN].name); | |
7178 | if (filter->aslist[FILTER_OUT].name) | |
7179 | json_object_string_add(json_addr, "outgoingUpdateAsPathFilterList", filter->aslist[FILTER_OUT].name); | |
7180 | ||
7181 | /* route-map. */ | |
7182 | if (filter->map[RMAP_IN].name) | |
7183 | json_object_string_add(json_addr, "routeMapForIncomingAdvertisements", filter->map[RMAP_IN].name); | |
7184 | if (filter->map[RMAP_OUT].name) | |
7185 | json_object_string_add(json_addr, "routeMapForOutgoingAdvertisements", filter->map[RMAP_OUT].name); | |
856ca177 MS |
7186 | |
7187 | /* unsuppress-map */ | |
7188 | if (filter->usmap.name) | |
7189 | json_object_string_add(json_addr, "selectiveUnsuppressRouteMap", filter->usmap.name); | |
7190 | ||
7191 | /* Receive prefix count */ | |
7192 | json_object_int_add(json_addr, "acceptedPrefixCounter", p->pcount[afi][safi]); | |
7193 | ||
7194 | /* Maximum prefix */ | |
7195 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) | |
7196 | { | |
7197 | json_object_int_add(json_addr, "prefixAllowedMax", p->pmax[afi][safi]); | |
7198 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) | |
7199 | json_object_boolean_true_add(json_addr, "prefixAllowedMaxWarning"); | |
7200 | json_object_int_add(json_addr, "prefixAllowedWarningThresh", p->pmax_threshold[afi][safi]); | |
7201 | if (p->pmax_restart[afi][safi]) | |
7202 | json_object_int_add(json_addr, "prefixAllowedRestartIntervalMsecs", p->pmax_restart[afi][safi] * 60000); | |
7203 | } | |
7204 | json_object_object_add(json_neigh, afi_safi_print (afi, safi), json_addr); | |
7205 | ||
7206 | } | |
7207 | else | |
7208 | { | |
7209 | filter = &p->filter[afi][safi]; | |
7210 | ||
7211 | vty_out (vty, " For address family: %s%s", afi_safi_print (afi, safi), | |
7212 | VTY_NEWLINE); | |
7213 | ||
c8560b44 | 7214 | if (peer_group_active(p)) |
856ca177 MS |
7215 | vty_out (vty, " %s peer-group member%s", p->group->name, VTY_NEWLINE); |
7216 | ||
7217 | paf = peer_af_find(p, afi, safi); | |
7218 | if (paf && PAF_SUBGRP(paf)) | |
7219 | { | |
7220 | vty_out (vty, " Update group %" PRIu64 ", subgroup %" PRIu64 "%s", | |
7221 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id, VTY_NEWLINE); | |
7222 | vty_out (vty, " Packet Queue length %d%s", | |
7223 | bpacket_queue_virtual_length(paf), VTY_NEWLINE); | |
7224 | } | |
718e3744 | 7225 | else |
856ca177 MS |
7226 | { |
7227 | vty_out(vty, " Not part of any update group%s", VTY_NEWLINE); | |
7228 | } | |
7229 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7230 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
7231 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7232 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7233 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV) | |
7234 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7235 | vty_out (vty, " AF-dependant capabilities:%s", VTY_NEWLINE); | |
7236 | ||
7237 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7238 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
7239 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7240 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)) | |
7241 | { | |
7242 | vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s", | |
7243 | ORF_TYPE_PREFIX, VTY_NEWLINE); | |
7244 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, | |
7245 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
7246 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7247 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
7248 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
7249 | } | |
7250 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7251 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7252 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7253 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7254 | { | |
7255 | vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s", | |
7256 | ORF_TYPE_PREFIX_OLD, VTY_NEWLINE); | |
7257 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, | |
7258 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
7259 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7260 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
7261 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
7262 | } | |
718e3744 | 7263 | |
856ca177 MS |
7264 | sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi); |
7265 | orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json); | |
718e3744 | 7266 | |
856ca177 MS |
7267 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND) |
7268 | || orf_pfx_count) | |
7269 | { | |
7270 | vty_out (vty, " Outbound Route Filter (ORF):"); | |
7271 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)) | |
7272 | vty_out (vty, " sent;"); | |
7273 | if (orf_pfx_count) | |
7274 | vty_out (vty, " received (%d entries)", orf_pfx_count); | |
7275 | vty_out (vty, "%s", VTY_NEWLINE); | |
7276 | } | |
7277 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) | |
7278 | vty_out (vty, " First update is deferred until ORF or ROUTE-REFRESH is received%s", VTY_NEWLINE); | |
7279 | ||
7280 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) | |
7281 | vty_out (vty, " Route-Reflector Client%s", VTY_NEWLINE); | |
7282 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
7283 | vty_out (vty, " Route-Server Client%s", VTY_NEWLINE); | |
7284 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
7285 | vty_out (vty, " Inbound soft reconfiguration allowed%s", VTY_NEWLINE); | |
7286 | ||
88b8ed8d DW |
7287 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) |
7288 | vty_out (vty, " Private AS numbers (all) replaced in updates to this neighbor%s", VTY_NEWLINE); | |
7289 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
856ca177 | 7290 | vty_out (vty, " Private AS numbers replaced in updates to this neighbor%s", VTY_NEWLINE); |
88b8ed8d DW |
7291 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) |
7292 | vty_out (vty, " Private AS numbers (all) removed in updates to this neighbor%s", VTY_NEWLINE); | |
856ca177 MS |
7293 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS)) |
7294 | vty_out (vty, " Private AS numbers removed in updates to this neighbor%s", VTY_NEWLINE); | |
7295 | ||
adbac85e DW |
7296 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS)) |
7297 | vty_out (vty, " Advertise all paths via addpath%s", VTY_NEWLINE); | |
7298 | ||
06370dac DW |
7299 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) |
7300 | vty_out (vty, " Advertise bestpath per AS via addpath%s", VTY_NEWLINE); | |
7301 | ||
856ca177 MS |
7302 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) |
7303 | vty_out (vty, " Override ASNs in outbound updates if aspath equals remote-as%s", VTY_NEWLINE); | |
7304 | ||
7305 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) || | |
7306 | CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
7307 | vty_out (vty, " NEXT_HOP is always this router%s", VTY_NEWLINE); | |
7308 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED)) | |
7309 | vty_out (vty, " AS_PATH is propagated unchanged to this neighbor%s", VTY_NEWLINE); | |
7310 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)) | |
7311 | vty_out (vty, " NEXT_HOP is propagated unchanged to this neighbor%s", VTY_NEWLINE); | |
7312 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
7313 | vty_out (vty, " MED is propagated unchanged to this neighbor%s", VTY_NEWLINE); | |
7314 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
57d187bc JS |
7315 | || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY) |
7316 | || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
856ca177 MS |
7317 | { |
7318 | vty_out (vty, " Community attribute sent to this neighbor"); | |
7319 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
57d187bc JS |
7320 | && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY) |
7321 | && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
7322 | vty_out (vty, "(all)%s", VTY_NEWLINE); | |
7323 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
7324 | vty_out (vty, "(large)%s", VTY_NEWLINE); | |
856ca177 MS |
7325 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) |
7326 | vty_out (vty, "(extended)%s", VTY_NEWLINE); | |
7327 | else | |
7328 | vty_out (vty, "(standard)%s", VTY_NEWLINE); | |
7329 | } | |
7330 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) | |
7331 | { | |
7332 | vty_out (vty, " Default information originate,"); | |
7333 | ||
7334 | if (p->default_rmap[afi][safi].name) | |
7335 | vty_out (vty, " default route-map %s%s,", | |
7336 | p->default_rmap[afi][safi].map ? "*" : "", | |
7337 | p->default_rmap[afi][safi].name); | |
7338 | if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
7339 | vty_out (vty, " default sent%s", VTY_NEWLINE); | |
7340 | else | |
7341 | vty_out (vty, " default not sent%s", VTY_NEWLINE); | |
7342 | } | |
718e3744 | 7343 | |
856ca177 MS |
7344 | if (filter->plist[FILTER_IN].name |
7345 | || filter->dlist[FILTER_IN].name | |
7346 | || filter->aslist[FILTER_IN].name | |
7347 | || filter->map[RMAP_IN].name) | |
7348 | vty_out (vty, " Inbound path policy configured%s", VTY_NEWLINE); | |
7349 | if (filter->plist[FILTER_OUT].name | |
7350 | || filter->dlist[FILTER_OUT].name | |
7351 | || filter->aslist[FILTER_OUT].name | |
7352 | || filter->map[RMAP_OUT].name | |
7353 | || filter->usmap.name) | |
7354 | vty_out (vty, " Outbound path policy configured%s", VTY_NEWLINE); | |
856ca177 MS |
7355 | |
7356 | /* prefix-list */ | |
7357 | if (filter->plist[FILTER_IN].name) | |
7358 | vty_out (vty, " Incoming update prefix filter list is %s%s%s", | |
7359 | filter->plist[FILTER_IN].plist ? "*" : "", | |
7360 | filter->plist[FILTER_IN].name, | |
7361 | VTY_NEWLINE); | |
7362 | if (filter->plist[FILTER_OUT].name) | |
7363 | vty_out (vty, " Outgoing update prefix filter list is %s%s%s", | |
7364 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
7365 | filter->plist[FILTER_OUT].name, | |
7366 | VTY_NEWLINE); | |
7367 | ||
7368 | /* distribute-list */ | |
7369 | if (filter->dlist[FILTER_IN].name) | |
7370 | vty_out (vty, " Incoming update network filter list is %s%s%s", | |
7371 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
7372 | filter->dlist[FILTER_IN].name, | |
7373 | VTY_NEWLINE); | |
7374 | if (filter->dlist[FILTER_OUT].name) | |
7375 | vty_out (vty, " Outgoing update network filter list is %s%s%s", | |
7376 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
7377 | filter->dlist[FILTER_OUT].name, | |
7378 | VTY_NEWLINE); | |
7379 | ||
7380 | /* filter-list. */ | |
7381 | if (filter->aslist[FILTER_IN].name) | |
7382 | vty_out (vty, " Incoming update AS path filter list is %s%s%s", | |
7383 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
7384 | filter->aslist[FILTER_IN].name, | |
7385 | VTY_NEWLINE); | |
7386 | if (filter->aslist[FILTER_OUT].name) | |
7387 | vty_out (vty, " Outgoing update AS path filter list is %s%s%s", | |
7388 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
7389 | filter->aslist[FILTER_OUT].name, | |
7390 | VTY_NEWLINE); | |
7391 | ||
7392 | /* route-map. */ | |
7393 | if (filter->map[RMAP_IN].name) | |
7394 | vty_out (vty, " Route map for incoming advertisements is %s%s%s", | |
7395 | filter->map[RMAP_IN].map ? "*" : "", | |
7396 | filter->map[RMAP_IN].name, | |
7397 | VTY_NEWLINE); | |
7398 | if (filter->map[RMAP_OUT].name) | |
7399 | vty_out (vty, " Route map for outgoing advertisements is %s%s%s", | |
7400 | filter->map[RMAP_OUT].map ? "*" : "", | |
7401 | filter->map[RMAP_OUT].name, | |
7402 | VTY_NEWLINE); | |
856ca177 MS |
7403 | |
7404 | /* unsuppress-map */ | |
7405 | if (filter->usmap.name) | |
7406 | vty_out (vty, " Route map for selective unsuppress is %s%s%s", | |
7407 | filter->usmap.map ? "*" : "", | |
7408 | filter->usmap.name, VTY_NEWLINE); | |
7409 | ||
7410 | /* Receive prefix count */ | |
7411 | vty_out (vty, " %ld accepted prefixes%s", p->pcount[afi][safi], VTY_NEWLINE); | |
7412 | ||
7413 | /* Maximum prefix */ | |
7414 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) | |
7415 | { | |
7416 | vty_out (vty, " Maximum prefixes allowed %ld%s%s", p->pmax[afi][safi], | |
7417 | CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING) | |
7418 | ? " (warning-only)" : "", VTY_NEWLINE); | |
7419 | vty_out (vty, " Threshold for warning message %d%%", | |
7420 | p->pmax_threshold[afi][safi]); | |
7421 | if (p->pmax_restart[afi][safi]) | |
7422 | vty_out (vty, ", restart interval %d min", p->pmax_restart[afi][safi]); | |
7423 | vty_out (vty, "%s", VTY_NEWLINE); | |
7424 | } | |
718e3744 | 7425 | |
0a486e5f | 7426 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 7427 | } |
718e3744 | 7428 | } |
7429 | ||
94f2b392 | 7430 | static void |
e8f7da3a | 7431 | bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *json) |
718e3744 | 7432 | { |
7433 | struct bgp *bgp; | |
4690c7d7 | 7434 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; |
718e3744 | 7435 | char timebuf[BGP_UPTIME_LEN]; |
f14e6fdb | 7436 | char dn_flag[2]; |
3a8c7ba1 DW |
7437 | const char *subcode_str; |
7438 | const char *code_str; | |
538621f2 | 7439 | afi_t afi; |
7440 | safi_t safi; | |
d6661008 DS |
7441 | u_int16_t i; |
7442 | u_char *msg; | |
e8f7da3a | 7443 | json_object *json_neigh = NULL; |
718e3744 | 7444 | |
7445 | bgp = p->bgp; | |
7446 | ||
e8f7da3a DW |
7447 | if (use_json) |
7448 | json_neigh = json_object_new_object(); | |
7449 | ||
517cd68a DS |
7450 | memset (dn_flag, '\0', sizeof (dn_flag)); |
7451 | if (!p->conf_if && peer_dynamic_neighbor (p)) | |
7452 | dn_flag[0] = '*'; | |
7453 | ||
856ca177 | 7454 | if (!use_json) |
f14e6fdb | 7455 | { |
856ca177 MS |
7456 | if (p->conf_if) /* Configured interface name. */ |
7457 | vty_out (vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
7458 | BGP_PEER_SU_UNSPEC(p) ? "None" : | |
7459 | sockunion2str (&p->su, buf, SU_ADDRSTRLEN)); | |
7460 | else /* Configured IP address. */ | |
74ef1672 | 7461 | vty_out (vty, "BGP neighbor is %s%s, ", dn_flag, p->host); |
f14e6fdb DS |
7462 | } |
7463 | ||
856ca177 MS |
7464 | if (use_json) |
7465 | { | |
7466 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
7467 | json_object_string_add(json_neigh, "bgpNeighborAddr", "none"); | |
7468 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
7469 | json_object_string_add(json_neigh, "bgpNeighborAddr", sockunion2str (&p->su, buf, SU_ADDRSTRLEN)); | |
7470 | ||
7471 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
7472 | ||
7473 | if (p->change_local_as) | |
7474 | json_object_int_add(json_neigh, "localAs", p->change_local_as); | |
7475 | else | |
7476 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
7477 | ||
7478 | if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
7479 | json_object_boolean_true_add(json_neigh, "localAsNoPrepend"); | |
66b199b2 | 7480 | |
856ca177 MS |
7481 | if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) |
7482 | json_object_boolean_true_add(json_neigh, "localAsReplaceAs"); | |
7483 | } | |
7484 | else | |
7485 | { | |
f8cfafda DS |
7486 | if ((p->as_type == AS_SPECIFIED) || |
7487 | (p->as_type == AS_EXTERNAL) || | |
7488 | (p->as_type == AS_INTERNAL)) | |
7489 | vty_out (vty, "remote AS %u, ", p->as); | |
7490 | else | |
7491 | vty_out (vty, "remote AS Unspecified, "); | |
856ca177 MS |
7492 | vty_out (vty, "local AS %u%s%s, ", |
7493 | p->change_local_as ? p->change_local_as : p->local_as, | |
7494 | CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ? | |
7495 | " no-prepend" : "", | |
7496 | CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) ? | |
7497 | " replace-as" : ""); | |
7498 | } | |
66b199b2 DS |
7499 | /* peer type internal, external, confed-internal or confed-external */ |
7500 | if (p->as == p->local_as) | |
7501 | { | |
856ca177 MS |
7502 | if (use_json) |
7503 | { | |
7504 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
7505 | json_object_boolean_true_add(json_neigh, "nbrConfedInternalLink"); | |
7506 | else | |
7507 | json_object_boolean_true_add(json_neigh, "nbrInternalLink"); | |
7508 | } | |
66b199b2 | 7509 | else |
856ca177 MS |
7510 | { |
7511 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
7512 | vty_out (vty, "confed-internal link%s", VTY_NEWLINE); | |
7513 | else | |
7514 | vty_out (vty, "internal link%s", VTY_NEWLINE); | |
7515 | } | |
66b199b2 DS |
7516 | } |
7517 | else | |
7518 | { | |
856ca177 MS |
7519 | if (use_json) |
7520 | { | |
7521 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
7522 | json_object_boolean_true_add(json_neigh, "nbrConfedExternalLink"); | |
7523 | else | |
7524 | json_object_boolean_true_add(json_neigh, "nbrExternalLink"); | |
7525 | } | |
66b199b2 | 7526 | else |
856ca177 MS |
7527 | { |
7528 | if (bgp_confederation_peers_check(bgp, p->as)) | |
7529 | vty_out (vty, "confed-external link%s", VTY_NEWLINE); | |
7530 | else | |
7531 | vty_out (vty, "external link%s", VTY_NEWLINE); | |
7532 | } | |
66b199b2 | 7533 | } |
718e3744 | 7534 | |
7535 | /* Description. */ | |
7536 | if (p->desc) | |
856ca177 MS |
7537 | { |
7538 | if (use_json) | |
7539 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
7540 | else | |
7541 | vty_out (vty, " Description: %s%s", p->desc, VTY_NEWLINE); | |
7542 | } | |
6410e93a | 7543 | |
04b6bdc0 DW |
7544 | if (p->hostname) |
7545 | { | |
d1570739 DW |
7546 | if (use_json) |
7547 | { | |
7548 | if (p->hostname) | |
7549 | json_object_string_add(json_neigh, "hostname", p->hostname); | |
7550 | ||
7551 | if (p->domainname) | |
7552 | json_object_string_add(json_neigh, "domainname", p->domainname); | |
7553 | } | |
04b6bdc0 | 7554 | else |
d1570739 DW |
7555 | { |
7556 | if (p->domainname && (p->domainname[0] != '\0')) | |
7557 | vty_out(vty, "Hostname: %s.%s%s", p->hostname, p->domainname, | |
7558 | VTY_NEWLINE); | |
7559 | else | |
7560 | vty_out(vty, "Hostname: %s%s", p->hostname, VTY_NEWLINE); | |
7561 | } | |
7562 | ||
04b6bdc0 DW |
7563 | } |
7564 | ||
c744aa9f | 7565 | /* Peer-group */ |
718e3744 | 7566 | if (p->group) |
f14e6fdb | 7567 | { |
856ca177 MS |
7568 | if (use_json) |
7569 | { | |
7570 | json_object_string_add(json_neigh, "peerGroup", p->group->name); | |
7571 | ||
7572 | if (dn_flag[0]) | |
7573 | { | |
40ee54a7 | 7574 | struct prefix prefix, *range = NULL; |
f14e6fdb | 7575 | |
40ee54a7 TT |
7576 | sockunion2hostprefix(&(p->su), &prefix); |
7577 | range = peer_group_lookup_dynamic_neighbor_range (p->group, &prefix); | |
856ca177 MS |
7578 | |
7579 | if (range) | |
7580 | { | |
7581 | prefix2str(range, buf1, sizeof(buf1)); | |
7582 | json_object_string_add(json_neigh, "peerSubnetRangeGroup", buf1); | |
7583 | } | |
7584 | } | |
7585 | } | |
7586 | else | |
f14e6fdb | 7587 | { |
856ca177 MS |
7588 | vty_out (vty, " Member of peer-group %s for session parameters%s", |
7589 | p->group->name, VTY_NEWLINE); | |
f14e6fdb | 7590 | |
856ca177 | 7591 | if (dn_flag[0]) |
f14e6fdb | 7592 | { |
40ee54a7 | 7593 | struct prefix prefix, *range = NULL; |
856ca177 | 7594 | |
40ee54a7 TT |
7595 | sockunion2hostprefix(&(p->su), &prefix); |
7596 | range = peer_group_lookup_dynamic_neighbor_range (p->group, &prefix); | |
856ca177 MS |
7597 | |
7598 | if (range) | |
7599 | { | |
7600 | prefix2str(range, buf1, sizeof(buf1)); | |
7601 | vty_out (vty, " Belongs to the subnet range group: %s%s", buf1, VTY_NEWLINE); | |
7602 | } | |
f14e6fdb DS |
7603 | } |
7604 | } | |
7605 | } | |
718e3744 | 7606 | |
856ca177 MS |
7607 | if (use_json) |
7608 | { | |
7609 | /* Administrative shutdown. */ | |
7610 | if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN)) | |
7611 | json_object_boolean_true_add(json_neigh, "adminShutDown"); | |
718e3744 | 7612 | |
856ca177 MS |
7613 | /* BGP Version. */ |
7614 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
389e3fe0 | 7615 | json_object_string_add(json_neigh, "remoteRouterId", |
44b8cd53 | 7616 | inet_ntop (AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
718e3744 | 7617 | |
856ca177 MS |
7618 | /* Confederation */ |
7619 | if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION) && bgp_confederation_peers_check (bgp, p->as)) | |
7620 | json_object_boolean_true_add(json_neigh, "nbrCommonAdmin"); | |
7621 | ||
7622 | /* Status. */ | |
7623 | json_object_string_add(json_neigh, "bgpState", LOOKUP (bgp_status_msg, p->status)); | |
7624 | ||
7625 | if (p->status == Established) | |
7626 | { | |
7627 | time_t uptime; | |
7628 | struct tm *tm; | |
7629 | ||
7630 | uptime = bgp_clock(); | |
7631 | uptime -= p->uptime; | |
7632 | tm = gmtime(&uptime); | |
7633 | ||
7634 | json_object_int_add(json_neigh, "bgpTimerUp", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); | |
7635 | } | |
7636 | ||
7637 | else if (p->status == Active) | |
7638 | { | |
7639 | if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE)) | |
7640 | json_object_string_add(json_neigh, "bgpStateIs", "passive"); | |
7641 | else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT)) | |
7642 | json_object_string_add(json_neigh, "bgpStateIs", "passiveNSF"); | |
7643 | } | |
7644 | ||
7645 | /* read timer */ | |
7646 | time_t uptime; | |
7647 | struct tm *tm; | |
7648 | ||
7649 | uptime = bgp_clock(); | |
7650 | uptime -= p->readtime; | |
7651 | tm = gmtime(&uptime); | |
7652 | json_object_int_add(json_neigh, "bgpTimerLastRead", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); | |
7653 | ||
7654 | uptime = bgp_clock(); | |
7655 | uptime -= p->last_write; | |
7656 | tm = gmtime(&uptime); | |
39e871e6 ST |
7657 | json_object_int_add(json_neigh, "bgpTimerLastWrite", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); |
7658 | ||
7659 | uptime = bgp_clock(); | |
7660 | uptime -= p->update_time; | |
7661 | tm = gmtime(&uptime); | |
7662 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", | |
7663 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); | |
856ca177 MS |
7664 | |
7665 | /* Configured timer values. */ | |
7666 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", p->v_holdtime * 1000); | |
7667 | json_object_int_add(json_neigh, "bgpTimerKeepAliveIntervalMsecs", p->v_keepalive * 1000); | |
7668 | ||
7669 | if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER)) | |
7670 | { | |
7671 | json_object_int_add(json_neigh, "bgpTimerConfiguredHoldTimeMsecs", p->holdtime * 1000); | |
7672 | json_object_int_add(json_neigh, "bgpTimerConfiguredKeepAliveIntervalMsecs", p->keepalive * 1000); | |
7673 | } | |
93406d87 | 7674 | } |
856ca177 MS |
7675 | else |
7676 | { | |
7677 | /* Administrative shutdown. */ | |
7678 | if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN)) | |
7679 | vty_out (vty, " Administratively shut down%s", VTY_NEWLINE); | |
7680 | ||
7681 | /* BGP Version. */ | |
7682 | vty_out (vty, " BGP version 4"); | |
389e3fe0 | 7683 | vty_out (vty, ", remote router ID %s%s", |
44b8cd53 | 7684 | inet_ntop (AF_INET, &p->remote_id, buf1, sizeof(buf1)), |
856ca177 MS |
7685 | VTY_NEWLINE); |
7686 | ||
7687 | /* Confederation */ | |
7688 | if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION) | |
7689 | && bgp_confederation_peers_check (bgp, p->as)) | |
7690 | vty_out (vty, " Neighbor under common administration%s", VTY_NEWLINE); | |
e52702f2 | 7691 | |
856ca177 MS |
7692 | /* Status. */ |
7693 | vty_out (vty, " BGP state = %s", LOOKUP (bgp_status_msg, p->status)); | |
718e3744 | 7694 | |
856ca177 MS |
7695 | if (p->status == Established) |
7696 | vty_out (vty, ", up for %8s", peer_uptime (p->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL)); | |
7697 | ||
7698 | else if (p->status == Active) | |
7699 | { | |
7700 | if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE)) | |
7701 | vty_out (vty, " (passive)"); | |
7702 | else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT)) | |
7703 | vty_out (vty, " (NSF passive)"); | |
7704 | } | |
7705 | vty_out (vty, "%s", VTY_NEWLINE); | |
93406d87 | 7706 | |
856ca177 MS |
7707 | /* read timer */ |
7708 | vty_out (vty, " Last read %s", peer_uptime (p->readtime, timebuf, BGP_UPTIME_LEN, 0, NULL)); | |
7709 | vty_out (vty, ", Last write %s%s", | |
7710 | peer_uptime (p->last_write, timebuf, BGP_UPTIME_LEN, 0, NULL), VTY_NEWLINE); | |
7711 | ||
7712 | /* Configured timer values. */ | |
7713 | vty_out (vty, " Hold time is %d, keepalive interval is %d seconds%s", | |
7714 | p->v_holdtime, p->v_keepalive, VTY_NEWLINE); | |
7715 | if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER)) | |
7716 | { | |
7717 | vty_out (vty, " Configured hold time is %d", p->holdtime); | |
7718 | vty_out (vty, ", keepalive interval is %d seconds%s", | |
7719 | p->keepalive, VTY_NEWLINE); | |
7720 | } | |
7721 | } | |
718e3744 | 7722 | /* Capability. */ |
e52702f2 | 7723 | if (p->status == Established) |
718e3744 | 7724 | { |
538621f2 | 7725 | if (p->cap |
718e3744 | 7726 | || p->afc_adv[AFI_IP][SAFI_UNICAST] |
7727 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
7728 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
7729 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
718e3744 | 7730 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] |
7731 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
7732 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
7733 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
945c8fe9 LB |
7734 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] |
7735 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
8b1fb8be LB |
7736 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] |
7737 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
8b1fb8be LB |
7738 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
7739 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
718e3744 | 7740 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
7741 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) | |
7742 | { | |
856ca177 MS |
7743 | if (use_json) |
7744 | { | |
7745 | json_object *json_cap = NULL; | |
7746 | ||
7747 | json_cap = json_object_new_object(); | |
7748 | ||
7749 | /* AS4 */ | |
7750 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV) | |
7751 | || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
7752 | { | |
7753 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) && CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)) | |
7754 | json_object_string_add(json_cap, "4byteAs", "advertisedAndReceived"); | |
7755 | else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
7756 | json_object_string_add(json_cap, "4byteAs", "advertised"); | |
7757 | else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)) | |
7758 | json_object_string_add(json_cap, "4byteAs", "received"); | |
7759 | } | |
7760 | ||
7761 | /* AddPath */ | |
7762 | if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV) | |
7763 | || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV)) | |
7764 | { | |
7765 | json_object *json_add = NULL; | |
7766 | const char *print_store; | |
718e3744 | 7767 | |
856ca177 | 7768 | json_add = json_object_new_object(); |
a82478b9 | 7769 | |
856ca177 MS |
7770 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) |
7771 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7772 | { | |
7773 | json_object *json_sub = NULL; | |
7774 | json_sub = json_object_new_object(); | |
7775 | print_store = afi_safi_print (afi, safi); | |
7776 | ||
7777 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) || | |
7778 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) | |
7779 | { | |
7780 | 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)) | |
7781 | json_object_boolean_true_add(json_sub, "txAdvertisedAndReceived"); | |
7782 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV)) | |
7783 | json_object_boolean_true_add(json_sub, "txAdvertised"); | |
7784 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) | |
7785 | json_object_boolean_true_add(json_sub, "txReceived"); | |
7786 | } | |
7787 | ||
7788 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) || | |
7789 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) | |
7790 | { | |
7791 | 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)) | |
7792 | json_object_boolean_true_add(json_sub, "rxAdvertisedAndReceived"); | |
7793 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV)) | |
7794 | json_object_boolean_true_add(json_sub, "rxAdvertised"); | |
7795 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) | |
7796 | json_object_boolean_true_add(json_sub, "rxReceived"); | |
7797 | } | |
7798 | ||
7799 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) || | |
7800 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV) || | |
7801 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) || | |
7802 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) | |
7803 | json_object_object_add(json_add, print_store, json_sub); | |
b6df4090 DS |
7804 | else |
7805 | json_object_free(json_sub); | |
856ca177 | 7806 | } |
a82478b9 | 7807 | |
856ca177 MS |
7808 | json_object_object_add(json_cap, "addPath", json_add); |
7809 | } | |
7810 | ||
7811 | /* Dynamic */ | |
7812 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV) | |
7813 | || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
7814 | { | |
7815 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) && CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)) | |
7816 | json_object_string_add(json_cap, "dynamic", "advertisedAndReceived"); | |
7817 | else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
7818 | json_object_string_add(json_cap, "dynamic", "advertised"); | |
7819 | else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)) | |
7820 | json_object_string_add(json_cap, "dynamic", "received"); | |
7821 | } | |
7822 | ||
7823 | /* Extended nexthop */ | |
7824 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV) | |
7825 | || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
7826 | { | |
7827 | json_object *json_nxt = NULL; | |
7828 | const char *print_store; | |
7829 | ||
856ca177 MS |
7830 | |
7831 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) && CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
7832 | json_object_string_add(json_cap, "extendedNexthop", "advertisedAndReceived"); | |
7833 | else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
7834 | json_object_string_add(json_cap, "extendedNexthop", "advertised"); | |
7835 | else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
7836 | json_object_string_add(json_cap, "extendedNexthop", "received"); | |
7837 | ||
7838 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
7839 | { | |
b6df4090 DS |
7840 | json_nxt = json_object_new_object(); |
7841 | ||
856ca177 MS |
7842 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) |
7843 | { | |
7844 | if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV)) | |
7845 | { | |
7846 | print_store = afi_safi_print (AFI_IP, safi); | |
7847 | json_object_string_add(json_nxt, print_store, "recieved"); | |
7848 | } | |
7849 | } | |
7850 | json_object_object_add(json_cap, "extendedNexthopFamililesByPeer", json_nxt); | |
7851 | } | |
7852 | } | |
7853 | ||
7854 | /* Route Refresh */ | |
7855 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) | |
7856 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) | |
7857 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
7858 | { | |
7859 | 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))) | |
7860 | { | |
7861 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) | |
7862 | json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOldNew"); | |
7863 | else | |
7864 | { | |
7865 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
7866 | json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOld"); | |
7867 | else | |
7868 | json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedNew"); | |
7869 | } | |
7870 | } | |
7871 | else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)) | |
7872 | json_object_string_add(json_cap, "routeRefresh", "advertised"); | |
7873 | else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
7874 | json_object_string_add(json_cap, "routeRefresh", "received"); | |
7875 | } | |
7876 | ||
7877 | /* Multiprotocol Extensions */ | |
7878 | json_object *json_multi = NULL; | |
7879 | json_multi = json_object_new_object(); | |
7880 | ||
7881 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7882 | { | |
7883 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7884 | { | |
7885 | if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi]) | |
7886 | { | |
7887 | json_object *json_exten = NULL; | |
7888 | json_exten = json_object_new_object(); | |
7889 | ||
7890 | if (p->afc_adv[afi][safi] && p->afc_recv[afi][safi]) | |
7891 | json_object_boolean_true_add(json_exten, "advertisedAndReceived"); | |
7892 | else if (p->afc_adv[afi][safi]) | |
7893 | json_object_boolean_true_add(json_exten, "advertised"); | |
7894 | else if (p->afc_recv[afi][safi]) | |
7895 | json_object_boolean_true_add(json_exten, "received"); | |
7896 | ||
7897 | json_object_object_add(json_multi, afi_safi_print (afi, safi), json_exten); | |
7898 | } | |
7899 | } | |
7900 | } | |
7901 | json_object_object_add(json_cap, "multiprotocolExtensions", json_multi); | |
7902 | ||
7903 | /* Gracefull Restart */ | |
7904 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV) | |
7905 | || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
7906 | { | |
7907 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) && CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) | |
7908 | json_object_string_add(json_cap, "gracefulRestart", "advertisedAndReceived"); | |
7909 | else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
7910 | json_object_string_add(json_cap, "gracefulRestartCapability", "advertised"); | |
7911 | else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) | |
7912 | json_object_string_add(json_cap, "gracefulRestartCapability", "received"); | |
7913 | ||
7914 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) | |
7915 | { | |
7916 | int restart_af_count = 0; | |
7917 | json_object *json_restart = NULL; | |
7918 | json_restart = json_object_new_object(); | |
7919 | ||
7920 | json_object_int_add(json_cap, "gracefulRestartRemoteTimerMsecs", p->v_gr_restart * 1000); | |
7921 | ||
7922 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7923 | { | |
7924 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7925 | { | |
7926 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV)) | |
7927 | { | |
7928 | json_object *json_sub = NULL; | |
7929 | json_sub = json_object_new_object(); | |
7930 | ||
7931 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV)) | |
7932 | json_object_boolean_true_add(json_sub, "preserved"); | |
7933 | restart_af_count++; | |
7934 | json_object_object_add(json_restart, afi_safi_print (afi, safi), json_sub); | |
7935 | } | |
7936 | } | |
7937 | } | |
7938 | if (! restart_af_count) | |
b6df4090 | 7939 | { |
856ca177 | 7940 | json_object_string_add(json_cap, "addressFamiliesByPeer", "none"); |
b6df4090 DS |
7941 | json_object_free(json_restart); |
7942 | } | |
856ca177 MS |
7943 | else |
7944 | json_object_object_add(json_cap, "addressFamiliesByPeer", json_restart); | |
7945 | } | |
7946 | } | |
7947 | json_object_object_add(json_neigh, "neighborCapabilities", json_cap); | |
7948 | } | |
7949 | else | |
7950 | { | |
7951 | vty_out (vty, " Neighbor capabilities:%s", VTY_NEWLINE); | |
7952 | ||
7953 | /* AS4 */ | |
7954 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV) | |
7955 | || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
7956 | { | |
7957 | vty_out (vty, " 4 Byte AS:"); | |
7958 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
7959 | vty_out (vty, " advertised"); | |
7960 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)) | |
7961 | vty_out (vty, " %sreceived", | |
7962 | CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) ? "and " : ""); | |
7963 | vty_out (vty, "%s", VTY_NEWLINE); | |
7964 | } | |
7965 | ||
7966 | /* AddPath */ | |
7967 | if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV) | |
7968 | || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV)) | |
7969 | { | |
7970 | vty_out (vty, " AddPath:%s", VTY_NEWLINE); | |
a82478b9 | 7971 | |
856ca177 MS |
7972 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) |
7973 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
a82478b9 | 7974 | { |
856ca177 MS |
7975 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) || |
7976 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) | |
7977 | { | |
7978 | vty_out (vty, " %s: TX ", afi_safi_print (afi, safi)); | |
a82478b9 | 7979 | |
856ca177 MS |
7980 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV)) |
7981 | vty_out (vty, "advertised %s", afi_safi_print (afi, safi)); | |
a82478b9 | 7982 | |
856ca177 MS |
7983 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) |
7984 | vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ? " and " : "" ); | |
a82478b9 | 7985 | |
856ca177 MS |
7986 | vty_out (vty, "%s", VTY_NEWLINE); |
7987 | } | |
a82478b9 | 7988 | |
856ca177 | 7989 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) || |
a82478b9 | 7990 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) |
856ca177 MS |
7991 | { |
7992 | vty_out (vty, " %s: RX ", afi_safi_print (afi, safi)); | |
a82478b9 | 7993 | |
856ca177 MS |
7994 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV)) |
7995 | vty_out (vty, "advertised %s", afi_safi_print (afi, safi)); | |
a82478b9 | 7996 | |
856ca177 MS |
7997 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) |
7998 | vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ? " and " : "" ); | |
a82478b9 | 7999 | |
856ca177 MS |
8000 | vty_out (vty, "%s", VTY_NEWLINE); |
8001 | } | |
a82478b9 | 8002 | } |
856ca177 | 8003 | } |
a82478b9 | 8004 | |
856ca177 MS |
8005 | /* Dynamic */ |
8006 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV) | |
8007 | || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
8008 | { | |
8009 | vty_out (vty, " Dynamic:"); | |
8010 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
8011 | vty_out (vty, " advertised"); | |
8012 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)) | |
8013 | vty_out (vty, " %sreceived", | |
8014 | CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) ? "and " : ""); | |
8015 | vty_out (vty, "%s", VTY_NEWLINE); | |
8016 | } | |
8017 | ||
8018 | /* Extended nexthop */ | |
8019 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV) | |
8020 | || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
8021 | { | |
8022 | vty_out (vty, " Extended nexthop:"); | |
8023 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
8024 | vty_out (vty, " advertised"); | |
8025 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
8026 | vty_out (vty, " %sreceived", | |
8027 | CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) ? "and " : ""); | |
8028 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 8029 | |
856ca177 MS |
8030 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) |
8031 | { | |
8032 | vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE); | |
8033 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8034 | if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV)) | |
8035 | vty_out (vty, " %s%s", | |
8036 | afi_safi_print (AFI_IP, safi), VTY_NEWLINE); | |
8037 | } | |
8038 | } | |
8a92a8a0 | 8039 | |
856ca177 MS |
8040 | /* Route Refresh */ |
8041 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) | |
8042 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) | |
8043 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
8044 | { | |
8045 | vty_out (vty, " Route refresh:"); | |
8046 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)) | |
8047 | vty_out (vty, " advertised"); | |
8048 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) | |
8049 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
8050 | vty_out (vty, " %sreceived(%s)", | |
8051 | CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) ? "and " : "", | |
8052 | (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) | |
8053 | && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) ? | |
8054 | "old & new" : CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) ? "old" : "new"); | |
8a92a8a0 | 8055 | |
856ca177 MS |
8056 | vty_out (vty, "%s", VTY_NEWLINE); |
8057 | } | |
718e3744 | 8058 | |
856ca177 MS |
8059 | /* Multiprotocol Extensions */ |
8060 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8061 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8062 | if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi]) | |
8063 | { | |
8c3deaae | 8064 | vty_out (vty, " Address Family %s:", afi_safi_print (afi, safi)); |
856ca177 MS |
8065 | if (p->afc_adv[afi][safi]) |
8066 | vty_out (vty, " advertised"); | |
8067 | if (p->afc_recv[afi][safi]) | |
8068 | vty_out (vty, " %sreceived", p->afc_adv[afi][safi] ? "and " : ""); | |
8069 | vty_out (vty, "%s", VTY_NEWLINE); | |
8070 | } | |
538621f2 | 8071 | |
04b6bdc0 DW |
8072 | /* Hostname capability */ |
8073 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV) || | |
8074 | CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) | |
8075 | { | |
8076 | vty_out (vty, " Hostname Capability:"); | |
8077 | if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV)) | |
8078 | vty_out (vty, " advertised"); | |
8079 | if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_RCV)) | |
8080 | vty_out (vty, " %sreceived", | |
8081 | CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV) ? "and " : ""); | |
8082 | vty_out (vty, "%s", VTY_NEWLINE); | |
8083 | } | |
8084 | ||
856ca177 MS |
8085 | /* Gracefull Restart */ |
8086 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV) | |
8087 | || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
8088 | { | |
8089 | vty_out (vty, " Graceful Restart Capabilty:"); | |
8090 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
538621f2 | 8091 | vty_out (vty, " advertised"); |
856ca177 MS |
8092 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) |
8093 | vty_out (vty, " %sreceived", | |
8094 | CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) ? "and " : ""); | |
8095 | vty_out (vty, "%s", VTY_NEWLINE); | |
538621f2 | 8096 | |
856ca177 MS |
8097 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) |
8098 | { | |
8099 | int restart_af_count = 0; | |
8100 | ||
8101 | vty_out (vty, " Remote Restart timer is %d seconds%s", | |
8102 | p->v_gr_restart, VTY_NEWLINE); | |
8103 | vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE); | |
8104 | ||
8105 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8106 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8107 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV)) | |
8108 | { | |
8109 | vty_out (vty, "%s%s(%s)", restart_af_count ? ", " : "", | |
8110 | afi_safi_print (afi, safi), | |
8111 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV) ? | |
8112 | "preserved" : "not preserved"); | |
8113 | restart_af_count++; | |
8114 | } | |
8115 | if (! restart_af_count) | |
8116 | vty_out (vty, "none"); | |
8117 | vty_out (vty, "%s", VTY_NEWLINE); | |
8118 | } | |
8119 | } | |
8120 | } | |
718e3744 | 8121 | } |
8122 | } | |
8123 | ||
93406d87 | 8124 | /* graceful restart information */ |
8125 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV) | |
8126 | || p->t_gr_restart | |
8127 | || p->t_gr_stale) | |
8128 | { | |
856ca177 MS |
8129 | json_object *json_grace = NULL; |
8130 | json_object *json_grace_send = NULL; | |
8131 | json_object *json_grace_recv = NULL; | |
93406d87 | 8132 | int eor_send_af_count = 0; |
8133 | int eor_receive_af_count = 0; | |
8134 | ||
856ca177 MS |
8135 | if (use_json) |
8136 | { | |
8137 | json_grace = json_object_new_object(); | |
8138 | json_grace_send = json_object_new_object(); | |
8139 | json_grace_recv = json_object_new_object(); | |
8140 | ||
8141 | if (p->status == Established) | |
8142 | { | |
8143 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8144 | { | |
8145 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8146 | { | |
8147 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND)) | |
8148 | { | |
8149 | json_object_boolean_true_add(json_grace_send, afi_safi_print (afi, safi)); | |
8150 | eor_send_af_count++; | |
8151 | } | |
8152 | } | |
8153 | } | |
8154 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8155 | { | |
8156 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8157 | { | |
8158 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED)) | |
8159 | { | |
8160 | json_object_boolean_true_add(json_grace_recv, afi_safi_print (afi, safi)); | |
8161 | eor_receive_af_count++; | |
8162 | } | |
8163 | } | |
8164 | } | |
8165 | } | |
8166 | ||
8167 | json_object_object_add(json_grace, "endOfRibSend", json_grace_send); | |
8168 | json_object_object_add(json_grace, "endOfRibRecv", json_grace_recv); | |
8169 | ||
8170 | if (p->t_gr_restart) | |
8171 | json_object_int_add(json_grace, "gracefulRestartTimerMsecs", thread_timer_remain_second (p->t_gr_restart) * 1000); | |
8172 | ||
8173 | if (p->t_gr_stale) | |
8174 | json_object_int_add(json_grace, "gracefulStalepathTimerMsecs", thread_timer_remain_second (p->t_gr_stale) * 1000); | |
8175 | ||
8176 | json_object_object_add(json_neigh, "gracefulRestartInfo", json_grace); | |
8177 | } | |
8178 | else | |
8179 | { | |
8180 | vty_out (vty, " Graceful restart informations:%s", VTY_NEWLINE); | |
8181 | if (p->status == Established) | |
8182 | { | |
8183 | vty_out (vty, " End-of-RIB send: "); | |
8184 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8185 | { | |
8186 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8187 | { | |
8188 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND)) | |
8189 | { | |
8190 | vty_out (vty, "%s%s", eor_send_af_count ? ", " : "", | |
8191 | afi_safi_print (afi, safi)); | |
8192 | eor_send_af_count++; | |
8193 | } | |
8194 | } | |
8195 | } | |
8196 | vty_out (vty, "%s", VTY_NEWLINE); | |
8197 | vty_out (vty, " End-of-RIB received: "); | |
8198 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8199 | { | |
8200 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8201 | { | |
8202 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED)) | |
8203 | { | |
8204 | vty_out (vty, "%s%s", eor_receive_af_count ? ", " : "", | |
8205 | afi_safi_print (afi, safi)); | |
8206 | eor_receive_af_count++; | |
8207 | } | |
8208 | } | |
8209 | } | |
8210 | vty_out (vty, "%s", VTY_NEWLINE); | |
8211 | } | |
93406d87 | 8212 | |
856ca177 MS |
8213 | if (p->t_gr_restart) |
8214 | vty_out (vty, " The remaining time of restart timer is %ld%s", | |
8215 | thread_timer_remain_second (p->t_gr_restart), VTY_NEWLINE); | |
e52702f2 | 8216 | |
856ca177 MS |
8217 | if (p->t_gr_stale) |
8218 | vty_out (vty, " The remaining time of stalepath timer is %ld%s", | |
8219 | thread_timer_remain_second (p->t_gr_stale), VTY_NEWLINE); | |
8220 | } | |
8221 | } | |
8222 | if (use_json) | |
8223 | { | |
8224 | json_object *json_stat = NULL; | |
8225 | json_stat = json_object_new_object(); | |
8226 | /* Packet counts. */ | |
8227 | json_object_int_add(json_stat, "depthInq", 0); | |
8228 | json_object_int_add(json_stat, "depthOutq", (unsigned long) p->obuf->count); | |
8229 | json_object_int_add(json_stat, "opensSent", p->open_out); | |
8230 | json_object_int_add(json_stat, "opensRecv", p->open_in); | |
8231 | json_object_int_add(json_stat, "notificationsSent", p->notify_out); | |
8232 | json_object_int_add(json_stat, "notificationsRecv", p->notify_in); | |
8233 | json_object_int_add(json_stat, "updatesSent", p->update_out); | |
8234 | json_object_int_add(json_stat, "updatesRecv", p->update_in); | |
8235 | json_object_int_add(json_stat, "keepalivesSent", p->keepalive_out); | |
8236 | json_object_int_add(json_stat, "keepalivesRecv", p->keepalive_in); | |
8237 | json_object_int_add(json_stat, "routeRefreshSent", p->refresh_out); | |
8238 | json_object_int_add(json_stat, "routeRefreshRecv", p->refresh_in); | |
8239 | json_object_int_add(json_stat, "capabilitySent", p->dynamic_cap_out); | |
8240 | json_object_int_add(json_stat, "capabilityRecv", p->dynamic_cap_in); | |
8241 | 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); | |
8242 | 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); | |
8243 | json_object_object_add(json_neigh, "messageStats", json_stat); | |
8244 | } | |
8245 | else | |
8246 | { | |
8247 | /* Packet counts. */ | |
8248 | vty_out (vty, " Message statistics:%s", VTY_NEWLINE); | |
8249 | vty_out (vty, " Inq depth is 0%s", VTY_NEWLINE); | |
8250 | vty_out (vty, " Outq depth is %lu%s", (unsigned long) p->obuf->count, VTY_NEWLINE); | |
8251 | vty_out (vty, " Sent Rcvd%s", VTY_NEWLINE); | |
8252 | vty_out (vty, " Opens: %10d %10d%s", p->open_out, p->open_in, VTY_NEWLINE); | |
8253 | vty_out (vty, " Notifications: %10d %10d%s", p->notify_out, p->notify_in, VTY_NEWLINE); | |
8254 | vty_out (vty, " Updates: %10d %10d%s", p->update_out, p->update_in, VTY_NEWLINE); | |
8255 | vty_out (vty, " Keepalives: %10d %10d%s", p->keepalive_out, p->keepalive_in, VTY_NEWLINE); | |
8256 | vty_out (vty, " Route Refresh: %10d %10d%s", p->refresh_out, p->refresh_in, VTY_NEWLINE); | |
8257 | vty_out (vty, " Capability: %10d %10d%s", p->dynamic_cap_out, p->dynamic_cap_in, VTY_NEWLINE); | |
8258 | vty_out (vty, " Total: %10d %10d%s", p->open_out + p->notify_out + | |
8259 | p->update_out + p->keepalive_out + p->refresh_out + p->dynamic_cap_out, | |
8260 | p->open_in + p->notify_in + p->update_in + p->keepalive_in + p->refresh_in + | |
8261 | p->dynamic_cap_in, VTY_NEWLINE); | |
718e3744 | 8262 | } |
8263 | ||
856ca177 MS |
8264 | if (use_json) |
8265 | { | |
8266 | /* advertisement-interval */ | |
8267 | json_object_int_add(json_neigh, "minBtwnAdvertisementRunsTimerMsecs", p->v_routeadv * 1000); | |
718e3744 | 8268 | |
856ca177 MS |
8269 | /* Update-source. */ |
8270 | if (p->update_if || p->update_source) | |
8271 | { | |
8272 | if (p->update_if) | |
8273 | json_object_string_add(json_neigh, "updateSource", p->update_if); | |
8274 | else if (p->update_source) | |
8275 | json_object_string_add(json_neigh, "updateSource", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN)); | |
8276 | } | |
856ca177 MS |
8277 | } |
8278 | else | |
8279 | { | |
8280 | /* advertisement-interval */ | |
8281 | vty_out (vty, " Minimum time between advertisement runs is %d seconds%s", | |
8282 | p->v_routeadv, VTY_NEWLINE); | |
8283 | ||
8284 | /* Update-source. */ | |
8285 | if (p->update_if || p->update_source) | |
8286 | { | |
8287 | vty_out (vty, " Update source is "); | |
8288 | if (p->update_if) | |
8289 | vty_out (vty, "%s", p->update_if); | |
8290 | else if (p->update_source) | |
8291 | vty_out (vty, "%s", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN)); | |
8292 | vty_out (vty, "%s", VTY_NEWLINE); | |
8293 | } | |
8294 | ||
856ca177 MS |
8295 | vty_out (vty, "%s", VTY_NEWLINE); |
8296 | } | |
718e3744 | 8297 | |
8298 | /* Address Family Information */ | |
856ca177 MS |
8299 | json_object *json_hold = NULL; |
8300 | ||
8301 | if (use_json) | |
8302 | json_hold = json_object_new_object(); | |
8303 | ||
538621f2 | 8304 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) |
8305 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8306 | if (p->afc[afi][safi]) | |
856ca177 | 8307 | bgp_show_peer_afi (vty, p, afi, safi, use_json, json_hold); |
718e3744 | 8308 | |
856ca177 MS |
8309 | if (use_json) |
8310 | { | |
58433ae6 | 8311 | json_object_object_add(json_neigh, "addressFamilyInfo", json_hold); |
e08ac8b7 DW |
8312 | json_object_int_add(json_neigh, "connectionsEstablished", p->established); |
8313 | json_object_int_add(json_neigh, "connectionsDropped", p->dropped); | |
856ca177 MS |
8314 | } |
8315 | else | |
8316 | vty_out (vty, " Connections established %d; dropped %d%s", p->established, p->dropped, | |
8317 | VTY_NEWLINE); | |
718e3744 | 8318 | |
d6661008 | 8319 | if (! p->last_reset) |
856ca177 MS |
8320 | { |
8321 | if (use_json) | |
e08ac8b7 | 8322 | json_object_string_add(json_neigh, "lastReset", "never"); |
856ca177 MS |
8323 | else |
8324 | vty_out (vty, " Last reset never%s", VTY_NEWLINE); | |
8325 | } | |
e0701b79 | 8326 | else |
d6661008 | 8327 | { |
856ca177 MS |
8328 | if (use_json) |
8329 | { | |
8330 | time_t uptime; | |
8331 | struct tm *tm; | |
8332 | ||
8333 | uptime = bgp_clock(); | |
8334 | uptime -= p->resettime; | |
8335 | tm = gmtime(&uptime); | |
e08ac8b7 DW |
8336 | json_object_int_add(json_neigh, "lastResetTimerMsecs", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); |
8337 | json_object_string_add(json_neigh, "lastResetDueTo", peer_down_str[(int) p->last_reset]); | |
cca1dda8 DD |
8338 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND || |
8339 | p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) | |
856ca177 | 8340 | { |
39e871e6 | 8341 | char errorcodesubcode_hexstr[5]; |
cca1dda8 DD |
8342 | char errorcodesubcode_str[256]; |
8343 | ||
8344 | code_str = bgp_notify_code_str(p->notify.code); | |
8345 | subcode_str = bgp_notify_subcode_str(p->notify.code, p->notify.subcode); | |
8346 | ||
39e871e6 | 8347 | sprintf(errorcodesubcode_hexstr, "%02X%02X", p->notify.code, p->notify.subcode); |
e08ac8b7 | 8348 | json_object_string_add(json_neigh, "lastErrorCodeSubcode", errorcodesubcode_hexstr); |
cca1dda8 DD |
8349 | snprintf(errorcodesubcode_str, 255, "%s%s", code_str, subcode_str); |
8350 | json_object_string_add(json_neigh, "lastNotificationReason", errorcodesubcode_str); | |
652b9429 DS |
8351 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED |
8352 | && p->notify.code == BGP_NOTIFY_CEASE | |
8353 | && (p->notify.subcode == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
8354 | || p->notify.subcode == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
8355 | && p->notify.length) | |
8356 | { | |
8357 | char msgbuf[1024]; | |
8358 | const char *msg_str; | |
8359 | ||
8360 | msg_str = bgp_notify_admin_message(msgbuf, sizeof(msgbuf), | |
8361 | (u_char*)p->notify.data, p->notify.length); | |
8362 | if (msg_str) | |
8363 | json_object_string_add(json_neigh, "lastShutdownDescription", msg_str); | |
8364 | } | |
856ca177 MS |
8365 | } |
8366 | } | |
8367 | else | |
d6661008 | 8368 | { |
3a8c7ba1 DW |
8369 | vty_out (vty, " Last reset %s, ", |
8370 | peer_uptime (p->resettime, timebuf, BGP_UPTIME_LEN, 0, NULL)); | |
8371 | ||
8372 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND || | |
8373 | p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) | |
8374 | { | |
8375 | code_str = bgp_notify_code_str(p->notify.code); | |
8376 | subcode_str = bgp_notify_subcode_str(p->notify.code, p->notify.subcode); | |
8377 | vty_out (vty, "due to NOTIFICATION %s (%s%s)%s", | |
8378 | p->last_reset == PEER_DOWN_NOTIFY_SEND ? "sent" : "received", | |
8379 | code_str, subcode_str, VTY_NEWLINE); | |
38de8d02 DL |
8380 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED |
8381 | && p->notify.code == BGP_NOTIFY_CEASE | |
8382 | && (p->notify.subcode == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
8383 | || p->notify.subcode == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
8384 | && p->notify.length) | |
8385 | { | |
8386 | char msgbuf[1024]; | |
8387 | const char *msg_str; | |
8388 | ||
8389 | msg_str = bgp_notify_admin_message(msgbuf, sizeof(msgbuf), | |
8390 | (u_char*)p->notify.data, p->notify.length); | |
8391 | if (msg_str) | |
8392 | vty_out (vty, " Message: \"%s\"%s", msg_str, VTY_NEWLINE); | |
8393 | } | |
3a8c7ba1 DW |
8394 | } |
8395 | else | |
8396 | { | |
8397 | vty_out (vty, "due to %s%s", | |
8398 | peer_down_str[(int) p->last_reset], VTY_NEWLINE); | |
8399 | } | |
856ca177 MS |
8400 | |
8401 | if (p->last_reset_cause_size) | |
d6661008 | 8402 | { |
856ca177 MS |
8403 | msg = p->last_reset_cause; |
8404 | vty_out(vty, " Message received that caused BGP to send a NOTIFICATION:%s ", VTY_NEWLINE); | |
8405 | for (i = 1; i <= p->last_reset_cause_size; i++) | |
8406 | { | |
8407 | vty_out(vty, "%02X", *msg++); | |
d6661008 | 8408 | |
856ca177 MS |
8409 | if (i != p->last_reset_cause_size) |
8410 | { | |
8411 | if (i % 16 == 0) | |
8412 | { | |
8413 | vty_out(vty, "%s ", VTY_NEWLINE); | |
8414 | } | |
8415 | else if (i % 4 == 0) | |
8416 | { | |
8417 | vty_out(vty, " "); | |
8418 | } | |
8419 | } | |
8420 | } | |
8421 | vty_out(vty, "%s", VTY_NEWLINE); | |
d6661008 | 8422 | } |
d6661008 DS |
8423 | } |
8424 | } | |
848973c7 | 8425 | |
718e3744 | 8426 | if (CHECK_FLAG (p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) |
8427 | { | |
856ca177 | 8428 | if (use_json) |
e08ac8b7 | 8429 | json_object_boolean_true_add(json_neigh, "prefixesConfigExceedMax"); |
856ca177 MS |
8430 | else |
8431 | vty_out (vty, " Peer had exceeded the max. no. of prefixes configured.%s", VTY_NEWLINE); | |
0a486e5f | 8432 | |
8433 | if (p->t_pmax_restart) | |
856ca177 MS |
8434 | { |
8435 | if (use_json) | |
8436 | { | |
e08ac8b7 DW |
8437 | json_object_boolean_true_add(json_neigh, "reducePrefixNumFrom"); |
8438 | json_object_int_add(json_neigh, "restartInTimerMsec", thread_timer_remain_second (p->t_pmax_restart) * 1000); | |
856ca177 MS |
8439 | } |
8440 | else | |
8441 | vty_out (vty, " Reduce the no. of prefix from %s, will restart in %ld seconds%s", | |
8442 | p->host, thread_timer_remain_second (p->t_pmax_restart), | |
8443 | VTY_NEWLINE); | |
8444 | } | |
0a486e5f | 8445 | else |
856ca177 MS |
8446 | { |
8447 | if (use_json) | |
e08ac8b7 | 8448 | json_object_boolean_true_add(json_neigh, "reducePrefixNumAndClearIpBgp"); |
856ca177 MS |
8449 | else |
8450 | vty_out (vty, " Reduce the no. of prefix and clear ip bgp %s to restore peering%s", | |
8451 | p->host, VTY_NEWLINE); | |
8452 | } | |
718e3744 | 8453 | } |
8454 | ||
f5a4827d | 8455 | /* EBGP Multihop and GTSM */ |
6d85b15b | 8456 | if (p->sort != BGP_PEER_IBGP) |
f5a4827d | 8457 | { |
856ca177 MS |
8458 | if (use_json) |
8459 | { | |
8460 | if (p->gtsm_hops > 0) | |
8461 | json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->gtsm_hops); | |
8462 | else if (p->ttl > 1) | |
8463 | json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->ttl); | |
8464 | } | |
8465 | else | |
8466 | { | |
8467 | if (p->gtsm_hops > 0) | |
8468 | vty_out (vty, " External BGP neighbor may be up to %d hops away.%s", | |
8469 | p->gtsm_hops, VTY_NEWLINE); | |
8470 | else if (p->ttl > 1) | |
8471 | vty_out (vty, " External BGP neighbor may be up to %d hops away.%s", | |
8472 | p->ttl, VTY_NEWLINE); | |
8473 | } | |
f5a4827d | 8474 | } |
5d804b43 PM |
8475 | else |
8476 | { | |
8477 | if (p->gtsm_hops > 0) | |
856ca177 MS |
8478 | { |
8479 | if (use_json) | |
8480 | json_object_int_add(json_neigh, "internalBgpNbrMaxHopsAway", p->gtsm_hops); | |
8481 | else | |
8482 | vty_out (vty, " Internal BGP neighbor may be up to %d hops away.%s", | |
8483 | p->gtsm_hops, VTY_NEWLINE); | |
8484 | } | |
5d804b43 | 8485 | } |
718e3744 | 8486 | |
8487 | /* Local address. */ | |
8488 | if (p->su_local) | |
8489 | { | |
856ca177 MS |
8490 | if (use_json) |
8491 | { | |
8492 | json_object_string_add(json_neigh, "hostLocal", sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN)); | |
8493 | json_object_int_add(json_neigh, "portLocal", ntohs (p->su_local->sin.sin_port)); | |
8494 | } | |
8495 | else | |
8496 | vty_out (vty, "Local host: %s, Local port: %d%s", | |
8497 | sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN), | |
8498 | ntohs (p->su_local->sin.sin_port), | |
8499 | VTY_NEWLINE); | |
718e3744 | 8500 | } |
e52702f2 | 8501 | |
718e3744 | 8502 | /* Remote address. */ |
8503 | if (p->su_remote) | |
8504 | { | |
856ca177 MS |
8505 | if (use_json) |
8506 | { | |
8507 | json_object_string_add(json_neigh, "hostForeign", sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN)); | |
8508 | json_object_int_add(json_neigh, "portForeign", ntohs (p->su_remote->sin.sin_port)); | |
8509 | } | |
8510 | else | |
8511 | vty_out (vty, "Foreign host: %s, Foreign port: %d%s", | |
718e3744 | 8512 | sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN), |
8513 | ntohs (p->su_remote->sin.sin_port), | |
8514 | VTY_NEWLINE); | |
8515 | } | |
8516 | ||
8517 | /* Nexthop display. */ | |
8518 | if (p->su_local) | |
8519 | { | |
856ca177 MS |
8520 | if (use_json) |
8521 | { | |
389e3fe0 | 8522 | json_object_string_add(json_neigh, "nexthop", |
44b8cd53 | 8523 | inet_ntop (AF_INET, &p->nexthop.v4, buf1, sizeof(buf1))); |
389e3fe0 | 8524 | json_object_string_add(json_neigh, "nexthopGlobal", |
44b8cd53 | 8525 | inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, sizeof(buf1))); |
389e3fe0 | 8526 | json_object_string_add(json_neigh, "nexthopLocal", |
44b8cd53 | 8527 | inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, sizeof(buf1))); |
856ca177 MS |
8528 | if (p->shared_network) |
8529 | json_object_string_add(json_neigh, "bgpConnection", "sharedNetwork"); | |
8530 | else | |
8531 | json_object_string_add(json_neigh, "bgpConnection", "nonSharedNetwork"); | |
856ca177 MS |
8532 | } |
8533 | else | |
8534 | { | |
8535 | vty_out (vty, "Nexthop: %s%s", | |
44b8cd53 DL |
8536 | inet_ntop (AF_INET, &p->nexthop.v4, buf1, sizeof(buf1)), |
8537 | VTY_NEWLINE); | |
856ca177 | 8538 | vty_out (vty, "Nexthop global: %s%s", |
44b8cd53 DL |
8539 | inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, sizeof(buf1)), |
8540 | VTY_NEWLINE); | |
856ca177 | 8541 | vty_out (vty, "Nexthop local: %s%s", |
44b8cd53 DL |
8542 | inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, sizeof(buf1)), |
8543 | VTY_NEWLINE); | |
856ca177 | 8544 | vty_out (vty, "BGP connection: %s%s", |
44b8cd53 DL |
8545 | p->shared_network ? "shared network" : "non shared network", |
8546 | VTY_NEWLINE); | |
856ca177 | 8547 | } |
718e3744 | 8548 | } |
8549 | ||
8550 | /* Timer information. */ | |
856ca177 MS |
8551 | if (use_json) |
8552 | { | |
39e871e6 | 8553 | json_object_int_add(json_neigh, "connectRetryTimer", p->v_connect); |
dd9275d6 ST |
8554 | if (p->status == Established && p->rtt) |
8555 | json_object_int_add(json_neigh, "estimatedRttInMsecs", p->rtt); | |
856ca177 MS |
8556 | if (p->t_start) |
8557 | json_object_int_add(json_neigh, "nextStartTimerDueInMsecs", thread_timer_remain_second (p->t_start) * 1000); | |
8558 | if (p->t_connect) | |
8559 | json_object_int_add(json_neigh, "nextConnectTimerDueInMsecs", thread_timer_remain_second (p->t_connect) * 1000); | |
8560 | if (p->t_routeadv) | |
8561 | { | |
8562 | json_object_int_add(json_neigh, "mraiInterval", p->v_routeadv); | |
8563 | json_object_int_add(json_neigh, "mraiTimerExpireInMsecs", thread_timer_remain_second (p->t_routeadv) * 1000); | |
8564 | } | |
cb1faec9 | 8565 | |
856ca177 MS |
8566 | if (p->t_read) |
8567 | json_object_string_add(json_neigh, "readThread", "on"); | |
8568 | else | |
8569 | json_object_string_add(json_neigh, "readThread", "off"); | |
8570 | if (p->t_write) | |
8571 | json_object_string_add(json_neigh, "writeThread", "on"); | |
8572 | else | |
8573 | json_object_string_add(json_neigh, "writeThread", "off"); | |
8574 | } | |
8575 | else | |
8576 | { | |
39e871e6 ST |
8577 | vty_out (vty, "BGP Connect Retry Timer in Seconds: %d%s", |
8578 | p->v_connect, VTY_NEWLINE); | |
dd9275d6 ST |
8579 | if (p->status == Established && p->rtt) |
8580 | vty_out (vty, "Estimated round trip time: %d ms%s", | |
8581 | p->rtt, VTY_NEWLINE); | |
856ca177 MS |
8582 | if (p->t_start) |
8583 | vty_out (vty, "Next start timer due in %ld seconds%s", | |
8584 | thread_timer_remain_second (p->t_start), VTY_NEWLINE); | |
8585 | if (p->t_connect) | |
8586 | vty_out (vty, "Next connect timer due in %ld seconds%s", | |
8587 | thread_timer_remain_second (p->t_connect), VTY_NEWLINE); | |
8588 | if (p->t_routeadv) | |
8589 | vty_out (vty, "MRAI (interval %u) timer expires in %ld seconds%s", | |
8590 | p->v_routeadv, thread_timer_remain_second (p->t_routeadv), | |
8591 | VTY_NEWLINE); | |
8592 | ||
8593 | vty_out (vty, "Read thread: %s Write thread: %s%s", | |
8594 | p->t_read ? "on" : "off", | |
8595 | p->t_write ? "on" : "off", | |
8596 | VTY_NEWLINE); | |
8597 | } | |
718e3744 | 8598 | |
8599 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
8600 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
856ca177 MS |
8601 | bgp_capability_vty_out (vty, p, use_json, json_neigh); |
8602 | ||
8603 | if (!use_json) | |
8604 | vty_out (vty, "%s", VTY_NEWLINE); | |
c43ed2e4 DS |
8605 | |
8606 | /* BFD information. */ | |
856ca177 MS |
8607 | bgp_bfd_show_info(vty, p, use_json, json_neigh); |
8608 | ||
8609 | if (use_json) | |
8610 | { | |
8611 | if (p->conf_if) /* Configured interface name. */ | |
8612 | json_object_object_add(json, p->conf_if, json_neigh); | |
8613 | else /* Configured IP address. */ | |
8614 | json_object_object_add(json, p->host, json_neigh); | |
8615 | } | |
718e3744 | 8616 | } |
8617 | ||
94f2b392 | 8618 | static int |
856ca177 MS |
8619 | bgp_show_neighbor (struct vty *vty, struct bgp *bgp, enum show_type type, |
8620 | union sockunion *su, const char *conf_if, u_char use_json, json_object *json) | |
718e3744 | 8621 | { |
1eb8ef25 | 8622 | struct listnode *node, *nnode; |
718e3744 | 8623 | struct peer *peer; |
8624 | int find = 0; | |
8625 | ||
1eb8ef25 | 8626 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
718e3744 | 8627 | { |
1ff9a340 DS |
8628 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
8629 | continue; | |
8630 | ||
718e3744 | 8631 | switch (type) |
856ca177 MS |
8632 | { |
8633 | case show_all: | |
e8f7da3a | 8634 | bgp_show_peer (vty, peer, use_json, json); |
856ca177 MS |
8635 | break; |
8636 | case show_peer: | |
8637 | if (conf_if) | |
8638 | { | |
4873b3b9 DW |
8639 | if ((peer->conf_if && !strcmp(peer->conf_if, conf_if)) || |
8640 | (peer->hostname && !strcmp(peer->hostname, conf_if))) | |
856ca177 MS |
8641 | { |
8642 | find = 1; | |
e8f7da3a | 8643 | bgp_show_peer (vty, peer, use_json, json); |
856ca177 MS |
8644 | } |
8645 | } | |
8646 | else | |
8647 | { | |
8648 | if (sockunion_same (&peer->su, su)) | |
8649 | { | |
8650 | find = 1; | |
e8f7da3a | 8651 | bgp_show_peer (vty, peer, use_json, json); |
856ca177 MS |
8652 | } |
8653 | } | |
8654 | break; | |
718e3744 | 8655 | } |
8656 | } | |
8657 | ||
8658 | if (type == show_peer && ! find) | |
856ca177 MS |
8659 | { |
8660 | if (use_json) | |
8661 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
8662 | else | |
8663 | vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE); | |
8664 | } | |
8665 | ||
8666 | if (use_json) | |
8667 | { | |
2aac5767 | 8668 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
856ca177 MS |
8669 | json_object_free(json); |
8670 | } | |
8671 | else | |
8672 | { | |
8673 | vty_out (vty, "%s", VTY_NEWLINE); | |
8674 | } | |
8675 | ||
718e3744 | 8676 | return CMD_SUCCESS; |
8677 | } | |
8678 | ||
f186de26 | 8679 | static void |
8680 | bgp_show_all_instances_neighbors_vty (struct vty *vty, u_char use_json) | |
8681 | { | |
8682 | struct listnode *node, *nnode; | |
8683 | struct bgp *bgp; | |
8684 | json_object *json = NULL; | |
9f689658 DD |
8685 | int is_first = 1; |
8686 | ||
8687 | if (use_json) | |
8688 | vty_out (vty, "{%s", VTY_NEWLINE); | |
f186de26 | 8689 | |
8690 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) | |
8691 | { | |
f186de26 | 8692 | if (use_json) |
9f689658 DD |
8693 | { |
8694 | if (!(json = json_object_new_object())) | |
8695 | { | |
8696 | zlog_err("Unable to allocate memory for JSON object"); | |
8697 | vty_out (vty, | |
8698 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}%s", | |
8699 | VTY_NEWLINE); | |
8700 | return; | |
8701 | } | |
8702 | ||
8703 | json_object_int_add(json, "vrfId", | |
8704 | (bgp->vrf_id == VRF_UNKNOWN) | |
8705 | ? -1 : bgp->vrf_id); | |
8706 | json_object_string_add(json, "vrfName", | |
8707 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
8708 | ? "Default" : bgp->name); | |
8709 | ||
8710 | if (! is_first) | |
8711 | vty_out (vty, ",%s", VTY_NEWLINE); | |
8712 | else | |
8713 | is_first = 0; | |
8714 | ||
8715 | vty_out(vty, "\"%s\":", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
8716 | ? "Default" : bgp->name); | |
8717 | } | |
8718 | else | |
8719 | { | |
8720 | vty_out (vty, "%sInstance %s:%s", | |
8721 | VTY_NEWLINE, | |
8722 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
8723 | ? "Default" : bgp->name, | |
8724 | VTY_NEWLINE); | |
8725 | } | |
f186de26 | 8726 | bgp_show_neighbor (vty, bgp, show_all, NULL, NULL, use_json, json); |
8727 | } | |
9f689658 DD |
8728 | |
8729 | if (use_json) | |
8730 | vty_out (vty, "}%s", VTY_NEWLINE); | |
f186de26 | 8731 | } |
8732 | ||
4fb25c53 DW |
8733 | static int |
8734 | bgp_show_neighbor_vty (struct vty *vty, const char *name, | |
8735 | enum show_type type, const char *ip_str, u_char use_json) | |
8736 | { | |
8737 | int ret; | |
8738 | struct bgp *bgp; | |
8739 | union sockunion su; | |
8740 | json_object *json = NULL; | |
8741 | ||
8742 | if (use_json) | |
8743 | json = json_object_new_object(); | |
8744 | ||
8745 | if (name) | |
8746 | { | |
8747 | if (strmatch(name, "all")) | |
8748 | { | |
8749 | bgp_show_all_instances_neighbors_vty (vty, use_json); | |
8750 | return CMD_SUCCESS; | |
8751 | } | |
8752 | else | |
8753 | { | |
8754 | bgp = bgp_lookup_by_name (name); | |
8755 | if (! bgp) | |
8756 | { | |
8757 | if (use_json) | |
8758 | { | |
8759 | json_object_boolean_true_add(json, "bgpNoSuchInstance"); | |
e52702f2 | 8760 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
4fb25c53 DW |
8761 | json_object_free(json); |
8762 | } | |
8763 | else | |
8764 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
8765 | ||
8766 | return CMD_WARNING; | |
8767 | } | |
8768 | } | |
8769 | } | |
8770 | else | |
8771 | { | |
8772 | bgp = bgp_get_default (); | |
8773 | } | |
8774 | ||
8775 | if (bgp) | |
8776 | { | |
8777 | if (ip_str) | |
8778 | { | |
8779 | ret = str2sockunion (ip_str, &su); | |
8780 | if (ret < 0) | |
8781 | bgp_show_neighbor (vty, bgp, type, NULL, ip_str, use_json, json); | |
8782 | else | |
8783 | bgp_show_neighbor (vty, bgp, type, &su, NULL, use_json, json); | |
8784 | } | |
8785 | else | |
8786 | { | |
8787 | bgp_show_neighbor (vty, bgp, type, NULL, NULL, use_json, json); | |
8788 | } | |
8789 | } | |
8790 | ||
8791 | return CMD_SUCCESS; | |
8792 | } | |
8793 | ||
716b2d8a | 8794 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 8795 | DEFUN (show_ip_bgp_neighbors, |
8796 | show_ip_bgp_neighbors_cmd, | |
91d37724 | 8797 | "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 | 8798 | SHOW_STR |
8799 | IP_STR | |
8800 | BGP_STR | |
f2a8972b | 8801 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
8802 | "Address Family\n" |
8803 | "Address Family\n" | |
91d37724 QY |
8804 | "Address Family\n" |
8805 | "Display information about all VPNv4 NLRIs\n" | |
8806 | "Display information for a route distinguisher\n" | |
8807 | "VPN Route Distinguisher\n" | |
718e3744 | 8808 | "Detailed information on TCP and BGP neighbor connections\n" |
8809 | "Neighbor to display information about\n" | |
a80beece | 8810 | "Neighbor to display information about\n" |
91d37724 | 8811 | "Neighbor on BGP configured interface\n" |
9973d184 | 8812 | JSON_STR) |
718e3744 | 8813 | { |
5bf15956 DW |
8814 | char *vrf = NULL; |
8815 | char *sh_arg = NULL; | |
8816 | enum show_type sh_type; | |
718e3744 | 8817 | |
5bf15956 | 8818 | u_char uj = use_json(argc, argv); |
718e3744 | 8819 | |
630a298c | 8820 | int idx = 0; |
718e3744 | 8821 | |
630a298c QY |
8822 | if (argv_find (argv, argc, "WORD", &idx)) |
8823 | vrf = argv[idx]->arg; | |
718e3744 | 8824 | |
91d37724 QY |
8825 | if (argv_find (argv, argc, "A.B.C.D", &idx) || |
8826 | argv_find (argv, argc, "X:X::X:X", &idx) || | |
630a298c QY |
8827 | argv_find (argv, argc, "WORD", &idx)) |
8828 | { | |
8829 | sh_type = show_peer; | |
8830 | sh_arg = argv[idx]->arg; | |
8831 | } | |
5bf15956 | 8832 | else |
630a298c | 8833 | sh_type = show_all; |
856ca177 | 8834 | |
5bf15956 | 8835 | return bgp_show_neighbor_vty (vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 8836 | } |
8837 | ||
716b2d8a | 8838 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 8839 | paths' and `show ip mbgp paths'. Those functions results are the |
8840 | same.*/ | |
f412b39a | 8841 | DEFUN (show_ip_bgp_paths, |
718e3744 | 8842 | show_ip_bgp_paths_cmd, |
46f296b4 | 8843 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 8844 | SHOW_STR |
8845 | IP_STR | |
8846 | BGP_STR | |
46f296b4 | 8847 | BGP_SAFI_HELP_STR |
718e3744 | 8848 | "Path information\n") |
8849 | { | |
8850 | vty_out (vty, "Address Refcnt Path%s", VTY_NEWLINE); | |
8851 | aspath_print_all_vty (vty); | |
8852 | return CMD_SUCCESS; | |
8853 | } | |
8854 | ||
718e3744 | 8855 | #include "hash.h" |
8856 | ||
94f2b392 | 8857 | static void |
718e3744 | 8858 | community_show_all_iterator (struct hash_backet *backet, struct vty *vty) |
8859 | { | |
8860 | struct community *com; | |
8861 | ||
8862 | com = (struct community *) backet->data; | |
6c4f4e6e | 8863 | vty_out (vty, "[%p] (%ld) %s%s", (void *)backet, com->refcnt, |
718e3744 | 8864 | community_str (com), VTY_NEWLINE); |
8865 | } | |
8866 | ||
8867 | /* Show BGP's community internal data. */ | |
f412b39a | 8868 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 8869 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 8870 | "show [ip] bgp community-info", |
718e3744 | 8871 | SHOW_STR |
8872 | IP_STR | |
8873 | BGP_STR | |
8874 | "List all bgp community information\n") | |
8875 | { | |
8876 | vty_out (vty, "Address Refcnt Community%s", VTY_NEWLINE); | |
8877 | ||
e52702f2 | 8878 | hash_iterate (community_hash (), |
718e3744 | 8879 | (void (*) (struct hash_backet *, void *)) |
8880 | community_show_all_iterator, | |
8881 | vty); | |
8882 | ||
8883 | return CMD_SUCCESS; | |
8884 | } | |
8885 | ||
57d187bc JS |
8886 | static void |
8887 | lcommunity_show_all_iterator (struct hash_backet *backet, struct vty *vty) | |
8888 | { | |
8889 | struct lcommunity *lcom; | |
8890 | ||
8891 | lcom = (struct lcommunity *) backet->data; | |
8892 | vty_out (vty, "[%p] (%ld) %s%s", (void *)backet, lcom->refcnt, | |
2acb4ac2 | 8893 | lcommunity_str (lcom), VTY_NEWLINE); |
57d187bc JS |
8894 | } |
8895 | ||
8896 | /* Show BGP's community internal data. */ | |
8897 | DEFUN (show_ip_bgp_lcommunity_info, | |
8898 | show_ip_bgp_lcommunity_info_cmd, | |
8899 | "show ip bgp large-community-info", | |
8900 | SHOW_STR | |
8901 | IP_STR | |
8902 | BGP_STR | |
8903 | "List all bgp large-community information\n") | |
8904 | { | |
8905 | vty_out (vty, "Address Refcnt Large-community%s", VTY_NEWLINE); | |
8906 | ||
8907 | hash_iterate (lcommunity_hash (), | |
2acb4ac2 DL |
8908 | (void (*) (struct hash_backet *, void *)) |
8909 | lcommunity_show_all_iterator, | |
8910 | vty); | |
57d187bc JS |
8911 | |
8912 | return CMD_SUCCESS; | |
8913 | } | |
8914 | ||
8915 | ||
f412b39a | 8916 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 8917 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 8918 | "show [ip] bgp attribute-info", |
718e3744 | 8919 | SHOW_STR |
8920 | IP_STR | |
8921 | BGP_STR | |
8922 | "List all bgp attribute information\n") | |
8923 | { | |
8924 | attr_show_all (vty); | |
8925 | return CMD_SUCCESS; | |
8926 | } | |
6b0655a2 | 8927 | |
f186de26 | 8928 | static void |
8929 | bgp_show_all_instances_updgrps_vty (struct vty *vty, afi_t afi, safi_t safi) | |
8930 | { | |
8931 | struct listnode *node, *nnode; | |
8932 | struct bgp *bgp; | |
8933 | ||
8934 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) | |
8935 | { | |
8936 | vty_out (vty, "%sInstance %s:%s", | |
8937 | VTY_NEWLINE, | |
8938 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) ? "Default" : bgp->name, | |
8939 | VTY_NEWLINE); | |
8940 | update_group_show(bgp, afi, safi, vty, 0); | |
8941 | } | |
8942 | } | |
8943 | ||
4fb25c53 DW |
8944 | static int |
8945 | bgp_show_update_groups(struct vty *vty, const char *name, | |
8946 | int afi, int safi, | |
8947 | uint64_t subgrp_id) | |
8948 | { | |
8949 | struct bgp *bgp; | |
8950 | ||
8951 | if (name) | |
8952 | { | |
8953 | if (strmatch (name, "all")) | |
8954 | { | |
8955 | bgp_show_all_instances_updgrps_vty (vty, afi, safi); | |
8956 | return CMD_SUCCESS; | |
8957 | } | |
8958 | else | |
8959 | { | |
8960 | bgp = bgp_lookup_by_name (name); | |
8961 | } | |
8962 | } | |
8963 | else | |
8964 | { | |
8965 | bgp = bgp_get_default (); | |
8966 | } | |
8967 | ||
8968 | if (bgp) | |
8969 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
8970 | return CMD_SUCCESS; | |
8971 | } | |
8972 | ||
8fe8a7f6 DS |
8973 | DEFUN (show_ip_bgp_updgrps, |
8974 | show_ip_bgp_updgrps_cmd, | |
c9e571b4 | 8975 | "show [ip] bgp [<view|vrf> WORD] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 8976 | SHOW_STR |
8977 | IP_STR | |
8978 | BGP_STR | |
8979 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 8980 | BGP_AFI_HELP_STR |
46f296b4 | 8981 | BGP_SAFI_HELP_STR |
5bf15956 DW |
8982 | "Detailed info about dynamic update groups\n" |
8983 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 8984 | { |
5bf15956 | 8985 | char *vrf = NULL; |
ae19d7dd QY |
8986 | afi_t afi = AFI_IP6; |
8987 | safi_t safi = SAFI_UNICAST; | |
5bf15956 DW |
8988 | uint64_t subgrp_id = 0; |
8989 | ||
ae19d7dd QY |
8990 | int idx = 0; |
8991 | ||
8992 | /* show [ip] bgp */ | |
8993 | if (argv_find (argv, argc, "ip", &idx)) | |
8994 | afi = AFI_IP; | |
8995 | /* [<view|vrf> WORD] */ | |
8996 | if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) | |
8997 | vrf = argv[++idx]->arg; | |
c9e571b4 LB |
8998 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
8999 | if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) | |
9000 | { | |
9001 | argv_find_and_parse_safi (argv, argc, &idx, &safi); | |
9002 | } | |
5bf15956 | 9003 | |
ae19d7dd QY |
9004 | /* get subgroup id, if provided */ |
9005 | idx = argc - 1; | |
9006 | if (argv[idx]->type == VARIABLE_TKN) | |
9007 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx]->arg); | |
5bf15956 DW |
9008 | |
9009 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); | |
8fe8a7f6 DS |
9010 | } |
9011 | ||
f186de26 | 9012 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
9013 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 9014 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 9015 | SHOW_STR |
716b2d8a | 9016 | IP_STR |
f186de26 | 9017 | BGP_STR |
9018 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 9019 | "Detailed info about dynamic update groups\n") |
f186de26 | 9020 | { |
9021 | bgp_show_all_instances_updgrps_vty (vty, AFI_IP6, SAFI_UNICAST); | |
9022 | return CMD_SUCCESS; | |
9023 | } | |
9024 | ||
5bf15956 DW |
9025 | DEFUN (show_bgp_updgrps_stats, |
9026 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 9027 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 9028 | SHOW_STR |
716b2d8a | 9029 | IP_STR |
3f9c7369 | 9030 | BGP_STR |
0c7b1b01 | 9031 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
9032 | "Statistics\n") |
9033 | { | |
9034 | struct bgp *bgp; | |
9035 | ||
9036 | bgp = bgp_get_default(); | |
9037 | if (bgp) | |
9038 | update_group_show_stats(bgp, vty); | |
9039 | ||
9040 | return CMD_SUCCESS; | |
9041 | } | |
9042 | ||
8386ac43 | 9043 | DEFUN (show_bgp_instance_updgrps_stats, |
9044 | show_bgp_instance_updgrps_stats_cmd, | |
716b2d8a | 9045 | "show [ip] bgp <view|vrf> WORD update-groups statistics", |
8386ac43 | 9046 | SHOW_STR |
716b2d8a | 9047 | IP_STR |
8386ac43 | 9048 | BGP_STR |
9049 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 9050 | "Detailed info about dynamic update groups\n" |
8386ac43 | 9051 | "Statistics\n") |
9052 | { | |
c500ae40 | 9053 | int idx_word = 3; |
8386ac43 | 9054 | struct bgp *bgp; |
9055 | ||
c500ae40 | 9056 | bgp = bgp_lookup_by_name (argv[idx_word]->arg); |
8386ac43 | 9057 | if (bgp) |
9058 | update_group_show_stats(bgp, vty); | |
9059 | ||
9060 | return CMD_SUCCESS; | |
9061 | } | |
9062 | ||
3f9c7369 | 9063 | static void |
8386ac43 | 9064 | show_bgp_updgrps_adj_info_aux (struct vty *vty, const char *name, |
9065 | afi_t afi, safi_t safi, | |
f43e655e | 9066 | const char *what, uint64_t subgrp_id) |
3f9c7369 DS |
9067 | { |
9068 | struct bgp *bgp; | |
8386ac43 | 9069 | |
9070 | if (name) | |
9071 | bgp = bgp_lookup_by_name (name); | |
9072 | else | |
9073 | bgp = bgp_get_default (); | |
9074 | ||
3f9c7369 DS |
9075 | if (bgp) |
9076 | { | |
9077 | if (!strcmp(what, "advertise-queue")) | |
9078 | update_group_show_adj_queue(bgp, afi, safi, vty, subgrp_id); | |
9079 | else if (!strcmp(what, "advertised-routes")) | |
9080 | update_group_show_advertised(bgp, afi, safi, vty, subgrp_id); | |
9081 | else if (!strcmp(what, "packet-queue")) | |
9082 | update_group_show_packet_queue(bgp, afi, safi, vty, subgrp_id); | |
9083 | } | |
9084 | } | |
9085 | ||
9086 | DEFUN (show_ip_bgp_updgrps_adj, | |
9087 | show_ip_bgp_updgrps_adj_cmd, | |
716b2d8a | 9088 | "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 DS |
9089 | SHOW_STR |
9090 | IP_STR | |
9091 | BGP_STR | |
0c7b1b01 | 9092 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
9093 | "Advertisement queue\n" |
9094 | "Announced routes\n" | |
9095 | "Packet queue\n") | |
8fe8a7f6 | 9096 | |
3f9c7369 | 9097 | { |
c500ae40 DW |
9098 | int idx_type = 4; |
9099 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
8386ac43 | 9100 | return CMD_SUCCESS; |
9101 | } | |
9102 | ||
9103 | DEFUN (show_ip_bgp_instance_updgrps_adj, | |
9104 | show_ip_bgp_instance_updgrps_adj_cmd, | |
716b2d8a | 9105 | "show [ip] bgp <view|vrf> WORD update-groups <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 9106 | SHOW_STR |
9107 | IP_STR | |
9108 | BGP_STR | |
9109 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 9110 | "Detailed info about dynamic update groups\n" |
8386ac43 | 9111 | "Advertisement queue\n" |
9112 | "Announced routes\n" | |
9113 | "Packet queue\n") | |
9114 | ||
9115 | { | |
c500ae40 DW |
9116 | int idx_word = 4; |
9117 | int idx_type = 6; | |
9118 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
3f9c7369 DS |
9119 | return CMD_SUCCESS; |
9120 | } | |
9121 | ||
9122 | DEFUN (show_bgp_updgrps_afi_adj, | |
9123 | show_bgp_updgrps_afi_adj_cmd, | |
46f296b4 | 9124 | "show [ip] bgp "BGP_AFI_SAFI_CMD_STR" update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 9125 | SHOW_STR |
716b2d8a | 9126 | IP_STR |
3f9c7369 | 9127 | BGP_STR |
46f296b4 | 9128 | BGP_AFI_SAFI_HELP_STR |
0c7b1b01 | 9129 | "Detailed info about dynamic update groups\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; | |
9137 | int idx_type = 5; | |
46f296b4 LB |
9138 | show_bgp_updgrps_adj_info_aux(vty, NULL, |
9139 | bgp_vty_afi_from_arg(argv[idx_afi]->arg), | |
9140 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), | |
9141 | argv[idx_type]->arg, 0); | |
8fe8a7f6 | 9142 | return CMD_SUCCESS; |
3f9c7369 DS |
9143 | } |
9144 | ||
9145 | DEFUN (show_bgp_updgrps_adj, | |
9146 | show_bgp_updgrps_adj_cmd, | |
716b2d8a | 9147 | "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 9148 | SHOW_STR |
716b2d8a | 9149 | IP_STR |
3f9c7369 | 9150 | BGP_STR |
0c7b1b01 | 9151 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
9152 | "Advertisement queue\n" |
9153 | "Announced routes\n" | |
9154 | "Packet queue\n") | |
9155 | { | |
c500ae40 DW |
9156 | int idx_type = 3; |
9157 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
8386ac43 | 9158 | return CMD_SUCCESS; |
9159 | } | |
9160 | ||
9161 | DEFUN (show_bgp_instance_updgrps_adj, | |
9162 | show_bgp_instance_updgrps_adj_cmd, | |
716b2d8a | 9163 | "show [ip] bgp <view|vrf> WORD update-groups <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 9164 | SHOW_STR |
716b2d8a | 9165 | IP_STR |
8386ac43 | 9166 | BGP_STR |
9167 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 9168 | "Detailed info about dynamic update groups\n" |
8386ac43 | 9169 | "Advertisement queue\n" |
9170 | "Announced routes\n" | |
9171 | "Packet queue\n") | |
9172 | { | |
c500ae40 DW |
9173 | int idx_word = 3; |
9174 | int idx_type = 5; | |
9175 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
3f9c7369 DS |
9176 | return CMD_SUCCESS; |
9177 | } | |
9178 | ||
9179 | DEFUN (show_ip_bgp_updgrps_adj_s, | |
8fe8a7f6 | 9180 | show_ip_bgp_updgrps_adj_s_cmd, |
716b2d8a | 9181 | "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 DS |
9182 | SHOW_STR |
9183 | IP_STR | |
9184 | BGP_STR | |
0c7b1b01 | 9185 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 | 9186 | "Specific subgroup to display info for\n" |
3f9c7369 DS |
9187 | "Advertisement queue\n" |
9188 | "Announced routes\n" | |
9189 | "Packet queue\n") | |
3f9c7369 | 9190 | |
3f9c7369 | 9191 | { |
5bf15956 | 9192 | int idx_subgroup_id = 4; |
c500ae40 | 9193 | int idx_type = 5; |
f43e655e | 9194 | uint64_t subgrp_id; |
8fe8a7f6 | 9195 | |
5bf15956 | 9196 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8fe8a7f6 | 9197 | |
5bf15956 | 9198 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
8386ac43 | 9199 | return CMD_SUCCESS; |
9200 | } | |
9201 | ||
9202 | DEFUN (show_ip_bgp_instance_updgrps_adj_s, | |
9203 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
716b2d8a | 9204 | "show [ip] bgp <view|vrf> WORD update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 9205 | SHOW_STR |
9206 | IP_STR | |
9207 | BGP_STR | |
9208 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 9209 | "Detailed info about dynamic update groups\n" |
8386ac43 | 9210 | "Specific subgroup to display info for\n" |
9211 | "Advertisement queue\n" | |
9212 | "Announced routes\n" | |
9213 | "Packet queue\n") | |
9214 | ||
9215 | { | |
5bf15956 DW |
9216 | int idx_vrf = 4; |
9217 | int idx_subgroup_id = 6; | |
c500ae40 | 9218 | int idx_type = 7; |
f43e655e | 9219 | uint64_t subgrp_id; |
8386ac43 | 9220 | |
5bf15956 | 9221 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8386ac43 | 9222 | |
5bf15956 | 9223 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
3f9c7369 DS |
9224 | return CMD_SUCCESS; |
9225 | } | |
9226 | ||
8fe8a7f6 DS |
9227 | DEFUN (show_bgp_updgrps_afi_adj_s, |
9228 | show_bgp_updgrps_afi_adj_s_cmd, | |
46f296b4 | 9229 | "show [ip] bgp "BGP_AFI_SAFI_CMD_STR" update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 9230 | SHOW_STR |
716b2d8a | 9231 | IP_STR |
3f9c7369 | 9232 | BGP_STR |
46f296b4 | 9233 | BGP_AFI_SAFI_HELP_STR |
0c7b1b01 | 9234 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 | 9235 | "Specific subgroup to display info for\n" |
3f9c7369 DS |
9236 | "Advertisement queue\n" |
9237 | "Announced routes\n" | |
8fe8a7f6 DS |
9238 | "Packet queue\n" |
9239 | "Specific subgroup info wanted for\n") | |
3f9c7369 | 9240 | { |
c500ae40 DW |
9241 | int idx_afi = 2; |
9242 | int idx_safi = 3; | |
5bf15956 | 9243 | int idx_subgroup_id = 5; |
c500ae40 | 9244 | int idx_type = 6; |
f43e655e | 9245 | uint64_t subgrp_id; |
3f9c7369 | 9246 | |
5bf15956 | 9247 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8fe8a7f6 | 9248 | |
46f296b4 LB |
9249 | show_bgp_updgrps_adj_info_aux(vty, NULL, |
9250 | bgp_vty_afi_from_arg(argv[idx_afi]->arg), | |
9251 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), | |
9252 | argv[idx_type]->arg, subgrp_id); | |
8fe8a7f6 | 9253 | return CMD_SUCCESS; |
3f9c7369 DS |
9254 | } |
9255 | ||
8fe8a7f6 DS |
9256 | DEFUN (show_bgp_updgrps_adj_s, |
9257 | show_bgp_updgrps_adj_s_cmd, | |
716b2d8a | 9258 | "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8fe8a7f6 | 9259 | SHOW_STR |
716b2d8a | 9260 | IP_STR |
8fe8a7f6 | 9261 | BGP_STR |
0c7b1b01 | 9262 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 DS |
9263 | "Specific subgroup to display info for\n" |
9264 | "Advertisement queue\n" | |
9265 | "Announced routes\n" | |
9266 | "Packet queue\n") | |
9267 | { | |
5bf15956 | 9268 | int idx_subgroup_id = 3; |
c500ae40 | 9269 | int idx_type = 4; |
f43e655e | 9270 | uint64_t subgrp_id; |
8fe8a7f6 | 9271 | |
5bf15956 | 9272 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8fe8a7f6 | 9273 | |
5bf15956 | 9274 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
8fe8a7f6 DS |
9275 | return CMD_SUCCESS; |
9276 | } | |
9277 | ||
8386ac43 | 9278 | DEFUN (show_bgp_instance_updgrps_adj_s, |
9279 | show_bgp_instance_updgrps_adj_s_cmd, | |
716b2d8a | 9280 | "show [ip] bgp <view|vrf> WORD update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 9281 | SHOW_STR |
716b2d8a | 9282 | IP_STR |
8386ac43 | 9283 | BGP_STR |
9284 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 9285 | "Detailed info about dynamic update groups\n" |
8386ac43 | 9286 | "Specific subgroup to display info for\n" |
9287 | "Advertisement queue\n" | |
9288 | "Announced routes\n" | |
9289 | "Packet queue\n") | |
9290 | { | |
5bf15956 DW |
9291 | int idx_vrf = 3; |
9292 | int idx_subgroup_id = 5; | |
c500ae40 | 9293 | int idx_type = 6; |
f43e655e | 9294 | uint64_t subgrp_id; |
8386ac43 | 9295 | |
5bf15956 | 9296 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8386ac43 | 9297 | |
5bf15956 | 9298 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
8386ac43 | 9299 | return CMD_SUCCESS; |
9300 | } | |
9301 | ||
9302 | ||
8fe8a7f6 | 9303 | |
f14e6fdb DS |
9304 | static int |
9305 | bgp_show_one_peer_group (struct vty *vty, struct peer_group *group) | |
9306 | { | |
9307 | struct listnode *node, *nnode; | |
9308 | struct prefix *range; | |
9309 | struct peer *conf; | |
9310 | struct peer *peer; | |
4690c7d7 | 9311 | char buf[PREFIX2STR_BUFFER]; |
f14e6fdb DS |
9312 | afi_t afi; |
9313 | safi_t safi; | |
ffd0c037 DS |
9314 | const char *peer_status; |
9315 | const char *af_str; | |
f14e6fdb DS |
9316 | int lr_count; |
9317 | int dynamic; | |
9318 | int af_cfgd; | |
9319 | ||
9320 | conf = group->conf; | |
9321 | ||
0299c004 DS |
9322 | if (conf->as_type == AS_SPECIFIED || |
9323 | conf->as_type == AS_EXTERNAL) { | |
66b199b2 | 9324 | vty_out (vty, "%sBGP peer-group %s, remote AS %d%s", |
f14e6fdb | 9325 | VTY_NEWLINE, group->name, conf->as, VTY_NEWLINE); |
0299c004 | 9326 | } else if (conf->as_type == AS_INTERNAL) { |
66b199b2 | 9327 | vty_out (vty, "%sBGP peer-group %s, remote AS %d%s", |
0299c004 | 9328 | VTY_NEWLINE, group->name, group->bgp->as, VTY_NEWLINE); |
66b199b2 DS |
9329 | } else { |
9330 | vty_out (vty, "%sBGP peer-group %s%s", | |
9331 | VTY_NEWLINE, group->name, VTY_NEWLINE); | |
0299c004 | 9332 | } |
f14e6fdb | 9333 | |
0299c004 | 9334 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
f14e6fdb DS |
9335 | vty_out (vty, " Peer-group type is internal%s", VTY_NEWLINE); |
9336 | else | |
9337 | vty_out (vty, " Peer-group type is external%s", VTY_NEWLINE); | |
9338 | ||
9339 | /* Display AFs configured. */ | |
9340 | vty_out (vty, " Configured address-families:"); | |
9341 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
9342 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
9343 | { | |
9344 | if (conf->afc[afi][safi]) | |
9345 | { | |
9346 | af_cfgd = 1; | |
9347 | vty_out (vty, " %s;", afi_safi_print(afi, safi)); | |
9348 | } | |
9349 | } | |
9350 | if (!af_cfgd) | |
9351 | vty_out (vty, " none%s", VTY_NEWLINE); | |
9352 | else | |
9353 | vty_out (vty, "%s", VTY_NEWLINE); | |
9354 | ||
9355 | /* Display listen ranges (for dynamic neighbors), if any */ | |
9356 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
9357 | { | |
9358 | if (afi == AFI_IP) | |
9359 | af_str = "IPv4"; | |
9360 | else if (afi == AFI_IP6) | |
9361 | af_str = "IPv6"; | |
45ef4300 DL |
9362 | else |
9363 | af_str = "???"; | |
f14e6fdb DS |
9364 | lr_count = listcount(group->listen_range[afi]); |
9365 | if (lr_count) | |
9366 | { | |
9367 | vty_out(vty, | |
9368 | " %d %s listen range(s)%s", | |
9369 | lr_count, af_str, VTY_NEWLINE); | |
9370 | ||
9371 | ||
9372 | for (ALL_LIST_ELEMENTS (group->listen_range[afi], node, | |
9373 | nnode, range)) | |
9374 | { | |
9375 | prefix2str(range, buf, sizeof(buf)); | |
9376 | vty_out(vty, " %s%s", buf, VTY_NEWLINE); | |
9377 | } | |
9378 | } | |
9379 | } | |
9380 | ||
9381 | /* Display group members and their status */ | |
9382 | if (listcount(group->peer)) | |
9383 | { | |
9384 | vty_out (vty, " Peer-group members:%s", VTY_NEWLINE); | |
9385 | for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) | |
9386 | { | |
9387 | if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) | |
9388 | peer_status = "Idle (Admin)"; | |
9389 | else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) | |
9390 | peer_status = "Idle (PfxCt)"; | |
9391 | else | |
9392 | peer_status = LOOKUP(bgp_status_msg, peer->status); | |
9393 | ||
9394 | dynamic = peer_dynamic_neighbor(peer); | |
9395 | vty_out (vty, " %s %s %s %s", | |
9396 | peer->host, dynamic ? "(dynamic)" : "", | |
9397 | peer_status, VTY_NEWLINE); | |
9398 | } | |
9399 | } | |
9400 | ||
9401 | return CMD_SUCCESS; | |
9402 | } | |
9403 | ||
9404 | /* Show BGP peer group's information. */ | |
9405 | enum show_group_type | |
9406 | { | |
9407 | show_all_groups, | |
9408 | show_peer_group | |
9409 | }; | |
9410 | ||
9411 | static int | |
9412 | bgp_show_peer_group (struct vty *vty, struct bgp *bgp, | |
9413 | enum show_group_type type, const char *group_name) | |
9414 | { | |
9415 | struct listnode *node, *nnode; | |
9416 | struct peer_group *group; | |
9417 | int find = 0; | |
9418 | ||
9419 | for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) | |
9420 | { | |
9421 | switch (type) | |
9422 | { | |
9423 | case show_all_groups: | |
9424 | bgp_show_one_peer_group (vty, group); | |
9425 | break; | |
9426 | case show_peer_group: | |
9427 | if (group_name && (strcmp(group->name, group_name) == 0)) | |
9428 | { | |
9429 | find = 1; | |
9430 | bgp_show_one_peer_group (vty, group); | |
9431 | } | |
9432 | break; | |
9433 | } | |
9434 | } | |
9435 | ||
9436 | if (type == show_peer_group && ! find) | |
6d9e66dc | 9437 | vty_out (vty, "%% No such peer-group%s", VTY_NEWLINE); |
f14e6fdb DS |
9438 | |
9439 | return CMD_SUCCESS; | |
9440 | } | |
9441 | ||
9442 | static int | |
9443 | bgp_show_peer_group_vty (struct vty *vty, const char *name, | |
9444 | enum show_group_type type, const char *group_name) | |
9445 | { | |
9446 | struct bgp *bgp; | |
9447 | int ret = CMD_SUCCESS; | |
9448 | ||
9449 | if (name) | |
8386ac43 | 9450 | bgp = bgp_lookup_by_name (name); |
9451 | else | |
9452 | bgp = bgp_get_default (); | |
f14e6fdb | 9453 | |
8386ac43 | 9454 | if (! bgp) |
9455 | { | |
9456 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
9457 | return CMD_WARNING; | |
f14e6fdb DS |
9458 | } |
9459 | ||
8386ac43 | 9460 | ret = bgp_show_peer_group (vty, bgp, type, group_name); |
f14e6fdb DS |
9461 | |
9462 | return ret; | |
9463 | } | |
9464 | ||
9465 | DEFUN (show_ip_bgp_peer_groups, | |
9466 | show_ip_bgp_peer_groups_cmd, | |
f2a8972b | 9467 | "show [ip] bgp [<view|vrf> WORD] peer-group [PGNAME]", |
f14e6fdb DS |
9468 | SHOW_STR |
9469 | IP_STR | |
9470 | BGP_STR | |
8386ac43 | 9471 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
9472 | "Detailed information on BGP peer groups\n" |
9473 | "Peer group name\n") | |
f14e6fdb | 9474 | { |
d6e3c605 QY |
9475 | char *vrf, *pg; |
9476 | vrf = pg = NULL; | |
9477 | int idx = 0; | |
f14e6fdb | 9478 | |
f2a8972b | 9479 | vrf = argv_find (argv, argc, "WORD", &idx) ? argv[idx]->arg : NULL; |
d6e3c605 | 9480 | pg = argv_find (argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 9481 | |
d6e3c605 | 9482 | return bgp_show_peer_group_vty (vty, vrf, show_all_groups, pg); |
f14e6fdb | 9483 | } |
3f9c7369 | 9484 | |
d6e3c605 | 9485 | |
718e3744 | 9486 | /* Redistribute VTY commands. */ |
9487 | ||
718e3744 | 9488 | DEFUN (bgp_redistribute_ipv4, |
9489 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 9490 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 9491 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9492 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 9493 | { |
cdc2d765 | 9494 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 9495 | int idx_protocol = 1; |
718e3744 | 9496 | int type; |
9497 | ||
6d681bd8 QY |
9498 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9499 | if (type < 0) | |
718e3744 | 9500 | { |
9501 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9502 | return CMD_WARNING; | |
9503 | } | |
cdc2d765 DL |
9504 | bgp_redist_add(bgp, AFI_IP, type, 0); |
9505 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); | |
718e3744 | 9506 | } |
9507 | ||
9508 | DEFUN (bgp_redistribute_ipv4_rmap, | |
9509 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 9510 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 9511 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9512 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 9513 | "Route map reference\n" |
9514 | "Pointer to route-map entries\n") | |
9515 | { | |
cdc2d765 | 9516 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9517 | int idx_protocol = 1; |
9518 | int idx_word = 3; | |
718e3744 | 9519 | int type; |
7c8ff89e | 9520 | struct bgp_redist *red; |
718e3744 | 9521 | |
6d681bd8 QY |
9522 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9523 | if (type < 0) | |
718e3744 | 9524 | { |
9525 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9526 | return CMD_WARNING; | |
9527 | } | |
9528 | ||
cdc2d765 | 9529 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
c500ae40 | 9530 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9531 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); |
718e3744 | 9532 | } |
9533 | ||
9534 | DEFUN (bgp_redistribute_ipv4_metric, | |
9535 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 9536 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 9537 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9538 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 9539 | "Metric for redistributed routes\n" |
9540 | "Default metric\n") | |
9541 | { | |
cdc2d765 | 9542 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9543 | int idx_protocol = 1; |
9544 | int idx_number = 3; | |
718e3744 | 9545 | int type; |
9546 | u_int32_t metric; | |
7c8ff89e | 9547 | struct bgp_redist *red; |
718e3744 | 9548 | |
6d681bd8 QY |
9549 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9550 | if (type < 0) | |
718e3744 | 9551 | { |
9552 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9553 | return CMD_WARNING; | |
9554 | } | |
c500ae40 | 9555 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9556 | |
cdc2d765 DL |
9557 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
9558 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
9559 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); | |
718e3744 | 9560 | } |
9561 | ||
9562 | DEFUN (bgp_redistribute_ipv4_rmap_metric, | |
9563 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 9564 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 9565 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9566 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 9567 | "Route map reference\n" |
9568 | "Pointer to route-map entries\n" | |
9569 | "Metric for redistributed routes\n" | |
9570 | "Default metric\n") | |
9571 | { | |
cdc2d765 | 9572 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9573 | int idx_protocol = 1; |
9574 | int idx_word = 3; | |
9575 | int idx_number = 5; | |
718e3744 | 9576 | int type; |
9577 | u_int32_t metric; | |
7c8ff89e | 9578 | struct bgp_redist *red; |
718e3744 | 9579 | |
6d681bd8 QY |
9580 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9581 | if (type < 0) | |
718e3744 | 9582 | { |
9583 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9584 | return CMD_WARNING; | |
9585 | } | |
c500ae40 | 9586 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9587 | |
cdc2d765 | 9588 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
c500ae40 | 9589 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 DL |
9590 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
9591 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); | |
718e3744 | 9592 | } |
9593 | ||
9594 | DEFUN (bgp_redistribute_ipv4_metric_rmap, | |
9595 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 9596 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 9597 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9598 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 9599 | "Metric for redistributed routes\n" |
9600 | "Default metric\n" | |
9601 | "Route map reference\n" | |
9602 | "Pointer to route-map entries\n") | |
9603 | { | |
cdc2d765 | 9604 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9605 | int idx_protocol = 1; |
9606 | int idx_number = 3; | |
9607 | int idx_word = 5; | |
718e3744 | 9608 | int type; |
9609 | u_int32_t metric; | |
7c8ff89e | 9610 | struct bgp_redist *red; |
718e3744 | 9611 | |
6d681bd8 QY |
9612 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9613 | if (type < 0) | |
718e3744 | 9614 | { |
9615 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9616 | return CMD_WARNING; | |
9617 | } | |
c500ae40 | 9618 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9619 | |
cdc2d765 DL |
9620 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
9621 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
c500ae40 | 9622 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9623 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); |
718e3744 | 9624 | } |
9625 | ||
7c8ff89e DS |
9626 | DEFUN (bgp_redistribute_ipv4_ospf, |
9627 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 9628 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
9629 | "Redistribute information from another routing protocol\n" |
9630 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9631 | "Non-main Kernel Routing Table\n" |
9632 | "Instance ID/Table ID\n") | |
7c8ff89e | 9633 | { |
cdc2d765 | 9634 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9635 | int idx_ospf_table = 1; |
9636 | int idx_number = 2; | |
7c8ff89e | 9637 | u_short instance; |
7a4bb9c5 | 9638 | u_short protocol; |
7c8ff89e | 9639 | |
c500ae40 | 9640 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
7a4bb9c5 | 9641 | |
c500ae40 | 9642 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9643 | protocol = ZEBRA_ROUTE_OSPF; |
9644 | else | |
9645 | protocol = ZEBRA_ROUTE_TABLE; | |
9646 | ||
cdc2d765 DL |
9647 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
9648 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
9649 | } |
9650 | ||
9651 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, | |
9652 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 9653 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
9654 | "Redistribute information from another routing protocol\n" |
9655 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9656 | "Non-main Kernel Routing Table\n" |
9657 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
9658 | "Route map reference\n" |
9659 | "Pointer to route-map entries\n") | |
9660 | { | |
cdc2d765 | 9661 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9662 | int idx_ospf_table = 1; |
9663 | int idx_number = 2; | |
9664 | int idx_word = 4; | |
7c8ff89e DS |
9665 | struct bgp_redist *red; |
9666 | u_short instance; | |
7a4bb9c5 | 9667 | int protocol; |
7c8ff89e | 9668 | |
c500ae40 | 9669 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9670 | protocol = ZEBRA_ROUTE_OSPF; |
9671 | else | |
9672 | protocol = ZEBRA_ROUTE_TABLE; | |
9673 | ||
c500ae40 | 9674 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
cdc2d765 | 9675 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
c500ae40 | 9676 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9677 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); |
7c8ff89e DS |
9678 | } |
9679 | ||
9680 | DEFUN (bgp_redistribute_ipv4_ospf_metric, | |
9681 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 9682 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
9683 | "Redistribute information from another routing protocol\n" |
9684 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9685 | "Non-main Kernel Routing Table\n" |
9686 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
9687 | "Metric for redistributed routes\n" |
9688 | "Default metric\n") | |
9689 | { | |
cdc2d765 | 9690 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9691 | int idx_ospf_table = 1; |
9692 | int idx_number = 2; | |
9693 | int idx_number_2 = 4; | |
7c8ff89e DS |
9694 | u_int32_t metric; |
9695 | struct bgp_redist *red; | |
9696 | u_short instance; | |
7a4bb9c5 | 9697 | int protocol; |
7c8ff89e | 9698 | |
c500ae40 | 9699 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9700 | protocol = ZEBRA_ROUTE_OSPF; |
9701 | else | |
9702 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 9703 | |
c500ae40 DW |
9704 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
9705 | VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); | |
7a4bb9c5 | 9706 | |
cdc2d765 DL |
9707 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
9708 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
9709 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
9710 | } |
9711 | ||
9712 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, | |
9713 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 9714 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
9715 | "Redistribute information from another routing protocol\n" |
9716 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9717 | "Non-main Kernel Routing Table\n" |
9718 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
9719 | "Route map reference\n" |
9720 | "Pointer to route-map entries\n" | |
9721 | "Metric for redistributed routes\n" | |
9722 | "Default metric\n") | |
9723 | { | |
cdc2d765 | 9724 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9725 | int idx_ospf_table = 1; |
9726 | int idx_number = 2; | |
9727 | int idx_word = 4; | |
9728 | int idx_number_2 = 6; | |
7c8ff89e DS |
9729 | u_int32_t metric; |
9730 | struct bgp_redist *red; | |
9731 | u_short instance; | |
7a4bb9c5 | 9732 | int protocol; |
7c8ff89e | 9733 | |
c500ae40 | 9734 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9735 | protocol = ZEBRA_ROUTE_OSPF; |
9736 | else | |
9737 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 9738 | |
c500ae40 DW |
9739 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
9740 | VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); | |
7a4bb9c5 | 9741 | |
cdc2d765 | 9742 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
c500ae40 | 9743 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 DL |
9744 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); |
9745 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
9746 | } |
9747 | ||
9748 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, | |
9749 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 9750 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
9751 | "Redistribute information from another routing protocol\n" |
9752 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9753 | "Non-main Kernel Routing Table\n" |
9754 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
9755 | "Metric for redistributed routes\n" |
9756 | "Default metric\n" | |
9757 | "Route map reference\n" | |
9758 | "Pointer to route-map entries\n") | |
9759 | { | |
cdc2d765 | 9760 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9761 | int idx_ospf_table = 1; |
9762 | int idx_number = 2; | |
9763 | int idx_number_2 = 4; | |
9764 | int idx_word = 6; | |
7c8ff89e DS |
9765 | u_int32_t metric; |
9766 | struct bgp_redist *red; | |
9767 | u_short instance; | |
7a4bb9c5 | 9768 | int protocol; |
7c8ff89e | 9769 | |
c500ae40 | 9770 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9771 | protocol = ZEBRA_ROUTE_OSPF; |
9772 | else | |
9773 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 9774 | |
c500ae40 DW |
9775 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
9776 | VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); | |
7a4bb9c5 | 9777 | |
cdc2d765 DL |
9778 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
9779 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
c500ae40 | 9780 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9781 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); |
7c8ff89e DS |
9782 | } |
9783 | ||
9784 | DEFUN (no_bgp_redistribute_ipv4_ospf, | |
9785 | no_bgp_redistribute_ipv4_ospf_cmd, | |
d04c479d | 9786 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", |
7c8ff89e DS |
9787 | NO_STR |
9788 | "Redistribute information from another routing protocol\n" | |
9789 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 9790 | "Non-main Kernel Routing Table\n" |
31500417 DW |
9791 | "Instance ID/Table ID\n" |
9792 | "Metric for redistributed routes\n" | |
9793 | "Default metric\n" | |
9794 | "Route map reference\n" | |
9795 | "Pointer to route-map entries\n") | |
7c8ff89e | 9796 | { |
cdc2d765 | 9797 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9798 | int idx_ospf_table = 2; |
9799 | int idx_number = 3; | |
7c8ff89e | 9800 | u_short instance; |
7a4bb9c5 DS |
9801 | int protocol; |
9802 | ||
c500ae40 | 9803 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9804 | protocol = ZEBRA_ROUTE_OSPF; |
9805 | else | |
9806 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 9807 | |
c500ae40 | 9808 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
cdc2d765 | 9809 | return bgp_redistribute_unset (bgp, AFI_IP, protocol, instance); |
7c8ff89e DS |
9810 | } |
9811 | ||
718e3744 | 9812 | DEFUN (no_bgp_redistribute_ipv4, |
9813 | no_bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 9814 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 9815 | NO_STR |
9816 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 9817 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
9818 | "Metric for redistributed routes\n" |
9819 | "Default metric\n" | |
9820 | "Route map reference\n" | |
9821 | "Pointer to route-map entries\n") | |
718e3744 | 9822 | { |
cdc2d765 | 9823 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 9824 | int idx_protocol = 2; |
718e3744 | 9825 | int type; |
9826 | ||
6d681bd8 QY |
9827 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9828 | if (type < 0) | |
718e3744 | 9829 | { |
9830 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9831 | return CMD_WARNING; | |
9832 | } | |
cdc2d765 | 9833 | return bgp_redistribute_unset (bgp, AFI_IP, type, 0); |
718e3744 | 9834 | } |
9835 | ||
718e3744 | 9836 | DEFUN (bgp_redistribute_ipv6, |
9837 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 9838 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 9839 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9840 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 9841 | { |
cdc2d765 | 9842 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 9843 | int idx_protocol = 1; |
718e3744 | 9844 | int type; |
9845 | ||
6d681bd8 QY |
9846 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9847 | if (type < 0) | |
718e3744 | 9848 | { |
9849 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9850 | return CMD_WARNING; | |
9851 | } | |
9852 | ||
cdc2d765 DL |
9853 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
9854 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); | |
718e3744 | 9855 | } |
9856 | ||
9857 | DEFUN (bgp_redistribute_ipv6_rmap, | |
9858 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 9859 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 9860 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9861 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 9862 | "Route map reference\n" |
9863 | "Pointer to route-map entries\n") | |
9864 | { | |
cdc2d765 | 9865 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9866 | int idx_protocol = 1; |
9867 | int idx_word = 3; | |
718e3744 | 9868 | int type; |
7c8ff89e | 9869 | struct bgp_redist *red; |
718e3744 | 9870 | |
6d681bd8 QY |
9871 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9872 | if (type < 0) | |
718e3744 | 9873 | { |
9874 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9875 | return CMD_WARNING; | |
9876 | } | |
9877 | ||
cdc2d765 | 9878 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
c500ae40 | 9879 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9880 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); |
718e3744 | 9881 | } |
9882 | ||
9883 | DEFUN (bgp_redistribute_ipv6_metric, | |
9884 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 9885 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 9886 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9887 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 9888 | "Metric for redistributed routes\n" |
9889 | "Default metric\n") | |
9890 | { | |
cdc2d765 | 9891 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9892 | int idx_protocol = 1; |
9893 | int idx_number = 3; | |
718e3744 | 9894 | int type; |
9895 | u_int32_t metric; | |
7c8ff89e | 9896 | struct bgp_redist *red; |
718e3744 | 9897 | |
6d681bd8 QY |
9898 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9899 | if (type < 0) | |
718e3744 | 9900 | { |
9901 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9902 | return CMD_WARNING; | |
9903 | } | |
c500ae40 | 9904 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9905 | |
cdc2d765 DL |
9906 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
9907 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
9908 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); | |
718e3744 | 9909 | } |
9910 | ||
9911 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
9912 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 9913 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 9914 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9915 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 9916 | "Route map reference\n" |
9917 | "Pointer to route-map entries\n" | |
9918 | "Metric for redistributed routes\n" | |
9919 | "Default metric\n") | |
9920 | { | |
cdc2d765 | 9921 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9922 | int idx_protocol = 1; |
9923 | int idx_word = 3; | |
9924 | int idx_number = 5; | |
718e3744 | 9925 | int type; |
9926 | u_int32_t metric; | |
7c8ff89e | 9927 | struct bgp_redist *red; |
718e3744 | 9928 | |
6d681bd8 QY |
9929 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9930 | if (type < 0) | |
718e3744 | 9931 | { |
9932 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9933 | return CMD_WARNING; | |
9934 | } | |
c500ae40 | 9935 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9936 | |
cdc2d765 | 9937 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
c500ae40 | 9938 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 DL |
9939 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); |
9940 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); | |
718e3744 | 9941 | } |
9942 | ||
9943 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
9944 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 9945 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 9946 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9947 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 9948 | "Metric for redistributed routes\n" |
9949 | "Default metric\n" | |
9950 | "Route map reference\n" | |
9951 | "Pointer to route-map entries\n") | |
9952 | { | |
cdc2d765 | 9953 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9954 | int idx_protocol = 1; |
9955 | int idx_number = 3; | |
9956 | int idx_word = 5; | |
718e3744 | 9957 | int type; |
9958 | u_int32_t metric; | |
7c8ff89e | 9959 | struct bgp_redist *red; |
718e3744 | 9960 | |
6d681bd8 QY |
9961 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9962 | if (type < 0) | |
718e3744 | 9963 | { |
9964 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9965 | return CMD_WARNING; | |
9966 | } | |
c500ae40 | 9967 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9968 | |
cdc2d765 DL |
9969 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
9970 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, metric); | |
c500ae40 | 9971 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9972 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); |
718e3744 | 9973 | } |
9974 | ||
9975 | DEFUN (no_bgp_redistribute_ipv6, | |
9976 | no_bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 9977 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 9978 | NO_STR |
9979 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 9980 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
9981 | "Metric for redistributed routes\n" |
9982 | "Default metric\n" | |
9983 | "Route map reference\n" | |
9984 | "Pointer to route-map entries\n") | |
718e3744 | 9985 | { |
cdc2d765 | 9986 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 9987 | int idx_protocol = 2; |
718e3744 | 9988 | int type; |
9989 | ||
6d681bd8 QY |
9990 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9991 | if (type < 0) | |
718e3744 | 9992 | { |
9993 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9994 | return CMD_WARNING; | |
9995 | } | |
9996 | ||
cdc2d765 | 9997 | return bgp_redistribute_unset (bgp, AFI_IP6, type, 0); |
718e3744 | 9998 | } |
6b0655a2 | 9999 | |
718e3744 | 10000 | int |
10001 | bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi, | |
10002 | safi_t safi, int *write) | |
10003 | { | |
10004 | int i; | |
718e3744 | 10005 | |
10006 | /* Unicast redistribution only. */ | |
10007 | if (safi != SAFI_UNICAST) | |
10008 | return 0; | |
10009 | ||
10010 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) | |
10011 | { | |
10012 | /* Redistribute BGP does not make sense. */ | |
7c8ff89e | 10013 | if (i != ZEBRA_ROUTE_BGP) |
718e3744 | 10014 | { |
7c8ff89e DS |
10015 | struct list *red_list; |
10016 | struct listnode *node; | |
10017 | struct bgp_redist *red; | |
718e3744 | 10018 | |
7c8ff89e DS |
10019 | red_list = bgp->redist[afi][i]; |
10020 | if (!red_list) | |
10021 | continue; | |
718e3744 | 10022 | |
7c8ff89e DS |
10023 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) |
10024 | { | |
10025 | /* Display "address-family" when it is not yet diplayed. */ | |
10026 | bgp_config_write_family_header (vty, afi, safi, write); | |
10027 | ||
10028 | /* "redistribute" configuration. */ | |
0b960b4d | 10029 | vty_out (vty, " redistribute %s", zebra_route_string(i)); |
7c8ff89e DS |
10030 | if (red->instance) |
10031 | vty_out (vty, " %d", red->instance); | |
10032 | if (red->redist_metric_flag) | |
10033 | vty_out (vty, " metric %u", red->redist_metric); | |
10034 | if (red->rmap.name) | |
10035 | vty_out (vty, " route-map %s", red->rmap.name); | |
10036 | vty_out (vty, "%s", VTY_NEWLINE); | |
10037 | } | |
718e3744 | 10038 | } |
10039 | } | |
10040 | return *write; | |
10041 | } | |
6b0655a2 | 10042 | |
718e3744 | 10043 | /* BGP node structure. */ |
7fc626de | 10044 | static struct cmd_node bgp_node = |
718e3744 | 10045 | { |
10046 | BGP_NODE, | |
10047 | "%s(config-router)# ", | |
10048 | 1, | |
10049 | }; | |
10050 | ||
7fc626de | 10051 | static struct cmd_node bgp_ipv4_unicast_node = |
718e3744 | 10052 | { |
10053 | BGP_IPV4_NODE, | |
10054 | "%s(config-router-af)# ", | |
10055 | 1, | |
10056 | }; | |
10057 | ||
7fc626de | 10058 | static struct cmd_node bgp_ipv4_multicast_node = |
718e3744 | 10059 | { |
10060 | BGP_IPV4M_NODE, | |
10061 | "%s(config-router-af)# ", | |
10062 | 1, | |
10063 | }; | |
10064 | ||
7fc626de | 10065 | static struct cmd_node bgp_ipv6_unicast_node = |
718e3744 | 10066 | { |
10067 | BGP_IPV6_NODE, | |
10068 | "%s(config-router-af)# ", | |
10069 | 1, | |
10070 | }; | |
10071 | ||
7fc626de | 10072 | static struct cmd_node bgp_ipv6_multicast_node = |
25ffbdc1 | 10073 | { |
10074 | BGP_IPV6M_NODE, | |
10075 | "%s(config-router-af)# ", | |
10076 | 1, | |
10077 | }; | |
10078 | ||
7fc626de | 10079 | static struct cmd_node bgp_vpnv4_node = |
718e3744 | 10080 | { |
10081 | BGP_VPNV4_NODE, | |
10082 | "%s(config-router-af)# ", | |
10083 | 1 | |
10084 | }; | |
6b0655a2 | 10085 | |
8ecd3266 | 10086 | static struct cmd_node bgp_vpnv6_node = |
10087 | { | |
10088 | BGP_VPNV6_NODE, | |
10089 | "%s(config-router-af-vpnv6)# ", | |
10090 | 1 | |
10091 | }; | |
10092 | ||
8b1fb8be LB |
10093 | static struct cmd_node bgp_encap_node = |
10094 | { | |
10095 | BGP_ENCAP_NODE, | |
10096 | "%s(config-router-af-encap)# ", | |
10097 | 1 | |
10098 | }; | |
10099 | ||
10100 | static struct cmd_node bgp_encapv6_node = | |
10101 | { | |
10102 | BGP_ENCAPV6_NODE, | |
10103 | "%s(config-router-af-encapv6)# ", | |
10104 | 1 | |
10105 | }; | |
10106 | ||
4e0b7b6d PG |
10107 | static struct cmd_node bgp_evpn_node = |
10108 | { | |
10109 | BGP_EVPN_NODE, | |
10110 | "%s(config-router-evpn)# ", | |
10111 | 1 | |
10112 | }; | |
10113 | ||
1f8ae70b | 10114 | static void community_list_vty (void); |
10115 | ||
718e3744 | 10116 | void |
94f2b392 | 10117 | bgp_vty_init (void) |
718e3744 | 10118 | { |
718e3744 | 10119 | /* Install bgp top node. */ |
10120 | install_node (&bgp_node, bgp_config_write); | |
10121 | install_node (&bgp_ipv4_unicast_node, NULL); | |
10122 | install_node (&bgp_ipv4_multicast_node, NULL); | |
10123 | install_node (&bgp_ipv6_unicast_node, NULL); | |
25ffbdc1 | 10124 | install_node (&bgp_ipv6_multicast_node, NULL); |
718e3744 | 10125 | install_node (&bgp_vpnv4_node, NULL); |
8ecd3266 | 10126 | install_node (&bgp_vpnv6_node, NULL); |
8b1fb8be LB |
10127 | install_node (&bgp_encap_node, NULL); |
10128 | install_node (&bgp_encapv6_node, NULL); | |
4e0b7b6d | 10129 | install_node (&bgp_evpn_node, NULL); |
718e3744 | 10130 | |
10131 | /* Install default VTY commands to new nodes. */ | |
10132 | install_default (BGP_NODE); | |
10133 | install_default (BGP_IPV4_NODE); | |
10134 | install_default (BGP_IPV4M_NODE); | |
10135 | install_default (BGP_IPV6_NODE); | |
25ffbdc1 | 10136 | install_default (BGP_IPV6M_NODE); |
718e3744 | 10137 | install_default (BGP_VPNV4_NODE); |
8ecd3266 | 10138 | install_default (BGP_VPNV6_NODE); |
8b1fb8be LB |
10139 | install_default (BGP_ENCAP_NODE); |
10140 | install_default (BGP_ENCAPV6_NODE); | |
4e0b7b6d | 10141 | install_default (BGP_EVPN_NODE); |
e52702f2 | 10142 | |
718e3744 | 10143 | /* "bgp multiple-instance" commands. */ |
10144 | install_element (CONFIG_NODE, &bgp_multiple_instance_cmd); | |
10145 | install_element (CONFIG_NODE, &no_bgp_multiple_instance_cmd); | |
10146 | ||
10147 | /* "bgp config-type" commands. */ | |
10148 | install_element (CONFIG_NODE, &bgp_config_type_cmd); | |
8c3deaae | 10149 | install_element (CONFIG_NODE, &no_bgp_config_type_cmd); |
718e3744 | 10150 | |
5fe9f963 | 10151 | /* bgp route-map delay-timer commands. */ |
10152 | install_element (CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
10153 | install_element (CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
5fe9f963 | 10154 | |
718e3744 | 10155 | /* Dummy commands (Currently not supported) */ |
10156 | install_element (BGP_NODE, &no_synchronization_cmd); | |
10157 | install_element (BGP_NODE, &no_auto_summary_cmd); | |
10158 | ||
10159 | /* "router bgp" commands. */ | |
10160 | install_element (CONFIG_NODE, &router_bgp_cmd); | |
718e3744 | 10161 | |
10162 | /* "no router bgp" commands. */ | |
10163 | install_element (CONFIG_NODE, &no_router_bgp_cmd); | |
718e3744 | 10164 | |
10165 | /* "bgp router-id" commands. */ | |
10166 | install_element (BGP_NODE, &bgp_router_id_cmd); | |
10167 | install_element (BGP_NODE, &no_bgp_router_id_cmd); | |
718e3744 | 10168 | |
10169 | /* "bgp cluster-id" commands. */ | |
10170 | install_element (BGP_NODE, &bgp_cluster_id_cmd); | |
718e3744 | 10171 | install_element (BGP_NODE, &no_bgp_cluster_id_cmd); |
718e3744 | 10172 | |
10173 | /* "bgp confederation" commands. */ | |
10174 | install_element (BGP_NODE, &bgp_confederation_identifier_cmd); | |
10175 | install_element (BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
718e3744 | 10176 | |
10177 | /* "bgp confederation peers" commands. */ | |
10178 | install_element (BGP_NODE, &bgp_confederation_peers_cmd); | |
10179 | install_element (BGP_NODE, &no_bgp_confederation_peers_cmd); | |
10180 | ||
abc920f8 DS |
10181 | /* bgp max-med command */ |
10182 | install_element (BGP_NODE, &bgp_maxmed_admin_cmd); | |
10183 | install_element (BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
10184 | install_element (BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
abc920f8 DS |
10185 | install_element (BGP_NODE, &bgp_maxmed_onstartup_cmd); |
10186 | install_element (BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
abc920f8 | 10187 | install_element (BGP_NODE, &bgp_maxmed_onstartup_medv_cmd); |
abc920f8 | 10188 | |
907f92c8 DS |
10189 | /* bgp disable-ebgp-connected-nh-check */ |
10190 | install_element (BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
10191 | install_element (BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
10192 | ||
f188f2c4 DS |
10193 | /* bgp update-delay command */ |
10194 | install_element (BGP_NODE, &bgp_update_delay_cmd); | |
10195 | install_element (BGP_NODE, &no_bgp_update_delay_cmd); | |
10196 | install_element (BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
f188f2c4 | 10197 | |
cb1faec9 DS |
10198 | install_element (BGP_NODE, &bgp_wpkt_quanta_cmd); |
10199 | install_element (BGP_NODE, &no_bgp_wpkt_quanta_cmd); | |
10200 | ||
3f9c7369 DS |
10201 | install_element (BGP_NODE, &bgp_coalesce_time_cmd); |
10202 | install_element (BGP_NODE, &no_bgp_coalesce_time_cmd); | |
10203 | ||
165b5fff JB |
10204 | /* "maximum-paths" commands. */ |
10205 | install_element (BGP_NODE, &bgp_maxpaths_cmd); | |
10206 | install_element (BGP_NODE, &no_bgp_maxpaths_cmd); | |
165b5fff JB |
10207 | install_element (BGP_IPV4_NODE, &bgp_maxpaths_cmd); |
10208 | install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
431aa9f9 DS |
10209 | install_element (BGP_IPV6_NODE, &bgp_maxpaths_cmd); |
10210 | install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
165b5fff | 10211 | install_element (BGP_NODE, &bgp_maxpaths_ibgp_cmd); |
5e242b0d | 10212 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_cmd); |
165b5fff | 10213 | install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_cmd); |
165b5fff | 10214 | install_element (BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); |
5e242b0d | 10215 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); |
165b5fff | 10216 | install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); |
431aa9f9 | 10217 | install_element (BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); |
5e242b0d | 10218 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); |
431aa9f9 | 10219 | install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); |
165b5fff | 10220 | |
718e3744 | 10221 | /* "timers bgp" commands. */ |
10222 | install_element (BGP_NODE, &bgp_timers_cmd); | |
10223 | install_element (BGP_NODE, &no_bgp_timers_cmd); | |
718e3744 | 10224 | |
5fe9f963 | 10225 | /* route-map delay-timer commands - per instance for backwards compat. */ |
518f0eb1 DS |
10226 | install_element (BGP_NODE, &bgp_set_route_map_delay_timer_cmd); |
10227 | install_element (BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
10228 | ||
718e3744 | 10229 | /* "bgp client-to-client reflection" commands */ |
10230 | install_element (BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
10231 | install_element (BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
10232 | ||
10233 | /* "bgp always-compare-med" commands */ | |
10234 | install_element (BGP_NODE, &bgp_always_compare_med_cmd); | |
10235 | install_element (BGP_NODE, &no_bgp_always_compare_med_cmd); | |
e52702f2 | 10236 | |
718e3744 | 10237 | /* "bgp deterministic-med" commands */ |
10238 | install_element (BGP_NODE, &bgp_deterministic_med_cmd); | |
10239 | install_element (BGP_NODE, &no_bgp_deterministic_med_cmd); | |
538621f2 | 10240 | |
538621f2 | 10241 | /* "bgp graceful-restart" commands */ |
10242 | install_element (BGP_NODE, &bgp_graceful_restart_cmd); | |
10243 | install_element (BGP_NODE, &no_bgp_graceful_restart_cmd); | |
93406d87 | 10244 | install_element (BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
10245 | install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
eb6f1b41 PG |
10246 | install_element (BGP_NODE, &bgp_graceful_restart_restart_time_cmd); |
10247 | install_element (BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
e52702f2 | 10248 | |
43fc21b3 JC |
10249 | install_element (BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
10250 | install_element (BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
10251 | ||
718e3744 | 10252 | /* "bgp fast-external-failover" commands */ |
10253 | install_element (BGP_NODE, &bgp_fast_external_failover_cmd); | |
10254 | install_element (BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
10255 | ||
10256 | /* "bgp enforce-first-as" commands */ | |
10257 | install_element (BGP_NODE, &bgp_enforce_first_as_cmd); | |
10258 | install_element (BGP_NODE, &no_bgp_enforce_first_as_cmd); | |
10259 | ||
10260 | /* "bgp bestpath compare-routerid" commands */ | |
10261 | install_element (BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
10262 | install_element (BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
10263 | ||
10264 | /* "bgp bestpath as-path ignore" commands */ | |
10265 | install_element (BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
10266 | install_element (BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
10267 | ||
6811845b | 10268 | /* "bgp bestpath as-path confed" commands */ |
10269 | install_element (BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
10270 | install_element (BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
10271 | ||
2fdd455c PM |
10272 | /* "bgp bestpath as-path multipath-relax" commands */ |
10273 | install_element (BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
10274 | install_element (BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
10275 | ||
848973c7 | 10276 | /* "bgp log-neighbor-changes" commands */ |
10277 | install_element (BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
10278 | install_element (BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
10279 | ||
718e3744 | 10280 | /* "bgp bestpath med" commands */ |
10281 | install_element (BGP_NODE, &bgp_bestpath_med_cmd); | |
718e3744 | 10282 | install_element (BGP_NODE, &no_bgp_bestpath_med_cmd); |
718e3744 | 10283 | |
10284 | /* "no bgp default ipv4-unicast" commands. */ | |
10285 | install_element (BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
10286 | install_element (BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
e52702f2 | 10287 | |
718e3744 | 10288 | /* "bgp network import-check" commands. */ |
10289 | install_element (BGP_NODE, &bgp_network_import_check_cmd); | |
8233ef81 | 10290 | install_element (BGP_NODE, &bgp_network_import_check_exact_cmd); |
718e3744 | 10291 | install_element (BGP_NODE, &no_bgp_network_import_check_cmd); |
10292 | ||
10293 | /* "bgp default local-preference" commands. */ | |
10294 | install_element (BGP_NODE, &bgp_default_local_preference_cmd); | |
10295 | install_element (BGP_NODE, &no_bgp_default_local_preference_cmd); | |
718e3744 | 10296 | |
04b6bdc0 DW |
10297 | /* bgp default show-hostname */ |
10298 | install_element (BGP_NODE, &bgp_default_show_hostname_cmd); | |
10299 | install_element (BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
10300 | ||
3f9c7369 DS |
10301 | /* "bgp default subgroup-pkt-queue-max" commands. */ |
10302 | install_element (BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
10303 | install_element (BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
10304 | ||
8bd9d948 DS |
10305 | /* bgp ibgp-allow-policy-mods command */ |
10306 | install_element (BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
10307 | install_element (BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
10308 | ||
f14e6fdb DS |
10309 | /* "bgp listen limit" commands. */ |
10310 | install_element (BGP_NODE, &bgp_listen_limit_cmd); | |
10311 | install_element (BGP_NODE, &no_bgp_listen_limit_cmd); | |
10312 | ||
10313 | /* "bgp listen range" commands. */ | |
10314 | install_element (BGP_NODE, &bgp_listen_range_cmd); | |
10315 | install_element (BGP_NODE, &no_bgp_listen_range_cmd); | |
10316 | ||
718e3744 | 10317 | /* "neighbor remote-as" commands. */ |
10318 | install_element (BGP_NODE, &neighbor_remote_as_cmd); | |
a80beece | 10319 | install_element (BGP_NODE, &neighbor_interface_config_cmd); |
4c48cf63 | 10320 | install_element (BGP_NODE, &neighbor_interface_config_v6only_cmd); |
b3a39dc5 DD |
10321 | install_element (BGP_NODE, &neighbor_interface_config_remote_as_cmd); |
10322 | install_element (BGP_NODE, &neighbor_interface_v6only_config_remote_as_cmd); | |
718e3744 | 10323 | install_element (BGP_NODE, &no_neighbor_cmd); |
a80beece | 10324 | install_element (BGP_NODE, &no_neighbor_interface_config_cmd); |
718e3744 | 10325 | |
10326 | /* "neighbor peer-group" commands. */ | |
10327 | install_element (BGP_NODE, &neighbor_peer_group_cmd); | |
10328 | install_element (BGP_NODE, &no_neighbor_peer_group_cmd); | |
a80beece | 10329 | install_element (BGP_NODE, &no_neighbor_interface_peer_group_remote_as_cmd); |
718e3744 | 10330 | |
10331 | /* "neighbor local-as" commands. */ | |
10332 | install_element (BGP_NODE, &neighbor_local_as_cmd); | |
10333 | install_element (BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
9d3f9705 | 10334 | install_element (BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); |
718e3744 | 10335 | install_element (BGP_NODE, &no_neighbor_local_as_cmd); |
718e3744 | 10336 | |
3f9c7369 DS |
10337 | /* "neighbor solo" commands. */ |
10338 | install_element (BGP_NODE, &neighbor_solo_cmd); | |
10339 | install_element (BGP_NODE, &no_neighbor_solo_cmd); | |
10340 | ||
0df7c91f PJ |
10341 | /* "neighbor password" commands. */ |
10342 | install_element (BGP_NODE, &neighbor_password_cmd); | |
10343 | install_element (BGP_NODE, &no_neighbor_password_cmd); | |
10344 | ||
718e3744 | 10345 | /* "neighbor activate" commands. */ |
10346 | install_element (BGP_NODE, &neighbor_activate_cmd); | |
10347 | install_element (BGP_IPV4_NODE, &neighbor_activate_cmd); | |
10348 | install_element (BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
10349 | install_element (BGP_IPV6_NODE, &neighbor_activate_cmd); | |
25ffbdc1 | 10350 | install_element (BGP_IPV6M_NODE, &neighbor_activate_cmd); |
718e3744 | 10351 | install_element (BGP_VPNV4_NODE, &neighbor_activate_cmd); |
8ecd3266 | 10352 | install_element (BGP_VPNV6_NODE, &neighbor_activate_cmd); |
8b1fb8be LB |
10353 | install_element (BGP_ENCAP_NODE, &neighbor_activate_cmd); |
10354 | install_element (BGP_ENCAPV6_NODE, &neighbor_activate_cmd); | |
4e0b7b6d | 10355 | install_element (BGP_EVPN_NODE, &neighbor_activate_cmd); |
718e3744 | 10356 | |
10357 | /* "no neighbor activate" commands. */ | |
10358 | install_element (BGP_NODE, &no_neighbor_activate_cmd); | |
10359 | install_element (BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
10360 | install_element (BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
10361 | install_element (BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
25ffbdc1 | 10362 | install_element (BGP_IPV6M_NODE, &no_neighbor_activate_cmd); |
718e3744 | 10363 | install_element (BGP_VPNV4_NODE, &no_neighbor_activate_cmd); |
8ecd3266 | 10364 | install_element (BGP_VPNV6_NODE, &no_neighbor_activate_cmd); |
8b1fb8be LB |
10365 | install_element (BGP_ENCAP_NODE, &no_neighbor_activate_cmd); |
10366 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_activate_cmd); | |
4e0b7b6d | 10367 | install_element (BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
718e3744 | 10368 | |
c8560b44 DW |
10369 | /* "neighbor peer-group" set commands. |
10370 | * Long term we should only accept this command under BGP_NODE and not all of | |
10371 | * the afi/safi sub-contexts. For now though we need to accept it for backwards | |
10372 | * compatibility. This changed when we stopped requiring that peers be assigned | |
10373 | * to their peer-group under each address-family sub-context. | |
10374 | */ | |
718e3744 | 10375 | install_element (BGP_NODE, &neighbor_set_peer_group_cmd); |
10376 | install_element (BGP_IPV4_NODE, &neighbor_set_peer_group_cmd); | |
10377 | install_element (BGP_IPV4M_NODE, &neighbor_set_peer_group_cmd); | |
10378 | install_element (BGP_IPV6_NODE, &neighbor_set_peer_group_cmd); | |
25ffbdc1 | 10379 | install_element (BGP_IPV6M_NODE, &neighbor_set_peer_group_cmd); |
a58545bb | 10380 | install_element (BGP_VPNV4_NODE, &neighbor_set_peer_group_cmd); |
8ecd3266 | 10381 | install_element (BGP_VPNV6_NODE, &neighbor_set_peer_group_cmd); |
8b1fb8be LB |
10382 | install_element (BGP_ENCAP_NODE, &neighbor_set_peer_group_cmd); |
10383 | install_element (BGP_ENCAPV6_NODE, &neighbor_set_peer_group_cmd); | |
c8560b44 | 10384 | |
718e3744 | 10385 | /* "no neighbor peer-group unset" commands. */ |
10386 | install_element (BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
10387 | install_element (BGP_IPV4_NODE, &no_neighbor_set_peer_group_cmd); | |
10388 | install_element (BGP_IPV4M_NODE, &no_neighbor_set_peer_group_cmd); | |
10389 | install_element (BGP_IPV6_NODE, &no_neighbor_set_peer_group_cmd); | |
25ffbdc1 | 10390 | install_element (BGP_IPV6M_NODE, &no_neighbor_set_peer_group_cmd); |
a58545bb | 10391 | install_element (BGP_VPNV4_NODE, &no_neighbor_set_peer_group_cmd); |
8ecd3266 | 10392 | install_element (BGP_VPNV6_NODE, &no_neighbor_set_peer_group_cmd); |
8b1fb8be LB |
10393 | install_element (BGP_ENCAP_NODE, &no_neighbor_set_peer_group_cmd); |
10394 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_set_peer_group_cmd); | |
e52702f2 | 10395 | |
718e3744 | 10396 | /* "neighbor softreconfiguration inbound" commands.*/ |
10397 | install_element (BGP_NODE, &neighbor_soft_reconfiguration_cmd); | |
10398 | install_element (BGP_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
10399 | install_element (BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
10400 | install_element (BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
10401 | install_element (BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
10402 | install_element (BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
10403 | install_element (BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
10404 | install_element (BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
25ffbdc1 | 10405 | install_element (BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); |
10406 | install_element (BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
a58545bb | 10407 | install_element (BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); |
10408 | install_element (BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
8ecd3266 | 10409 | install_element (BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); |
10410 | install_element (BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
8b1fb8be LB |
10411 | install_element (BGP_ENCAP_NODE, &neighbor_soft_reconfiguration_cmd); |
10412 | install_element (BGP_ENCAP_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
10413 | install_element (BGP_ENCAPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
10414 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
718e3744 | 10415 | |
10416 | /* "neighbor attribute-unchanged" commands. */ | |
10417 | install_element (BGP_NODE, &neighbor_attr_unchanged_cmd); | |
718e3744 | 10418 | install_element (BGP_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10419 | install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 10420 | install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10421 | install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 10422 | install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10423 | install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 10424 | install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); |
25ffbdc1 | 10425 | install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); |
25ffbdc1 | 10426 | install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10427 | install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 10428 | install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); |
8ecd3266 | 10429 | install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); |
8ecd3266 | 10430 | install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); |
8ecd3266 | 10431 | |
8b1fb8be | 10432 | install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged_cmd); |
8b1fb8be | 10433 | install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged_cmd); |
8b1fb8be LB |
10434 | |
10435 | install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged_cmd); | |
8b1fb8be | 10436 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10437 | |
4e0b7b6d PG |
10438 | install_element (BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); |
10439 | install_element (BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
10440 | ||
fee0f4c6 | 10441 | /* "nexthop-local unchanged" commands */ |
10442 | install_element (BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
10443 | install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_local_unchanged_cmd); | |
10444 | ||
718e3744 | 10445 | /* "neighbor next-hop-self" commands. */ |
10446 | install_element (BGP_NODE, &neighbor_nexthop_self_cmd); | |
10447 | install_element (BGP_NODE, &no_neighbor_nexthop_self_cmd); | |
10448 | install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
10449 | install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
10450 | install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
10451 | install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
10452 | install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
10453 | install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
25ffbdc1 | 10454 | install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); |
10455 | install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
718e3744 | 10456 | install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); |
10457 | install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
8ecd3266 | 10458 | install_element (BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); |
10459 | install_element (BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
8b1fb8be LB |
10460 | install_element (BGP_ENCAP_NODE, &neighbor_nexthop_self_cmd); |
10461 | install_element (BGP_ENCAP_NODE, &no_neighbor_nexthop_self_cmd); | |
10462 | install_element (BGP_ENCAPV6_NODE, &neighbor_nexthop_self_cmd); | |
10463 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
718e3744 | 10464 | |
a538debe DS |
10465 | /* "neighbor next-hop-self force" commands. */ |
10466 | install_element (BGP_NODE, &neighbor_nexthop_self_force_cmd); | |
10467 | install_element (BGP_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10468 | install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); | |
10469 | install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10470 | install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); | |
10471 | install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10472 | install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); | |
10473 | install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10474 | install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); | |
10475 | install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10476 | install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); | |
10477 | install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
8ecd3266 | 10478 | install_element (BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
10479 | install_element (BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
a538debe | 10480 | |
c7122e14 DS |
10481 | /* "neighbor as-override" commands. */ |
10482 | install_element (BGP_NODE, &neighbor_as_override_cmd); | |
10483 | install_element (BGP_NODE, &no_neighbor_as_override_cmd); | |
10484 | install_element (BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
10485 | install_element (BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
10486 | install_element (BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
10487 | install_element (BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
10488 | install_element (BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
10489 | install_element (BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
10490 | install_element (BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
10491 | install_element (BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
10492 | install_element (BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
10493 | install_element (BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
8ecd3266 | 10494 | install_element (BGP_VPNV6_NODE, &neighbor_as_override_cmd); |
10495 | install_element (BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
c7122e14 | 10496 | |
718e3744 | 10497 | /* "neighbor remove-private-AS" commands. */ |
10498 | install_element (BGP_NODE, &neighbor_remove_private_as_cmd); | |
10499 | install_element (BGP_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10500 | install_element (BGP_NODE, &neighbor_remove_private_as_all_cmd); |
10501 | install_element (BGP_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10502 | install_element (BGP_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10503 | install_element (BGP_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10504 | install_element (BGP_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10505 | install_element (BGP_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 10506 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); |
10507 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10508 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); |
10509 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10510 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10511 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10512 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10513 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 10514 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); |
10515 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10516 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); |
10517 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10518 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10519 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10520 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10521 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 10522 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); |
10523 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10524 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); |
10525 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10526 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10527 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10528 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10529 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
25ffbdc1 | 10530 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); |
10531 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10532 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); |
10533 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10534 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10535 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10536 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10537 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 10538 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); |
10539 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10540 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); |
10541 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10542 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10543 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10544 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10545 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
8ecd3266 | 10546 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); |
10547 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
10548 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
10549 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10550 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10551 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10552 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10553 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
8b1fb8be LB |
10554 | install_element (BGP_ENCAP_NODE, &neighbor_remove_private_as_cmd); |
10555 | install_element (BGP_ENCAP_NODE, &no_neighbor_remove_private_as_cmd); | |
10556 | install_element (BGP_ENCAPV6_NODE, &neighbor_remove_private_as_cmd); | |
10557 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
718e3744 | 10558 | |
10559 | /* "neighbor send-community" commands.*/ | |
10560 | install_element (BGP_NODE, &neighbor_send_community_cmd); | |
10561 | install_element (BGP_NODE, &neighbor_send_community_type_cmd); | |
10562 | install_element (BGP_NODE, &no_neighbor_send_community_cmd); | |
10563 | install_element (BGP_NODE, &no_neighbor_send_community_type_cmd); | |
10564 | install_element (BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
10565 | install_element (BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
10566 | install_element (BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
10567 | install_element (BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
10568 | install_element (BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
10569 | install_element (BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
10570 | install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
10571 | install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
10572 | install_element (BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
10573 | install_element (BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
10574 | install_element (BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
10575 | install_element (BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
25ffbdc1 | 10576 | install_element (BGP_IPV6M_NODE, &neighbor_send_community_cmd); |
10577 | install_element (BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
10578 | install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
10579 | install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
718e3744 | 10580 | install_element (BGP_VPNV4_NODE, &neighbor_send_community_cmd); |
10581 | install_element (BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
10582 | install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
10583 | install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
8ecd3266 | 10584 | install_element (BGP_VPNV6_NODE, &neighbor_send_community_cmd); |
10585 | install_element (BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
10586 | install_element (BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
10587 | install_element (BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
8b1fb8be LB |
10588 | install_element (BGP_ENCAP_NODE, &neighbor_send_community_cmd); |
10589 | install_element (BGP_ENCAP_NODE, &neighbor_send_community_type_cmd); | |
10590 | install_element (BGP_ENCAP_NODE, &no_neighbor_send_community_cmd); | |
10591 | install_element (BGP_ENCAP_NODE, &no_neighbor_send_community_type_cmd); | |
10592 | install_element (BGP_ENCAPV6_NODE, &neighbor_send_community_cmd); | |
10593 | install_element (BGP_ENCAPV6_NODE, &neighbor_send_community_type_cmd); | |
10594 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_send_community_cmd); | |
10595 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_send_community_type_cmd); | |
718e3744 | 10596 | |
10597 | /* "neighbor route-reflector" commands.*/ | |
10598 | install_element (BGP_NODE, &neighbor_route_reflector_client_cmd); | |
10599 | install_element (BGP_NODE, &no_neighbor_route_reflector_client_cmd); | |
10600 | install_element (BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
10601 | install_element (BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
10602 | install_element (BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
10603 | install_element (BGP_IPV4M_NODE, &no_neighbor_route_reflector_client_cmd); | |
10604 | install_element (BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
10605 | install_element (BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
25ffbdc1 | 10606 | install_element (BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); |
10607 | install_element (BGP_IPV6M_NODE, &no_neighbor_route_reflector_client_cmd); | |
718e3744 | 10608 | install_element (BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); |
10609 | install_element (BGP_VPNV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
8ecd3266 | 10610 | install_element (BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); |
10611 | install_element (BGP_VPNV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
8b1fb8be LB |
10612 | install_element (BGP_ENCAP_NODE, &neighbor_route_reflector_client_cmd); |
10613 | install_element (BGP_ENCAP_NODE, &no_neighbor_route_reflector_client_cmd); | |
10614 | install_element (BGP_ENCAPV6_NODE, &neighbor_route_reflector_client_cmd); | |
10615 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
718e3744 | 10616 | |
10617 | /* "neighbor route-server" commands.*/ | |
10618 | install_element (BGP_NODE, &neighbor_route_server_client_cmd); | |
10619 | install_element (BGP_NODE, &no_neighbor_route_server_client_cmd); | |
10620 | install_element (BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
10621 | install_element (BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
10622 | install_element (BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
10623 | install_element (BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
10624 | install_element (BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
10625 | install_element (BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
25ffbdc1 | 10626 | install_element (BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); |
10627 | install_element (BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
718e3744 | 10628 | install_element (BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); |
10629 | install_element (BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
8ecd3266 | 10630 | install_element (BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); |
10631 | install_element (BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
8b1fb8be LB |
10632 | install_element (BGP_ENCAP_NODE, &neighbor_route_server_client_cmd); |
10633 | install_element (BGP_ENCAP_NODE, &no_neighbor_route_server_client_cmd); | |
10634 | install_element (BGP_ENCAPV6_NODE, &neighbor_route_server_client_cmd); | |
10635 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_server_client_cmd); | |
718e3744 | 10636 | |
adbac85e DW |
10637 | /* "neighbor addpath-tx-all-paths" commands.*/ |
10638 | install_element (BGP_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10639 | install_element (BGP_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10640 | install_element (BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10641 | install_element (BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10642 | install_element (BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10643 | install_element (BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10644 | install_element (BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10645 | install_element (BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10646 | install_element (BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10647 | install_element (BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10648 | install_element (BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10649 | install_element (BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
8ecd3266 | 10650 | install_element (BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); |
10651 | install_element (BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
adbac85e | 10652 | |
06370dac DW |
10653 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ |
10654 | install_element (BGP_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10655 | install_element (BGP_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10656 | install_element (BGP_IPV4_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10657 | install_element (BGP_IPV4_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10658 | install_element (BGP_IPV4M_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10659 | install_element (BGP_IPV4M_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10660 | install_element (BGP_IPV6_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10661 | install_element (BGP_IPV6_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10662 | install_element (BGP_IPV6M_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10663 | install_element (BGP_IPV6M_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10664 | install_element (BGP_VPNV4_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10665 | install_element (BGP_VPNV4_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
8ecd3266 | 10666 | install_element (BGP_VPNV6_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); |
10667 | install_element (BGP_VPNV6_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
06370dac | 10668 | |
718e3744 | 10669 | /* "neighbor passive" commands. */ |
10670 | install_element (BGP_NODE, &neighbor_passive_cmd); | |
10671 | install_element (BGP_NODE, &no_neighbor_passive_cmd); | |
10672 | ||
d5a5c8f0 | 10673 | |
718e3744 | 10674 | /* "neighbor shutdown" commands. */ |
10675 | install_element (BGP_NODE, &neighbor_shutdown_cmd); | |
10676 | install_element (BGP_NODE, &no_neighbor_shutdown_cmd); | |
73d70fa6 DL |
10677 | install_element (BGP_NODE, &neighbor_shutdown_msg_cmd); |
10678 | install_element (BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
718e3744 | 10679 | |
8a92a8a0 DS |
10680 | /* "neighbor capability extended-nexthop" commands.*/ |
10681 | install_element (BGP_NODE, &neighbor_capability_enhe_cmd); | |
10682 | install_element (BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
10683 | ||
718e3744 | 10684 | /* "neighbor capability orf prefix-list" commands.*/ |
10685 | install_element (BGP_NODE, &neighbor_capability_orf_prefix_cmd); | |
10686 | install_element (BGP_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
10687 | install_element (BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
10688 | install_element (BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
10689 | install_element (BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
10690 | install_element (BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
10691 | install_element (BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
10692 | install_element (BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
25ffbdc1 | 10693 | install_element (BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); |
10694 | install_element (BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
718e3744 | 10695 | |
10696 | /* "neighbor capability dynamic" commands.*/ | |
10697 | install_element (BGP_NODE, &neighbor_capability_dynamic_cmd); | |
10698 | install_element (BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
10699 | ||
10700 | /* "neighbor dont-capability-negotiate" commands. */ | |
10701 | install_element (BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
10702 | install_element (BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
10703 | ||
10704 | /* "neighbor ebgp-multihop" commands. */ | |
10705 | install_element (BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
10706 | install_element (BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
10707 | install_element (BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
718e3744 | 10708 | |
6ffd2079 | 10709 | /* "neighbor disable-connected-check" commands. */ |
10710 | install_element (BGP_NODE, &neighbor_disable_connected_check_cmd); | |
10711 | install_element (BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
718e3744 | 10712 | |
10713 | /* "neighbor description" commands. */ | |
10714 | install_element (BGP_NODE, &neighbor_description_cmd); | |
10715 | install_element (BGP_NODE, &no_neighbor_description_cmd); | |
718e3744 | 10716 | |
10717 | /* "neighbor update-source" commands. "*/ | |
10718 | install_element (BGP_NODE, &neighbor_update_source_cmd); | |
10719 | install_element (BGP_NODE, &no_neighbor_update_source_cmd); | |
10720 | ||
10721 | /* "neighbor default-originate" commands. */ | |
10722 | install_element (BGP_NODE, &neighbor_default_originate_cmd); | |
10723 | install_element (BGP_NODE, &neighbor_default_originate_rmap_cmd); | |
10724 | install_element (BGP_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 10725 | install_element (BGP_IPV4_NODE, &neighbor_default_originate_cmd); |
10726 | install_element (BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
10727 | install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 10728 | install_element (BGP_IPV4M_NODE, &neighbor_default_originate_cmd); |
10729 | install_element (BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
10730 | install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 10731 | install_element (BGP_IPV6_NODE, &neighbor_default_originate_cmd); |
10732 | install_element (BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
10733 | install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
25ffbdc1 | 10734 | install_element (BGP_IPV6M_NODE, &neighbor_default_originate_cmd); |
10735 | install_element (BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
10736 | install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 10737 | |
10738 | /* "neighbor port" commands. */ | |
10739 | install_element (BGP_NODE, &neighbor_port_cmd); | |
10740 | install_element (BGP_NODE, &no_neighbor_port_cmd); | |
718e3744 | 10741 | |
10742 | /* "neighbor weight" commands. */ | |
10743 | install_element (BGP_NODE, &neighbor_weight_cmd); | |
10744 | install_element (BGP_NODE, &no_neighbor_weight_cmd); | |
718e3744 | 10745 | |
d93f7ffc DW |
10746 | install_element (BGP_IPV4_NODE, &neighbor_weight_cmd); |
10747 | install_element (BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10748 | install_element (BGP_IPV4M_NODE, &neighbor_weight_cmd); |
10749 | install_element (BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10750 | install_element (BGP_IPV6_NODE, &neighbor_weight_cmd); |
10751 | install_element (BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10752 | install_element (BGP_IPV6M_NODE, &neighbor_weight_cmd); |
10753 | install_element (BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10754 | install_element (BGP_VPNV4_NODE, &neighbor_weight_cmd); |
10755 | install_element (BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10756 | install_element (BGP_VPNV6_NODE, &neighbor_weight_cmd); |
10757 | install_element (BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10758 | install_element (BGP_ENCAP_NODE, &neighbor_weight_cmd); |
10759 | install_element (BGP_ENCAP_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10760 | install_element (BGP_ENCAPV6_NODE, &neighbor_weight_cmd); |
10761 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_weight_cmd); | |
718e3744 | 10762 | |
10763 | /* "neighbor override-capability" commands. */ | |
10764 | install_element (BGP_NODE, &neighbor_override_capability_cmd); | |
10765 | install_element (BGP_NODE, &no_neighbor_override_capability_cmd); | |
10766 | ||
10767 | /* "neighbor strict-capability-match" commands. */ | |
10768 | install_element (BGP_NODE, &neighbor_strict_capability_cmd); | |
10769 | install_element (BGP_NODE, &no_neighbor_strict_capability_cmd); | |
10770 | ||
10771 | /* "neighbor timers" commands. */ | |
10772 | install_element (BGP_NODE, &neighbor_timers_cmd); | |
10773 | install_element (BGP_NODE, &no_neighbor_timers_cmd); | |
10774 | ||
10775 | /* "neighbor timers connect" commands. */ | |
10776 | install_element (BGP_NODE, &neighbor_timers_connect_cmd); | |
10777 | install_element (BGP_NODE, &no_neighbor_timers_connect_cmd); | |
718e3744 | 10778 | |
10779 | /* "neighbor advertisement-interval" commands. */ | |
10780 | install_element (BGP_NODE, &neighbor_advertise_interval_cmd); | |
10781 | install_element (BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
718e3744 | 10782 | |
718e3744 | 10783 | /* "neighbor interface" commands. */ |
10784 | install_element (BGP_NODE, &neighbor_interface_cmd); | |
10785 | install_element (BGP_NODE, &no_neighbor_interface_cmd); | |
10786 | ||
10787 | /* "neighbor distribute" commands. */ | |
10788 | install_element (BGP_NODE, &neighbor_distribute_list_cmd); | |
10789 | install_element (BGP_NODE, &no_neighbor_distribute_list_cmd); | |
10790 | install_element (BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
10791 | install_element (BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
10792 | install_element (BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
10793 | install_element (BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
10794 | install_element (BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
10795 | install_element (BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
25ffbdc1 | 10796 | install_element (BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); |
10797 | install_element (BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
718e3744 | 10798 | install_element (BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); |
10799 | install_element (BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
8ecd3266 | 10800 | install_element (BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); |
10801 | install_element (BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
8b1fb8be LB |
10802 | install_element (BGP_ENCAP_NODE, &neighbor_distribute_list_cmd); |
10803 | install_element (BGP_ENCAP_NODE, &no_neighbor_distribute_list_cmd); | |
10804 | install_element (BGP_ENCAPV6_NODE, &neighbor_distribute_list_cmd); | |
10805 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_distribute_list_cmd); | |
718e3744 | 10806 | |
10807 | /* "neighbor prefix-list" commands. */ | |
10808 | install_element (BGP_NODE, &neighbor_prefix_list_cmd); | |
10809 | install_element (BGP_NODE, &no_neighbor_prefix_list_cmd); | |
10810 | install_element (BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
10811 | install_element (BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
10812 | install_element (BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
10813 | install_element (BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
10814 | install_element (BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
10815 | install_element (BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
25ffbdc1 | 10816 | install_element (BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); |
10817 | install_element (BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
718e3744 | 10818 | install_element (BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); |
10819 | install_element (BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
8ecd3266 | 10820 | install_element (BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); |
10821 | install_element (BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
8b1fb8be LB |
10822 | install_element (BGP_ENCAP_NODE, &neighbor_prefix_list_cmd); |
10823 | install_element (BGP_ENCAP_NODE, &no_neighbor_prefix_list_cmd); | |
10824 | install_element (BGP_ENCAPV6_NODE, &neighbor_prefix_list_cmd); | |
10825 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_prefix_list_cmd); | |
718e3744 | 10826 | |
10827 | /* "neighbor filter-list" commands. */ | |
10828 | install_element (BGP_NODE, &neighbor_filter_list_cmd); | |
10829 | install_element (BGP_NODE, &no_neighbor_filter_list_cmd); | |
10830 | install_element (BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
10831 | install_element (BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
10832 | install_element (BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
10833 | install_element (BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
10834 | install_element (BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
10835 | install_element (BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
25ffbdc1 | 10836 | install_element (BGP_IPV6M_NODE, &neighbor_filter_list_cmd); |
10837 | install_element (BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
718e3744 | 10838 | install_element (BGP_VPNV4_NODE, &neighbor_filter_list_cmd); |
10839 | install_element (BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
8ecd3266 | 10840 | install_element (BGP_VPNV6_NODE, &neighbor_filter_list_cmd); |
10841 | install_element (BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
8b1fb8be LB |
10842 | install_element (BGP_ENCAP_NODE, &neighbor_filter_list_cmd); |
10843 | install_element (BGP_ENCAP_NODE, &no_neighbor_filter_list_cmd); | |
10844 | install_element (BGP_ENCAPV6_NODE, &neighbor_filter_list_cmd); | |
10845 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_filter_list_cmd); | |
718e3744 | 10846 | |
10847 | /* "neighbor route-map" commands. */ | |
10848 | install_element (BGP_NODE, &neighbor_route_map_cmd); | |
10849 | install_element (BGP_NODE, &no_neighbor_route_map_cmd); | |
10850 | install_element (BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
10851 | install_element (BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
10852 | install_element (BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
10853 | install_element (BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
10854 | install_element (BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
10855 | install_element (BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
25ffbdc1 | 10856 | install_element (BGP_IPV6M_NODE, &neighbor_route_map_cmd); |
10857 | install_element (BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
718e3744 | 10858 | install_element (BGP_VPNV4_NODE, &neighbor_route_map_cmd); |
10859 | install_element (BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
8ecd3266 | 10860 | install_element (BGP_VPNV6_NODE, &neighbor_route_map_cmd); |
10861 | install_element (BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
8b1fb8be LB |
10862 | install_element (BGP_ENCAP_NODE, &neighbor_route_map_cmd); |
10863 | install_element (BGP_ENCAP_NODE, &no_neighbor_route_map_cmd); | |
10864 | install_element (BGP_ENCAPV6_NODE, &neighbor_route_map_cmd); | |
10865 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_map_cmd); | |
718e3744 | 10866 | |
10867 | /* "neighbor unsuppress-map" commands. */ | |
10868 | install_element (BGP_NODE, &neighbor_unsuppress_map_cmd); | |
10869 | install_element (BGP_NODE, &no_neighbor_unsuppress_map_cmd); | |
10870 | install_element (BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
10871 | install_element (BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
10872 | install_element (BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
10873 | install_element (BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
10874 | install_element (BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
10875 | install_element (BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
25ffbdc1 | 10876 | install_element (BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); |
10877 | install_element (BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
a58545bb | 10878 | install_element (BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); |
bb86c601 | 10879 | install_element (BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); |
8ecd3266 | 10880 | install_element (BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); |
bb86c601 | 10881 | install_element (BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); |
8b1fb8be LB |
10882 | install_element (BGP_ENCAP_NODE, &neighbor_unsuppress_map_cmd); |
10883 | install_element (BGP_ENCAP_NODE, &no_neighbor_unsuppress_map_cmd); | |
10884 | install_element (BGP_ENCAPV6_NODE, &neighbor_unsuppress_map_cmd); | |
10885 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
718e3744 | 10886 | |
10887 | /* "neighbor maximum-prefix" commands. */ | |
10888 | install_element (BGP_NODE, &neighbor_maximum_prefix_cmd); | |
e0701b79 | 10889 | install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 10890 | install_element (BGP_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 10891 | install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 10892 | install_element (BGP_NODE, &neighbor_maximum_prefix_restart_cmd); |
10893 | install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 10894 | install_element (BGP_NODE, &no_neighbor_maximum_prefix_cmd); |
718e3744 | 10895 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 10896 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 10897 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 10898 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 10899 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); |
10900 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 10901 | install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); |
718e3744 | 10902 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 10903 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 10904 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 10905 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 10906 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); |
10907 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 10908 | install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); |
718e3744 | 10909 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 10910 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 10911 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 10912 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 10913 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); |
10914 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 10915 | install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); |
25ffbdc1 | 10916 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); |
10917 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
10918 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
10919 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
10920 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
10921 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
10922 | install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
718e3744 | 10923 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 10924 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 10925 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 10926 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 10927 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); |
10928 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 10929 | install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); |
8ecd3266 | 10930 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); |
10931 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
10932 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
10933 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
10934 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
10935 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
10936 | install_element (BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
718e3744 | 10937 | |
8b1fb8be LB |
10938 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_cmd); |
10939 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
10940 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_warning_cmd); | |
10941 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
10942 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_restart_cmd); | |
10943 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
10944 | install_element (BGP_ENCAP_NODE, &no_neighbor_maximum_prefix_cmd); | |
8b1fb8be LB |
10945 | |
10946 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_cmd); | |
10947 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
10948 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
10949 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
10950 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
10951 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
10952 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
8b1fb8be | 10953 | |
718e3744 | 10954 | /* "neighbor allowas-in" */ |
10955 | install_element (BGP_NODE, &neighbor_allowas_in_cmd); | |
718e3744 | 10956 | install_element (BGP_NODE, &no_neighbor_allowas_in_cmd); |
10957 | install_element (BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
718e3744 | 10958 | install_element (BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); |
10959 | install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
718e3744 | 10960 | install_element (BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); |
10961 | install_element (BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
718e3744 | 10962 | install_element (BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); |
25ffbdc1 | 10963 | install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); |
25ffbdc1 | 10964 | install_element (BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); |
718e3744 | 10965 | install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); |
718e3744 | 10966 | install_element (BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); |
8ecd3266 | 10967 | install_element (BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); |
8ecd3266 | 10968 | install_element (BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); |
8b1fb8be | 10969 | install_element (BGP_ENCAP_NODE, &neighbor_allowas_in_cmd); |
8b1fb8be LB |
10970 | install_element (BGP_ENCAP_NODE, &no_neighbor_allowas_in_cmd); |
10971 | install_element (BGP_ENCAPV6_NODE, &neighbor_allowas_in_cmd); | |
8b1fb8be | 10972 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_allowas_in_cmd); |
718e3744 | 10973 | |
10974 | /* address-family commands. */ | |
718e3744 | 10975 | install_element (BGP_NODE, &address_family_ipv4_safi_cmd); |
25ffbdc1 | 10976 | install_element (BGP_NODE, &address_family_ipv6_safi_cmd); |
d6902373 | 10977 | #ifdef KEEP_OLD_VPN_COMMANDS |
718e3744 | 10978 | install_element (BGP_NODE, &address_family_vpnv4_cmd); |
8b1fb8be | 10979 | install_element (BGP_NODE, &address_family_vpnv6_cmd); |
d6902373 | 10980 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be LB |
10981 | |
10982 | install_element (BGP_NODE, &address_family_encap_cmd); | |
8b1fb8be | 10983 | install_element (BGP_NODE, &address_family_encapv6_cmd); |
8b1fb8be | 10984 | |
4e0b7b6d PG |
10985 | install_element (BGP_NODE, &address_family_evpn_cmd); |
10986 | ||
718e3744 | 10987 | /* "exit-address-family" command. */ |
10988 | install_element (BGP_IPV4_NODE, &exit_address_family_cmd); | |
10989 | install_element (BGP_IPV4M_NODE, &exit_address_family_cmd); | |
10990 | install_element (BGP_IPV6_NODE, &exit_address_family_cmd); | |
25ffbdc1 | 10991 | install_element (BGP_IPV6M_NODE, &exit_address_family_cmd); |
718e3744 | 10992 | install_element (BGP_VPNV4_NODE, &exit_address_family_cmd); |
8ecd3266 | 10993 | install_element (BGP_VPNV6_NODE, &exit_address_family_cmd); |
8b1fb8be LB |
10994 | install_element (BGP_ENCAP_NODE, &exit_address_family_cmd); |
10995 | install_element (BGP_ENCAPV6_NODE, &exit_address_family_cmd); | |
4e0b7b6d | 10996 | install_element (BGP_EVPN_NODE, &exit_address_family_cmd); |
718e3744 | 10997 | |
10998 | /* "clear ip bgp commands" */ | |
10999 | install_element (ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
718e3744 | 11000 | |
8ad7271d DS |
11001 | /* clear ip bgp prefix */ |
11002 | install_element (ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
11003 | install_element (ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
01080f7c | 11004 | install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); |
8ad7271d | 11005 | |
716b2d8a | 11006 | /* "show [ip] bgp summary" commands. */ |
f186de26 | 11007 | install_element (VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); |
8386ac43 | 11008 | install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_cmd); |
8386ac43 | 11009 | install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_s_cmd); |
271ad8d5 | 11010 | install_element (VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
e52702f2 | 11011 | install_element (VIEW_NODE, &show_bgp_updgrps_adj_cmd); |
e52702f2 | 11012 | install_element (VIEW_NODE, &show_bgp_updgrps_adj_s_cmd); |
271ad8d5 | 11013 | install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_cmd); |
e52702f2 | 11014 | install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_s_cmd); |
8c3deaae | 11015 | install_element (VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
271ad8d5 QY |
11016 | install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_cmd); |
11017 | install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); | |
11018 | install_element (VIEW_NODE, &show_ip_bgp_summary_cmd); | |
11019 | install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_cmd); | |
11020 | install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_s_cmd); | |
11021 | install_element (VIEW_NODE, &show_ip_bgp_updgrps_cmd); | |
e3e29b32 | 11022 | |
716b2d8a | 11023 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 11024 | install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd); |
718e3744 | 11025 | |
716b2d8a | 11026 | /* "show [ip] bgp peer-group" commands. */ |
f14e6fdb | 11027 | install_element (VIEW_NODE, &show_ip_bgp_peer_groups_cmd); |
f14e6fdb | 11028 | |
716b2d8a | 11029 | /* "show [ip] bgp paths" commands. */ |
718e3744 | 11030 | install_element (VIEW_NODE, &show_ip_bgp_paths_cmd); |
718e3744 | 11031 | |
716b2d8a | 11032 | /* "show [ip] bgp community" commands. */ |
718e3744 | 11033 | install_element (VIEW_NODE, &show_ip_bgp_community_info_cmd); |
718e3744 | 11034 | |
57d187bc JS |
11035 | /* "show ip bgp large-community" commands. */ |
11036 | install_element (VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
716b2d8a | 11037 | /* "show [ip] bgp attribute-info" commands. */ |
718e3744 | 11038 | install_element (VIEW_NODE, &show_ip_bgp_attr_info_cmd); |
718e3744 | 11039 | |
11040 | /* "redistribute" commands. */ | |
11041 | install_element (BGP_NODE, &bgp_redistribute_ipv4_cmd); | |
11042 | install_element (BGP_NODE, &no_bgp_redistribute_ipv4_cmd); | |
11043 | install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
718e3744 | 11044 | install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_cmd); |
718e3744 | 11045 | install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); |
11046 | install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
7c8ff89e DS |
11047 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_cmd); |
11048 | install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
11049 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
7c8ff89e | 11050 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); |
7c8ff89e | 11051 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); |
7c8ff89e | 11052 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); |
919e0666 DW |
11053 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); |
11054 | install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
11055 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
919e0666 | 11056 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); |
919e0666 DW |
11057 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); |
11058 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
919e0666 DW |
11059 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); |
11060 | install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
11061 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
919e0666 | 11062 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); |
919e0666 | 11063 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); |
919e0666 | 11064 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); |
718e3744 | 11065 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); |
11066 | install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
11067 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
718e3744 | 11068 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); |
718e3744 | 11069 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); |
11070 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
718e3744 | 11071 | |
fa411a21 NH |
11072 | /* ttl_security commands */ |
11073 | install_element (BGP_NODE, &neighbor_ttl_security_cmd); | |
11074 | install_element (BGP_NODE, &no_neighbor_ttl_security_cmd); | |
11075 | ||
716b2d8a | 11076 | /* "show [ip] bgp memory" commands. */ |
4bf6a362 | 11077 | install_element (VIEW_NODE, &show_bgp_memory_cmd); |
e52702f2 | 11078 | |
716b2d8a | 11079 | /* "show [ip] bgp views" commands. */ |
e0081f70 | 11080 | install_element (VIEW_NODE, &show_bgp_views_cmd); |
e52702f2 | 11081 | |
716b2d8a | 11082 | /* "show [ip] bgp vrfs" commands. */ |
8386ac43 | 11083 | install_element (VIEW_NODE, &show_bgp_vrfs_cmd); |
e52702f2 | 11084 | |
718e3744 | 11085 | /* Community-list. */ |
11086 | community_list_vty (); | |
11087 | } | |
6b0655a2 | 11088 | |
718e3744 | 11089 | #include "memory.h" |
11090 | #include "bgp_regex.h" | |
11091 | #include "bgp_clist.h" | |
11092 | #include "bgp_ecommunity.h" | |
11093 | ||
11094 | /* VTY functions. */ | |
11095 | ||
11096 | /* Direction value to string conversion. */ | |
94f2b392 | 11097 | static const char * |
718e3744 | 11098 | community_direct_str (int direct) |
11099 | { | |
11100 | switch (direct) | |
11101 | { | |
11102 | case COMMUNITY_DENY: | |
11103 | return "deny"; | |
718e3744 | 11104 | case COMMUNITY_PERMIT: |
11105 | return "permit"; | |
718e3744 | 11106 | default: |
11107 | return "unknown"; | |
718e3744 | 11108 | } |
11109 | } | |
11110 | ||
11111 | /* Display error string. */ | |
94f2b392 | 11112 | static void |
718e3744 | 11113 | community_list_perror (struct vty *vty, int ret) |
11114 | { | |
11115 | switch (ret) | |
11116 | { | |
11117 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
b729294c | 11118 | vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE); |
718e3744 | 11119 | break; |
11120 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
11121 | vty_out (vty, "%% Malformed community-list value%s", VTY_NEWLINE); | |
11122 | break; | |
11123 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
11124 | vty_out (vty, "%% Community name conflict, previously defined as standard community%s", VTY_NEWLINE); | |
11125 | break; | |
11126 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
11127 | vty_out (vty, "%% Community name conflict, previously defined as expanded community%s", VTY_NEWLINE); | |
11128 | break; | |
11129 | } | |
11130 | } | |
11131 | ||
5bf15956 DW |
11132 | /* "community-list" keyword help string. */ |
11133 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
11134 | ||
718e3744 | 11135 | |
5bf15956 | 11136 | /* ip community-list standard */ |
718e3744 | 11137 | DEFUN (ip_community_list_standard, |
11138 | ip_community_list_standard_cmd, | |
e961923c | 11139 | "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 11140 | IP_STR |
11141 | COMMUNITY_LIST_STR | |
11142 | "Community list number (standard)\n" | |
5bf15956 | 11143 | "Add an standard community-list entry\n" |
718e3744 | 11144 | "Community list name\n" |
11145 | "Specify community to reject\n" | |
11146 | "Specify community to accept\n" | |
11147 | COMMUNITY_VAL_STR) | |
11148 | { | |
42f914d4 QY |
11149 | char *cl_name_or_number = NULL; |
11150 | int direct = 0; | |
11151 | int style = COMMUNITY_LIST_STANDARD; | |
11152 | ||
11153 | int idx = 0; | |
11154 | argv_find (argv, argc, "(1-99)", &idx); | |
11155 | argv_find (argv, argc, "WORD", &idx); | |
11156 | cl_name_or_number = argv[idx]->arg; | |
11157 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11158 | argv_find (argv, argc, "AA:NN", &idx); | |
11159 | char *str = argv_concat (argv, argc, idx); | |
11160 | ||
11161 | int ret = community_list_set (bgp_clist, cl_name_or_number, str, direct, style); | |
11162 | ||
11163 | XFREE (MTYPE_TMP, str); | |
11164 | ||
11165 | if (ret < 0) | |
11166 | { | |
11167 | /* Display error string. */ | |
11168 | community_list_perror (vty, ret); | |
11169 | return CMD_WARNING; | |
11170 | } | |
11171 | ||
11172 | return CMD_SUCCESS; | |
718e3744 | 11173 | } |
11174 | ||
fee6e4e4 | 11175 | DEFUN (no_ip_community_list_standard_all, |
11176 | no_ip_community_list_standard_all_cmd, | |
e961923c | 11177 | "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 11178 | NO_STR |
11179 | IP_STR | |
11180 | COMMUNITY_LIST_STR | |
11181 | "Community list number (standard)\n" | |
5bf15956 DW |
11182 | "Add an standard community-list entry\n" |
11183 | "Community list name\n" | |
718e3744 | 11184 | "Specify community to reject\n" |
11185 | "Specify community to accept\n" | |
11186 | COMMUNITY_VAL_STR) | |
11187 | { | |
42f914d4 QY |
11188 | int delete_all = 0; |
11189 | ||
11190 | char *cl_name_or_number = NULL; | |
11191 | int direct = 0; | |
11192 | int style = COMMUNITY_LIST_STANDARD; | |
11193 | ||
11194 | int idx = 0; | |
11195 | argv_find (argv, argc, "(1-99)", &idx); | |
11196 | argv_find (argv, argc, "WORD", &idx); | |
11197 | cl_name_or_number = argv[idx]->arg; | |
11198 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11199 | argv_find (argv, argc, "AA:NN", &idx); | |
11200 | char *str = argv_concat (argv, argc, idx); | |
11201 | ||
11202 | int ret = community_list_unset (bgp_clist, cl_name_or_number, str, direct, style, delete_all); | |
11203 | ||
daf9ddbb DS |
11204 | XFREE (MTYPE_TMP, str); |
11205 | ||
42f914d4 QY |
11206 | if (ret < 0) |
11207 | { | |
11208 | community_list_perror (vty, ret); | |
11209 | return CMD_WARNING; | |
11210 | } | |
11211 | ||
11212 | return CMD_SUCCESS; | |
718e3744 | 11213 | } |
11214 | ||
5bf15956 DW |
11215 | /* ip community-list expanded */ |
11216 | DEFUN (ip_community_list_expanded_all, | |
11217 | ip_community_list_expanded_all_cmd, | |
42f914d4 | 11218 | "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 11219 | IP_STR |
11220 | COMMUNITY_LIST_STR | |
11221 | "Community list number (expanded)\n" | |
5bf15956 | 11222 | "Add an expanded community-list entry\n" |
718e3744 | 11223 | "Community list name\n" |
11224 | "Specify community to reject\n" | |
11225 | "Specify community to accept\n" | |
11226 | COMMUNITY_VAL_STR) | |
11227 | { | |
42f914d4 QY |
11228 | char *cl_name_or_number = NULL; |
11229 | int direct = 0; | |
11230 | int style = COMMUNITY_LIST_EXPANDED; | |
11231 | ||
11232 | int idx = 0; | |
11233 | argv_find (argv, argc, "(100-500)", &idx); | |
11234 | argv_find (argv, argc, "WORD", &idx); | |
11235 | cl_name_or_number = argv[idx]->arg; | |
11236 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11237 | argv_find (argv, argc, "AA:NN", &idx); | |
11238 | char *str = argv_concat (argv, argc, idx); | |
11239 | ||
11240 | int ret = community_list_set (bgp_clist, cl_name_or_number, str, direct, style); | |
11241 | ||
11242 | XFREE (MTYPE_TMP, str); | |
11243 | ||
11244 | if (ret < 0) | |
11245 | { | |
11246 | /* Display error string. */ | |
11247 | community_list_perror (vty, ret); | |
11248 | return CMD_WARNING; | |
11249 | } | |
11250 | ||
11251 | return CMD_SUCCESS; | |
718e3744 | 11252 | } |
11253 | ||
5bf15956 DW |
11254 | DEFUN (no_ip_community_list_expanded_all, |
11255 | no_ip_community_list_expanded_all_cmd, | |
42f914d4 | 11256 | "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 11257 | NO_STR |
11258 | IP_STR | |
11259 | COMMUNITY_LIST_STR | |
5bf15956 DW |
11260 | "Community list number (expanded)\n" |
11261 | "Add an expanded community-list entry\n" | |
718e3744 | 11262 | "Community list name\n" |
11263 | "Specify community to reject\n" | |
11264 | "Specify community to accept\n" | |
5bf15956 | 11265 | COMMUNITY_VAL_STR) |
718e3744 | 11266 | { |
42f914d4 QY |
11267 | int delete_all = 0; |
11268 | ||
11269 | char *cl_name_or_number = NULL; | |
11270 | int direct = 0; | |
11271 | int style = COMMUNITY_LIST_EXPANDED; | |
11272 | ||
11273 | int idx = 0; | |
11274 | argv_find (argv, argc, "(100-500)", &idx); | |
11275 | argv_find (argv, argc, "WORD", &idx); | |
11276 | cl_name_or_number = argv[idx]->arg; | |
11277 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11278 | argv_find (argv, argc, "AA:NN", &idx); | |
11279 | char *str = argv_concat (argv, argc, idx); | |
11280 | ||
11281 | int ret = community_list_unset (bgp_clist, cl_name_or_number, str, direct, style, delete_all); | |
11282 | ||
daf9ddbb DS |
11283 | XFREE (MTYPE_TMP, str); |
11284 | ||
42f914d4 QY |
11285 | if (ret < 0) |
11286 | { | |
11287 | community_list_perror (vty, ret); | |
11288 | return CMD_WARNING; | |
11289 | } | |
11290 | ||
11291 | return CMD_SUCCESS; | |
718e3744 | 11292 | } |
11293 | ||
94f2b392 | 11294 | static void |
718e3744 | 11295 | community_list_show (struct vty *vty, struct community_list *list) |
11296 | { | |
11297 | struct community_entry *entry; | |
11298 | ||
11299 | for (entry = list->head; entry; entry = entry->next) | |
11300 | { | |
11301 | if (entry == list->head) | |
11302 | { | |
11303 | if (all_digit (list->name)) | |
11304 | vty_out (vty, "Community %s list %s%s", | |
11305 | entry->style == COMMUNITY_LIST_STANDARD ? | |
11306 | "standard" : "(expanded) access", | |
11307 | list->name, VTY_NEWLINE); | |
11308 | else | |
11309 | vty_out (vty, "Named Community %s list %s%s", | |
11310 | entry->style == COMMUNITY_LIST_STANDARD ? | |
11311 | "standard" : "expanded", | |
11312 | list->name, VTY_NEWLINE); | |
11313 | } | |
11314 | if (entry->any) | |
11315 | vty_out (vty, " %s%s", | |
11316 | community_direct_str (entry->direct), VTY_NEWLINE); | |
11317 | else | |
11318 | vty_out (vty, " %s %s%s", | |
11319 | community_direct_str (entry->direct), | |
11320 | entry->style == COMMUNITY_LIST_STANDARD | |
11321 | ? community_str (entry->u.com) : entry->config, | |
11322 | VTY_NEWLINE); | |
11323 | } | |
11324 | } | |
11325 | ||
11326 | DEFUN (show_ip_community_list, | |
11327 | show_ip_community_list_cmd, | |
11328 | "show ip community-list", | |
11329 | SHOW_STR | |
11330 | IP_STR | |
11331 | "List community-list\n") | |
11332 | { | |
11333 | struct community_list *list; | |
11334 | struct community_list_master *cm; | |
11335 | ||
fee6e4e4 | 11336 | cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER); |
718e3744 | 11337 | if (! cm) |
11338 | return CMD_SUCCESS; | |
11339 | ||
11340 | for (list = cm->num.head; list; list = list->next) | |
11341 | community_list_show (vty, list); | |
11342 | ||
11343 | for (list = cm->str.head; list; list = list->next) | |
11344 | community_list_show (vty, list); | |
11345 | ||
11346 | return CMD_SUCCESS; | |
11347 | } | |
11348 | ||
11349 | DEFUN (show_ip_community_list_arg, | |
11350 | show_ip_community_list_arg_cmd, | |
6147e2c6 | 11351 | "show ip community-list <(1-500)|WORD>", |
718e3744 | 11352 | SHOW_STR |
11353 | IP_STR | |
11354 | "List community-list\n" | |
11355 | "Community-list number\n" | |
11356 | "Community-list name\n") | |
11357 | { | |
c500ae40 | 11358 | int idx_comm_list = 3; |
718e3744 | 11359 | struct community_list *list; |
11360 | ||
c500ae40 | 11361 | list = community_list_lookup (bgp_clist, argv[idx_comm_list]->arg, COMMUNITY_LIST_MASTER); |
718e3744 | 11362 | if (! list) |
11363 | { | |
b729294c | 11364 | vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE); |
718e3744 | 11365 | return CMD_WARNING; |
11366 | } | |
11367 | ||
11368 | community_list_show (vty, list); | |
11369 | ||
11370 | return CMD_SUCCESS; | |
11371 | } | |
6b0655a2 | 11372 | |
57d187bc JS |
11373 | /* |
11374 | * Large Community code. | |
11375 | */ | |
11376 | static int | |
11377 | lcommunity_list_set_vty (struct vty *vty, int argc, struct cmd_token **argv, | |
2acb4ac2 | 11378 | int style, int reject_all_digit_name) |
57d187bc JS |
11379 | { |
11380 | int ret; | |
11381 | int direct; | |
11382 | char *str; | |
11383 | int idx = 0; | |
11384 | char *cl_name; | |
11385 | ||
11386 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11387 | ||
11388 | /* All digit name check. */ | |
11389 | idx = 0; | |
11390 | argv_find (argv, argc, "WORD", &idx); | |
11391 | argv_find (argv, argc, "(1-99)", &idx); | |
11392 | argv_find (argv, argc, "(100-500)", &idx); | |
11393 | cl_name = argv[idx]->arg; | |
11394 | if (reject_all_digit_name && all_digit (cl_name)) | |
11395 | { | |
11396 | vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE); | |
11397 | return CMD_WARNING; | |
11398 | } | |
11399 | ||
11400 | argv_find (argv, argc, "AA:BB:CC", &idx); | |
11401 | argv_find (argv, argc, "LINE", &idx); | |
11402 | /* Concat community string argument. */ | |
11403 | if (idx) | |
11404 | str = argv_concat (argv, argc, idx); | |
11405 | else | |
11406 | str = NULL; | |
11407 | ||
11408 | ret = lcommunity_list_set (bgp_clist, cl_name, str, direct, style); | |
11409 | ||
11410 | /* Free temporary community list string allocated by | |
11411 | argv_concat(). */ | |
11412 | if (str) | |
11413 | XFREE (MTYPE_TMP, str); | |
11414 | ||
11415 | if (ret < 0) | |
11416 | { | |
11417 | community_list_perror (vty, ret); | |
11418 | return CMD_WARNING; | |
11419 | } | |
11420 | return CMD_SUCCESS; | |
11421 | } | |
11422 | ||
11423 | static int | |
11424 | lcommunity_list_unset_vty (struct vty *vty, int argc, struct cmd_token **argv, | |
2acb4ac2 | 11425 | int style) |
57d187bc JS |
11426 | { |
11427 | int ret; | |
11428 | int direct = 0; | |
11429 | char *str = NULL; | |
11430 | int idx = 0; | |
11431 | ||
11432 | argv_find (argv, argc, "permit", &idx); | |
11433 | argv_find (argv, argc, "deny", &idx); | |
11434 | ||
11435 | if (idx) | |
11436 | { | |
11437 | /* Check the list direct. */ | |
11438 | if (strncmp (argv[idx]->arg, "p", 1) == 0) | |
2acb4ac2 | 11439 | direct = COMMUNITY_PERMIT; |
57d187bc | 11440 | else |
2acb4ac2 | 11441 | direct = COMMUNITY_DENY; |
57d187bc JS |
11442 | |
11443 | idx = 0; | |
11444 | argv_find (argv, argc, "LINE", &idx); | |
11445 | argv_find (argv, argc, "AA:AA:NN", &idx); | |
11446 | /* Concat community string argument. */ | |
11447 | str = argv_concat (argv, argc, idx); | |
11448 | } | |
11449 | ||
11450 | idx = 0; | |
11451 | argv_find (argv, argc, "(1-99)", &idx); | |
11452 | argv_find (argv, argc, "(100-500)", &idx); | |
11453 | argv_find (argv, argc, "WORD", &idx); | |
11454 | ||
11455 | /* Unset community list. */ | |
11456 | ret = lcommunity_list_unset (bgp_clist, argv[idx]->arg, str, direct, style); | |
11457 | ||
11458 | /* Free temporary community list string allocated by | |
11459 | argv_concat(). */ | |
11460 | if (str) | |
11461 | XFREE (MTYPE_TMP, str); | |
11462 | ||
11463 | if (ret < 0) | |
11464 | { | |
11465 | community_list_perror (vty, ret); | |
11466 | return CMD_WARNING; | |
11467 | } | |
11468 | ||
11469 | return CMD_SUCCESS; | |
11470 | } | |
11471 | ||
11472 | /* "large-community-list" keyword help string. */ | |
11473 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
11474 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
11475 | ||
11476 | DEFUN (ip_lcommunity_list_standard, | |
11477 | ip_lcommunity_list_standard_cmd, | |
52951b63 DS |
11478 | "ip large-community-list (1-99) <deny|permit>", |
11479 | IP_STR | |
11480 | LCOMMUNITY_LIST_STR | |
11481 | "Large Community list number (standard)\n" | |
11482 | "Specify large community to reject\n" | |
11483 | "Specify large community to accept\n" | |
11484 | LCOMMUNITY_VAL_STR) | |
11485 | { | |
11486 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD, 0); | |
11487 | } | |
11488 | ||
11489 | DEFUN (ip_lcommunity_list_standard1, | |
11490 | ip_lcommunity_list_standard1_cmd, | |
11491 | "ip large-community-list (1-99) <deny|permit> AA:BB:CC...", | |
57d187bc JS |
11492 | IP_STR |
11493 | LCOMMUNITY_LIST_STR | |
11494 | "Large Community list number (standard)\n" | |
11495 | "Specify large community to reject\n" | |
11496 | "Specify large community to accept\n" | |
11497 | LCOMMUNITY_VAL_STR) | |
11498 | { | |
11499 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD, 0); | |
11500 | } | |
11501 | ||
11502 | DEFUN (ip_lcommunity_list_expanded, | |
11503 | ip_lcommunity_list_expanded_cmd, | |
11504 | "ip large-community-list (100-500) <deny|permit> LINE...", | |
11505 | IP_STR | |
11506 | LCOMMUNITY_LIST_STR | |
11507 | "Large Community list number (expanded)\n" | |
11508 | "Specify large community to reject\n" | |
11509 | "Specify large community to accept\n" | |
11510 | "An ordered list as a regular-expression\n") | |
11511 | { | |
11512 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED, 0); | |
11513 | } | |
11514 | ||
11515 | DEFUN (ip_lcommunity_list_name_standard, | |
11516 | ip_lcommunity_list_name_standard_cmd, | |
52951b63 DS |
11517 | "ip large-community-list standard WORD <deny|permit>", |
11518 | IP_STR | |
11519 | LCOMMUNITY_LIST_STR | |
11520 | "Specify standard large-community-list\n" | |
11521 | "Large Community list name\n" | |
11522 | "Specify large community to reject\n" | |
11523 | "Specify large community to accept\n") | |
11524 | { | |
11525 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD, 1); | |
11526 | } | |
11527 | ||
11528 | DEFUN (ip_lcommunity_list_name_standard1, | |
11529 | ip_lcommunity_list_name_standard1_cmd, | |
11530 | "ip large-community-list standard WORD <deny|permit> AA:BB:CC...", | |
57d187bc JS |
11531 | IP_STR |
11532 | LCOMMUNITY_LIST_STR | |
11533 | "Specify standard large-community-list\n" | |
11534 | "Large Community list name\n" | |
11535 | "Specify large community to reject\n" | |
11536 | "Specify large community to accept\n" | |
11537 | LCOMMUNITY_VAL_STR) | |
11538 | { | |
11539 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD, 1); | |
11540 | } | |
11541 | ||
11542 | DEFUN (ip_lcommunity_list_name_expanded, | |
11543 | ip_lcommunity_list_name_expanded_cmd, | |
11544 | "ip large-community-list expanded WORD <deny|permit> LINE...", | |
11545 | IP_STR | |
11546 | LCOMMUNITY_LIST_STR | |
11547 | "Specify expanded large-community-list\n" | |
11548 | "Large Community list name\n" | |
11549 | "Specify large community to reject\n" | |
11550 | "Specify large community to accept\n" | |
11551 | "An ordered list as a regular-expression\n") | |
11552 | { | |
11553 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED, 1); | |
11554 | } | |
11555 | ||
11556 | DEFUN (no_ip_lcommunity_list_standard_all, | |
11557 | no_ip_lcommunity_list_standard_all_cmd, | |
11558 | "no ip large-community-list <(1-99)|(100-500)|WORD>", | |
11559 | NO_STR | |
11560 | IP_STR | |
11561 | LCOMMUNITY_LIST_STR | |
11562 | "Large Community list number (standard)\n" | |
11563 | "Large Community list number (expanded)\n" | |
11564 | "Large Community list name\n") | |
11565 | { | |
11566 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD); | |
11567 | } | |
11568 | ||
11569 | DEFUN (no_ip_lcommunity_list_name_expanded_all, | |
11570 | no_ip_lcommunity_list_name_expanded_all_cmd, | |
11571 | "no ip large-community-list expanded WORD", | |
11572 | NO_STR | |
11573 | IP_STR | |
11574 | LCOMMUNITY_LIST_STR | |
11575 | "Specify expanded large-community-list\n" | |
11576 | "Large Community list name\n") | |
11577 | { | |
11578 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED); | |
11579 | } | |
11580 | ||
11581 | DEFUN (no_ip_lcommunity_list_standard, | |
11582 | no_ip_lcommunity_list_standard_cmd, | |
11583 | "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...", | |
11584 | NO_STR | |
11585 | IP_STR | |
11586 | LCOMMUNITY_LIST_STR | |
11587 | "Large Community list number (standard)\n" | |
11588 | "Specify large community to reject\n" | |
11589 | "Specify large community to accept\n" | |
11590 | LCOMMUNITY_VAL_STR) | |
11591 | { | |
11592 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD); | |
11593 | } | |
11594 | ||
11595 | DEFUN (no_ip_lcommunity_list_expanded, | |
11596 | no_ip_lcommunity_list_expanded_cmd, | |
11597 | "no ip large-community-list (100-500) <deny|permit> LINE...", | |
11598 | NO_STR | |
11599 | IP_STR | |
11600 | LCOMMUNITY_LIST_STR | |
11601 | "Large Community list number (expanded)\n" | |
11602 | "Specify large community to reject\n" | |
11603 | "Specify large community to accept\n" | |
11604 | "An ordered list as a regular-expression\n") | |
11605 | { | |
11606 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED); | |
11607 | } | |
11608 | ||
11609 | DEFUN (no_ip_lcommunity_list_name_standard, | |
11610 | no_ip_lcommunity_list_name_standard_cmd, | |
11611 | "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...", | |
11612 | NO_STR | |
11613 | IP_STR | |
11614 | LCOMMUNITY_LIST_STR | |
11615 | "Specify standard large-community-list\n" | |
11616 | "Large Community list name\n" | |
11617 | "Specify large community to reject\n" | |
11618 | "Specify large community to accept\n" | |
11619 | LCOMMUNITY_VAL_STR) | |
11620 | { | |
11621 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD); | |
11622 | } | |
11623 | ||
11624 | DEFUN (no_ip_lcommunity_list_name_expanded, | |
11625 | no_ip_lcommunity_list_name_expanded_cmd, | |
11626 | "no ip large-community-list expanded WORD <deny|permit> LINE...", | |
11627 | NO_STR | |
11628 | IP_STR | |
11629 | LCOMMUNITY_LIST_STR | |
11630 | "Specify expanded large-community-list\n" | |
11631 | "Large community list name\n" | |
11632 | "Specify large community to reject\n" | |
11633 | "Specify large community to accept\n" | |
11634 | "An ordered list as a regular-expression\n") | |
11635 | { | |
11636 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED); | |
11637 | } | |
11638 | ||
11639 | static void | |
11640 | lcommunity_list_show (struct vty *vty, struct community_list *list) | |
11641 | { | |
11642 | struct community_entry *entry; | |
11643 | ||
11644 | for (entry = list->head; entry; entry = entry->next) | |
11645 | { | |
11646 | if (entry == list->head) | |
2acb4ac2 DL |
11647 | { |
11648 | if (all_digit (list->name)) | |
11649 | vty_out (vty, "Large community %s list %s%s", | |
11650 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
11651 | "standard" : "(expanded) access", | |
11652 | list->name, VTY_NEWLINE); | |
11653 | else | |
11654 | vty_out (vty, "Named large community %s list %s%s", | |
11655 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
11656 | "standard" : "expanded", | |
11657 | list->name, VTY_NEWLINE); | |
11658 | } | |
57d187bc | 11659 | if (entry->any) |
2acb4ac2 DL |
11660 | vty_out (vty, " %s%s", |
11661 | community_direct_str (entry->direct), VTY_NEWLINE); | |
57d187bc | 11662 | else |
2acb4ac2 DL |
11663 | vty_out (vty, " %s %s%s", |
11664 | community_direct_str (entry->direct), | |
11665 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
11666 | entry->u.ecom->str : entry->config, | |
11667 | VTY_NEWLINE); | |
57d187bc JS |
11668 | } |
11669 | } | |
11670 | ||
11671 | DEFUN (show_ip_lcommunity_list, | |
11672 | show_ip_lcommunity_list_cmd, | |
11673 | "show ip large-community-list", | |
11674 | SHOW_STR | |
11675 | IP_STR | |
11676 | "List large-community list\n") | |
11677 | { | |
11678 | struct community_list *list; | |
11679 | struct community_list_master *cm; | |
11680 | ||
11681 | cm = community_list_master_lookup (bgp_clist, LARGE_COMMUNITY_LIST_MASTER); | |
11682 | if (! cm) | |
11683 | return CMD_SUCCESS; | |
11684 | ||
11685 | for (list = cm->num.head; list; list = list->next) | |
11686 | lcommunity_list_show (vty, list); | |
11687 | ||
11688 | for (list = cm->str.head; list; list = list->next) | |
11689 | lcommunity_list_show (vty, list); | |
11690 | ||
11691 | return CMD_SUCCESS; | |
11692 | } | |
11693 | ||
11694 | DEFUN (show_ip_lcommunity_list_arg, | |
11695 | show_ip_lcommunity_list_arg_cmd, | |
11696 | "show ip large-community-list <(1-500)|WORD>", | |
11697 | SHOW_STR | |
11698 | IP_STR | |
11699 | "List large-community list\n" | |
11700 | "large-community-list number\n" | |
11701 | "large-community-list name\n") | |
11702 | { | |
11703 | struct community_list *list; | |
11704 | ||
11705 | list = community_list_lookup (bgp_clist, argv[3]->arg, LARGE_COMMUNITY_LIST_MASTER); | |
11706 | if (! list) | |
11707 | { | |
11708 | vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE); | |
11709 | return CMD_WARNING; | |
11710 | } | |
11711 | ||
11712 | lcommunity_list_show (vty, list); | |
11713 | ||
11714 | return CMD_SUCCESS; | |
11715 | } | |
11716 | ||
718e3744 | 11717 | /* "extcommunity-list" keyword help string. */ |
11718 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
11719 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
11720 | ||
11721 | DEFUN (ip_extcommunity_list_standard, | |
11722 | ip_extcommunity_list_standard_cmd, | |
e961923c | 11723 | "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 11724 | IP_STR |
11725 | EXTCOMMUNITY_LIST_STR | |
11726 | "Extended Community list number (standard)\n" | |
718e3744 | 11727 | "Specify standard extcommunity-list\n" |
5bf15956 | 11728 | "Community list name\n" |
718e3744 | 11729 | "Specify community to reject\n" |
11730 | "Specify community to accept\n" | |
11731 | EXTCOMMUNITY_VAL_STR) | |
11732 | { | |
42f914d4 QY |
11733 | int style = EXTCOMMUNITY_LIST_STANDARD; |
11734 | int direct = 0; | |
11735 | char *cl_number_or_name = NULL; | |
11736 | ||
11737 | int idx = 0; | |
11738 | argv_find (argv, argc, "(1-99)", &idx); | |
11739 | argv_find (argv, argc, "WORD", &idx); | |
11740 | cl_number_or_name = argv[idx]->arg; | |
11741 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11742 | argv_find (argv, argc, "AA:NN", &idx); | |
11743 | char *str = argv_concat (argv, argc, idx); | |
11744 | ||
11745 | int ret = extcommunity_list_set (bgp_clist, cl_number_or_name, str, direct, style); | |
11746 | ||
11747 | XFREE (MTYPE_TMP, str); | |
11748 | ||
11749 | if (ret < 0) | |
11750 | { | |
11751 | community_list_perror (vty, ret); | |
11752 | return CMD_WARNING; | |
11753 | } | |
11754 | ||
11755 | return CMD_SUCCESS; | |
718e3744 | 11756 | } |
11757 | ||
718e3744 | 11758 | DEFUN (ip_extcommunity_list_name_expanded, |
11759 | ip_extcommunity_list_name_expanded_cmd, | |
e961923c | 11760 | "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 11761 | IP_STR |
11762 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 11763 | "Extended Community list number (expanded)\n" |
718e3744 | 11764 | "Specify expanded extcommunity-list\n" |
11765 | "Extended Community list name\n" | |
11766 | "Specify community to reject\n" | |
11767 | "Specify community to accept\n" | |
11768 | "An ordered list as a regular-expression\n") | |
11769 | { | |
42f914d4 QY |
11770 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
11771 | int direct = 0; | |
11772 | char *cl_number_or_name = NULL; | |
11773 | ||
11774 | int idx = 0; | |
11775 | argv_find (argv, argc, "(100-500)", &idx); | |
11776 | argv_find (argv, argc, "WORD", &idx); | |
11777 | cl_number_or_name = argv[idx]->arg; | |
11778 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11779 | argv_find (argv, argc, "LINE", &idx); | |
11780 | char *str = argv_concat (argv, argc, idx); | |
11781 | ||
11782 | int ret = extcommunity_list_set (bgp_clist, cl_number_or_name, str, direct, style); | |
11783 | ||
11784 | XFREE (MTYPE_TMP, str); | |
11785 | ||
11786 | if (ret < 0) | |
11787 | { | |
11788 | community_list_perror (vty, ret); | |
11789 | return CMD_WARNING; | |
11790 | } | |
11791 | ||
11792 | return CMD_SUCCESS; | |
718e3744 | 11793 | } |
11794 | ||
fee6e4e4 | 11795 | DEFUN (no_ip_extcommunity_list_standard_all, |
11796 | no_ip_extcommunity_list_standard_all_cmd, | |
e961923c | 11797 | "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
813d4307 DW |
11798 | NO_STR |
11799 | IP_STR | |
11800 | EXTCOMMUNITY_LIST_STR | |
11801 | "Extended Community list number (standard)\n" | |
718e3744 | 11802 | "Specify standard extcommunity-list\n" |
5bf15956 | 11803 | "Community list name\n" |
718e3744 | 11804 | "Specify community to reject\n" |
11805 | "Specify community to accept\n" | |
11806 | EXTCOMMUNITY_VAL_STR) | |
11807 | { | |
42f914d4 QY |
11808 | int deleteall = 0; |
11809 | ||
11810 | int style = EXTCOMMUNITY_LIST_STANDARD; | |
11811 | int direct = 0; | |
11812 | char *cl_number_or_name = NULL; | |
11813 | ||
11814 | int idx = 0; | |
11815 | argv_find (argv, argc, "(1-99)", &idx); | |
11816 | argv_find (argv, argc, "WORD", &idx); | |
11817 | cl_number_or_name = argv[idx]->arg; | |
11818 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11819 | argv_find (argv, argc, "AA:NN", &idx); | |
11820 | char *str = argv_concat (argv, argc, idx); | |
11821 | ||
11822 | int ret = extcommunity_list_unset (bgp_clist, cl_number_or_name, str, direct, style, deleteall); | |
11823 | ||
11824 | XFREE (MTYPE_TMP, str); | |
11825 | ||
11826 | if (ret < 0) | |
11827 | { | |
11828 | community_list_perror (vty, ret); | |
11829 | return CMD_WARNING; | |
11830 | } | |
11831 | ||
11832 | return CMD_SUCCESS; | |
718e3744 | 11833 | } |
11834 | ||
5bf15956 DW |
11835 | DEFUN (no_ip_extcommunity_list_expanded_all, |
11836 | no_ip_extcommunity_list_expanded_all_cmd, | |
e961923c | 11837 | "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 11838 | NO_STR |
11839 | IP_STR | |
11840 | EXTCOMMUNITY_LIST_STR | |
11841 | "Extended Community list number (expanded)\n" | |
718e3744 | 11842 | "Specify expanded extcommunity-list\n" |
5bf15956 | 11843 | "Extended Community list name\n" |
718e3744 | 11844 | "Specify community to reject\n" |
11845 | "Specify community to accept\n" | |
11846 | "An ordered list as a regular-expression\n") | |
11847 | { | |
42f914d4 QY |
11848 | int deleteall = 0; |
11849 | ||
11850 | int style = EXTCOMMUNITY_LIST_EXPANDED; | |
11851 | int direct = 0; | |
11852 | char *cl_number_or_name = NULL; | |
11853 | ||
11854 | int idx = 0; | |
11855 | argv_find (argv, argc, "(100-500)", &idx); | |
11856 | argv_find (argv, argc, "WORD", &idx); | |
11857 | cl_number_or_name = argv[idx]->arg; | |
11858 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11859 | argv_find (argv, argc, "LINE", &idx); | |
11860 | char *str = argv_concat (argv, argc, idx); | |
11861 | ||
11862 | int ret = extcommunity_list_unset (bgp_clist, cl_number_or_name, str, direct, style, deleteall); | |
11863 | ||
11864 | XFREE (MTYPE_TMP, str); | |
11865 | ||
11866 | if (ret < 0) | |
11867 | { | |
11868 | community_list_perror (vty, ret); | |
11869 | return CMD_WARNING; | |
11870 | } | |
11871 | ||
11872 | return CMD_SUCCESS; | |
718e3744 | 11873 | } |
11874 | ||
94f2b392 | 11875 | static void |
718e3744 | 11876 | extcommunity_list_show (struct vty *vty, struct community_list *list) |
11877 | { | |
11878 | struct community_entry *entry; | |
11879 | ||
11880 | for (entry = list->head; entry; entry = entry->next) | |
11881 | { | |
11882 | if (entry == list->head) | |
11883 | { | |
11884 | if (all_digit (list->name)) | |
11885 | vty_out (vty, "Extended community %s list %s%s", | |
11886 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
11887 | "standard" : "(expanded) access", | |
11888 | list->name, VTY_NEWLINE); | |
11889 | else | |
11890 | vty_out (vty, "Named extended community %s list %s%s", | |
11891 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
11892 | "standard" : "expanded", | |
11893 | list->name, VTY_NEWLINE); | |
11894 | } | |
11895 | if (entry->any) | |
11896 | vty_out (vty, " %s%s", | |
11897 | community_direct_str (entry->direct), VTY_NEWLINE); | |
11898 | else | |
11899 | vty_out (vty, " %s %s%s", | |
11900 | community_direct_str (entry->direct), | |
11901 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
11902 | entry->u.ecom->str : entry->config, | |
11903 | VTY_NEWLINE); | |
11904 | } | |
11905 | } | |
11906 | ||
11907 | DEFUN (show_ip_extcommunity_list, | |
11908 | show_ip_extcommunity_list_cmd, | |
11909 | "show ip extcommunity-list", | |
11910 | SHOW_STR | |
11911 | IP_STR | |
11912 | "List extended-community list\n") | |
11913 | { | |
11914 | struct community_list *list; | |
11915 | struct community_list_master *cm; | |
11916 | ||
fee6e4e4 | 11917 | cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
718e3744 | 11918 | if (! cm) |
11919 | return CMD_SUCCESS; | |
11920 | ||
11921 | for (list = cm->num.head; list; list = list->next) | |
11922 | extcommunity_list_show (vty, list); | |
11923 | ||
11924 | for (list = cm->str.head; list; list = list->next) | |
11925 | extcommunity_list_show (vty, list); | |
11926 | ||
11927 | return CMD_SUCCESS; | |
11928 | } | |
11929 | ||
11930 | DEFUN (show_ip_extcommunity_list_arg, | |
11931 | show_ip_extcommunity_list_arg_cmd, | |
6147e2c6 | 11932 | "show ip extcommunity-list <(1-500)|WORD>", |
718e3744 | 11933 | SHOW_STR |
11934 | IP_STR | |
11935 | "List extended-community list\n" | |
11936 | "Extcommunity-list number\n" | |
11937 | "Extcommunity-list name\n") | |
11938 | { | |
c500ae40 | 11939 | int idx_comm_list = 3; |
718e3744 | 11940 | struct community_list *list; |
11941 | ||
c500ae40 | 11942 | list = community_list_lookup (bgp_clist, argv[idx_comm_list]->arg, EXTCOMMUNITY_LIST_MASTER); |
718e3744 | 11943 | if (! list) |
11944 | { | |
b729294c | 11945 | vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE); |
718e3744 | 11946 | return CMD_WARNING; |
11947 | } | |
11948 | ||
11949 | extcommunity_list_show (vty, list); | |
11950 | ||
11951 | return CMD_SUCCESS; | |
11952 | } | |
6b0655a2 | 11953 | |
718e3744 | 11954 | /* Return configuration string of community-list entry. */ |
fd79ac91 | 11955 | static const char * |
718e3744 | 11956 | community_list_config_str (struct community_entry *entry) |
11957 | { | |
fd79ac91 | 11958 | const char *str; |
718e3744 | 11959 | |
11960 | if (entry->any) | |
11961 | str = ""; | |
11962 | else | |
11963 | { | |
11964 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
11965 | str = community_str (entry->u.com); | |
11966 | else | |
11967 | str = entry->config; | |
11968 | } | |
11969 | return str; | |
11970 | } | |
11971 | ||
11972 | /* Display community-list and extcommunity-list configuration. */ | |
94f2b392 | 11973 | static int |
718e3744 | 11974 | community_list_config_write (struct vty *vty) |
11975 | { | |
11976 | struct community_list *list; | |
11977 | struct community_entry *entry; | |
11978 | struct community_list_master *cm; | |
11979 | int write = 0; | |
11980 | ||
11981 | /* Community-list. */ | |
fee6e4e4 | 11982 | cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER); |
718e3744 | 11983 | |
11984 | for (list = cm->num.head; list; list = list->next) | |
11985 | for (entry = list->head; entry; entry = entry->next) | |
11986 | { | |
fee6e4e4 | 11987 | vty_out (vty, "ip community-list %s %s %s%s", |
11988 | list->name, community_direct_str (entry->direct), | |
11989 | community_list_config_str (entry), | |
11990 | VTY_NEWLINE); | |
718e3744 | 11991 | write++; |
11992 | } | |
11993 | for (list = cm->str.head; list; list = list->next) | |
11994 | for (entry = list->head; entry; entry = entry->next) | |
11995 | { | |
11996 | vty_out (vty, "ip community-list %s %s %s %s%s", | |
11997 | entry->style == COMMUNITY_LIST_STANDARD | |
11998 | ? "standard" : "expanded", | |
11999 | list->name, community_direct_str (entry->direct), | |
12000 | community_list_config_str (entry), | |
12001 | VTY_NEWLINE); | |
12002 | write++; | |
12003 | } | |
12004 | ||
12005 | /* Extcommunity-list. */ | |
fee6e4e4 | 12006 | cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
718e3744 | 12007 | |
12008 | for (list = cm->num.head; list; list = list->next) | |
12009 | for (entry = list->head; entry; entry = entry->next) | |
12010 | { | |
fee6e4e4 | 12011 | vty_out (vty, "ip extcommunity-list %s %s %s%s", |
12012 | list->name, community_direct_str (entry->direct), | |
12013 | community_list_config_str (entry), VTY_NEWLINE); | |
718e3744 | 12014 | write++; |
12015 | } | |
12016 | for (list = cm->str.head; list; list = list->next) | |
12017 | for (entry = list->head; entry; entry = entry->next) | |
12018 | { | |
12019 | vty_out (vty, "ip extcommunity-list %s %s %s %s%s", | |
12020 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
12021 | ? "standard" : "expanded", | |
12022 | list->name, community_direct_str (entry->direct), | |
12023 | community_list_config_str (entry), VTY_NEWLINE); | |
12024 | write++; | |
12025 | } | |
57d187bc JS |
12026 | |
12027 | ||
12028 | /* lcommunity-list. */ | |
12029 | cm = community_list_master_lookup (bgp_clist, LARGE_COMMUNITY_LIST_MASTER); | |
12030 | ||
12031 | for (list = cm->num.head; list; list = list->next) | |
12032 | for (entry = list->head; entry; entry = entry->next) | |
12033 | { | |
2acb4ac2 DL |
12034 | vty_out (vty, "ip large-community-list %s %s %s%s", |
12035 | list->name, community_direct_str (entry->direct), | |
12036 | community_list_config_str (entry), VTY_NEWLINE); | |
12037 | write++; | |
57d187bc JS |
12038 | } |
12039 | for (list = cm->str.head; list; list = list->next) | |
12040 | for (entry = list->head; entry; entry = entry->next) | |
12041 | { | |
2acb4ac2 DL |
12042 | vty_out (vty, "ip large-community-list %s %s %s %s%s", |
12043 | entry->style == LARGE_COMMUNITY_LIST_STANDARD | |
12044 | ? "standard" : "expanded", | |
12045 | list->name, community_direct_str (entry->direct), | |
12046 | community_list_config_str (entry), VTY_NEWLINE); | |
12047 | write++; | |
57d187bc JS |
12048 | } |
12049 | ||
718e3744 | 12050 | return write; |
12051 | } | |
12052 | ||
7fc626de | 12053 | static struct cmd_node community_list_node = |
718e3744 | 12054 | { |
12055 | COMMUNITY_LIST_NODE, | |
12056 | "", | |
12057 | 1 /* Export to vtysh. */ | |
12058 | }; | |
12059 | ||
94f2b392 | 12060 | static void |
12061 | community_list_vty (void) | |
718e3744 | 12062 | { |
12063 | install_node (&community_list_node, community_list_config_write); | |
12064 | ||
12065 | /* Community-list. */ | |
718e3744 | 12066 | install_element (CONFIG_NODE, &ip_community_list_standard_cmd); |
d7d73ffc | 12067 | install_element (CONFIG_NODE, &ip_community_list_expanded_all_cmd); |
fee6e4e4 | 12068 | install_element (CONFIG_NODE, &no_ip_community_list_standard_all_cmd); |
12069 | install_element (CONFIG_NODE, &no_ip_community_list_expanded_all_cmd); | |
718e3744 | 12070 | install_element (VIEW_NODE, &show_ip_community_list_cmd); |
12071 | install_element (VIEW_NODE, &show_ip_community_list_arg_cmd); | |
718e3744 | 12072 | |
12073 | /* Extcommunity-list. */ | |
12074 | install_element (CONFIG_NODE, &ip_extcommunity_list_standard_cmd); | |
718e3744 | 12075 | install_element (CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd); |
fee6e4e4 | 12076 | install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd); |
12077 | install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd); | |
718e3744 | 12078 | install_element (VIEW_NODE, &show_ip_extcommunity_list_cmd); |
12079 | install_element (VIEW_NODE, &show_ip_extcommunity_list_arg_cmd); | |
57d187bc JS |
12080 | |
12081 | /* Large Community List */ | |
12082 | install_element (CONFIG_NODE, &ip_lcommunity_list_standard_cmd); | |
52951b63 | 12083 | install_element (CONFIG_NODE, &ip_lcommunity_list_standard1_cmd); |
57d187bc JS |
12084 | install_element (CONFIG_NODE, &ip_lcommunity_list_expanded_cmd); |
12085 | install_element (CONFIG_NODE, &ip_lcommunity_list_name_standard_cmd); | |
52951b63 | 12086 | install_element (CONFIG_NODE, &ip_lcommunity_list_name_standard1_cmd); |
57d187bc JS |
12087 | install_element (CONFIG_NODE, &ip_lcommunity_list_name_expanded_cmd); |
12088 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_standard_all_cmd); | |
12089 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_all_cmd); | |
12090 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_standard_cmd); | |
12091 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_expanded_cmd); | |
12092 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_name_standard_cmd); | |
12093 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_cmd); | |
12094 | install_element (VIEW_NODE, &show_ip_lcommunity_list_cmd); | |
12095 | install_element (VIEW_NODE, &show_ip_lcommunity_list_arg_cmd); | |
5bf15956 | 12096 | } |