]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* BGP VTY interface. |
896014f4 DL |
2 | * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro |
3 | * | |
4 | * This file is part of GNU Zebra. | |
5 | * | |
6 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
7 | * under the terms of the GNU General Public License as published by the | |
8 | * Free Software Foundation; either version 2, or (at your option) any | |
9 | * later version. | |
10 | * | |
11 | * GNU Zebra is distributed in the hope that it will be useful, but | |
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License along | |
17 | * with this program; see the file COPYING; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | */ | |
718e3744 | 20 | |
21 | #include <zebra.h> | |
22 | ||
23 | #include "command.h" | |
afec25d9 | 24 | #include "lib/json.h" |
5cb5f4d0 | 25 | #include "lib_errors.h" |
ec0ab544 | 26 | #include "lib/zclient.h" |
718e3744 | 27 | #include "prefix.h" |
28 | #include "plist.h" | |
29 | #include "buffer.h" | |
30 | #include "linklist.h" | |
31 | #include "stream.h" | |
32 | #include "thread.h" | |
33 | #include "log.h" | |
3b8b1855 | 34 | #include "memory.h" |
fc7948fa | 35 | #include "memory_vty.h" |
4bf6a362 | 36 | #include "hash.h" |
3f9c7369 | 37 | #include "queue.h" |
039f3a34 | 38 | #include "filter.h" |
5d5ba018 | 39 | #include "frrstr.h" |
718e3744 | 40 | |
41 | #include "bgpd/bgpd.h" | |
48ecf8f5 | 42 | #include "bgpd/bgp_attr_evpn.h" |
4bf6a362 | 43 | #include "bgpd/bgp_advertise.h" |
718e3744 | 44 | #include "bgpd/bgp_attr.h" |
45 | #include "bgpd/bgp_aspath.h" | |
46 | #include "bgpd/bgp_community.h" | |
4bf6a362 | 47 | #include "bgpd/bgp_ecommunity.h" |
57d187bc | 48 | #include "bgpd/bgp_lcommunity.h" |
4bf6a362 | 49 | #include "bgpd/bgp_damp.h" |
718e3744 | 50 | #include "bgpd/bgp_debug.h" |
14454c9f | 51 | #include "bgpd/bgp_errors.h" |
e0701b79 | 52 | #include "bgpd/bgp_fsm.h" |
4bf6a362 | 53 | #include "bgpd/bgp_nexthop.h" |
718e3744 | 54 | #include "bgpd/bgp_open.h" |
4bf6a362 | 55 | #include "bgpd/bgp_regex.h" |
718e3744 | 56 | #include "bgpd/bgp_route.h" |
c016b6c7 | 57 | #include "bgpd/bgp_mplsvpn.h" |
718e3744 | 58 | #include "bgpd/bgp_zebra.h" |
fee0f4c6 | 59 | #include "bgpd/bgp_table.h" |
94f2b392 | 60 | #include "bgpd/bgp_vty.h" |
165b5fff | 61 | #include "bgpd/bgp_mpath.h" |
cb1faec9 | 62 | #include "bgpd/bgp_packet.h" |
3f9c7369 | 63 | #include "bgpd/bgp_updgrp.h" |
c43ed2e4 | 64 | #include "bgpd/bgp_bfd.h" |
555e09d4 | 65 | #include "bgpd/bgp_io.h" |
94c2f693 | 66 | #include "bgpd/bgp_evpn.h" |
dcc68b5e | 67 | #include "bgpd/bgp_addpath.h" |
48ecf8f5 | 68 | #include "bgpd/bgp_mac.h" |
718e3744 | 69 | |
d62a17ae | 70 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
71 | struct prefix *range, int exact); | |
72 | ||
73 | static enum node_type bgp_node_type(afi_t afi, safi_t safi) | |
74 | { | |
75 | switch (afi) { | |
76 | case AFI_IP: | |
77 | switch (safi) { | |
78 | case SAFI_UNICAST: | |
79 | return BGP_IPV4_NODE; | |
80 | break; | |
81 | case SAFI_MULTICAST: | |
82 | return BGP_IPV4M_NODE; | |
83 | break; | |
84 | case SAFI_LABELED_UNICAST: | |
85 | return BGP_IPV4L_NODE; | |
86 | break; | |
87 | case SAFI_MPLS_VPN: | |
88 | return BGP_VPNV4_NODE; | |
89 | break; | |
7c40bf39 | 90 | case SAFI_FLOWSPEC: |
91 | return BGP_FLOWSPECV4_NODE; | |
5c525538 RW |
92 | default: |
93 | /* not expected */ | |
94 | return BGP_IPV4_NODE; | |
95 | break; | |
d62a17ae | 96 | } |
97 | break; | |
98 | case AFI_IP6: | |
99 | switch (safi) { | |
100 | case SAFI_UNICAST: | |
101 | return BGP_IPV6_NODE; | |
102 | break; | |
103 | case SAFI_MULTICAST: | |
104 | return BGP_IPV6M_NODE; | |
105 | break; | |
106 | case SAFI_LABELED_UNICAST: | |
107 | return BGP_IPV6L_NODE; | |
108 | break; | |
109 | case SAFI_MPLS_VPN: | |
110 | return BGP_VPNV6_NODE; | |
111 | break; | |
7c40bf39 | 112 | case SAFI_FLOWSPEC: |
113 | return BGP_FLOWSPECV6_NODE; | |
5c525538 RW |
114 | default: |
115 | /* not expected */ | |
116 | return BGP_IPV4_NODE; | |
117 | break; | |
d62a17ae | 118 | } |
119 | break; | |
120 | case AFI_L2VPN: | |
121 | return BGP_EVPN_NODE; | |
122 | break; | |
b26f891d | 123 | case AFI_UNSPEC: |
d62a17ae | 124 | case AFI_MAX: |
125 | // We should never be here but to clarify the switch statement.. | |
126 | return BGP_IPV4_NODE; | |
127 | break; | |
128 | } | |
129 | ||
130 | // Impossible to happen | |
131 | return BGP_IPV4_NODE; | |
f51bae9c | 132 | } |
20eb8864 | 133 | |
5cb5f4d0 DD |
134 | static const char *get_afi_safi_vty_str(afi_t afi, safi_t safi) |
135 | { | |
136 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
137 | return "IPv4 Unicast"; | |
138 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
139 | return "IPv4 Multicast"; | |
140 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
141 | return "IPv4 Labeled Unicast"; | |
142 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
143 | return "IPv4 VPN"; | |
144 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
145 | return "IPv4 Encap"; | |
146 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) | |
147 | return "IPv4 Flowspec"; | |
148 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
149 | return "IPv6 Unicast"; | |
150 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
151 | return "IPv6 Multicast"; | |
152 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
153 | return "IPv6 Labeled Unicast"; | |
154 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
155 | return "IPv6 VPN"; | |
156 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
157 | return "IPv6 Encap"; | |
158 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) | |
159 | return "IPv6 Flowspec"; | |
160 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) | |
161 | return "L2VPN EVPN"; | |
8e5509b0 | 162 | else |
5cb5f4d0 | 163 | return "Unknown"; |
5cb5f4d0 DD |
164 | } |
165 | ||
166 | /* | |
167 | * Please note that we have intentionally camelCased | |
168 | * the return strings here. So if you want | |
169 | * to use this function, please ensure you | |
170 | * are doing this within json output | |
171 | */ | |
172 | static const char *get_afi_safi_json_str(afi_t afi, safi_t safi) | |
173 | { | |
174 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
175 | return "ipv4Unicast"; | |
176 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
177 | return "ipv4Multicast"; | |
178 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
179 | return "ipv4LabeledUnicast"; | |
180 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
181 | return "ipv4Vpn"; | |
182 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
183 | return "ipv4Encap"; | |
184 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) | |
185 | return "ipv4Flowspec"; | |
186 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
187 | return "ipv6Unicast"; | |
188 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
189 | return "ipv6Multicast"; | |
190 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
191 | return "ipv6LabeledUnicast"; | |
192 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
193 | return "ipv6Vpn"; | |
194 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
195 | return "ipv6Encap"; | |
196 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) | |
197 | return "ipv6Flowspec"; | |
198 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) | |
199 | return "l2VpnEvpn"; | |
8e5509b0 | 200 | else |
5cb5f4d0 | 201 | return "Unknown"; |
5cb5f4d0 DD |
202 | } |
203 | ||
718e3744 | 204 | /* Utility function to get address family from current node. */ |
d62a17ae | 205 | afi_t bgp_node_afi(struct vty *vty) |
206 | { | |
207 | afi_t afi; | |
208 | switch (vty->node) { | |
209 | case BGP_IPV6_NODE: | |
210 | case BGP_IPV6M_NODE: | |
211 | case BGP_IPV6L_NODE: | |
212 | case BGP_VPNV6_NODE: | |
7c40bf39 | 213 | case BGP_FLOWSPECV6_NODE: |
d62a17ae | 214 | afi = AFI_IP6; |
215 | break; | |
216 | case BGP_EVPN_NODE: | |
217 | afi = AFI_L2VPN; | |
218 | break; | |
219 | default: | |
220 | afi = AFI_IP; | |
221 | break; | |
222 | } | |
223 | return afi; | |
718e3744 | 224 | } |
225 | ||
226 | /* Utility function to get subsequent address family from current | |
227 | node. */ | |
d62a17ae | 228 | safi_t bgp_node_safi(struct vty *vty) |
229 | { | |
230 | safi_t safi; | |
231 | switch (vty->node) { | |
232 | case BGP_VPNV4_NODE: | |
233 | case BGP_VPNV6_NODE: | |
234 | safi = SAFI_MPLS_VPN; | |
235 | break; | |
236 | case BGP_IPV4M_NODE: | |
237 | case BGP_IPV6M_NODE: | |
238 | safi = SAFI_MULTICAST; | |
239 | break; | |
240 | case BGP_EVPN_NODE: | |
241 | safi = SAFI_EVPN; | |
242 | break; | |
243 | case BGP_IPV4L_NODE: | |
244 | case BGP_IPV6L_NODE: | |
245 | safi = SAFI_LABELED_UNICAST; | |
246 | break; | |
7c40bf39 | 247 | case BGP_FLOWSPECV4_NODE: |
248 | case BGP_FLOWSPECV6_NODE: | |
249 | safi = SAFI_FLOWSPEC; | |
250 | break; | |
d62a17ae | 251 | default: |
252 | safi = SAFI_UNICAST; | |
253 | break; | |
254 | } | |
255 | return safi; | |
718e3744 | 256 | } |
257 | ||
55f91488 QY |
258 | /** |
259 | * Converts an AFI in string form to afi_t | |
260 | * | |
261 | * @param afi string, one of | |
262 | * - "ipv4" | |
263 | * - "ipv6" | |
81cf0de5 | 264 | * - "l2vpn" |
55f91488 QY |
265 | * @return the corresponding afi_t |
266 | */ | |
d62a17ae | 267 | afi_t bgp_vty_afi_from_str(const char *afi_str) |
268 | { | |
269 | afi_t afi = AFI_MAX; /* unknown */ | |
270 | if (strmatch(afi_str, "ipv4")) | |
271 | afi = AFI_IP; | |
272 | else if (strmatch(afi_str, "ipv6")) | |
273 | afi = AFI_IP6; | |
81cf0de5 CS |
274 | else if (strmatch(afi_str, "l2vpn")) |
275 | afi = AFI_L2VPN; | |
d62a17ae | 276 | return afi; |
277 | } | |
278 | ||
279 | int argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, | |
280 | afi_t *afi) | |
281 | { | |
282 | int ret = 0; | |
283 | if (argv_find(argv, argc, "ipv4", index)) { | |
284 | ret = 1; | |
285 | if (afi) | |
286 | *afi = AFI_IP; | |
287 | } else if (argv_find(argv, argc, "ipv6", index)) { | |
288 | ret = 1; | |
289 | if (afi) | |
290 | *afi = AFI_IP6; | |
8688b3e7 DS |
291 | } else if (argv_find(argv, argc, "l2vpn", index)) { |
292 | ret = 1; | |
293 | if (afi) | |
294 | *afi = AFI_L2VPN; | |
d62a17ae | 295 | } |
296 | return ret; | |
46f296b4 LB |
297 | } |
298 | ||
375a2e67 | 299 | /* supports <unicast|multicast|vpn|labeled-unicast> */ |
d62a17ae | 300 | safi_t bgp_vty_safi_from_str(const char *safi_str) |
301 | { | |
302 | safi_t safi = SAFI_MAX; /* unknown */ | |
303 | if (strmatch(safi_str, "multicast")) | |
304 | safi = SAFI_MULTICAST; | |
305 | else if (strmatch(safi_str, "unicast")) | |
306 | safi = SAFI_UNICAST; | |
307 | else if (strmatch(safi_str, "vpn")) | |
308 | safi = SAFI_MPLS_VPN; | |
81cf0de5 CS |
309 | else if (strmatch(safi_str, "evpn")) |
310 | safi = SAFI_EVPN; | |
d62a17ae | 311 | else if (strmatch(safi_str, "labeled-unicast")) |
312 | safi = SAFI_LABELED_UNICAST; | |
7c40bf39 | 313 | else if (strmatch(safi_str, "flowspec")) |
314 | safi = SAFI_FLOWSPEC; | |
d62a17ae | 315 | return safi; |
316 | } | |
317 | ||
318 | int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, | |
319 | safi_t *safi) | |
320 | { | |
321 | int ret = 0; | |
322 | if (argv_find(argv, argc, "unicast", index)) { | |
323 | ret = 1; | |
324 | if (safi) | |
325 | *safi = SAFI_UNICAST; | |
326 | } else if (argv_find(argv, argc, "multicast", index)) { | |
327 | ret = 1; | |
328 | if (safi) | |
329 | *safi = SAFI_MULTICAST; | |
330 | } else if (argv_find(argv, argc, "labeled-unicast", index)) { | |
331 | ret = 1; | |
332 | if (safi) | |
333 | *safi = SAFI_LABELED_UNICAST; | |
334 | } else if (argv_find(argv, argc, "vpn", index)) { | |
335 | ret = 1; | |
336 | if (safi) | |
337 | *safi = SAFI_MPLS_VPN; | |
8688b3e7 DS |
338 | } else if (argv_find(argv, argc, "evpn", index)) { |
339 | ret = 1; | |
340 | if (safi) | |
341 | *safi = SAFI_EVPN; | |
7c40bf39 | 342 | } else if (argv_find(argv, argc, "flowspec", index)) { |
343 | ret = 1; | |
344 | if (safi) | |
345 | *safi = SAFI_FLOWSPEC; | |
d62a17ae | 346 | } |
347 | return ret; | |
46f296b4 LB |
348 | } |
349 | ||
7eeee51e | 350 | /* |
f212a857 | 351 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 352 | * |
f212a857 DS |
353 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
354 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
355 | * to appropriate values for the calling function. This is to allow the |
356 | * calling function to make decisions appropriate for the show command | |
357 | * that is being parsed. | |
358 | * | |
359 | * The show commands are generally of the form: | |
d62a17ae | 360 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> |
361 | * [<unicast|multicast|vpn|labeled-unicast>]] ..." | |
7eeee51e DS |
362 | * |
363 | * Since we use argv_find if the show command in particular doesn't have: | |
364 | * [ip] | |
18c57037 | 365 | * [<view|vrf> VIEWVRFNAME] |
375a2e67 | 366 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] |
7eeee51e DS |
367 | * The command parsing should still be ok. |
368 | * | |
369 | * vty -> The vty for the command so we can output some useful data in | |
370 | * the event of a parse error in the vrf. | |
371 | * argv -> The command tokens | |
372 | * argc -> How many command tokens we have | |
d62a17ae | 373 | * idx -> The current place in the command, generally should be 0 for this |
374 | * function | |
7eeee51e DS |
375 | * afi -> The parsed afi if it was included in the show command, returned here |
376 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 377 | * bgp -> Pointer to the bgp data structure we need to fill in. |
52e5b8c4 | 378 | * use_json -> json is configured or not |
7eeee51e DS |
379 | * |
380 | * The function returns the correct location in the parse tree for the | |
381 | * last token found. | |
0e37c258 DS |
382 | * |
383 | * Returns 0 for failure to parse correctly, else the idx position of where | |
384 | * it found the last token. | |
7eeee51e | 385 | */ |
d62a17ae | 386 | int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, |
387 | struct cmd_token **argv, int argc, | |
388 | int *idx, afi_t *afi, safi_t *safi, | |
9f049418 | 389 | struct bgp **bgp, bool use_json) |
d62a17ae | 390 | { |
391 | char *vrf_name = NULL; | |
392 | ||
393 | assert(afi); | |
394 | assert(safi); | |
395 | assert(bgp); | |
396 | ||
397 | if (argv_find(argv, argc, "ip", idx)) | |
398 | *afi = AFI_IP; | |
399 | ||
9a8bdf1c | 400 | if (argv_find(argv, argc, "view", idx)) |
d62a17ae | 401 | vrf_name = argv[*idx + 1]->arg; |
9a8bdf1c PG |
402 | else if (argv_find(argv, argc, "vrf", idx)) { |
403 | vrf_name = argv[*idx + 1]->arg; | |
404 | if (strmatch(vrf_name, VRF_DEFAULT_NAME)) | |
405 | vrf_name = NULL; | |
406 | } | |
407 | if (vrf_name) { | |
d62a17ae | 408 | if (strmatch(vrf_name, "all")) |
409 | *bgp = NULL; | |
410 | else { | |
411 | *bgp = bgp_lookup_by_name(vrf_name); | |
412 | if (!*bgp) { | |
52e5b8c4 SP |
413 | if (use_json) { |
414 | json_object *json = NULL; | |
415 | json = json_object_new_object(); | |
416 | json_object_string_add( | |
417 | json, "warning", | |
418 | "View/Vrf is unknown"); | |
419 | vty_out(vty, "%s\n", | |
420 | json_object_to_json_string_ext(json, | |
421 | JSON_C_TO_STRING_PRETTY)); | |
422 | json_object_free(json); | |
423 | } | |
ca61fd25 DS |
424 | else |
425 | vty_out(vty, "View/Vrf %s is unknown\n", | |
426 | vrf_name); | |
d62a17ae | 427 | *idx = 0; |
428 | return 0; | |
429 | } | |
430 | } | |
431 | } else { | |
432 | *bgp = bgp_get_default(); | |
433 | if (!*bgp) { | |
52e5b8c4 SP |
434 | if (use_json) { |
435 | json_object *json = NULL; | |
436 | json = json_object_new_object(); | |
437 | json_object_string_add( | |
438 | json, "warning", | |
439 | "Default BGP instance not found"); | |
440 | vty_out(vty, "%s\n", | |
441 | json_object_to_json_string_ext(json, | |
442 | JSON_C_TO_STRING_PRETTY)); | |
443 | json_object_free(json); | |
444 | } | |
ca61fd25 DS |
445 | else |
446 | vty_out(vty, | |
447 | "Default BGP instance not found\n"); | |
d62a17ae | 448 | *idx = 0; |
449 | return 0; | |
450 | } | |
451 | } | |
452 | ||
453 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
454 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
455 | ||
456 | *idx += 1; | |
457 | return *idx; | |
458 | } | |
459 | ||
460 | static int peer_address_self_check(struct bgp *bgp, union sockunion *su) | |
461 | { | |
462 | struct interface *ifp = NULL; | |
463 | ||
464 | if (su->sa.sa_family == AF_INET) | |
465 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); | |
466 | else if (su->sa.sa_family == AF_INET6) | |
467 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, | |
468 | su->sin6.sin6_scope_id, | |
469 | bgp->vrf_id); | |
470 | ||
471 | if (ifp) | |
472 | return 1; | |
473 | ||
474 | return 0; | |
718e3744 | 475 | } |
476 | ||
477 | /* Utility function for looking up peer from VTY. */ | |
f14e6fdb DS |
478 | /* This is used only for configuration, so disallow if attempted on |
479 | * a dynamic neighbor. | |
480 | */ | |
d62a17ae | 481 | static struct peer *peer_lookup_vty(struct vty *vty, const char *ip_str) |
482 | { | |
483 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
484 | int ret; | |
485 | union sockunion su; | |
486 | struct peer *peer; | |
487 | ||
488 | if (!bgp) { | |
489 | return NULL; | |
490 | } | |
491 | ||
492 | ret = str2sockunion(ip_str, &su); | |
493 | if (ret < 0) { | |
494 | peer = peer_lookup_by_conf_if(bgp, ip_str); | |
495 | if (!peer) { | |
496 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) | |
497 | == NULL) { | |
498 | vty_out(vty, | |
499 | "%% Malformed address or name: %s\n", | |
500 | ip_str); | |
501 | return NULL; | |
502 | } | |
503 | } | |
504 | } else { | |
505 | peer = peer_lookup(bgp, &su); | |
506 | if (!peer) { | |
507 | vty_out(vty, | |
508 | "%% Specify remote-as or peer-group commands first\n"); | |
509 | return NULL; | |
510 | } | |
511 | if (peer_dynamic_neighbor(peer)) { | |
512 | vty_out(vty, | |
513 | "%% Operation not allowed on a dynamic neighbor\n"); | |
514 | return NULL; | |
515 | } | |
516 | } | |
517 | return peer; | |
718e3744 | 518 | } |
519 | ||
520 | /* Utility function for looking up peer or peer group. */ | |
f14e6fdb DS |
521 | /* This is used only for configuration, so disallow if attempted on |
522 | * a dynamic neighbor. | |
523 | */ | |
d62a17ae | 524 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) |
525 | { | |
526 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
527 | int ret; | |
528 | union sockunion su; | |
529 | struct peer *peer = NULL; | |
530 | struct peer_group *group = NULL; | |
531 | ||
532 | if (!bgp) { | |
533 | return NULL; | |
534 | } | |
535 | ||
536 | ret = str2sockunion(peer_str, &su); | |
537 | if (ret == 0) { | |
538 | /* IP address, locate peer. */ | |
539 | peer = peer_lookup(bgp, &su); | |
540 | } else { | |
541 | /* Not IP, could match either peer configured on interface or a | |
542 | * group. */ | |
543 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
544 | if (!peer) | |
545 | group = peer_group_lookup(bgp, peer_str); | |
546 | } | |
547 | ||
548 | if (peer) { | |
549 | if (peer_dynamic_neighbor(peer)) { | |
550 | vty_out(vty, | |
551 | "%% Operation not allowed on a dynamic neighbor\n"); | |
552 | return NULL; | |
553 | } | |
554 | ||
555 | return peer; | |
556 | } | |
557 | ||
558 | if (group) | |
559 | return group->conf; | |
560 | ||
561 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); | |
562 | ||
563 | return NULL; | |
564 | } | |
565 | ||
566 | int bgp_vty_return(struct vty *vty, int ret) | |
567 | { | |
568 | const char *str = NULL; | |
569 | ||
570 | switch (ret) { | |
571 | case BGP_ERR_INVALID_VALUE: | |
572 | str = "Invalid value"; | |
573 | break; | |
574 | case BGP_ERR_INVALID_FLAG: | |
575 | str = "Invalid flag"; | |
576 | break; | |
577 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
578 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
579 | break; | |
580 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
581 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
582 | break; | |
583 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
584 | str = "Specify remote-as or peer-group remote AS first"; | |
585 | break; | |
586 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
587 | str = "Cannot change the peer-group. Deconfigure first"; | |
588 | break; | |
589 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
590 | str = "Peer is not a member of this peer-group"; | |
591 | break; | |
592 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
593 | str = "Prefix/distribute list can not co-exist"; | |
594 | break; | |
595 | case BGP_ERR_NOT_INTERNAL_PEER: | |
596 | str = "Invalid command. Not an internal neighbor"; | |
597 | break; | |
598 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
599 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
600 | break; | |
601 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
602 | str = "Local-AS allowed only for EBGP peers"; | |
603 | break; | |
604 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
605 | str = "Cannot have local-as same as BGP AS number"; | |
606 | break; | |
607 | case BGP_ERR_TCPSIG_FAILED: | |
608 | str = "Error while applying TCP-Sig to session(s)"; | |
609 | break; | |
610 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
611 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
612 | break; | |
613 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
614 | str = "ttl-security only allowed for EBGP peers"; | |
615 | break; | |
616 | case BGP_ERR_AS_OVERRIDE: | |
617 | str = "as-override cannot be configured for IBGP peers"; | |
618 | break; | |
619 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
620 | str = "Invalid limit for number of dynamic neighbors"; | |
621 | break; | |
622 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
623 | str = "Dynamic neighbor listen range already exists"; | |
624 | break; | |
625 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
626 | str = "Operation not allowed on a dynamic neighbor"; | |
627 | break; | |
628 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
629 | str = "Operation not allowed on a directly connected neighbor"; | |
630 | break; | |
631 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
632 | str = "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'"; | |
633 | break; | |
634 | } | |
635 | if (str) { | |
636 | vty_out(vty, "%% %s\n", str); | |
637 | return CMD_WARNING_CONFIG_FAILED; | |
638 | } | |
639 | return CMD_SUCCESS; | |
718e3744 | 640 | } |
641 | ||
7aafcaca | 642 | /* BGP clear sort. */ |
d62a17ae | 643 | enum clear_sort { |
644 | clear_all, | |
645 | clear_peer, | |
646 | clear_group, | |
647 | clear_external, | |
648 | clear_as | |
7aafcaca DS |
649 | }; |
650 | ||
d62a17ae | 651 | static void bgp_clear_vty_error(struct vty *vty, struct peer *peer, afi_t afi, |
652 | safi_t safi, int error) | |
653 | { | |
654 | switch (error) { | |
655 | case BGP_ERR_AF_UNCONFIGURED: | |
656 | vty_out(vty, | |
657 | "%%BGP: Enable %s address family for the neighbor %s\n", | |
5cb5f4d0 | 658 | get_afi_safi_str(afi, safi, false), peer->host); |
d62a17ae | 659 | break; |
660 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
661 | vty_out(vty, | |
662 | "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n", | |
663 | peer->host); | |
664 | break; | |
665 | default: | |
666 | break; | |
667 | } | |
7aafcaca DS |
668 | } |
669 | ||
dc912615 DS |
670 | static int bgp_peer_clear(struct peer *peer, afi_t afi, safi_t safi, |
671 | struct listnode *nnode, enum bgp_clear_type stype) | |
672 | { | |
673 | int ret = 0; | |
674 | ||
675 | /* if afi/.safi not specified, spin thru all of them */ | |
676 | if ((afi == AFI_UNSPEC) && (safi == SAFI_UNSPEC)) { | |
677 | afi_t tmp_afi; | |
678 | safi_t tmp_safi; | |
679 | ||
680 | FOREACH_AFI_SAFI (tmp_afi, tmp_safi) { | |
681 | if (!peer->afc[tmp_afi][tmp_safi]) | |
682 | continue; | |
683 | ||
684 | if (stype == BGP_CLEAR_SOFT_NONE) | |
685 | ret = peer_clear(peer, &nnode); | |
686 | else | |
687 | ret = peer_clear_soft(peer, tmp_afi, tmp_safi, | |
688 | stype); | |
689 | } | |
690 | /* if afi specified and safi not, spin thru safis on this afi */ | |
691 | } else if (safi == SAFI_UNSPEC) { | |
692 | safi_t tmp_safi; | |
693 | ||
694 | for (tmp_safi = SAFI_UNICAST; | |
695 | tmp_safi < SAFI_MAX; tmp_safi++) { | |
696 | if (!peer->afc[afi][tmp_safi]) | |
697 | continue; | |
698 | ||
699 | if (stype == BGP_CLEAR_SOFT_NONE) | |
700 | ret = peer_clear(peer, &nnode); | |
701 | else | |
702 | ret = peer_clear_soft(peer, afi, | |
703 | tmp_safi, stype); | |
704 | } | |
705 | /* both afi/safi specified, let the caller know if not defined */ | |
706 | } else { | |
707 | if (!peer->afc[afi][safi]) | |
708 | return 1; | |
709 | ||
710 | if (stype == BGP_CLEAR_SOFT_NONE) | |
711 | ret = peer_clear(peer, &nnode); | |
712 | else | |
713 | ret = peer_clear_soft(peer, afi, safi, stype); | |
714 | } | |
715 | ||
716 | return ret; | |
717 | } | |
718 | ||
7aafcaca | 719 | /* `clear ip bgp' functions. */ |
d62a17ae | 720 | static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
721 | enum clear_sort sort, enum bgp_clear_type stype, | |
722 | const char *arg) | |
723 | { | |
dc912615 | 724 | int ret = 0; |
3ae8bfa5 | 725 | bool found = false; |
d62a17ae | 726 | struct peer *peer; |
727 | struct listnode *node, *nnode; | |
728 | ||
729 | /* Clear all neighbors. */ | |
730 | /* | |
731 | * Pass along pointer to next node to peer_clear() when walking all | |
3ae8bfa5 PM |
732 | * nodes on the BGP instance as that may get freed if it is a |
733 | * doppelganger | |
d62a17ae | 734 | */ |
735 | if (sort == clear_all) { | |
736 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
dc912615 DS |
737 | ret = bgp_peer_clear(peer, afi, safi, nnode, |
738 | stype); | |
d62a17ae | 739 | |
740 | if (ret < 0) | |
741 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
04b6bdc0 | 742 | } |
d62a17ae | 743 | |
744 | /* This is to apply read-only mode on this clear. */ | |
745 | if (stype == BGP_CLEAR_SOFT_NONE) | |
746 | bgp->update_delay_over = 0; | |
747 | ||
748 | return CMD_SUCCESS; | |
7aafcaca DS |
749 | } |
750 | ||
3ae8bfa5 | 751 | /* Clear specified neighbor. */ |
d62a17ae | 752 | if (sort == clear_peer) { |
753 | union sockunion su; | |
d62a17ae | 754 | |
755 | /* Make sockunion for lookup. */ | |
756 | ret = str2sockunion(arg, &su); | |
757 | if (ret < 0) { | |
758 | peer = peer_lookup_by_conf_if(bgp, arg); | |
759 | if (!peer) { | |
760 | peer = peer_lookup_by_hostname(bgp, arg); | |
761 | if (!peer) { | |
762 | vty_out(vty, | |
763 | "Malformed address or name: %s\n", | |
764 | arg); | |
765 | return CMD_WARNING; | |
766 | } | |
767 | } | |
768 | } else { | |
769 | peer = peer_lookup(bgp, &su); | |
770 | if (!peer) { | |
771 | vty_out(vty, | |
772 | "%%BGP: Unknown neighbor - \"%s\"\n", | |
773 | arg); | |
774 | return CMD_WARNING; | |
775 | } | |
776 | } | |
7aafcaca | 777 | |
dc912615 DS |
778 | ret = bgp_peer_clear(peer, afi, safi, NULL, stype); |
779 | ||
780 | /* if afi/safi not defined for this peer, let caller know */ | |
781 | if (ret == 1) | |
3ae8bfa5 | 782 | ret = BGP_ERR_AF_UNCONFIGURED; |
7aafcaca | 783 | |
d62a17ae | 784 | if (ret < 0) |
785 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
7aafcaca | 786 | |
d62a17ae | 787 | return CMD_SUCCESS; |
7aafcaca | 788 | } |
7aafcaca | 789 | |
3ae8bfa5 | 790 | /* Clear all neighbors belonging to a specific peer-group. */ |
d62a17ae | 791 | if (sort == clear_group) { |
792 | struct peer_group *group; | |
7aafcaca | 793 | |
d62a17ae | 794 | group = peer_group_lookup(bgp, arg); |
795 | if (!group) { | |
796 | vty_out(vty, "%%BGP: No such peer-group %s\n", arg); | |
797 | return CMD_WARNING; | |
798 | } | |
799 | ||
800 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
dc912615 | 801 | ret = bgp_peer_clear(peer, afi, safi, nnode, stype); |
7aafcaca | 802 | |
d62a17ae | 803 | if (ret < 0) |
804 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
805 | else |
806 | found = true; | |
d62a17ae | 807 | } |
3ae8bfa5 PM |
808 | |
809 | if (!found) | |
810 | vty_out(vty, | |
811 | "%%BGP: No %s peer belonging to peer-group %s is configured\n", | |
5cb5f4d0 | 812 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 813 | |
d62a17ae | 814 | return CMD_SUCCESS; |
7aafcaca | 815 | } |
7aafcaca | 816 | |
3ae8bfa5 | 817 | /* Clear all external (eBGP) neighbors. */ |
d62a17ae | 818 | if (sort == clear_external) { |
819 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
820 | if (peer->sort == BGP_PEER_IBGP) | |
821 | continue; | |
7aafcaca | 822 | |
dc912615 | 823 | ret = bgp_peer_clear(peer, afi, safi, nnode, stype); |
7aafcaca | 824 | |
d62a17ae | 825 | if (ret < 0) |
826 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
827 | else |
828 | found = true; | |
d62a17ae | 829 | } |
3ae8bfa5 PM |
830 | |
831 | if (!found) | |
832 | vty_out(vty, | |
833 | "%%BGP: No external %s peer is configured\n", | |
5cb5f4d0 | 834 | get_afi_safi_str(afi, safi, false)); |
3ae8bfa5 | 835 | |
d62a17ae | 836 | return CMD_SUCCESS; |
837 | } | |
838 | ||
3ae8bfa5 | 839 | /* Clear all neighbors belonging to a specific AS. */ |
d62a17ae | 840 | if (sort == clear_as) { |
3ae8bfa5 | 841 | as_t as = strtoul(arg, NULL, 10); |
d62a17ae | 842 | |
843 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
844 | if (peer->as != as) | |
845 | continue; | |
846 | ||
dc912615 | 847 | ret = bgp_peer_clear(peer, afi, safi, nnode, stype); |
d62a17ae | 848 | |
849 | if (ret < 0) | |
850 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
851 | else |
852 | found = true; | |
d62a17ae | 853 | } |
3ae8bfa5 PM |
854 | |
855 | if (!found) | |
d62a17ae | 856 | vty_out(vty, |
3ae8bfa5 | 857 | "%%BGP: No %s peer is configured with AS %s\n", |
5cb5f4d0 | 858 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 859 | |
d62a17ae | 860 | return CMD_SUCCESS; |
861 | } | |
862 | ||
863 | return CMD_SUCCESS; | |
864 | } | |
865 | ||
866 | static int bgp_clear_vty(struct vty *vty, const char *name, afi_t afi, | |
867 | safi_t safi, enum clear_sort sort, | |
868 | enum bgp_clear_type stype, const char *arg) | |
869 | { | |
870 | struct bgp *bgp; | |
871 | ||
872 | /* BGP structure lookup. */ | |
873 | if (name) { | |
874 | bgp = bgp_lookup_by_name(name); | |
875 | if (bgp == NULL) { | |
876 | vty_out(vty, "Can't find BGP instance %s\n", name); | |
877 | return CMD_WARNING; | |
878 | } | |
879 | } else { | |
880 | bgp = bgp_get_default(); | |
881 | if (bgp == NULL) { | |
882 | vty_out(vty, "No BGP process is configured\n"); | |
883 | return CMD_WARNING; | |
884 | } | |
885 | } | |
886 | ||
887 | return bgp_clear(vty, bgp, afi, safi, sort, stype, arg); | |
7aafcaca DS |
888 | } |
889 | ||
890 | /* clear soft inbound */ | |
d62a17ae | 891 | static void bgp_clear_star_soft_in(struct vty *vty, const char *name) |
7aafcaca | 892 | { |
99b3ebd3 NS |
893 | afi_t afi; |
894 | safi_t safi; | |
895 | ||
896 | FOREACH_AFI_SAFI (afi, safi) | |
897 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
898 | BGP_CLEAR_SOFT_IN, NULL); | |
7aafcaca DS |
899 | } |
900 | ||
901 | /* clear soft outbound */ | |
d62a17ae | 902 | static void bgp_clear_star_soft_out(struct vty *vty, const char *name) |
7aafcaca | 903 | { |
99b3ebd3 NS |
904 | afi_t afi; |
905 | safi_t safi; | |
906 | ||
907 | FOREACH_AFI_SAFI (afi, safi) | |
908 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
909 | BGP_CLEAR_SOFT_OUT, NULL); | |
7aafcaca DS |
910 | } |
911 | ||
912 | ||
f787d7a0 | 913 | #ifndef VTYSH_EXTRACT_PL |
2e4c2296 | 914 | #include "bgpd/bgp_vty_clippy.c" |
f787d7a0 DL |
915 | #endif |
916 | ||
8029b216 AK |
917 | DEFUN_HIDDEN (bgp_local_mac, |
918 | bgp_local_mac_cmd, | |
093e3f23 | 919 | "bgp local-mac vni " CMD_VNI_RANGE " mac WORD seq (0-4294967295)", |
8029b216 AK |
920 | BGP_STR |
921 | "Local MAC config\n" | |
922 | "VxLAN Network Identifier\n" | |
923 | "VNI number\n" | |
924 | "local mac\n" | |
925 | "mac address\n" | |
926 | "mac-mobility sequence\n" | |
927 | "seq number\n") | |
928 | { | |
929 | int rv; | |
930 | vni_t vni; | |
931 | struct ethaddr mac; | |
932 | struct ipaddr ip; | |
933 | uint32_t seq; | |
934 | struct bgp *bgp; | |
935 | ||
936 | vni = strtoul(argv[3]->arg, NULL, 10); | |
937 | if (!prefix_str2mac(argv[5]->arg, &mac)) { | |
938 | vty_out(vty, "%% Malformed MAC address\n"); | |
939 | return CMD_WARNING; | |
940 | } | |
941 | memset(&ip, 0, sizeof(ip)); | |
942 | seq = strtoul(argv[7]->arg, NULL, 10); | |
943 | ||
944 | bgp = bgp_get_default(); | |
945 | if (!bgp) { | |
946 | vty_out(vty, "Default BGP instance is not there\n"); | |
947 | return CMD_WARNING; | |
948 | } | |
949 | ||
950 | rv = bgp_evpn_local_macip_add(bgp, vni, &mac, &ip, 0 /* flags */, seq); | |
951 | if (rv < 0) { | |
952 | vty_out(vty, "Internal error\n"); | |
953 | return CMD_WARNING; | |
954 | } | |
955 | ||
956 | return CMD_SUCCESS; | |
957 | } | |
958 | ||
959 | DEFUN_HIDDEN (no_bgp_local_mac, | |
960 | no_bgp_local_mac_cmd, | |
093e3f23 | 961 | "no bgp local-mac vni " CMD_VNI_RANGE " mac WORD", |
8029b216 AK |
962 | NO_STR |
963 | BGP_STR | |
964 | "Local MAC config\n" | |
965 | "VxLAN Network Identifier\n" | |
966 | "VNI number\n" | |
967 | "local mac\n" | |
968 | "mac address\n") | |
969 | { | |
970 | int rv; | |
971 | vni_t vni; | |
972 | struct ethaddr mac; | |
973 | struct ipaddr ip; | |
974 | struct bgp *bgp; | |
975 | ||
976 | vni = strtoul(argv[4]->arg, NULL, 10); | |
977 | if (!prefix_str2mac(argv[6]->arg, &mac)) { | |
978 | vty_out(vty, "%% Malformed MAC address\n"); | |
979 | return CMD_WARNING; | |
980 | } | |
981 | memset(&ip, 0, sizeof(ip)); | |
982 | ||
983 | bgp = bgp_get_default(); | |
984 | if (!bgp) { | |
985 | vty_out(vty, "Default BGP instance is not there\n"); | |
986 | return CMD_WARNING; | |
987 | } | |
988 | ||
ec0ab544 | 989 | rv = bgp_evpn_local_macip_del(bgp, vni, &mac, &ip, ZEBRA_NEIGH_ACTIVE); |
8029b216 AK |
990 | if (rv < 0) { |
991 | vty_out(vty, "Internal error\n"); | |
992 | return CMD_WARNING; | |
993 | } | |
994 | ||
995 | return CMD_SUCCESS; | |
996 | } | |
997 | ||
718e3744 | 998 | DEFUN (no_synchronization, |
999 | no_synchronization_cmd, | |
1000 | "no synchronization", | |
1001 | NO_STR | |
1002 | "Perform IGP synchronization\n") | |
1003 | { | |
d62a17ae | 1004 | return CMD_SUCCESS; |
718e3744 | 1005 | } |
1006 | ||
1007 | DEFUN (no_auto_summary, | |
1008 | no_auto_summary_cmd, | |
1009 | "no auto-summary", | |
1010 | NO_STR | |
1011 | "Enable automatic network number summarization\n") | |
1012 | { | |
d62a17ae | 1013 | return CMD_SUCCESS; |
718e3744 | 1014 | } |
3d515fd9 | 1015 | |
718e3744 | 1016 | /* "router bgp" commands. */ |
505e5056 | 1017 | DEFUN_NOSH (router_bgp, |
f412b39a | 1018 | router_bgp_cmd, |
2ed9fe4a | 1019 | "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 1020 | ROUTER_STR |
1021 | BGP_STR | |
31500417 DW |
1022 | AS_STR |
1023 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1024 | { |
d62a17ae | 1025 | int idx_asn = 2; |
1026 | int idx_view_vrf = 3; | |
1027 | int idx_vrf = 4; | |
ecec9495 | 1028 | int is_new_bgp = 0; |
d62a17ae | 1029 | int ret; |
1030 | as_t as; | |
1031 | struct bgp *bgp; | |
1032 | const char *name = NULL; | |
1033 | enum bgp_instance_type inst_type; | |
1034 | ||
1035 | // "router bgp" without an ASN | |
1036 | if (argc == 2) { | |
1037 | // Pending: Make VRF option available for ASN less config | |
1038 | bgp = bgp_get_default(); | |
1039 | ||
1040 | if (bgp == NULL) { | |
1041 | vty_out(vty, "%% No BGP process is configured\n"); | |
1042 | return CMD_WARNING_CONFIG_FAILED; | |
1043 | } | |
1044 | ||
1045 | if (listcount(bm->bgp) > 1) { | |
996c9314 | 1046 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1047 | return CMD_WARNING_CONFIG_FAILED; |
1048 | } | |
1049 | } | |
1050 | ||
1051 | // "router bgp X" | |
1052 | else { | |
1053 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
1054 | ||
1055 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; | |
1056 | if (argc > 3) { | |
1057 | name = argv[idx_vrf]->arg; | |
1058 | ||
9a8bdf1c PG |
1059 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) { |
1060 | if (strmatch(name, VRF_DEFAULT_NAME)) | |
1061 | name = NULL; | |
1062 | else | |
1063 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
1064 | } else if (!strcmp(argv[idx_view_vrf]->text, "view")) | |
d62a17ae | 1065 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
1066 | } | |
1067 | ||
ecec9495 AD |
1068 | if (inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
1069 | is_new_bgp = (bgp_lookup(as, name) == NULL); | |
1070 | ||
d62a17ae | 1071 | ret = bgp_get(&bgp, &as, name, inst_type); |
1072 | switch (ret) { | |
d62a17ae | 1073 | case BGP_ERR_AS_MISMATCH: |
1074 | vty_out(vty, "BGP is already running; AS is %u\n", as); | |
1075 | return CMD_WARNING_CONFIG_FAILED; | |
1076 | case BGP_ERR_INSTANCE_MISMATCH: | |
1077 | vty_out(vty, | |
1078 | "BGP instance name and AS number mismatch\n"); | |
1079 | vty_out(vty, | |
1080 | "BGP instance is already running; AS is %u\n", | |
1081 | as); | |
1082 | return CMD_WARNING_CONFIG_FAILED; | |
1083 | } | |
1084 | ||
3bd70bf8 PZ |
1085 | /* |
1086 | * If we just instantiated the default instance, complete | |
1087 | * any pending VRF-VPN leaking that was configured via | |
1088 | * earlier "router bgp X vrf FOO" blocks. | |
1089 | */ | |
ecec9495 | 1090 | if (is_new_bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
3bd70bf8 PZ |
1091 | vpn_leak_postchange_all(); |
1092 | ||
48381346 CS |
1093 | if (inst_type == BGP_INSTANCE_TYPE_VRF) |
1094 | bgp_vpn_leak_export(bgp); | |
d62a17ae | 1095 | /* Pending: handle when user tries to change a view to vrf n vv. |
1096 | */ | |
1097 | } | |
1098 | ||
0b5131c9 MK |
1099 | /* unset the auto created flag as the user config is now present */ |
1100 | UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO); | |
d62a17ae | 1101 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); |
1102 | ||
1103 | return CMD_SUCCESS; | |
718e3744 | 1104 | } |
1105 | ||
718e3744 | 1106 | /* "no router bgp" commands. */ |
1107 | DEFUN (no_router_bgp, | |
1108 | no_router_bgp_cmd, | |
2ed9fe4a | 1109 | "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 1110 | NO_STR |
1111 | ROUTER_STR | |
1112 | BGP_STR | |
31500417 DW |
1113 | AS_STR |
1114 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1115 | { |
d62a17ae | 1116 | int idx_asn = 3; |
1117 | int idx_vrf = 5; | |
1118 | as_t as; | |
1119 | struct bgp *bgp; | |
1120 | const char *name = NULL; | |
718e3744 | 1121 | |
d62a17ae | 1122 | // "no router bgp" without an ASN |
1123 | if (argc == 3) { | |
1124 | // Pending: Make VRF option available for ASN less config | |
1125 | bgp = bgp_get_default(); | |
718e3744 | 1126 | |
d62a17ae | 1127 | if (bgp == NULL) { |
1128 | vty_out(vty, "%% No BGP process is configured\n"); | |
1129 | return CMD_WARNING_CONFIG_FAILED; | |
1130 | } | |
7fb21a9f | 1131 | |
d62a17ae | 1132 | if (listcount(bm->bgp) > 1) { |
996c9314 | 1133 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1134 | return CMD_WARNING_CONFIG_FAILED; |
1135 | } | |
0b5131c9 MK |
1136 | |
1137 | if (bgp->l3vni) { | |
1138 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
1139 | bgp->l3vni); | |
1140 | return CMD_WARNING_CONFIG_FAILED; | |
1141 | } | |
d62a17ae | 1142 | } else { |
1143 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
7fb21a9f | 1144 | |
d62a17ae | 1145 | if (argc > 4) |
1146 | name = argv[idx_vrf]->arg; | |
7fb21a9f | 1147 | |
d62a17ae | 1148 | /* Lookup bgp structure. */ |
1149 | bgp = bgp_lookup(as, name); | |
1150 | if (!bgp) { | |
1151 | vty_out(vty, "%% Can't find BGP instance\n"); | |
1152 | return CMD_WARNING_CONFIG_FAILED; | |
1153 | } | |
0b5131c9 MK |
1154 | |
1155 | if (bgp->l3vni) { | |
dd5868c2 | 1156 | vty_out(vty, "%% Please unconfigure l3vni %u\n", |
0b5131c9 MK |
1157 | bgp->l3vni); |
1158 | return CMD_WARNING_CONFIG_FAILED; | |
1159 | } | |
dd5868c2 DS |
1160 | |
1161 | /* Cannot delete default instance if vrf instances exist */ | |
1162 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
1163 | struct listnode *node; | |
1164 | struct bgp *tmp_bgp; | |
1165 | ||
1166 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, tmp_bgp)) { | |
1167 | if (tmp_bgp->inst_type | |
1168 | == BGP_INSTANCE_TYPE_VRF) { | |
1169 | vty_out(vty, | |
1170 | "%% Cannot delete default BGP instance. Dependent VRF instances exist\n"); | |
1171 | return CMD_WARNING_CONFIG_FAILED; | |
1172 | } | |
1173 | } | |
1174 | } | |
d62a17ae | 1175 | } |
718e3744 | 1176 | |
9ecf931b CS |
1177 | if (bgp_vpn_leak_unimport(bgp, vty)) |
1178 | return CMD_WARNING_CONFIG_FAILED; | |
1179 | ||
d62a17ae | 1180 | bgp_delete(bgp); |
718e3744 | 1181 | |
d62a17ae | 1182 | return CMD_SUCCESS; |
718e3744 | 1183 | } |
1184 | ||
6b0655a2 | 1185 | |
718e3744 | 1186 | /* BGP router-id. */ |
1187 | ||
f787d7a0 | 1188 | DEFPY (bgp_router_id, |
718e3744 | 1189 | bgp_router_id_cmd, |
1190 | "bgp router-id A.B.C.D", | |
1191 | BGP_STR | |
1192 | "Override configured router identifier\n" | |
1193 | "Manually configured router identifier\n") | |
1194 | { | |
d62a17ae | 1195 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1196 | bgp_router_id_static_set(bgp, router_id); | |
1197 | return CMD_SUCCESS; | |
718e3744 | 1198 | } |
1199 | ||
f787d7a0 | 1200 | DEFPY (no_bgp_router_id, |
718e3744 | 1201 | no_bgp_router_id_cmd, |
31500417 | 1202 | "no bgp router-id [A.B.C.D]", |
718e3744 | 1203 | NO_STR |
1204 | BGP_STR | |
31500417 DW |
1205 | "Override configured router identifier\n" |
1206 | "Manually configured router identifier\n") | |
718e3744 | 1207 | { |
d62a17ae | 1208 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1209 | |
d62a17ae | 1210 | if (router_id_str) { |
1211 | if (!IPV4_ADDR_SAME(&bgp->router_id_static, &router_id)) { | |
1212 | vty_out(vty, "%% BGP router-id doesn't match\n"); | |
1213 | return CMD_WARNING_CONFIG_FAILED; | |
1214 | } | |
e018c7cc | 1215 | } |
718e3744 | 1216 | |
d62a17ae | 1217 | router_id.s_addr = 0; |
1218 | bgp_router_id_static_set(bgp, router_id); | |
718e3744 | 1219 | |
d62a17ae | 1220 | return CMD_SUCCESS; |
718e3744 | 1221 | } |
1222 | ||
6b0655a2 | 1223 | |
718e3744 | 1224 | /* BGP Cluster ID. */ |
718e3744 | 1225 | DEFUN (bgp_cluster_id, |
1226 | bgp_cluster_id_cmd, | |
838758ac | 1227 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", |
718e3744 | 1228 | BGP_STR |
1229 | "Configure Route-Reflector Cluster-id\n" | |
838758ac DW |
1230 | "Route-Reflector Cluster-id in IP address format\n" |
1231 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1232 | { |
d62a17ae | 1233 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1234 | int idx_ipv4 = 2; | |
1235 | int ret; | |
1236 | struct in_addr cluster; | |
718e3744 | 1237 | |
d62a17ae | 1238 | ret = inet_aton(argv[idx_ipv4]->arg, &cluster); |
1239 | if (!ret) { | |
1240 | vty_out(vty, "%% Malformed bgp cluster identifier\n"); | |
1241 | return CMD_WARNING_CONFIG_FAILED; | |
1242 | } | |
718e3744 | 1243 | |
d62a17ae | 1244 | bgp_cluster_id_set(bgp, &cluster); |
1245 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1246 | |
d62a17ae | 1247 | return CMD_SUCCESS; |
718e3744 | 1248 | } |
1249 | ||
718e3744 | 1250 | DEFUN (no_bgp_cluster_id, |
1251 | no_bgp_cluster_id_cmd, | |
c7178fe7 | 1252 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", |
718e3744 | 1253 | NO_STR |
1254 | BGP_STR | |
838758ac DW |
1255 | "Configure Route-Reflector Cluster-id\n" |
1256 | "Route-Reflector Cluster-id in IP address format\n" | |
1257 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1258 | { |
d62a17ae | 1259 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1260 | bgp_cluster_id_unset(bgp); | |
1261 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1262 | |
d62a17ae | 1263 | return CMD_SUCCESS; |
718e3744 | 1264 | } |
1265 | ||
718e3744 | 1266 | DEFUN (bgp_confederation_identifier, |
1267 | bgp_confederation_identifier_cmd, | |
9ccf14f7 | 1268 | "bgp confederation identifier (1-4294967295)", |
718e3744 | 1269 | "BGP specific commands\n" |
1270 | "AS confederation parameters\n" | |
1271 | "AS number\n" | |
1272 | "Set routing domain confederation AS\n") | |
1273 | { | |
d62a17ae | 1274 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1275 | int idx_number = 3; | |
1276 | as_t as; | |
718e3744 | 1277 | |
d62a17ae | 1278 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 1279 | |
d62a17ae | 1280 | bgp_confederation_id_set(bgp, as); |
718e3744 | 1281 | |
d62a17ae | 1282 | return CMD_SUCCESS; |
718e3744 | 1283 | } |
1284 | ||
1285 | DEFUN (no_bgp_confederation_identifier, | |
1286 | no_bgp_confederation_identifier_cmd, | |
838758ac | 1287 | "no bgp confederation identifier [(1-4294967295)]", |
718e3744 | 1288 | NO_STR |
1289 | "BGP specific commands\n" | |
1290 | "AS confederation parameters\n" | |
3a2d747c QY |
1291 | "AS number\n" |
1292 | "Set routing domain confederation AS\n") | |
718e3744 | 1293 | { |
d62a17ae | 1294 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1295 | bgp_confederation_id_unset(bgp); | |
718e3744 | 1296 | |
d62a17ae | 1297 | return CMD_SUCCESS; |
718e3744 | 1298 | } |
1299 | ||
718e3744 | 1300 | DEFUN (bgp_confederation_peers, |
1301 | bgp_confederation_peers_cmd, | |
12dcf78e | 1302 | "bgp confederation peers (1-4294967295)...", |
718e3744 | 1303 | "BGP specific commands\n" |
1304 | "AS confederation parameters\n" | |
1305 | "Peer ASs in BGP confederation\n" | |
1306 | AS_STR) | |
1307 | { | |
d62a17ae | 1308 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1309 | int idx_asn = 3; | |
1310 | as_t as; | |
1311 | int i; | |
718e3744 | 1312 | |
d62a17ae | 1313 | for (i = idx_asn; i < argc; i++) { |
1314 | as = strtoul(argv[i]->arg, NULL, 10); | |
718e3744 | 1315 | |
d62a17ae | 1316 | if (bgp->as == as) { |
1317 | vty_out(vty, | |
1318 | "%% Local member-AS not allowed in confed peer list\n"); | |
1319 | continue; | |
1320 | } | |
718e3744 | 1321 | |
d62a17ae | 1322 | bgp_confederation_peers_add(bgp, as); |
1323 | } | |
1324 | return CMD_SUCCESS; | |
718e3744 | 1325 | } |
1326 | ||
1327 | DEFUN (no_bgp_confederation_peers, | |
1328 | no_bgp_confederation_peers_cmd, | |
e83a9414 | 1329 | "no bgp confederation peers (1-4294967295)...", |
718e3744 | 1330 | NO_STR |
1331 | "BGP specific commands\n" | |
1332 | "AS confederation parameters\n" | |
1333 | "Peer ASs in BGP confederation\n" | |
1334 | AS_STR) | |
1335 | { | |
d62a17ae | 1336 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1337 | int idx_asn = 4; | |
1338 | as_t as; | |
1339 | int i; | |
718e3744 | 1340 | |
d62a17ae | 1341 | for (i = idx_asn; i < argc; i++) { |
1342 | as = strtoul(argv[i]->arg, NULL, 10); | |
0b2aa3a0 | 1343 | |
d62a17ae | 1344 | bgp_confederation_peers_remove(bgp, as); |
1345 | } | |
1346 | return CMD_SUCCESS; | |
718e3744 | 1347 | } |
6b0655a2 | 1348 | |
5e242b0d DS |
1349 | /** |
1350 | * Central routine for maximum-paths configuration. | |
1351 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1352 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1353 | */ | |
d62a17ae | 1354 | static int bgp_maxpaths_config_vty(struct vty *vty, int peer_type, |
d7c0a89a | 1355 | const char *mpaths, uint16_t options, |
d62a17ae | 1356 | int set) |
1357 | { | |
1358 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
d7c0a89a | 1359 | uint16_t maxpaths = 0; |
d62a17ae | 1360 | int ret; |
1361 | afi_t afi; | |
1362 | safi_t safi; | |
1363 | ||
1364 | afi = bgp_node_afi(vty); | |
1365 | safi = bgp_node_safi(vty); | |
1366 | ||
1367 | if (set) { | |
1368 | maxpaths = strtol(mpaths, NULL, 10); | |
1369 | if (maxpaths > multipath_num) { | |
1370 | vty_out(vty, | |
1371 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", | |
1372 | maxpaths, multipath_num); | |
1373 | return CMD_WARNING_CONFIG_FAILED; | |
1374 | } | |
1375 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1376 | options); | |
1377 | } else | |
1378 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1379 | ||
1380 | if (ret < 0) { | |
1381 | vty_out(vty, | |
1382 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", | |
1383 | (set == 1) ? "" : "un", | |
1384 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1385 | maxpaths, afi, safi); | |
1386 | return CMD_WARNING_CONFIG_FAILED; | |
1387 | } | |
1388 | ||
1389 | bgp_recalculate_all_bestpaths(bgp); | |
1390 | ||
1391 | return CMD_SUCCESS; | |
165b5fff JB |
1392 | } |
1393 | ||
abc920f8 DS |
1394 | DEFUN (bgp_maxmed_admin, |
1395 | bgp_maxmed_admin_cmd, | |
1396 | "bgp max-med administrative ", | |
1397 | BGP_STR | |
1398 | "Advertise routes with max-med\n" | |
1399 | "Administratively applied, for an indefinite period\n") | |
1400 | { | |
d62a17ae | 1401 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1402 | |
d62a17ae | 1403 | bgp->v_maxmed_admin = 1; |
1404 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1405 | |
d62a17ae | 1406 | bgp_maxmed_update(bgp); |
abc920f8 | 1407 | |
d62a17ae | 1408 | return CMD_SUCCESS; |
abc920f8 DS |
1409 | } |
1410 | ||
1411 | DEFUN (bgp_maxmed_admin_medv, | |
1412 | bgp_maxmed_admin_medv_cmd, | |
4668a151 | 1413 | "bgp max-med administrative (0-4294967295)", |
abc920f8 DS |
1414 | BGP_STR |
1415 | "Advertise routes with max-med\n" | |
1416 | "Administratively applied, for an indefinite period\n" | |
1417 | "Max MED value to be used\n") | |
1418 | { | |
d62a17ae | 1419 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1420 | int idx_number = 3; | |
abc920f8 | 1421 | |
d62a17ae | 1422 | bgp->v_maxmed_admin = 1; |
1423 | bgp->maxmed_admin_value = strtoul(argv[idx_number]->arg, NULL, 10); | |
abc920f8 | 1424 | |
d62a17ae | 1425 | bgp_maxmed_update(bgp); |
abc920f8 | 1426 | |
d62a17ae | 1427 | return CMD_SUCCESS; |
abc920f8 DS |
1428 | } |
1429 | ||
1430 | DEFUN (no_bgp_maxmed_admin, | |
1431 | no_bgp_maxmed_admin_cmd, | |
4668a151 | 1432 | "no bgp max-med administrative [(0-4294967295)]", |
abc920f8 DS |
1433 | NO_STR |
1434 | BGP_STR | |
1435 | "Advertise routes with max-med\n" | |
838758ac DW |
1436 | "Administratively applied, for an indefinite period\n" |
1437 | "Max MED value to be used\n") | |
abc920f8 | 1438 | { |
d62a17ae | 1439 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1440 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; | |
1441 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1442 | bgp_maxmed_update(bgp); | |
abc920f8 | 1443 | |
d62a17ae | 1444 | return CMD_SUCCESS; |
abc920f8 DS |
1445 | } |
1446 | ||
abc920f8 DS |
1447 | DEFUN (bgp_maxmed_onstartup, |
1448 | bgp_maxmed_onstartup_cmd, | |
4668a151 | 1449 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", |
abc920f8 DS |
1450 | BGP_STR |
1451 | "Advertise routes with max-med\n" | |
1452 | "Effective on a startup\n" | |
1453 | "Time (seconds) period for max-med\n" | |
1454 | "Max MED value to be used\n") | |
1455 | { | |
d62a17ae | 1456 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1457 | int idx = 0; | |
4668a151 | 1458 | |
d62a17ae | 1459 | argv_find(argv, argc, "(5-86400)", &idx); |
1460 | bgp->v_maxmed_onstartup = strtoul(argv[idx]->arg, NULL, 10); | |
1461 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
1462 | bgp->maxmed_onstartup_value = strtoul(argv[idx]->arg, NULL, 10); | |
1463 | else | |
1464 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
4668a151 | 1465 | |
d62a17ae | 1466 | bgp_maxmed_update(bgp); |
abc920f8 | 1467 | |
d62a17ae | 1468 | return CMD_SUCCESS; |
abc920f8 DS |
1469 | } |
1470 | ||
1471 | DEFUN (no_bgp_maxmed_onstartup, | |
1472 | no_bgp_maxmed_onstartup_cmd, | |
4668a151 | 1473 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", |
abc920f8 DS |
1474 | NO_STR |
1475 | BGP_STR | |
1476 | "Advertise routes with max-med\n" | |
838758ac DW |
1477 | "Effective on a startup\n" |
1478 | "Time (seconds) period for max-med\n" | |
1479 | "Max MED value to be used\n") | |
abc920f8 | 1480 | { |
d62a17ae | 1481 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1482 | |
d62a17ae | 1483 | /* Cancel max-med onstartup if its on */ |
1484 | if (bgp->t_maxmed_onstartup) { | |
1485 | THREAD_TIMER_OFF(bgp->t_maxmed_onstartup); | |
1486 | bgp->maxmed_onstartup_over = 1; | |
1487 | } | |
abc920f8 | 1488 | |
d62a17ae | 1489 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; |
1490 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1491 | |
d62a17ae | 1492 | bgp_maxmed_update(bgp); |
abc920f8 | 1493 | |
d62a17ae | 1494 | return CMD_SUCCESS; |
abc920f8 DS |
1495 | } |
1496 | ||
d62a17ae | 1497 | static int bgp_update_delay_config_vty(struct vty *vty, const char *delay, |
1498 | const char *wait) | |
f188f2c4 | 1499 | { |
d62a17ae | 1500 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d7c0a89a QY |
1501 | uint16_t update_delay; |
1502 | uint16_t establish_wait; | |
f188f2c4 | 1503 | |
d62a17ae | 1504 | update_delay = strtoul(delay, NULL, 10); |
f188f2c4 | 1505 | |
d62a17ae | 1506 | if (!wait) /* update-delay <delay> */ |
1507 | { | |
1508 | bgp->v_update_delay = update_delay; | |
1509 | bgp->v_establish_wait = bgp->v_update_delay; | |
1510 | return CMD_SUCCESS; | |
1511 | } | |
f188f2c4 | 1512 | |
d62a17ae | 1513 | /* update-delay <delay> <establish-wait> */ |
1514 | establish_wait = atoi(wait); | |
1515 | if (update_delay < establish_wait) { | |
1516 | vty_out(vty, | |
1517 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1518 | return CMD_WARNING_CONFIG_FAILED; | |
1519 | } | |
f188f2c4 | 1520 | |
d62a17ae | 1521 | bgp->v_update_delay = update_delay; |
1522 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 1523 | |
d62a17ae | 1524 | return CMD_SUCCESS; |
f188f2c4 DS |
1525 | } |
1526 | ||
d62a17ae | 1527 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 1528 | { |
d62a17ae | 1529 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 1530 | |
d62a17ae | 1531 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
1532 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 1533 | |
d62a17ae | 1534 | return CMD_SUCCESS; |
f188f2c4 DS |
1535 | } |
1536 | ||
2b791107 | 1537 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 1538 | { |
d62a17ae | 1539 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
1540 | vty_out(vty, " update-delay %d", bgp->v_update_delay); | |
1541 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1542 | vty_out(vty, " %d", bgp->v_establish_wait); | |
1543 | vty_out(vty, "\n"); | |
1544 | } | |
f188f2c4 DS |
1545 | } |
1546 | ||
1547 | ||
1548 | /* Update-delay configuration */ | |
1549 | DEFUN (bgp_update_delay, | |
1550 | bgp_update_delay_cmd, | |
6147e2c6 | 1551 | "update-delay (0-3600)", |
f188f2c4 DS |
1552 | "Force initial delay for best-path and updates\n" |
1553 | "Seconds\n") | |
1554 | { | |
d62a17ae | 1555 | int idx_number = 1; |
1556 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); | |
f188f2c4 DS |
1557 | } |
1558 | ||
1559 | DEFUN (bgp_update_delay_establish_wait, | |
1560 | bgp_update_delay_establish_wait_cmd, | |
6147e2c6 | 1561 | "update-delay (0-3600) (1-3600)", |
f188f2c4 DS |
1562 | "Force initial delay for best-path and updates\n" |
1563 | "Seconds\n" | |
f188f2c4 DS |
1564 | "Seconds\n") |
1565 | { | |
d62a17ae | 1566 | int idx_number = 1; |
1567 | int idx_number_2 = 2; | |
1568 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, | |
1569 | argv[idx_number_2]->arg); | |
f188f2c4 DS |
1570 | } |
1571 | ||
1572 | /* Update-delay deconfiguration */ | |
1573 | DEFUN (no_bgp_update_delay, | |
1574 | no_bgp_update_delay_cmd, | |
838758ac DW |
1575 | "no update-delay [(0-3600) [(1-3600)]]", |
1576 | NO_STR | |
f188f2c4 | 1577 | "Force initial delay for best-path and updates\n" |
838758ac | 1578 | "Seconds\n" |
7111c1a0 | 1579 | "Seconds\n") |
f188f2c4 | 1580 | { |
d62a17ae | 1581 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
1582 | } |
1583 | ||
5e242b0d | 1584 | |
8fa7732f QY |
1585 | static int bgp_wpkt_quanta_config_vty(struct vty *vty, uint32_t quanta, |
1586 | bool set) | |
cb1faec9 | 1587 | { |
d62a17ae | 1588 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
cb1faec9 | 1589 | |
8fa7732f QY |
1590 | quanta = set ? quanta : BGP_WRITE_PACKET_MAX; |
1591 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, memory_order_relaxed); | |
555e09d4 QY |
1592 | |
1593 | return CMD_SUCCESS; | |
1594 | } | |
1595 | ||
8fa7732f QY |
1596 | static int bgp_rpkt_quanta_config_vty(struct vty *vty, uint32_t quanta, |
1597 | bool set) | |
555e09d4 QY |
1598 | { |
1599 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1600 | ||
8fa7732f QY |
1601 | quanta = set ? quanta : BGP_READ_PACKET_MAX; |
1602 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, memory_order_relaxed); | |
cb1faec9 | 1603 | |
d62a17ae | 1604 | return CMD_SUCCESS; |
cb1faec9 DS |
1605 | } |
1606 | ||
2b791107 | 1607 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 1608 | { |
555e09d4 QY |
1609 | uint32_t quanta = |
1610 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
1611 | if (quanta != BGP_WRITE_PACKET_MAX) | |
152456fe | 1612 | vty_out(vty, " write-quanta %d\n", quanta); |
cb1faec9 DS |
1613 | } |
1614 | ||
555e09d4 QY |
1615 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) |
1616 | { | |
1617 | uint32_t quanta = | |
1618 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
1619 | if (quanta != BGP_READ_PACKET_MAX) | |
152456fe | 1620 | vty_out(vty, " read-quanta %d\n", quanta); |
555e09d4 | 1621 | } |
cb1faec9 | 1622 | |
8fa7732f QY |
1623 | /* Packet quanta configuration |
1624 | * | |
1625 | * XXX: The value set here controls the size of a stack buffer in the IO | |
1626 | * thread. When changing these limits be careful to prevent stack overflow. | |
1627 | * | |
1628 | * Furthermore, the maximums used here should correspond to | |
1629 | * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX. | |
1630 | */ | |
1631 | DEFPY (bgp_wpkt_quanta, | |
cb1faec9 | 1632 | bgp_wpkt_quanta_cmd, |
8fa7732f | 1633 | "[no] write-quanta (1-64)$quanta", |
d7fa34c1 | 1634 | NO_STR |
8fa7732f | 1635 | "How many packets to write to peer socket per run\n" |
cb1faec9 DS |
1636 | "Number of packets\n") |
1637 | { | |
8fa7732f | 1638 | return bgp_wpkt_quanta_config_vty(vty, quanta, !no); |
cb1faec9 DS |
1639 | } |
1640 | ||
8fa7732f | 1641 | DEFPY (bgp_rpkt_quanta, |
555e09d4 | 1642 | bgp_rpkt_quanta_cmd, |
8fa7732f | 1643 | "[no] read-quanta (1-10)$quanta", |
555e09d4 QY |
1644 | NO_STR |
1645 | "How many packets to read from peer socket per I/O cycle\n" | |
1646 | "Number of packets\n") | |
1647 | { | |
8fa7732f | 1648 | return bgp_rpkt_quanta_config_vty(vty, quanta, !no); |
555e09d4 QY |
1649 | } |
1650 | ||
2b791107 | 1651 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 1652 | { |
37a333fe | 1653 | if (!bgp->heuristic_coalesce) |
d62a17ae | 1654 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); |
3f9c7369 DS |
1655 | } |
1656 | ||
1657 | ||
1658 | DEFUN (bgp_coalesce_time, | |
1659 | bgp_coalesce_time_cmd, | |
6147e2c6 | 1660 | "coalesce-time (0-4294967295)", |
3f9c7369 DS |
1661 | "Subgroup coalesce timer\n" |
1662 | "Subgroup coalesce timer value (in ms)\n") | |
1663 | { | |
d62a17ae | 1664 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1665 | |
d62a17ae | 1666 | int idx = 0; |
1667 | argv_find(argv, argc, "(0-4294967295)", &idx); | |
37a333fe | 1668 | bgp->heuristic_coalesce = false; |
d62a17ae | 1669 | bgp->coalesce_time = strtoul(argv[idx]->arg, NULL, 10); |
1670 | return CMD_SUCCESS; | |
3f9c7369 DS |
1671 | } |
1672 | ||
1673 | DEFUN (no_bgp_coalesce_time, | |
1674 | no_bgp_coalesce_time_cmd, | |
6147e2c6 | 1675 | "no coalesce-time (0-4294967295)", |
3a2d747c | 1676 | NO_STR |
3f9c7369 DS |
1677 | "Subgroup coalesce timer\n" |
1678 | "Subgroup coalesce timer value (in ms)\n") | |
1679 | { | |
d62a17ae | 1680 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1681 | |
37a333fe | 1682 | bgp->heuristic_coalesce = true; |
d62a17ae | 1683 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; |
1684 | return CMD_SUCCESS; | |
3f9c7369 DS |
1685 | } |
1686 | ||
5e242b0d DS |
1687 | /* Maximum-paths configuration */ |
1688 | DEFUN (bgp_maxpaths, | |
1689 | bgp_maxpaths_cmd, | |
6319fd63 | 1690 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), |
5e242b0d DS |
1691 | "Forward packets over multiple paths\n" |
1692 | "Number of paths\n") | |
1693 | { | |
d62a17ae | 1694 | int idx_number = 1; |
1695 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, | |
1696 | argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
1697 | } |
1698 | ||
d62a17ae | 1699 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
1700 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1701 | "Forward packets over multiple paths\n" | |
1702 | "Number of paths\n") | |
596c17ba | 1703 | |
165b5fff JB |
1704 | DEFUN (bgp_maxpaths_ibgp, |
1705 | bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1706 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), |
165b5fff JB |
1707 | "Forward packets over multiple paths\n" |
1708 | "iBGP-multipath\n" | |
1709 | "Number of paths\n") | |
1710 | { | |
d62a17ae | 1711 | int idx_number = 2; |
1712 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, | |
1713 | argv[idx_number]->arg, 0, 1); | |
5e242b0d | 1714 | } |
165b5fff | 1715 | |
d62a17ae | 1716 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
1717 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1718 | "Forward packets over multiple paths\n" | |
1719 | "iBGP-multipath\n" | |
1720 | "Number of paths\n") | |
596c17ba | 1721 | |
5e242b0d DS |
1722 | DEFUN (bgp_maxpaths_ibgp_cluster, |
1723 | bgp_maxpaths_ibgp_cluster_cmd, | |
6319fd63 | 1724 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", |
5e242b0d DS |
1725 | "Forward packets over multiple paths\n" |
1726 | "iBGP-multipath\n" | |
1727 | "Number of paths\n" | |
1728 | "Match the cluster length\n") | |
1729 | { | |
d62a17ae | 1730 | int idx_number = 2; |
1731 | return bgp_maxpaths_config_vty( | |
1732 | vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
1733 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); | |
165b5fff JB |
1734 | } |
1735 | ||
d62a17ae | 1736 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
1737 | "maximum-paths ibgp " CMD_RANGE_STR( | |
1738 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
1739 | "Forward packets over multiple paths\n" | |
1740 | "iBGP-multipath\n" | |
1741 | "Number of paths\n" | |
1742 | "Match the cluster length\n") | |
596c17ba | 1743 | |
165b5fff JB |
1744 | DEFUN (no_bgp_maxpaths, |
1745 | no_bgp_maxpaths_cmd, | |
6319fd63 | 1746 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", |
165b5fff JB |
1747 | NO_STR |
1748 | "Forward packets over multiple paths\n" | |
1749 | "Number of paths\n") | |
1750 | { | |
d62a17ae | 1751 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
1752 | } |
1753 | ||
d62a17ae | 1754 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
996c9314 | 1755 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 1756 | "Forward packets over multiple paths\n" |
1757 | "Number of paths\n") | |
596c17ba | 1758 | |
165b5fff JB |
1759 | DEFUN (no_bgp_maxpaths_ibgp, |
1760 | no_bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1761 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", |
165b5fff JB |
1762 | NO_STR |
1763 | "Forward packets over multiple paths\n" | |
1764 | "iBGP-multipath\n" | |
838758ac DW |
1765 | "Number of paths\n" |
1766 | "Match the cluster length\n") | |
165b5fff | 1767 | { |
d62a17ae | 1768 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1769 | } |
1770 | ||
d62a17ae | 1771 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
1772 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
1773 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
1774 | NO_STR | |
1775 | "Forward packets over multiple paths\n" | |
1776 | "iBGP-multipath\n" | |
1777 | "Number of paths\n" | |
1778 | "Match the cluster length\n") | |
596c17ba | 1779 | |
2b791107 | 1780 | void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, afi_t afi, |
60466a63 | 1781 | safi_t safi) |
165b5fff | 1782 | { |
d62a17ae | 1783 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) { |
d62a17ae | 1784 | vty_out(vty, " maximum-paths %d\n", |
1785 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
1786 | } | |
165b5fff | 1787 | |
d62a17ae | 1788 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) { |
d62a17ae | 1789 | vty_out(vty, " maximum-paths ibgp %d", |
1790 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
1791 | if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, | |
1792 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1793 | vty_out(vty, " equal-cluster-length"); | |
1794 | vty_out(vty, "\n"); | |
1795 | } | |
165b5fff | 1796 | } |
6b0655a2 | 1797 | |
718e3744 | 1798 | /* BGP timers. */ |
1799 | ||
1800 | DEFUN (bgp_timers, | |
1801 | bgp_timers_cmd, | |
6147e2c6 | 1802 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1803 | "Adjust routing timers\n" |
1804 | "BGP timers\n" | |
1805 | "Keepalive interval\n" | |
1806 | "Holdtime\n") | |
1807 | { | |
d62a17ae | 1808 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1809 | int idx_number = 2; | |
1810 | int idx_number_2 = 3; | |
1811 | unsigned long keepalive = 0; | |
1812 | unsigned long holdtime = 0; | |
718e3744 | 1813 | |
d62a17ae | 1814 | keepalive = strtoul(argv[idx_number]->arg, NULL, 10); |
1815 | holdtime = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
718e3744 | 1816 | |
d62a17ae | 1817 | /* Holdtime value check. */ |
1818 | if (holdtime < 3 && holdtime != 0) { | |
1819 | vty_out(vty, | |
1820 | "%% hold time value must be either 0 or greater than 3\n"); | |
1821 | return CMD_WARNING_CONFIG_FAILED; | |
1822 | } | |
718e3744 | 1823 | |
d62a17ae | 1824 | bgp_timers_set(bgp, keepalive, holdtime); |
718e3744 | 1825 | |
d62a17ae | 1826 | return CMD_SUCCESS; |
718e3744 | 1827 | } |
1828 | ||
1829 | DEFUN (no_bgp_timers, | |
1830 | no_bgp_timers_cmd, | |
838758ac | 1831 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1832 | NO_STR |
1833 | "Adjust routing timers\n" | |
838758ac DW |
1834 | "BGP timers\n" |
1835 | "Keepalive interval\n" | |
1836 | "Holdtime\n") | |
718e3744 | 1837 | { |
d62a17ae | 1838 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1839 | bgp_timers_unset(bgp); | |
718e3744 | 1840 | |
d62a17ae | 1841 | return CMD_SUCCESS; |
718e3744 | 1842 | } |
1843 | ||
6b0655a2 | 1844 | |
718e3744 | 1845 | DEFUN (bgp_client_to_client_reflection, |
1846 | bgp_client_to_client_reflection_cmd, | |
1847 | "bgp client-to-client reflection", | |
1848 | "BGP specific commands\n" | |
1849 | "Configure client to client route reflection\n" | |
1850 | "reflection of routes allowed\n") | |
1851 | { | |
d62a17ae | 1852 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1853 | bgp_flag_unset(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1854 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1855 | |
d62a17ae | 1856 | return CMD_SUCCESS; |
718e3744 | 1857 | } |
1858 | ||
1859 | DEFUN (no_bgp_client_to_client_reflection, | |
1860 | no_bgp_client_to_client_reflection_cmd, | |
1861 | "no bgp client-to-client reflection", | |
1862 | NO_STR | |
1863 | "BGP specific commands\n" | |
1864 | "Configure client to client route reflection\n" | |
1865 | "reflection of routes allowed\n") | |
1866 | { | |
d62a17ae | 1867 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1868 | bgp_flag_set(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1869 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1870 | |
d62a17ae | 1871 | return CMD_SUCCESS; |
718e3744 | 1872 | } |
1873 | ||
1874 | /* "bgp always-compare-med" configuration. */ | |
1875 | DEFUN (bgp_always_compare_med, | |
1876 | bgp_always_compare_med_cmd, | |
1877 | "bgp always-compare-med", | |
1878 | "BGP specific commands\n" | |
1879 | "Allow comparing MED from different neighbors\n") | |
1880 | { | |
d62a17ae | 1881 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1882 | bgp_flag_set(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1883 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1884 | |
d62a17ae | 1885 | return CMD_SUCCESS; |
718e3744 | 1886 | } |
1887 | ||
1888 | DEFUN (no_bgp_always_compare_med, | |
1889 | no_bgp_always_compare_med_cmd, | |
1890 | "no bgp always-compare-med", | |
1891 | NO_STR | |
1892 | "BGP specific commands\n" | |
1893 | "Allow comparing MED from different neighbors\n") | |
1894 | { | |
d62a17ae | 1895 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1896 | bgp_flag_unset(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1897 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1898 | |
d62a17ae | 1899 | return CMD_SUCCESS; |
718e3744 | 1900 | } |
6b0655a2 | 1901 | |
9dac9fc8 DA |
1902 | |
1903 | DEFUN(bgp_ebgp_requires_policy, bgp_ebgp_requires_policy_cmd, | |
1904 | "bgp ebgp-requires-policy", | |
1905 | "BGP specific commands\n" | |
1906 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
1907 | { | |
1908 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1909 | bgp->ebgp_requires_policy = DEFAULT_EBGP_POLICY_ENABLED; | |
1910 | return CMD_SUCCESS; | |
1911 | } | |
1912 | ||
1913 | DEFUN(no_bgp_ebgp_requires_policy, no_bgp_ebgp_requires_policy_cmd, | |
1914 | "no bgp ebgp-requires-policy", | |
1915 | NO_STR | |
1916 | "BGP specific commands\n" | |
1917 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
1918 | { | |
1919 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1920 | bgp->ebgp_requires_policy = DEFAULT_EBGP_POLICY_DISABLED; | |
1921 | return CMD_SUCCESS; | |
1922 | } | |
1923 | ||
1924 | ||
718e3744 | 1925 | /* "bgp deterministic-med" configuration. */ |
1926 | DEFUN (bgp_deterministic_med, | |
1927 | bgp_deterministic_med_cmd, | |
1928 | "bgp deterministic-med", | |
1929 | "BGP specific commands\n" | |
1930 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1931 | { | |
d62a17ae | 1932 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1475ac87 | 1933 | |
d62a17ae | 1934 | if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { |
1935 | bgp_flag_set(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1936 | bgp_recalculate_all_bestpaths(bgp); | |
1937 | } | |
7aafcaca | 1938 | |
d62a17ae | 1939 | return CMD_SUCCESS; |
718e3744 | 1940 | } |
1941 | ||
1942 | DEFUN (no_bgp_deterministic_med, | |
1943 | no_bgp_deterministic_med_cmd, | |
1944 | "no bgp deterministic-med", | |
1945 | NO_STR | |
1946 | "BGP specific commands\n" | |
1947 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1948 | { | |
d62a17ae | 1949 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1950 | int bestpath_per_as_used; | |
1951 | afi_t afi; | |
1952 | safi_t safi; | |
1953 | struct peer *peer; | |
1954 | struct listnode *node, *nnode; | |
1955 | ||
1956 | if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { | |
1957 | bestpath_per_as_used = 0; | |
1958 | ||
1959 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
05c7a1cc | 1960 | FOREACH_AFI_SAFI (afi, safi) |
dcc68b5e MS |
1961 | if (bgp_addpath_dmed_required( |
1962 | peer->addpath_type[afi][safi])) { | |
05c7a1cc QY |
1963 | bestpath_per_as_used = 1; |
1964 | break; | |
1965 | } | |
d62a17ae | 1966 | |
1967 | if (bestpath_per_as_used) | |
1968 | break; | |
1969 | } | |
1970 | ||
1971 | if (bestpath_per_as_used) { | |
1972 | vty_out(vty, | |
1973 | "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n"); | |
1974 | return CMD_WARNING_CONFIG_FAILED; | |
1975 | } else { | |
1976 | bgp_flag_unset(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1977 | bgp_recalculate_all_bestpaths(bgp); | |
1978 | } | |
1979 | } | |
1980 | ||
1981 | return CMD_SUCCESS; | |
718e3744 | 1982 | } |
538621f2 | 1983 | |
1984 | /* "bgp graceful-restart" configuration. */ | |
1985 | DEFUN (bgp_graceful_restart, | |
1986 | bgp_graceful_restart_cmd, | |
1987 | "bgp graceful-restart", | |
1988 | "BGP specific commands\n" | |
1989 | "Graceful restart capability parameters\n") | |
1990 | { | |
d62a17ae | 1991 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1992 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
1993 | return CMD_SUCCESS; | |
538621f2 | 1994 | } |
1995 | ||
1996 | DEFUN (no_bgp_graceful_restart, | |
1997 | no_bgp_graceful_restart_cmd, | |
1998 | "no bgp graceful-restart", | |
1999 | NO_STR | |
2000 | "BGP specific commands\n" | |
2001 | "Graceful restart capability parameters\n") | |
2002 | { | |
d62a17ae | 2003 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2004 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
2005 | return CMD_SUCCESS; | |
538621f2 | 2006 | } |
2007 | ||
93406d87 | 2008 | DEFUN (bgp_graceful_restart_stalepath_time, |
2009 | bgp_graceful_restart_stalepath_time_cmd, | |
c1779b7d | 2010 | "bgp graceful-restart stalepath-time (1-4095)", |
93406d87 | 2011 | "BGP specific commands\n" |
2012 | "Graceful restart capability parameters\n" | |
2013 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2014 | "Delay value (seconds)\n") | |
2015 | { | |
d62a17ae | 2016 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2017 | int idx_number = 3; | |
d7c0a89a | 2018 | uint32_t stalepath; |
93406d87 | 2019 | |
d62a17ae | 2020 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
2021 | bgp->stalepath_time = stalepath; | |
2022 | return CMD_SUCCESS; | |
93406d87 | 2023 | } |
2024 | ||
eb6f1b41 PG |
2025 | DEFUN (bgp_graceful_restart_restart_time, |
2026 | bgp_graceful_restart_restart_time_cmd, | |
c72d0314 | 2027 | "bgp graceful-restart restart-time (1-4095)", |
eb6f1b41 PG |
2028 | "BGP specific commands\n" |
2029 | "Graceful restart capability parameters\n" | |
2030 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2031 | "Delay value (seconds)\n") | |
2032 | { | |
d62a17ae | 2033 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2034 | int idx_number = 3; | |
d7c0a89a | 2035 | uint32_t restart; |
eb6f1b41 | 2036 | |
d62a17ae | 2037 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
2038 | bgp->restart_time = restart; | |
2039 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2040 | } |
2041 | ||
93406d87 | 2042 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
2043 | no_bgp_graceful_restart_stalepath_time_cmd, | |
c1779b7d | 2044 | "no bgp graceful-restart stalepath-time [(1-4095)]", |
93406d87 | 2045 | NO_STR |
2046 | "BGP specific commands\n" | |
2047 | "Graceful restart capability parameters\n" | |
838758ac DW |
2048 | "Set the max time to hold onto restarting peer's stale paths\n" |
2049 | "Delay value (seconds)\n") | |
93406d87 | 2050 | { |
d62a17ae | 2051 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 2052 | |
d62a17ae | 2053 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
2054 | return CMD_SUCCESS; | |
93406d87 | 2055 | } |
2056 | ||
eb6f1b41 PG |
2057 | DEFUN (no_bgp_graceful_restart_restart_time, |
2058 | no_bgp_graceful_restart_restart_time_cmd, | |
c72d0314 | 2059 | "no bgp graceful-restart restart-time [(1-4095)]", |
eb6f1b41 PG |
2060 | NO_STR |
2061 | "BGP specific commands\n" | |
2062 | "Graceful restart capability parameters\n" | |
838758ac DW |
2063 | "Set the time to wait to delete stale routes before a BGP open message is received\n" |
2064 | "Delay value (seconds)\n") | |
eb6f1b41 | 2065 | { |
d62a17ae | 2066 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 2067 | |
d62a17ae | 2068 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
2069 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2070 | } |
2071 | ||
43fc21b3 JC |
2072 | DEFUN (bgp_graceful_restart_preserve_fw, |
2073 | bgp_graceful_restart_preserve_fw_cmd, | |
2074 | "bgp graceful-restart preserve-fw-state", | |
2075 | "BGP specific commands\n" | |
2076 | "Graceful restart capability parameters\n" | |
2077 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
2078 | { | |
d62a17ae | 2079 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2080 | bgp_flag_set(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
2081 | return CMD_SUCCESS; | |
43fc21b3 JC |
2082 | } |
2083 | ||
2084 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
2085 | no_bgp_graceful_restart_preserve_fw_cmd, | |
2086 | "no bgp graceful-restart preserve-fw-state", | |
2087 | NO_STR | |
2088 | "BGP specific commands\n" | |
2089 | "Graceful restart capability parameters\n" | |
2090 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
2091 | { | |
d62a17ae | 2092 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2093 | bgp_flag_unset(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
2094 | return CMD_SUCCESS; | |
43fc21b3 JC |
2095 | } |
2096 | ||
7f323236 DW |
2097 | /* "bgp graceful-shutdown" configuration */ |
2098 | DEFUN (bgp_graceful_shutdown, | |
2099 | bgp_graceful_shutdown_cmd, | |
2100 | "bgp graceful-shutdown", | |
2101 | BGP_STR | |
2102 | "Graceful shutdown parameters\n") | |
2103 | { | |
2104 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2105 | ||
2106 | if (!bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
2107 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
2108 | bgp_static_redo_import_check(bgp); | |
2109 | bgp_redistribute_redo(bgp); | |
2110 | bgp_clear_star_soft_out(vty, bgp->name); | |
2111 | bgp_clear_star_soft_in(vty, bgp->name); | |
2112 | } | |
2113 | ||
2114 | return CMD_SUCCESS; | |
2115 | } | |
2116 | ||
2117 | DEFUN (no_bgp_graceful_shutdown, | |
2118 | no_bgp_graceful_shutdown_cmd, | |
2119 | "no bgp graceful-shutdown", | |
2120 | NO_STR | |
2121 | BGP_STR | |
2122 | "Graceful shutdown parameters\n") | |
2123 | { | |
2124 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2125 | ||
2126 | if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
2127 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
2128 | bgp_static_redo_import_check(bgp); | |
2129 | bgp_redistribute_redo(bgp); | |
2130 | bgp_clear_star_soft_out(vty, bgp->name); | |
2131 | bgp_clear_star_soft_in(vty, bgp->name); | |
2132 | } | |
2133 | ||
2134 | return CMD_SUCCESS; | |
2135 | } | |
2136 | ||
718e3744 | 2137 | /* "bgp fast-external-failover" configuration. */ |
2138 | DEFUN (bgp_fast_external_failover, | |
2139 | bgp_fast_external_failover_cmd, | |
2140 | "bgp fast-external-failover", | |
2141 | BGP_STR | |
2142 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2143 | { | |
d62a17ae | 2144 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2145 | bgp_flag_unset(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
2146 | return CMD_SUCCESS; | |
718e3744 | 2147 | } |
2148 | ||
2149 | DEFUN (no_bgp_fast_external_failover, | |
2150 | no_bgp_fast_external_failover_cmd, | |
2151 | "no bgp fast-external-failover", | |
2152 | NO_STR | |
2153 | BGP_STR | |
2154 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2155 | { | |
d62a17ae | 2156 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2157 | bgp_flag_set(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
2158 | return CMD_SUCCESS; | |
718e3744 | 2159 | } |
6b0655a2 | 2160 | |
718e3744 | 2161 | /* "bgp bestpath compare-routerid" configuration. */ |
2162 | DEFUN (bgp_bestpath_compare_router_id, | |
2163 | bgp_bestpath_compare_router_id_cmd, | |
2164 | "bgp bestpath compare-routerid", | |
2165 | "BGP specific commands\n" | |
2166 | "Change the default bestpath selection\n" | |
2167 | "Compare router-id for identical EBGP paths\n") | |
2168 | { | |
d62a17ae | 2169 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2170 | bgp_flag_set(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
2171 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2172 | |
d62a17ae | 2173 | return CMD_SUCCESS; |
718e3744 | 2174 | } |
2175 | ||
2176 | DEFUN (no_bgp_bestpath_compare_router_id, | |
2177 | no_bgp_bestpath_compare_router_id_cmd, | |
2178 | "no bgp bestpath compare-routerid", | |
2179 | NO_STR | |
2180 | "BGP specific commands\n" | |
2181 | "Change the default bestpath selection\n" | |
2182 | "Compare router-id for identical EBGP paths\n") | |
2183 | { | |
d62a17ae | 2184 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2185 | bgp_flag_unset(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
2186 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2187 | |
d62a17ae | 2188 | return CMD_SUCCESS; |
718e3744 | 2189 | } |
6b0655a2 | 2190 | |
718e3744 | 2191 | /* "bgp bestpath as-path ignore" configuration. */ |
2192 | DEFUN (bgp_bestpath_aspath_ignore, | |
2193 | bgp_bestpath_aspath_ignore_cmd, | |
2194 | "bgp bestpath as-path ignore", | |
2195 | "BGP specific commands\n" | |
2196 | "Change the default bestpath selection\n" | |
2197 | "AS-path attribute\n" | |
2198 | "Ignore as-path length in selecting a route\n") | |
2199 | { | |
d62a17ae | 2200 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2201 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2202 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2203 | |
d62a17ae | 2204 | return CMD_SUCCESS; |
718e3744 | 2205 | } |
2206 | ||
2207 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
2208 | no_bgp_bestpath_aspath_ignore_cmd, | |
2209 | "no bgp bestpath as-path ignore", | |
2210 | NO_STR | |
2211 | "BGP specific commands\n" | |
2212 | "Change the default bestpath selection\n" | |
2213 | "AS-path attribute\n" | |
2214 | "Ignore as-path length in selecting a route\n") | |
2215 | { | |
d62a17ae | 2216 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2217 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2218 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2219 | |
d62a17ae | 2220 | return CMD_SUCCESS; |
718e3744 | 2221 | } |
6b0655a2 | 2222 | |
6811845b | 2223 | /* "bgp bestpath as-path confed" configuration. */ |
2224 | DEFUN (bgp_bestpath_aspath_confed, | |
2225 | bgp_bestpath_aspath_confed_cmd, | |
2226 | "bgp bestpath as-path confed", | |
2227 | "BGP specific commands\n" | |
2228 | "Change the default bestpath selection\n" | |
2229 | "AS-path attribute\n" | |
2230 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2231 | { | |
d62a17ae | 2232 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2233 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_CONFED); | |
2234 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2235 | |
d62a17ae | 2236 | return CMD_SUCCESS; |
6811845b | 2237 | } |
2238 | ||
2239 | DEFUN (no_bgp_bestpath_aspath_confed, | |
2240 | no_bgp_bestpath_aspath_confed_cmd, | |
2241 | "no bgp bestpath as-path confed", | |
2242 | NO_STR | |
2243 | "BGP specific commands\n" | |
2244 | "Change the default bestpath selection\n" | |
2245 | "AS-path attribute\n" | |
2246 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2247 | { | |
d62a17ae | 2248 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2249 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_CONFED); | |
2250 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2251 | |
d62a17ae | 2252 | return CMD_SUCCESS; |
6811845b | 2253 | } |
6b0655a2 | 2254 | |
2fdd455c PM |
2255 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
2256 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
2257 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2258 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2259 | "BGP specific commands\n" |
2260 | "Change the default bestpath selection\n" | |
2261 | "AS-path attribute\n" | |
2262 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2263 | "Generate an AS_SET\n" |
16fc1eec DS |
2264 | "Do not generate an AS_SET\n") |
2265 | { | |
d62a17ae | 2266 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2267 | int idx = 0; | |
2268 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
219178b6 | 2269 | |
d62a17ae | 2270 | /* no-as-set is now the default behavior so we can silently |
2271 | * ignore it */ | |
2272 | if (argv_find(argv, argc, "as-set", &idx)) | |
2273 | bgp_flag_set(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2274 | else | |
2275 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
219178b6 | 2276 | |
d62a17ae | 2277 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2278 | |
d62a17ae | 2279 | return CMD_SUCCESS; |
16fc1eec DS |
2280 | } |
2281 | ||
219178b6 DW |
2282 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
2283 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2284 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2285 | NO_STR |
2286 | "BGP specific commands\n" | |
2287 | "Change the default bestpath selection\n" | |
2288 | "AS-path attribute\n" | |
2289 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2290 | "Generate an AS_SET\n" |
16fc1eec DS |
2291 | "Do not generate an AS_SET\n") |
2292 | { | |
d62a17ae | 2293 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2294 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
2295 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2296 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2297 | |
d62a17ae | 2298 | return CMD_SUCCESS; |
2fdd455c | 2299 | } |
6b0655a2 | 2300 | |
848973c7 | 2301 | /* "bgp log-neighbor-changes" configuration. */ |
2302 | DEFUN (bgp_log_neighbor_changes, | |
2303 | bgp_log_neighbor_changes_cmd, | |
2304 | "bgp log-neighbor-changes", | |
2305 | "BGP specific commands\n" | |
2306 | "Log neighbor up/down and reset reason\n") | |
2307 | { | |
d62a17ae | 2308 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2309 | bgp_flag_set(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2310 | return CMD_SUCCESS; | |
848973c7 | 2311 | } |
2312 | ||
2313 | DEFUN (no_bgp_log_neighbor_changes, | |
2314 | no_bgp_log_neighbor_changes_cmd, | |
2315 | "no bgp log-neighbor-changes", | |
2316 | NO_STR | |
2317 | "BGP specific commands\n" | |
2318 | "Log neighbor up/down and reset reason\n") | |
2319 | { | |
d62a17ae | 2320 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2321 | bgp_flag_unset(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2322 | return CMD_SUCCESS; | |
848973c7 | 2323 | } |
6b0655a2 | 2324 | |
718e3744 | 2325 | /* "bgp bestpath med" configuration. */ |
2326 | DEFUN (bgp_bestpath_med, | |
2327 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 2328 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2329 | "BGP specific commands\n" |
2330 | "Change the default bestpath selection\n" | |
2331 | "MED attribute\n" | |
2332 | "Compare MED among confederation paths\n" | |
838758ac DW |
2333 | "Treat missing MED as the least preferred one\n" |
2334 | "Treat missing MED as the least preferred one\n" | |
2335 | "Compare MED among confederation paths\n") | |
718e3744 | 2336 | { |
d62a17ae | 2337 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6cbd1915 | 2338 | |
d62a17ae | 2339 | int idx = 0; |
2340 | if (argv_find(argv, argc, "confed", &idx)) | |
2341 | bgp_flag_set(bgp, BGP_FLAG_MED_CONFED); | |
2342 | idx = 0; | |
2343 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2344 | bgp_flag_set(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
e52702f2 | 2345 | |
d62a17ae | 2346 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2347 | |
d62a17ae | 2348 | return CMD_SUCCESS; |
718e3744 | 2349 | } |
2350 | ||
718e3744 | 2351 | DEFUN (no_bgp_bestpath_med, |
2352 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2353 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2354 | NO_STR |
2355 | "BGP specific commands\n" | |
2356 | "Change the default bestpath selection\n" | |
2357 | "MED attribute\n" | |
2358 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2359 | "Treat missing MED as the least preferred one\n" |
2360 | "Treat missing MED as the least preferred one\n" | |
2361 | "Compare MED among confederation paths\n") | |
718e3744 | 2362 | { |
d62a17ae | 2363 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
e52702f2 | 2364 | |
d62a17ae | 2365 | int idx = 0; |
2366 | if (argv_find(argv, argc, "confed", &idx)) | |
2367 | bgp_flag_unset(bgp, BGP_FLAG_MED_CONFED); | |
2368 | idx = 0; | |
2369 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2370 | bgp_flag_unset(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
718e3744 | 2371 | |
d62a17ae | 2372 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2373 | |
d62a17ae | 2374 | return CMD_SUCCESS; |
718e3744 | 2375 | } |
2376 | ||
718e3744 | 2377 | /* "no bgp default ipv4-unicast". */ |
2378 | DEFUN (no_bgp_default_ipv4_unicast, | |
2379 | no_bgp_default_ipv4_unicast_cmd, | |
2380 | "no bgp default ipv4-unicast", | |
2381 | NO_STR | |
2382 | "BGP specific commands\n" | |
2383 | "Configure BGP defaults\n" | |
2384 | "Activate ipv4-unicast for a peer by default\n") | |
2385 | { | |
d62a17ae | 2386 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2387 | bgp_flag_set(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2388 | return CMD_SUCCESS; | |
718e3744 | 2389 | } |
2390 | ||
2391 | DEFUN (bgp_default_ipv4_unicast, | |
2392 | bgp_default_ipv4_unicast_cmd, | |
2393 | "bgp default ipv4-unicast", | |
2394 | "BGP specific commands\n" | |
2395 | "Configure BGP defaults\n" | |
2396 | "Activate ipv4-unicast for a peer by default\n") | |
2397 | { | |
d62a17ae | 2398 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2399 | bgp_flag_unset(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2400 | return CMD_SUCCESS; | |
718e3744 | 2401 | } |
6b0655a2 | 2402 | |
04b6bdc0 DW |
2403 | /* Display hostname in certain command outputs */ |
2404 | DEFUN (bgp_default_show_hostname, | |
2405 | bgp_default_show_hostname_cmd, | |
2406 | "bgp default show-hostname", | |
2407 | "BGP specific commands\n" | |
2408 | "Configure BGP defaults\n" | |
0437e105 | 2409 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 2410 | { |
d62a17ae | 2411 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2412 | bgp_flag_set(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2413 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2414 | } |
2415 | ||
2416 | DEFUN (no_bgp_default_show_hostname, | |
2417 | no_bgp_default_show_hostname_cmd, | |
2418 | "no bgp default show-hostname", | |
2419 | NO_STR | |
2420 | "BGP specific commands\n" | |
2421 | "Configure BGP defaults\n" | |
0437e105 | 2422 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 2423 | { |
d62a17ae | 2424 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2425 | bgp_flag_unset(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2426 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2427 | } |
2428 | ||
8233ef81 | 2429 | /* "bgp network import-check" configuration. */ |
718e3744 | 2430 | DEFUN (bgp_network_import_check, |
2431 | bgp_network_import_check_cmd, | |
5623e905 | 2432 | "bgp network import-check", |
718e3744 | 2433 | "BGP specific commands\n" |
2434 | "BGP network command\n" | |
5623e905 | 2435 | "Check BGP network route exists in IGP\n") |
718e3744 | 2436 | { |
d62a17ae | 2437 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2438 | if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2439 | bgp_flag_set(bgp, BGP_FLAG_IMPORT_CHECK); | |
2440 | bgp_static_redo_import_check(bgp); | |
2441 | } | |
078430f6 | 2442 | |
d62a17ae | 2443 | return CMD_SUCCESS; |
718e3744 | 2444 | } |
2445 | ||
d62a17ae | 2446 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
2447 | "bgp network import-check exact", | |
2448 | "BGP specific commands\n" | |
2449 | "BGP network command\n" | |
2450 | "Check BGP network route exists in IGP\n" | |
2451 | "Match route precisely\n") | |
8233ef81 | 2452 | |
718e3744 | 2453 | DEFUN (no_bgp_network_import_check, |
2454 | no_bgp_network_import_check_cmd, | |
5623e905 | 2455 | "no bgp network import-check", |
718e3744 | 2456 | NO_STR |
2457 | "BGP specific commands\n" | |
2458 | "BGP network command\n" | |
2459 | "Check BGP network route exists in IGP\n") | |
2460 | { | |
d62a17ae | 2461 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2462 | if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2463 | bgp_flag_unset(bgp, BGP_FLAG_IMPORT_CHECK); | |
2464 | bgp_static_redo_import_check(bgp); | |
2465 | } | |
5623e905 | 2466 | |
d62a17ae | 2467 | return CMD_SUCCESS; |
718e3744 | 2468 | } |
6b0655a2 | 2469 | |
718e3744 | 2470 | DEFUN (bgp_default_local_preference, |
2471 | bgp_default_local_preference_cmd, | |
6147e2c6 | 2472 | "bgp default local-preference (0-4294967295)", |
718e3744 | 2473 | "BGP specific commands\n" |
2474 | "Configure BGP defaults\n" | |
2475 | "local preference (higher=more preferred)\n" | |
2476 | "Configure default local preference value\n") | |
2477 | { | |
d62a17ae | 2478 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2479 | int idx_number = 3; | |
d7c0a89a | 2480 | uint32_t local_pref; |
718e3744 | 2481 | |
d62a17ae | 2482 | local_pref = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 2483 | |
d62a17ae | 2484 | bgp_default_local_preference_set(bgp, local_pref); |
2485 | bgp_clear_star_soft_in(vty, bgp->name); | |
718e3744 | 2486 | |
d62a17ae | 2487 | return CMD_SUCCESS; |
718e3744 | 2488 | } |
2489 | ||
2490 | DEFUN (no_bgp_default_local_preference, | |
2491 | no_bgp_default_local_preference_cmd, | |
838758ac | 2492 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 2493 | NO_STR |
2494 | "BGP specific commands\n" | |
2495 | "Configure BGP defaults\n" | |
838758ac DW |
2496 | "local preference (higher=more preferred)\n" |
2497 | "Configure default local preference value\n") | |
718e3744 | 2498 | { |
d62a17ae | 2499 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2500 | bgp_default_local_preference_unset(bgp); | |
2501 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2502 | |
d62a17ae | 2503 | return CMD_SUCCESS; |
718e3744 | 2504 | } |
2505 | ||
6b0655a2 | 2506 | |
3f9c7369 DS |
2507 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
2508 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 2509 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
2510 | "BGP specific commands\n" |
2511 | "Configure BGP defaults\n" | |
2512 | "subgroup-pkt-queue-max\n" | |
2513 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 2514 | { |
d62a17ae | 2515 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2516 | int idx_number = 3; | |
d7c0a89a | 2517 | uint32_t max_size; |
8bd9d948 | 2518 | |
d62a17ae | 2519 | max_size = strtoul(argv[idx_number]->arg, NULL, 10); |
3f9c7369 | 2520 | |
d62a17ae | 2521 | bgp_default_subgroup_pkt_queue_max_set(bgp, max_size); |
3f9c7369 | 2522 | |
d62a17ae | 2523 | return CMD_SUCCESS; |
3f9c7369 DS |
2524 | } |
2525 | ||
2526 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
2527 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 2528 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
2529 | NO_STR |
2530 | "BGP specific commands\n" | |
2531 | "Configure BGP defaults\n" | |
838758ac DW |
2532 | "subgroup-pkt-queue-max\n" |
2533 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 2534 | { |
d62a17ae | 2535 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2536 | bgp_default_subgroup_pkt_queue_max_unset(bgp); | |
2537 | return CMD_SUCCESS; | |
8bd9d948 DS |
2538 | } |
2539 | ||
813d4307 | 2540 | |
8bd9d948 DS |
2541 | DEFUN (bgp_rr_allow_outbound_policy, |
2542 | bgp_rr_allow_outbound_policy_cmd, | |
2543 | "bgp route-reflector allow-outbound-policy", | |
2544 | "BGP specific commands\n" | |
2545 | "Allow modifications made by out route-map\n" | |
2546 | "on ibgp neighbors\n") | |
2547 | { | |
d62a17ae | 2548 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2549 | |
d62a17ae | 2550 | if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2551 | bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2552 | update_group_announce_rrclients(bgp); | |
2553 | bgp_clear_star_soft_out(vty, bgp->name); | |
2554 | } | |
8bd9d948 | 2555 | |
d62a17ae | 2556 | return CMD_SUCCESS; |
8bd9d948 DS |
2557 | } |
2558 | ||
2559 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
2560 | no_bgp_rr_allow_outbound_policy_cmd, | |
2561 | "no bgp route-reflector allow-outbound-policy", | |
2562 | NO_STR | |
2563 | "BGP specific commands\n" | |
2564 | "Allow modifications made by out route-map\n" | |
2565 | "on ibgp neighbors\n") | |
2566 | { | |
d62a17ae | 2567 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2568 | |
d62a17ae | 2569 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2570 | bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2571 | update_group_announce_rrclients(bgp); | |
2572 | bgp_clear_star_soft_out(vty, bgp->name); | |
2573 | } | |
8bd9d948 | 2574 | |
d62a17ae | 2575 | return CMD_SUCCESS; |
8bd9d948 DS |
2576 | } |
2577 | ||
f14e6fdb DS |
2578 | DEFUN (bgp_listen_limit, |
2579 | bgp_listen_limit_cmd, | |
9ccf14f7 | 2580 | "bgp listen limit (1-5000)", |
f14e6fdb DS |
2581 | "BGP specific commands\n" |
2582 | "Configure BGP defaults\n" | |
2583 | "maximum number of BGP Dynamic Neighbors that can be created\n" | |
2584 | "Configure Dynamic Neighbors listen limit value\n") | |
2585 | { | |
d62a17ae | 2586 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2587 | int idx_number = 3; | |
2588 | int listen_limit; | |
f14e6fdb | 2589 | |
d62a17ae | 2590 | listen_limit = strtoul(argv[idx_number]->arg, NULL, 10); |
f14e6fdb | 2591 | |
d62a17ae | 2592 | bgp_listen_limit_set(bgp, listen_limit); |
f14e6fdb | 2593 | |
d62a17ae | 2594 | return CMD_SUCCESS; |
f14e6fdb DS |
2595 | } |
2596 | ||
2597 | DEFUN (no_bgp_listen_limit, | |
2598 | no_bgp_listen_limit_cmd, | |
838758ac | 2599 | "no bgp listen limit [(1-5000)]", |
f14e6fdb DS |
2600 | "BGP specific commands\n" |
2601 | "Configure BGP defaults\n" | |
2602 | "unset maximum number of BGP Dynamic Neighbors that can be created\n" | |
838758ac DW |
2603 | "Configure Dynamic Neighbors listen limit value to default\n" |
2604 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 2605 | { |
d62a17ae | 2606 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2607 | bgp_listen_limit_unset(bgp); | |
2608 | return CMD_SUCCESS; | |
f14e6fdb DS |
2609 | } |
2610 | ||
2611 | ||
20eb8864 | 2612 | /* |
2613 | * Check if this listen range is already configured. Check for exact | |
2614 | * match or overlap based on input. | |
2615 | */ | |
d62a17ae | 2616 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
2617 | struct prefix *range, int exact) | |
2618 | { | |
2619 | struct listnode *node, *nnode; | |
2620 | struct listnode *node1, *nnode1; | |
2621 | struct peer_group *group; | |
2622 | struct prefix *lr; | |
2623 | afi_t afi; | |
2624 | int match; | |
2625 | ||
2626 | afi = family2afi(range->family); | |
2627 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2628 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
2629 | lr)) { | |
2630 | if (exact) | |
2631 | match = prefix_same(range, lr); | |
2632 | else | |
2633 | match = (prefix_match(range, lr) | |
2634 | || prefix_match(lr, range)); | |
2635 | if (match) | |
2636 | return group; | |
2637 | } | |
2638 | } | |
2639 | ||
2640 | return NULL; | |
20eb8864 | 2641 | } |
2642 | ||
f14e6fdb DS |
2643 | DEFUN (bgp_listen_range, |
2644 | bgp_listen_range_cmd, | |
d7b9898c | 2645 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
f14e6fdb | 2646 | "BGP specific commands\n" |
d7fa34c1 QY |
2647 | "Configure BGP dynamic neighbors listen range\n" |
2648 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
2649 | NEIGHBOR_ADDR_STR |
2650 | "Member of the peer-group\n" | |
2651 | "Peer-group name\n") | |
f14e6fdb | 2652 | { |
d62a17ae | 2653 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2654 | struct prefix range; | |
2655 | struct peer_group *group, *existing_group; | |
2656 | afi_t afi; | |
2657 | int ret; | |
2658 | int idx = 0; | |
2659 | ||
2660 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2661 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2662 | char *prefix = argv[idx]->arg; | |
d7b9898c | 2663 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 2664 | char *peergroup = argv[idx]->arg; |
2665 | ||
2666 | /* Convert IP prefix string to struct prefix. */ | |
2667 | ret = str2prefix(prefix, &range); | |
2668 | if (!ret) { | |
2669 | vty_out(vty, "%% Malformed listen range\n"); | |
2670 | return CMD_WARNING_CONFIG_FAILED; | |
2671 | } | |
2672 | ||
2673 | afi = family2afi(range.family); | |
2674 | ||
2675 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2676 | vty_out(vty, | |
2677 | "%% Malformed listen range (link-local address)\n"); | |
2678 | return CMD_WARNING_CONFIG_FAILED; | |
2679 | } | |
2680 | ||
2681 | apply_mask(&range); | |
2682 | ||
2683 | /* Check if same listen range is already configured. */ | |
2684 | existing_group = listen_range_exists(bgp, &range, 1); | |
2685 | if (existing_group) { | |
2686 | if (strcmp(existing_group->name, peergroup) == 0) | |
2687 | return CMD_SUCCESS; | |
2688 | else { | |
2689 | vty_out(vty, | |
2690 | "%% Same listen range is attached to peer-group %s\n", | |
2691 | existing_group->name); | |
2692 | return CMD_WARNING_CONFIG_FAILED; | |
2693 | } | |
2694 | } | |
2695 | ||
2696 | /* Check if an overlapping listen range exists. */ | |
2697 | if (listen_range_exists(bgp, &range, 0)) { | |
2698 | vty_out(vty, | |
2699 | "%% Listen range overlaps with existing listen range\n"); | |
2700 | return CMD_WARNING_CONFIG_FAILED; | |
2701 | } | |
2702 | ||
2703 | group = peer_group_lookup(bgp, peergroup); | |
2704 | if (!group) { | |
2705 | vty_out(vty, "%% Configure the peer-group first\n"); | |
2706 | return CMD_WARNING_CONFIG_FAILED; | |
2707 | } | |
2708 | ||
2709 | ret = peer_group_listen_range_add(group, &range); | |
2710 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
2711 | } |
2712 | ||
2713 | DEFUN (no_bgp_listen_range, | |
2714 | no_bgp_listen_range_cmd, | |
d7b9898c | 2715 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
d7fa34c1 | 2716 | NO_STR |
f14e6fdb | 2717 | "BGP specific commands\n" |
d7fa34c1 QY |
2718 | "Unconfigure BGP dynamic neighbors listen range\n" |
2719 | "Unconfigure BGP dynamic neighbors listen range\n" | |
2720 | NEIGHBOR_ADDR_STR | |
2721 | "Member of the peer-group\n" | |
2722 | "Peer-group name\n") | |
f14e6fdb | 2723 | { |
d62a17ae | 2724 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2725 | struct prefix range; | |
2726 | struct peer_group *group; | |
2727 | afi_t afi; | |
2728 | int ret; | |
2729 | int idx = 0; | |
2730 | ||
2731 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2732 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2733 | char *prefix = argv[idx]->arg; | |
2734 | argv_find(argv, argc, "WORD", &idx); | |
2735 | char *peergroup = argv[idx]->arg; | |
2736 | ||
2737 | /* Convert IP prefix string to struct prefix. */ | |
2738 | ret = str2prefix(prefix, &range); | |
2739 | if (!ret) { | |
2740 | vty_out(vty, "%% Malformed listen range\n"); | |
2741 | return CMD_WARNING_CONFIG_FAILED; | |
2742 | } | |
2743 | ||
2744 | afi = family2afi(range.family); | |
2745 | ||
2746 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2747 | vty_out(vty, | |
2748 | "%% Malformed listen range (link-local address)\n"); | |
2749 | return CMD_WARNING_CONFIG_FAILED; | |
2750 | } | |
2751 | ||
2752 | apply_mask(&range); | |
2753 | ||
2754 | group = peer_group_lookup(bgp, peergroup); | |
2755 | if (!group) { | |
2756 | vty_out(vty, "%% Peer-group does not exist\n"); | |
2757 | return CMD_WARNING_CONFIG_FAILED; | |
2758 | } | |
2759 | ||
2760 | ret = peer_group_listen_range_del(group, &range); | |
2761 | return bgp_vty_return(vty, ret); | |
2762 | } | |
2763 | ||
2b791107 | 2764 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 2765 | { |
2766 | struct peer_group *group; | |
2767 | struct listnode *node, *nnode, *rnode, *nrnode; | |
2768 | struct prefix *range; | |
2769 | afi_t afi; | |
2770 | char buf[PREFIX2STR_BUFFER]; | |
2771 | ||
2772 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
2773 | vty_out(vty, " bgp listen limit %d\n", | |
2774 | bgp->dynamic_neighbors_limit); | |
2775 | ||
2776 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2777 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
2778 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
2779 | nrnode, range)) { | |
2780 | prefix2str(range, buf, sizeof(buf)); | |
2781 | vty_out(vty, | |
2782 | " bgp listen range %s peer-group %s\n", | |
2783 | buf, group->name); | |
2784 | } | |
2785 | } | |
2786 | } | |
f14e6fdb DS |
2787 | } |
2788 | ||
2789 | ||
907f92c8 DS |
2790 | DEFUN (bgp_disable_connected_route_check, |
2791 | bgp_disable_connected_route_check_cmd, | |
2792 | "bgp disable-ebgp-connected-route-check", | |
2793 | "BGP specific commands\n" | |
2794 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2795 | { | |
d62a17ae | 2796 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2797 | bgp_flag_set(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2798 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2799 | |
d62a17ae | 2800 | return CMD_SUCCESS; |
907f92c8 DS |
2801 | } |
2802 | ||
2803 | DEFUN (no_bgp_disable_connected_route_check, | |
2804 | no_bgp_disable_connected_route_check_cmd, | |
2805 | "no bgp disable-ebgp-connected-route-check", | |
2806 | NO_STR | |
2807 | "BGP specific commands\n" | |
2808 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2809 | { | |
d62a17ae | 2810 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2811 | bgp_flag_unset(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2812 | bgp_clear_star_soft_in(vty, bgp->name); | |
2813 | ||
2814 | return CMD_SUCCESS; | |
2815 | } | |
2816 | ||
2817 | ||
2818 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, | |
2819 | const char *as_str, afi_t afi, safi_t safi) | |
2820 | { | |
2821 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2822 | int ret; | |
2823 | as_t as; | |
2824 | int as_type = AS_SPECIFIED; | |
2825 | union sockunion su; | |
2826 | ||
2827 | if (as_str[0] == 'i') { | |
2828 | as = 0; | |
2829 | as_type = AS_INTERNAL; | |
2830 | } else if (as_str[0] == 'e') { | |
2831 | as = 0; | |
2832 | as_type = AS_EXTERNAL; | |
2833 | } else { | |
2834 | /* Get AS number. */ | |
2835 | as = strtoul(as_str, NULL, 10); | |
2836 | } | |
2837 | ||
390485fd | 2838 | /* If peer is peer group or interface peer, call proper function. */ |
d62a17ae | 2839 | ret = str2sockunion(peer_str, &su); |
2840 | if (ret < 0) { | |
390485fd DS |
2841 | struct peer *peer; |
2842 | ||
2843 | /* Check if existing interface peer */ | |
2844 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
2845 | ||
d62a17ae | 2846 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type, afi, |
2847 | safi); | |
390485fd DS |
2848 | |
2849 | /* if not interface peer, check peer-group settings */ | |
2850 | if (ret < 0 && !peer) { | |
d62a17ae | 2851 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); |
2852 | if (ret < 0) { | |
2853 | vty_out(vty, | |
390485fd | 2854 | "%% Create the peer-group or interface first\n"); |
d62a17ae | 2855 | return CMD_WARNING_CONFIG_FAILED; |
2856 | } | |
2857 | return CMD_SUCCESS; | |
2858 | } | |
2859 | } else { | |
2860 | if (peer_address_self_check(bgp, &su)) { | |
2861 | vty_out(vty, | |
2862 | "%% Can not configure the local system as neighbor\n"); | |
2863 | return CMD_WARNING_CONFIG_FAILED; | |
2864 | } | |
2865 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type, afi, safi); | |
2866 | } | |
2867 | ||
2868 | /* This peer belongs to peer group. */ | |
2869 | switch (ret) { | |
2870 | case BGP_ERR_PEER_GROUP_MEMBER: | |
2871 | vty_out(vty, | |
faa16034 | 2872 | "%% Peer-group member cannot override remote-as of peer-group\n"); |
d62a17ae | 2873 | return CMD_WARNING_CONFIG_FAILED; |
2874 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
2875 | vty_out(vty, | |
faa16034 | 2876 | "%% Peer-group members must be all internal or all external\n"); |
d62a17ae | 2877 | return CMD_WARNING_CONFIG_FAILED; |
2878 | } | |
2879 | return bgp_vty_return(vty, ret); | |
718e3744 | 2880 | } |
2881 | ||
f26845f9 QY |
2882 | DEFUN (bgp_default_shutdown, |
2883 | bgp_default_shutdown_cmd, | |
2884 | "[no] bgp default shutdown", | |
2885 | NO_STR | |
2886 | BGP_STR | |
2887 | "Configure BGP defaults\n" | |
b012cbe2 | 2888 | "Apply administrative shutdown to newly configured peers\n") |
f26845f9 QY |
2889 | { |
2890 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2891 | bgp->autoshutdown = !strmatch(argv[0]->text, "no"); | |
2892 | return CMD_SUCCESS; | |
2893 | } | |
2894 | ||
718e3744 | 2895 | DEFUN (neighbor_remote_as, |
2896 | neighbor_remote_as_cmd, | |
3a2d747c | 2897 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2898 | NEIGHBOR_STR |
2899 | NEIGHBOR_ADDR_STR2 | |
2900 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 2901 | AS_STR |
3a2d747c QY |
2902 | "Internal BGP peer\n" |
2903 | "External BGP peer\n") | |
718e3744 | 2904 | { |
d62a17ae | 2905 | int idx_peer = 1; |
2906 | int idx_remote_as = 3; | |
2907 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, | |
2908 | argv[idx_remote_as]->arg, AFI_IP, | |
2909 | SAFI_UNICAST); | |
2910 | } | |
2911 | ||
2912 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, | |
2913 | afi_t afi, safi_t safi, int v6only, | |
2914 | const char *peer_group_name, | |
2915 | const char *as_str) | |
2916 | { | |
2917 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2918 | as_t as = 0; | |
2919 | int as_type = AS_UNSPECIFIED; | |
2920 | struct peer *peer; | |
2921 | struct peer_group *group; | |
2922 | int ret = 0; | |
2923 | union sockunion su; | |
2924 | ||
2925 | group = peer_group_lookup(bgp, conf_if); | |
2926 | ||
2927 | if (group) { | |
2928 | vty_out(vty, "%% Name conflict with peer-group \n"); | |
2929 | return CMD_WARNING_CONFIG_FAILED; | |
2930 | } | |
2931 | ||
2932 | if (as_str) { | |
2933 | if (as_str[0] == 'i') { | |
2934 | as_type = AS_INTERNAL; | |
2935 | } else if (as_str[0] == 'e') { | |
2936 | as_type = AS_EXTERNAL; | |
2937 | } else { | |
2938 | /* Get AS number. */ | |
2939 | as = strtoul(as_str, NULL, 10); | |
2940 | as_type = AS_SPECIFIED; | |
2941 | } | |
2942 | } | |
2943 | ||
2944 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
2945 | if (peer) { | |
2946 | if (as_str) | |
cc4d4ce8 | 2947 | ret = peer_remote_as(bgp, NULL, conf_if, &as, as_type, |
d62a17ae | 2948 | afi, safi); |
2949 | } else { | |
2950 | if (bgp_flag_check(bgp, BGP_FLAG_NO_DEFAULT_IPV4) | |
2951 | && afi == AFI_IP && safi == SAFI_UNICAST) | |
2952 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
2953 | as_type, 0, 0, NULL); | |
2954 | else | |
2955 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
2956 | as_type, afi, safi, NULL); | |
2957 | ||
2958 | if (!peer) { | |
2959 | vty_out(vty, "%% BGP failed to create peer\n"); | |
2960 | return CMD_WARNING_CONFIG_FAILED; | |
2961 | } | |
2962 | ||
2963 | if (v6only) | |
527de3dc | 2964 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 2965 | |
2966 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
2967 | * this | |
2968 | * any unnumbered peer in order to not worry about run-time | |
2969 | * transitions | |
2970 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
2971 | * address | |
2972 | * gets deleted later etc.) | |
2973 | */ | |
2974 | if (peer->ifp) | |
2975 | bgp_zebra_initiate_radv(bgp, peer); | |
2976 | } | |
2977 | ||
2978 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
2979 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
2980 | if (v6only) | |
527de3dc | 2981 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 2982 | else |
527de3dc | 2983 | peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 2984 | |
2985 | /* v6only flag changed. Reset bgp seesion */ | |
2986 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2987 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
2988 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2989 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2990 | } else | |
2991 | bgp_session_reset(peer); | |
2992 | } | |
2993 | ||
9fb964de PM |
2994 | if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) { |
2995 | SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE); | |
2996 | SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE); | |
dc2f50f3 | 2997 | SET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE); |
9fb964de | 2998 | } |
d62a17ae | 2999 | |
3000 | if (peer_group_name) { | |
3001 | group = peer_group_lookup(bgp, peer_group_name); | |
3002 | if (!group) { | |
3003 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3004 | return CMD_WARNING_CONFIG_FAILED; | |
3005 | } | |
3006 | ||
3007 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
3008 | } | |
3009 | ||
3010 | return bgp_vty_return(vty, ret); | |
a80beece DS |
3011 | } |
3012 | ||
4c48cf63 DW |
3013 | DEFUN (neighbor_interface_config, |
3014 | neighbor_interface_config_cmd, | |
d7b9898c | 3015 | "neighbor WORD interface [peer-group PGNAME]", |
4c48cf63 DW |
3016 | NEIGHBOR_STR |
3017 | "Interface name or neighbor tag\n" | |
31500417 DW |
3018 | "Enable BGP on interface\n" |
3019 | "Member of the peer-group\n" | |
16cedbb0 | 3020 | "Peer-group name\n") |
4c48cf63 | 3021 | { |
d62a17ae | 3022 | int idx_word = 1; |
3023 | int idx_peer_group_word = 4; | |
31500417 | 3024 | |
d62a17ae | 3025 | if (argc > idx_peer_group_word) |
3026 | return peer_conf_interface_get( | |
3027 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
3028 | argv[idx_peer_group_word]->arg, NULL); | |
3029 | else | |
3030 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3031 | SAFI_UNICAST, 0, NULL, NULL); | |
4c48cf63 DW |
3032 | } |
3033 | ||
4c48cf63 DW |
3034 | DEFUN (neighbor_interface_config_v6only, |
3035 | neighbor_interface_config_v6only_cmd, | |
d7b9898c | 3036 | "neighbor WORD interface v6only [peer-group PGNAME]", |
4c48cf63 DW |
3037 | NEIGHBOR_STR |
3038 | "Interface name or neighbor tag\n" | |
3039 | "Enable BGP on interface\n" | |
31500417 DW |
3040 | "Enable BGP with v6 link-local only\n" |
3041 | "Member of the peer-group\n" | |
16cedbb0 | 3042 | "Peer-group name\n") |
4c48cf63 | 3043 | { |
d62a17ae | 3044 | int idx_word = 1; |
3045 | int idx_peer_group_word = 5; | |
31500417 | 3046 | |
d62a17ae | 3047 | if (argc > idx_peer_group_word) |
3048 | return peer_conf_interface_get( | |
3049 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
3050 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 3051 | |
d62a17ae | 3052 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, |
3053 | SAFI_UNICAST, 1, NULL, NULL); | |
4c48cf63 DW |
3054 | } |
3055 | ||
a80beece | 3056 | |
b3a39dc5 DD |
3057 | DEFUN (neighbor_interface_config_remote_as, |
3058 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 3059 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
3060 | NEIGHBOR_STR |
3061 | "Interface name or neighbor tag\n" | |
3062 | "Enable BGP on interface\n" | |
3a2d747c | 3063 | "Specify a BGP neighbor\n" |
d7fa34c1 | 3064 | AS_STR |
3a2d747c QY |
3065 | "Internal BGP peer\n" |
3066 | "External BGP peer\n") | |
b3a39dc5 | 3067 | { |
d62a17ae | 3068 | int idx_word = 1; |
3069 | int idx_remote_as = 4; | |
3070 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3071 | SAFI_UNICAST, 0, NULL, | |
3072 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
3073 | } |
3074 | ||
3075 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
3076 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 3077 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
3078 | NEIGHBOR_STR |
3079 | "Interface name or neighbor tag\n" | |
3a2d747c | 3080 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 3081 | "Enable BGP on interface\n" |
3a2d747c | 3082 | "Specify a BGP neighbor\n" |
d7fa34c1 | 3083 | AS_STR |
3a2d747c QY |
3084 | "Internal BGP peer\n" |
3085 | "External BGP peer\n") | |
b3a39dc5 | 3086 | { |
d62a17ae | 3087 | int idx_word = 1; |
3088 | int idx_remote_as = 5; | |
3089 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3090 | SAFI_UNICAST, 1, NULL, | |
3091 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
3092 | } |
3093 | ||
718e3744 | 3094 | DEFUN (neighbor_peer_group, |
3095 | neighbor_peer_group_cmd, | |
3096 | "neighbor WORD peer-group", | |
3097 | NEIGHBOR_STR | |
a80beece | 3098 | "Interface name or neighbor tag\n" |
718e3744 | 3099 | "Configure peer-group\n") |
3100 | { | |
d62a17ae | 3101 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3102 | int idx_word = 1; | |
3103 | struct peer *peer; | |
3104 | struct peer_group *group; | |
718e3744 | 3105 | |
d62a17ae | 3106 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
3107 | if (peer) { | |
3108 | vty_out(vty, "%% Name conflict with interface: \n"); | |
3109 | return CMD_WARNING_CONFIG_FAILED; | |
3110 | } | |
718e3744 | 3111 | |
d62a17ae | 3112 | group = peer_group_get(bgp, argv[idx_word]->arg); |
3113 | if (!group) { | |
3114 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
3115 | return CMD_WARNING_CONFIG_FAILED; | |
3116 | } | |
718e3744 | 3117 | |
d62a17ae | 3118 | return CMD_SUCCESS; |
718e3744 | 3119 | } |
3120 | ||
3121 | DEFUN (no_neighbor, | |
3122 | no_neighbor_cmd, | |
dab8cd00 | 3123 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 3124 | NO_STR |
3125 | NEIGHBOR_STR | |
3a2d747c QY |
3126 | NEIGHBOR_ADDR_STR2 |
3127 | "Specify a BGP neighbor\n" | |
3128 | AS_STR | |
3129 | "Internal BGP peer\n" | |
3130 | "External BGP peer\n") | |
718e3744 | 3131 | { |
d62a17ae | 3132 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3133 | int idx_peer = 2; | |
3134 | int ret; | |
3135 | union sockunion su; | |
3136 | struct peer_group *group; | |
3137 | struct peer *peer; | |
3138 | struct peer *other; | |
3139 | ||
3140 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
3141 | if (ret < 0) { | |
3142 | /* look up for neighbor by interface name config. */ | |
3143 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3144 | if (peer) { | |
3145 | /* Request zebra to terminate IPv6 RAs on this | |
3146 | * interface. */ | |
3147 | if (peer->ifp) | |
3148 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
3149 | peer_delete(peer); | |
3150 | return CMD_SUCCESS; | |
3151 | } | |
f14e6fdb | 3152 | |
d62a17ae | 3153 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); |
3154 | if (group) | |
3155 | peer_group_delete(group); | |
3156 | else { | |
3157 | vty_out(vty, "%% Create the peer-group first\n"); | |
3158 | return CMD_WARNING_CONFIG_FAILED; | |
3159 | } | |
3160 | } else { | |
3161 | peer = peer_lookup(bgp, &su); | |
3162 | if (peer) { | |
3163 | if (peer_dynamic_neighbor(peer)) { | |
3164 | vty_out(vty, | |
3165 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3166 | return CMD_WARNING_CONFIG_FAILED; | |
3167 | } | |
3168 | ||
3169 | other = peer->doppelganger; | |
3170 | peer_delete(peer); | |
3171 | if (other && other->status != Deleted) | |
3172 | peer_delete(other); | |
3173 | } | |
1ff9a340 | 3174 | } |
718e3744 | 3175 | |
d62a17ae | 3176 | return CMD_SUCCESS; |
718e3744 | 3177 | } |
3178 | ||
a80beece DS |
3179 | DEFUN (no_neighbor_interface_config, |
3180 | no_neighbor_interface_config_cmd, | |
d7b9898c | 3181 | "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
3182 | NO_STR |
3183 | NEIGHBOR_STR | |
3184 | "Interface name\n" | |
31500417 DW |
3185 | "Configure BGP on interface\n" |
3186 | "Enable BGP with v6 link-local only\n" | |
3187 | "Member of the peer-group\n" | |
16cedbb0 | 3188 | "Peer-group name\n" |
3a2d747c QY |
3189 | "Specify a BGP neighbor\n" |
3190 | AS_STR | |
3191 | "Internal BGP peer\n" | |
3192 | "External BGP peer\n") | |
a80beece | 3193 | { |
d62a17ae | 3194 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3195 | int idx_word = 2; | |
3196 | struct peer *peer; | |
3197 | ||
3198 | /* look up for neighbor by interface name config. */ | |
3199 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3200 | if (peer) { | |
3201 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
3202 | if (peer->ifp) | |
3203 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
3204 | peer_delete(peer); | |
3205 | } else { | |
3206 | vty_out(vty, "%% Create the bgp interface first\n"); | |
3207 | return CMD_WARNING_CONFIG_FAILED; | |
3208 | } | |
3209 | return CMD_SUCCESS; | |
a80beece DS |
3210 | } |
3211 | ||
718e3744 | 3212 | DEFUN (no_neighbor_peer_group, |
3213 | no_neighbor_peer_group_cmd, | |
3214 | "no neighbor WORD peer-group", | |
3215 | NO_STR | |
3216 | NEIGHBOR_STR | |
3217 | "Neighbor tag\n" | |
3218 | "Configure peer-group\n") | |
3219 | { | |
d62a17ae | 3220 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3221 | int idx_word = 2; | |
3222 | struct peer_group *group; | |
718e3744 | 3223 | |
d62a17ae | 3224 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
3225 | if (group) | |
3226 | peer_group_delete(group); | |
3227 | else { | |
3228 | vty_out(vty, "%% Create the peer-group first\n"); | |
3229 | return CMD_WARNING_CONFIG_FAILED; | |
3230 | } | |
3231 | return CMD_SUCCESS; | |
718e3744 | 3232 | } |
3233 | ||
a80beece DS |
3234 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
3235 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 3236 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3237 | NO_STR |
3238 | NEIGHBOR_STR | |
a80beece | 3239 | "Interface name or neighbor tag\n" |
718e3744 | 3240 | "Specify a BGP neighbor\n" |
3a2d747c QY |
3241 | AS_STR |
3242 | "Internal BGP peer\n" | |
3243 | "External BGP peer\n") | |
718e3744 | 3244 | { |
d62a17ae | 3245 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3246 | int idx_word = 2; | |
3247 | struct peer_group *group; | |
3248 | struct peer *peer; | |
3249 | ||
3250 | /* look up for neighbor by interface name config. */ | |
3251 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3252 | if (peer) { | |
390485fd | 3253 | peer_as_change(peer, 0, AS_UNSPECIFIED); |
d62a17ae | 3254 | return CMD_SUCCESS; |
3255 | } | |
3256 | ||
3257 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3258 | if (group) | |
3259 | peer_group_remote_as_delete(group); | |
3260 | else { | |
3261 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
3262 | return CMD_WARNING_CONFIG_FAILED; | |
3263 | } | |
3264 | return CMD_SUCCESS; | |
718e3744 | 3265 | } |
6b0655a2 | 3266 | |
718e3744 | 3267 | DEFUN (neighbor_local_as, |
3268 | neighbor_local_as_cmd, | |
9ccf14f7 | 3269 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 3270 | NEIGHBOR_STR |
3271 | NEIGHBOR_ADDR_STR2 | |
3272 | "Specify a local-as number\n" | |
3273 | "AS number used as local AS\n") | |
3274 | { | |
d62a17ae | 3275 | int idx_peer = 1; |
3276 | int idx_number = 3; | |
3277 | struct peer *peer; | |
3278 | int ret; | |
3279 | as_t as; | |
718e3744 | 3280 | |
d62a17ae | 3281 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3282 | if (!peer) | |
3283 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3284 | |
d62a17ae | 3285 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3286 | ret = peer_local_as_set(peer, as, 0, 0); | |
3287 | return bgp_vty_return(vty, ret); | |
718e3744 | 3288 | } |
3289 | ||
3290 | DEFUN (neighbor_local_as_no_prepend, | |
3291 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 3292 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 3293 | NEIGHBOR_STR |
3294 | NEIGHBOR_ADDR_STR2 | |
3295 | "Specify a local-as number\n" | |
3296 | "AS number used as local AS\n" | |
3297 | "Do not prepend local-as to updates from ebgp peers\n") | |
3298 | { | |
d62a17ae | 3299 | int idx_peer = 1; |
3300 | int idx_number = 3; | |
3301 | struct peer *peer; | |
3302 | int ret; | |
3303 | as_t as; | |
718e3744 | 3304 | |
d62a17ae | 3305 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3306 | if (!peer) | |
3307 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3308 | |
d62a17ae | 3309 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3310 | ret = peer_local_as_set(peer, as, 1, 0); | |
3311 | return bgp_vty_return(vty, ret); | |
718e3744 | 3312 | } |
3313 | ||
9d3f9705 AC |
3314 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
3315 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 3316 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
3317 | NEIGHBOR_STR |
3318 | NEIGHBOR_ADDR_STR2 | |
3319 | "Specify a local-as number\n" | |
3320 | "AS number used as local AS\n" | |
3321 | "Do not prepend local-as to updates from ebgp peers\n" | |
3322 | "Do not prepend local-as to updates from ibgp peers\n") | |
3323 | { | |
d62a17ae | 3324 | int idx_peer = 1; |
3325 | int idx_number = 3; | |
3326 | struct peer *peer; | |
3327 | int ret; | |
3328 | as_t as; | |
9d3f9705 | 3329 | |
d62a17ae | 3330 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3331 | if (!peer) | |
3332 | return CMD_WARNING_CONFIG_FAILED; | |
9d3f9705 | 3333 | |
d62a17ae | 3334 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3335 | ret = peer_local_as_set(peer, as, 1, 1); | |
3336 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
3337 | } |
3338 | ||
718e3744 | 3339 | DEFUN (no_neighbor_local_as, |
3340 | no_neighbor_local_as_cmd, | |
a636c635 | 3341 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 3342 | NO_STR |
3343 | NEIGHBOR_STR | |
3344 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
3345 | "Specify a local-as number\n" |
3346 | "AS number used as local AS\n" | |
3347 | "Do not prepend local-as to updates from ebgp peers\n" | |
3348 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 3349 | { |
d62a17ae | 3350 | int idx_peer = 2; |
3351 | struct peer *peer; | |
3352 | int ret; | |
718e3744 | 3353 | |
d62a17ae | 3354 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3355 | if (!peer) | |
3356 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3357 | |
d62a17ae | 3358 | ret = peer_local_as_unset(peer); |
3359 | return bgp_vty_return(vty, ret); | |
718e3744 | 3360 | } |
3361 | ||
718e3744 | 3362 | |
3f9c7369 DS |
3363 | DEFUN (neighbor_solo, |
3364 | neighbor_solo_cmd, | |
9ccf14f7 | 3365 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3366 | NEIGHBOR_STR |
3367 | NEIGHBOR_ADDR_STR2 | |
3368 | "Solo peer - part of its own update group\n") | |
3369 | { | |
d62a17ae | 3370 | int idx_peer = 1; |
3371 | struct peer *peer; | |
3372 | int ret; | |
3f9c7369 | 3373 | |
d62a17ae | 3374 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3375 | if (!peer) | |
3376 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3377 | |
d62a17ae | 3378 | ret = update_group_adjust_soloness(peer, 1); |
3379 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3380 | } |
3381 | ||
3382 | DEFUN (no_neighbor_solo, | |
3383 | no_neighbor_solo_cmd, | |
9ccf14f7 | 3384 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3385 | NO_STR |
3386 | NEIGHBOR_STR | |
3387 | NEIGHBOR_ADDR_STR2 | |
3388 | "Solo peer - part of its own update group\n") | |
3389 | { | |
d62a17ae | 3390 | int idx_peer = 2; |
3391 | struct peer *peer; | |
3392 | int ret; | |
3f9c7369 | 3393 | |
d62a17ae | 3394 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3395 | if (!peer) | |
3396 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3397 | |
d62a17ae | 3398 | ret = update_group_adjust_soloness(peer, 0); |
3399 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3400 | } |
3401 | ||
0df7c91f PJ |
3402 | DEFUN (neighbor_password, |
3403 | neighbor_password_cmd, | |
9ccf14f7 | 3404 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
3405 | NEIGHBOR_STR |
3406 | NEIGHBOR_ADDR_STR2 | |
3407 | "Set a password\n" | |
3408 | "The password\n") | |
3409 | { | |
d62a17ae | 3410 | int idx_peer = 1; |
3411 | int idx_line = 3; | |
3412 | struct peer *peer; | |
3413 | int ret; | |
0df7c91f | 3414 | |
d62a17ae | 3415 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3416 | if (!peer) | |
3417 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3418 | |
d62a17ae | 3419 | ret = peer_password_set(peer, argv[idx_line]->arg); |
3420 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
3421 | } |
3422 | ||
3423 | DEFUN (no_neighbor_password, | |
3424 | no_neighbor_password_cmd, | |
a636c635 | 3425 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
3426 | NO_STR |
3427 | NEIGHBOR_STR | |
3428 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
3429 | "Set a password\n" |
3430 | "The password\n") | |
0df7c91f | 3431 | { |
d62a17ae | 3432 | int idx_peer = 2; |
3433 | struct peer *peer; | |
3434 | int ret; | |
0df7c91f | 3435 | |
d62a17ae | 3436 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3437 | if (!peer) | |
3438 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3439 | |
d62a17ae | 3440 | ret = peer_password_unset(peer); |
3441 | return bgp_vty_return(vty, ret); | |
0df7c91f | 3442 | } |
6b0655a2 | 3443 | |
718e3744 | 3444 | DEFUN (neighbor_activate, |
3445 | neighbor_activate_cmd, | |
9ccf14f7 | 3446 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3447 | NEIGHBOR_STR |
3448 | NEIGHBOR_ADDR_STR2 | |
3449 | "Enable the Address Family for this Neighbor\n") | |
3450 | { | |
d62a17ae | 3451 | int idx_peer = 1; |
3452 | int ret; | |
3453 | struct peer *peer; | |
718e3744 | 3454 | |
d62a17ae | 3455 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3456 | if (!peer) | |
3457 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3458 | |
d62a17ae | 3459 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3460 | return bgp_vty_return(vty, ret); | |
718e3744 | 3461 | } |
3462 | ||
d62a17ae | 3463 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
3464 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3465 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3466 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3467 | |
718e3744 | 3468 | DEFUN (no_neighbor_activate, |
3469 | no_neighbor_activate_cmd, | |
9ccf14f7 | 3470 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3471 | NO_STR |
3472 | NEIGHBOR_STR | |
3473 | NEIGHBOR_ADDR_STR2 | |
3474 | "Enable the Address Family for this Neighbor\n") | |
3475 | { | |
d62a17ae | 3476 | int idx_peer = 2; |
3477 | int ret; | |
3478 | struct peer *peer; | |
718e3744 | 3479 | |
d62a17ae | 3480 | /* Lookup peer. */ |
3481 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3482 | if (!peer) | |
3483 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3484 | |
d62a17ae | 3485 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3486 | return bgp_vty_return(vty, ret); | |
718e3744 | 3487 | } |
6b0655a2 | 3488 | |
d62a17ae | 3489 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
3490 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3491 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3492 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3493 | |
718e3744 | 3494 | DEFUN (neighbor_set_peer_group, |
3495 | neighbor_set_peer_group_cmd, | |
d7b9898c | 3496 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
718e3744 | 3497 | NEIGHBOR_STR |
a80beece | 3498 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3499 | "Member of the peer-group\n" |
16cedbb0 | 3500 | "Peer-group name\n") |
718e3744 | 3501 | { |
d62a17ae | 3502 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3503 | int idx_peer = 1; | |
3504 | int idx_word = 3; | |
3505 | int ret; | |
3506 | as_t as; | |
3507 | union sockunion su; | |
3508 | struct peer *peer; | |
3509 | struct peer_group *group; | |
3510 | ||
d62a17ae | 3511 | ret = str2sockunion(argv[idx_peer]->arg, &su); |
3512 | if (ret < 0) { | |
3513 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3514 | if (!peer) { | |
3515 | vty_out(vty, "%% Malformed address or name: %s\n", | |
3516 | argv[idx_peer]->arg); | |
3517 | return CMD_WARNING_CONFIG_FAILED; | |
3518 | } | |
3519 | } else { | |
3520 | if (peer_address_self_check(bgp, &su)) { | |
3521 | vty_out(vty, | |
3522 | "%% Can not configure the local system as neighbor\n"); | |
3523 | return CMD_WARNING_CONFIG_FAILED; | |
3524 | } | |
3525 | ||
3526 | /* Disallow for dynamic neighbor. */ | |
3527 | peer = peer_lookup(bgp, &su); | |
3528 | if (peer && peer_dynamic_neighbor(peer)) { | |
3529 | vty_out(vty, | |
3530 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3531 | return CMD_WARNING_CONFIG_FAILED; | |
3532 | } | |
3533 | } | |
3534 | ||
3535 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3536 | if (!group) { | |
3537 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3538 | return CMD_WARNING_CONFIG_FAILED; | |
3539 | } | |
3540 | ||
3541 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
3542 | ||
3543 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { | |
3544 | vty_out(vty, | |
3545 | "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", | |
3546 | as); | |
3547 | return CMD_WARNING_CONFIG_FAILED; | |
3548 | } | |
3549 | ||
3550 | return bgp_vty_return(vty, ret); | |
3551 | } | |
3552 | ||
3553 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
d7b9898c | 3554 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 3555 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
3556 | "Member of the peer-group\n" | |
3557 | "Peer-group name\n") | |
596c17ba | 3558 | |
718e3744 | 3559 | DEFUN (no_neighbor_set_peer_group, |
3560 | no_neighbor_set_peer_group_cmd, | |
d7b9898c | 3561 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
718e3744 | 3562 | NO_STR |
3563 | NEIGHBOR_STR | |
a80beece | 3564 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3565 | "Member of the peer-group\n" |
16cedbb0 | 3566 | "Peer-group name\n") |
718e3744 | 3567 | { |
d62a17ae | 3568 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3569 | int idx_peer = 2; | |
3570 | int idx_word = 4; | |
3571 | int ret; | |
3572 | struct peer *peer; | |
3573 | struct peer_group *group; | |
3574 | ||
3575 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); | |
3576 | if (!peer) | |
3577 | return CMD_WARNING_CONFIG_FAILED; | |
3578 | ||
3579 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3580 | if (!group) { | |
3581 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3582 | return CMD_WARNING_CONFIG_FAILED; | |
3583 | } | |
718e3744 | 3584 | |
827ed707 | 3585 | ret = peer_delete(peer); |
718e3744 | 3586 | |
d62a17ae | 3587 | return bgp_vty_return(vty, ret); |
718e3744 | 3588 | } |
6b0655a2 | 3589 | |
d62a17ae | 3590 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
d7b9898c | 3591 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 3592 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
3593 | "Member of the peer-group\n" | |
3594 | "Peer-group name\n") | |
596c17ba | 3595 | |
d62a17ae | 3596 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 3597 | uint32_t flag, int set) |
718e3744 | 3598 | { |
d62a17ae | 3599 | int ret; |
3600 | struct peer *peer; | |
718e3744 | 3601 | |
d62a17ae | 3602 | peer = peer_and_group_lookup_vty(vty, ip_str); |
3603 | if (!peer) | |
3604 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3605 | |
7ebe625c QY |
3606 | /* |
3607 | * If 'neighbor <interface>', then this is for directly connected peers, | |
3608 | * we should not accept disable-connected-check. | |
3609 | */ | |
3610 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
3611 | vty_out(vty, | |
3612 | "%s is directly connected peer, cannot accept disable-" | |
3613 | "connected-check\n", | |
3614 | ip_str); | |
3615 | return CMD_WARNING_CONFIG_FAILED; | |
3616 | } | |
3617 | ||
d62a17ae | 3618 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
3619 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 3620 | |
d62a17ae | 3621 | if (set) |
3622 | ret = peer_flag_set(peer, flag); | |
3623 | else | |
3624 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 3625 | |
d62a17ae | 3626 | return bgp_vty_return(vty, ret); |
718e3744 | 3627 | } |
3628 | ||
47cbc09b | 3629 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint32_t flag) |
718e3744 | 3630 | { |
d62a17ae | 3631 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 3632 | } |
3633 | ||
d62a17ae | 3634 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 3635 | uint32_t flag) |
718e3744 | 3636 | { |
d62a17ae | 3637 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 3638 | } |
3639 | ||
3640 | /* neighbor passive. */ | |
3641 | DEFUN (neighbor_passive, | |
3642 | neighbor_passive_cmd, | |
9ccf14f7 | 3643 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3644 | NEIGHBOR_STR |
3645 | NEIGHBOR_ADDR_STR2 | |
3646 | "Don't send open messages to this neighbor\n") | |
3647 | { | |
d62a17ae | 3648 | int idx_peer = 1; |
3649 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3650 | } |
3651 | ||
3652 | DEFUN (no_neighbor_passive, | |
3653 | no_neighbor_passive_cmd, | |
9ccf14f7 | 3654 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3655 | NO_STR |
3656 | NEIGHBOR_STR | |
3657 | NEIGHBOR_ADDR_STR2 | |
3658 | "Don't send open messages to this neighbor\n") | |
3659 | { | |
d62a17ae | 3660 | int idx_peer = 2; |
3661 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3662 | } |
6b0655a2 | 3663 | |
718e3744 | 3664 | /* neighbor shutdown. */ |
73d70fa6 DL |
3665 | DEFUN (neighbor_shutdown_msg, |
3666 | neighbor_shutdown_msg_cmd, | |
3667 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
718e3744 | 3668 | NEIGHBOR_STR |
3669 | NEIGHBOR_ADDR_STR2 | |
73d70fa6 DL |
3670 | "Administratively shut down this neighbor\n" |
3671 | "Add a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3672 | "Shutdown message\n") | |
718e3744 | 3673 | { |
d62a17ae | 3674 | int idx_peer = 1; |
73d70fa6 | 3675 | |
d62a17ae | 3676 | if (argc >= 5) { |
3677 | struct peer *peer = | |
3678 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3679 | char *message; | |
73d70fa6 | 3680 | |
d62a17ae | 3681 | if (!peer) |
3682 | return CMD_WARNING_CONFIG_FAILED; | |
3683 | message = argv_concat(argv, argc, 4); | |
3684 | peer_tx_shutdown_message_set(peer, message); | |
3685 | XFREE(MTYPE_TMP, message); | |
3686 | } | |
73d70fa6 | 3687 | |
d62a17ae | 3688 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 3689 | } |
3690 | ||
d62a17ae | 3691 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
3692 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3693 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3694 | "Administratively shut down this neighbor\n") | |
73d70fa6 DL |
3695 | |
3696 | DEFUN (no_neighbor_shutdown_msg, | |
3697 | no_neighbor_shutdown_msg_cmd, | |
3698 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
3699 | NO_STR | |
3700 | NEIGHBOR_STR | |
3701 | NEIGHBOR_ADDR_STR2 | |
3702 | "Administratively shut down this neighbor\n" | |
3703 | "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3704 | "Shutdown message\n") | |
718e3744 | 3705 | { |
d62a17ae | 3706 | int idx_peer = 2; |
73d70fa6 | 3707 | |
d62a17ae | 3708 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
3709 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 3710 | } |
6b0655a2 | 3711 | |
d62a17ae | 3712 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
3713 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3714 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3715 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 3716 | |
718e3744 | 3717 | /* neighbor capability dynamic. */ |
3718 | DEFUN (neighbor_capability_dynamic, | |
3719 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3720 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3721 | NEIGHBOR_STR |
3722 | NEIGHBOR_ADDR_STR2 | |
3723 | "Advertise capability to the peer\n" | |
3724 | "Advertise dynamic capability to this neighbor\n") | |
3725 | { | |
d62a17ae | 3726 | int idx_peer = 1; |
3727 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3728 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3729 | } |
3730 | ||
3731 | DEFUN (no_neighbor_capability_dynamic, | |
3732 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3733 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3734 | NO_STR |
3735 | NEIGHBOR_STR | |
3736 | NEIGHBOR_ADDR_STR2 | |
3737 | "Advertise capability to the peer\n" | |
3738 | "Advertise dynamic capability to this neighbor\n") | |
3739 | { | |
d62a17ae | 3740 | int idx_peer = 2; |
3741 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3742 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3743 | } |
6b0655a2 | 3744 | |
718e3744 | 3745 | /* neighbor dont-capability-negotiate */ |
3746 | DEFUN (neighbor_dont_capability_negotiate, | |
3747 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3748 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3749 | NEIGHBOR_STR |
3750 | NEIGHBOR_ADDR_STR2 | |
3751 | "Do not perform capability negotiation\n") | |
3752 | { | |
d62a17ae | 3753 | int idx_peer = 1; |
3754 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3755 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3756 | } |
3757 | ||
3758 | DEFUN (no_neighbor_dont_capability_negotiate, | |
3759 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3760 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3761 | NO_STR |
3762 | NEIGHBOR_STR | |
3763 | NEIGHBOR_ADDR_STR2 | |
3764 | "Do not perform capability negotiation\n") | |
3765 | { | |
d62a17ae | 3766 | int idx_peer = 2; |
3767 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3768 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3769 | } |
6b0655a2 | 3770 | |
8a92a8a0 DS |
3771 | /* neighbor capability extended next hop encoding */ |
3772 | DEFUN (neighbor_capability_enhe, | |
3773 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3774 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3775 | NEIGHBOR_STR |
3776 | NEIGHBOR_ADDR_STR2 | |
3777 | "Advertise capability to the peer\n" | |
3778 | "Advertise extended next-hop capability to the peer\n") | |
3779 | { | |
d62a17ae | 3780 | int idx_peer = 1; |
3781 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3782 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3783 | } |
3784 | ||
3785 | DEFUN (no_neighbor_capability_enhe, | |
3786 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3787 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3788 | NO_STR |
3789 | NEIGHBOR_STR | |
3790 | NEIGHBOR_ADDR_STR2 | |
3791 | "Advertise capability to the peer\n" | |
3792 | "Advertise extended next-hop capability to the peer\n") | |
3793 | { | |
d62a17ae | 3794 | int idx_peer = 2; |
3795 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3796 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3797 | } |
3798 | ||
d62a17ae | 3799 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3800 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 3801 | int set) |
718e3744 | 3802 | { |
d62a17ae | 3803 | int ret; |
3804 | struct peer *peer; | |
718e3744 | 3805 | |
d62a17ae | 3806 | peer = peer_and_group_lookup_vty(vty, peer_str); |
3807 | if (!peer) | |
3808 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3809 | |
d62a17ae | 3810 | if (set) |
3811 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
3812 | else | |
3813 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 3814 | |
d62a17ae | 3815 | return bgp_vty_return(vty, ret); |
718e3744 | 3816 | } |
3817 | ||
d62a17ae | 3818 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3819 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 3820 | { |
d62a17ae | 3821 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 3822 | } |
3823 | ||
d62a17ae | 3824 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3825 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 3826 | { |
d62a17ae | 3827 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 3828 | } |
6b0655a2 | 3829 | |
718e3744 | 3830 | /* neighbor capability orf prefix-list. */ |
3831 | DEFUN (neighbor_capability_orf_prefix, | |
3832 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3833 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3834 | NEIGHBOR_STR |
3835 | NEIGHBOR_ADDR_STR2 | |
3836 | "Advertise capability to the peer\n" | |
3837 | "Advertise ORF capability to the peer\n" | |
3838 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3839 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3840 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3841 | "Capability to SEND the ORF to this neighbor\n") | |
3842 | { | |
d62a17ae | 3843 | int idx_peer = 1; |
3844 | int idx_send_recv = 5; | |
d7c0a89a | 3845 | uint16_t flag = 0; |
d62a17ae | 3846 | |
3847 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3848 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3849 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3850 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3851 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3852 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3853 | else { | |
3854 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3855 | return CMD_WARNING_CONFIG_FAILED; | |
3856 | } | |
3857 | ||
3858 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3859 | bgp_node_safi(vty), flag); | |
3860 | } | |
3861 | ||
3862 | ALIAS_HIDDEN( | |
3863 | neighbor_capability_orf_prefix, | |
3864 | neighbor_capability_orf_prefix_hidden_cmd, | |
3865 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3866 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3867 | "Advertise capability to the peer\n" | |
3868 | "Advertise ORF capability to the peer\n" | |
3869 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3870 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3871 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3872 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 3873 | |
718e3744 | 3874 | DEFUN (no_neighbor_capability_orf_prefix, |
3875 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3876 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3877 | NO_STR |
3878 | NEIGHBOR_STR | |
3879 | NEIGHBOR_ADDR_STR2 | |
3880 | "Advertise capability to the peer\n" | |
3881 | "Advertise ORF capability to the peer\n" | |
3882 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3883 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3884 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3885 | "Capability to SEND the ORF to this neighbor\n") | |
3886 | { | |
d62a17ae | 3887 | int idx_peer = 2; |
3888 | int idx_send_recv = 6; | |
d7c0a89a | 3889 | uint16_t flag = 0; |
d62a17ae | 3890 | |
3891 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3892 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3893 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3894 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3895 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3896 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3897 | else { | |
3898 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3899 | return CMD_WARNING_CONFIG_FAILED; | |
3900 | } | |
3901 | ||
3902 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3903 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3904 | flag); | |
3905 | } | |
3906 | ||
3907 | ALIAS_HIDDEN( | |
3908 | no_neighbor_capability_orf_prefix, | |
3909 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
3910 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3911 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3912 | "Advertise capability to the peer\n" | |
3913 | "Advertise ORF capability to the peer\n" | |
3914 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3915 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3916 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3917 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 3918 | |
718e3744 | 3919 | /* neighbor next-hop-self. */ |
3920 | DEFUN (neighbor_nexthop_self, | |
3921 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3922 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3923 | NEIGHBOR_STR |
3924 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3925 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3926 | { |
d62a17ae | 3927 | int idx_peer = 1; |
3928 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3929 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 3930 | } |
9e7a53c1 | 3931 | |
d62a17ae | 3932 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
3933 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3934 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3935 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 3936 | |
a538debe DS |
3937 | /* neighbor next-hop-self. */ |
3938 | DEFUN (neighbor_nexthop_self_force, | |
3939 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 3940 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3941 | NEIGHBOR_STR |
3942 | NEIGHBOR_ADDR_STR2 | |
3943 | "Disable the next hop calculation for this neighbor\n" | |
3944 | "Set the next hop to self for reflected routes\n") | |
3945 | { | |
d62a17ae | 3946 | int idx_peer = 1; |
3947 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3948 | bgp_node_safi(vty), | |
3949 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 3950 | } |
3951 | ||
d62a17ae | 3952 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
3953 | neighbor_nexthop_self_force_hidden_cmd, | |
3954 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3955 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3956 | "Disable the next hop calculation for this neighbor\n" | |
3957 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 3958 | |
1bc4e531 DA |
3959 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
3960 | neighbor_nexthop_self_all_hidden_cmd, | |
3961 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
3962 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3963 | "Disable the next hop calculation for this neighbor\n" | |
3964 | "Set the next hop to self for reflected routes\n") | |
3965 | ||
718e3744 | 3966 | DEFUN (no_neighbor_nexthop_self, |
3967 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3968 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3969 | NO_STR |
3970 | NEIGHBOR_STR | |
3971 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3972 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3973 | { |
d62a17ae | 3974 | int idx_peer = 2; |
3975 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3976 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3977 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 3978 | } |
6b0655a2 | 3979 | |
d62a17ae | 3980 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
3981 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3982 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3983 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 3984 | |
88b8ed8d | 3985 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 3986 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 3987 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3988 | NO_STR |
3989 | NEIGHBOR_STR | |
3990 | NEIGHBOR_ADDR_STR2 | |
3991 | "Disable the next hop calculation for this neighbor\n" | |
3992 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 3993 | { |
d62a17ae | 3994 | int idx_peer = 2; |
3995 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3996 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3997 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 3998 | } |
a538debe | 3999 | |
d62a17ae | 4000 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
4001 | no_neighbor_nexthop_self_force_hidden_cmd, | |
4002 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
4003 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4004 | "Disable the next hop calculation for this neighbor\n" | |
4005 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 4006 | |
1bc4e531 DA |
4007 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
4008 | no_neighbor_nexthop_self_all_hidden_cmd, | |
4009 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
4010 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4011 | "Disable the next hop calculation for this neighbor\n" | |
4012 | "Set the next hop to self for reflected routes\n") | |
4013 | ||
c7122e14 DS |
4014 | /* neighbor as-override */ |
4015 | DEFUN (neighbor_as_override, | |
4016 | neighbor_as_override_cmd, | |
9ccf14f7 | 4017 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
4018 | NEIGHBOR_STR |
4019 | NEIGHBOR_ADDR_STR2 | |
4020 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
4021 | { | |
d62a17ae | 4022 | int idx_peer = 1; |
4023 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4024 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
4025 | } |
4026 | ||
d62a17ae | 4027 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
4028 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
4029 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4030 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 4031 | |
c7122e14 DS |
4032 | DEFUN (no_neighbor_as_override, |
4033 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 4034 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
4035 | NO_STR |
4036 | NEIGHBOR_STR | |
4037 | NEIGHBOR_ADDR_STR2 | |
4038 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
4039 | { | |
d62a17ae | 4040 | int idx_peer = 2; |
4041 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4042 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4043 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
4044 | } |
4045 | ||
d62a17ae | 4046 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
4047 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
4048 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4049 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 4050 | |
718e3744 | 4051 | /* neighbor remove-private-AS. */ |
4052 | DEFUN (neighbor_remove_private_as, | |
4053 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4054 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4055 | NEIGHBOR_STR |
4056 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4057 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4058 | { |
d62a17ae | 4059 | int idx_peer = 1; |
4060 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4061 | bgp_node_safi(vty), | |
4062 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4063 | } |
4064 | ||
d62a17ae | 4065 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
4066 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4067 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4068 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4069 | |
5000f21c DS |
4070 | DEFUN (neighbor_remove_private_as_all, |
4071 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 4072 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4073 | NEIGHBOR_STR |
4074 | NEIGHBOR_ADDR_STR2 | |
4075 | "Remove private ASNs in outbound updates\n" | |
efd7904e | 4076 | "Apply to all AS numbers\n") |
5000f21c | 4077 | { |
d62a17ae | 4078 | int idx_peer = 1; |
4079 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4080 | bgp_node_safi(vty), | |
4081 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
4082 | } |
4083 | ||
d62a17ae | 4084 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
4085 | neighbor_remove_private_as_all_hidden_cmd, | |
4086 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4087 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4088 | "Remove private ASNs in outbound updates\n" | |
4089 | "Apply to all AS numbers") | |
596c17ba | 4090 | |
5000f21c DS |
4091 | DEFUN (neighbor_remove_private_as_replace_as, |
4092 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 4093 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4094 | NEIGHBOR_STR |
4095 | NEIGHBOR_ADDR_STR2 | |
4096 | "Remove private ASNs in outbound updates\n" | |
4097 | "Replace private ASNs with our ASN in outbound updates\n") | |
4098 | { | |
d62a17ae | 4099 | int idx_peer = 1; |
4100 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4101 | bgp_node_safi(vty), | |
4102 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
4103 | } |
4104 | ||
d62a17ae | 4105 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
4106 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
4107 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4108 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4109 | "Remove private ASNs in outbound updates\n" | |
4110 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4111 | |
5000f21c DS |
4112 | DEFUN (neighbor_remove_private_as_all_replace_as, |
4113 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 4114 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4115 | NEIGHBOR_STR |
4116 | NEIGHBOR_ADDR_STR2 | |
4117 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4118 | "Apply to all AS numbers\n" |
5000f21c DS |
4119 | "Replace private ASNs with our ASN in outbound updates\n") |
4120 | { | |
d62a17ae | 4121 | int idx_peer = 1; |
4122 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4123 | bgp_node_safi(vty), | |
4124 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
4125 | } |
4126 | ||
d62a17ae | 4127 | ALIAS_HIDDEN( |
4128 | neighbor_remove_private_as_all_replace_as, | |
4129 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4130 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4131 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4132 | "Remove private ASNs in outbound updates\n" | |
4133 | "Apply to all AS numbers\n" | |
4134 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4135 | |
718e3744 | 4136 | DEFUN (no_neighbor_remove_private_as, |
4137 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4138 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4139 | NO_STR |
4140 | NEIGHBOR_STR | |
4141 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4142 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4143 | { |
d62a17ae | 4144 | int idx_peer = 2; |
4145 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4146 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4147 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4148 | } |
6b0655a2 | 4149 | |
d62a17ae | 4150 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
4151 | no_neighbor_remove_private_as_hidden_cmd, | |
4152 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4153 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4154 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4155 | |
88b8ed8d | 4156 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 4157 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 4158 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4159 | NO_STR |
4160 | NEIGHBOR_STR | |
4161 | NEIGHBOR_ADDR_STR2 | |
4162 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4163 | "Apply to all AS numbers\n") |
88b8ed8d | 4164 | { |
d62a17ae | 4165 | int idx_peer = 2; |
4166 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4167 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4168 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 4169 | } |
5000f21c | 4170 | |
d62a17ae | 4171 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
4172 | no_neighbor_remove_private_as_all_hidden_cmd, | |
4173 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4174 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4175 | "Remove private ASNs in outbound updates\n" | |
4176 | "Apply to all AS numbers\n") | |
596c17ba | 4177 | |
88b8ed8d | 4178 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 4179 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 4180 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4181 | NO_STR |
4182 | NEIGHBOR_STR | |
4183 | NEIGHBOR_ADDR_STR2 | |
4184 | "Remove private ASNs in outbound updates\n" | |
4185 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 4186 | { |
d62a17ae | 4187 | int idx_peer = 2; |
4188 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4189 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4190 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 4191 | } |
5000f21c | 4192 | |
d62a17ae | 4193 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
4194 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
4195 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4196 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4197 | "Remove private ASNs in outbound updates\n" | |
4198 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4199 | |
88b8ed8d | 4200 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 4201 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 4202 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4203 | NO_STR |
4204 | NEIGHBOR_STR | |
4205 | NEIGHBOR_ADDR_STR2 | |
4206 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4207 | "Apply to all AS numbers\n" |
5000f21c | 4208 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 4209 | { |
d62a17ae | 4210 | int idx_peer = 2; |
4211 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4212 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4213 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 4214 | } |
5000f21c | 4215 | |
d62a17ae | 4216 | ALIAS_HIDDEN( |
4217 | no_neighbor_remove_private_as_all_replace_as, | |
4218 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4219 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4220 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4221 | "Remove private ASNs in outbound updates\n" | |
4222 | "Apply to all AS numbers\n" | |
4223 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4224 | |
5000f21c | 4225 | |
718e3744 | 4226 | /* neighbor send-community. */ |
4227 | DEFUN (neighbor_send_community, | |
4228 | neighbor_send_community_cmd, | |
9ccf14f7 | 4229 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4230 | NEIGHBOR_STR |
4231 | NEIGHBOR_ADDR_STR2 | |
4232 | "Send Community attribute to this neighbor\n") | |
4233 | { | |
d62a17ae | 4234 | int idx_peer = 1; |
27c05d4d | 4235 | |
d62a17ae | 4236 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4237 | bgp_node_safi(vty), | |
4238 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4239 | } |
4240 | ||
d62a17ae | 4241 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
4242 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4243 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4244 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4245 | |
718e3744 | 4246 | DEFUN (no_neighbor_send_community, |
4247 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 4248 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4249 | NO_STR |
4250 | NEIGHBOR_STR | |
4251 | NEIGHBOR_ADDR_STR2 | |
4252 | "Send Community attribute to this neighbor\n") | |
4253 | { | |
d62a17ae | 4254 | int idx_peer = 2; |
27c05d4d | 4255 | |
d62a17ae | 4256 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
4257 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4258 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4259 | } |
6b0655a2 | 4260 | |
d62a17ae | 4261 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
4262 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4263 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4264 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4265 | |
718e3744 | 4266 | /* neighbor send-community extended. */ |
4267 | DEFUN (neighbor_send_community_type, | |
4268 | neighbor_send_community_type_cmd, | |
57d187bc | 4269 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4270 | NEIGHBOR_STR |
4271 | NEIGHBOR_ADDR_STR2 | |
4272 | "Send Community attribute to this neighbor\n" | |
4273 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4274 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4275 | "Send Extended Community attributes\n" |
57d187bc JS |
4276 | "Send Standard Community attributes\n" |
4277 | "Send Large Community attributes\n") | |
718e3744 | 4278 | { |
27c05d4d | 4279 | int idx_peer = 1; |
d7c0a89a | 4280 | uint32_t flag = 0; |
27c05d4d | 4281 | const char *type = argv[argc - 1]->text; |
d62a17ae | 4282 | |
27c05d4d | 4283 | if (strmatch(type, "standard")) { |
d62a17ae | 4284 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
27c05d4d | 4285 | } else if (strmatch(type, "extended")) { |
d62a17ae | 4286 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); |
27c05d4d | 4287 | } else if (strmatch(type, "large")) { |
d62a17ae | 4288 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); |
27c05d4d | 4289 | } else if (strmatch(type, "both")) { |
d62a17ae | 4290 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4291 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
27c05d4d | 4292 | } else { /* if (strmatch(type, "all")) */ |
d62a17ae | 4293 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4294 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4295 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4296 | } | |
4297 | ||
27c05d4d | 4298 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
d62a17ae | 4299 | bgp_node_safi(vty), flag); |
4300 | } | |
4301 | ||
4302 | ALIAS_HIDDEN( | |
4303 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
4304 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4305 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4306 | "Send Community attribute to this neighbor\n" | |
4307 | "Send Standard and Extended Community attributes\n" | |
4308 | "Send Standard, Large and Extended Community attributes\n" | |
4309 | "Send Extended Community attributes\n" | |
4310 | "Send Standard Community attributes\n" | |
4311 | "Send Large Community attributes\n") | |
596c17ba | 4312 | |
718e3744 | 4313 | DEFUN (no_neighbor_send_community_type, |
4314 | no_neighbor_send_community_type_cmd, | |
57d187bc | 4315 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4316 | NO_STR |
4317 | NEIGHBOR_STR | |
4318 | NEIGHBOR_ADDR_STR2 | |
4319 | "Send Community attribute to this neighbor\n" | |
4320 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4321 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4322 | "Send Extended Community attributes\n" |
57d187bc JS |
4323 | "Send Standard Community attributes\n" |
4324 | "Send Large Community attributes\n") | |
718e3744 | 4325 | { |
d62a17ae | 4326 | int idx_peer = 2; |
27c05d4d | 4327 | uint32_t flag = 0; |
d62a17ae | 4328 | const char *type = argv[argc - 1]->text; |
4329 | ||
27c05d4d PM |
4330 | if (strmatch(type, "standard")) { |
4331 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4332 | } else if (strmatch(type, "extended")) { | |
4333 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4334 | } else if (strmatch(type, "large")) { | |
4335 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4336 | } else if (strmatch(type, "both")) { | |
4337 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4338 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4339 | } else { /* if (strmatch(type, "all")) */ | |
4340 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4341 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4342 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4343 | } | |
4344 | ||
4345 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4346 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4347 | flag); | |
d62a17ae | 4348 | } |
4349 | ||
4350 | ALIAS_HIDDEN( | |
4351 | no_neighbor_send_community_type, | |
4352 | no_neighbor_send_community_type_hidden_cmd, | |
4353 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4354 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4355 | "Send Community attribute to this neighbor\n" | |
4356 | "Send Standard and Extended Community attributes\n" | |
4357 | "Send Standard, Large and Extended Community attributes\n" | |
4358 | "Send Extended Community attributes\n" | |
4359 | "Send Standard Community attributes\n" | |
4360 | "Send Large Community attributes\n") | |
596c17ba | 4361 | |
718e3744 | 4362 | /* neighbor soft-reconfig. */ |
4363 | DEFUN (neighbor_soft_reconfiguration, | |
4364 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4365 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4366 | NEIGHBOR_STR |
4367 | NEIGHBOR_ADDR_STR2 | |
4368 | "Per neighbor soft reconfiguration\n" | |
4369 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4370 | { | |
d62a17ae | 4371 | int idx_peer = 1; |
4372 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4373 | bgp_node_safi(vty), | |
4374 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4375 | } |
4376 | ||
d62a17ae | 4377 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
4378 | neighbor_soft_reconfiguration_hidden_cmd, | |
4379 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4380 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4381 | "Per neighbor soft reconfiguration\n" | |
4382 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4383 | |
718e3744 | 4384 | DEFUN (no_neighbor_soft_reconfiguration, |
4385 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4386 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4387 | NO_STR |
4388 | NEIGHBOR_STR | |
4389 | NEIGHBOR_ADDR_STR2 | |
4390 | "Per neighbor soft reconfiguration\n" | |
4391 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4392 | { | |
d62a17ae | 4393 | int idx_peer = 2; |
4394 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4395 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4396 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4397 | } |
6b0655a2 | 4398 | |
d62a17ae | 4399 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
4400 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
4401 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4402 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4403 | "Per neighbor soft reconfiguration\n" | |
4404 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4405 | |
718e3744 | 4406 | DEFUN (neighbor_route_reflector_client, |
4407 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4408 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4409 | NEIGHBOR_STR |
4410 | NEIGHBOR_ADDR_STR2 | |
4411 | "Configure a neighbor as Route Reflector client\n") | |
4412 | { | |
d62a17ae | 4413 | int idx_peer = 1; |
4414 | struct peer *peer; | |
718e3744 | 4415 | |
4416 | ||
d62a17ae | 4417 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4418 | if (!peer) | |
4419 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4420 | |
d62a17ae | 4421 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4422 | bgp_node_safi(vty), | |
4423 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4424 | } |
4425 | ||
d62a17ae | 4426 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
4427 | neighbor_route_reflector_client_hidden_cmd, | |
4428 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4429 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4430 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4431 | |
718e3744 | 4432 | DEFUN (no_neighbor_route_reflector_client, |
4433 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4434 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4435 | NO_STR |
4436 | NEIGHBOR_STR | |
4437 | NEIGHBOR_ADDR_STR2 | |
4438 | "Configure a neighbor as Route Reflector client\n") | |
4439 | { | |
d62a17ae | 4440 | int idx_peer = 2; |
4441 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4442 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4443 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4444 | } |
6b0655a2 | 4445 | |
d62a17ae | 4446 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
4447 | no_neighbor_route_reflector_client_hidden_cmd, | |
4448 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4449 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4450 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4451 | |
718e3744 | 4452 | /* neighbor route-server-client. */ |
4453 | DEFUN (neighbor_route_server_client, | |
4454 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 4455 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4456 | NEIGHBOR_STR |
4457 | NEIGHBOR_ADDR_STR2 | |
4458 | "Configure a neighbor as Route Server client\n") | |
4459 | { | |
d62a17ae | 4460 | int idx_peer = 1; |
4461 | struct peer *peer; | |
2a3d5731 | 4462 | |
d62a17ae | 4463 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4464 | if (!peer) | |
4465 | return CMD_WARNING_CONFIG_FAILED; | |
4466 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4467 | bgp_node_safi(vty), | |
4468 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 4469 | } |
4470 | ||
d62a17ae | 4471 | ALIAS_HIDDEN(neighbor_route_server_client, |
4472 | neighbor_route_server_client_hidden_cmd, | |
4473 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4474 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4475 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4476 | |
718e3744 | 4477 | DEFUN (no_neighbor_route_server_client, |
4478 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 4479 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4480 | NO_STR |
4481 | NEIGHBOR_STR | |
4482 | NEIGHBOR_ADDR_STR2 | |
4483 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 4484 | { |
d62a17ae | 4485 | int idx_peer = 2; |
4486 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4487 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4488 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 4489 | } |
6b0655a2 | 4490 | |
d62a17ae | 4491 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
4492 | no_neighbor_route_server_client_hidden_cmd, | |
4493 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4494 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4495 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4496 | |
fee0f4c6 | 4497 | DEFUN (neighbor_nexthop_local_unchanged, |
4498 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4499 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4500 | NEIGHBOR_STR |
4501 | NEIGHBOR_ADDR_STR2 | |
4502 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
4503 | "Leave link-local nexthop unchanged for this peer\n") | |
4504 | { | |
d62a17ae | 4505 | int idx_peer = 1; |
4506 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4507 | bgp_node_safi(vty), | |
4508 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 4509 | } |
6b0655a2 | 4510 | |
fee0f4c6 | 4511 | DEFUN (no_neighbor_nexthop_local_unchanged, |
4512 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4513 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4514 | NO_STR |
4515 | NEIGHBOR_STR | |
4516 | NEIGHBOR_ADDR_STR2 | |
4517 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
4518 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 4519 | { |
d62a17ae | 4520 | int idx_peer = 2; |
4521 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4522 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4523 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 4524 | } |
6b0655a2 | 4525 | |
718e3744 | 4526 | DEFUN (neighbor_attr_unchanged, |
4527 | neighbor_attr_unchanged_cmd, | |
a8206004 | 4528 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
718e3744 | 4529 | NEIGHBOR_STR |
4530 | NEIGHBOR_ADDR_STR2 | |
4531 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4532 | "As-path attribute\n" | |
4533 | "Nexthop attribute\n" | |
a8206004 | 4534 | "Med attribute\n") |
718e3744 | 4535 | { |
d62a17ae | 4536 | int idx = 0; |
8eeb0335 DW |
4537 | char *peer_str = argv[1]->arg; |
4538 | struct peer *peer; | |
d7c0a89a | 4539 | uint16_t flags = 0; |
8eeb0335 DW |
4540 | afi_t afi = bgp_node_afi(vty); |
4541 | safi_t safi = bgp_node_safi(vty); | |
4542 | ||
4543 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
4544 | if (!peer) | |
4545 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4546 | |
4547 | if (argv_find(argv, argc, "as-path", &idx)) | |
4548 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4549 | idx = 0; | |
4550 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4551 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4552 | idx = 0; | |
4553 | if (argv_find(argv, argc, "med", &idx)) | |
4554 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4555 | ||
8eeb0335 DW |
4556 | /* no flags means all of them! */ |
4557 | if (!flags) { | |
d62a17ae | 4558 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); |
4559 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4560 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 | 4561 | } else { |
a4d82a8a PZ |
4562 | if (!CHECK_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED) |
4563 | && peer_af_flag_check(peer, afi, safi, | |
4564 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
8eeb0335 DW |
4565 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4566 | PEER_FLAG_AS_PATH_UNCHANGED); | |
4567 | } | |
4568 | ||
a4d82a8a PZ |
4569 | if (!CHECK_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED) |
4570 | && peer_af_flag_check(peer, afi, safi, | |
4571 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
8eeb0335 DW |
4572 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4573 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
4574 | } | |
4575 | ||
a4d82a8a PZ |
4576 | if (!CHECK_FLAG(flags, PEER_FLAG_MED_UNCHANGED) |
4577 | && peer_af_flag_check(peer, afi, safi, | |
4578 | PEER_FLAG_MED_UNCHANGED)) { | |
8eeb0335 DW |
4579 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4580 | PEER_FLAG_MED_UNCHANGED); | |
4581 | } | |
d62a17ae | 4582 | } |
4583 | ||
8eeb0335 | 4584 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, flags); |
d62a17ae | 4585 | } |
4586 | ||
4587 | ALIAS_HIDDEN( | |
4588 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
4589 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4590 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4591 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4592 | "As-path attribute\n" | |
4593 | "Nexthop attribute\n" | |
4594 | "Med attribute\n") | |
596c17ba | 4595 | |
718e3744 | 4596 | DEFUN (no_neighbor_attr_unchanged, |
4597 | no_neighbor_attr_unchanged_cmd, | |
a8206004 | 4598 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
e52702f2 | 4599 | NO_STR |
718e3744 | 4600 | NEIGHBOR_STR |
4601 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
4602 | "BGP attribute is propagated unchanged to this neighbor\n" |
4603 | "As-path attribute\n" | |
40e718b5 | 4604 | "Nexthop attribute\n" |
a8206004 | 4605 | "Med attribute\n") |
718e3744 | 4606 | { |
d62a17ae | 4607 | int idx = 0; |
4608 | char *peer = argv[2]->arg; | |
d7c0a89a | 4609 | uint16_t flags = 0; |
d62a17ae | 4610 | |
4611 | if (argv_find(argv, argc, "as-path", &idx)) | |
4612 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4613 | idx = 0; | |
4614 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4615 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4616 | idx = 0; | |
4617 | if (argv_find(argv, argc, "med", &idx)) | |
4618 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4619 | ||
4620 | if (!flags) // no flags means all of them! | |
4621 | { | |
4622 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4623 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4624 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4625 | } | |
4626 | ||
4627 | return peer_af_flag_unset_vty(vty, peer, bgp_node_afi(vty), | |
4628 | bgp_node_safi(vty), flags); | |
4629 | } | |
4630 | ||
4631 | ALIAS_HIDDEN( | |
4632 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
4633 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4634 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4635 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4636 | "As-path attribute\n" | |
4637 | "Nexthop attribute\n" | |
4638 | "Med attribute\n") | |
718e3744 | 4639 | |
718e3744 | 4640 | /* EBGP multihop configuration. */ |
d62a17ae | 4641 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, |
4642 | const char *ttl_str) | |
718e3744 | 4643 | { |
d62a17ae | 4644 | struct peer *peer; |
4645 | unsigned int ttl; | |
718e3744 | 4646 | |
d62a17ae | 4647 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4648 | if (!peer) | |
4649 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4650 | |
d62a17ae | 4651 | if (peer->conf_if) |
4652 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
63fa10b5 | 4653 | |
d62a17ae | 4654 | if (!ttl_str) |
4655 | ttl = MAXTTL; | |
4656 | else | |
4657 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 4658 | |
d62a17ae | 4659 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 4660 | } |
4661 | ||
d62a17ae | 4662 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 4663 | { |
d62a17ae | 4664 | struct peer *peer; |
718e3744 | 4665 | |
d62a17ae | 4666 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4667 | if (!peer) | |
4668 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4669 | |
d62a17ae | 4670 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 4671 | } |
4672 | ||
4673 | /* neighbor ebgp-multihop. */ | |
4674 | DEFUN (neighbor_ebgp_multihop, | |
4675 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 4676 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 4677 | NEIGHBOR_STR |
4678 | NEIGHBOR_ADDR_STR2 | |
4679 | "Allow EBGP neighbors not on directly connected networks\n") | |
4680 | { | |
d62a17ae | 4681 | int idx_peer = 1; |
4682 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4683 | } |
4684 | ||
4685 | DEFUN (neighbor_ebgp_multihop_ttl, | |
4686 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 4687 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 4688 | NEIGHBOR_STR |
4689 | NEIGHBOR_ADDR_STR2 | |
4690 | "Allow EBGP neighbors not on directly connected networks\n" | |
4691 | "maximum hop count\n") | |
4692 | { | |
d62a17ae | 4693 | int idx_peer = 1; |
4694 | int idx_number = 3; | |
4695 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
4696 | argv[idx_number]->arg); | |
718e3744 | 4697 | } |
4698 | ||
4699 | DEFUN (no_neighbor_ebgp_multihop, | |
4700 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 4701 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 4702 | NO_STR |
4703 | NEIGHBOR_STR | |
4704 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4705 | "Allow EBGP neighbors not on directly connected networks\n" |
4706 | "maximum hop count\n") | |
718e3744 | 4707 | { |
d62a17ae | 4708 | int idx_peer = 2; |
4709 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 4710 | } |
4711 | ||
6b0655a2 | 4712 | |
6ffd2079 | 4713 | /* disable-connected-check */ |
4714 | DEFUN (neighbor_disable_connected_check, | |
4715 | neighbor_disable_connected_check_cmd, | |
7ebe625c | 4716 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4717 | NEIGHBOR_STR |
7ebe625c | 4718 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
4719 | "one-hop away EBGP peer using loopback address\n" |
4720 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4721 | { |
d62a17ae | 4722 | int idx_peer = 1; |
4723 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4724 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4725 | } |
4726 | ||
4727 | DEFUN (no_neighbor_disable_connected_check, | |
4728 | no_neighbor_disable_connected_check_cmd, | |
7ebe625c | 4729 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4730 | NO_STR |
4731 | NEIGHBOR_STR | |
7ebe625c | 4732 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
4733 | "one-hop away EBGP peer using loopback address\n" |
4734 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4735 | { |
d62a17ae | 4736 | int idx_peer = 2; |
4737 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4738 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4739 | } |
4740 | ||
47cbc09b PM |
4741 | |
4742 | /* enforce-first-as */ | |
4743 | DEFUN (neighbor_enforce_first_as, | |
4744 | neighbor_enforce_first_as_cmd, | |
4745 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
4746 | NEIGHBOR_STR | |
4747 | NEIGHBOR_ADDR_STR2 | |
4748 | "Enforce the first AS for EBGP routes\n") | |
4749 | { | |
4750 | int idx_peer = 1; | |
4751 | ||
4752 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4753 | PEER_FLAG_ENFORCE_FIRST_AS); | |
4754 | } | |
4755 | ||
4756 | DEFUN (no_neighbor_enforce_first_as, | |
4757 | no_neighbor_enforce_first_as_cmd, | |
4758 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
4759 | NO_STR | |
4760 | NEIGHBOR_STR | |
4761 | NEIGHBOR_ADDR_STR2 | |
4762 | "Enforce the first AS for EBGP routes\n") | |
4763 | { | |
4764 | int idx_peer = 2; | |
4765 | ||
4766 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4767 | PEER_FLAG_ENFORCE_FIRST_AS); | |
4768 | } | |
4769 | ||
4770 | ||
718e3744 | 4771 | DEFUN (neighbor_description, |
4772 | neighbor_description_cmd, | |
e961923c | 4773 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 4774 | NEIGHBOR_STR |
4775 | NEIGHBOR_ADDR_STR2 | |
4776 | "Neighbor specific description\n" | |
4777 | "Up to 80 characters describing this neighbor\n") | |
4778 | { | |
d62a17ae | 4779 | int idx_peer = 1; |
4780 | int idx_line = 3; | |
4781 | struct peer *peer; | |
4782 | char *str; | |
718e3744 | 4783 | |
d62a17ae | 4784 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4785 | if (!peer) | |
4786 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4787 | |
d62a17ae | 4788 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 4789 | |
d62a17ae | 4790 | peer_description_set(peer, str); |
718e3744 | 4791 | |
d62a17ae | 4792 | XFREE(MTYPE_TMP, str); |
718e3744 | 4793 | |
d62a17ae | 4794 | return CMD_SUCCESS; |
718e3744 | 4795 | } |
4796 | ||
4797 | DEFUN (no_neighbor_description, | |
4798 | no_neighbor_description_cmd, | |
a14810f4 | 4799 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", |
718e3744 | 4800 | NO_STR |
4801 | NEIGHBOR_STR | |
4802 | NEIGHBOR_ADDR_STR2 | |
a14810f4 | 4803 | "Neighbor specific description\n") |
718e3744 | 4804 | { |
d62a17ae | 4805 | int idx_peer = 2; |
4806 | struct peer *peer; | |
718e3744 | 4807 | |
d62a17ae | 4808 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4809 | if (!peer) | |
4810 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4811 | |
d62a17ae | 4812 | peer_description_unset(peer); |
718e3744 | 4813 | |
d62a17ae | 4814 | return CMD_SUCCESS; |
718e3744 | 4815 | } |
4816 | ||
a14810f4 PM |
4817 | ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd, |
4818 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
4819 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4820 | "Neighbor specific description\n" | |
4821 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 4822 | |
718e3744 | 4823 | /* Neighbor update-source. */ |
d62a17ae | 4824 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, |
4825 | const char *source_str) | |
4826 | { | |
4827 | struct peer *peer; | |
4828 | struct prefix p; | |
a14810f4 | 4829 | union sockunion su; |
d62a17ae | 4830 | |
4831 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
4832 | if (!peer) | |
4833 | return CMD_WARNING_CONFIG_FAILED; | |
4834 | ||
4835 | if (peer->conf_if) | |
4836 | return CMD_WARNING; | |
4837 | ||
4838 | if (source_str) { | |
a14810f4 | 4839 | if (str2sockunion(source_str, &su) == 0) |
d62a17ae | 4840 | peer_update_source_addr_set(peer, &su); |
4841 | else { | |
4842 | if (str2prefix(source_str, &p)) { | |
4843 | vty_out(vty, | |
4844 | "%% Invalid update-source, remove prefix length \n"); | |
4845 | return CMD_WARNING_CONFIG_FAILED; | |
4846 | } else | |
4847 | peer_update_source_if_set(peer, source_str); | |
4848 | } | |
4849 | } else | |
4850 | peer_update_source_unset(peer); | |
4851 | ||
4852 | return CMD_SUCCESS; | |
4853 | } | |
4854 | ||
4855 | #define BGP_UPDATE_SOURCE_HELP_STR \ | |
4856 | "IPv4 address\n" \ | |
4857 | "IPv6 address\n" \ | |
4858 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 4859 | |
718e3744 | 4860 | DEFUN (neighbor_update_source, |
4861 | neighbor_update_source_cmd, | |
9ccf14f7 | 4862 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 4863 | NEIGHBOR_STR |
4864 | NEIGHBOR_ADDR_STR2 | |
4865 | "Source of routing updates\n" | |
369688c0 | 4866 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 4867 | { |
d62a17ae | 4868 | int idx_peer = 1; |
4869 | int idx_peer_2 = 3; | |
4870 | return peer_update_source_vty(vty, argv[idx_peer]->arg, | |
4871 | argv[idx_peer_2]->arg); | |
718e3744 | 4872 | } |
4873 | ||
4874 | DEFUN (no_neighbor_update_source, | |
4875 | no_neighbor_update_source_cmd, | |
c7178fe7 | 4876 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 4877 | NO_STR |
4878 | NEIGHBOR_STR | |
4879 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
4880 | "Source of routing updates\n" |
4881 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 4882 | { |
d62a17ae | 4883 | int idx_peer = 2; |
4884 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4885 | } |
6b0655a2 | 4886 | |
d62a17ae | 4887 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
4888 | afi_t afi, safi_t safi, | |
4889 | const char *rmap, int set) | |
718e3744 | 4890 | { |
d62a17ae | 4891 | int ret; |
4892 | struct peer *peer; | |
80912664 | 4893 | struct route_map *route_map = NULL; |
718e3744 | 4894 | |
d62a17ae | 4895 | peer = peer_and_group_lookup_vty(vty, peer_str); |
4896 | if (!peer) | |
4897 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4898 | |
1de27621 | 4899 | if (set) { |
80912664 DS |
4900 | if (rmap) |
4901 | route_map = route_map_lookup_warn_noexist(vty, rmap); | |
1de27621 DA |
4902 | ret = peer_default_originate_set(peer, afi, safi, |
4903 | rmap, route_map); | |
4904 | } else | |
d62a17ae | 4905 | ret = peer_default_originate_unset(peer, afi, safi); |
718e3744 | 4906 | |
d62a17ae | 4907 | return bgp_vty_return(vty, ret); |
718e3744 | 4908 | } |
4909 | ||
4910 | /* neighbor default-originate. */ | |
4911 | DEFUN (neighbor_default_originate, | |
4912 | neighbor_default_originate_cmd, | |
9ccf14f7 | 4913 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 4914 | NEIGHBOR_STR |
4915 | NEIGHBOR_ADDR_STR2 | |
4916 | "Originate default route to this neighbor\n") | |
4917 | { | |
d62a17ae | 4918 | int idx_peer = 1; |
4919 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
4920 | bgp_node_afi(vty), | |
4921 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 4922 | } |
4923 | ||
d62a17ae | 4924 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
4925 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
4926 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4927 | "Originate default route to this neighbor\n") | |
596c17ba | 4928 | |
718e3744 | 4929 | DEFUN (neighbor_default_originate_rmap, |
4930 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 4931 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 4932 | NEIGHBOR_STR |
4933 | NEIGHBOR_ADDR_STR2 | |
4934 | "Originate default route to this neighbor\n" | |
4935 | "Route-map to specify criteria to originate default\n" | |
4936 | "route-map name\n") | |
4937 | { | |
d62a17ae | 4938 | int idx_peer = 1; |
4939 | int idx_word = 4; | |
4940 | return peer_default_originate_set_vty( | |
4941 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
4942 | argv[idx_word]->arg, 1); | |
718e3744 | 4943 | } |
4944 | ||
d62a17ae | 4945 | ALIAS_HIDDEN( |
4946 | neighbor_default_originate_rmap, | |
4947 | neighbor_default_originate_rmap_hidden_cmd, | |
4948 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
4949 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4950 | "Originate default route to this neighbor\n" | |
4951 | "Route-map to specify criteria to originate default\n" | |
4952 | "route-map name\n") | |
596c17ba | 4953 | |
718e3744 | 4954 | DEFUN (no_neighbor_default_originate, |
4955 | no_neighbor_default_originate_cmd, | |
a636c635 | 4956 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 4957 | NO_STR |
4958 | NEIGHBOR_STR | |
4959 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4960 | "Originate default route to this neighbor\n" |
4961 | "Route-map to specify criteria to originate default\n" | |
4962 | "route-map name\n") | |
718e3744 | 4963 | { |
d62a17ae | 4964 | int idx_peer = 2; |
4965 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
4966 | bgp_node_afi(vty), | |
4967 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 4968 | } |
4969 | ||
d62a17ae | 4970 | ALIAS_HIDDEN( |
4971 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
4972 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
4973 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4974 | "Originate default route to this neighbor\n" | |
4975 | "Route-map to specify criteria to originate default\n" | |
4976 | "route-map name\n") | |
596c17ba | 4977 | |
6b0655a2 | 4978 | |
718e3744 | 4979 | /* Set neighbor's BGP port. */ |
d62a17ae | 4980 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, |
4981 | const char *port_str) | |
4982 | { | |
4983 | struct peer *peer; | |
d7c0a89a | 4984 | uint16_t port; |
d62a17ae | 4985 | struct servent *sp; |
4986 | ||
4987 | peer = peer_lookup_vty(vty, ip_str); | |
4988 | if (!peer) | |
4989 | return CMD_WARNING_CONFIG_FAILED; | |
4990 | ||
4991 | if (!port_str) { | |
4992 | sp = getservbyname("bgp", "tcp"); | |
4993 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
4994 | } else { | |
4995 | port = strtoul(port_str, NULL, 10); | |
4996 | } | |
718e3744 | 4997 | |
d62a17ae | 4998 | peer_port_set(peer, port); |
718e3744 | 4999 | |
d62a17ae | 5000 | return CMD_SUCCESS; |
718e3744 | 5001 | } |
5002 | ||
f418446b | 5003 | /* Set specified peer's BGP port. */ |
718e3744 | 5004 | DEFUN (neighbor_port, |
5005 | neighbor_port_cmd, | |
9ccf14f7 | 5006 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 5007 | NEIGHBOR_STR |
5008 | NEIGHBOR_ADDR_STR | |
5009 | "Neighbor's BGP port\n" | |
5010 | "TCP port number\n") | |
5011 | { | |
d62a17ae | 5012 | int idx_ip = 1; |
5013 | int idx_number = 3; | |
5014 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
5015 | argv[idx_number]->arg); | |
718e3744 | 5016 | } |
5017 | ||
5018 | DEFUN (no_neighbor_port, | |
5019 | no_neighbor_port_cmd, | |
9ccf14f7 | 5020 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 5021 | NO_STR |
5022 | NEIGHBOR_STR | |
5023 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
5024 | "Neighbor's BGP port\n" |
5025 | "TCP port number\n") | |
718e3744 | 5026 | { |
d62a17ae | 5027 | int idx_ip = 2; |
5028 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 5029 | } |
5030 | ||
6b0655a2 | 5031 | |
718e3744 | 5032 | /* neighbor weight. */ |
d62a17ae | 5033 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5034 | safi_t safi, const char *weight_str) | |
718e3744 | 5035 | { |
d62a17ae | 5036 | int ret; |
5037 | struct peer *peer; | |
5038 | unsigned long weight; | |
718e3744 | 5039 | |
d62a17ae | 5040 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5041 | if (!peer) | |
5042 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5043 | |
d62a17ae | 5044 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 5045 | |
d62a17ae | 5046 | ret = peer_weight_set(peer, afi, safi, weight); |
5047 | return bgp_vty_return(vty, ret); | |
718e3744 | 5048 | } |
5049 | ||
d62a17ae | 5050 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5051 | safi_t safi) | |
718e3744 | 5052 | { |
d62a17ae | 5053 | int ret; |
5054 | struct peer *peer; | |
718e3744 | 5055 | |
d62a17ae | 5056 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5057 | if (!peer) | |
5058 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5059 | |
d62a17ae | 5060 | ret = peer_weight_unset(peer, afi, safi); |
5061 | return bgp_vty_return(vty, ret); | |
718e3744 | 5062 | } |
5063 | ||
5064 | DEFUN (neighbor_weight, | |
5065 | neighbor_weight_cmd, | |
9ccf14f7 | 5066 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 5067 | NEIGHBOR_STR |
5068 | NEIGHBOR_ADDR_STR2 | |
5069 | "Set default weight for routes from this neighbor\n" | |
5070 | "default weight\n") | |
5071 | { | |
d62a17ae | 5072 | int idx_peer = 1; |
5073 | int idx_number = 3; | |
5074 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5075 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 5076 | } |
5077 | ||
d62a17ae | 5078 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
5079 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
5080 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5081 | "Set default weight for routes from this neighbor\n" | |
5082 | "default weight\n") | |
596c17ba | 5083 | |
718e3744 | 5084 | DEFUN (no_neighbor_weight, |
5085 | no_neighbor_weight_cmd, | |
9ccf14f7 | 5086 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 5087 | NO_STR |
5088 | NEIGHBOR_STR | |
5089 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5090 | "Set default weight for routes from this neighbor\n" |
5091 | "default weight\n") | |
718e3744 | 5092 | { |
d62a17ae | 5093 | int idx_peer = 2; |
5094 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, | |
5095 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 5096 | } |
5097 | ||
d62a17ae | 5098 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
5099 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
5100 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5101 | "Set default weight for routes from this neighbor\n" | |
5102 | "default weight\n") | |
596c17ba | 5103 | |
6b0655a2 | 5104 | |
718e3744 | 5105 | /* Override capability negotiation. */ |
5106 | DEFUN (neighbor_override_capability, | |
5107 | neighbor_override_capability_cmd, | |
9ccf14f7 | 5108 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5109 | NEIGHBOR_STR |
5110 | NEIGHBOR_ADDR_STR2 | |
5111 | "Override capability negotiation result\n") | |
5112 | { | |
d62a17ae | 5113 | int idx_peer = 1; |
5114 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5115 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5116 | } |
5117 | ||
5118 | DEFUN (no_neighbor_override_capability, | |
5119 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 5120 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5121 | NO_STR |
5122 | NEIGHBOR_STR | |
5123 | NEIGHBOR_ADDR_STR2 | |
5124 | "Override capability negotiation result\n") | |
5125 | { | |
d62a17ae | 5126 | int idx_peer = 2; |
5127 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5128 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5129 | } |
6b0655a2 | 5130 | |
718e3744 | 5131 | DEFUN (neighbor_strict_capability, |
5132 | neighbor_strict_capability_cmd, | |
9fb964de | 5133 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5134 | NEIGHBOR_STR |
9fb964de | 5135 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5136 | "Strict capability negotiation match\n") |
5137 | { | |
9fb964de PM |
5138 | int idx_peer = 1; |
5139 | ||
5140 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5141 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5142 | } |
5143 | ||
5144 | DEFUN (no_neighbor_strict_capability, | |
5145 | no_neighbor_strict_capability_cmd, | |
9fb964de | 5146 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5147 | NO_STR |
5148 | NEIGHBOR_STR | |
9fb964de | 5149 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5150 | "Strict capability negotiation match\n") |
5151 | { | |
9fb964de PM |
5152 | int idx_peer = 2; |
5153 | ||
5154 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5155 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5156 | } |
6b0655a2 | 5157 | |
d62a17ae | 5158 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
5159 | const char *keep_str, const char *hold_str) | |
718e3744 | 5160 | { |
d62a17ae | 5161 | int ret; |
5162 | struct peer *peer; | |
d7c0a89a QY |
5163 | uint32_t keepalive; |
5164 | uint32_t holdtime; | |
718e3744 | 5165 | |
d62a17ae | 5166 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5167 | if (!peer) | |
5168 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5169 | |
d62a17ae | 5170 | keepalive = strtoul(keep_str, NULL, 10); |
5171 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 5172 | |
d62a17ae | 5173 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 5174 | |
d62a17ae | 5175 | return bgp_vty_return(vty, ret); |
718e3744 | 5176 | } |
6b0655a2 | 5177 | |
d62a17ae | 5178 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5179 | { |
d62a17ae | 5180 | int ret; |
5181 | struct peer *peer; | |
718e3744 | 5182 | |
d62a17ae | 5183 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5184 | if (!peer) | |
5185 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5186 | |
d62a17ae | 5187 | ret = peer_timers_unset(peer); |
718e3744 | 5188 | |
d62a17ae | 5189 | return bgp_vty_return(vty, ret); |
718e3744 | 5190 | } |
5191 | ||
5192 | DEFUN (neighbor_timers, | |
5193 | neighbor_timers_cmd, | |
9ccf14f7 | 5194 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 5195 | NEIGHBOR_STR |
5196 | NEIGHBOR_ADDR_STR2 | |
5197 | "BGP per neighbor timers\n" | |
5198 | "Keepalive interval\n" | |
5199 | "Holdtime\n") | |
5200 | { | |
d62a17ae | 5201 | int idx_peer = 1; |
5202 | int idx_number = 3; | |
5203 | int idx_number_2 = 4; | |
5204 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
5205 | argv[idx_number]->arg, | |
5206 | argv[idx_number_2]->arg); | |
718e3744 | 5207 | } |
5208 | ||
5209 | DEFUN (no_neighbor_timers, | |
5210 | no_neighbor_timers_cmd, | |
9ccf14f7 | 5211 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 5212 | NO_STR |
5213 | NEIGHBOR_STR | |
5214 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5215 | "BGP per neighbor timers\n" |
5216 | "Keepalive interval\n" | |
5217 | "Holdtime\n") | |
718e3744 | 5218 | { |
d62a17ae | 5219 | int idx_peer = 2; |
5220 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5221 | } |
6b0655a2 | 5222 | |
813d4307 | 5223 | |
d62a17ae | 5224 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, |
5225 | const char *time_str) | |
718e3744 | 5226 | { |
d62a17ae | 5227 | int ret; |
5228 | struct peer *peer; | |
d7c0a89a | 5229 | uint32_t connect; |
718e3744 | 5230 | |
d62a17ae | 5231 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5232 | if (!peer) | |
5233 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5234 | |
d62a17ae | 5235 | connect = strtoul(time_str, NULL, 10); |
718e3744 | 5236 | |
d62a17ae | 5237 | ret = peer_timers_connect_set(peer, connect); |
718e3744 | 5238 | |
d62a17ae | 5239 | return bgp_vty_return(vty, ret); |
718e3744 | 5240 | } |
5241 | ||
d62a17ae | 5242 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5243 | { |
d62a17ae | 5244 | int ret; |
5245 | struct peer *peer; | |
718e3744 | 5246 | |
d62a17ae | 5247 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5248 | if (!peer) | |
5249 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5250 | |
d62a17ae | 5251 | ret = peer_timers_connect_unset(peer); |
718e3744 | 5252 | |
d62a17ae | 5253 | return bgp_vty_return(vty, ret); |
718e3744 | 5254 | } |
5255 | ||
5256 | DEFUN (neighbor_timers_connect, | |
5257 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 5258 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 5259 | NEIGHBOR_STR |
966f821c | 5260 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5261 | "BGP per neighbor timers\n" |
5262 | "BGP connect timer\n" | |
5263 | "Connect timer\n") | |
5264 | { | |
d62a17ae | 5265 | int idx_peer = 1; |
5266 | int idx_number = 4; | |
5267 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
5268 | argv[idx_number]->arg); | |
718e3744 | 5269 | } |
5270 | ||
5271 | DEFUN (no_neighbor_timers_connect, | |
5272 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 5273 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 5274 | NO_STR |
5275 | NEIGHBOR_STR | |
966f821c | 5276 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5277 | "BGP per neighbor timers\n" |
8334fd5a DW |
5278 | "BGP connect timer\n" |
5279 | "Connect timer\n") | |
718e3744 | 5280 | { |
d62a17ae | 5281 | int idx_peer = 2; |
5282 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5283 | } |
5284 | ||
6b0655a2 | 5285 | |
d62a17ae | 5286 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
5287 | const char *time_str, int set) | |
718e3744 | 5288 | { |
d62a17ae | 5289 | int ret; |
5290 | struct peer *peer; | |
d7c0a89a | 5291 | uint32_t routeadv = 0; |
718e3744 | 5292 | |
d62a17ae | 5293 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5294 | if (!peer) | |
5295 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5296 | |
d62a17ae | 5297 | if (time_str) |
5298 | routeadv = strtoul(time_str, NULL, 10); | |
718e3744 | 5299 | |
d62a17ae | 5300 | if (set) |
5301 | ret = peer_advertise_interval_set(peer, routeadv); | |
5302 | else | |
5303 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 5304 | |
d62a17ae | 5305 | return bgp_vty_return(vty, ret); |
718e3744 | 5306 | } |
5307 | ||
5308 | DEFUN (neighbor_advertise_interval, | |
5309 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5310 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 5311 | NEIGHBOR_STR |
966f821c | 5312 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5313 | "Minimum interval between sending BGP routing updates\n" |
5314 | "time in seconds\n") | |
5315 | { | |
d62a17ae | 5316 | int idx_peer = 1; |
5317 | int idx_number = 3; | |
5318 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
5319 | argv[idx_number]->arg, 1); | |
718e3744 | 5320 | } |
5321 | ||
5322 | DEFUN (no_neighbor_advertise_interval, | |
5323 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5324 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 5325 | NO_STR |
5326 | NEIGHBOR_STR | |
966f821c | 5327 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
5328 | "Minimum interval between sending BGP routing updates\n" |
5329 | "time in seconds\n") | |
718e3744 | 5330 | { |
d62a17ae | 5331 | int idx_peer = 2; |
5332 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 5333 | } |
5334 | ||
6b0655a2 | 5335 | |
518f0eb1 DS |
5336 | /* Time to wait before processing route-map updates */ |
5337 | DEFUN (bgp_set_route_map_delay_timer, | |
5338 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 5339 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
5340 | SET_STR |
5341 | "BGP route-map delay timer\n" | |
5342 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 5343 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 5344 | { |
d62a17ae | 5345 | int idx_number = 3; |
d7c0a89a | 5346 | uint32_t rmap_delay_timer; |
d62a17ae | 5347 | |
5348 | if (argv[idx_number]->arg) { | |
5349 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
5350 | bm->rmap_update_timer = rmap_delay_timer; | |
5351 | ||
5352 | /* if the dynamic update handling is being disabled, and a timer | |
5353 | * is | |
5354 | * running, stop the timer and act as if the timer has already | |
5355 | * fired. | |
5356 | */ | |
5357 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
5358 | BGP_TIMER_OFF(bm->t_rmap_update); | |
5359 | thread_execute(bm->master, bgp_route_map_update_timer, | |
5360 | NULL, 0); | |
5361 | } | |
5362 | return CMD_SUCCESS; | |
5363 | } else { | |
5364 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
5365 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 5366 | } |
518f0eb1 DS |
5367 | } |
5368 | ||
5369 | DEFUN (no_bgp_set_route_map_delay_timer, | |
5370 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 5371 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 5372 | NO_STR |
3a2d747c | 5373 | BGP_STR |
518f0eb1 | 5374 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
5375 | "Reset to default time to wait for processing route-map changes\n" |
5376 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 5377 | { |
518f0eb1 | 5378 | |
d62a17ae | 5379 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 5380 | |
d62a17ae | 5381 | return CMD_SUCCESS; |
518f0eb1 DS |
5382 | } |
5383 | ||
f414725f | 5384 | |
718e3744 | 5385 | /* neighbor interface */ |
d62a17ae | 5386 | static int peer_interface_vty(struct vty *vty, const char *ip_str, |
5387 | const char *str) | |
718e3744 | 5388 | { |
d62a17ae | 5389 | struct peer *peer; |
718e3744 | 5390 | |
d62a17ae | 5391 | peer = peer_lookup_vty(vty, ip_str); |
5392 | if (!peer || peer->conf_if) { | |
5393 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
5394 | return CMD_WARNING_CONFIG_FAILED; | |
5395 | } | |
718e3744 | 5396 | |
d62a17ae | 5397 | if (str) |
5398 | peer_interface_set(peer, str); | |
5399 | else | |
5400 | peer_interface_unset(peer); | |
718e3744 | 5401 | |
d62a17ae | 5402 | return CMD_SUCCESS; |
718e3744 | 5403 | } |
5404 | ||
5405 | DEFUN (neighbor_interface, | |
5406 | neighbor_interface_cmd, | |
9ccf14f7 | 5407 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 5408 | NEIGHBOR_STR |
5409 | NEIGHBOR_ADDR_STR | |
5410 | "Interface\n" | |
5411 | "Interface name\n") | |
5412 | { | |
d62a17ae | 5413 | int idx_ip = 1; |
5414 | int idx_word = 3; | |
5415 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); | |
718e3744 | 5416 | } |
5417 | ||
5418 | DEFUN (no_neighbor_interface, | |
5419 | no_neighbor_interface_cmd, | |
9ccf14f7 | 5420 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 5421 | NO_STR |
5422 | NEIGHBOR_STR | |
16cedbb0 | 5423 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5424 | "Interface\n" |
5425 | "Interface name\n") | |
5426 | { | |
d62a17ae | 5427 | int idx_peer = 2; |
5428 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5429 | } |
6b0655a2 | 5430 | |
718e3744 | 5431 | DEFUN (neighbor_distribute_list, |
5432 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 5433 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5434 | NEIGHBOR_STR |
5435 | NEIGHBOR_ADDR_STR2 | |
5436 | "Filter updates to/from this neighbor\n" | |
5437 | "IP access-list number\n" | |
5438 | "IP access-list number (expanded range)\n" | |
5439 | "IP Access-list name\n" | |
5440 | "Filter incoming updates\n" | |
5441 | "Filter outgoing updates\n") | |
5442 | { | |
d62a17ae | 5443 | int idx_peer = 1; |
5444 | int idx_acl = 3; | |
5445 | int direct, ret; | |
5446 | struct peer *peer; | |
a8206004 | 5447 | |
d62a17ae | 5448 | const char *pstr = argv[idx_peer]->arg; |
5449 | const char *acl = argv[idx_acl]->arg; | |
5450 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5451 | |
d62a17ae | 5452 | peer = peer_and_group_lookup_vty(vty, pstr); |
5453 | if (!peer) | |
5454 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5455 | |
d62a17ae | 5456 | /* Check filter direction. */ |
5457 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5458 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5459 | direct, acl); | |
a8206004 | 5460 | |
d62a17ae | 5461 | return bgp_vty_return(vty, ret); |
718e3744 | 5462 | } |
5463 | ||
d62a17ae | 5464 | ALIAS_HIDDEN( |
5465 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
5466 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5467 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5468 | "Filter updates to/from this neighbor\n" | |
5469 | "IP access-list number\n" | |
5470 | "IP access-list number (expanded range)\n" | |
5471 | "IP Access-list name\n" | |
5472 | "Filter incoming updates\n" | |
5473 | "Filter outgoing updates\n") | |
596c17ba | 5474 | |
718e3744 | 5475 | DEFUN (no_neighbor_distribute_list, |
5476 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 5477 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5478 | NO_STR |
5479 | NEIGHBOR_STR | |
5480 | NEIGHBOR_ADDR_STR2 | |
5481 | "Filter updates to/from this neighbor\n" | |
5482 | "IP access-list number\n" | |
5483 | "IP access-list number (expanded range)\n" | |
5484 | "IP Access-list name\n" | |
5485 | "Filter incoming updates\n" | |
5486 | "Filter outgoing updates\n") | |
5487 | { | |
d62a17ae | 5488 | int idx_peer = 2; |
5489 | int direct, ret; | |
5490 | struct peer *peer; | |
a8206004 | 5491 | |
d62a17ae | 5492 | const char *pstr = argv[idx_peer]->arg; |
5493 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5494 | |
d62a17ae | 5495 | peer = peer_and_group_lookup_vty(vty, pstr); |
5496 | if (!peer) | |
5497 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5498 | |
d62a17ae | 5499 | /* Check filter direction. */ |
5500 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5501 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5502 | direct); | |
a8206004 | 5503 | |
d62a17ae | 5504 | return bgp_vty_return(vty, ret); |
718e3744 | 5505 | } |
6b0655a2 | 5506 | |
d62a17ae | 5507 | ALIAS_HIDDEN( |
5508 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
5509 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5510 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5511 | "Filter updates to/from this neighbor\n" | |
5512 | "IP access-list number\n" | |
5513 | "IP access-list number (expanded range)\n" | |
5514 | "IP Access-list name\n" | |
5515 | "Filter incoming updates\n" | |
5516 | "Filter outgoing updates\n") | |
596c17ba | 5517 | |
718e3744 | 5518 | /* Set prefix list to the peer. */ |
d62a17ae | 5519 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
5520 | afi_t afi, safi_t safi, | |
5521 | const char *name_str, | |
5522 | const char *direct_str) | |
718e3744 | 5523 | { |
d62a17ae | 5524 | int ret; |
d62a17ae | 5525 | int direct = FILTER_IN; |
cf9ac8bf | 5526 | struct peer *peer; |
718e3744 | 5527 | |
d62a17ae | 5528 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5529 | if (!peer) | |
5530 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5531 | |
d62a17ae | 5532 | /* Check filter direction. */ |
5533 | if (strncmp(direct_str, "i", 1) == 0) | |
5534 | direct = FILTER_IN; | |
5535 | else if (strncmp(direct_str, "o", 1) == 0) | |
5536 | direct = FILTER_OUT; | |
718e3744 | 5537 | |
d62a17ae | 5538 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 5539 | |
d62a17ae | 5540 | return bgp_vty_return(vty, ret); |
718e3744 | 5541 | } |
5542 | ||
d62a17ae | 5543 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, |
5544 | afi_t afi, safi_t safi, | |
5545 | const char *direct_str) | |
718e3744 | 5546 | { |
d62a17ae | 5547 | int ret; |
5548 | struct peer *peer; | |
5549 | int direct = FILTER_IN; | |
718e3744 | 5550 | |
d62a17ae | 5551 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5552 | if (!peer) | |
5553 | return CMD_WARNING_CONFIG_FAILED; | |
e52702f2 | 5554 | |
d62a17ae | 5555 | /* Check filter direction. */ |
5556 | if (strncmp(direct_str, "i", 1) == 0) | |
5557 | direct = FILTER_IN; | |
5558 | else if (strncmp(direct_str, "o", 1) == 0) | |
5559 | direct = FILTER_OUT; | |
718e3744 | 5560 | |
d62a17ae | 5561 | ret = peer_prefix_list_unset(peer, afi, safi, direct); |
718e3744 | 5562 | |
d62a17ae | 5563 | return bgp_vty_return(vty, ret); |
718e3744 | 5564 | } |
5565 | ||
5566 | DEFUN (neighbor_prefix_list, | |
5567 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 5568 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5569 | NEIGHBOR_STR |
5570 | NEIGHBOR_ADDR_STR2 | |
5571 | "Filter updates to/from this neighbor\n" | |
5572 | "Name of a prefix list\n" | |
5573 | "Filter incoming updates\n" | |
5574 | "Filter outgoing updates\n") | |
5575 | { | |
d62a17ae | 5576 | int idx_peer = 1; |
5577 | int idx_word = 3; | |
5578 | int idx_in_out = 4; | |
5579 | return peer_prefix_list_set_vty( | |
5580 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5581 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5582 | } |
5583 | ||
d62a17ae | 5584 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
5585 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5586 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5587 | "Filter updates to/from this neighbor\n" | |
5588 | "Name of a prefix list\n" | |
5589 | "Filter incoming updates\n" | |
5590 | "Filter outgoing updates\n") | |
596c17ba | 5591 | |
718e3744 | 5592 | DEFUN (no_neighbor_prefix_list, |
5593 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 5594 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5595 | NO_STR |
5596 | NEIGHBOR_STR | |
5597 | NEIGHBOR_ADDR_STR2 | |
5598 | "Filter updates to/from this neighbor\n" | |
5599 | "Name of a prefix list\n" | |
5600 | "Filter incoming updates\n" | |
5601 | "Filter outgoing updates\n") | |
5602 | { | |
d62a17ae | 5603 | int idx_peer = 2; |
5604 | int idx_in_out = 5; | |
5605 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
5606 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5607 | argv[idx_in_out]->arg); | |
718e3744 | 5608 | } |
6b0655a2 | 5609 | |
d62a17ae | 5610 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, |
5611 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5612 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5613 | "Filter updates to/from this neighbor\n" | |
5614 | "Name of a prefix list\n" | |
5615 | "Filter incoming updates\n" | |
5616 | "Filter outgoing updates\n") | |
596c17ba | 5617 | |
d62a17ae | 5618 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5619 | safi_t safi, const char *name_str, | |
5620 | const char *direct_str) | |
718e3744 | 5621 | { |
d62a17ae | 5622 | int ret; |
5623 | struct peer *peer; | |
5624 | int direct = FILTER_IN; | |
718e3744 | 5625 | |
d62a17ae | 5626 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5627 | if (!peer) | |
5628 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5629 | |
d62a17ae | 5630 | /* Check filter direction. */ |
5631 | if (strncmp(direct_str, "i", 1) == 0) | |
5632 | direct = FILTER_IN; | |
5633 | else if (strncmp(direct_str, "o", 1) == 0) | |
5634 | direct = FILTER_OUT; | |
718e3744 | 5635 | |
d62a17ae | 5636 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 5637 | |
d62a17ae | 5638 | return bgp_vty_return(vty, ret); |
718e3744 | 5639 | } |
5640 | ||
d62a17ae | 5641 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5642 | safi_t safi, const char *direct_str) | |
718e3744 | 5643 | { |
d62a17ae | 5644 | int ret; |
5645 | struct peer *peer; | |
5646 | int direct = FILTER_IN; | |
718e3744 | 5647 | |
d62a17ae | 5648 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5649 | if (!peer) | |
5650 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5651 | |
d62a17ae | 5652 | /* Check filter direction. */ |
5653 | if (strncmp(direct_str, "i", 1) == 0) | |
5654 | direct = FILTER_IN; | |
5655 | else if (strncmp(direct_str, "o", 1) == 0) | |
5656 | direct = FILTER_OUT; | |
718e3744 | 5657 | |
d62a17ae | 5658 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 5659 | |
d62a17ae | 5660 | return bgp_vty_return(vty, ret); |
718e3744 | 5661 | } |
5662 | ||
5663 | DEFUN (neighbor_filter_list, | |
5664 | neighbor_filter_list_cmd, | |
9ccf14f7 | 5665 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5666 | NEIGHBOR_STR |
5667 | NEIGHBOR_ADDR_STR2 | |
5668 | "Establish BGP filters\n" | |
5669 | "AS path access-list name\n" | |
5670 | "Filter incoming routes\n" | |
5671 | "Filter outgoing routes\n") | |
5672 | { | |
d62a17ae | 5673 | int idx_peer = 1; |
5674 | int idx_word = 3; | |
5675 | int idx_in_out = 4; | |
5676 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5677 | bgp_node_safi(vty), argv[idx_word]->arg, | |
5678 | argv[idx_in_out]->arg); | |
718e3744 | 5679 | } |
5680 | ||
d62a17ae | 5681 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
5682 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5683 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5684 | "Establish BGP filters\n" | |
5685 | "AS path access-list name\n" | |
5686 | "Filter incoming routes\n" | |
5687 | "Filter outgoing routes\n") | |
596c17ba | 5688 | |
718e3744 | 5689 | DEFUN (no_neighbor_filter_list, |
5690 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 5691 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5692 | NO_STR |
5693 | NEIGHBOR_STR | |
5694 | NEIGHBOR_ADDR_STR2 | |
5695 | "Establish BGP filters\n" | |
5696 | "AS path access-list name\n" | |
5697 | "Filter incoming routes\n" | |
5698 | "Filter outgoing routes\n") | |
5699 | { | |
d62a17ae | 5700 | int idx_peer = 2; |
5701 | int idx_in_out = 5; | |
5702 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
5703 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5704 | argv[idx_in_out]->arg); | |
718e3744 | 5705 | } |
6b0655a2 | 5706 | |
d62a17ae | 5707 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
5708 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5709 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5710 | "Establish BGP filters\n" | |
5711 | "AS path access-list name\n" | |
5712 | "Filter incoming routes\n" | |
5713 | "Filter outgoing routes\n") | |
596c17ba | 5714 | |
718e3744 | 5715 | /* Set route-map to the peer. */ |
d62a17ae | 5716 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
5717 | afi_t afi, safi_t safi, const char *name_str, | |
5718 | const char *direct_str) | |
718e3744 | 5719 | { |
d62a17ae | 5720 | int ret; |
5721 | struct peer *peer; | |
5722 | int direct = RMAP_IN; | |
1de27621 | 5723 | struct route_map *route_map; |
718e3744 | 5724 | |
d62a17ae | 5725 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5726 | if (!peer) | |
5727 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5728 | |
d62a17ae | 5729 | /* Check filter direction. */ |
5730 | if (strncmp(direct_str, "in", 2) == 0) | |
5731 | direct = RMAP_IN; | |
5732 | else if (strncmp(direct_str, "o", 1) == 0) | |
5733 | direct = RMAP_OUT; | |
718e3744 | 5734 | |
1de27621 DA |
5735 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
5736 | ret = peer_route_map_set(peer, afi, safi, direct, name_str, route_map); | |
718e3744 | 5737 | |
d62a17ae | 5738 | return bgp_vty_return(vty, ret); |
718e3744 | 5739 | } |
5740 | ||
d62a17ae | 5741 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, |
5742 | afi_t afi, safi_t safi, | |
5743 | const char *direct_str) | |
718e3744 | 5744 | { |
d62a17ae | 5745 | int ret; |
5746 | struct peer *peer; | |
5747 | int direct = RMAP_IN; | |
718e3744 | 5748 | |
d62a17ae | 5749 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5750 | if (!peer) | |
5751 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5752 | |
d62a17ae | 5753 | /* Check filter direction. */ |
5754 | if (strncmp(direct_str, "in", 2) == 0) | |
5755 | direct = RMAP_IN; | |
5756 | else if (strncmp(direct_str, "o", 1) == 0) | |
5757 | direct = RMAP_OUT; | |
718e3744 | 5758 | |
d62a17ae | 5759 | ret = peer_route_map_unset(peer, afi, safi, direct); |
718e3744 | 5760 | |
d62a17ae | 5761 | return bgp_vty_return(vty, ret); |
718e3744 | 5762 | } |
5763 | ||
5764 | DEFUN (neighbor_route_map, | |
5765 | neighbor_route_map_cmd, | |
9ccf14f7 | 5766 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5767 | NEIGHBOR_STR |
5768 | NEIGHBOR_ADDR_STR2 | |
5769 | "Apply route map to neighbor\n" | |
5770 | "Name of route map\n" | |
5771 | "Apply map to incoming routes\n" | |
2a3d5731 | 5772 | "Apply map to outbound routes\n") |
718e3744 | 5773 | { |
d62a17ae | 5774 | int idx_peer = 1; |
5775 | int idx_word = 3; | |
5776 | int idx_in_out = 4; | |
5777 | return peer_route_map_set_vty( | |
5778 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5779 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5780 | } |
5781 | ||
d62a17ae | 5782 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
5783 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5784 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5785 | "Apply route map to neighbor\n" | |
5786 | "Name of route map\n" | |
5787 | "Apply map to incoming routes\n" | |
5788 | "Apply map to outbound routes\n") | |
596c17ba | 5789 | |
718e3744 | 5790 | DEFUN (no_neighbor_route_map, |
5791 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 5792 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5793 | NO_STR |
5794 | NEIGHBOR_STR | |
5795 | NEIGHBOR_ADDR_STR2 | |
5796 | "Apply route map to neighbor\n" | |
5797 | "Name of route map\n" | |
5798 | "Apply map to incoming routes\n" | |
2a3d5731 | 5799 | "Apply map to outbound routes\n") |
718e3744 | 5800 | { |
d62a17ae | 5801 | int idx_peer = 2; |
5802 | int idx_in_out = 5; | |
5803 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
5804 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5805 | argv[idx_in_out]->arg); | |
718e3744 | 5806 | } |
6b0655a2 | 5807 | |
d62a17ae | 5808 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, |
5809 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5810 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5811 | "Apply route map to neighbor\n" | |
5812 | "Name of route map\n" | |
5813 | "Apply map to incoming routes\n" | |
5814 | "Apply map to outbound routes\n") | |
596c17ba | 5815 | |
718e3744 | 5816 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 5817 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
5818 | afi_t afi, safi_t safi, | |
5819 | const char *name_str) | |
718e3744 | 5820 | { |
d62a17ae | 5821 | int ret; |
5822 | struct peer *peer; | |
1de27621 | 5823 | struct route_map *route_map; |
718e3744 | 5824 | |
d62a17ae | 5825 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5826 | if (!peer) | |
5827 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5828 | |
1de27621 DA |
5829 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
5830 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str, route_map); | |
718e3744 | 5831 | |
d62a17ae | 5832 | return bgp_vty_return(vty, ret); |
718e3744 | 5833 | } |
5834 | ||
5835 | /* Unset route-map from the peer. */ | |
d62a17ae | 5836 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
5837 | afi_t afi, safi_t safi) | |
718e3744 | 5838 | { |
d62a17ae | 5839 | int ret; |
5840 | struct peer *peer; | |
718e3744 | 5841 | |
d62a17ae | 5842 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5843 | if (!peer) | |
5844 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5845 | |
d62a17ae | 5846 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 5847 | |
d62a17ae | 5848 | return bgp_vty_return(vty, ret); |
718e3744 | 5849 | } |
5850 | ||
5851 | DEFUN (neighbor_unsuppress_map, | |
5852 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5853 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5854 | NEIGHBOR_STR |
5855 | NEIGHBOR_ADDR_STR2 | |
5856 | "Route-map to selectively unsuppress suppressed routes\n" | |
5857 | "Name of route map\n") | |
5858 | { | |
d62a17ae | 5859 | int idx_peer = 1; |
5860 | int idx_word = 3; | |
5861 | return peer_unsuppress_map_set_vty( | |
5862 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5863 | argv[idx_word]->arg); | |
718e3744 | 5864 | } |
5865 | ||
d62a17ae | 5866 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
5867 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5868 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5869 | "Route-map to selectively unsuppress suppressed routes\n" | |
5870 | "Name of route map\n") | |
596c17ba | 5871 | |
718e3744 | 5872 | DEFUN (no_neighbor_unsuppress_map, |
5873 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5874 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5875 | NO_STR |
5876 | NEIGHBOR_STR | |
5877 | NEIGHBOR_ADDR_STR2 | |
5878 | "Route-map to selectively unsuppress suppressed routes\n" | |
5879 | "Name of route map\n") | |
5880 | { | |
d62a17ae | 5881 | int idx_peer = 2; |
5882 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
5883 | bgp_node_afi(vty), | |
5884 | bgp_node_safi(vty)); | |
718e3744 | 5885 | } |
6b0655a2 | 5886 | |
d62a17ae | 5887 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
5888 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5889 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5890 | "Route-map to selectively unsuppress suppressed routes\n" | |
5891 | "Name of route map\n") | |
596c17ba | 5892 | |
d62a17ae | 5893 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
5894 | afi_t afi, safi_t safi, | |
5895 | const char *num_str, | |
5896 | const char *threshold_str, int warning, | |
5897 | const char *restart_str) | |
718e3744 | 5898 | { |
d62a17ae | 5899 | int ret; |
5900 | struct peer *peer; | |
d7c0a89a QY |
5901 | uint32_t max; |
5902 | uint8_t threshold; | |
5903 | uint16_t restart; | |
718e3744 | 5904 | |
d62a17ae | 5905 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5906 | if (!peer) | |
5907 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5908 | |
d62a17ae | 5909 | max = strtoul(num_str, NULL, 10); |
5910 | if (threshold_str) | |
5911 | threshold = atoi(threshold_str); | |
5912 | else | |
5913 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 5914 | |
d62a17ae | 5915 | if (restart_str) |
5916 | restart = atoi(restart_str); | |
5917 | else | |
5918 | restart = 0; | |
0a486e5f | 5919 | |
d62a17ae | 5920 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, |
5921 | restart); | |
718e3744 | 5922 | |
d62a17ae | 5923 | return bgp_vty_return(vty, ret); |
718e3744 | 5924 | } |
5925 | ||
d62a17ae | 5926 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, |
5927 | afi_t afi, safi_t safi) | |
718e3744 | 5928 | { |
d62a17ae | 5929 | int ret; |
5930 | struct peer *peer; | |
718e3744 | 5931 | |
d62a17ae | 5932 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5933 | if (!peer) | |
5934 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5935 | |
d62a17ae | 5936 | ret = peer_maximum_prefix_unset(peer, afi, safi); |
718e3744 | 5937 | |
d62a17ae | 5938 | return bgp_vty_return(vty, ret); |
718e3744 | 5939 | } |
5940 | ||
5941 | /* Maximum number of prefix configuration. prefix count is different | |
5942 | for each peer configuration. So this configuration can be set for | |
5943 | each peer configuration. */ | |
5944 | DEFUN (neighbor_maximum_prefix, | |
5945 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 5946 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 5947 | NEIGHBOR_STR |
5948 | NEIGHBOR_ADDR_STR2 | |
5949 | "Maximum number of prefix accept from this peer\n" | |
5950 | "maximum no. of prefix limit\n") | |
5951 | { | |
d62a17ae | 5952 | int idx_peer = 1; |
5953 | int idx_number = 3; | |
5954 | return peer_maximum_prefix_set_vty( | |
5955 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5956 | argv[idx_number]->arg, NULL, 0, NULL); | |
718e3744 | 5957 | } |
5958 | ||
d62a17ae | 5959 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
5960 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", | |
5961 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5962 | "Maximum number of prefix accept from this peer\n" | |
5963 | "maximum no. of prefix limit\n") | |
596c17ba | 5964 | |
e0701b79 | 5965 | DEFUN (neighbor_maximum_prefix_threshold, |
5966 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 5967 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 5968 | NEIGHBOR_STR |
5969 | NEIGHBOR_ADDR_STR2 | |
5970 | "Maximum number of prefix accept from this peer\n" | |
5971 | "maximum no. of prefix limit\n" | |
5972 | "Threshold value (%) at which to generate a warning msg\n") | |
5973 | { | |
d62a17ae | 5974 | int idx_peer = 1; |
5975 | int idx_number = 3; | |
5976 | int idx_number_2 = 4; | |
5977 | return peer_maximum_prefix_set_vty( | |
5978 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5979 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL); | |
0a486e5f | 5980 | } |
e0701b79 | 5981 | |
d62a17ae | 5982 | ALIAS_HIDDEN( |
5983 | neighbor_maximum_prefix_threshold, | |
5984 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
5985 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", | |
5986 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5987 | "Maximum number of prefix accept from this peer\n" | |
5988 | "maximum no. of prefix limit\n" | |
5989 | "Threshold value (%) at which to generate a warning msg\n") | |
596c17ba | 5990 | |
718e3744 | 5991 | DEFUN (neighbor_maximum_prefix_warning, |
5992 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 5993 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 5994 | NEIGHBOR_STR |
5995 | NEIGHBOR_ADDR_STR2 | |
5996 | "Maximum number of prefix accept from this peer\n" | |
5997 | "maximum no. of prefix limit\n" | |
5998 | "Only give warning message when limit is exceeded\n") | |
5999 | { | |
d62a17ae | 6000 | int idx_peer = 1; |
6001 | int idx_number = 3; | |
6002 | return peer_maximum_prefix_set_vty( | |
6003 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6004 | argv[idx_number]->arg, NULL, 1, NULL); | |
718e3744 | 6005 | } |
6006 | ||
d62a17ae | 6007 | ALIAS_HIDDEN( |
6008 | neighbor_maximum_prefix_warning, | |
6009 | neighbor_maximum_prefix_warning_hidden_cmd, | |
6010 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", | |
6011 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6012 | "Maximum number of prefix accept from this peer\n" | |
6013 | "maximum no. of prefix limit\n" | |
6014 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6015 | |
e0701b79 | 6016 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
6017 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 6018 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 6019 | NEIGHBOR_STR |
6020 | NEIGHBOR_ADDR_STR2 | |
6021 | "Maximum number of prefix accept from this peer\n" | |
6022 | "maximum no. of prefix limit\n" | |
6023 | "Threshold value (%) at which to generate a warning msg\n" | |
6024 | "Only give warning message when limit is exceeded\n") | |
6025 | { | |
d62a17ae | 6026 | int idx_peer = 1; |
6027 | int idx_number = 3; | |
6028 | int idx_number_2 = 4; | |
6029 | return peer_maximum_prefix_set_vty( | |
6030 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6031 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 6032 | } |
6033 | ||
d62a17ae | 6034 | ALIAS_HIDDEN( |
6035 | neighbor_maximum_prefix_threshold_warning, | |
6036 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
6037 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", | |
6038 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6039 | "Maximum number of prefix accept from this peer\n" | |
6040 | "maximum no. of prefix limit\n" | |
6041 | "Threshold value (%) at which to generate a warning msg\n" | |
6042 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6043 | |
0a486e5f | 6044 | DEFUN (neighbor_maximum_prefix_restart, |
6045 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 6046 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 6047 | NEIGHBOR_STR |
6048 | NEIGHBOR_ADDR_STR2 | |
6049 | "Maximum number of prefix accept from this peer\n" | |
6050 | "maximum no. of prefix limit\n" | |
6051 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 6052 | "Restart interval in minutes\n") |
0a486e5f | 6053 | { |
d62a17ae | 6054 | int idx_peer = 1; |
6055 | int idx_number = 3; | |
6056 | int idx_number_2 = 5; | |
6057 | return peer_maximum_prefix_set_vty( | |
6058 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6059 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 6060 | } |
6061 | ||
d62a17ae | 6062 | ALIAS_HIDDEN( |
6063 | neighbor_maximum_prefix_restart, | |
6064 | neighbor_maximum_prefix_restart_hidden_cmd, | |
6065 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", | |
6066 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6067 | "Maximum number of prefix accept from this peer\n" | |
6068 | "maximum no. of prefix limit\n" | |
6069 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 6070 | "Restart interval in minutes\n") |
596c17ba | 6071 | |
0a486e5f | 6072 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
6073 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 6074 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 6075 | NEIGHBOR_STR |
6076 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6077 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 6078 | "maximum no. of prefix limit\n" |
6079 | "Threshold value (%) at which to generate a warning msg\n" | |
6080 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6081 | "Restart interval in minutes\n") |
0a486e5f | 6082 | { |
d62a17ae | 6083 | int idx_peer = 1; |
6084 | int idx_number = 3; | |
6085 | int idx_number_2 = 4; | |
6086 | int idx_number_3 = 6; | |
6087 | return peer_maximum_prefix_set_vty( | |
6088 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6089 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
6090 | argv[idx_number_3]->arg); | |
6091 | } | |
6092 | ||
6093 | ALIAS_HIDDEN( | |
6094 | neighbor_maximum_prefix_threshold_restart, | |
6095 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
6096 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", | |
6097 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6098 | "Maximum number of prefixes to accept from this peer\n" | |
6099 | "maximum no. of prefix limit\n" | |
6100 | "Threshold value (%) at which to generate a warning msg\n" | |
6101 | "Restart bgp connection after limit is exceeded\n" | |
6102 | "Restart interval in minutes\n") | |
596c17ba | 6103 | |
718e3744 | 6104 | DEFUN (no_neighbor_maximum_prefix, |
6105 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 6106 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 6107 | NO_STR |
6108 | NEIGHBOR_STR | |
6109 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6110 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
6111 | "maximum no. of prefix limit\n" |
6112 | "Threshold value (%) at which to generate a warning msg\n" | |
6113 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6114 | "Restart interval in minutes\n" |
31500417 | 6115 | "Only give warning message when limit is exceeded\n") |
718e3744 | 6116 | { |
d62a17ae | 6117 | int idx_peer = 2; |
6118 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, | |
6119 | bgp_node_afi(vty), | |
6120 | bgp_node_safi(vty)); | |
718e3744 | 6121 | } |
e52702f2 | 6122 | |
d62a17ae | 6123 | ALIAS_HIDDEN( |
6124 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
6125 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", | |
6126 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6127 | "Maximum number of prefixes to accept from this peer\n" | |
6128 | "maximum no. of prefix limit\n" | |
6129 | "Threshold value (%) at which to generate a warning msg\n" | |
6130 | "Restart bgp connection after limit is exceeded\n" | |
6131 | "Restart interval in minutes\n" | |
6132 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6133 | |
718e3744 | 6134 | |
718e3744 | 6135 | /* "neighbor allowas-in" */ |
6136 | DEFUN (neighbor_allowas_in, | |
6137 | neighbor_allowas_in_cmd, | |
fd8503f5 | 6138 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6139 | NEIGHBOR_STR |
6140 | NEIGHBOR_ADDR_STR2 | |
31500417 | 6141 | "Accept as-path with my AS present in it\n" |
f79f7a7b | 6142 | "Number of occurrences of AS number\n" |
fd8503f5 | 6143 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 6144 | { |
d62a17ae | 6145 | int idx_peer = 1; |
6146 | int idx_number_origin = 3; | |
6147 | int ret; | |
6148 | int origin = 0; | |
6149 | struct peer *peer; | |
6150 | int allow_num = 0; | |
6151 | ||
6152 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6153 | if (!peer) | |
6154 | return CMD_WARNING_CONFIG_FAILED; | |
6155 | ||
6156 | if (argc <= idx_number_origin) | |
6157 | allow_num = 3; | |
6158 | else { | |
6159 | if (argv[idx_number_origin]->type == WORD_TKN) | |
6160 | origin = 1; | |
6161 | else | |
6162 | allow_num = atoi(argv[idx_number_origin]->arg); | |
6163 | } | |
6164 | ||
6165 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6166 | allow_num, origin); | |
6167 | ||
6168 | return bgp_vty_return(vty, ret); | |
6169 | } | |
6170 | ||
6171 | ALIAS_HIDDEN( | |
6172 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
6173 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6174 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6175 | "Accept as-path with my AS present in it\n" | |
f79f7a7b | 6176 | "Number of occurrences of AS number\n" |
d62a17ae | 6177 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 6178 | |
718e3744 | 6179 | DEFUN (no_neighbor_allowas_in, |
6180 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 6181 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6182 | NO_STR |
6183 | NEIGHBOR_STR | |
6184 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 6185 | "allow local ASN appears in aspath attribute\n" |
f79f7a7b | 6186 | "Number of occurrences of AS number\n" |
fd8503f5 | 6187 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 6188 | { |
d62a17ae | 6189 | int idx_peer = 2; |
6190 | int ret; | |
6191 | struct peer *peer; | |
718e3744 | 6192 | |
d62a17ae | 6193 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6194 | if (!peer) | |
6195 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6196 | |
d62a17ae | 6197 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
6198 | bgp_node_safi(vty)); | |
718e3744 | 6199 | |
d62a17ae | 6200 | return bgp_vty_return(vty, ret); |
718e3744 | 6201 | } |
6b0655a2 | 6202 | |
d62a17ae | 6203 | ALIAS_HIDDEN( |
6204 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
6205 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6206 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6207 | "allow local ASN appears in aspath attribute\n" | |
f79f7a7b | 6208 | "Number of occurrences of AS number\n" |
d62a17ae | 6209 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 6210 | |
fa411a21 NH |
6211 | DEFUN (neighbor_ttl_security, |
6212 | neighbor_ttl_security_cmd, | |
7ebe625c | 6213 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 | 6214 | NEIGHBOR_STR |
7ebe625c | 6215 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6216 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
6217 | "Specify the maximum number of hops to the BGP peer\n" |
6218 | "Number of hops to BGP peer\n") | |
fa411a21 | 6219 | { |
d62a17ae | 6220 | int idx_peer = 1; |
6221 | int idx_number = 4; | |
6222 | struct peer *peer; | |
6223 | int gtsm_hops; | |
6224 | ||
6225 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6226 | if (!peer) | |
6227 | return CMD_WARNING_CONFIG_FAILED; | |
6228 | ||
6229 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); | |
6230 | ||
7ebe625c QY |
6231 | /* |
6232 | * If 'neighbor swpX', then this is for directly connected peers, | |
6233 | * we should not accept a ttl-security hops value greater than 1. | |
6234 | */ | |
6235 | if (peer->conf_if && (gtsm_hops > 1)) { | |
6236 | vty_out(vty, | |
6237 | "%s is directly connected peer, hops cannot exceed 1\n", | |
6238 | argv[idx_peer]->arg); | |
6239 | return CMD_WARNING_CONFIG_FAILED; | |
6240 | } | |
6241 | ||
d62a17ae | 6242 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
6243 | } |
6244 | ||
6245 | DEFUN (no_neighbor_ttl_security, | |
6246 | no_neighbor_ttl_security_cmd, | |
7ebe625c | 6247 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
6248 | NO_STR |
6249 | NEIGHBOR_STR | |
7ebe625c | 6250 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6251 | "BGP ttl-security parameters\n" |
3a2d747c QY |
6252 | "Specify the maximum number of hops to the BGP peer\n" |
6253 | "Number of hops to BGP peer\n") | |
fa411a21 | 6254 | { |
d62a17ae | 6255 | int idx_peer = 2; |
6256 | struct peer *peer; | |
fa411a21 | 6257 | |
d62a17ae | 6258 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6259 | if (!peer) | |
6260 | return CMD_WARNING_CONFIG_FAILED; | |
fa411a21 | 6261 | |
d62a17ae | 6262 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 6263 | } |
6b0655a2 | 6264 | |
adbac85e DW |
6265 | DEFUN (neighbor_addpath_tx_all_paths, |
6266 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6267 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6268 | NEIGHBOR_STR |
6269 | NEIGHBOR_ADDR_STR2 | |
6270 | "Use addpath to advertise all paths to a neighbor\n") | |
6271 | { | |
d62a17ae | 6272 | int idx_peer = 1; |
6273 | struct peer *peer; | |
adbac85e | 6274 | |
d62a17ae | 6275 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6276 | if (!peer) | |
6277 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 6278 | |
dcc68b5e MS |
6279 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
6280 | BGP_ADDPATH_ALL); | |
6281 | return CMD_SUCCESS; | |
adbac85e DW |
6282 | } |
6283 | ||
d62a17ae | 6284 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
6285 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
6286 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6287 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6288 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6289 | |
adbac85e DW |
6290 | DEFUN (no_neighbor_addpath_tx_all_paths, |
6291 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6292 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6293 | NO_STR |
6294 | NEIGHBOR_STR | |
6295 | NEIGHBOR_ADDR_STR2 | |
6296 | "Use addpath to advertise all paths to a neighbor\n") | |
6297 | { | |
d62a17ae | 6298 | int idx_peer = 2; |
dcc68b5e MS |
6299 | struct peer *peer; |
6300 | ||
6301 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6302 | if (!peer) | |
6303 | return CMD_WARNING_CONFIG_FAILED; | |
6304 | ||
6305 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
6306 | != BGP_ADDPATH_ALL) { | |
6307 | vty_out(vty, | |
6308 | "%% Peer not currently configured to transmit all paths."); | |
6309 | return CMD_WARNING_CONFIG_FAILED; | |
6310 | } | |
6311 | ||
6312 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6313 | BGP_ADDPATH_NONE); | |
6314 | ||
6315 | return CMD_SUCCESS; | |
adbac85e DW |
6316 | } |
6317 | ||
d62a17ae | 6318 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
6319 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
6320 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6321 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6322 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6323 | |
06370dac DW |
6324 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
6325 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6326 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6327 | NEIGHBOR_STR |
6328 | NEIGHBOR_ADDR_STR2 | |
6329 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6330 | { | |
d62a17ae | 6331 | int idx_peer = 1; |
6332 | struct peer *peer; | |
06370dac | 6333 | |
d62a17ae | 6334 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6335 | if (!peer) | |
6336 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 6337 | |
dcc68b5e MS |
6338 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
6339 | BGP_ADDPATH_BEST_PER_AS); | |
6340 | ||
6341 | return CMD_SUCCESS; | |
06370dac DW |
6342 | } |
6343 | ||
d62a17ae | 6344 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
6345 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6346 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6347 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6348 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 6349 | |
06370dac DW |
6350 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
6351 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6352 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6353 | NO_STR |
6354 | NEIGHBOR_STR | |
6355 | NEIGHBOR_ADDR_STR2 | |
6356 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6357 | { | |
d62a17ae | 6358 | int idx_peer = 2; |
dcc68b5e MS |
6359 | struct peer *peer; |
6360 | ||
6361 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6362 | if (!peer) | |
6363 | return CMD_WARNING_CONFIG_FAILED; | |
6364 | ||
6365 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
6366 | != BGP_ADDPATH_BEST_PER_AS) { | |
6367 | vty_out(vty, | |
6368 | "%% Peer not currently configured to transmit all best path per as."); | |
6369 | return CMD_WARNING_CONFIG_FAILED; | |
6370 | } | |
6371 | ||
6372 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6373 | BGP_ADDPATH_NONE); | |
6374 | ||
6375 | return CMD_SUCCESS; | |
06370dac DW |
6376 | } |
6377 | ||
d62a17ae | 6378 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
6379 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6380 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6381 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6382 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 6383 | |
2b31007c RZ |
6384 | DEFPY( |
6385 | neighbor_aspath_loop_detection, neighbor_aspath_loop_detection_cmd, | |
6386 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
6387 | NEIGHBOR_STR | |
6388 | NEIGHBOR_ADDR_STR2 | |
6389 | "Detect AS loops before sending to neighbor\n") | |
6390 | { | |
6391 | struct peer *peer; | |
6392 | ||
6393 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
6394 | if (!peer) | |
6395 | return CMD_WARNING_CONFIG_FAILED; | |
6396 | ||
6397 | peer->as_path_loop_detection = true; | |
6398 | ||
6399 | return CMD_SUCCESS; | |
6400 | } | |
6401 | ||
6402 | DEFPY( | |
6403 | no_neighbor_aspath_loop_detection, | |
6404 | no_neighbor_aspath_loop_detection_cmd, | |
6405 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
6406 | NO_STR | |
6407 | NEIGHBOR_STR | |
6408 | NEIGHBOR_ADDR_STR2 | |
6409 | "Detect AS loops before sending to neighbor\n") | |
6410 | { | |
6411 | struct peer *peer; | |
6412 | ||
6413 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
6414 | if (!peer) | |
6415 | return CMD_WARNING_CONFIG_FAILED; | |
6416 | ||
6417 | peer->as_path_loop_detection = false; | |
6418 | ||
6419 | return CMD_SUCCESS; | |
6420 | } | |
6421 | ||
b9c7bc5a PZ |
6422 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
6423 | struct ecommunity **list) | |
ddb5b488 | 6424 | { |
b9c7bc5a PZ |
6425 | struct ecommunity *ecom = NULL; |
6426 | struct ecommunity *ecomadd; | |
ddb5b488 | 6427 | |
b9c7bc5a | 6428 | for (; argc; --argc, ++argv) { |
ddb5b488 | 6429 | |
b9c7bc5a PZ |
6430 | ecomadd = ecommunity_str2com(argv[0]->arg, |
6431 | ECOMMUNITY_ROUTE_TARGET, 0); | |
6432 | if (!ecomadd) { | |
6433 | vty_out(vty, "Malformed community-list value\n"); | |
6434 | if (ecom) | |
6435 | ecommunity_free(&ecom); | |
6436 | return CMD_WARNING_CONFIG_FAILED; | |
6437 | } | |
ddb5b488 | 6438 | |
b9c7bc5a PZ |
6439 | if (ecom) { |
6440 | ecommunity_merge(ecom, ecomadd); | |
6441 | ecommunity_free(&ecomadd); | |
6442 | } else { | |
6443 | ecom = ecomadd; | |
6444 | } | |
6445 | } | |
6446 | ||
6447 | if (*list) { | |
6448 | ecommunity_free(&*list); | |
ddb5b488 | 6449 | } |
b9c7bc5a PZ |
6450 | *list = ecom; |
6451 | ||
6452 | return CMD_SUCCESS; | |
ddb5b488 PZ |
6453 | } |
6454 | ||
0ca70ba5 DS |
6455 | /* |
6456 | * v2vimport is true if we are handling a `import vrf ...` command | |
6457 | */ | |
6458 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 6459 | { |
0ca70ba5 DS |
6460 | afi_t afi; |
6461 | ||
ddb5b488 | 6462 | switch (vty->node) { |
b9c7bc5a | 6463 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
6464 | afi = AFI_IP; |
6465 | break; | |
b9c7bc5a | 6466 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
6467 | afi = AFI_IP6; |
6468 | break; | |
ddb5b488 PZ |
6469 | default: |
6470 | vty_out(vty, | |
b9c7bc5a | 6471 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 6472 | return AFI_MAX; |
ddb5b488 | 6473 | } |
69b07479 | 6474 | |
0ca70ba5 DS |
6475 | if (!v2vimport) { |
6476 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6477 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
6478 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6479 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
6480 | vty_out(vty, | |
6481 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
6482 | return AFI_MAX; | |
6483 | } | |
6484 | } else { | |
6485 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6486 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
6487 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6488 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
6489 | vty_out(vty, | |
6490 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
6491 | return AFI_MAX; | |
6492 | } | |
6493 | } | |
6494 | return afi; | |
ddb5b488 PZ |
6495 | } |
6496 | ||
b9c7bc5a PZ |
6497 | DEFPY (af_rd_vpn_export, |
6498 | af_rd_vpn_export_cmd, | |
6499 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
6500 | NO_STR | |
ddb5b488 | 6501 | "Specify route distinguisher\n" |
b9c7bc5a PZ |
6502 | "Between current address-family and vpn\n" |
6503 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6504 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") |
6505 | { | |
6506 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6507 | struct prefix_rd prd; | |
6508 | int ret; | |
ddb5b488 | 6509 | afi_t afi; |
b9c7bc5a PZ |
6510 | int idx = 0; |
6511 | int yes = 1; | |
ddb5b488 | 6512 | |
b9c7bc5a | 6513 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6514 | yes = 0; |
b9c7bc5a PZ |
6515 | |
6516 | if (yes) { | |
6517 | ret = str2prefix_rd(rd_str, &prd); | |
6518 | if (!ret) { | |
6519 | vty_out(vty, "%% Malformed rd\n"); | |
6520 | return CMD_WARNING_CONFIG_FAILED; | |
6521 | } | |
ddb5b488 PZ |
6522 | } |
6523 | ||
0ca70ba5 | 6524 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6525 | if (afi == AFI_MAX) |
6526 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6527 | |
69b07479 DS |
6528 | /* |
6529 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6530 | */ | |
6531 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6532 | bgp_get_default(), bgp); | |
ddb5b488 | 6533 | |
69b07479 DS |
6534 | if (yes) { |
6535 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
6536 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6537 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
6538 | } else { | |
6539 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
6540 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
ddb5b488 PZ |
6541 | } |
6542 | ||
69b07479 DS |
6543 | /* post-change: re-export vpn routes */ |
6544 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6545 | bgp_get_default(), bgp); | |
6546 | ||
ddb5b488 PZ |
6547 | return CMD_SUCCESS; |
6548 | } | |
6549 | ||
b9c7bc5a PZ |
6550 | ALIAS (af_rd_vpn_export, |
6551 | af_no_rd_vpn_export_cmd, | |
6552 | "no rd vpn export", | |
ddb5b488 | 6553 | NO_STR |
b9c7bc5a PZ |
6554 | "Specify route distinguisher\n" |
6555 | "Between current address-family and vpn\n" | |
6556 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6557 | |
b9c7bc5a PZ |
6558 | DEFPY (af_label_vpn_export, |
6559 | af_label_vpn_export_cmd, | |
e70e9f8e | 6560 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 6561 | NO_STR |
ddb5b488 | 6562 | "label value for VRF\n" |
b9c7bc5a PZ |
6563 | "Between current address-family and vpn\n" |
6564 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
6565 | "Label Value <0-1048575>\n" |
6566 | "Automatically assign a label\n") | |
ddb5b488 PZ |
6567 | { |
6568 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 6569 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 6570 | afi_t afi; |
b9c7bc5a PZ |
6571 | int idx = 0; |
6572 | int yes = 1; | |
6573 | ||
6574 | if (argv_find(argv, argc, "no", &idx)) | |
d555f3e9 | 6575 | yes = 0; |
ddb5b488 | 6576 | |
21a16cc2 PZ |
6577 | /* If "no ...", squash trailing parameter */ |
6578 | if (!yes) | |
6579 | label_auto = NULL; | |
6580 | ||
e70e9f8e PZ |
6581 | if (yes) { |
6582 | if (!label_auto) | |
6583 | label = label_val; /* parser should force unsigned */ | |
6584 | } | |
ddb5b488 | 6585 | |
0ca70ba5 | 6586 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6587 | if (afi == AFI_MAX) |
6588 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 6589 | |
e70e9f8e | 6590 | |
69b07479 DS |
6591 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
6592 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
6593 | /* no change */ | |
6594 | return CMD_SUCCESS; | |
e70e9f8e | 6595 | |
69b07479 DS |
6596 | /* |
6597 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6598 | */ | |
6599 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6600 | bgp_get_default(), bgp); | |
6601 | ||
6602 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
6603 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
6604 | ||
6605 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
6606 | ||
6607 | /* | |
6608 | * label has previously been automatically | |
6609 | * assigned by labelpool: release it | |
6610 | * | |
6611 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
6612 | * means the automatic assignment is in flight | |
6613 | * and therefore the labelpool callback must | |
6614 | * detect that the auto label is not needed. | |
6615 | */ | |
6616 | ||
6617 | bgp_lp_release(LP_TYPE_VRF, | |
6618 | &bgp->vpn_policy[afi], | |
6619 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 6620 | } |
69b07479 DS |
6621 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
6622 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
6623 | } | |
ddb5b488 | 6624 | |
69b07479 DS |
6625 | bgp->vpn_policy[afi].tovpn_label = label; |
6626 | if (label_auto) { | |
6627 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6628 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
6629 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
6630 | vpn_leak_label_callback); | |
ddb5b488 PZ |
6631 | } |
6632 | ||
69b07479 DS |
6633 | /* post-change: re-export vpn routes */ |
6634 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6635 | bgp_get_default(), bgp); | |
6636 | ||
ddb5b488 PZ |
6637 | return CMD_SUCCESS; |
6638 | } | |
6639 | ||
b9c7bc5a PZ |
6640 | ALIAS (af_label_vpn_export, |
6641 | af_no_label_vpn_export_cmd, | |
6642 | "no label vpn export", | |
6643 | NO_STR | |
6644 | "label value for VRF\n" | |
6645 | "Between current address-family and vpn\n" | |
6646 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6647 | |
b9c7bc5a PZ |
6648 | DEFPY (af_nexthop_vpn_export, |
6649 | af_nexthop_vpn_export_cmd, | |
6650 | "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str", | |
6651 | NO_STR | |
ddb5b488 | 6652 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
6653 | "Between current address-family and vpn\n" |
6654 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6655 | "IPv4 prefix\n" |
6656 | "IPv6 prefix\n") | |
6657 | { | |
6658 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
ddb5b488 | 6659 | afi_t afi; |
ddb5b488 | 6660 | struct prefix p; |
b9c7bc5a PZ |
6661 | int idx = 0; |
6662 | int yes = 1; | |
ddb5b488 | 6663 | |
b9c7bc5a | 6664 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6665 | yes = 0; |
b9c7bc5a PZ |
6666 | |
6667 | if (yes) { | |
6668 | if (!sockunion2hostprefix(nexthop_str, &p)) | |
6669 | return CMD_WARNING_CONFIG_FAILED; | |
6670 | } | |
ddb5b488 | 6671 | |
0ca70ba5 | 6672 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6673 | if (afi == AFI_MAX) |
6674 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6675 | |
69b07479 DS |
6676 | /* |
6677 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6678 | */ | |
6679 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6680 | bgp_get_default(), bgp); | |
ddb5b488 | 6681 | |
69b07479 DS |
6682 | if (yes) { |
6683 | bgp->vpn_policy[afi].tovpn_nexthop = p; | |
6684 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6685 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
6686 | } else { | |
6687 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
6688 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
ddb5b488 PZ |
6689 | } |
6690 | ||
69b07479 DS |
6691 | /* post-change: re-export vpn routes */ |
6692 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6693 | bgp_get_default(), bgp); | |
6694 | ||
ddb5b488 PZ |
6695 | return CMD_SUCCESS; |
6696 | } | |
6697 | ||
b9c7bc5a PZ |
6698 | ALIAS (af_nexthop_vpn_export, |
6699 | af_no_nexthop_vpn_export_cmd, | |
6700 | "no nexthop vpn export", | |
ddb5b488 | 6701 | NO_STR |
b9c7bc5a PZ |
6702 | "Specify next hop to use for VRF advertised prefixes\n" |
6703 | "Between current address-family and vpn\n" | |
6704 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6705 | |
b9c7bc5a | 6706 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 6707 | { |
b9c7bc5a PZ |
6708 | if (!strcmp(dstr, "import")) { |
6709 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
6710 | } else if (!strcmp(dstr, "export")) { | |
6711 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
6712 | } else if (!strcmp(dstr, "both")) { | |
6713 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
6714 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
6715 | } else { | |
6716 | vty_out(vty, "%% direction parse error\n"); | |
6717 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6718 | } |
ddb5b488 PZ |
6719 | return CMD_SUCCESS; |
6720 | } | |
6721 | ||
b9c7bc5a PZ |
6722 | DEFPY (af_rt_vpn_imexport, |
6723 | af_rt_vpn_imexport_cmd, | |
6724 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
6725 | NO_STR | |
6726 | "Specify route target list\n" | |
ddb5b488 | 6727 | "Specify route target list\n" |
b9c7bc5a PZ |
6728 | "Between current address-family and vpn\n" |
6729 | "For routes leaked from vpn to current address-family: match any\n" | |
6730 | "For routes leaked from current address-family to vpn: set\n" | |
6731 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
6732 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
6733 | { | |
6734 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6735 | int ret; | |
6736 | struct ecommunity *ecom = NULL; | |
6737 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
6738 | vpn_policy_direction_t dir; |
6739 | afi_t afi; | |
6740 | int idx = 0; | |
b9c7bc5a | 6741 | int yes = 1; |
ddb5b488 | 6742 | |
b9c7bc5a | 6743 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6744 | yes = 0; |
b9c7bc5a | 6745 | |
0ca70ba5 | 6746 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6747 | if (afi == AFI_MAX) |
6748 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6749 | |
b9c7bc5a | 6750 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
6751 | if (ret != CMD_SUCCESS) |
6752 | return ret; | |
6753 | ||
b9c7bc5a PZ |
6754 | if (yes) { |
6755 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
6756 | vty_out(vty, "%% Missing RTLIST\n"); | |
6757 | return CMD_WARNING_CONFIG_FAILED; | |
6758 | } | |
6759 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
6760 | if (ret != CMD_SUCCESS) { | |
6761 | return ret; | |
6762 | } | |
ddb5b488 PZ |
6763 | } |
6764 | ||
69b07479 DS |
6765 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
6766 | if (!dodir[dir]) | |
ddb5b488 | 6767 | continue; |
ddb5b488 | 6768 | |
69b07479 | 6769 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 6770 | |
69b07479 DS |
6771 | if (yes) { |
6772 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
6773 | ecommunity_free( | |
6774 | &bgp->vpn_policy[afi].rtlist[dir]); | |
6775 | bgp->vpn_policy[afi].rtlist[dir] = | |
6776 | ecommunity_dup(ecom); | |
6777 | } else { | |
6778 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
6779 | ecommunity_free( | |
6780 | &bgp->vpn_policy[afi].rtlist[dir]); | |
6781 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 6782 | } |
69b07479 DS |
6783 | |
6784 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 6785 | } |
69b07479 | 6786 | |
d555f3e9 PZ |
6787 | if (ecom) |
6788 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
6789 | |
6790 | return CMD_SUCCESS; | |
6791 | } | |
6792 | ||
b9c7bc5a PZ |
6793 | ALIAS (af_rt_vpn_imexport, |
6794 | af_no_rt_vpn_imexport_cmd, | |
6795 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
6796 | NO_STR |
6797 | "Specify route target list\n" | |
b9c7bc5a PZ |
6798 | "Specify route target list\n" |
6799 | "Between current address-family and vpn\n" | |
6800 | "For routes leaked from vpn to current address-family\n" | |
6801 | "For routes leaked from current address-family to vpn\n" | |
6802 | "both import and export\n") | |
6803 | ||
6804 | DEFPY (af_route_map_vpn_imexport, | |
6805 | af_route_map_vpn_imexport_cmd, | |
6806 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
6807 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
6808 | NO_STR | |
ddb5b488 | 6809 | "Specify route map\n" |
b9c7bc5a PZ |
6810 | "Between current address-family and vpn\n" |
6811 | "For routes leaked from vpn to current address-family\n" | |
6812 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6813 | "name of route-map\n") |
6814 | { | |
6815 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6816 | int ret; | |
6817 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
6818 | vpn_policy_direction_t dir; |
6819 | afi_t afi; | |
ddb5b488 | 6820 | int idx = 0; |
b9c7bc5a | 6821 | int yes = 1; |
ddb5b488 | 6822 | |
b9c7bc5a | 6823 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6824 | yes = 0; |
b9c7bc5a | 6825 | |
0ca70ba5 | 6826 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6827 | if (afi == AFI_MAX) |
6828 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6829 | |
b9c7bc5a | 6830 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
6831 | if (ret != CMD_SUCCESS) |
6832 | return ret; | |
6833 | ||
69b07479 DS |
6834 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
6835 | if (!dodir[dir]) | |
ddb5b488 | 6836 | continue; |
ddb5b488 | 6837 | |
69b07479 | 6838 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 6839 | |
69b07479 DS |
6840 | if (yes) { |
6841 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6842 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6843 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6844 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
6845 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
6846 | bgp->vpn_policy[afi].rmap[dir] = | |
1de27621 | 6847 | route_map_lookup_warn_noexist(vty, rmap_str); |
69b07479 DS |
6848 | if (!bgp->vpn_policy[afi].rmap[dir]) |
6849 | return CMD_SUCCESS; | |
6850 | } else { | |
6851 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6852 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6853 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6854 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
6855 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
ddb5b488 | 6856 | } |
69b07479 DS |
6857 | |
6858 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 PZ |
6859 | } |
6860 | ||
6861 | return CMD_SUCCESS; | |
6862 | } | |
6863 | ||
b9c7bc5a PZ |
6864 | ALIAS (af_route_map_vpn_imexport, |
6865 | af_no_route_map_vpn_imexport_cmd, | |
6866 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
6867 | NO_STR |
6868 | "Specify route map\n" | |
b9c7bc5a PZ |
6869 | "Between current address-family and vpn\n" |
6870 | "For routes leaked from vpn to current address-family\n" | |
6871 | "For routes leaked from current address-family to vpn\n") | |
6872 | ||
bb4f6190 DS |
6873 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
6874 | "[no] import vrf route-map RMAP$rmap_str", | |
6875 | NO_STR | |
6876 | "Import routes from another VRF\n" | |
6877 | "Vrf routes being filtered\n" | |
6878 | "Specify route map\n" | |
6879 | "name of route-map\n") | |
6880 | { | |
6881 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
bb4f6190 DS |
6882 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; |
6883 | afi_t afi; | |
6884 | int idx = 0; | |
6885 | int yes = 1; | |
6886 | struct bgp *bgp_default; | |
6887 | ||
6888 | if (argv_find(argv, argc, "no", &idx)) | |
6889 | yes = 0; | |
6890 | ||
0ca70ba5 | 6891 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
6892 | if (afi == AFI_MAX) |
6893 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
6894 | |
6895 | bgp_default = bgp_get_default(); | |
6896 | if (!bgp_default) { | |
6897 | int32_t ret; | |
6898 | as_t as = bgp->as; | |
6899 | ||
6900 | /* Auto-create assuming the same AS */ | |
6901 | ret = bgp_get(&bgp_default, &as, NULL, | |
6902 | BGP_INSTANCE_TYPE_DEFAULT); | |
6903 | ||
6904 | if (ret) { | |
6905 | vty_out(vty, | |
6906 | "VRF default is not configured as a bgp instance\n"); | |
6907 | return CMD_WARNING; | |
6908 | } | |
6909 | } | |
6910 | ||
69b07479 | 6911 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 6912 | |
69b07479 DS |
6913 | if (yes) { |
6914 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6915 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6916 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6917 | bgp->vpn_policy[afi].rmap_name[dir] = | |
6918 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
6919 | bgp->vpn_policy[afi].rmap[dir] = | |
1de27621 | 6920 | route_map_lookup_warn_noexist(vty, rmap_str); |
69b07479 DS |
6921 | if (!bgp->vpn_policy[afi].rmap[dir]) |
6922 | return CMD_SUCCESS; | |
6923 | } else { | |
6924 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6925 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6926 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6927 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
6928 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
bb4f6190 DS |
6929 | } |
6930 | ||
69b07479 DS |
6931 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
6932 | ||
bb4f6190 DS |
6933 | return CMD_SUCCESS; |
6934 | } | |
6935 | ||
6936 | ALIAS(af_import_vrf_route_map, af_no_import_vrf_route_map_cmd, | |
6937 | "no import vrf route-map", | |
6938 | NO_STR | |
6939 | "Import routes from another VRF\n" | |
6940 | "Vrf routes being filtered\n" | |
6941 | "Specify route map\n") | |
6942 | ||
4d1b335c DA |
6943 | DEFPY(bgp_imexport_vrf, bgp_imexport_vrf_cmd, |
6944 | "[no] import vrf VIEWVRFNAME$import_name", | |
6945 | NO_STR | |
6946 | "Import routes from another VRF\n" | |
6947 | "VRF to import from\n" | |
6948 | "The name of the VRF\n") | |
12a844a5 DS |
6949 | { |
6950 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6951 | struct listnode *node; | |
79ef8664 DS |
6952 | struct bgp *vrf_bgp, *bgp_default; |
6953 | int32_t ret = 0; | |
6954 | as_t as = bgp->as; | |
12a844a5 DS |
6955 | bool remove = false; |
6956 | int32_t idx = 0; | |
6957 | char *vname; | |
a8dadcf6 | 6958 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; |
12a844a5 DS |
6959 | safi_t safi; |
6960 | afi_t afi; | |
6961 | ||
867f0cca | 6962 | if (import_name == NULL) { |
6963 | vty_out(vty, "%% Missing import name\n"); | |
6964 | return CMD_WARNING; | |
6965 | } | |
6966 | ||
12a844a5 DS |
6967 | if (argv_find(argv, argc, "no", &idx)) |
6968 | remove = true; | |
6969 | ||
0ca70ba5 DS |
6970 | afi = vpn_policy_getafi(vty, bgp, true); |
6971 | if (afi == AFI_MAX) | |
6972 | return CMD_WARNING_CONFIG_FAILED; | |
6973 | ||
12a844a5 DS |
6974 | safi = bgp_node_safi(vty); |
6975 | ||
25679caa | 6976 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) |
5742e42b | 6977 | && (strcmp(import_name, VRF_DEFAULT_NAME) == 0)) |
25679caa DS |
6978 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { |
6979 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
6980 | remove ? "unimport" : "import", import_name); | |
6981 | return CMD_WARNING; | |
6982 | } | |
6983 | ||
79ef8664 DS |
6984 | bgp_default = bgp_get_default(); |
6985 | if (!bgp_default) { | |
6986 | /* Auto-create assuming the same AS */ | |
6987 | ret = bgp_get(&bgp_default, &as, NULL, | |
6988 | BGP_INSTANCE_TYPE_DEFAULT); | |
6989 | ||
6990 | if (ret) { | |
6991 | vty_out(vty, | |
6992 | "VRF default is not configured as a bgp instance\n"); | |
6993 | return CMD_WARNING; | |
6994 | } | |
6995 | } | |
6996 | ||
12a844a5 DS |
6997 | vrf_bgp = bgp_lookup_by_name(import_name); |
6998 | if (!vrf_bgp) { | |
5742e42b | 6999 | if (strcmp(import_name, VRF_DEFAULT_NAME) == 0) |
79ef8664 DS |
7000 | vrf_bgp = bgp_default; |
7001 | else | |
0fb8d6e6 DS |
7002 | /* Auto-create assuming the same AS */ |
7003 | ret = bgp_get(&vrf_bgp, &as, import_name, bgp_type); | |
a8dadcf6 | 7004 | |
6e2c7fe6 | 7005 | if (ret) { |
020a3f60 DS |
7006 | vty_out(vty, |
7007 | "VRF %s is not configured as a bgp instance\n", | |
6e2c7fe6 DS |
7008 | import_name); |
7009 | return CMD_WARNING; | |
7010 | } | |
12a844a5 DS |
7011 | } |
7012 | ||
12a844a5 | 7013 | if (remove) { |
44338987 | 7014 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 | 7015 | } else { |
44338987 | 7016 | /* Already importing from "import_vrf"? */ |
12a844a5 DS |
7017 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, |
7018 | vname)) { | |
7019 | if (strcmp(vname, import_name) == 0) | |
7020 | return CMD_WARNING; | |
7021 | } | |
7022 | ||
44338987 | 7023 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 DS |
7024 | } |
7025 | ||
7026 | return CMD_SUCCESS; | |
7027 | } | |
7028 | ||
b9c7bc5a PZ |
7029 | /* This command is valid only in a bgp vrf instance or the default instance */ |
7030 | DEFPY (bgp_imexport_vpn, | |
7031 | bgp_imexport_vpn_cmd, | |
7032 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
7033 | NO_STR |
7034 | "Import routes to this address-family\n" | |
7035 | "Export routes from this address-family\n" | |
7036 | "to/from default instance VPN RIB\n") | |
ddb5b488 PZ |
7037 | { |
7038 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 7039 | int previous_state; |
ddb5b488 | 7040 | afi_t afi; |
b9c7bc5a | 7041 | safi_t safi; |
ddb5b488 | 7042 | int idx = 0; |
b9c7bc5a PZ |
7043 | int yes = 1; |
7044 | int flag; | |
7045 | vpn_policy_direction_t dir; | |
ddb5b488 | 7046 | |
b9c7bc5a | 7047 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7048 | yes = 0; |
ddb5b488 | 7049 | |
b9c7bc5a PZ |
7050 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && |
7051 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
ddb5b488 | 7052 | |
b9c7bc5a PZ |
7053 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); |
7054 | return CMD_WARNING_CONFIG_FAILED; | |
7055 | } | |
ddb5b488 | 7056 | |
b9c7bc5a PZ |
7057 | afi = bgp_node_afi(vty); |
7058 | safi = bgp_node_safi(vty); | |
7059 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { | |
7060 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
7061 | return CMD_WARNING_CONFIG_FAILED; | |
7062 | } | |
ddb5b488 | 7063 | |
b9c7bc5a PZ |
7064 | if (!strcmp(direction_str, "import")) { |
7065 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; | |
7066 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
7067 | } else if (!strcmp(direction_str, "export")) { | |
7068 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; | |
7069 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
7070 | } else { | |
7071 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
7072 | return CMD_WARNING_CONFIG_FAILED; | |
7073 | } | |
7074 | ||
7075 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 | 7076 | |
b9c7bc5a PZ |
7077 | if (yes) { |
7078 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
7079 | if (!previous_state) { | |
7080 | /* trigger export current vrf */ | |
ddb5b488 PZ |
7081 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
7082 | } | |
b9c7bc5a PZ |
7083 | } else { |
7084 | if (previous_state) { | |
7085 | /* trigger un-export current vrf */ | |
7086 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
7087 | } | |
7088 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 PZ |
7089 | } |
7090 | ||
7091 | return CMD_SUCCESS; | |
7092 | } | |
7093 | ||
301ad80a PG |
7094 | DEFPY (af_routetarget_import, |
7095 | af_routetarget_import_cmd, | |
7096 | "[no] <rt|route-target> redirect import RTLIST...", | |
7097 | NO_STR | |
7098 | "Specify route target list\n" | |
7099 | "Specify route target list\n" | |
7100 | "Flow-spec redirect type route target\n" | |
7101 | "Import routes to this address-family\n" | |
7102 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") | |
7103 | { | |
7104 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7105 | int ret; | |
7106 | struct ecommunity *ecom = NULL; | |
301ad80a PG |
7107 | afi_t afi; |
7108 | int idx = 0; | |
7109 | int yes = 1; | |
7110 | ||
7111 | if (argv_find(argv, argc, "no", &idx)) | |
7112 | yes = 0; | |
7113 | ||
0ca70ba5 | 7114 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7115 | if (afi == AFI_MAX) |
7116 | return CMD_WARNING_CONFIG_FAILED; | |
7117 | ||
301ad80a PG |
7118 | if (yes) { |
7119 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
7120 | vty_out(vty, "%% Missing RTLIST\n"); | |
7121 | return CMD_WARNING_CONFIG_FAILED; | |
7122 | } | |
7123 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
7124 | if (ret != CMD_SUCCESS) | |
7125 | return ret; | |
7126 | } | |
69b07479 DS |
7127 | |
7128 | if (yes) { | |
7129 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
7130 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 7131 | .import_redirect_rtlist); |
69b07479 DS |
7132 | bgp->vpn_policy[afi].import_redirect_rtlist = |
7133 | ecommunity_dup(ecom); | |
7134 | } else { | |
7135 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
7136 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 7137 | .import_redirect_rtlist); |
69b07479 | 7138 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 7139 | } |
69b07479 | 7140 | |
301ad80a PG |
7141 | if (ecom) |
7142 | ecommunity_free(&ecom); | |
7143 | ||
7144 | return CMD_SUCCESS; | |
7145 | } | |
7146 | ||
505e5056 | 7147 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 7148 | address_family_ipv4_safi_cmd, |
7149 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
7150 | "Enter Address Family command mode\n" | |
7151 | "Address Family\n" | |
7152 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
718e3744 | 7153 | { |
f51bae9c | 7154 | |
d62a17ae | 7155 | if (argc == 3) { |
2131d5cf | 7156 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7157 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
7158 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
7159 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 7160 | && safi != SAFI_EVPN) { |
31947174 MK |
7161 | vty_out(vty, |
7162 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
7163 | return CMD_WARNING_CONFIG_FAILED; |
7164 | } | |
d62a17ae | 7165 | vty->node = bgp_node_type(AFI_IP, safi); |
7166 | } else | |
7167 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 7168 | |
d62a17ae | 7169 | return CMD_SUCCESS; |
718e3744 | 7170 | } |
7171 | ||
505e5056 | 7172 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 7173 | address_family_ipv6_safi_cmd, |
7174 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
7175 | "Enter Address Family command mode\n" | |
7176 | "Address Family\n" | |
7177 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
25ffbdc1 | 7178 | { |
d62a17ae | 7179 | if (argc == 3) { |
2131d5cf | 7180 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7181 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
7182 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
7183 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 7184 | && safi != SAFI_EVPN) { |
31947174 MK |
7185 | vty_out(vty, |
7186 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
7187 | return CMD_WARNING_CONFIG_FAILED; |
7188 | } | |
d62a17ae | 7189 | vty->node = bgp_node_type(AFI_IP6, safi); |
7190 | } else | |
7191 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 7192 | |
d62a17ae | 7193 | return CMD_SUCCESS; |
25ffbdc1 | 7194 | } |
718e3744 | 7195 | |
d6902373 | 7196 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 7197 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 7198 | address_family_vpnv4_cmd, |
8334fd5a | 7199 | "address-family vpnv4 [unicast]", |
718e3744 | 7200 | "Enter Address Family command mode\n" |
8c3deaae | 7201 | "Address Family\n" |
3a2d747c | 7202 | "Address Family modifier\n") |
718e3744 | 7203 | { |
d62a17ae | 7204 | vty->node = BGP_VPNV4_NODE; |
7205 | return CMD_SUCCESS; | |
718e3744 | 7206 | } |
7207 | ||
505e5056 | 7208 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 7209 | address_family_vpnv6_cmd, |
8334fd5a | 7210 | "address-family vpnv6 [unicast]", |
8ecd3266 | 7211 | "Enter Address Family command mode\n" |
8c3deaae | 7212 | "Address Family\n" |
3a2d747c | 7213 | "Address Family modifier\n") |
8ecd3266 | 7214 | { |
d62a17ae | 7215 | vty->node = BGP_VPNV6_NODE; |
7216 | return CMD_SUCCESS; | |
8ecd3266 | 7217 | } |
64e4a6c5 | 7218 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
d6902373 | 7219 | |
505e5056 | 7220 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 7221 | address_family_evpn_cmd, |
7111c1a0 | 7222 | "address-family l2vpn evpn", |
4e0b7b6d | 7223 | "Enter Address Family command mode\n" |
7111c1a0 QY |
7224 | "Address Family\n" |
7225 | "Address Family modifier\n") | |
4e0b7b6d | 7226 | { |
2131d5cf | 7227 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7228 | vty->node = BGP_EVPN_NODE; |
7229 | return CMD_SUCCESS; | |
4e0b7b6d PG |
7230 | } |
7231 | ||
505e5056 | 7232 | DEFUN_NOSH (exit_address_family, |
718e3744 | 7233 | exit_address_family_cmd, |
7234 | "exit-address-family", | |
7235 | "Exit from Address Family configuration mode\n") | |
7236 | { | |
d62a17ae | 7237 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
7238 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
7239 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
7240 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
7241 | || vty->node == BGP_EVPN_NODE |
7242 | || vty->node == BGP_FLOWSPECV4_NODE | |
7243 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 7244 | vty->node = BGP_NODE; |
7245 | return CMD_SUCCESS; | |
718e3744 | 7246 | } |
6b0655a2 | 7247 | |
8ad7271d | 7248 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 7249 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
7250 | const char *ip_str, afi_t afi, safi_t safi, | |
7251 | struct prefix_rd *prd) | |
7252 | { | |
7253 | int ret; | |
7254 | struct prefix match; | |
7255 | struct bgp_node *rn; | |
7256 | struct bgp_node *rm; | |
7257 | struct bgp *bgp; | |
7258 | struct bgp_table *table; | |
7259 | struct bgp_table *rib; | |
7260 | ||
7261 | /* BGP structure lookup. */ | |
7262 | if (view_name) { | |
7263 | bgp = bgp_lookup_by_name(view_name); | |
7264 | if (bgp == NULL) { | |
7265 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
7266 | view_name); | |
7267 | return CMD_WARNING; | |
7268 | } | |
7269 | } else { | |
7270 | bgp = bgp_get_default(); | |
7271 | if (bgp == NULL) { | |
7272 | vty_out(vty, "%% No BGP process is configured\n"); | |
7273 | return CMD_WARNING; | |
7274 | } | |
7275 | } | |
7276 | ||
7277 | /* Check IP address argument. */ | |
7278 | ret = str2prefix(ip_str, &match); | |
7279 | if (!ret) { | |
7280 | vty_out(vty, "%% address is malformed\n"); | |
7281 | return CMD_WARNING; | |
7282 | } | |
7283 | ||
7284 | match.family = afi2family(afi); | |
7285 | rib = bgp->rib[afi][safi]; | |
7286 | ||
7287 | if (safi == SAFI_MPLS_VPN) { | |
7288 | for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) { | |
7289 | if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0) | |
7290 | continue; | |
7291 | ||
67009e22 DS |
7292 | table = bgp_node_get_bgp_table_info(rn); |
7293 | if (table != NULL) { | |
7294 | ||
d62a17ae | 7295 | if ((rm = bgp_node_match(table, &match)) |
7296 | != NULL) { | |
7297 | if (rm->p.prefixlen | |
7298 | == match.prefixlen) { | |
343cdb61 | 7299 | SET_FLAG(rm->flags, |
d62a17ae | 7300 | BGP_NODE_USER_CLEAR); |
7301 | bgp_process(bgp, rm, afi, safi); | |
7302 | } | |
7303 | bgp_unlock_node(rm); | |
7304 | } | |
7305 | } | |
7306 | } | |
7307 | } else { | |
7308 | if ((rn = bgp_node_match(rib, &match)) != NULL) { | |
7309 | if (rn->p.prefixlen == match.prefixlen) { | |
7310 | SET_FLAG(rn->flags, BGP_NODE_USER_CLEAR); | |
7311 | bgp_process(bgp, rn, afi, safi); | |
7312 | } | |
7313 | bgp_unlock_node(rn); | |
7314 | } | |
7315 | } | |
7316 | ||
7317 | return CMD_SUCCESS; | |
8ad7271d DS |
7318 | } |
7319 | ||
b09b5ae0 | 7320 | /* one clear bgp command to rule them all */ |
718e3744 | 7321 | DEFUN (clear_ip_bgp_all, |
7322 | clear_ip_bgp_all_cmd, | |
d7b9898c | 7323 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6|l2vpn> [<unicast|multicast|vpn|labeled-unicast|flowspec|evpn>]] <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> [<soft [<in|out>]|in [prefix-filter]|out>]", |
718e3744 | 7324 | CLEAR_STR |
7325 | IP_STR | |
7326 | BGP_STR | |
838758ac | 7327 | BGP_INSTANCE_HELP_STR |
510afcd6 | 7328 | BGP_AFI_HELP_STR |
fd5e7b70 | 7329 | "Address Family\n" |
510afcd6 | 7330 | BGP_SAFI_WITH_LABEL_HELP_STR |
fd5e7b70 | 7331 | "Address Family modifier\n" |
b09b5ae0 DW |
7332 | "Clear all peers\n" |
7333 | "BGP neighbor address to clear\n" | |
a80beece | 7334 | "BGP IPv6 neighbor to clear\n" |
838758ac | 7335 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
7336 | "Clear peers with the AS number\n" |
7337 | "Clear all external peers\n" | |
718e3744 | 7338 | "Clear all members of peer-group\n" |
b09b5ae0 | 7339 | "BGP peer-group name\n" |
b09b5ae0 DW |
7340 | BGP_SOFT_STR |
7341 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
7342 | BGP_SOFT_OUT_STR |
7343 | BGP_SOFT_IN_STR | |
7344 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 7345 | BGP_SOFT_OUT_STR) |
718e3744 | 7346 | { |
d62a17ae | 7347 | char *vrf = NULL; |
7348 | ||
dc912615 DS |
7349 | afi_t afi = AFI_UNSPEC; |
7350 | safi_t safi = SAFI_UNSPEC; | |
d62a17ae | 7351 | enum clear_sort clr_sort = clear_peer; |
7352 | enum bgp_clear_type clr_type; | |
7353 | char *clr_arg = NULL; | |
7354 | ||
7355 | int idx = 0; | |
7356 | ||
7357 | /* clear [ip] bgp */ | |
7358 | if (argv_find(argv, argc, "ip", &idx)) | |
7359 | afi = AFI_IP; | |
7360 | ||
9a8bdf1c PG |
7361 | /* [<vrf> VIEWVRFNAME] */ |
7362 | if (argv_find(argv, argc, "vrf", &idx)) { | |
7363 | vrf = argv[idx + 1]->arg; | |
7364 | idx += 2; | |
7365 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
7366 | vrf = NULL; | |
7367 | } else if (argv_find(argv, argc, "view", &idx)) { | |
7368 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 7369 | vrf = argv[idx + 1]->arg; |
7370 | idx += 2; | |
7371 | } | |
d62a17ae | 7372 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
7373 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
7374 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
7375 | ||
d7b9898c | 7376 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */ |
d62a17ae | 7377 | if (argv_find(argv, argc, "*", &idx)) { |
7378 | clr_sort = clear_all; | |
7379 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
7380 | clr_sort = clear_peer; | |
7381 | clr_arg = argv[idx]->arg; | |
7382 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
7383 | clr_sort = clear_peer; | |
7384 | clr_arg = argv[idx]->arg; | |
7385 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
7386 | clr_sort = clear_group; | |
7387 | idx++; | |
7388 | clr_arg = argv[idx]->arg; | |
d7b9898c | 7389 | } else if (argv_find(argv, argc, "PGNAME", &idx)) { |
d62a17ae | 7390 | clr_sort = clear_peer; |
7391 | clr_arg = argv[idx]->arg; | |
8fa7d444 DS |
7392 | } else if (argv_find(argv, argc, "WORD", &idx)) { |
7393 | clr_sort = clear_peer; | |
7394 | clr_arg = argv[idx]->arg; | |
d62a17ae | 7395 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { |
7396 | clr_sort = clear_as; | |
7397 | clr_arg = argv[idx]->arg; | |
7398 | } else if (argv_find(argv, argc, "external", &idx)) { | |
7399 | clr_sort = clear_external; | |
7400 | } | |
7401 | ||
7402 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
7403 | if (argv_find(argv, argc, "soft", &idx)) { | |
7404 | if (argv_find(argv, argc, "in", &idx) | |
7405 | || argv_find(argv, argc, "out", &idx)) | |
7406 | clr_type = strmatch(argv[idx]->text, "in") | |
7407 | ? BGP_CLEAR_SOFT_IN | |
7408 | : BGP_CLEAR_SOFT_OUT; | |
7409 | else | |
7410 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
7411 | } else if (argv_find(argv, argc, "in", &idx)) { | |
7412 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
7413 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
7414 | : BGP_CLEAR_SOFT_IN; | |
7415 | } else if (argv_find(argv, argc, "out", &idx)) { | |
7416 | clr_type = BGP_CLEAR_SOFT_OUT; | |
7417 | } else | |
7418 | clr_type = BGP_CLEAR_SOFT_NONE; | |
7419 | ||
7420 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); | |
838758ac | 7421 | } |
01080f7c | 7422 | |
8ad7271d DS |
7423 | DEFUN (clear_ip_bgp_prefix, |
7424 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 7425 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
7426 | CLEAR_STR |
7427 | IP_STR | |
7428 | BGP_STR | |
838758ac | 7429 | BGP_INSTANCE_HELP_STR |
8ad7271d | 7430 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7431 | "IPv4 prefix\n") |
8ad7271d | 7432 | { |
d62a17ae | 7433 | char *vrf = NULL; |
7434 | char *prefix = NULL; | |
8ad7271d | 7435 | |
d62a17ae | 7436 | int idx = 0; |
01080f7c | 7437 | |
d62a17ae | 7438 | /* [<view|vrf> VIEWVRFNAME] */ |
9a8bdf1c PG |
7439 | if (argv_find(argv, argc, "vrf", &idx)) { |
7440 | vrf = argv[idx + 1]->arg; | |
7441 | idx += 2; | |
7442 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
7443 | vrf = NULL; | |
7444 | } else if (argv_find(argv, argc, "view", &idx)) { | |
7445 | /* [<view> VIEWVRFNAME] */ | |
7446 | vrf = argv[idx + 1]->arg; | |
7447 | idx += 2; | |
7448 | } | |
0c7b1b01 | 7449 | |
d62a17ae | 7450 | prefix = argv[argc - 1]->arg; |
8ad7271d | 7451 | |
d62a17ae | 7452 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 7453 | } |
8ad7271d | 7454 | |
b09b5ae0 DW |
7455 | DEFUN (clear_bgp_ipv6_safi_prefix, |
7456 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 7457 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 7458 | CLEAR_STR |
3a2d747c | 7459 | IP_STR |
718e3744 | 7460 | BGP_STR |
8c3deaae | 7461 | "Address Family\n" |
46f296b4 | 7462 | BGP_SAFI_HELP_STR |
b09b5ae0 | 7463 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7464 | "IPv6 prefix\n") |
718e3744 | 7465 | { |
9b475e76 PG |
7466 | int idx_safi = 0; |
7467 | int idx_ipv6_prefix = 0; | |
7468 | safi_t safi = SAFI_UNICAST; | |
7469 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
7470 | argv[idx_ipv6_prefix]->arg : NULL; | |
7471 | ||
7472 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 7473 | return bgp_clear_prefix( |
9b475e76 PG |
7474 | vty, NULL, prefix, AFI_IP6, |
7475 | safi, NULL); | |
838758ac | 7476 | } |
01080f7c | 7477 | |
b09b5ae0 DW |
7478 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
7479 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 7480 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 7481 | CLEAR_STR |
3a2d747c | 7482 | IP_STR |
718e3744 | 7483 | BGP_STR |
838758ac | 7484 | BGP_INSTANCE_HELP_STR |
8c3deaae | 7485 | "Address Family\n" |
46f296b4 | 7486 | BGP_SAFI_HELP_STR |
b09b5ae0 | 7487 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7488 | "IPv6 prefix\n") |
718e3744 | 7489 | { |
9b475e76 | 7490 | int idx_safi = 0; |
9a8bdf1c | 7491 | int idx_vrfview = 0; |
9b475e76 PG |
7492 | int idx_ipv6_prefix = 0; |
7493 | safi_t safi = SAFI_UNICAST; | |
7494 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
7495 | argv[idx_ipv6_prefix]->arg : NULL; | |
9a8bdf1c | 7496 | char *vrfview = NULL; |
9b475e76 | 7497 | |
9a8bdf1c PG |
7498 | /* [<view|vrf> VIEWVRFNAME] */ |
7499 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
7500 | vrfview = argv[idx_vrfview + 1]->arg; | |
7501 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
7502 | vrfview = NULL; | |
7503 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
7504 | /* [<view> VIEWVRFNAME] */ | |
7505 | vrfview = argv[idx_vrfview + 1]->arg; | |
7506 | } | |
9b475e76 PG |
7507 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); |
7508 | ||
d62a17ae | 7509 | return bgp_clear_prefix( |
9b475e76 PG |
7510 | vty, vrfview, prefix, |
7511 | AFI_IP6, safi, NULL); | |
718e3744 | 7512 | } |
7513 | ||
b09b5ae0 DW |
7514 | DEFUN (show_bgp_views, |
7515 | show_bgp_views_cmd, | |
d6e3c605 | 7516 | "show [ip] bgp views", |
b09b5ae0 | 7517 | SHOW_STR |
d6e3c605 | 7518 | IP_STR |
01080f7c | 7519 | BGP_STR |
b09b5ae0 | 7520 | "Show the defined BGP views\n") |
01080f7c | 7521 | { |
d62a17ae | 7522 | struct list *inst = bm->bgp; |
7523 | struct listnode *node; | |
7524 | struct bgp *bgp; | |
01080f7c | 7525 | |
d62a17ae | 7526 | vty_out(vty, "Defined BGP views:\n"); |
7527 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
7528 | /* Skip VRFs. */ | |
7529 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
7530 | continue; | |
7531 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
7532 | bgp->as); | |
7533 | } | |
e52702f2 | 7534 | |
d62a17ae | 7535 | return CMD_SUCCESS; |
e0081f70 ML |
7536 | } |
7537 | ||
8386ac43 | 7538 | DEFUN (show_bgp_vrfs, |
7539 | show_bgp_vrfs_cmd, | |
d6e3c605 | 7540 | "show [ip] bgp vrfs [json]", |
8386ac43 | 7541 | SHOW_STR |
d6e3c605 | 7542 | IP_STR |
8386ac43 | 7543 | BGP_STR |
7544 | "Show BGP VRFs\n" | |
9973d184 | 7545 | JSON_STR) |
8386ac43 | 7546 | { |
fe1dc5a3 | 7547 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 7548 | struct list *inst = bm->bgp; |
7549 | struct listnode *node; | |
7550 | struct bgp *bgp; | |
9f049418 | 7551 | bool uj = use_json(argc, argv); |
d62a17ae | 7552 | json_object *json = NULL; |
7553 | json_object *json_vrfs = NULL; | |
7554 | int count = 0; | |
d62a17ae | 7555 | |
d62a17ae | 7556 | if (uj) { |
7557 | json = json_object_new_object(); | |
7558 | json_vrfs = json_object_new_object(); | |
7559 | } | |
7560 | ||
7561 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
7562 | const char *name, *type; | |
7563 | struct peer *peer; | |
7fe96307 | 7564 | struct listnode *node2, *nnode2; |
d62a17ae | 7565 | int peers_cfg, peers_estb; |
7566 | json_object *json_vrf = NULL; | |
d62a17ae | 7567 | |
7568 | /* Skip Views. */ | |
7569 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
7570 | continue; | |
7571 | ||
7572 | count++; | |
efb4077a | 7573 | if (!uj && count == 1) { |
fe1dc5a3 | 7574 | vty_out(vty, |
efb4077a | 7575 | "%4s %-5s %-16s %9s %10s %-37s\n", |
a4d82a8a | 7576 | "Type", "Id", "routerId", "#PeersVfg", |
efb4077a CS |
7577 | "#PeersEstb", "Name"); |
7578 | vty_out(vty, "%11s %-16s %-21s %-6s\n", " ", | |
7579 | "L3-VNI", "RouterMAC", "Interface"); | |
7580 | } | |
d62a17ae | 7581 | |
7582 | peers_cfg = peers_estb = 0; | |
7583 | if (uj) | |
7584 | json_vrf = json_object_new_object(); | |
7585 | ||
7586 | ||
7fe96307 | 7587 | for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { |
d62a17ae | 7588 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
7589 | continue; | |
7590 | peers_cfg++; | |
7591 | if (peer->status == Established) | |
7592 | peers_estb++; | |
7593 | } | |
7594 | ||
7595 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
5742e42b | 7596 | name = VRF_DEFAULT_NAME; |
d62a17ae | 7597 | type = "DFLT"; |
7598 | } else { | |
7599 | name = bgp->name; | |
7600 | type = "VRF"; | |
7601 | } | |
7602 | ||
a8bf7d9c | 7603 | |
d62a17ae | 7604 | if (uj) { |
a4d82a8a PZ |
7605 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
7606 | ? -1 | |
7607 | : (int64_t)bgp->vrf_id; | |
d62a17ae | 7608 | json_object_string_add(json_vrf, "type", type); |
7609 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
7610 | json_object_string_add(json_vrf, "routerId", | |
7611 | inet_ntoa(bgp->router_id)); | |
7612 | json_object_int_add(json_vrf, "numConfiguredPeers", | |
7613 | peers_cfg); | |
7614 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
7615 | peers_estb); | |
7616 | ||
fe1dc5a3 | 7617 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
7618 | json_object_string_add( |
7619 | json_vrf, "rmac", | |
7620 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
efb4077a CS |
7621 | json_object_string_add(json_vrf, "interface", |
7622 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
7623 | bgp->vrf_id)); | |
d62a17ae | 7624 | json_object_object_add(json_vrfs, name, json_vrf); |
efb4077a | 7625 | } else { |
fe1dc5a3 | 7626 | vty_out(vty, |
efb4077a | 7627 | "%4s %-5d %-16s %-9u %-10u %-37s\n", |
a4d82a8a PZ |
7628 | type, |
7629 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
7630 | : (int)bgp->vrf_id, | |
7631 | inet_ntoa(bgp->router_id), peers_cfg, | |
efb4077a CS |
7632 | peers_estb, name); |
7633 | vty_out(vty,"%11s %-16u %-21s %-20s\n", " ", | |
7634 | bgp->l3vni, | |
7635 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf)), | |
7636 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
7637 | bgp->vrf_id)); | |
7638 | } | |
d62a17ae | 7639 | } |
7640 | ||
7641 | if (uj) { | |
7642 | json_object_object_add(json, "vrfs", json_vrfs); | |
7643 | ||
7644 | json_object_int_add(json, "totalVrfs", count); | |
7645 | ||
996c9314 LB |
7646 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
7647 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 7648 | json_object_free(json); |
7649 | } else { | |
7650 | if (count) | |
7651 | vty_out(vty, | |
7652 | "\nTotal number of VRFs (including default): %d\n", | |
7653 | count); | |
7654 | } | |
7655 | ||
7656 | return CMD_SUCCESS; | |
8386ac43 | 7657 | } |
7658 | ||
48ecf8f5 DS |
7659 | DEFUN (show_bgp_mac_hash, |
7660 | show_bgp_mac_hash_cmd, | |
7661 | "show bgp mac hash", | |
7662 | SHOW_STR | |
7663 | BGP_STR | |
7664 | "Mac Address\n" | |
7665 | "Mac Address database\n") | |
7666 | { | |
7667 | bgp_mac_dump_table(vty); | |
7668 | ||
7669 | return CMD_SUCCESS; | |
7670 | } | |
acf71666 | 7671 | |
e3b78da8 | 7672 | static void show_tip_entry(struct hash_bucket *bucket, void *args) |
acf71666 | 7673 | { |
0291c246 | 7674 | struct vty *vty = (struct vty *)args; |
e3b78da8 | 7675 | struct tip_addr *tip = (struct tip_addr *)bucket->data; |
acf71666 | 7676 | |
60466a63 | 7677 | vty_out(vty, "addr: %s, count: %d\n", inet_ntoa(tip->addr), |
acf71666 MK |
7678 | tip->refcnt); |
7679 | } | |
7680 | ||
7681 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
7682 | { | |
7683 | vty_out(vty, "self nexthop database:\n"); | |
af97a18b | 7684 | bgp_nexthop_show_address_hash(vty, bgp); |
acf71666 MK |
7685 | |
7686 | vty_out(vty, "Tunnel-ip database:\n"); | |
7687 | hash_iterate(bgp->tip_hash, | |
e3b78da8 | 7688 | (void (*)(struct hash_bucket *, void *))show_tip_entry, |
acf71666 MK |
7689 | vty); |
7690 | } | |
7691 | ||
15c81ca4 DS |
7692 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
7693 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
7694 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
7695 | "martian next-hops\n" |
7696 | "martian next-hop database\n") | |
acf71666 | 7697 | { |
0291c246 | 7698 | struct bgp *bgp = NULL; |
15c81ca4 | 7699 | int idx = 0; |
9a8bdf1c PG |
7700 | char *name = NULL; |
7701 | ||
7702 | /* [<vrf> VIEWVRFNAME] */ | |
7703 | if (argv_find(argv, argc, "vrf", &idx)) { | |
7704 | name = argv[idx + 1]->arg; | |
7705 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
7706 | name = NULL; | |
7707 | } else if (argv_find(argv, argc, "view", &idx)) | |
7708 | /* [<view> VIEWVRFNAME] */ | |
7709 | name = argv[idx + 1]->arg; | |
7710 | if (name) | |
7711 | bgp = bgp_lookup_by_name(name); | |
15c81ca4 DS |
7712 | else |
7713 | bgp = bgp_get_default(); | |
acf71666 | 7714 | |
acf71666 MK |
7715 | if (!bgp) { |
7716 | vty_out(vty, "%% No BGP process is configured\n"); | |
7717 | return CMD_WARNING; | |
7718 | } | |
7719 | bgp_show_martian_nexthops(vty, bgp); | |
7720 | ||
7721 | return CMD_SUCCESS; | |
7722 | } | |
7723 | ||
f412b39a | 7724 | DEFUN (show_bgp_memory, |
4bf6a362 | 7725 | show_bgp_memory_cmd, |
7fa12b13 | 7726 | "show [ip] bgp memory", |
4bf6a362 | 7727 | SHOW_STR |
3a2d747c | 7728 | IP_STR |
4bf6a362 PJ |
7729 | BGP_STR |
7730 | "Global BGP memory statistics\n") | |
7731 | { | |
d62a17ae | 7732 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
7733 | unsigned long count; | |
7734 | ||
7735 | /* RIB related usage stats */ | |
7736 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
7737 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
7738 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7739 | count * sizeof(struct bgp_node))); | |
7740 | ||
7741 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
7742 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
7743 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
4b7e6066 | 7744 | count * sizeof(struct bgp_path_info))); |
d62a17ae | 7745 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) |
7746 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
7747 | count, | |
4b7e6066 DS |
7748 | mtype_memstr( |
7749 | memstrbuf, sizeof(memstrbuf), | |
7750 | count * sizeof(struct bgp_path_info_extra))); | |
d62a17ae | 7751 | |
7752 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
7753 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
7754 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7755 | count * sizeof(struct bgp_static))); | |
7756 | ||
7757 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
7758 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
7759 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7760 | count * sizeof(struct bpacket))); | |
7761 | ||
7762 | /* Adj-In/Out */ | |
7763 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
7764 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
7765 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7766 | count * sizeof(struct bgp_adj_in))); | |
7767 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
7768 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
7769 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7770 | count * sizeof(struct bgp_adj_out))); | |
7771 | ||
7772 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
7773 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
7774 | count, | |
7775 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7776 | count * sizeof(struct bgp_nexthop_cache))); | |
7777 | ||
7778 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
7779 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
7780 | count, | |
7781 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7782 | count * sizeof(struct bgp_damp_info))); | |
7783 | ||
7784 | /* Attributes */ | |
7785 | count = attr_count(); | |
7786 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
7787 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7788 | count * sizeof(struct attr))); | |
7789 | ||
7790 | if ((count = attr_unknown_count())) | |
7791 | vty_out(vty, "%ld unknown attributes\n", count); | |
7792 | ||
7793 | /* AS_PATH attributes */ | |
7794 | count = aspath_count(); | |
7795 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
7796 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7797 | count * sizeof(struct aspath))); | |
7798 | ||
7799 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
7800 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
7801 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7802 | count * sizeof(struct assegment))); | |
7803 | ||
7804 | /* Other attributes */ | |
7805 | if ((count = community_count())) | |
7806 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
7807 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7808 | count * sizeof(struct community))); | |
d62a17ae | 7809 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
7810 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
7811 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7812 | count * sizeof(struct ecommunity))); | |
d62a17ae | 7813 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
7814 | vty_out(vty, | |
7815 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
7816 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7817 | count * sizeof(struct lcommunity))); | |
d62a17ae | 7818 | |
7819 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
7820 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
7821 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7822 | count * sizeof(struct cluster_list))); | |
7823 | ||
7824 | /* Peer related usage */ | |
7825 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
7826 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
7827 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7828 | count * sizeof(struct peer))); | |
7829 | ||
7830 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
7831 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
7832 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7833 | count * sizeof(struct peer_group))); | |
7834 | ||
7835 | /* Other */ | |
d62a17ae | 7836 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) |
7837 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
7838 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7839 | count * sizeof(regex_t))); | |
d62a17ae | 7840 | return CMD_SUCCESS; |
4bf6a362 | 7841 | } |
fee0f4c6 | 7842 | |
57a9c8a8 DS |
7843 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
7844 | { | |
7845 | json_object *bestpath = json_object_new_object(); | |
7846 | ||
7847 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_IGNORE)) | |
7848 | json_object_string_add(bestpath, "asPath", "ignore"); | |
7849 | ||
7850 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_CONFED)) | |
7851 | json_object_string_add(bestpath, "asPath", "confed"); | |
7852 | ||
7853 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { | |
a4d82a8a PZ |
7854 | if (bgp_flag_check(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) |
7855 | json_object_string_add(bestpath, "multiPathRelax", | |
57a9c8a8 DS |
7856 | "as-set"); |
7857 | else | |
a4d82a8a | 7858 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
7859 | "true"); |
7860 | } else | |
a4d82a8a | 7861 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 DS |
7862 | |
7863 | if (bgp_flag_check(bgp, BGP_FLAG_COMPARE_ROUTER_ID)) | |
7864 | json_object_string_add(bestpath, "compareRouterId", "true"); | |
7865 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED) | |
7866 | || bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
7867 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 7868 | json_object_string_add(bestpath, "med", "confed"); |
57a9c8a8 DS |
7869 | if (bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) |
7870 | json_object_string_add(bestpath, "med", | |
7871 | "missing-as-worst"); | |
7872 | else | |
7873 | json_object_string_add(bestpath, "med", "true"); | |
7874 | } | |
7875 | ||
7876 | json_object_object_add(json, "bestPath", bestpath); | |
7877 | } | |
7878 | ||
3577f1c5 DD |
7879 | /* Print the error code/subcode for why the peer is down */ |
7880 | static void bgp_show_peer_reset(struct vty * vty, struct peer *peer, | |
7881 | json_object *json_peer, bool use_json) | |
7882 | { | |
7883 | const char *code_str; | |
7884 | const char *subcode_str; | |
7885 | ||
7886 | if (use_json) { | |
7887 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
7888 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
7889 | char errorcodesubcode_hexstr[5]; | |
7890 | char errorcodesubcode_str[256]; | |
7891 | ||
7892 | code_str = bgp_notify_code_str(peer->notify.code); | |
7893 | subcode_str = bgp_notify_subcode_str( | |
7894 | peer->notify.code, | |
7895 | peer->notify.subcode); | |
7896 | ||
7897 | sprintf(errorcodesubcode_hexstr, "%02X%02X", | |
7898 | peer->notify.code, peer->notify.subcode); | |
7899 | json_object_string_add(json_peer, | |
7900 | "lastErrorCodeSubcode", | |
7901 | errorcodesubcode_hexstr); | |
7902 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
7903 | code_str, subcode_str); | |
7904 | json_object_string_add(json_peer, | |
7905 | "lastNotificationReason", | |
7906 | errorcodesubcode_str); | |
7907 | if (peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
7908 | && peer->notify.code == BGP_NOTIFY_CEASE | |
7909 | && (peer->notify.subcode | |
7910 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
7911 | || peer->notify.subcode | |
7912 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
7913 | && peer->notify.length) { | |
7914 | char msgbuf[1024]; | |
7915 | const char *msg_str; | |
7916 | ||
7917 | msg_str = bgp_notify_admin_message( | |
7918 | msgbuf, sizeof(msgbuf), | |
7919 | (uint8_t *)peer->notify.data, | |
7920 | peer->notify.length); | |
7921 | if (msg_str) | |
7922 | json_object_string_add( | |
7923 | json_peer, | |
7924 | "lastShutdownDescription", | |
7925 | msg_str); | |
7926 | } | |
7927 | ||
c258527b | 7928 | } |
3577f1c5 DD |
7929 | json_object_string_add(json_peer, "lastResetDueTo", |
7930 | peer_down_str[(int)peer->last_reset]); | |
05912a17 DD |
7931 | json_object_int_add(json_peer, "lastResetCode", |
7932 | peer->last_reset); | |
3577f1c5 DD |
7933 | } else { |
7934 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
7935 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
7936 | code_str = bgp_notify_code_str(peer->notify.code); | |
7937 | subcode_str = | |
7938 | bgp_notify_subcode_str(peer->notify.code, | |
7939 | peer->notify.subcode); | |
7940 | vty_out(vty, " Notification %s (%s%s)\n", | |
7941 | peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
7942 | ? "sent" | |
7943 | : "received", | |
7944 | code_str, subcode_str); | |
7945 | } else { | |
7946 | vty_out(vty, " %s\n", | |
7947 | peer_down_str[(int)peer->last_reset]); | |
7948 | } | |
7949 | } | |
7950 | } | |
7951 | ||
7952 | static inline bool bgp_has_peer_failed(struct peer *peer, afi_t afi, | |
7953 | safi_t safi) | |
7954 | { | |
7955 | return ((peer->status != Established) || | |
7956 | !peer->afc_recv[afi][safi]); | |
7957 | } | |
7958 | ||
7959 | static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp, | |
7960 | struct peer *peer, json_object *json_peer, | |
7961 | int max_neighbor_width, bool use_json) | |
7962 | { | |
7963 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
7964 | int len; | |
7965 | ||
7966 | if (use_json) { | |
7967 | if (peer_dynamic_neighbor(peer)) | |
7968 | json_object_boolean_true_add(json_peer, | |
7969 | "dynamicPeer"); | |
7970 | if (peer->hostname) | |
7971 | json_object_string_add(json_peer, "hostname", | |
7972 | peer->hostname); | |
7973 | ||
7974 | if (peer->domainname) | |
7975 | json_object_string_add(json_peer, "domainname", | |
7976 | peer->domainname); | |
7977 | json_object_int_add(json_peer, "connectionsEstablished", | |
7978 | peer->established); | |
7979 | json_object_int_add(json_peer, "connectionsDropped", | |
7980 | peer->dropped); | |
7981 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
7982 | use_json, json_peer); | |
7983 | if (peer->status == Established) | |
7984 | json_object_string_add(json_peer, "lastResetDueTo", | |
7985 | "AFI/SAFI Not Negotiated"); | |
7986 | else | |
7987 | bgp_show_peer_reset(NULL, peer, json_peer, true); | |
7988 | } else { | |
7989 | dn_flag[1] = '\0'; | |
7990 | dn_flag[0] = peer_dynamic_neighbor(peer) ? '*' : '\0'; | |
7991 | if (peer->hostname | |
7992 | && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) | |
7993 | len = vty_out(vty, "%s%s(%s)", dn_flag, | |
7994 | peer->hostname, peer->host); | |
7995 | else | |
7996 | len = vty_out(vty, "%s%s", dn_flag, peer->host); | |
7997 | ||
7998 | /* pad the neighbor column with spaces */ | |
7999 | if (len < max_neighbor_width) | |
8000 | vty_out(vty, "%*s", max_neighbor_width - len, | |
8001 | " "); | |
8002 | vty_out(vty, "%7d %7d %8s", peer->established, | |
8003 | peer->dropped, | |
8004 | peer_uptime(peer->uptime, timebuf, | |
8005 | BGP_UPTIME_LEN, 0, NULL)); | |
8006 | if (peer->status == Established) | |
8007 | vty_out(vty, " AFI/SAFI Not Negotiated\n"); | |
8008 | else | |
8009 | bgp_show_peer_reset(vty, peer, NULL, | |
8010 | false); | |
8011 | } | |
8012 | } | |
c258527b | 8013 | |
3577f1c5 | 8014 | |
718e3744 | 8015 | /* Show BGP peer's summary information. */ |
d62a17ae | 8016 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
3577f1c5 | 8017 | bool show_failed, bool use_json) |
d62a17ae | 8018 | { |
8019 | struct peer *peer; | |
8020 | struct listnode *node, *nnode; | |
8021 | unsigned int count = 0, dn_count = 0; | |
8022 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
8023 | char neighbor_buf[VTY_BUFSIZ]; | |
8024 | int neighbor_col_default_width = 16; | |
3577f1c5 | 8025 | int len, failed_count = 0; |
d62a17ae | 8026 | int max_neighbor_width = 0; |
8027 | int pfx_rcd_safi; | |
3c13337d | 8028 | json_object *json = NULL; |
d62a17ae | 8029 | json_object *json_peer = NULL; |
8030 | json_object *json_peers = NULL; | |
50e05855 | 8031 | struct peer_af *paf; |
d62a17ae | 8032 | |
8033 | /* labeled-unicast routes are installed in the unicast table so in order | |
8034 | * to | |
8035 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
8036 | */ | |
3577f1c5 | 8037 | |
d62a17ae | 8038 | if (safi == SAFI_LABELED_UNICAST) |
8039 | pfx_rcd_safi = SAFI_UNICAST; | |
8040 | else | |
8041 | pfx_rcd_safi = safi; | |
8042 | ||
8043 | if (use_json) { | |
3c13337d | 8044 | json = json_object_new_object(); |
d62a17ae | 8045 | json_peers = json_object_new_object(); |
3577f1c5 DD |
8046 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
8047 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
8048 | continue; | |
8049 | ||
8050 | if (peer->afc[afi][safi]) { | |
8051 | /* See if we have at least a single failed peer */ | |
8052 | if (bgp_has_peer_failed(peer, afi, safi)) | |
8053 | failed_count++; | |
8054 | count++; | |
8055 | } | |
8056 | if (peer_dynamic_neighbor(peer)) | |
8057 | dn_count++; | |
8058 | } | |
c258527b | 8059 | |
d62a17ae | 8060 | } else { |
8061 | /* Loop over all neighbors that will be displayed to determine | |
8062 | * how many | |
8063 | * characters are needed for the Neighbor column | |
8064 | */ | |
8065 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
8066 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
8067 | continue; | |
8068 | ||
8069 | if (peer->afc[afi][safi]) { | |
8070 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
8071 | if (peer_dynamic_neighbor(peer)) | |
8072 | dn_flag[0] = '*'; | |
8073 | ||
8074 | if (peer->hostname | |
8075 | && bgp_flag_check(bgp, | |
8076 | BGP_FLAG_SHOW_HOSTNAME)) | |
8077 | sprintf(neighbor_buf, "%s%s(%s) ", | |
8078 | dn_flag, peer->hostname, | |
8079 | peer->host); | |
8080 | else | |
8081 | sprintf(neighbor_buf, "%s%s ", dn_flag, | |
8082 | peer->host); | |
8083 | ||
8084 | len = strlen(neighbor_buf); | |
8085 | ||
8086 | if (len > max_neighbor_width) | |
8087 | max_neighbor_width = len; | |
c258527b | 8088 | |
3577f1c5 DD |
8089 | /* See if we have at least a single failed peer */ |
8090 | if (bgp_has_peer_failed(peer, afi, safi)) | |
8091 | failed_count++; | |
8092 | count++; | |
d62a17ae | 8093 | } |
8094 | } | |
f933309e | 8095 | |
d62a17ae | 8096 | /* Originally we displayed the Neighbor column as 16 |
8097 | * characters wide so make that the default | |
8098 | */ | |
8099 | if (max_neighbor_width < neighbor_col_default_width) | |
8100 | max_neighbor_width = neighbor_col_default_width; | |
8101 | } | |
f933309e | 8102 | |
3577f1c5 DD |
8103 | if (show_failed && !failed_count) { |
8104 | if (use_json) { | |
8105 | json_object_int_add(json, "failedPeersCount", 0); | |
8106 | json_object_int_add(json, "dynamicPeers", dn_count); | |
c258527b | 8107 | json_object_int_add(json, "totalPeers", count); |
3577f1c5 DD |
8108 | |
8109 | vty_out(vty, "%s\n", json_object_to_json_string_ext( | |
8110 | json, JSON_C_TO_STRING_PRETTY)); | |
8111 | json_object_free(json); | |
8112 | } else { | |
8113 | vty_out(vty, "%% No failed BGP neighbors found\n"); | |
8114 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
8115 | } | |
8116 | return CMD_SUCCESS; | |
8117 | } | |
c258527b | 8118 | |
3577f1c5 | 8119 | count = 0; /* Reset the value as its used again */ |
d62a17ae | 8120 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
8121 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
8122 | continue; | |
8123 | ||
ea47320b DL |
8124 | if (!peer->afc[afi][safi]) |
8125 | continue; | |
d62a17ae | 8126 | |
ea47320b DL |
8127 | if (!count) { |
8128 | unsigned long ents; | |
8129 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 8130 | int64_t vrf_id_ui; |
d62a17ae | 8131 | |
a4d82a8a PZ |
8132 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
8133 | ? -1 | |
8134 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
8135 | |
8136 | /* Usage summary and header */ | |
8137 | if (use_json) { | |
8138 | json_object_string_add( | |
8139 | json, "routerId", | |
8140 | inet_ntoa(bgp->router_id)); | |
60466a63 QY |
8141 | json_object_int_add(json, "as", bgp->as); |
8142 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
8143 | json_object_string_add( |
8144 | json, "vrfName", | |
8145 | (bgp->inst_type | |
8146 | == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 8147 | ? VRF_DEFAULT_NAME |
ea47320b DL |
8148 | : bgp->name); |
8149 | } else { | |
8150 | vty_out(vty, | |
8151 | "BGP router identifier %s, local AS number %u vrf-id %d", | |
60466a63 | 8152 | inet_ntoa(bgp->router_id), bgp->as, |
a4d82a8a PZ |
8153 | bgp->vrf_id == VRF_UNKNOWN |
8154 | ? -1 | |
8155 | : (int)bgp->vrf_id); | |
ea47320b DL |
8156 | vty_out(vty, "\n"); |
8157 | } | |
d62a17ae | 8158 | |
ea47320b | 8159 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 8160 | if (use_json) { |
ea47320b | 8161 | json_object_int_add( |
60466a63 | 8162 | json, "updateDelayLimit", |
ea47320b | 8163 | bgp->v_update_delay); |
d62a17ae | 8164 | |
ea47320b DL |
8165 | if (bgp->v_update_delay |
8166 | != bgp->v_establish_wait) | |
d62a17ae | 8167 | json_object_int_add( |
8168 | json, | |
ea47320b DL |
8169 | "updateDelayEstablishWait", |
8170 | bgp->v_establish_wait); | |
d62a17ae | 8171 | |
60466a63 | 8172 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
8173 | json_object_string_add( |
8174 | json, | |
8175 | "updateDelayFirstNeighbor", | |
8176 | bgp->update_delay_begin_time); | |
8177 | json_object_boolean_true_add( | |
8178 | json, | |
8179 | "updateDelayInProgress"); | |
8180 | } else { | |
8181 | if (bgp->update_delay_over) { | |
d62a17ae | 8182 | json_object_string_add( |
8183 | json, | |
8184 | "updateDelayFirstNeighbor", | |
8185 | bgp->update_delay_begin_time); | |
ea47320b | 8186 | json_object_string_add( |
d62a17ae | 8187 | json, |
ea47320b DL |
8188 | "updateDelayBestpathResumed", |
8189 | bgp->update_delay_end_time); | |
8190 | json_object_string_add( | |
d62a17ae | 8191 | json, |
ea47320b DL |
8192 | "updateDelayZebraUpdateResume", |
8193 | bgp->update_delay_zebra_resume_time); | |
8194 | json_object_string_add( | |
8195 | json, | |
8196 | "updateDelayPeerUpdateResume", | |
8197 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 8198 | } |
ea47320b DL |
8199 | } |
8200 | } else { | |
8201 | vty_out(vty, | |
8202 | "Read-only mode update-delay limit: %d seconds\n", | |
8203 | bgp->v_update_delay); | |
8204 | if (bgp->v_update_delay | |
8205 | != bgp->v_establish_wait) | |
d62a17ae | 8206 | vty_out(vty, |
ea47320b DL |
8207 | " Establish wait: %d seconds\n", |
8208 | bgp->v_establish_wait); | |
d62a17ae | 8209 | |
60466a63 | 8210 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
8211 | vty_out(vty, |
8212 | " First neighbor established: %s\n", | |
8213 | bgp->update_delay_begin_time); | |
8214 | vty_out(vty, | |
8215 | " Delay in progress\n"); | |
8216 | } else { | |
8217 | if (bgp->update_delay_over) { | |
d62a17ae | 8218 | vty_out(vty, |
8219 | " First neighbor established: %s\n", | |
8220 | bgp->update_delay_begin_time); | |
8221 | vty_out(vty, | |
ea47320b DL |
8222 | " Best-paths resumed: %s\n", |
8223 | bgp->update_delay_end_time); | |
8224 | vty_out(vty, | |
8225 | " zebra update resumed: %s\n", | |
8226 | bgp->update_delay_zebra_resume_time); | |
8227 | vty_out(vty, | |
8228 | " peers update resumed: %s\n", | |
8229 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 8230 | } |
8231 | } | |
8232 | } | |
ea47320b | 8233 | } |
d62a17ae | 8234 | |
ea47320b DL |
8235 | if (use_json) { |
8236 | if (bgp_maxmed_onstartup_configured(bgp) | |
8237 | && bgp->maxmed_active) | |
8238 | json_object_boolean_true_add( | |
60466a63 | 8239 | json, "maxMedOnStartup"); |
ea47320b DL |
8240 | if (bgp->v_maxmed_admin) |
8241 | json_object_boolean_true_add( | |
60466a63 | 8242 | json, "maxMedAdministrative"); |
d62a17ae | 8243 | |
ea47320b DL |
8244 | json_object_int_add( |
8245 | json, "tableVersion", | |
60466a63 | 8246 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 8247 | |
60466a63 QY |
8248 | ents = bgp_table_count(bgp->rib[afi][safi]); |
8249 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
8250 | json_object_int_add( |
8251 | json, "ribMemory", | |
8252 | ents * sizeof(struct bgp_node)); | |
d62a17ae | 8253 | |
210ec2a0 | 8254 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 QY |
8255 | json_object_int_add(json, "peerCount", ents); |
8256 | json_object_int_add(json, "peerMemory", | |
8257 | ents * sizeof(struct peer)); | |
d62a17ae | 8258 | |
ea47320b DL |
8259 | if ((ents = listcount(bgp->group))) { |
8260 | json_object_int_add( | |
60466a63 | 8261 | json, "peerGroupCount", ents); |
ea47320b DL |
8262 | json_object_int_add( |
8263 | json, "peerGroupMemory", | |
996c9314 LB |
8264 | ents * sizeof(struct |
8265 | peer_group)); | |
ea47320b | 8266 | } |
d62a17ae | 8267 | |
ea47320b DL |
8268 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
8269 | BGP_CONFIG_DAMPENING)) | |
8270 | json_object_boolean_true_add( | |
60466a63 | 8271 | json, "dampeningEnabled"); |
ea47320b DL |
8272 | } else { |
8273 | if (bgp_maxmed_onstartup_configured(bgp) | |
8274 | && bgp->maxmed_active) | |
d62a17ae | 8275 | vty_out(vty, |
ea47320b DL |
8276 | "Max-med on-startup active\n"); |
8277 | if (bgp->v_maxmed_admin) | |
d62a17ae | 8278 | vty_out(vty, |
ea47320b | 8279 | "Max-med administrative active\n"); |
d62a17ae | 8280 | |
60466a63 QY |
8281 | vty_out(vty, "BGP table version %" PRIu64 "\n", |
8282 | bgp_table_version(bgp->rib[afi][safi])); | |
d62a17ae | 8283 | |
60466a63 | 8284 | ents = bgp_table_count(bgp->rib[afi][safi]); |
ea47320b DL |
8285 | vty_out(vty, |
8286 | "RIB entries %ld, using %s of memory\n", | |
8287 | ents, | |
996c9314 LB |
8288 | mtype_memstr(memstrbuf, |
8289 | sizeof(memstrbuf), | |
8290 | ents * sizeof(struct | |
8291 | bgp_node))); | |
ea47320b DL |
8292 | |
8293 | /* Peer related usage */ | |
210ec2a0 | 8294 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 | 8295 | vty_out(vty, "Peers %ld, using %s of memory\n", |
ea47320b DL |
8296 | ents, |
8297 | mtype_memstr( | |
60466a63 QY |
8298 | memstrbuf, sizeof(memstrbuf), |
8299 | ents * sizeof(struct peer))); | |
ea47320b DL |
8300 | |
8301 | if ((ents = listcount(bgp->group))) | |
d62a17ae | 8302 | vty_out(vty, |
ea47320b | 8303 | "Peer groups %ld, using %s of memory\n", |
d62a17ae | 8304 | ents, |
8305 | mtype_memstr( | |
8306 | memstrbuf, | |
8307 | sizeof(memstrbuf), | |
996c9314 LB |
8308 | ents * sizeof(struct |
8309 | peer_group))); | |
d62a17ae | 8310 | |
ea47320b DL |
8311 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
8312 | BGP_CONFIG_DAMPENING)) | |
60466a63 | 8313 | vty_out(vty, "Dampening enabled.\n"); |
ea47320b | 8314 | vty_out(vty, "\n"); |
d62a17ae | 8315 | |
ea47320b DL |
8316 | /* Subtract 8 here because 'Neighbor' is |
8317 | * 8 characters */ | |
8318 | vty_out(vty, "Neighbor"); | |
60466a63 QY |
8319 | vty_out(vty, "%*s", max_neighbor_width - 8, |
8320 | " "); | |
3577f1c5 DD |
8321 | if (show_failed) |
8322 | vty_out(vty, "EstdCnt DropCnt ResetTime Reason\n"); | |
8323 | else | |
8324 | vty_out(vty, | |
ea47320b | 8325 | "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n"); |
d62a17ae | 8326 | } |
ea47320b | 8327 | } |
d62a17ae | 8328 | |
ea47320b | 8329 | count++; |
3577f1c5 DD |
8330 | /* Works for both failed & successful cases */ |
8331 | if (peer_dynamic_neighbor(peer)) | |
8332 | dn_count++; | |
d62a17ae | 8333 | |
ea47320b | 8334 | if (use_json) { |
3577f1c5 DD |
8335 | json_peer = NULL; |
8336 | ||
8337 | if (show_failed && | |
8338 | bgp_has_peer_failed(peer, afi, safi)) { | |
8339 | json_peer = json_object_new_object(); | |
8340 | bgp_show_failed_summary(vty, bgp, peer, | |
8341 | json_peer, 0, use_json); | |
8342 | } else if (!show_failed) { | |
8343 | json_peer = json_object_new_object(); | |
8344 | if (peer_dynamic_neighbor(peer)) { | |
8345 | json_object_boolean_true_add(json_peer, | |
8346 | "dynamicPeer"); | |
8347 | } | |
d62a17ae | 8348 | |
3577f1c5 DD |
8349 | if (peer->hostname) |
8350 | json_object_string_add(json_peer, "hostname", | |
8351 | peer->hostname); | |
8352 | ||
8353 | if (peer->domainname) | |
8354 | json_object_string_add(json_peer, "domainname", | |
8355 | peer->domainname); | |
8356 | ||
8357 | json_object_int_add(json_peer, "remoteAs", peer->as); | |
8358 | json_object_int_add(json_peer, "version", 4); | |
8359 | json_object_int_add(json_peer, "msgRcvd", | |
8360 | PEER_TOTAL_RX(peer)); | |
8361 | json_object_int_add(json_peer, "msgSent", | |
8362 | PEER_TOTAL_TX(peer)); | |
8363 | ||
8364 | json_object_int_add(json_peer, "tableVersion", | |
8365 | peer->version[afi][safi]); | |
8366 | json_object_int_add(json_peer, "outq", | |
8367 | peer->obuf->count); | |
8368 | json_object_int_add(json_peer, "inq", 0); | |
8369 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
8370 | use_json, json_peer); | |
8371 | ||
8372 | /* | |
8373 | * Adding "pfxRcd" field to match with the corresponding | |
8374 | * CLI. "prefixReceivedCount" will be deprecated in | |
8375 | * future. | |
8376 | */ | |
8377 | json_object_int_add(json_peer, "prefixReceivedCount", | |
8378 | peer->pcount[afi][pfx_rcd_safi]); | |
8379 | json_object_int_add(json_peer, "pfxRcd", | |
8380 | peer->pcount[afi][pfx_rcd_safi]); | |
8381 | ||
8382 | paf = peer_af_find(peer, afi, pfx_rcd_safi); | |
8383 | if (paf && PAF_SUBGRP(paf)) | |
8384 | json_object_int_add(json_peer, | |
8385 | "pfxSnt", | |
8386 | (PAF_SUBGRP(paf))->scount); | |
8387 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
8388 | json_object_string_add(json_peer, "state", | |
8389 | "Idle (Admin)"); | |
8390 | else if (peer->afc_recv[afi][safi]) | |
8391 | json_object_string_add( | |
8392 | json_peer, "state", | |
8393 | lookup_msg(bgp_status_msg, peer->status, | |
8394 | NULL)); | |
8395 | else if (CHECK_FLAG(peer->sflags, | |
8396 | PEER_STATUS_PREFIX_OVERFLOW)) | |
8397 | json_object_string_add(json_peer, "state", | |
8398 | "Idle (PfxCt)"); | |
8399 | else | |
8400 | json_object_string_add( | |
8401 | json_peer, "state", | |
8402 | lookup_msg(bgp_status_msg, peer->status, | |
8403 | NULL)); | |
200116db DD |
8404 | json_object_int_add(json_peer, "connectionsEstablished", |
8405 | peer->established); | |
8406 | json_object_int_add(json_peer, "connectionsDropped", | |
8407 | peer->dropped); | |
b4e9dcba | 8408 | } |
3577f1c5 DD |
8409 | /* Avoid creating empty peer dicts in JSON */ |
8410 | if (json_peer == NULL) | |
8411 | continue; | |
ea47320b DL |
8412 | |
8413 | if (peer->conf_if) | |
60466a63 | 8414 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
8415 | "interface"); |
8416 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
8417 | json_object_string_add(json_peer, "idType", |
8418 | "ipv4"); | |
ea47320b | 8419 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
8420 | json_object_string_add(json_peer, "idType", |
8421 | "ipv6"); | |
ea47320b DL |
8422 | json_object_object_add(json_peers, peer->host, |
8423 | json_peer); | |
8424 | } else { | |
3577f1c5 DD |
8425 | if (show_failed && |
8426 | bgp_has_peer_failed(peer, afi, safi)) { | |
8427 | bgp_show_failed_summary(vty, bgp, peer, NULL, | |
8428 | max_neighbor_width, | |
8429 | use_json); | |
8430 | } else if (!show_failed) { | |
8431 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
8432 | if (peer_dynamic_neighbor(peer)) { | |
8433 | dn_flag[0] = '*'; | |
8434 | } | |
d62a17ae | 8435 | |
3577f1c5 DD |
8436 | if (peer->hostname |
8437 | && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) | |
8438 | len = vty_out(vty, "%s%s(%s)", dn_flag, | |
8439 | peer->hostname, peer->host); | |
d62a17ae | 8440 | else |
3577f1c5 DD |
8441 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
8442 | ||
8443 | /* pad the neighbor column with spaces */ | |
8444 | if (len < max_neighbor_width) | |
8445 | vty_out(vty, "%*s", max_neighbor_width - len, | |
8446 | " "); | |
8447 | ||
8448 | vty_out(vty, "4 %10u %7u %7u %8" PRIu64 " %4d %4zd %8s", | |
8449 | peer->as, PEER_TOTAL_RX(peer), | |
8450 | PEER_TOTAL_TX(peer), peer->version[afi][safi], | |
8451 | 0, peer->obuf->count, | |
8452 | peer_uptime(peer->uptime, timebuf, | |
8453 | BGP_UPTIME_LEN, 0, NULL)); | |
8454 | ||
8455 | if (peer->status == Established) | |
8456 | if (peer->afc_recv[afi][safi]) | |
a0a87037 DA |
8457 | vty_out(vty, " %12" PRIu32, |
8458 | peer->pcount | |
8459 | [afi] | |
8460 | [pfx_rcd_safi]); | |
3577f1c5 DD |
8461 | else |
8462 | vty_out(vty, " NoNeg"); | |
8463 | else { | |
8464 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
8465 | vty_out(vty, " Idle (Admin)"); | |
8466 | else if (CHECK_FLAG( | |
8467 | peer->sflags, | |
8468 | PEER_STATUS_PREFIX_OVERFLOW)) | |
8469 | vty_out(vty, " Idle (PfxCt)"); | |
8470 | else | |
8471 | vty_out(vty, " %12s", | |
8472 | lookup_msg(bgp_status_msg, | |
8473 | peer->status, NULL)); | |
8474 | } | |
8475 | vty_out(vty, "\n"); | |
d62a17ae | 8476 | } |
3577f1c5 | 8477 | |
d62a17ae | 8478 | } |
8479 | } | |
f933309e | 8480 | |
d62a17ae | 8481 | if (use_json) { |
8482 | json_object_object_add(json, "peers", json_peers); | |
3577f1c5 | 8483 | json_object_int_add(json, "failedPeers", failed_count); |
d62a17ae | 8484 | json_object_int_add(json, "totalPeers", count); |
8485 | json_object_int_add(json, "dynamicPeers", dn_count); | |
8486 | ||
3577f1c5 DD |
8487 | if (!show_failed) |
8488 | bgp_show_bestpath_json(bgp, json); | |
57a9c8a8 | 8489 | |
996c9314 LB |
8490 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
8491 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 8492 | json_object_free(json); |
8493 | } else { | |
8494 | if (count) | |
8495 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
8496 | else { | |
d6ceaca3 | 8497 | vty_out(vty, "No %s neighbor is configured\n", |
5cb5f4d0 | 8498 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 8499 | } |
b05a1c8b | 8500 | |
d6ceaca3 | 8501 | if (dn_count) { |
d62a17ae | 8502 | vty_out(vty, "* - dynamic neighbor\n"); |
8503 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
8504 | dn_count, bgp->dynamic_neighbors_limit); | |
8505 | } | |
8506 | } | |
1ff9a340 | 8507 | |
d62a17ae | 8508 | return CMD_SUCCESS; |
718e3744 | 8509 | } |
8510 | ||
d62a17ae | 8511 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
3577f1c5 | 8512 | int safi, bool show_failed, bool use_json) |
d62a17ae | 8513 | { |
8514 | int is_first = 1; | |
8515 | int afi_wildcard = (afi == AFI_MAX); | |
8516 | int safi_wildcard = (safi == SAFI_MAX); | |
8517 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 8518 | bool nbr_output = false; |
d62a17ae | 8519 | |
8520 | if (use_json && is_wildcard) | |
8521 | vty_out(vty, "{\n"); | |
8522 | if (afi_wildcard) | |
8523 | afi = 1; /* AFI_IP */ | |
8524 | while (afi < AFI_MAX) { | |
8525 | if (safi_wildcard) | |
8526 | safi = 1; /* SAFI_UNICAST */ | |
8527 | while (safi < SAFI_MAX) { | |
318cac96 | 8528 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 8529 | nbr_output = true; |
f86897b9 | 8530 | |
d62a17ae | 8531 | if (is_wildcard) { |
8532 | /* | |
8533 | * So limit output to those afi/safi | |
8534 | * pairs that | |
8535 | * actualy have something interesting in | |
8536 | * them | |
8537 | */ | |
8538 | if (use_json) { | |
d62a17ae | 8539 | if (!is_first) |
8540 | vty_out(vty, ",\n"); | |
8541 | else | |
8542 | is_first = 0; | |
8543 | ||
8544 | vty_out(vty, "\"%s\":", | |
5cb5f4d0 DD |
8545 | get_afi_safi_str(afi, |
8546 | safi, | |
8547 | true)); | |
d62a17ae | 8548 | } else { |
8549 | vty_out(vty, "\n%s Summary:\n", | |
5cb5f4d0 DD |
8550 | get_afi_safi_str(afi, |
8551 | safi, | |
8552 | false)); | |
d62a17ae | 8553 | } |
8554 | } | |
3577f1c5 DD |
8555 | bgp_show_summary(vty, bgp, afi, safi, show_failed, |
8556 | use_json); | |
d62a17ae | 8557 | } |
8558 | safi++; | |
d62a17ae | 8559 | if (!safi_wildcard) |
8560 | safi = SAFI_MAX; | |
8561 | } | |
8562 | afi++; | |
ee851c8c | 8563 | if (!afi_wildcard) |
d62a17ae | 8564 | afi = AFI_MAX; |
8565 | } | |
8566 | ||
8567 | if (use_json && is_wildcard) | |
8568 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
8569 | else if (!nbr_output) { |
8570 | if (use_json) | |
8571 | vty_out(vty, "{}\n"); | |
8572 | else | |
8573 | vty_out(vty, "%% No BGP neighbors found\n"); | |
8574 | } | |
d62a17ae | 8575 | } |
8576 | ||
8577 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
3577f1c5 DD |
8578 | safi_t safi, bool show_failed, |
8579 | bool use_json) | |
d62a17ae | 8580 | { |
8581 | struct listnode *node, *nnode; | |
8582 | struct bgp *bgp; | |
d62a17ae | 8583 | int is_first = 1; |
9f049418 | 8584 | bool nbr_output = false; |
d62a17ae | 8585 | |
8586 | if (use_json) | |
8587 | vty_out(vty, "{\n"); | |
8588 | ||
8589 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 8590 | nbr_output = true; |
d62a17ae | 8591 | if (use_json) { |
d62a17ae | 8592 | if (!is_first) |
8593 | vty_out(vty, ",\n"); | |
8594 | else | |
8595 | is_first = 0; | |
8596 | ||
8597 | vty_out(vty, "\"%s\":", | |
8598 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 8599 | ? VRF_DEFAULT_NAME |
d62a17ae | 8600 | : bgp->name); |
8601 | } else { | |
8602 | vty_out(vty, "\nInstance %s:\n", | |
8603 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 8604 | ? VRF_DEFAULT_NAME |
d62a17ae | 8605 | : bgp->name); |
8606 | } | |
3577f1c5 DD |
8607 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
8608 | use_json); | |
d62a17ae | 8609 | } |
8610 | ||
8611 | if (use_json) | |
8612 | vty_out(vty, "}\n"); | |
9f049418 DS |
8613 | else if (!nbr_output) |
8614 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 8615 | } |
8616 | ||
8617 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
3577f1c5 | 8618 | safi_t safi, bool show_failed, bool use_json) |
d62a17ae | 8619 | { |
8620 | struct bgp *bgp; | |
8621 | ||
8622 | if (name) { | |
8623 | if (strmatch(name, "all")) { | |
8624 | bgp_show_all_instances_summary_vty(vty, afi, safi, | |
3577f1c5 | 8625 | show_failed, |
d62a17ae | 8626 | use_json); |
8627 | return CMD_SUCCESS; | |
8628 | } else { | |
8629 | bgp = bgp_lookup_by_name(name); | |
8630 | ||
8631 | if (!bgp) { | |
8632 | if (use_json) | |
8633 | vty_out(vty, "{}\n"); | |
8634 | else | |
8635 | vty_out(vty, | |
ca61fd25 | 8636 | "%% BGP instance not found\n"); |
d62a17ae | 8637 | return CMD_WARNING; |
8638 | } | |
8639 | ||
f86897b9 | 8640 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, |
3577f1c5 | 8641 | show_failed, use_json); |
d62a17ae | 8642 | return CMD_SUCCESS; |
8643 | } | |
8644 | } | |
8645 | ||
8646 | bgp = bgp_get_default(); | |
8647 | ||
8648 | if (bgp) | |
3577f1c5 DD |
8649 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
8650 | use_json); | |
9f049418 | 8651 | else { |
ca61fd25 DS |
8652 | if (use_json) |
8653 | vty_out(vty, "{}\n"); | |
8654 | else | |
8655 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
8656 | return CMD_WARNING; |
8657 | } | |
d62a17ae | 8658 | |
8659 | return CMD_SUCCESS; | |
4fb25c53 DW |
8660 | } |
8661 | ||
716b2d8a | 8662 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 8663 | DEFUN (show_ip_bgp_summary, |
718e3744 | 8664 | show_ip_bgp_summary_cmd, |
3577f1c5 | 8665 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] summary [failed] [json]", |
718e3744 | 8666 | SHOW_STR |
8667 | IP_STR | |
8668 | BGP_STR | |
8386ac43 | 8669 | BGP_INSTANCE_HELP_STR |
46f296b4 | 8670 | BGP_AFI_HELP_STR |
dd6bd0f1 | 8671 | BGP_SAFI_WITH_LABEL_HELP_STR |
b05a1c8b | 8672 | "Summary of BGP neighbor status\n" |
3577f1c5 | 8673 | "Show only sessions not in Established state\n" |
9973d184 | 8674 | JSON_STR) |
718e3744 | 8675 | { |
d62a17ae | 8676 | char *vrf = NULL; |
8677 | afi_t afi = AFI_MAX; | |
8678 | safi_t safi = SAFI_MAX; | |
3577f1c5 | 8679 | bool show_failed = false; |
d62a17ae | 8680 | |
8681 | int idx = 0; | |
8682 | ||
8683 | /* show [ip] bgp */ | |
8684 | if (argv_find(argv, argc, "ip", &idx)) | |
8685 | afi = AFI_IP; | |
9a8bdf1c PG |
8686 | /* [<vrf> VIEWVRFNAME] */ |
8687 | if (argv_find(argv, argc, "vrf", &idx)) { | |
8688 | vrf = argv[idx + 1]->arg; | |
8689 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
8690 | vrf = NULL; | |
8691 | } else if (argv_find(argv, argc, "view", &idx)) | |
8692 | /* [<view> VIEWVRFNAME] */ | |
8693 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 8694 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
8695 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
8696 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
8697 | } | |
8698 | ||
3577f1c5 DD |
8699 | if (argv_find(argv, argc, "failed", &idx)) |
8700 | show_failed = true; | |
8701 | ||
9f049418 | 8702 | bool uj = use_json(argc, argv); |
d62a17ae | 8703 | |
3577f1c5 | 8704 | return bgp_show_summary_vty(vty, vrf, afi, safi, show_failed, uj); |
d62a17ae | 8705 | } |
8706 | ||
5cb5f4d0 | 8707 | const char *get_afi_safi_str(afi_t afi, safi_t safi, bool for_json) |
d62a17ae | 8708 | { |
5cb5f4d0 DD |
8709 | if (for_json) |
8710 | return get_afi_safi_json_str(afi, safi); | |
d62a17ae | 8711 | else |
5cb5f4d0 | 8712 | return get_afi_safi_vty_str(afi, safi); |
27162734 LB |
8713 | } |
8714 | ||
718e3744 | 8715 | /* Show BGP peer's information. */ |
d1927ebe | 8716 | enum show_type { show_all, show_peer, show_ipv4_all, show_ipv6_all, show_ipv4_peer, show_ipv6_peer }; |
d62a17ae | 8717 | |
8718 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
8719 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
8720 | uint16_t adv_smcap, uint16_t adv_rmcap, |
8721 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 8722 | bool use_json, json_object *json_pref) |
d62a17ae | 8723 | { |
8724 | /* Send-Mode */ | |
8725 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
8726 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
8727 | if (use_json) { | |
8728 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
8729 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8730 | json_object_string_add(json_pref, "sendMode", | |
8731 | "advertisedAndReceived"); | |
8732 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
8733 | json_object_string_add(json_pref, "sendMode", | |
8734 | "advertised"); | |
8735 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8736 | json_object_string_add(json_pref, "sendMode", | |
8737 | "received"); | |
8738 | } else { | |
8739 | vty_out(vty, " Send-mode: "); | |
8740 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
8741 | vty_out(vty, "advertised"); | |
8742 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8743 | vty_out(vty, "%sreceived", | |
8744 | CHECK_FLAG(p->af_cap[afi][safi], | |
8745 | adv_smcap) | |
8746 | ? ", " | |
8747 | : ""); | |
8748 | vty_out(vty, "\n"); | |
8749 | } | |
8750 | } | |
8751 | ||
8752 | /* Receive-Mode */ | |
8753 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
8754 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
8755 | if (use_json) { | |
8756 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
8757 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8758 | json_object_string_add(json_pref, "recvMode", | |
8759 | "advertisedAndReceived"); | |
8760 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
8761 | json_object_string_add(json_pref, "recvMode", | |
8762 | "advertised"); | |
8763 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8764 | json_object_string_add(json_pref, "recvMode", | |
8765 | "received"); | |
8766 | } else { | |
8767 | vty_out(vty, " Receive-mode: "); | |
8768 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
8769 | vty_out(vty, "advertised"); | |
8770 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8771 | vty_out(vty, "%sreceived", | |
8772 | CHECK_FLAG(p->af_cap[afi][safi], | |
8773 | adv_rmcap) | |
8774 | ? ", " | |
8775 | : ""); | |
8776 | vty_out(vty, "\n"); | |
8777 | } | |
8778 | } | |
8779 | } | |
8780 | ||
8781 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, | |
9f049418 | 8782 | safi_t safi, bool use_json, |
d62a17ae | 8783 | json_object *json_neigh) |
8784 | { | |
0291c246 MK |
8785 | struct bgp_filter *filter; |
8786 | struct peer_af *paf; | |
8787 | char orf_pfx_name[BUFSIZ]; | |
8788 | int orf_pfx_count; | |
8789 | json_object *json_af = NULL; | |
8790 | json_object *json_prefA = NULL; | |
8791 | json_object *json_prefB = NULL; | |
8792 | json_object *json_addr = NULL; | |
d62a17ae | 8793 | |
8794 | if (use_json) { | |
8795 | json_addr = json_object_new_object(); | |
8796 | json_af = json_object_new_object(); | |
8797 | filter = &p->filter[afi][safi]; | |
8798 | ||
8799 | if (peer_group_active(p)) | |
8800 | json_object_string_add(json_addr, "peerGroupMember", | |
8801 | p->group->name); | |
8802 | ||
8803 | paf = peer_af_find(p, afi, safi); | |
8804 | if (paf && PAF_SUBGRP(paf)) { | |
8805 | json_object_int_add(json_addr, "updateGroupId", | |
8806 | PAF_UPDGRP(paf)->id); | |
8807 | json_object_int_add(json_addr, "subGroupId", | |
8808 | PAF_SUBGRP(paf)->id); | |
8809 | json_object_int_add(json_addr, "packetQueueLength", | |
8810 | bpacket_queue_virtual_length(paf)); | |
8811 | } | |
8812 | ||
8813 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8814 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8815 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8816 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8817 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8818 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8819 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
8820 | json_object_int_add(json_af, "orfType", | |
8821 | ORF_TYPE_PREFIX); | |
8822 | json_prefA = json_object_new_object(); | |
8823 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
8824 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
8825 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8826 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
8827 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
8828 | use_json, json_prefA); | |
8829 | json_object_object_add(json_af, "orfPrefixList", | |
8830 | json_prefA); | |
8831 | } | |
8832 | ||
8833 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8834 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8835 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8836 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8837 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8838 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8839 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
8840 | json_object_int_add(json_af, "orfOldType", | |
8841 | ORF_TYPE_PREFIX_OLD); | |
8842 | json_prefB = json_object_new_object(); | |
8843 | bgp_show_peer_afi_orf_cap( | |
8844 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
8845 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8846 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
8847 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
8848 | json_prefB); | |
8849 | json_object_object_add(json_af, "orfOldPrefixList", | |
8850 | json_prefB); | |
8851 | } | |
8852 | ||
8853 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8854 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8855 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8856 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8857 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8858 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8859 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8860 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8861 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
8862 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8863 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
8864 | json_object_object_add(json_addr, "afDependentCap", | |
8865 | json_af); | |
8866 | else | |
8867 | json_object_free(json_af); | |
8868 | ||
8869 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
8870 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
8871 | NULL, afi, orf_pfx_name, use_json); | |
8872 | ||
8873 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8874 | PEER_STATUS_ORF_PREFIX_SEND) | |
8875 | || orf_pfx_count) { | |
8876 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8877 | PEER_STATUS_ORF_PREFIX_SEND)) | |
8878 | json_object_boolean_true_add(json_neigh, | |
8879 | "orfSent"); | |
8880 | if (orf_pfx_count) | |
8881 | json_object_int_add(json_addr, "orfRecvCounter", | |
8882 | orf_pfx_count); | |
8883 | } | |
8884 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8885 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
8886 | json_object_string_add( | |
8887 | json_addr, "orfFirstUpdate", | |
8888 | "deferredUntilORFOrRouteRefreshRecvd"); | |
8889 | ||
8890 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8891 | PEER_FLAG_REFLECTOR_CLIENT)) | |
8892 | json_object_boolean_true_add(json_addr, | |
8893 | "routeReflectorClient"); | |
8894 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8895 | PEER_FLAG_RSERVER_CLIENT)) | |
8896 | json_object_boolean_true_add(json_addr, | |
8897 | "routeServerClient"); | |
8898 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
8899 | json_object_boolean_true_add(json_addr, | |
8900 | "inboundSoftConfigPermit"); | |
8901 | ||
8902 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8903 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
8904 | json_object_boolean_true_add( | |
8905 | json_addr, | |
8906 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
8907 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8908 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
8909 | json_object_boolean_true_add( | |
8910 | json_addr, | |
8911 | "privateAsNumsReplacedInUpdatesToNbr"); | |
8912 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8913 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
8914 | json_object_boolean_true_add( | |
8915 | json_addr, | |
8916 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
8917 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8918 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
8919 | json_object_boolean_true_add( | |
8920 | json_addr, | |
8921 | "privateAsNumsRemovedInUpdatesToNbr"); | |
8922 | ||
dcc68b5e MS |
8923 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
8924 | json_object_boolean_true_add( | |
8925 | json_addr, | |
8926 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
8927 | ->type_json_name); | |
d62a17ae | 8928 | |
8929 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
8930 | json_object_string_add(json_addr, | |
8931 | "overrideASNsInOutboundUpdates", | |
8932 | "ifAspathEqualRemoteAs"); | |
8933 | ||
8934 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
8935 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8936 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
8937 | json_object_boolean_true_add(json_addr, | |
8938 | "routerAlwaysNextHop"); | |
8939 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8940 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
8941 | json_object_boolean_true_add( | |
8942 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
8943 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8944 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
8945 | json_object_boolean_true_add( | |
8946 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
8947 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
8948 | json_object_boolean_true_add( | |
8949 | json_addr, "unchangedMedPropogatedToNbr"); | |
8950 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
8951 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8952 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
8953 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8954 | PEER_FLAG_SEND_COMMUNITY) | |
8955 | && CHECK_FLAG(p->af_flags[afi][safi], | |
8956 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
8957 | json_object_string_add(json_addr, | |
8958 | "commAttriSentToNbr", | |
8959 | "extendedAndStandard"); | |
8960 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8961 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
8962 | json_object_string_add(json_addr, | |
8963 | "commAttriSentToNbr", | |
8964 | "extended"); | |
8965 | else | |
8966 | json_object_string_add(json_addr, | |
8967 | "commAttriSentToNbr", | |
8968 | "standard"); | |
8969 | } | |
8970 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8971 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
8972 | if (p->default_rmap[afi][safi].name) | |
8973 | json_object_string_add( | |
8974 | json_addr, "defaultRouteMap", | |
8975 | p->default_rmap[afi][safi].name); | |
8976 | ||
8977 | if (paf && PAF_SUBGRP(paf) | |
8978 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
8979 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
8980 | json_object_boolean_true_add(json_addr, | |
8981 | "defaultSent"); | |
8982 | else | |
8983 | json_object_boolean_true_add(json_addr, | |
8984 | "defaultNotSent"); | |
8985 | } | |
8986 | ||
dff8f48d | 8987 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 8988 | if (is_evpn_enabled()) |
60466a63 QY |
8989 | json_object_boolean_true_add( |
8990 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
8991 | } |
8992 | ||
d62a17ae | 8993 | if (filter->plist[FILTER_IN].name |
8994 | || filter->dlist[FILTER_IN].name | |
8995 | || filter->aslist[FILTER_IN].name | |
8996 | || filter->map[RMAP_IN].name) | |
8997 | json_object_boolean_true_add(json_addr, | |
8998 | "inboundPathPolicyConfig"); | |
8999 | if (filter->plist[FILTER_OUT].name | |
9000 | || filter->dlist[FILTER_OUT].name | |
9001 | || filter->aslist[FILTER_OUT].name | |
9002 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
9003 | json_object_boolean_true_add( | |
9004 | json_addr, "outboundPathPolicyConfig"); | |
9005 | ||
9006 | /* prefix-list */ | |
9007 | if (filter->plist[FILTER_IN].name) | |
9008 | json_object_string_add(json_addr, | |
9009 | "incomingUpdatePrefixFilterList", | |
9010 | filter->plist[FILTER_IN].name); | |
9011 | if (filter->plist[FILTER_OUT].name) | |
9012 | json_object_string_add(json_addr, | |
9013 | "outgoingUpdatePrefixFilterList", | |
9014 | filter->plist[FILTER_OUT].name); | |
9015 | ||
9016 | /* distribute-list */ | |
9017 | if (filter->dlist[FILTER_IN].name) | |
9018 | json_object_string_add( | |
9019 | json_addr, "incomingUpdateNetworkFilterList", | |
9020 | filter->dlist[FILTER_IN].name); | |
9021 | if (filter->dlist[FILTER_OUT].name) | |
9022 | json_object_string_add( | |
9023 | json_addr, "outgoingUpdateNetworkFilterList", | |
9024 | filter->dlist[FILTER_OUT].name); | |
9025 | ||
9026 | /* filter-list. */ | |
9027 | if (filter->aslist[FILTER_IN].name) | |
9028 | json_object_string_add(json_addr, | |
9029 | "incomingUpdateAsPathFilterList", | |
9030 | filter->aslist[FILTER_IN].name); | |
9031 | if (filter->aslist[FILTER_OUT].name) | |
9032 | json_object_string_add(json_addr, | |
9033 | "outgoingUpdateAsPathFilterList", | |
9034 | filter->aslist[FILTER_OUT].name); | |
9035 | ||
9036 | /* route-map. */ | |
9037 | if (filter->map[RMAP_IN].name) | |
9038 | json_object_string_add( | |
9039 | json_addr, "routeMapForIncomingAdvertisements", | |
9040 | filter->map[RMAP_IN].name); | |
9041 | if (filter->map[RMAP_OUT].name) | |
9042 | json_object_string_add( | |
9043 | json_addr, "routeMapForOutgoingAdvertisements", | |
9044 | filter->map[RMAP_OUT].name); | |
9045 | ||
9dac9fc8 DA |
9046 | /* ebgp-requires-policy (inbound) */ |
9047 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
9048 | && !bgp_inbound_policy_exists(p, filter)) | |
9049 | json_object_string_add( | |
9050 | json_addr, "inboundEbgpRequiresPolicy", | |
9051 | "Inbound updates discarded due to missing policy"); | |
9052 | ||
9053 | /* ebgp-requires-policy (outbound) */ | |
9054 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
9055 | && (!bgp_outbound_policy_exists(p, filter))) | |
9056 | json_object_string_add( | |
9057 | json_addr, "outboundEbgpRequiresPolicy", | |
9058 | "Outbound updates discarded due to missing policy"); | |
9059 | ||
d62a17ae | 9060 | /* unsuppress-map */ |
9061 | if (filter->usmap.name) | |
9062 | json_object_string_add(json_addr, | |
9063 | "selectiveUnsuppressRouteMap", | |
9064 | filter->usmap.name); | |
9065 | ||
9066 | /* Receive prefix count */ | |
9067 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
9068 | p->pcount[afi][safi]); | |
50e05855 AD |
9069 | if (paf && PAF_SUBGRP(paf)) |
9070 | json_object_int_add(json_addr, "sentPrefixCounter", | |
9071 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 9072 | |
9073 | /* Maximum prefix */ | |
9074 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
9075 | json_object_int_add(json_addr, "prefixAllowedMax", | |
9076 | p->pmax[afi][safi]); | |
9077 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9078 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
9079 | json_object_boolean_true_add( | |
9080 | json_addr, "prefixAllowedMaxWarning"); | |
9081 | json_object_int_add(json_addr, | |
9082 | "prefixAllowedWarningThresh", | |
9083 | p->pmax_threshold[afi][safi]); | |
9084 | if (p->pmax_restart[afi][safi]) | |
9085 | json_object_int_add( | |
9086 | json_addr, | |
9087 | "prefixAllowedRestartIntervalMsecs", | |
9088 | p->pmax_restart[afi][safi] * 60000); | |
9089 | } | |
5cb5f4d0 | 9090 | json_object_object_add(json_neigh, get_afi_safi_str(afi, safi, true), |
d62a17ae | 9091 | json_addr); |
9092 | ||
9093 | } else { | |
9094 | filter = &p->filter[afi][safi]; | |
9095 | ||
9096 | vty_out(vty, " For address family: %s\n", | |
5cb5f4d0 | 9097 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 9098 | |
9099 | if (peer_group_active(p)) | |
9100 | vty_out(vty, " %s peer-group member\n", | |
9101 | p->group->name); | |
9102 | ||
9103 | paf = peer_af_find(p, afi, safi); | |
9104 | if (paf && PAF_SUBGRP(paf)) { | |
996c9314 LB |
9105 | vty_out(vty, " Update group %" PRIu64 |
9106 | ", subgroup %" PRIu64 "\n", | |
d62a17ae | 9107 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
9108 | vty_out(vty, " Packet Queue length %d\n", | |
9109 | bpacket_queue_virtual_length(paf)); | |
9110 | } else { | |
9111 | vty_out(vty, " Not part of any update group\n"); | |
9112 | } | |
9113 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
9114 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9115 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
9116 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9117 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
9118 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9119 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
9120 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9121 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
9122 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9123 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
9124 | vty_out(vty, " AF-dependant capabilities:\n"); | |
9125 | ||
9126 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
9127 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9128 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
9129 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9130 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
9131 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9132 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
9133 | vty_out(vty, | |
9134 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
9135 | ORF_TYPE_PREFIX); | |
9136 | bgp_show_peer_afi_orf_cap( | |
9137 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
9138 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
9139 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
9140 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
9141 | } | |
9142 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
9143 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9144 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
9145 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9146 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
9147 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9148 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
9149 | vty_out(vty, | |
9150 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
9151 | ORF_TYPE_PREFIX_OLD); | |
9152 | bgp_show_peer_afi_orf_cap( | |
9153 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
9154 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
9155 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
9156 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
9157 | } | |
9158 | ||
9159 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
9160 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
9161 | NULL, afi, orf_pfx_name, use_json); | |
9162 | ||
9163 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
9164 | PEER_STATUS_ORF_PREFIX_SEND) | |
9165 | || orf_pfx_count) { | |
9166 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
9167 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
9168 | PEER_STATUS_ORF_PREFIX_SEND)) | |
9169 | vty_out(vty, " sent;"); | |
9170 | if (orf_pfx_count) | |
9171 | vty_out(vty, " received (%d entries)", | |
9172 | orf_pfx_count); | |
9173 | vty_out(vty, "\n"); | |
9174 | } | |
9175 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
9176 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
9177 | vty_out(vty, | |
9178 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
9179 | ||
9180 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9181 | PEER_FLAG_REFLECTOR_CLIENT)) | |
9182 | vty_out(vty, " Route-Reflector Client\n"); | |
9183 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9184 | PEER_FLAG_RSERVER_CLIENT)) | |
9185 | vty_out(vty, " Route-Server Client\n"); | |
9186 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
9187 | vty_out(vty, | |
9188 | " Inbound soft reconfiguration allowed\n"); | |
9189 | ||
9190 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9191 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
9192 | vty_out(vty, | |
9193 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
9194 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9195 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
9196 | vty_out(vty, | |
9197 | " Private AS numbers replaced in updates to this neighbor\n"); | |
9198 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9199 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
9200 | vty_out(vty, | |
9201 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
9202 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9203 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
9204 | vty_out(vty, | |
9205 | " Private AS numbers removed in updates to this neighbor\n"); | |
9206 | ||
dcc68b5e MS |
9207 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
9208 | vty_out(vty, " %s\n", | |
9209 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
9210 | ->human_description); | |
d62a17ae | 9211 | |
9212 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
9213 | vty_out(vty, | |
9214 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
9215 | ||
9216 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
9217 | || CHECK_FLAG(p->af_flags[afi][safi], | |
9218 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
9219 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
9220 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9221 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
9222 | vty_out(vty, | |
9223 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
9224 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9225 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
9226 | vty_out(vty, | |
9227 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
9228 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
9229 | vty_out(vty, | |
9230 | " MED is propagated unchanged to this neighbor\n"); | |
9231 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
9232 | || CHECK_FLAG(p->af_flags[afi][safi], | |
9233 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
9234 | || CHECK_FLAG(p->af_flags[afi][safi], | |
9235 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
9236 | vty_out(vty, | |
9237 | " Community attribute sent to this neighbor"); | |
9238 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9239 | PEER_FLAG_SEND_COMMUNITY) | |
9240 | && CHECK_FLAG(p->af_flags[afi][safi], | |
9241 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
9242 | && CHECK_FLAG(p->af_flags[afi][safi], | |
9243 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
9244 | vty_out(vty, "(all)\n"); | |
9245 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9246 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
9247 | vty_out(vty, "(large)\n"); | |
9248 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9249 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
9250 | vty_out(vty, "(extended)\n"); | |
9251 | else | |
9252 | vty_out(vty, "(standard)\n"); | |
9253 | } | |
9254 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9255 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
9256 | vty_out(vty, " Default information originate,"); | |
9257 | ||
9258 | if (p->default_rmap[afi][safi].name) | |
9259 | vty_out(vty, " default route-map %s%s,", | |
9260 | p->default_rmap[afi][safi].map ? "*" | |
9261 | : "", | |
9262 | p->default_rmap[afi][safi].name); | |
9263 | if (paf && PAF_SUBGRP(paf) | |
9264 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
9265 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
9266 | vty_out(vty, " default sent\n"); | |
9267 | else | |
9268 | vty_out(vty, " default not sent\n"); | |
9269 | } | |
9270 | ||
dff8f48d MK |
9271 | /* advertise-vni-all */ |
9272 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 9273 | if (is_evpn_enabled()) |
dff8f48d MK |
9274 | vty_out(vty, " advertise-all-vni\n"); |
9275 | } | |
9276 | ||
d62a17ae | 9277 | if (filter->plist[FILTER_IN].name |
9278 | || filter->dlist[FILTER_IN].name | |
9279 | || filter->aslist[FILTER_IN].name | |
9280 | || filter->map[RMAP_IN].name) | |
9281 | vty_out(vty, " Inbound path policy configured\n"); | |
9282 | if (filter->plist[FILTER_OUT].name | |
9283 | || filter->dlist[FILTER_OUT].name | |
9284 | || filter->aslist[FILTER_OUT].name | |
9285 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
9286 | vty_out(vty, " Outbound path policy configured\n"); | |
9287 | ||
9288 | /* prefix-list */ | |
9289 | if (filter->plist[FILTER_IN].name) | |
9290 | vty_out(vty, | |
9291 | " Incoming update prefix filter list is %s%s\n", | |
9292 | filter->plist[FILTER_IN].plist ? "*" : "", | |
9293 | filter->plist[FILTER_IN].name); | |
9294 | if (filter->plist[FILTER_OUT].name) | |
9295 | vty_out(vty, | |
9296 | " Outgoing update prefix filter list is %s%s\n", | |
9297 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
9298 | filter->plist[FILTER_OUT].name); | |
9299 | ||
9300 | /* distribute-list */ | |
9301 | if (filter->dlist[FILTER_IN].name) | |
9302 | vty_out(vty, | |
9303 | " Incoming update network filter list is %s%s\n", | |
9304 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
9305 | filter->dlist[FILTER_IN].name); | |
9306 | if (filter->dlist[FILTER_OUT].name) | |
9307 | vty_out(vty, | |
9308 | " Outgoing update network filter list is %s%s\n", | |
9309 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
9310 | filter->dlist[FILTER_OUT].name); | |
9311 | ||
9312 | /* filter-list. */ | |
9313 | if (filter->aslist[FILTER_IN].name) | |
9314 | vty_out(vty, | |
9315 | " Incoming update AS path filter list is %s%s\n", | |
9316 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
9317 | filter->aslist[FILTER_IN].name); | |
9318 | if (filter->aslist[FILTER_OUT].name) | |
9319 | vty_out(vty, | |
9320 | " Outgoing update AS path filter list is %s%s\n", | |
9321 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
9322 | filter->aslist[FILTER_OUT].name); | |
9323 | ||
9324 | /* route-map. */ | |
9325 | if (filter->map[RMAP_IN].name) | |
9326 | vty_out(vty, | |
9327 | " Route map for incoming advertisements is %s%s\n", | |
9328 | filter->map[RMAP_IN].map ? "*" : "", | |
9329 | filter->map[RMAP_IN].name); | |
9330 | if (filter->map[RMAP_OUT].name) | |
9331 | vty_out(vty, | |
9332 | " Route map for outgoing advertisements is %s%s\n", | |
9333 | filter->map[RMAP_OUT].map ? "*" : "", | |
9334 | filter->map[RMAP_OUT].name); | |
9335 | ||
9dac9fc8 DA |
9336 | /* ebgp-requires-policy (inbound) */ |
9337 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
9338 | && !bgp_inbound_policy_exists(p, filter)) | |
9339 | vty_out(vty, | |
9340 | " Inbound updates discarded due to missing policy\n"); | |
9341 | ||
9342 | /* ebgp-requires-policy (outbound) */ | |
9343 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
9344 | && !bgp_outbound_policy_exists(p, filter)) | |
9345 | vty_out(vty, | |
9346 | " Outbound updates discarded due to missing policy\n"); | |
9347 | ||
d62a17ae | 9348 | /* unsuppress-map */ |
9349 | if (filter->usmap.name) | |
9350 | vty_out(vty, | |
9351 | " Route map for selective unsuppress is %s%s\n", | |
9352 | filter->usmap.map ? "*" : "", | |
9353 | filter->usmap.name); | |
9354 | ||
9355 | /* Receive prefix count */ | |
a0a87037 DA |
9356 | vty_out(vty, " %" PRIu32 " accepted prefixes\n", |
9357 | p->pcount[afi][safi]); | |
d62a17ae | 9358 | |
9359 | /* Maximum prefix */ | |
9360 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
a0a87037 DA |
9361 | vty_out(vty, |
9362 | " Maximum prefixes allowed %" PRIu32 "%s\n", | |
d62a17ae | 9363 | p->pmax[afi][safi], |
9364 | CHECK_FLAG(p->af_flags[afi][safi], | |
9365 | PEER_FLAG_MAX_PREFIX_WARNING) | |
9366 | ? " (warning-only)" | |
9367 | : ""); | |
9368 | vty_out(vty, " Threshold for warning message %d%%", | |
9369 | p->pmax_threshold[afi][safi]); | |
9370 | if (p->pmax_restart[afi][safi]) | |
9371 | vty_out(vty, ", restart interval %d min", | |
9372 | p->pmax_restart[afi][safi]); | |
9373 | vty_out(vty, "\n"); | |
9374 | } | |
9375 | ||
9376 | vty_out(vty, "\n"); | |
9377 | } | |
9378 | } | |
9379 | ||
9f049418 | 9380 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 9381 | json_object *json) |
718e3744 | 9382 | { |
d62a17ae | 9383 | struct bgp *bgp; |
9384 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
9385 | char timebuf[BGP_UPTIME_LEN]; | |
9386 | char dn_flag[2]; | |
d62a17ae | 9387 | afi_t afi; |
9388 | safi_t safi; | |
d7c0a89a QY |
9389 | uint16_t i; |
9390 | uint8_t *msg; | |
d62a17ae | 9391 | json_object *json_neigh = NULL; |
9392 | time_t epoch_tbuf; | |
718e3744 | 9393 | |
d62a17ae | 9394 | bgp = p->bgp; |
9395 | ||
9396 | if (use_json) | |
9397 | json_neigh = json_object_new_object(); | |
9398 | ||
9399 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
9400 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
9401 | dn_flag[0] = '*'; | |
9402 | ||
9403 | if (!use_json) { | |
9404 | if (p->conf_if) /* Configured interface name. */ | |
9405 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
9406 | BGP_PEER_SU_UNSPEC(p) | |
9407 | ? "None" | |
9408 | : sockunion2str(&p->su, buf, | |
9409 | SU_ADDRSTRLEN)); | |
9410 | else /* Configured IP address. */ | |
9411 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
9412 | p->host); | |
9413 | } | |
9414 | ||
9415 | if (use_json) { | |
9416 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
9417 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
9418 | "none"); | |
9419 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
9420 | json_object_string_add( | |
9421 | json_neigh, "bgpNeighborAddr", | |
9422 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
9423 | ||
9424 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
9425 | ||
9426 | if (p->change_local_as) | |
9427 | json_object_int_add(json_neigh, "localAs", | |
9428 | p->change_local_as); | |
9429 | else | |
9430 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
9431 | ||
9432 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
9433 | json_object_boolean_true_add(json_neigh, | |
9434 | "localAsNoPrepend"); | |
9435 | ||
9436 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
9437 | json_object_boolean_true_add(json_neigh, | |
9438 | "localAsReplaceAs"); | |
9439 | } else { | |
9440 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
9441 | || (p->as_type == AS_INTERNAL)) | |
9442 | vty_out(vty, "remote AS %u, ", p->as); | |
9443 | else | |
9444 | vty_out(vty, "remote AS Unspecified, "); | |
9445 | vty_out(vty, "local AS %u%s%s, ", | |
9446 | p->change_local_as ? p->change_local_as : p->local_as, | |
9447 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
9448 | ? " no-prepend" | |
9449 | : "", | |
9450 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
9451 | ? " replace-as" | |
9452 | : ""); | |
9453 | } | |
faa16034 DS |
9454 | /* peer type internal or confed-internal */ |
9455 | if ((p->as == p->local_as) || (p->as_type == AS_INTERNAL)) { | |
d62a17ae | 9456 | if (use_json) { |
9457 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9458 | json_object_boolean_true_add( | |
9459 | json_neigh, "nbrConfedInternalLink"); | |
9460 | else | |
9461 | json_object_boolean_true_add(json_neigh, | |
9462 | "nbrInternalLink"); | |
9463 | } else { | |
9464 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9465 | vty_out(vty, "confed-internal link\n"); | |
9466 | else | |
9467 | vty_out(vty, "internal link\n"); | |
9468 | } | |
faa16034 DS |
9469 | /* peer type external or confed-external */ |
9470 | } else if (p->as || (p->as_type == AS_EXTERNAL)) { | |
d62a17ae | 9471 | if (use_json) { |
9472 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9473 | json_object_boolean_true_add( | |
9474 | json_neigh, "nbrConfedExternalLink"); | |
9475 | else | |
9476 | json_object_boolean_true_add(json_neigh, | |
9477 | "nbrExternalLink"); | |
9478 | } else { | |
9479 | if (bgp_confederation_peers_check(bgp, p->as)) | |
9480 | vty_out(vty, "confed-external link\n"); | |
9481 | else | |
9482 | vty_out(vty, "external link\n"); | |
9483 | } | |
faa16034 DS |
9484 | } else { |
9485 | if (use_json) | |
9486 | json_object_boolean_true_add(json_neigh, | |
9487 | "nbrUnspecifiedLink"); | |
9488 | else | |
9489 | vty_out(vty, "unspecified link\n"); | |
d62a17ae | 9490 | } |
9491 | ||
9492 | /* Description. */ | |
9493 | if (p->desc) { | |
9494 | if (use_json) | |
9495 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
9496 | else | |
9497 | vty_out(vty, " Description: %s\n", p->desc); | |
9498 | } | |
9499 | ||
9500 | if (p->hostname) { | |
9501 | if (use_json) { | |
9502 | if (p->hostname) | |
9503 | json_object_string_add(json_neigh, "hostname", | |
9504 | p->hostname); | |
9505 | ||
9506 | if (p->domainname) | |
9507 | json_object_string_add(json_neigh, "domainname", | |
9508 | p->domainname); | |
9509 | } else { | |
9510 | if (p->domainname && (p->domainname[0] != '\0')) | |
9511 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
9512 | p->domainname); | |
9513 | else | |
9514 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
9515 | } | |
9516 | } | |
9517 | ||
9518 | /* Peer-group */ | |
9519 | if (p->group) { | |
9520 | if (use_json) { | |
9521 | json_object_string_add(json_neigh, "peerGroup", | |
9522 | p->group->name); | |
9523 | ||
9524 | if (dn_flag[0]) { | |
9525 | struct prefix prefix, *range = NULL; | |
9526 | ||
9527 | sockunion2hostprefix(&(p->su), &prefix); | |
9528 | range = peer_group_lookup_dynamic_neighbor_range( | |
9529 | p->group, &prefix); | |
9530 | ||
9531 | if (range) { | |
9532 | prefix2str(range, buf1, sizeof(buf1)); | |
9533 | json_object_string_add( | |
9534 | json_neigh, | |
9535 | "peerSubnetRangeGroup", buf1); | |
9536 | } | |
9537 | } | |
9538 | } else { | |
9539 | vty_out(vty, | |
9540 | " Member of peer-group %s for session parameters\n", | |
9541 | p->group->name); | |
9542 | ||
9543 | if (dn_flag[0]) { | |
9544 | struct prefix prefix, *range = NULL; | |
9545 | ||
9546 | sockunion2hostprefix(&(p->su), &prefix); | |
9547 | range = peer_group_lookup_dynamic_neighbor_range( | |
9548 | p->group, &prefix); | |
9549 | ||
9550 | if (range) { | |
9551 | prefix2str(range, buf1, sizeof(buf1)); | |
9552 | vty_out(vty, | |
9553 | " Belongs to the subnet range group: %s\n", | |
9554 | buf1); | |
9555 | } | |
9556 | } | |
9557 | } | |
9558 | } | |
9559 | ||
9560 | if (use_json) { | |
9561 | /* Administrative shutdown. */ | |
9562 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
9563 | json_object_boolean_true_add(json_neigh, | |
9564 | "adminShutDown"); | |
9565 | ||
9566 | /* BGP Version. */ | |
9567 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
9568 | json_object_string_add( | |
9569 | json_neigh, "remoteRouterId", | |
9570 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
d0086e8e AD |
9571 | json_object_string_add( |
9572 | json_neigh, "localRouterId", | |
9573 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
9574 | sizeof(buf1))); | |
d62a17ae | 9575 | |
9576 | /* Confederation */ | |
9577 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
9578 | && bgp_confederation_peers_check(bgp, p->as)) | |
9579 | json_object_boolean_true_add(json_neigh, | |
9580 | "nbrCommonAdmin"); | |
9581 | ||
9582 | /* Status. */ | |
9583 | json_object_string_add( | |
9584 | json_neigh, "bgpState", | |
9585 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
9586 | ||
9587 | if (p->status == Established) { | |
9588 | time_t uptime; | |
d62a17ae | 9589 | |
9590 | uptime = bgp_clock(); | |
9591 | uptime -= p->uptime; | |
d62a17ae | 9592 | epoch_tbuf = time(NULL) - uptime; |
9593 | ||
bee57a7a | 9594 | #if CONFDATE > 20200101 |
a4d82a8a PZ |
9595 | CPP_NOTICE( |
9596 | "bgpTimerUp should be deprecated and can be removed now"); | |
d3c7efed DS |
9597 | #endif |
9598 | /* | |
9599 | * bgpTimerUp was miliseconds that was accurate | |
9600 | * up to 1 day, then the value returned | |
9601 | * became garbage. So in order to provide | |
9602 | * some level of backwards compatability, | |
9603 | * we still provde the data, but now | |
9604 | * we are returning the correct value | |
9605 | * and also adding a new bgpTimerUpMsec | |
9606 | * which will allow us to deprecate | |
9607 | * this eventually | |
9608 | */ | |
d62a17ae | 9609 | json_object_int_add(json_neigh, "bgpTimerUp", |
e0330274 | 9610 | uptime * 1000); |
d3c7efed DS |
9611 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
9612 | uptime * 1000); | |
d62a17ae | 9613 | json_object_string_add(json_neigh, "bgpTimerUpString", |
9614 | peer_uptime(p->uptime, timebuf, | |
9615 | BGP_UPTIME_LEN, 0, | |
9616 | NULL)); | |
9617 | json_object_int_add(json_neigh, | |
9618 | "bgpTimerUpEstablishedEpoch", | |
9619 | epoch_tbuf); | |
9620 | } | |
9621 | ||
9622 | else if (p->status == Active) { | |
9623 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
9624 | json_object_string_add(json_neigh, "bgpStateIs", | |
9625 | "passive"); | |
9626 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
9627 | json_object_string_add(json_neigh, "bgpStateIs", | |
9628 | "passiveNSF"); | |
9629 | } | |
9630 | ||
9631 | /* read timer */ | |
9632 | time_t uptime; | |
9633 | struct tm *tm; | |
9634 | ||
9635 | uptime = bgp_clock(); | |
9636 | uptime -= p->readtime; | |
9637 | tm = gmtime(&uptime); | |
9638 | json_object_int_add(json_neigh, "bgpTimerLastRead", | |
9639 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9640 | + (tm->tm_hour * 3600000)); | |
9641 | ||
9642 | uptime = bgp_clock(); | |
9643 | uptime -= p->last_write; | |
9644 | tm = gmtime(&uptime); | |
9645 | json_object_int_add(json_neigh, "bgpTimerLastWrite", | |
9646 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9647 | + (tm->tm_hour * 3600000)); | |
9648 | ||
9649 | uptime = bgp_clock(); | |
9650 | uptime -= p->update_time; | |
9651 | tm = gmtime(&uptime); | |
9652 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", | |
9653 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9654 | + (tm->tm_hour * 3600000)); | |
9655 | ||
9656 | /* Configured timer values. */ | |
9657 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
9658 | p->v_holdtime * 1000); | |
9659 | json_object_int_add(json_neigh, | |
9660 | "bgpTimerKeepAliveIntervalMsecs", | |
9661 | p->v_keepalive * 1000); | |
b90a8e13 | 9662 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 9663 | json_object_int_add(json_neigh, |
9664 | "bgpTimerConfiguredHoldTimeMsecs", | |
9665 | p->holdtime * 1000); | |
9666 | json_object_int_add( | |
9667 | json_neigh, | |
9668 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
9669 | p->keepalive * 1000); | |
d25e4efc | 9670 | } else if ((bgp->default_holdtime != BGP_DEFAULT_HOLDTIME) |
a4d82a8a PZ |
9671 | || (bgp->default_keepalive |
9672 | != BGP_DEFAULT_KEEPALIVE)) { | |
d25e4efc DS |
9673 | json_object_int_add(json_neigh, |
9674 | "bgpTimerConfiguredHoldTimeMsecs", | |
9675 | bgp->default_holdtime); | |
9676 | json_object_int_add( | |
9677 | json_neigh, | |
9678 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
9679 | bgp->default_keepalive); | |
d62a17ae | 9680 | } |
9681 | } else { | |
9682 | /* Administrative shutdown. */ | |
9683 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
9684 | vty_out(vty, " Administratively shut down\n"); | |
9685 | ||
9686 | /* BGP Version. */ | |
9687 | vty_out(vty, " BGP version 4"); | |
0e38aeb4 | 9688 | vty_out(vty, ", remote router ID %s", |
d62a17ae | 9689 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
0e38aeb4 AD |
9690 | vty_out(vty, ", local router ID %s\n", |
9691 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
9692 | sizeof(buf1))); | |
d62a17ae | 9693 | |
9694 | /* Confederation */ | |
9695 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
9696 | && bgp_confederation_peers_check(bgp, p->as)) | |
9697 | vty_out(vty, | |
9698 | " Neighbor under common administration\n"); | |
9699 | ||
9700 | /* Status. */ | |
9701 | vty_out(vty, " BGP state = %s", | |
9702 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
9703 | ||
9704 | if (p->status == Established) | |
9705 | vty_out(vty, ", up for %8s", | |
9706 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
9707 | 0, NULL)); | |
9708 | ||
9709 | else if (p->status == Active) { | |
9710 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
9711 | vty_out(vty, " (passive)"); | |
9712 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
9713 | vty_out(vty, " (NSF passive)"); | |
9714 | } | |
9715 | vty_out(vty, "\n"); | |
9716 | ||
9717 | /* read timer */ | |
9718 | vty_out(vty, " Last read %s", | |
9719 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
9720 | NULL)); | |
9721 | vty_out(vty, ", Last write %s\n", | |
9722 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
9723 | NULL)); | |
9724 | ||
9725 | /* Configured timer values. */ | |
9726 | vty_out(vty, | |
9727 | " Hold time is %d, keepalive interval is %d seconds\n", | |
9728 | p->v_holdtime, p->v_keepalive); | |
b90a8e13 | 9729 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 9730 | vty_out(vty, " Configured hold time is %d", |
9731 | p->holdtime); | |
9732 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
9733 | p->keepalive); | |
d25e4efc | 9734 | } else if ((bgp->default_holdtime != BGP_DEFAULT_HOLDTIME) |
a4d82a8a PZ |
9735 | || (bgp->default_keepalive |
9736 | != BGP_DEFAULT_KEEPALIVE)) { | |
d25e4efc DS |
9737 | vty_out(vty, " Configured hold time is %d", |
9738 | bgp->default_holdtime); | |
9739 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
9740 | bgp->default_keepalive); | |
d62a17ae | 9741 | } |
9742 | } | |
9743 | /* Capability. */ | |
9744 | if (p->status == Established) { | |
9745 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] | |
9746 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
9747 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
9748 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
9749 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
9750 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
9751 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
9752 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
9753 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
9754 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
9755 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
9756 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
7c40bf39 | 9757 | || p->afc_adv[AFI_IP6][SAFI_FLOWSPEC] |
9758 | || p->afc_recv[AFI_IP6][SAFI_FLOWSPEC] | |
d62a17ae | 9759 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
9760 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
7c40bf39 | 9761 | || p->afc_adv[AFI_IP][SAFI_FLOWSPEC] |
9762 | || p->afc_recv[AFI_IP][SAFI_FLOWSPEC] | |
d62a17ae | 9763 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
9764 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
9765 | if (use_json) { | |
9766 | json_object *json_cap = NULL; | |
9767 | ||
9768 | json_cap = json_object_new_object(); | |
9769 | ||
9770 | /* AS4 */ | |
9771 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
9772 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
9773 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
9774 | && CHECK_FLAG(p->cap, | |
9775 | PEER_CAP_AS4_RCV)) | |
9776 | json_object_string_add( | |
9777 | json_cap, "4byteAs", | |
9778 | "advertisedAndReceived"); | |
9779 | else if (CHECK_FLAG(p->cap, | |
9780 | PEER_CAP_AS4_ADV)) | |
9781 | json_object_string_add( | |
9782 | json_cap, "4byteAs", | |
9783 | "advertised"); | |
9784 | else if (CHECK_FLAG(p->cap, | |
9785 | PEER_CAP_AS4_RCV)) | |
9786 | json_object_string_add( | |
9787 | json_cap, "4byteAs", | |
9788 | "received"); | |
9789 | } | |
9790 | ||
9791 | /* AddPath */ | |
9792 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
9793 | || CHECK_FLAG(p->cap, | |
9794 | PEER_CAP_ADDPATH_ADV)) { | |
9795 | json_object *json_add = NULL; | |
9796 | const char *print_store; | |
9797 | ||
9798 | json_add = json_object_new_object(); | |
9799 | ||
05c7a1cc QY |
9800 | FOREACH_AFI_SAFI (afi, safi) { |
9801 | json_object *json_sub = NULL; | |
9802 | json_sub = | |
9803 | json_object_new_object(); | |
5cb5f4d0 DD |
9804 | print_store = get_afi_safi_str( |
9805 | afi, safi, true); | |
d62a17ae | 9806 | |
05c7a1cc QY |
9807 | if (CHECK_FLAG( |
9808 | p->af_cap[afi] | |
9809 | [safi], | |
9810 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9811 | || CHECK_FLAG( | |
9812 | p->af_cap[afi] | |
9813 | [safi], | |
9814 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 9815 | if (CHECK_FLAG( |
9816 | p->af_cap | |
9817 | [afi] | |
9818 | [safi], | |
9819 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 9820 | && CHECK_FLAG( |
d62a17ae | 9821 | p->af_cap |
9822 | [afi] | |
9823 | [safi], | |
05c7a1cc QY |
9824 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
9825 | json_object_boolean_true_add( | |
9826 | json_sub, | |
9827 | "txAdvertisedAndReceived"); | |
9828 | else if ( | |
9829 | CHECK_FLAG( | |
9830 | p->af_cap | |
9831 | [afi] | |
9832 | [safi], | |
9833 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
9834 | json_object_boolean_true_add( | |
9835 | json_sub, | |
9836 | "txAdvertised"); | |
9837 | else if ( | |
9838 | CHECK_FLAG( | |
9839 | p->af_cap | |
9840 | [afi] | |
9841 | [safi], | |
9842 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
9843 | json_object_boolean_true_add( | |
9844 | json_sub, | |
9845 | "txReceived"); | |
9846 | } | |
d62a17ae | 9847 | |
05c7a1cc QY |
9848 | if (CHECK_FLAG( |
9849 | p->af_cap[afi] | |
9850 | [safi], | |
9851 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9852 | || CHECK_FLAG( | |
9853 | p->af_cap[afi] | |
9854 | [safi], | |
9855 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 9856 | if (CHECK_FLAG( |
9857 | p->af_cap | |
9858 | [afi] | |
9859 | [safi], | |
9860 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 9861 | && CHECK_FLAG( |
d62a17ae | 9862 | p->af_cap |
9863 | [afi] | |
9864 | [safi], | |
9865 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
9866 | json_object_boolean_true_add( |
9867 | json_sub, | |
9868 | "rxAdvertisedAndReceived"); | |
9869 | else if ( | |
9870 | CHECK_FLAG( | |
9871 | p->af_cap | |
9872 | [afi] | |
9873 | [safi], | |
9874 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
9875 | json_object_boolean_true_add( | |
9876 | json_sub, | |
9877 | "rxAdvertised"); | |
9878 | else if ( | |
9879 | CHECK_FLAG( | |
9880 | p->af_cap | |
9881 | [afi] | |
9882 | [safi], | |
9883 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
9884 | json_object_boolean_true_add( | |
9885 | json_sub, | |
9886 | "rxReceived"); | |
d62a17ae | 9887 | } |
9888 | ||
05c7a1cc QY |
9889 | if (CHECK_FLAG( |
9890 | p->af_cap[afi] | |
9891 | [safi], | |
9892 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9893 | || CHECK_FLAG( | |
9894 | p->af_cap[afi] | |
9895 | [safi], | |
9896 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
9897 | || CHECK_FLAG( | |
9898 | p->af_cap[afi] | |
9899 | [safi], | |
9900 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9901 | || CHECK_FLAG( | |
9902 | p->af_cap[afi] | |
9903 | [safi], | |
9904 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
9905 | json_object_object_add( | |
9906 | json_add, | |
9907 | print_store, | |
9908 | json_sub); | |
9909 | else | |
9910 | json_object_free( | |
9911 | json_sub); | |
9912 | } | |
9913 | ||
d62a17ae | 9914 | json_object_object_add( |
9915 | json_cap, "addPath", json_add); | |
9916 | } | |
9917 | ||
9918 | /* Dynamic */ | |
9919 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
9920 | || CHECK_FLAG(p->cap, | |
9921 | PEER_CAP_DYNAMIC_ADV)) { | |
9922 | if (CHECK_FLAG(p->cap, | |
9923 | PEER_CAP_DYNAMIC_ADV) | |
9924 | && CHECK_FLAG(p->cap, | |
9925 | PEER_CAP_DYNAMIC_RCV)) | |
9926 | json_object_string_add( | |
9927 | json_cap, "dynamic", | |
9928 | "advertisedAndReceived"); | |
9929 | else if (CHECK_FLAG( | |
9930 | p->cap, | |
9931 | PEER_CAP_DYNAMIC_ADV)) | |
9932 | json_object_string_add( | |
9933 | json_cap, "dynamic", | |
9934 | "advertised"); | |
9935 | else if (CHECK_FLAG( | |
9936 | p->cap, | |
9937 | PEER_CAP_DYNAMIC_RCV)) | |
9938 | json_object_string_add( | |
9939 | json_cap, "dynamic", | |
9940 | "received"); | |
9941 | } | |
9942 | ||
9943 | /* Extended nexthop */ | |
9944 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
9945 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
9946 | json_object *json_nxt = NULL; | |
9947 | const char *print_store; | |
9948 | ||
9949 | ||
9950 | if (CHECK_FLAG(p->cap, | |
9951 | PEER_CAP_ENHE_ADV) | |
9952 | && CHECK_FLAG(p->cap, | |
9953 | PEER_CAP_ENHE_RCV)) | |
9954 | json_object_string_add( | |
9955 | json_cap, | |
9956 | "extendedNexthop", | |
9957 | "advertisedAndReceived"); | |
9958 | else if (CHECK_FLAG(p->cap, | |
9959 | PEER_CAP_ENHE_ADV)) | |
9960 | json_object_string_add( | |
9961 | json_cap, | |
9962 | "extendedNexthop", | |
9963 | "advertised"); | |
9964 | else if (CHECK_FLAG(p->cap, | |
9965 | PEER_CAP_ENHE_RCV)) | |
9966 | json_object_string_add( | |
9967 | json_cap, | |
9968 | "extendedNexthop", | |
9969 | "received"); | |
9970 | ||
9971 | if (CHECK_FLAG(p->cap, | |
9972 | PEER_CAP_ENHE_RCV)) { | |
9973 | json_nxt = | |
9974 | json_object_new_object(); | |
9975 | ||
9976 | for (safi = SAFI_UNICAST; | |
9977 | safi < SAFI_MAX; safi++) { | |
9978 | if (CHECK_FLAG( | |
9979 | p->af_cap | |
9980 | [AFI_IP] | |
9981 | [safi], | |
9982 | PEER_CAP_ENHE_AF_RCV)) { | |
5cb5f4d0 | 9983 | print_store = get_afi_safi_str( |
d62a17ae | 9984 | AFI_IP, |
5cb5f4d0 | 9985 | safi, true); |
d62a17ae | 9986 | json_object_string_add( |
9987 | json_nxt, | |
9988 | print_store, | |
54f29523 | 9989 | "recieved"); /* misspelled for compatibility */ |
d62a17ae | 9990 | } |
9991 | } | |
9992 | json_object_object_add( | |
9993 | json_cap, | |
9994 | "extendedNexthopFamililesByPeer", | |
9995 | json_nxt); | |
9996 | } | |
9997 | } | |
9998 | ||
9999 | /* Route Refresh */ | |
10000 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
10001 | || CHECK_FLAG(p->cap, | |
10002 | PEER_CAP_REFRESH_NEW_RCV) | |
10003 | || CHECK_FLAG(p->cap, | |
10004 | PEER_CAP_REFRESH_OLD_RCV)) { | |
10005 | if (CHECK_FLAG(p->cap, | |
10006 | PEER_CAP_REFRESH_ADV) | |
10007 | && (CHECK_FLAG( | |
10008 | p->cap, | |
10009 | PEER_CAP_REFRESH_NEW_RCV) | |
10010 | || CHECK_FLAG( | |
10011 | p->cap, | |
10012 | PEER_CAP_REFRESH_OLD_RCV))) { | |
10013 | if (CHECK_FLAG( | |
10014 | p->cap, | |
10015 | PEER_CAP_REFRESH_OLD_RCV) | |
10016 | && CHECK_FLAG( | |
10017 | p->cap, | |
10018 | PEER_CAP_REFRESH_NEW_RCV)) | |
10019 | json_object_string_add( | |
10020 | json_cap, | |
10021 | "routeRefresh", | |
10022 | "advertisedAndReceivedOldNew"); | |
10023 | else { | |
10024 | if (CHECK_FLAG( | |
10025 | p->cap, | |
10026 | PEER_CAP_REFRESH_OLD_RCV)) | |
10027 | json_object_string_add( | |
10028 | json_cap, | |
10029 | "routeRefresh", | |
10030 | "advertisedAndReceivedOld"); | |
10031 | else | |
10032 | json_object_string_add( | |
10033 | json_cap, | |
10034 | "routeRefresh", | |
10035 | "advertisedAndReceivedNew"); | |
10036 | } | |
10037 | } else if ( | |
10038 | CHECK_FLAG( | |
10039 | p->cap, | |
10040 | PEER_CAP_REFRESH_ADV)) | |
10041 | json_object_string_add( | |
10042 | json_cap, | |
10043 | "routeRefresh", | |
10044 | "advertised"); | |
10045 | else if ( | |
10046 | CHECK_FLAG( | |
10047 | p->cap, | |
10048 | PEER_CAP_REFRESH_NEW_RCV) | |
10049 | || CHECK_FLAG( | |
10050 | p->cap, | |
10051 | PEER_CAP_REFRESH_OLD_RCV)) | |
10052 | json_object_string_add( | |
10053 | json_cap, | |
10054 | "routeRefresh", | |
10055 | "received"); | |
10056 | } | |
10057 | ||
10058 | /* Multiprotocol Extensions */ | |
10059 | json_object *json_multi = NULL; | |
10060 | json_multi = json_object_new_object(); | |
10061 | ||
05c7a1cc QY |
10062 | FOREACH_AFI_SAFI (afi, safi) { |
10063 | if (p->afc_adv[afi][safi] | |
10064 | || p->afc_recv[afi][safi]) { | |
10065 | json_object *json_exten = NULL; | |
10066 | json_exten = | |
10067 | json_object_new_object(); | |
10068 | ||
d62a17ae | 10069 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
10070 | && p->afc_recv[afi][safi]) |
10071 | json_object_boolean_true_add( | |
10072 | json_exten, | |
10073 | "advertisedAndReceived"); | |
10074 | else if (p->afc_adv[afi][safi]) | |
10075 | json_object_boolean_true_add( | |
10076 | json_exten, | |
10077 | "advertised"); | |
10078 | else if (p->afc_recv[afi][safi]) | |
10079 | json_object_boolean_true_add( | |
10080 | json_exten, | |
10081 | "received"); | |
d62a17ae | 10082 | |
05c7a1cc QY |
10083 | json_object_object_add( |
10084 | json_multi, | |
5cb5f4d0 DD |
10085 | get_afi_safi_str(afi, |
10086 | safi, | |
10087 | true), | |
05c7a1cc | 10088 | json_exten); |
d62a17ae | 10089 | } |
10090 | } | |
10091 | json_object_object_add( | |
10092 | json_cap, "multiprotocolExtensions", | |
10093 | json_multi); | |
10094 | ||
d77114b7 | 10095 | /* Hostname capabilities */ |
60466a63 | 10096 | json_object *json_hname = NULL; |
d77114b7 MK |
10097 | |
10098 | json_hname = json_object_new_object(); | |
10099 | ||
10100 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
10101 | json_object_string_add( | |
60466a63 QY |
10102 | json_hname, "advHostName", |
10103 | bgp->peer_self->hostname | |
10104 | ? bgp->peer_self | |
10105 | ->hostname | |
d77114b7 MK |
10106 | : "n/a"); |
10107 | json_object_string_add( | |
60466a63 QY |
10108 | json_hname, "advDomainName", |
10109 | bgp->peer_self->domainname | |
10110 | ? bgp->peer_self | |
10111 | ->domainname | |
d77114b7 MK |
10112 | : "n/a"); |
10113 | } | |
10114 | ||
10115 | ||
10116 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
10117 | json_object_string_add( | |
60466a63 QY |
10118 | json_hname, "rcvHostName", |
10119 | p->hostname ? p->hostname | |
10120 | : "n/a"); | |
d77114b7 | 10121 | json_object_string_add( |
60466a63 QY |
10122 | json_hname, "rcvDomainName", |
10123 | p->domainname ? p->domainname | |
10124 | : "n/a"); | |
d77114b7 MK |
10125 | } |
10126 | ||
60466a63 | 10127 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
10128 | json_hname); |
10129 | ||
d62a17ae | 10130 | /* Gracefull Restart */ |
10131 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
10132 | || CHECK_FLAG(p->cap, | |
10133 | PEER_CAP_RESTART_ADV)) { | |
10134 | if (CHECK_FLAG(p->cap, | |
10135 | PEER_CAP_RESTART_ADV) | |
10136 | && CHECK_FLAG(p->cap, | |
10137 | PEER_CAP_RESTART_RCV)) | |
10138 | json_object_string_add( | |
10139 | json_cap, | |
10140 | "gracefulRestart", | |
10141 | "advertisedAndReceived"); | |
10142 | else if (CHECK_FLAG( | |
10143 | p->cap, | |
10144 | PEER_CAP_RESTART_ADV)) | |
10145 | json_object_string_add( | |
10146 | json_cap, | |
10147 | "gracefulRestartCapability", | |
10148 | "advertised"); | |
10149 | else if (CHECK_FLAG( | |
10150 | p->cap, | |
10151 | PEER_CAP_RESTART_RCV)) | |
10152 | json_object_string_add( | |
10153 | json_cap, | |
10154 | "gracefulRestartCapability", | |
10155 | "received"); | |
10156 | ||
10157 | if (CHECK_FLAG(p->cap, | |
10158 | PEER_CAP_RESTART_RCV)) { | |
10159 | int restart_af_count = 0; | |
10160 | json_object *json_restart = | |
10161 | NULL; | |
10162 | json_restart = | |
10163 | json_object_new_object(); | |
10164 | ||
10165 | json_object_int_add( | |
10166 | json_cap, | |
10167 | "gracefulRestartRemoteTimerMsecs", | |
10168 | p->v_gr_restart * 1000); | |
10169 | ||
05c7a1cc QY |
10170 | FOREACH_AFI_SAFI (afi, safi) { |
10171 | if (CHECK_FLAG( | |
10172 | p->af_cap | |
10173 | [afi] | |
10174 | [safi], | |
10175 | PEER_CAP_RESTART_AF_RCV)) { | |
10176 | json_object * | |
10177 | json_sub = | |
10178 | NULL; | |
10179 | json_sub = | |
10180 | json_object_new_object(); | |
10181 | ||
d62a17ae | 10182 | if (CHECK_FLAG( |
10183 | p->af_cap | |
10184 | [afi] | |
10185 | [safi], | |
05c7a1cc QY |
10186 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
10187 | json_object_boolean_true_add( | |
10188 | json_sub, | |
10189 | "preserved"); | |
10190 | restart_af_count++; | |
10191 | json_object_object_add( | |
10192 | json_restart, | |
5cb5f4d0 | 10193 | get_afi_safi_str( |
05c7a1cc | 10194 | afi, |
5cb5f4d0 DD |
10195 | safi, |
10196 | true), | |
05c7a1cc | 10197 | json_sub); |
d62a17ae | 10198 | } |
10199 | } | |
10200 | if (!restart_af_count) { | |
10201 | json_object_string_add( | |
10202 | json_cap, | |
10203 | "addressFamiliesByPeer", | |
10204 | "none"); | |
10205 | json_object_free( | |
10206 | json_restart); | |
10207 | } else | |
10208 | json_object_object_add( | |
10209 | json_cap, | |
10210 | "addressFamiliesByPeer", | |
10211 | json_restart); | |
10212 | } | |
10213 | } | |
10214 | json_object_object_add(json_neigh, | |
10215 | "neighborCapabilities", | |
10216 | json_cap); | |
10217 | } else { | |
10218 | vty_out(vty, " Neighbor capabilities:\n"); | |
10219 | ||
10220 | /* AS4 */ | |
10221 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
10222 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
10223 | vty_out(vty, " 4 Byte AS:"); | |
10224 | if (CHECK_FLAG(p->cap, | |
10225 | PEER_CAP_AS4_ADV)) | |
10226 | vty_out(vty, " advertised"); | |
10227 | if (CHECK_FLAG(p->cap, | |
10228 | PEER_CAP_AS4_RCV)) | |
10229 | vty_out(vty, " %sreceived", | |
10230 | CHECK_FLAG( | |
10231 | p->cap, | |
10232 | PEER_CAP_AS4_ADV) | |
10233 | ? "and " | |
10234 | : ""); | |
10235 | vty_out(vty, "\n"); | |
10236 | } | |
10237 | ||
10238 | /* AddPath */ | |
10239 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
10240 | || CHECK_FLAG(p->cap, | |
10241 | PEER_CAP_ADDPATH_ADV)) { | |
10242 | vty_out(vty, " AddPath:\n"); | |
10243 | ||
05c7a1cc QY |
10244 | FOREACH_AFI_SAFI (afi, safi) { |
10245 | if (CHECK_FLAG( | |
10246 | p->af_cap[afi] | |
10247 | [safi], | |
10248 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
10249 | || CHECK_FLAG( | |
10250 | p->af_cap[afi] | |
10251 | [safi], | |
10252 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
10253 | vty_out(vty, | |
10254 | " %s: TX ", | |
5cb5f4d0 | 10255 | get_afi_safi_str( |
05c7a1cc | 10256 | afi, |
5cb5f4d0 DD |
10257 | safi, |
10258 | false)); | |
05c7a1cc | 10259 | |
d62a17ae | 10260 | if (CHECK_FLAG( |
10261 | p->af_cap | |
10262 | [afi] | |
10263 | [safi], | |
05c7a1cc | 10264 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 10265 | vty_out(vty, |
05c7a1cc | 10266 | "advertised %s", |
5cb5f4d0 | 10267 | get_afi_safi_str( |
d62a17ae | 10268 | afi, |
5cb5f4d0 DD |
10269 | safi, |
10270 | false)); | |
d62a17ae | 10271 | |
05c7a1cc QY |
10272 | if (CHECK_FLAG( |
10273 | p->af_cap | |
10274 | [afi] | |
10275 | [safi], | |
10276 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
10277 | vty_out(vty, | |
10278 | "%sreceived", | |
10279 | CHECK_FLAG( | |
10280 | p->af_cap | |
10281 | [afi] | |
10282 | [safi], | |
10283 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
10284 | ? " and " | |
10285 | : ""); | |
d62a17ae | 10286 | |
05c7a1cc QY |
10287 | vty_out(vty, "\n"); |
10288 | } | |
d62a17ae | 10289 | |
05c7a1cc QY |
10290 | if (CHECK_FLAG( |
10291 | p->af_cap[afi] | |
10292 | [safi], | |
10293 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
10294 | || CHECK_FLAG( | |
10295 | p->af_cap[afi] | |
10296 | [safi], | |
10297 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
10298 | vty_out(vty, | |
10299 | " %s: RX ", | |
5cb5f4d0 | 10300 | get_afi_safi_str( |
05c7a1cc | 10301 | afi, |
5cb5f4d0 DD |
10302 | safi, |
10303 | false)); | |
d62a17ae | 10304 | |
10305 | if (CHECK_FLAG( | |
10306 | p->af_cap | |
10307 | [afi] | |
10308 | [safi], | |
05c7a1cc | 10309 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 10310 | vty_out(vty, |
05c7a1cc | 10311 | "advertised %s", |
5cb5f4d0 | 10312 | get_afi_safi_str( |
d62a17ae | 10313 | afi, |
5cb5f4d0 DD |
10314 | safi, |
10315 | false)); | |
d62a17ae | 10316 | |
05c7a1cc QY |
10317 | if (CHECK_FLAG( |
10318 | p->af_cap | |
10319 | [afi] | |
10320 | [safi], | |
10321 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 10322 | vty_out(vty, |
05c7a1cc QY |
10323 | "%sreceived", |
10324 | CHECK_FLAG( | |
10325 | p->af_cap | |
10326 | [afi] | |
10327 | [safi], | |
10328 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
10329 | ? " and " | |
10330 | : ""); | |
10331 | ||
10332 | vty_out(vty, "\n"); | |
d62a17ae | 10333 | } |
05c7a1cc | 10334 | } |
d62a17ae | 10335 | } |
10336 | ||
10337 | /* Dynamic */ | |
10338 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
10339 | || CHECK_FLAG(p->cap, | |
10340 | PEER_CAP_DYNAMIC_ADV)) { | |
10341 | vty_out(vty, " Dynamic:"); | |
10342 | if (CHECK_FLAG(p->cap, | |
10343 | PEER_CAP_DYNAMIC_ADV)) | |
10344 | vty_out(vty, " advertised"); | |
10345 | if (CHECK_FLAG(p->cap, | |
10346 | PEER_CAP_DYNAMIC_RCV)) | |
10347 | vty_out(vty, " %sreceived", | |
10348 | CHECK_FLAG( | |
10349 | p->cap, | |
10350 | PEER_CAP_DYNAMIC_ADV) | |
10351 | ? "and " | |
10352 | : ""); | |
10353 | vty_out(vty, "\n"); | |
10354 | } | |
10355 | ||
10356 | /* Extended nexthop */ | |
10357 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
10358 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
10359 | vty_out(vty, " Extended nexthop:"); | |
10360 | if (CHECK_FLAG(p->cap, | |
10361 | PEER_CAP_ENHE_ADV)) | |
10362 | vty_out(vty, " advertised"); | |
10363 | if (CHECK_FLAG(p->cap, | |
10364 | PEER_CAP_ENHE_RCV)) | |
10365 | vty_out(vty, " %sreceived", | |
10366 | CHECK_FLAG( | |
10367 | p->cap, | |
10368 | PEER_CAP_ENHE_ADV) | |
10369 | ? "and " | |
10370 | : ""); | |
10371 | vty_out(vty, "\n"); | |
10372 | ||
10373 | if (CHECK_FLAG(p->cap, | |
10374 | PEER_CAP_ENHE_RCV)) { | |
10375 | vty_out(vty, | |
10376 | " Address families by peer:\n "); | |
10377 | for (safi = SAFI_UNICAST; | |
10378 | safi < SAFI_MAX; safi++) | |
10379 | if (CHECK_FLAG( | |
10380 | p->af_cap | |
10381 | [AFI_IP] | |
10382 | [safi], | |
10383 | PEER_CAP_ENHE_AF_RCV)) | |
10384 | vty_out(vty, | |
10385 | " %s\n", | |
5cb5f4d0 | 10386 | get_afi_safi_str( |
d62a17ae | 10387 | AFI_IP, |
5cb5f4d0 DD |
10388 | safi, |
10389 | false)); | |
d62a17ae | 10390 | } |
10391 | } | |
10392 | ||
10393 | /* Route Refresh */ | |
10394 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
10395 | || CHECK_FLAG(p->cap, | |
10396 | PEER_CAP_REFRESH_NEW_RCV) | |
10397 | || CHECK_FLAG(p->cap, | |
10398 | PEER_CAP_REFRESH_OLD_RCV)) { | |
10399 | vty_out(vty, " Route refresh:"); | |
10400 | if (CHECK_FLAG(p->cap, | |
10401 | PEER_CAP_REFRESH_ADV)) | |
10402 | vty_out(vty, " advertised"); | |
10403 | if (CHECK_FLAG(p->cap, | |
10404 | PEER_CAP_REFRESH_NEW_RCV) | |
10405 | || CHECK_FLAG( | |
10406 | p->cap, | |
10407 | PEER_CAP_REFRESH_OLD_RCV)) | |
10408 | vty_out(vty, " %sreceived(%s)", | |
10409 | CHECK_FLAG( | |
10410 | p->cap, | |
10411 | PEER_CAP_REFRESH_ADV) | |
10412 | ? "and " | |
10413 | : "", | |
10414 | (CHECK_FLAG( | |
10415 | p->cap, | |
10416 | PEER_CAP_REFRESH_OLD_RCV) | |
10417 | && CHECK_FLAG( | |
10418 | p->cap, | |
10419 | PEER_CAP_REFRESH_NEW_RCV)) | |
10420 | ? "old & new" | |
10421 | : CHECK_FLAG( | |
10422 | p->cap, | |
10423 | PEER_CAP_REFRESH_OLD_RCV) | |
10424 | ? "old" | |
10425 | : "new"); | |
10426 | ||
10427 | vty_out(vty, "\n"); | |
10428 | } | |
10429 | ||
10430 | /* Multiprotocol Extensions */ | |
05c7a1cc QY |
10431 | FOREACH_AFI_SAFI (afi, safi) |
10432 | if (p->afc_adv[afi][safi] | |
10433 | || p->afc_recv[afi][safi]) { | |
10434 | vty_out(vty, | |
10435 | " Address Family %s:", | |
5cb5f4d0 DD |
10436 | get_afi_safi_str( |
10437 | afi, | |
10438 | safi, | |
10439 | false)); | |
05c7a1cc | 10440 | if (p->afc_adv[afi][safi]) |
d62a17ae | 10441 | vty_out(vty, |
05c7a1cc QY |
10442 | " advertised"); |
10443 | if (p->afc_recv[afi][safi]) | |
10444 | vty_out(vty, | |
10445 | " %sreceived", | |
10446 | p->afc_adv[afi] | |
10447 | [safi] | |
10448 | ? "and " | |
10449 | : ""); | |
10450 | vty_out(vty, "\n"); | |
10451 | } | |
d62a17ae | 10452 | |
10453 | /* Hostname capability */ | |
60466a63 | 10454 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
10455 | |
10456 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
10457 | vty_out(vty, |
10458 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
10459 | bgp->peer_self->hostname |
10460 | ? bgp->peer_self | |
10461 | ->hostname | |
d77114b7 | 10462 | : "n/a", |
60466a63 QY |
10463 | bgp->peer_self->domainname |
10464 | ? bgp->peer_self | |
10465 | ->domainname | |
d77114b7 MK |
10466 | : "n/a"); |
10467 | } else { | |
10468 | vty_out(vty, " not advertised"); | |
d62a17ae | 10469 | } |
10470 | ||
d77114b7 | 10471 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
10472 | vty_out(vty, |
10473 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
10474 | p->hostname ? p->hostname |
10475 | : "n/a", | |
10476 | p->domainname ? p->domainname | |
10477 | : "n/a"); | |
d77114b7 MK |
10478 | } else { |
10479 | vty_out(vty, " not received"); | |
10480 | } | |
10481 | ||
10482 | vty_out(vty, "\n"); | |
10483 | ||
d62a17ae | 10484 | /* Gracefull Restart */ |
10485 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
10486 | || CHECK_FLAG(p->cap, | |
10487 | PEER_CAP_RESTART_ADV)) { | |
10488 | vty_out(vty, | |
10489 | " Graceful Restart Capabilty:"); | |
10490 | if (CHECK_FLAG(p->cap, | |
10491 | PEER_CAP_RESTART_ADV)) | |
10492 | vty_out(vty, " advertised"); | |
10493 | if (CHECK_FLAG(p->cap, | |
10494 | PEER_CAP_RESTART_RCV)) | |
10495 | vty_out(vty, " %sreceived", | |
10496 | CHECK_FLAG( | |
10497 | p->cap, | |
10498 | PEER_CAP_RESTART_ADV) | |
10499 | ? "and " | |
10500 | : ""); | |
10501 | vty_out(vty, "\n"); | |
10502 | ||
10503 | if (CHECK_FLAG(p->cap, | |
10504 | PEER_CAP_RESTART_RCV)) { | |
10505 | int restart_af_count = 0; | |
10506 | ||
10507 | vty_out(vty, | |
10508 | " Remote Restart timer is %d seconds\n", | |
10509 | p->v_gr_restart); | |
10510 | vty_out(vty, | |
10511 | " Address families by peer:\n "); | |
10512 | ||
05c7a1cc QY |
10513 | FOREACH_AFI_SAFI (afi, safi) |
10514 | if (CHECK_FLAG( | |
10515 | p->af_cap | |
10516 | [afi] | |
10517 | [safi], | |
10518 | PEER_CAP_RESTART_AF_RCV)) { | |
10519 | vty_out(vty, | |
10520 | "%s%s(%s)", | |
10521 | restart_af_count | |
10522 | ? ", " | |
10523 | : "", | |
5cb5f4d0 | 10524 | get_afi_safi_str( |
05c7a1cc | 10525 | afi, |
5cb5f4d0 DD |
10526 | safi, |
10527 | false), | |
05c7a1cc QY |
10528 | CHECK_FLAG( |
10529 | p->af_cap | |
10530 | [afi] | |
10531 | [safi], | |
10532 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
10533 | ? "preserved" | |
10534 | : "not preserved"); | |
10535 | restart_af_count++; | |
10536 | } | |
d62a17ae | 10537 | if (!restart_af_count) |
10538 | vty_out(vty, "none"); | |
10539 | vty_out(vty, "\n"); | |
10540 | } | |
10541 | } | |
10542 | } | |
10543 | } | |
10544 | } | |
10545 | ||
10546 | /* graceful restart information */ | |
10547 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) || p->t_gr_restart | |
10548 | || p->t_gr_stale) { | |
10549 | json_object *json_grace = NULL; | |
10550 | json_object *json_grace_send = NULL; | |
10551 | json_object *json_grace_recv = NULL; | |
10552 | int eor_send_af_count = 0; | |
10553 | int eor_receive_af_count = 0; | |
10554 | ||
10555 | if (use_json) { | |
10556 | json_grace = json_object_new_object(); | |
10557 | json_grace_send = json_object_new_object(); | |
10558 | json_grace_recv = json_object_new_object(); | |
10559 | ||
10560 | if (p->status == Established) { | |
05c7a1cc QY |
10561 | FOREACH_AFI_SAFI (afi, safi) { |
10562 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10563 | PEER_STATUS_EOR_SEND)) { | |
10564 | json_object_boolean_true_add( | |
10565 | json_grace_send, | |
5cb5f4d0 DD |
10566 | get_afi_safi_str(afi, |
10567 | safi, | |
10568 | true)); | |
05c7a1cc | 10569 | eor_send_af_count++; |
d62a17ae | 10570 | } |
10571 | } | |
05c7a1cc QY |
10572 | FOREACH_AFI_SAFI (afi, safi) { |
10573 | if (CHECK_FLAG( | |
10574 | p->af_sflags[afi][safi], | |
10575 | PEER_STATUS_EOR_RECEIVED)) { | |
10576 | json_object_boolean_true_add( | |
10577 | json_grace_recv, | |
5cb5f4d0 DD |
10578 | get_afi_safi_str(afi, |
10579 | safi, | |
10580 | true)); | |
05c7a1cc | 10581 | eor_receive_af_count++; |
d62a17ae | 10582 | } |
10583 | } | |
10584 | } | |
10585 | ||
10586 | json_object_object_add(json_grace, "endOfRibSend", | |
10587 | json_grace_send); | |
10588 | json_object_object_add(json_grace, "endOfRibRecv", | |
10589 | json_grace_recv); | |
10590 | ||
10591 | if (p->t_gr_restart) | |
10592 | json_object_int_add(json_grace, | |
10593 | "gracefulRestartTimerMsecs", | |
10594 | thread_timer_remain_second( | |
10595 | p->t_gr_restart) | |
10596 | * 1000); | |
10597 | ||
10598 | if (p->t_gr_stale) | |
10599 | json_object_int_add( | |
10600 | json_grace, | |
10601 | "gracefulStalepathTimerMsecs", | |
10602 | thread_timer_remain_second( | |
10603 | p->t_gr_stale) | |
10604 | * 1000); | |
10605 | ||
10606 | json_object_object_add( | |
10607 | json_neigh, "gracefulRestartInfo", json_grace); | |
10608 | } else { | |
0437e105 | 10609 | vty_out(vty, " Graceful restart information:\n"); |
d62a17ae | 10610 | if (p->status == Established) { |
10611 | vty_out(vty, " End-of-RIB send: "); | |
05c7a1cc QY |
10612 | FOREACH_AFI_SAFI (afi, safi) { |
10613 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10614 | PEER_STATUS_EOR_SEND)) { | |
10615 | vty_out(vty, "%s%s", | |
10616 | eor_send_af_count ? ", " | |
10617 | : "", | |
5cb5f4d0 DD |
10618 | get_afi_safi_str(afi, |
10619 | safi, | |
10620 | false)); | |
05c7a1cc | 10621 | eor_send_af_count++; |
d62a17ae | 10622 | } |
10623 | } | |
10624 | vty_out(vty, "\n"); | |
10625 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
10626 | FOREACH_AFI_SAFI (afi, safi) { |
10627 | if (CHECK_FLAG( | |
10628 | p->af_sflags[afi][safi], | |
10629 | PEER_STATUS_EOR_RECEIVED)) { | |
10630 | vty_out(vty, "%s%s", | |
10631 | eor_receive_af_count | |
10632 | ? ", " | |
10633 | : "", | |
5cb5f4d0 DD |
10634 | get_afi_safi_str(afi, |
10635 | safi, | |
10636 | false)); | |
05c7a1cc | 10637 | eor_receive_af_count++; |
d62a17ae | 10638 | } |
10639 | } | |
10640 | vty_out(vty, "\n"); | |
10641 | } | |
10642 | ||
10643 | if (p->t_gr_restart) | |
10644 | vty_out(vty, | |
10645 | " The remaining time of restart timer is %ld\n", | |
10646 | thread_timer_remain_second( | |
10647 | p->t_gr_restart)); | |
10648 | ||
10649 | if (p->t_gr_stale) | |
10650 | vty_out(vty, | |
10651 | " The remaining time of stalepath timer is %ld\n", | |
10652 | thread_timer_remain_second( | |
10653 | p->t_gr_stale)); | |
10654 | } | |
10655 | } | |
10656 | if (use_json) { | |
10657 | json_object *json_stat = NULL; | |
10658 | json_stat = json_object_new_object(); | |
10659 | /* Packet counts. */ | |
10660 | json_object_int_add(json_stat, "depthInq", 0); | |
10661 | json_object_int_add(json_stat, "depthOutq", | |
10662 | (unsigned long)p->obuf->count); | |
0112e9e0 QY |
10663 | json_object_int_add(json_stat, "opensSent", |
10664 | atomic_load_explicit(&p->open_out, | |
10665 | memory_order_relaxed)); | |
10666 | json_object_int_add(json_stat, "opensRecv", | |
10667 | atomic_load_explicit(&p->open_in, | |
10668 | memory_order_relaxed)); | |
d62a17ae | 10669 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
10670 | atomic_load_explicit(&p->notify_out, |
10671 | memory_order_relaxed)); | |
d62a17ae | 10672 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
10673 | atomic_load_explicit(&p->notify_in, |
10674 | memory_order_relaxed)); | |
10675 | json_object_int_add(json_stat, "updatesSent", | |
10676 | atomic_load_explicit(&p->update_out, | |
10677 | memory_order_relaxed)); | |
10678 | json_object_int_add(json_stat, "updatesRecv", | |
10679 | atomic_load_explicit(&p->update_in, | |
10680 | memory_order_relaxed)); | |
d62a17ae | 10681 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
10682 | atomic_load_explicit(&p->keepalive_out, |
10683 | memory_order_relaxed)); | |
d62a17ae | 10684 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
10685 | atomic_load_explicit(&p->keepalive_in, |
10686 | memory_order_relaxed)); | |
d62a17ae | 10687 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
10688 | atomic_load_explicit(&p->refresh_out, |
10689 | memory_order_relaxed)); | |
d62a17ae | 10690 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
10691 | atomic_load_explicit(&p->refresh_in, |
10692 | memory_order_relaxed)); | |
d62a17ae | 10693 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
10694 | atomic_load_explicit(&p->dynamic_cap_out, |
10695 | memory_order_relaxed)); | |
d62a17ae | 10696 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
10697 | atomic_load_explicit(&p->dynamic_cap_in, |
10698 | memory_order_relaxed)); | |
10699 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
10700 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 10701 | json_object_object_add(json_neigh, "messageStats", json_stat); |
10702 | } else { | |
10703 | /* Packet counts. */ | |
10704 | vty_out(vty, " Message statistics:\n"); | |
10705 | vty_out(vty, " Inq depth is 0\n"); | |
10706 | vty_out(vty, " Outq depth is %lu\n", | |
10707 | (unsigned long)p->obuf->count); | |
10708 | vty_out(vty, " Sent Rcvd\n"); | |
0112e9e0 QY |
10709 | vty_out(vty, " Opens: %10d %10d\n", |
10710 | atomic_load_explicit(&p->open_out, | |
10711 | memory_order_relaxed), | |
10712 | atomic_load_explicit(&p->open_in, | |
10713 | memory_order_relaxed)); | |
10714 | vty_out(vty, " Notifications: %10d %10d\n", | |
10715 | atomic_load_explicit(&p->notify_out, | |
10716 | memory_order_relaxed), | |
10717 | atomic_load_explicit(&p->notify_in, | |
10718 | memory_order_relaxed)); | |
10719 | vty_out(vty, " Updates: %10d %10d\n", | |
10720 | atomic_load_explicit(&p->update_out, | |
10721 | memory_order_relaxed), | |
10722 | atomic_load_explicit(&p->update_in, | |
10723 | memory_order_relaxed)); | |
10724 | vty_out(vty, " Keepalives: %10d %10d\n", | |
10725 | atomic_load_explicit(&p->keepalive_out, | |
10726 | memory_order_relaxed), | |
10727 | atomic_load_explicit(&p->keepalive_in, | |
10728 | memory_order_relaxed)); | |
10729 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
10730 | atomic_load_explicit(&p->refresh_out, | |
10731 | memory_order_relaxed), | |
10732 | atomic_load_explicit(&p->refresh_in, | |
10733 | memory_order_relaxed)); | |
d62a17ae | 10734 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
10735 | atomic_load_explicit(&p->dynamic_cap_out, |
10736 | memory_order_relaxed), | |
10737 | atomic_load_explicit(&p->dynamic_cap_in, | |
10738 | memory_order_relaxed)); | |
10739 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
10740 | PEER_TOTAL_RX(p)); | |
d62a17ae | 10741 | } |
10742 | ||
10743 | if (use_json) { | |
10744 | /* advertisement-interval */ | |
10745 | json_object_int_add(json_neigh, | |
10746 | "minBtwnAdvertisementRunsTimerMsecs", | |
10747 | p->v_routeadv * 1000); | |
10748 | ||
10749 | /* Update-source. */ | |
10750 | if (p->update_if || p->update_source) { | |
10751 | if (p->update_if) | |
10752 | json_object_string_add(json_neigh, | |
10753 | "updateSource", | |
10754 | p->update_if); | |
10755 | else if (p->update_source) | |
10756 | json_object_string_add( | |
10757 | json_neigh, "updateSource", | |
10758 | sockunion2str(p->update_source, buf1, | |
10759 | SU_ADDRSTRLEN)); | |
10760 | } | |
10761 | } else { | |
10762 | /* advertisement-interval */ | |
10763 | vty_out(vty, | |
10764 | " Minimum time between advertisement runs is %d seconds\n", | |
10765 | p->v_routeadv); | |
10766 | ||
10767 | /* Update-source. */ | |
10768 | if (p->update_if || p->update_source) { | |
10769 | vty_out(vty, " Update source is "); | |
10770 | if (p->update_if) | |
10771 | vty_out(vty, "%s", p->update_if); | |
10772 | else if (p->update_source) | |
10773 | vty_out(vty, "%s", | |
10774 | sockunion2str(p->update_source, buf1, | |
10775 | SU_ADDRSTRLEN)); | |
10776 | vty_out(vty, "\n"); | |
10777 | } | |
10778 | ||
10779 | vty_out(vty, "\n"); | |
10780 | } | |
10781 | ||
10782 | /* Address Family Information */ | |
10783 | json_object *json_hold = NULL; | |
10784 | ||
10785 | if (use_json) | |
10786 | json_hold = json_object_new_object(); | |
10787 | ||
05c7a1cc QY |
10788 | FOREACH_AFI_SAFI (afi, safi) |
10789 | if (p->afc[afi][safi]) | |
10790 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
10791 | json_hold); | |
d62a17ae | 10792 | |
10793 | if (use_json) { | |
10794 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
10795 | json_hold); | |
10796 | json_object_int_add(json_neigh, "connectionsEstablished", | |
10797 | p->established); | |
10798 | json_object_int_add(json_neigh, "connectionsDropped", | |
10799 | p->dropped); | |
10800 | } else | |
10801 | vty_out(vty, " Connections established %d; dropped %d\n", | |
10802 | p->established, p->dropped); | |
10803 | ||
10804 | if (!p->last_reset) { | |
10805 | if (use_json) | |
10806 | json_object_string_add(json_neigh, "lastReset", | |
10807 | "never"); | |
10808 | else | |
10809 | vty_out(vty, " Last reset never\n"); | |
10810 | } else { | |
10811 | if (use_json) { | |
10812 | time_t uptime; | |
10813 | struct tm *tm; | |
10814 | ||
10815 | uptime = bgp_clock(); | |
10816 | uptime -= p->resettime; | |
10817 | tm = gmtime(&uptime); | |
10818 | json_object_int_add(json_neigh, "lastResetTimerMsecs", | |
10819 | (tm->tm_sec * 1000) | |
10820 | + (tm->tm_min * 60000) | |
10821 | + (tm->tm_hour * 3600000)); | |
3577f1c5 | 10822 | bgp_show_peer_reset(NULL, p, json_neigh, true); |
d62a17ae | 10823 | } else { |
10824 | vty_out(vty, " Last reset %s, ", | |
10825 | peer_uptime(p->resettime, timebuf, | |
10826 | BGP_UPTIME_LEN, 0, NULL)); | |
10827 | ||
3577f1c5 | 10828 | bgp_show_peer_reset(vty, p, NULL, false); |
d62a17ae | 10829 | if (p->last_reset_cause_size) { |
10830 | msg = p->last_reset_cause; | |
10831 | vty_out(vty, | |
10832 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
10833 | for (i = 1; i <= p->last_reset_cause_size; | |
10834 | i++) { | |
10835 | vty_out(vty, "%02X", *msg++); | |
10836 | ||
10837 | if (i != p->last_reset_cause_size) { | |
10838 | if (i % 16 == 0) { | |
10839 | vty_out(vty, "\n "); | |
10840 | } else if (i % 4 == 0) { | |
10841 | vty_out(vty, " "); | |
10842 | } | |
10843 | } | |
10844 | } | |
10845 | vty_out(vty, "\n"); | |
10846 | } | |
10847 | } | |
10848 | } | |
10849 | ||
10850 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
10851 | if (use_json) | |
10852 | json_object_boolean_true_add(json_neigh, | |
10853 | "prefixesConfigExceedMax"); | |
10854 | else | |
10855 | vty_out(vty, | |
10856 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
10857 | ||
10858 | if (p->t_pmax_restart) { | |
10859 | if (use_json) { | |
10860 | json_object_boolean_true_add( | |
10861 | json_neigh, "reducePrefixNumFrom"); | |
10862 | json_object_int_add(json_neigh, | |
10863 | "restartInTimerMsec", | |
10864 | thread_timer_remain_second( | |
10865 | p->t_pmax_restart) | |
10866 | * 1000); | |
10867 | } else | |
10868 | vty_out(vty, | |
10869 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
10870 | p->host, thread_timer_remain_second( |
10871 | p->t_pmax_restart)); | |
d62a17ae | 10872 | } else { |
10873 | if (use_json) | |
10874 | json_object_boolean_true_add( | |
10875 | json_neigh, | |
10876 | "reducePrefixNumAndClearIpBgp"); | |
10877 | else | |
10878 | vty_out(vty, | |
10879 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
10880 | p->host); | |
10881 | } | |
10882 | } | |
10883 | ||
10884 | /* EBGP Multihop and GTSM */ | |
10885 | if (p->sort != BGP_PEER_IBGP) { | |
10886 | if (use_json) { | |
10887 | if (p->gtsm_hops > 0) | |
10888 | json_object_int_add(json_neigh, | |
10889 | "externalBgpNbrMaxHopsAway", | |
10890 | p->gtsm_hops); | |
10891 | else if (p->ttl > 1) | |
10892 | json_object_int_add(json_neigh, | |
10893 | "externalBgpNbrMaxHopsAway", | |
10894 | p->ttl); | |
10895 | } else { | |
10896 | if (p->gtsm_hops > 0) | |
10897 | vty_out(vty, | |
10898 | " External BGP neighbor may be up to %d hops away.\n", | |
10899 | p->gtsm_hops); | |
10900 | else if (p->ttl > 1) | |
10901 | vty_out(vty, | |
10902 | " External BGP neighbor may be up to %d hops away.\n", | |
10903 | p->ttl); | |
10904 | } | |
10905 | } else { | |
10906 | if (p->gtsm_hops > 0) { | |
10907 | if (use_json) | |
10908 | json_object_int_add(json_neigh, | |
10909 | "internalBgpNbrMaxHopsAway", | |
10910 | p->gtsm_hops); | |
10911 | else | |
10912 | vty_out(vty, | |
10913 | " Internal BGP neighbor may be up to %d hops away.\n", | |
10914 | p->gtsm_hops); | |
10915 | } | |
10916 | } | |
10917 | ||
10918 | /* Local address. */ | |
10919 | if (p->su_local) { | |
10920 | if (use_json) { | |
10921 | json_object_string_add(json_neigh, "hostLocal", | |
10922 | sockunion2str(p->su_local, buf1, | |
10923 | SU_ADDRSTRLEN)); | |
10924 | json_object_int_add(json_neigh, "portLocal", | |
10925 | ntohs(p->su_local->sin.sin_port)); | |
10926 | } else | |
10927 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
10928 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
10929 | ntohs(p->su_local->sin.sin_port)); | |
10930 | } | |
10931 | ||
10932 | /* Remote address. */ | |
10933 | if (p->su_remote) { | |
10934 | if (use_json) { | |
10935 | json_object_string_add(json_neigh, "hostForeign", | |
10936 | sockunion2str(p->su_remote, buf1, | |
10937 | SU_ADDRSTRLEN)); | |
10938 | json_object_int_add(json_neigh, "portForeign", | |
10939 | ntohs(p->su_remote->sin.sin_port)); | |
10940 | } else | |
10941 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
10942 | sockunion2str(p->su_remote, buf1, | |
10943 | SU_ADDRSTRLEN), | |
10944 | ntohs(p->su_remote->sin.sin_port)); | |
10945 | } | |
10946 | ||
10947 | /* Nexthop display. */ | |
10948 | if (p->su_local) { | |
10949 | if (use_json) { | |
10950 | json_object_string_add(json_neigh, "nexthop", | |
10951 | inet_ntop(AF_INET, | |
10952 | &p->nexthop.v4, buf1, | |
10953 | sizeof(buf1))); | |
10954 | json_object_string_add(json_neigh, "nexthopGlobal", | |
10955 | inet_ntop(AF_INET6, | |
10956 | &p->nexthop.v6_global, | |
10957 | buf1, sizeof(buf1))); | |
10958 | json_object_string_add(json_neigh, "nexthopLocal", | |
10959 | inet_ntop(AF_INET6, | |
10960 | &p->nexthop.v6_local, | |
10961 | buf1, sizeof(buf1))); | |
10962 | if (p->shared_network) | |
10963 | json_object_string_add(json_neigh, | |
10964 | "bgpConnection", | |
10965 | "sharedNetwork"); | |
10966 | else | |
10967 | json_object_string_add(json_neigh, | |
10968 | "bgpConnection", | |
10969 | "nonSharedNetwork"); | |
10970 | } else { | |
10971 | vty_out(vty, "Nexthop: %s\n", | |
10972 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
10973 | sizeof(buf1))); | |
10974 | vty_out(vty, "Nexthop global: %s\n", | |
10975 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
10976 | sizeof(buf1))); | |
10977 | vty_out(vty, "Nexthop local: %s\n", | |
10978 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
10979 | sizeof(buf1))); | |
10980 | vty_out(vty, "BGP connection: %s\n", | |
10981 | p->shared_network ? "shared network" | |
10982 | : "non shared network"); | |
10983 | } | |
10984 | } | |
10985 | ||
10986 | /* Timer information. */ | |
10987 | if (use_json) { | |
10988 | json_object_int_add(json_neigh, "connectRetryTimer", | |
10989 | p->v_connect); | |
10990 | if (p->status == Established && p->rtt) | |
10991 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
10992 | p->rtt); | |
10993 | if (p->t_start) | |
10994 | json_object_int_add( | |
10995 | json_neigh, "nextStartTimerDueInMsecs", | |
10996 | thread_timer_remain_second(p->t_start) * 1000); | |
10997 | if (p->t_connect) | |
10998 | json_object_int_add( | |
10999 | json_neigh, "nextConnectTimerDueInMsecs", | |
11000 | thread_timer_remain_second(p->t_connect) | |
11001 | * 1000); | |
11002 | if (p->t_routeadv) { | |
11003 | json_object_int_add(json_neigh, "mraiInterval", | |
11004 | p->v_routeadv); | |
11005 | json_object_int_add( | |
11006 | json_neigh, "mraiTimerExpireInMsecs", | |
11007 | thread_timer_remain_second(p->t_routeadv) | |
11008 | * 1000); | |
11009 | } | |
11010 | if (p->password) | |
11011 | json_object_int_add(json_neigh, "authenticationEnabled", | |
11012 | 1); | |
11013 | ||
11014 | if (p->t_read) | |
11015 | json_object_string_add(json_neigh, "readThread", "on"); | |
11016 | else | |
11017 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
11018 | |
11019 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 11020 | json_object_string_add(json_neigh, "writeThread", "on"); |
11021 | else | |
11022 | json_object_string_add(json_neigh, "writeThread", | |
11023 | "off"); | |
11024 | } else { | |
11025 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
11026 | p->v_connect); | |
11027 | if (p->status == Established && p->rtt) | |
11028 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
11029 | p->rtt); | |
11030 | if (p->t_start) | |
11031 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
11032 | thread_timer_remain_second(p->t_start)); | |
11033 | if (p->t_connect) | |
11034 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
11035 | thread_timer_remain_second(p->t_connect)); | |
11036 | if (p->t_routeadv) | |
11037 | vty_out(vty, | |
11038 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
11039 | p->v_routeadv, | |
11040 | thread_timer_remain_second(p->t_routeadv)); | |
11041 | if (p->password) | |
11042 | vty_out(vty, "Peer Authentication Enabled\n"); | |
11043 | ||
cac9e917 | 11044 | vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n", |
49507a6f QY |
11045 | p->t_read ? "on" : "off", |
11046 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
11047 | ? "on" | |
cac9e917 | 11048 | : "off", p->fd); |
d62a17ae | 11049 | } |
11050 | ||
11051 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
11052 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
11053 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
11054 | ||
11055 | if (!use_json) | |
11056 | vty_out(vty, "\n"); | |
11057 | ||
11058 | /* BFD information. */ | |
11059 | bgp_bfd_show_info(vty, p, use_json, json_neigh); | |
11060 | ||
11061 | if (use_json) { | |
11062 | if (p->conf_if) /* Configured interface name. */ | |
11063 | json_object_object_add(json, p->conf_if, json_neigh); | |
11064 | else /* Configured IP address. */ | |
11065 | json_object_object_add(json, p->host, json_neigh); | |
11066 | } | |
11067 | } | |
11068 | ||
11069 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, | |
11070 | enum show_type type, union sockunion *su, | |
9f049418 | 11071 | const char *conf_if, bool use_json, |
d62a17ae | 11072 | json_object *json) |
11073 | { | |
11074 | struct listnode *node, *nnode; | |
11075 | struct peer *peer; | |
11076 | int find = 0; | |
9f049418 | 11077 | bool nbr_output = false; |
d1927ebe AS |
11078 | afi_t afi = AFI_MAX; |
11079 | safi_t safi = SAFI_MAX; | |
11080 | ||
11081 | if (type == show_ipv4_peer || type == show_ipv4_all) { | |
11082 | afi = AFI_IP; | |
11083 | } else if (type == show_ipv6_peer || type == show_ipv6_all) { | |
11084 | afi = AFI_IP6; | |
11085 | } | |
d62a17ae | 11086 | |
11087 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
11088 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
11089 | continue; | |
11090 | ||
11091 | switch (type) { | |
11092 | case show_all: | |
11093 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 11094 | nbr_output = true; |
d62a17ae | 11095 | break; |
11096 | case show_peer: | |
11097 | if (conf_if) { | |
11098 | if ((peer->conf_if | |
11099 | && !strcmp(peer->conf_if, conf_if)) | |
11100 | || (peer->hostname | |
11101 | && !strcmp(peer->hostname, conf_if))) { | |
11102 | find = 1; | |
11103 | bgp_show_peer(vty, peer, use_json, | |
11104 | json); | |
11105 | } | |
11106 | } else { | |
11107 | if (sockunion_same(&peer->su, su)) { | |
11108 | find = 1; | |
11109 | bgp_show_peer(vty, peer, use_json, | |
11110 | json); | |
11111 | } | |
11112 | } | |
11113 | break; | |
d1927ebe AS |
11114 | case show_ipv4_peer: |
11115 | case show_ipv6_peer: | |
11116 | FOREACH_SAFI (safi) { | |
11117 | if (peer->afc[afi][safi]) { | |
11118 | if (conf_if) { | |
11119 | if ((peer->conf_if | |
11120 | && !strcmp(peer->conf_if, conf_if)) | |
11121 | || (peer->hostname | |
11122 | && !strcmp(peer->hostname, conf_if))) { | |
11123 | find = 1; | |
11124 | bgp_show_peer(vty, peer, use_json, | |
11125 | json); | |
11126 | break; | |
11127 | } | |
11128 | } else { | |
11129 | if (sockunion_same(&peer->su, su)) { | |
11130 | find = 1; | |
11131 | bgp_show_peer(vty, peer, use_json, | |
11132 | json); | |
11133 | break; | |
11134 | } | |
11135 | } | |
11136 | } | |
11137 | } | |
11138 | break; | |
11139 | case show_ipv4_all: | |
11140 | case show_ipv6_all: | |
11141 | FOREACH_SAFI (safi) { | |
11142 | if (peer->afc[afi][safi]) { | |
11143 | bgp_show_peer(vty, peer, use_json, json); | |
11144 | nbr_output = true; | |
11145 | break; | |
11146 | } | |
11147 | } | |
11148 | break; | |
d62a17ae | 11149 | } |
11150 | } | |
11151 | ||
d1927ebe AS |
11152 | if ((type == show_peer || type == show_ipv4_peer || |
11153 | type == show_ipv6_peer) && !find) { | |
d62a17ae | 11154 | if (use_json) |
11155 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
11156 | else | |
88b7d255 | 11157 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 11158 | } |
11159 | ||
d1927ebe AS |
11160 | if (type != show_peer && type != show_ipv4_peer && |
11161 | type != show_ipv6_peer && !nbr_output && !use_json) | |
94d4c685 | 11162 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 11163 | |
d62a17ae | 11164 | if (use_json) { |
996c9314 LB |
11165 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
11166 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 11167 | } else { |
11168 | vty_out(vty, "\n"); | |
11169 | } | |
11170 | ||
11171 | return CMD_SUCCESS; | |
11172 | } | |
11173 | ||
11174 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, | |
71aedaa3 DS |
11175 | enum show_type type, |
11176 | const char *ip_str, | |
9f049418 | 11177 | bool use_json) |
d62a17ae | 11178 | { |
0291c246 MK |
11179 | struct listnode *node, *nnode; |
11180 | struct bgp *bgp; | |
71aedaa3 | 11181 | union sockunion su; |
0291c246 | 11182 | json_object *json = NULL; |
71aedaa3 | 11183 | int ret, is_first = 1; |
9f049418 | 11184 | bool nbr_output = false; |
d62a17ae | 11185 | |
11186 | if (use_json) | |
11187 | vty_out(vty, "{\n"); | |
11188 | ||
11189 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 11190 | nbr_output = true; |
d62a17ae | 11191 | if (use_json) { |
11192 | if (!(json = json_object_new_object())) { | |
af4c2728 | 11193 | flog_err( |
e50f7cfd | 11194 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 11195 | "Unable to allocate memory for JSON object"); |
11196 | vty_out(vty, | |
11197 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
11198 | return; | |
11199 | } | |
11200 | ||
11201 | json_object_int_add(json, "vrfId", | |
11202 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
11203 | ? -1 |
11204 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 11205 | json_object_string_add( |
11206 | json, "vrfName", | |
11207 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11208 | ? VRF_DEFAULT_NAME |
d62a17ae | 11209 | : bgp->name); |
11210 | ||
11211 | if (!is_first) | |
11212 | vty_out(vty, ",\n"); | |
11213 | else | |
11214 | is_first = 0; | |
11215 | ||
11216 | vty_out(vty, "\"%s\":", | |
11217 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11218 | ? VRF_DEFAULT_NAME |
d62a17ae | 11219 | : bgp->name); |
11220 | } else { | |
11221 | vty_out(vty, "\nInstance %s:\n", | |
11222 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11223 | ? VRF_DEFAULT_NAME |
d62a17ae | 11224 | : bgp->name); |
11225 | } | |
71aedaa3 | 11226 | |
d1927ebe AS |
11227 | if (type == show_peer || type == show_ipv4_peer || |
11228 | type == show_ipv6_peer) { | |
71aedaa3 DS |
11229 | ret = str2sockunion(ip_str, &su); |
11230 | if (ret < 0) | |
11231 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
11232 | use_json, json); | |
11233 | else | |
11234 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
11235 | use_json, json); | |
11236 | } else { | |
d1927ebe | 11237 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, |
71aedaa3 DS |
11238 | use_json, json); |
11239 | } | |
b77004d6 | 11240 | json_object_free(json); |
d62a17ae | 11241 | } |
11242 | ||
01cbfd04 | 11243 | if (use_json) { |
d62a17ae | 11244 | vty_out(vty, "}\n"); |
01cbfd04 QY |
11245 | json_object_free(json); |
11246 | } | |
9f049418 DS |
11247 | else if (!nbr_output) |
11248 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 11249 | } |
11250 | ||
11251 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
11252 | enum show_type type, const char *ip_str, | |
9f049418 | 11253 | bool use_json) |
d62a17ae | 11254 | { |
11255 | int ret; | |
11256 | struct bgp *bgp; | |
11257 | union sockunion su; | |
11258 | json_object *json = NULL; | |
11259 | ||
11260 | if (name) { | |
11261 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
11262 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
11263 | use_json); | |
d62a17ae | 11264 | return CMD_SUCCESS; |
11265 | } else { | |
11266 | bgp = bgp_lookup_by_name(name); | |
11267 | if (!bgp) { | |
11268 | if (use_json) { | |
11269 | json = json_object_new_object(); | |
d62a17ae | 11270 | vty_out(vty, "%s\n", |
11271 | json_object_to_json_string_ext( | |
11272 | json, | |
11273 | JSON_C_TO_STRING_PRETTY)); | |
11274 | json_object_free(json); | |
11275 | } else | |
11276 | vty_out(vty, | |
9f049418 | 11277 | "%% BGP instance not found\n"); |
d62a17ae | 11278 | |
11279 | return CMD_WARNING; | |
11280 | } | |
11281 | } | |
11282 | } else { | |
11283 | bgp = bgp_get_default(); | |
11284 | } | |
11285 | ||
11286 | if (bgp) { | |
11287 | json = json_object_new_object(); | |
11288 | if (ip_str) { | |
11289 | ret = str2sockunion(ip_str, &su); | |
11290 | if (ret < 0) | |
11291 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
11292 | use_json, json); | |
11293 | else | |
11294 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
11295 | use_json, json); | |
11296 | } else { | |
11297 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
11298 | json); | |
11299 | } | |
11300 | json_object_free(json); | |
ca61fd25 DS |
11301 | } else { |
11302 | if (use_json) | |
11303 | vty_out(vty, "{}\n"); | |
11304 | else | |
11305 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 11306 | } |
11307 | ||
11308 | return CMD_SUCCESS; | |
4fb25c53 DW |
11309 | } |
11310 | ||
716b2d8a | 11311 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 11312 | DEFUN (show_ip_bgp_neighbors, |
11313 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 11314 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 11315 | SHOW_STR |
11316 | IP_STR | |
11317 | BGP_STR | |
f2a8972b | 11318 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
11319 | "Address Family\n" |
11320 | "Address Family\n" | |
718e3744 | 11321 | "Detailed information on TCP and BGP neighbor connections\n" |
11322 | "Neighbor to display information about\n" | |
a80beece | 11323 | "Neighbor to display information about\n" |
91d37724 | 11324 | "Neighbor on BGP configured interface\n" |
9973d184 | 11325 | JSON_STR) |
718e3744 | 11326 | { |
d62a17ae | 11327 | char *vrf = NULL; |
11328 | char *sh_arg = NULL; | |
11329 | enum show_type sh_type; | |
d1927ebe | 11330 | afi_t afi = AFI_MAX; |
718e3744 | 11331 | |
9f049418 | 11332 | bool uj = use_json(argc, argv); |
718e3744 | 11333 | |
d62a17ae | 11334 | int idx = 0; |
718e3744 | 11335 | |
9a8bdf1c PG |
11336 | /* [<vrf> VIEWVRFNAME] */ |
11337 | if (argv_find(argv, argc, "vrf", &idx)) { | |
11338 | vrf = argv[idx + 1]->arg; | |
11339 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11340 | vrf = NULL; | |
11341 | } else if (argv_find(argv, argc, "view", &idx)) | |
11342 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 11343 | vrf = argv[idx + 1]->arg; |
718e3744 | 11344 | |
d62a17ae | 11345 | idx++; |
d1927ebe AS |
11346 | |
11347 | if (argv_find(argv, argc, "ipv4", &idx)) { | |
11348 | sh_type = show_ipv4_all; | |
11349 | afi = AFI_IP; | |
11350 | } else if (argv_find(argv, argc, "ipv6", &idx)) { | |
11351 | sh_type = show_ipv6_all; | |
11352 | afi = AFI_IP6; | |
11353 | } else { | |
11354 | sh_type = show_all; | |
11355 | } | |
11356 | ||
d62a17ae | 11357 | if (argv_find(argv, argc, "A.B.C.D", &idx) |
11358 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
11359 | || argv_find(argv, argc, "WORD", &idx)) { | |
11360 | sh_type = show_peer; | |
11361 | sh_arg = argv[idx]->arg; | |
d1927ebe AS |
11362 | } |
11363 | ||
11364 | if (sh_type == show_peer && afi == AFI_IP) { | |
11365 | sh_type = show_ipv4_peer; | |
11366 | } else if (sh_type == show_peer && afi == AFI_IP6) { | |
11367 | sh_type = show_ipv6_peer; | |
11368 | } | |
856ca177 | 11369 | |
d62a17ae | 11370 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 11371 | } |
11372 | ||
716b2d8a | 11373 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 11374 | paths' and `show ip mbgp paths'. Those functions results are the |
11375 | same.*/ | |
f412b39a | 11376 | DEFUN (show_ip_bgp_paths, |
718e3744 | 11377 | show_ip_bgp_paths_cmd, |
46f296b4 | 11378 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 11379 | SHOW_STR |
11380 | IP_STR | |
11381 | BGP_STR | |
46f296b4 | 11382 | BGP_SAFI_HELP_STR |
718e3744 | 11383 | "Path information\n") |
11384 | { | |
d62a17ae | 11385 | vty_out(vty, "Address Refcnt Path\n"); |
11386 | aspath_print_all_vty(vty); | |
11387 | return CMD_SUCCESS; | |
718e3744 | 11388 | } |
11389 | ||
718e3744 | 11390 | #include "hash.h" |
11391 | ||
e3b78da8 | 11392 | static void community_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 11393 | struct vty *vty) |
718e3744 | 11394 | { |
d62a17ae | 11395 | struct community *com; |
718e3744 | 11396 | |
e3b78da8 | 11397 | com = (struct community *)bucket->data; |
3f65c5b1 | 11398 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 11399 | community_str(com, false)); |
718e3744 | 11400 | } |
11401 | ||
11402 | /* Show BGP's community internal data. */ | |
f412b39a | 11403 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 11404 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 11405 | "show [ip] bgp community-info", |
718e3744 | 11406 | SHOW_STR |
11407 | IP_STR | |
11408 | BGP_STR | |
11409 | "List all bgp community information\n") | |
11410 | { | |
d62a17ae | 11411 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 11412 | |
d62a17ae | 11413 | hash_iterate(community_hash(), |
e3b78da8 | 11414 | (void (*)(struct hash_bucket *, |
d62a17ae | 11415 | void *))community_show_all_iterator, |
11416 | vty); | |
718e3744 | 11417 | |
d62a17ae | 11418 | return CMD_SUCCESS; |
718e3744 | 11419 | } |
11420 | ||
e3b78da8 | 11421 | static void lcommunity_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 11422 | struct vty *vty) |
57d187bc | 11423 | { |
d62a17ae | 11424 | struct lcommunity *lcom; |
57d187bc | 11425 | |
e3b78da8 | 11426 | lcom = (struct lcommunity *)bucket->data; |
3f65c5b1 | 11427 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
8d9b8ed9 | 11428 | lcommunity_str(lcom, false)); |
57d187bc JS |
11429 | } |
11430 | ||
11431 | /* Show BGP's community internal data. */ | |
11432 | DEFUN (show_ip_bgp_lcommunity_info, | |
11433 | show_ip_bgp_lcommunity_info_cmd, | |
11434 | "show ip bgp large-community-info", | |
11435 | SHOW_STR | |
11436 | IP_STR | |
11437 | BGP_STR | |
11438 | "List all bgp large-community information\n") | |
11439 | { | |
d62a17ae | 11440 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 11441 | |
d62a17ae | 11442 | hash_iterate(lcommunity_hash(), |
e3b78da8 | 11443 | (void (*)(struct hash_bucket *, |
d62a17ae | 11444 | void *))lcommunity_show_all_iterator, |
11445 | vty); | |
57d187bc | 11446 | |
d62a17ae | 11447 | return CMD_SUCCESS; |
57d187bc JS |
11448 | } |
11449 | ||
11450 | ||
f412b39a | 11451 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 11452 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 11453 | "show [ip] bgp attribute-info", |
718e3744 | 11454 | SHOW_STR |
11455 | IP_STR | |
11456 | BGP_STR | |
11457 | "List all bgp attribute information\n") | |
11458 | { | |
d62a17ae | 11459 | attr_show_all(vty); |
11460 | return CMD_SUCCESS; | |
718e3744 | 11461 | } |
6b0655a2 | 11462 | |
03915806 CS |
11463 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
11464 | afi_t afi, safi_t safi, | |
11465 | bool use_json, json_object *json) | |
53089bec | 11466 | { |
11467 | struct bgp *bgp; | |
11468 | struct listnode *node; | |
11469 | char *vname; | |
11470 | char buf1[INET6_ADDRSTRLEN]; | |
11471 | char *ecom_str; | |
11472 | vpn_policy_direction_t dir; | |
11473 | ||
03915806 | 11474 | if (json) { |
b46dfd20 DS |
11475 | json_object *json_import_vrfs = NULL; |
11476 | json_object *json_export_vrfs = NULL; | |
11477 | ||
b46dfd20 DS |
11478 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
11479 | ||
53089bec | 11480 | if (!bgp) { |
b46dfd20 DS |
11481 | vty_out(vty, "%s\n", |
11482 | json_object_to_json_string_ext( | |
11483 | json, | |
11484 | JSON_C_TO_STRING_PRETTY)); | |
11485 | json_object_free(json); | |
11486 | ||
53089bec | 11487 | return CMD_WARNING; |
11488 | } | |
b46dfd20 | 11489 | |
94d4c685 DS |
11490 | /* Provide context for the block */ |
11491 | json_object_string_add(json, "vrf", name ? name : "default"); | |
11492 | json_object_string_add(json, "afiSafi", | |
5cb5f4d0 | 11493 | get_afi_safi_str(afi, safi, true)); |
94d4c685 | 11494 | |
b46dfd20 DS |
11495 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
11496 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
11497 | json_object_string_add(json, "importFromVrfs", "none"); | |
11498 | json_object_string_add(json, "importRts", "none"); | |
11499 | } else { | |
6ce24e52 DS |
11500 | json_import_vrfs = json_object_new_array(); |
11501 | ||
b46dfd20 DS |
11502 | for (ALL_LIST_ELEMENTS_RO( |
11503 | bgp->vpn_policy[afi].import_vrf, | |
11504 | node, vname)) | |
11505 | json_object_array_add(json_import_vrfs, | |
11506 | json_object_new_string(vname)); | |
11507 | ||
b20875ea CS |
11508 | json_object_object_add(json, "importFromVrfs", |
11509 | json_import_vrfs); | |
b46dfd20 | 11510 | dir = BGP_VPN_POLICY_DIR_FROMVPN; |
b20875ea CS |
11511 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
11512 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
11513 | bgp->vpn_policy[afi].rtlist[dir], |
11514 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
11515 | json_object_string_add(json, "importRts", |
11516 | ecom_str); | |
11517 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
11518 | } else | |
11519 | json_object_string_add(json, "importRts", | |
11520 | "none"); | |
b46dfd20 DS |
11521 | } |
11522 | ||
11523 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
11524 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
11525 | json_object_string_add(json, "exportToVrfs", "none"); | |
11526 | json_object_string_add(json, "routeDistinguisher", | |
11527 | "none"); | |
11528 | json_object_string_add(json, "exportRts", "none"); | |
11529 | } else { | |
6ce24e52 DS |
11530 | json_export_vrfs = json_object_new_array(); |
11531 | ||
b46dfd20 DS |
11532 | for (ALL_LIST_ELEMENTS_RO( |
11533 | bgp->vpn_policy[afi].export_vrf, | |
11534 | node, vname)) | |
11535 | json_object_array_add(json_export_vrfs, | |
11536 | json_object_new_string(vname)); | |
11537 | json_object_object_add(json, "exportToVrfs", | |
11538 | json_export_vrfs); | |
11539 | json_object_string_add(json, "routeDistinguisher", | |
11540 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
11541 | buf1, RD_ADDRSTRLEN)); | |
11542 | ||
11543 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
11544 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
11545 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
11546 | bgp->vpn_policy[afi].rtlist[dir], |
11547 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
11548 | json_object_string_add(json, "exportRts", |
11549 | ecom_str); | |
11550 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
11551 | } else | |
11552 | json_object_string_add(json, "exportRts", | |
11553 | "none"); | |
b46dfd20 DS |
11554 | } |
11555 | ||
03915806 CS |
11556 | if (use_json) { |
11557 | vty_out(vty, "%s\n", | |
11558 | json_object_to_json_string_ext(json, | |
b46dfd20 | 11559 | JSON_C_TO_STRING_PRETTY)); |
03915806 CS |
11560 | json_object_free(json); |
11561 | } | |
53089bec | 11562 | } else { |
b46dfd20 DS |
11563 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
11564 | ||
53089bec | 11565 | if (!bgp) { |
b46dfd20 | 11566 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 11567 | return CMD_WARNING; |
11568 | } | |
53089bec | 11569 | |
b46dfd20 DS |
11570 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
11571 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
11572 | vty_out(vty, | |
11573 | "This VRF is not importing %s routes from any other VRF\n", | |
5cb5f4d0 | 11574 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
11575 | else { |
11576 | vty_out(vty, | |
11577 | "This VRF is importing %s routes from the following VRFs:\n", | |
5cb5f4d0 | 11578 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
11579 | |
11580 | for (ALL_LIST_ELEMENTS_RO( | |
11581 | bgp->vpn_policy[afi].import_vrf, | |
11582 | node, vname)) | |
11583 | vty_out(vty, " %s\n", vname); | |
11584 | ||
11585 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b20875ea CS |
11586 | ecom_str = NULL; |
11587 | if (bgp->vpn_policy[afi].rtlist[dir]) { | |
11588 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
11589 | bgp->vpn_policy[afi].rtlist[dir], |
11590 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea | 11591 | vty_out(vty, "Import RT(s): %s\n", ecom_str); |
b46dfd20 | 11592 | |
b20875ea CS |
11593 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
11594 | } else | |
11595 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 11596 | } |
53089bec | 11597 | |
b46dfd20 DS |
11598 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
11599 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
11600 | vty_out(vty, | |
11601 | "This VRF is not exporting %s routes to any other VRF\n", | |
5cb5f4d0 | 11602 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
11603 | else { |
11604 | vty_out(vty, | |
04c9077f | 11605 | "This VRF is exporting %s routes to the following VRFs:\n", |
5cb5f4d0 | 11606 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
11607 | |
11608 | for (ALL_LIST_ELEMENTS_RO( | |
11609 | bgp->vpn_policy[afi].export_vrf, | |
11610 | node, vname)) | |
11611 | vty_out(vty, " %s\n", vname); | |
11612 | ||
11613 | vty_out(vty, "RD: %s\n", | |
11614 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
11615 | buf1, RD_ADDRSTRLEN)); | |
11616 | ||
11617 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
11618 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
11619 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
11620 | bgp->vpn_policy[afi].rtlist[dir], |
11621 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
11622 | vty_out(vty, "Export RT: %s\n", ecom_str); |
11623 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
11624 | } else | |
11625 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 11626 | } |
53089bec | 11627 | } |
11628 | ||
11629 | return CMD_SUCCESS; | |
11630 | } | |
11631 | ||
03915806 CS |
11632 | static int bgp_show_all_instance_route_leak_vty(struct vty *vty, afi_t afi, |
11633 | safi_t safi, bool use_json) | |
11634 | { | |
11635 | struct listnode *node, *nnode; | |
11636 | struct bgp *bgp; | |
11637 | char *vrf_name = NULL; | |
11638 | json_object *json = NULL; | |
11639 | json_object *json_vrf = NULL; | |
11640 | json_object *json_vrfs = NULL; | |
11641 | ||
11642 | if (use_json) { | |
11643 | json = json_object_new_object(); | |
11644 | json_vrfs = json_object_new_object(); | |
11645 | } | |
11646 | ||
11647 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
11648 | ||
11649 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) | |
11650 | vrf_name = bgp->name; | |
11651 | ||
11652 | if (use_json) { | |
11653 | json_vrf = json_object_new_object(); | |
11654 | } else { | |
11655 | vty_out(vty, "\nInstance %s:\n", | |
11656 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
11657 | ? VRF_DEFAULT_NAME : bgp->name); | |
11658 | } | |
11659 | bgp_show_route_leak_vty(vty, vrf_name, afi, safi, 0, json_vrf); | |
11660 | if (use_json) { | |
11661 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
11662 | json_object_object_add(json_vrfs, | |
11663 | VRF_DEFAULT_NAME, json_vrf); | |
11664 | else | |
11665 | json_object_object_add(json_vrfs, vrf_name, | |
11666 | json_vrf); | |
11667 | } | |
11668 | } | |
11669 | ||
11670 | if (use_json) { | |
11671 | json_object_object_add(json, "vrfs", json_vrfs); | |
11672 | vty_out(vty, "%s\n", json_object_to_json_string_ext(json, | |
11673 | JSON_C_TO_STRING_PRETTY)); | |
11674 | json_object_free(json); | |
11675 | } | |
11676 | ||
11677 | return CMD_SUCCESS; | |
11678 | } | |
11679 | ||
53089bec | 11680 | /* "show [ip] bgp route-leak" command. */ |
11681 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
11682 | show_ip_bgp_route_leak_cmd, |
11683 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
11684 | SHOW_STR |
11685 | IP_STR | |
11686 | BGP_STR | |
11687 | BGP_INSTANCE_HELP_STR | |
11688 | BGP_AFI_HELP_STR | |
11689 | BGP_SAFI_HELP_STR | |
11690 | "Route leaking information\n" | |
11691 | JSON_STR) | |
53089bec | 11692 | { |
11693 | char *vrf = NULL; | |
11694 | afi_t afi = AFI_MAX; | |
11695 | safi_t safi = SAFI_MAX; | |
11696 | ||
9f049418 | 11697 | bool uj = use_json(argc, argv); |
53089bec | 11698 | int idx = 0; |
03915806 | 11699 | json_object *json = NULL; |
53089bec | 11700 | |
11701 | /* show [ip] bgp */ | |
11702 | if (argv_find(argv, argc, "ip", &idx)) { | |
11703 | afi = AFI_IP; | |
11704 | safi = SAFI_UNICAST; | |
11705 | } | |
11706 | /* [vrf VIEWVRFNAME] */ | |
11707 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
11708 | vty_out(vty, |
11709 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 11710 | return CMD_WARNING; |
11711 | } | |
11712 | ||
9a8bdf1c PG |
11713 | if (argv_find(argv, argc, "vrf", &idx)) { |
11714 | vrf = argv[idx + 1]->arg; | |
11715 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11716 | vrf = NULL; | |
11717 | } | |
53089bec | 11718 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
11719 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11720 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11721 | } | |
11722 | ||
11723 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
11724 | vty_out(vty, |
11725 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 11726 | return CMD_WARNING; |
11727 | } | |
11728 | ||
03915806 CS |
11729 | if (vrf && strmatch(vrf, "all")) |
11730 | return bgp_show_all_instance_route_leak_vty(vty, afi, safi, uj); | |
11731 | ||
11732 | if (uj) | |
11733 | json = json_object_new_object(); | |
11734 | ||
11735 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj, json); | |
53089bec | 11736 | } |
11737 | ||
d62a17ae | 11738 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
11739 | safi_t safi) | |
f186de26 | 11740 | { |
d62a17ae | 11741 | struct listnode *node, *nnode; |
11742 | struct bgp *bgp; | |
f186de26 | 11743 | |
d62a17ae | 11744 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
11745 | vty_out(vty, "\nInstance %s:\n", | |
11746 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11747 | ? VRF_DEFAULT_NAME |
d62a17ae | 11748 | : bgp->name); |
11749 | update_group_show(bgp, afi, safi, vty, 0); | |
11750 | } | |
f186de26 | 11751 | } |
11752 | ||
d62a17ae | 11753 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
11754 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 11755 | { |
d62a17ae | 11756 | struct bgp *bgp; |
4fb25c53 | 11757 | |
d62a17ae | 11758 | if (name) { |
11759 | if (strmatch(name, "all")) { | |
11760 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
11761 | return CMD_SUCCESS; | |
11762 | } else { | |
11763 | bgp = bgp_lookup_by_name(name); | |
11764 | } | |
11765 | } else { | |
11766 | bgp = bgp_get_default(); | |
11767 | } | |
4fb25c53 | 11768 | |
d62a17ae | 11769 | if (bgp) |
11770 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
11771 | return CMD_SUCCESS; | |
4fb25c53 DW |
11772 | } |
11773 | ||
8fe8a7f6 DS |
11774 | DEFUN (show_ip_bgp_updgrps, |
11775 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 11776 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 11777 | SHOW_STR |
11778 | IP_STR | |
11779 | BGP_STR | |
11780 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 11781 | BGP_AFI_HELP_STR |
9bedbb1e | 11782 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
11783 | "Detailed info about dynamic update groups\n" |
11784 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 11785 | { |
d62a17ae | 11786 | char *vrf = NULL; |
11787 | afi_t afi = AFI_IP6; | |
11788 | safi_t safi = SAFI_UNICAST; | |
11789 | uint64_t subgrp_id = 0; | |
11790 | ||
11791 | int idx = 0; | |
11792 | ||
11793 | /* show [ip] bgp */ | |
11794 | if (argv_find(argv, argc, "ip", &idx)) | |
11795 | afi = AFI_IP; | |
9a8bdf1c PG |
11796 | /* [<vrf> VIEWVRFNAME] */ |
11797 | if (argv_find(argv, argc, "vrf", &idx)) { | |
11798 | vrf = argv[idx + 1]->arg; | |
11799 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11800 | vrf = NULL; | |
11801 | } else if (argv_find(argv, argc, "view", &idx)) | |
11802 | /* [<view> VIEWVRFNAME] */ | |
11803 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 11804 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
11805 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11806 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11807 | } | |
5bf15956 | 11808 | |
d62a17ae | 11809 | /* get subgroup id, if provided */ |
11810 | idx = argc - 1; | |
11811 | if (argv[idx]->type == VARIABLE_TKN) | |
11812 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 11813 | |
d62a17ae | 11814 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
11815 | } |
11816 | ||
f186de26 | 11817 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
11818 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 11819 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 11820 | SHOW_STR |
716b2d8a | 11821 | IP_STR |
f186de26 | 11822 | BGP_STR |
11823 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 11824 | "Detailed info about dynamic update groups\n") |
f186de26 | 11825 | { |
d62a17ae | 11826 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
11827 | return CMD_SUCCESS; | |
f186de26 | 11828 | } |
11829 | ||
43d3f4fc DS |
11830 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
11831 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
11832 | "show [ip] bgp l2vpn evpn update-groups", | |
11833 | SHOW_STR | |
11834 | IP_STR | |
11835 | BGP_STR | |
11836 | "l2vpn address family\n" | |
11837 | "evpn sub-address family\n" | |
11838 | "Detailed info about dynamic update groups\n") | |
11839 | { | |
11840 | char *vrf = NULL; | |
11841 | uint64_t subgrp_id = 0; | |
11842 | ||
11843 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id); | |
11844 | return CMD_SUCCESS; | |
11845 | } | |
11846 | ||
5bf15956 DW |
11847 | DEFUN (show_bgp_updgrps_stats, |
11848 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 11849 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 11850 | SHOW_STR |
716b2d8a | 11851 | IP_STR |
3f9c7369 | 11852 | BGP_STR |
0c7b1b01 | 11853 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
11854 | "Statistics\n") |
11855 | { | |
d62a17ae | 11856 | struct bgp *bgp; |
3f9c7369 | 11857 | |
d62a17ae | 11858 | bgp = bgp_get_default(); |
11859 | if (bgp) | |
11860 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 11861 | |
d62a17ae | 11862 | return CMD_SUCCESS; |
3f9c7369 DS |
11863 | } |
11864 | ||
8386ac43 | 11865 | DEFUN (show_bgp_instance_updgrps_stats, |
11866 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 11867 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 11868 | SHOW_STR |
716b2d8a | 11869 | IP_STR |
8386ac43 | 11870 | BGP_STR |
11871 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 11872 | "Detailed info about dynamic update groups\n" |
8386ac43 | 11873 | "Statistics\n") |
11874 | { | |
d62a17ae | 11875 | int idx_word = 3; |
11876 | struct bgp *bgp; | |
8386ac43 | 11877 | |
d62a17ae | 11878 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
11879 | if (bgp) | |
11880 | update_group_show_stats(bgp, vty); | |
8386ac43 | 11881 | |
d62a17ae | 11882 | return CMD_SUCCESS; |
8386ac43 | 11883 | } |
11884 | ||
d62a17ae | 11885 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
11886 | afi_t afi, safi_t safi, | |
11887 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 11888 | { |
d62a17ae | 11889 | struct bgp *bgp; |
8386ac43 | 11890 | |
d62a17ae | 11891 | if (name) |
11892 | bgp = bgp_lookup_by_name(name); | |
11893 | else | |
11894 | bgp = bgp_get_default(); | |
8386ac43 | 11895 | |
d62a17ae | 11896 | if (bgp) { |
11897 | if (!strcmp(what, "advertise-queue")) | |
11898 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
11899 | subgrp_id); | |
11900 | else if (!strcmp(what, "advertised-routes")) | |
11901 | update_group_show_advertised(bgp, afi, safi, vty, | |
11902 | subgrp_id); | |
11903 | else if (!strcmp(what, "packet-queue")) | |
11904 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
11905 | subgrp_id); | |
11906 | } | |
3f9c7369 DS |
11907 | } |
11908 | ||
dc64bdec QY |
11909 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
11910 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
11911 | "show [ip]$ip bgp [<view|vrf> VIEWVRFNAME$vrf] [<ipv4|ipv6>$afi <unicast|multicast|vpn>$safi] update-groups [SUBGROUP-ID]$sgid <advertise-queue|advertised-routes|packet-queue>$rtq", | |
11912 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
11913 | BGP_SAFI_HELP_STR | |
11914 | "Detailed info about dynamic update groups\n" | |
11915 | "Specific subgroup to display info for\n" | |
11916 | "Advertisement queue\n" | |
11917 | "Announced routes\n" | |
11918 | "Packet queue\n") | |
3f9c7369 | 11919 | { |
dc64bdec QY |
11920 | uint64_t subgrp_id = 0; |
11921 | afi_t afiz; | |
11922 | safi_t safiz; | |
11923 | if (sgid) | |
11924 | subgrp_id = strtoull(sgid, NULL, 10); | |
11925 | ||
11926 | if (!ip && !afi) | |
11927 | afiz = AFI_IP6; | |
11928 | if (!ip && afi) | |
11929 | afiz = bgp_vty_afi_from_str(afi); | |
11930 | if (ip && !afi) | |
11931 | afiz = AFI_IP; | |
11932 | if (ip && afi) { | |
11933 | afiz = bgp_vty_afi_from_str(afi); | |
11934 | if (afiz != AFI_IP) | |
11935 | vty_out(vty, | |
11936 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
11937 | return CMD_WARNING; | |
11938 | } | |
d62a17ae | 11939 | |
dc64bdec | 11940 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 11941 | |
dc64bdec | 11942 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 11943 | return CMD_SUCCESS; |
11944 | } | |
11945 | ||
d62a17ae | 11946 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group) |
11947 | { | |
11948 | struct listnode *node, *nnode; | |
11949 | struct prefix *range; | |
11950 | struct peer *conf; | |
11951 | struct peer *peer; | |
11952 | char buf[PREFIX2STR_BUFFER]; | |
11953 | afi_t afi; | |
11954 | safi_t safi; | |
11955 | const char *peer_status; | |
11956 | const char *af_str; | |
11957 | int lr_count; | |
11958 | int dynamic; | |
11959 | int af_cfgd; | |
11960 | ||
11961 | conf = group->conf; | |
11962 | ||
11963 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
3b61f610 QY |
11964 | vty_out(vty, "\nBGP peer-group %s, remote AS %" PRIu32 "\n", |
11965 | group->name, conf->as); | |
d62a17ae | 11966 | } else if (conf->as_type == AS_INTERNAL) { |
3b61f610 QY |
11967 | vty_out(vty, "\nBGP peer-group %s, remote AS %" PRIu32 "\n", |
11968 | group->name, group->bgp->as); | |
d62a17ae | 11969 | } else { |
11970 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
11971 | } | |
f14e6fdb | 11972 | |
d62a17ae | 11973 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
11974 | vty_out(vty, " Peer-group type is internal\n"); | |
11975 | else | |
11976 | vty_out(vty, " Peer-group type is external\n"); | |
11977 | ||
11978 | /* Display AFs configured. */ | |
11979 | vty_out(vty, " Configured address-families:"); | |
05c7a1cc QY |
11980 | FOREACH_AFI_SAFI (afi, safi) { |
11981 | if (conf->afc[afi][safi]) { | |
11982 | af_cfgd = 1; | |
5cb5f4d0 | 11983 | vty_out(vty, " %s;", get_afi_safi_str(afi, safi, false)); |
d62a17ae | 11984 | } |
05c7a1cc | 11985 | } |
d62a17ae | 11986 | if (!af_cfgd) |
11987 | vty_out(vty, " none\n"); | |
11988 | else | |
11989 | vty_out(vty, "\n"); | |
11990 | ||
11991 | /* Display listen ranges (for dynamic neighbors), if any */ | |
11992 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
11993 | if (afi == AFI_IP) | |
11994 | af_str = "IPv4"; | |
11995 | else if (afi == AFI_IP6) | |
11996 | af_str = "IPv6"; | |
11997 | else | |
11998 | af_str = "???"; | |
11999 | lr_count = listcount(group->listen_range[afi]); | |
12000 | if (lr_count) { | |
12001 | vty_out(vty, " %d %s listen range(s)\n", lr_count, | |
12002 | af_str); | |
12003 | ||
12004 | ||
12005 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
12006 | nnode, range)) { | |
12007 | prefix2str(range, buf, sizeof(buf)); | |
12008 | vty_out(vty, " %s\n", buf); | |
12009 | } | |
12010 | } | |
12011 | } | |
f14e6fdb | 12012 | |
d62a17ae | 12013 | /* Display group members and their status */ |
12014 | if (listcount(group->peer)) { | |
12015 | vty_out(vty, " Peer-group members:\n"); | |
12016 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
12017 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
12018 | peer_status = "Idle (Admin)"; | |
12019 | else if (CHECK_FLAG(peer->sflags, | |
12020 | PEER_STATUS_PREFIX_OVERFLOW)) | |
12021 | peer_status = "Idle (PfxCt)"; | |
12022 | else | |
12023 | peer_status = lookup_msg(bgp_status_msg, | |
12024 | peer->status, NULL); | |
12025 | ||
12026 | dynamic = peer_dynamic_neighbor(peer); | |
12027 | vty_out(vty, " %s %s %s \n", peer->host, | |
12028 | dynamic ? "(dynamic)" : "", peer_status); | |
12029 | } | |
12030 | } | |
f14e6fdb | 12031 | |
d62a17ae | 12032 | return CMD_SUCCESS; |
12033 | } | |
12034 | ||
ff9959b0 QY |
12035 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
12036 | const char *group_name) | |
d62a17ae | 12037 | { |
ff9959b0 | 12038 | struct bgp *bgp; |
d62a17ae | 12039 | struct listnode *node, *nnode; |
12040 | struct peer_group *group; | |
ff9959b0 QY |
12041 | bool found = false; |
12042 | ||
12043 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
12044 | ||
12045 | if (!bgp) { | |
9f049418 | 12046 | vty_out(vty, "%% BGP instance not found\n"); |
ff9959b0 QY |
12047 | return CMD_WARNING; |
12048 | } | |
d62a17ae | 12049 | |
12050 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
12051 | if (group_name) { |
12052 | if (strmatch(group->name, group_name)) { | |
d62a17ae | 12053 | bgp_show_one_peer_group(vty, group); |
ff9959b0 QY |
12054 | found = true; |
12055 | break; | |
d62a17ae | 12056 | } |
ff9959b0 QY |
12057 | } else { |
12058 | bgp_show_one_peer_group(vty, group); | |
d62a17ae | 12059 | } |
f14e6fdb | 12060 | } |
f14e6fdb | 12061 | |
ff9959b0 | 12062 | if (group_name && !found) |
d62a17ae | 12063 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 12064 | |
d62a17ae | 12065 | return CMD_SUCCESS; |
f14e6fdb DS |
12066 | } |
12067 | ||
f14e6fdb DS |
12068 | DEFUN (show_ip_bgp_peer_groups, |
12069 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 12070 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
12071 | SHOW_STR |
12072 | IP_STR | |
12073 | BGP_STR | |
8386ac43 | 12074 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
12075 | "Detailed information on BGP peer groups\n" |
12076 | "Peer group name\n") | |
f14e6fdb | 12077 | { |
d62a17ae | 12078 | char *vrf, *pg; |
d62a17ae | 12079 | int idx = 0; |
f14e6fdb | 12080 | |
a4d82a8a PZ |
12081 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
12082 | : NULL; | |
d62a17ae | 12083 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 12084 | |
ff9959b0 | 12085 | return bgp_show_peer_group_vty(vty, vrf, pg); |
f14e6fdb | 12086 | } |
3f9c7369 | 12087 | |
d6e3c605 | 12088 | |
718e3744 | 12089 | /* Redistribute VTY commands. */ |
12090 | ||
718e3744 | 12091 | DEFUN (bgp_redistribute_ipv4, |
12092 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 12093 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 12094 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12095 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 12096 | { |
d62a17ae | 12097 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12098 | int idx_protocol = 1; | |
12099 | int type; | |
718e3744 | 12100 | |
d62a17ae | 12101 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
12102 | if (type < 0) { | |
12103 | vty_out(vty, "%% Invalid route type\n"); | |
12104 | return CMD_WARNING_CONFIG_FAILED; | |
12105 | } | |
7f323236 | 12106 | |
d62a17ae | 12107 | bgp_redist_add(bgp, AFI_IP, type, 0); |
e923dd62 | 12108 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, false); |
718e3744 | 12109 | } |
12110 | ||
d62a17ae | 12111 | ALIAS_HIDDEN( |
12112 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
12113 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
12114 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 12115 | |
718e3744 | 12116 | DEFUN (bgp_redistribute_ipv4_rmap, |
12117 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 12118 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 12119 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12120 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 12121 | "Route map reference\n" |
12122 | "Pointer to route-map entries\n") | |
12123 | { | |
d62a17ae | 12124 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12125 | int idx_protocol = 1; | |
12126 | int idx_word = 3; | |
12127 | int type; | |
12128 | struct bgp_redist *red; | |
e923dd62 | 12129 | bool changed; |
1de27621 DA |
12130 | struct route_map *route_map = route_map_lookup_warn_noexist( |
12131 | vty, argv[idx_word]->arg); | |
718e3744 | 12132 | |
d62a17ae | 12133 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
12134 | if (type < 0) { | |
12135 | vty_out(vty, "%% Invalid route type\n"); | |
12136 | return CMD_WARNING_CONFIG_FAILED; | |
12137 | } | |
718e3744 | 12138 | |
d62a17ae | 12139 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
1de27621 DA |
12140 | changed = |
12141 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12142 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
718e3744 | 12143 | } |
12144 | ||
d62a17ae | 12145 | ALIAS_HIDDEN( |
12146 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
12147 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
12148 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
12149 | "Route map reference\n" | |
12150 | "Pointer to route-map entries\n") | |
596c17ba | 12151 | |
718e3744 | 12152 | DEFUN (bgp_redistribute_ipv4_metric, |
12153 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 12154 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 12155 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12156 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 12157 | "Metric for redistributed routes\n" |
12158 | "Default metric\n") | |
12159 | { | |
d62a17ae | 12160 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12161 | int idx_protocol = 1; | |
12162 | int idx_number = 3; | |
12163 | int type; | |
d7c0a89a | 12164 | uint32_t metric; |
d62a17ae | 12165 | struct bgp_redist *red; |
e923dd62 | 12166 | bool changed; |
d62a17ae | 12167 | |
12168 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
12169 | if (type < 0) { | |
12170 | vty_out(vty, "%% Invalid route type\n"); | |
12171 | return CMD_WARNING_CONFIG_FAILED; | |
12172 | } | |
12173 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
12174 | ||
12175 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 12176 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
12177 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 12178 | } |
12179 | ||
12180 | ALIAS_HIDDEN( | |
12181 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
12182 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
12183 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
12184 | "Metric for redistributed routes\n" | |
12185 | "Default metric\n") | |
596c17ba | 12186 | |
718e3744 | 12187 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
12188 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 12189 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 12190 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12191 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 12192 | "Route map reference\n" |
12193 | "Pointer to route-map entries\n" | |
12194 | "Metric for redistributed routes\n" | |
12195 | "Default metric\n") | |
12196 | { | |
d62a17ae | 12197 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12198 | int idx_protocol = 1; | |
12199 | int idx_word = 3; | |
12200 | int idx_number = 5; | |
12201 | int type; | |
d7c0a89a | 12202 | uint32_t metric; |
d62a17ae | 12203 | struct bgp_redist *red; |
e923dd62 | 12204 | bool changed; |
1de27621 DA |
12205 | struct route_map *route_map = |
12206 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12207 | |
12208 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
12209 | if (type < 0) { | |
12210 | vty_out(vty, "%% Invalid route type\n"); | |
12211 | return CMD_WARNING_CONFIG_FAILED; | |
12212 | } | |
12213 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
12214 | ||
12215 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
1de27621 DA |
12216 | changed = |
12217 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12218 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
12219 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 12220 | } |
12221 | ||
12222 | ALIAS_HIDDEN( | |
12223 | bgp_redistribute_ipv4_rmap_metric, | |
12224 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
12225 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
12226 | " route-map WORD metric (0-4294967295)", | |
12227 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
12228 | "Route map reference\n" | |
12229 | "Pointer to route-map entries\n" | |
12230 | "Metric for redistributed routes\n" | |
12231 | "Default metric\n") | |
596c17ba | 12232 | |
718e3744 | 12233 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
12234 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 12235 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 12236 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12237 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 12238 | "Metric for redistributed routes\n" |
12239 | "Default metric\n" | |
12240 | "Route map reference\n" | |
12241 | "Pointer to route-map entries\n") | |
12242 | { | |
d62a17ae | 12243 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12244 | int idx_protocol = 1; | |
12245 | int idx_number = 3; | |
12246 | int idx_word = 5; | |
12247 | int type; | |
d7c0a89a | 12248 | uint32_t metric; |
d62a17ae | 12249 | struct bgp_redist *red; |
e923dd62 | 12250 | bool changed; |
1de27621 DA |
12251 | struct route_map *route_map = |
12252 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12253 | |
12254 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
12255 | if (type < 0) { | |
12256 | vty_out(vty, "%% Invalid route type\n"); | |
12257 | return CMD_WARNING_CONFIG_FAILED; | |
12258 | } | |
12259 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
12260 | ||
12261 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 12262 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
1de27621 DA |
12263 | changed |= |
12264 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12265 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
d62a17ae | 12266 | } |
12267 | ||
12268 | ALIAS_HIDDEN( | |
12269 | bgp_redistribute_ipv4_metric_rmap, | |
12270 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
12271 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
12272 | " metric (0-4294967295) route-map WORD", | |
12273 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
12274 | "Metric for redistributed routes\n" | |
12275 | "Default metric\n" | |
12276 | "Route map reference\n" | |
12277 | "Pointer to route-map entries\n") | |
596c17ba | 12278 | |
7c8ff89e DS |
12279 | DEFUN (bgp_redistribute_ipv4_ospf, |
12280 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 12281 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
12282 | "Redistribute information from another routing protocol\n" |
12283 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12284 | "Non-main Kernel Routing Table\n" |
12285 | "Instance ID/Table ID\n") | |
7c8ff89e | 12286 | { |
d62a17ae | 12287 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12288 | int idx_ospf_table = 1; | |
12289 | int idx_number = 2; | |
d7c0a89a QY |
12290 | unsigned short instance; |
12291 | unsigned short protocol; | |
7c8ff89e | 12292 | |
d62a17ae | 12293 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 12294 | |
d62a17ae | 12295 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
12296 | protocol = ZEBRA_ROUTE_OSPF; | |
12297 | else | |
12298 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 12299 | |
d62a17ae | 12300 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
e923dd62 | 12301 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, false); |
7c8ff89e DS |
12302 | } |
12303 | ||
d62a17ae | 12304 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
12305 | "redistribute <ospf|table> (1-65535)", | |
12306 | "Redistribute information from another routing protocol\n" | |
12307 | "Open Shortest Path First (OSPFv2)\n" | |
12308 | "Non-main Kernel Routing Table\n" | |
12309 | "Instance ID/Table ID\n") | |
596c17ba | 12310 | |
7c8ff89e DS |
12311 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
12312 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 12313 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
12314 | "Redistribute information from another routing protocol\n" |
12315 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12316 | "Non-main Kernel Routing Table\n" |
12317 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12318 | "Route map reference\n" |
12319 | "Pointer to route-map entries\n") | |
12320 | { | |
d62a17ae | 12321 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12322 | int idx_ospf_table = 1; | |
12323 | int idx_number = 2; | |
12324 | int idx_word = 4; | |
12325 | struct bgp_redist *red; | |
d7c0a89a | 12326 | unsigned short instance; |
d62a17ae | 12327 | int protocol; |
e923dd62 | 12328 | bool changed; |
1de27621 DA |
12329 | struct route_map *route_map = |
12330 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12331 | |
12332 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12333 | protocol = ZEBRA_ROUTE_OSPF; | |
12334 | else | |
12335 | protocol = ZEBRA_ROUTE_TABLE; | |
12336 | ||
12337 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12338 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
12339 | changed = |
12340 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12341 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 12342 | } |
12343 | ||
12344 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
12345 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
12346 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
12347 | "Redistribute information from another routing protocol\n" | |
12348 | "Open Shortest Path First (OSPFv2)\n" | |
12349 | "Non-main Kernel Routing Table\n" | |
12350 | "Instance ID/Table ID\n" | |
12351 | "Route map reference\n" | |
12352 | "Pointer to route-map entries\n") | |
596c17ba | 12353 | |
7c8ff89e DS |
12354 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
12355 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 12356 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
12357 | "Redistribute information from another routing protocol\n" |
12358 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12359 | "Non-main Kernel Routing Table\n" |
12360 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12361 | "Metric for redistributed routes\n" |
12362 | "Default metric\n") | |
12363 | { | |
d62a17ae | 12364 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12365 | int idx_ospf_table = 1; | |
12366 | int idx_number = 2; | |
12367 | int idx_number_2 = 4; | |
d7c0a89a | 12368 | uint32_t metric; |
d62a17ae | 12369 | struct bgp_redist *red; |
d7c0a89a | 12370 | unsigned short instance; |
d62a17ae | 12371 | int protocol; |
e923dd62 | 12372 | bool changed; |
d62a17ae | 12373 | |
12374 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12375 | protocol = ZEBRA_ROUTE_OSPF; | |
12376 | else | |
12377 | protocol = ZEBRA_ROUTE_TABLE; | |
12378 | ||
12379 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12380 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
12381 | ||
12382 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 12383 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
12384 | metric); | |
12385 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 12386 | } |
12387 | ||
12388 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
12389 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
12390 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
12391 | "Redistribute information from another routing protocol\n" | |
12392 | "Open Shortest Path First (OSPFv2)\n" | |
12393 | "Non-main Kernel Routing Table\n" | |
12394 | "Instance ID/Table ID\n" | |
12395 | "Metric for redistributed routes\n" | |
12396 | "Default metric\n") | |
596c17ba | 12397 | |
7c8ff89e DS |
12398 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
12399 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 12400 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
12401 | "Redistribute information from another routing protocol\n" |
12402 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12403 | "Non-main Kernel Routing Table\n" |
12404 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12405 | "Route map reference\n" |
12406 | "Pointer to route-map entries\n" | |
12407 | "Metric for redistributed routes\n" | |
12408 | "Default metric\n") | |
12409 | { | |
d62a17ae | 12410 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12411 | int idx_ospf_table = 1; | |
12412 | int idx_number = 2; | |
12413 | int idx_word = 4; | |
12414 | int idx_number_2 = 6; | |
d7c0a89a | 12415 | uint32_t metric; |
d62a17ae | 12416 | struct bgp_redist *red; |
d7c0a89a | 12417 | unsigned short instance; |
d62a17ae | 12418 | int protocol; |
e923dd62 | 12419 | bool changed; |
1de27621 DA |
12420 | struct route_map *route_map = |
12421 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12422 | |
12423 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12424 | protocol = ZEBRA_ROUTE_OSPF; | |
12425 | else | |
12426 | protocol = ZEBRA_ROUTE_TABLE; | |
12427 | ||
12428 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12429 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
12430 | ||
12431 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
12432 | changed = |
12433 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12434 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
12435 | metric); | |
12436 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 12437 | } |
12438 | ||
12439 | ALIAS_HIDDEN( | |
12440 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
12441 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
12442 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
12443 | "Redistribute information from another routing protocol\n" | |
12444 | "Open Shortest Path First (OSPFv2)\n" | |
12445 | "Non-main Kernel Routing Table\n" | |
12446 | "Instance ID/Table ID\n" | |
12447 | "Route map reference\n" | |
12448 | "Pointer to route-map entries\n" | |
12449 | "Metric for redistributed routes\n" | |
12450 | "Default metric\n") | |
596c17ba | 12451 | |
7c8ff89e DS |
12452 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
12453 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 12454 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
12455 | "Redistribute information from another routing protocol\n" |
12456 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12457 | "Non-main Kernel Routing Table\n" |
12458 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12459 | "Metric for redistributed routes\n" |
12460 | "Default metric\n" | |
12461 | "Route map reference\n" | |
12462 | "Pointer to route-map entries\n") | |
12463 | { | |
d62a17ae | 12464 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12465 | int idx_ospf_table = 1; | |
12466 | int idx_number = 2; | |
12467 | int idx_number_2 = 4; | |
12468 | int idx_word = 6; | |
d7c0a89a | 12469 | uint32_t metric; |
d62a17ae | 12470 | struct bgp_redist *red; |
d7c0a89a | 12471 | unsigned short instance; |
d62a17ae | 12472 | int protocol; |
e923dd62 | 12473 | bool changed; |
1de27621 DA |
12474 | struct route_map *route_map = |
12475 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12476 | |
12477 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12478 | protocol = ZEBRA_ROUTE_OSPF; | |
12479 | else | |
12480 | protocol = ZEBRA_ROUTE_TABLE; | |
12481 | ||
12482 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12483 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
12484 | ||
12485 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 12486 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
12487 | metric); | |
1de27621 DA |
12488 | changed |= |
12489 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12490 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 12491 | } |
12492 | ||
12493 | ALIAS_HIDDEN( | |
12494 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
12495 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
12496 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
12497 | "Redistribute information from another routing protocol\n" | |
12498 | "Open Shortest Path First (OSPFv2)\n" | |
12499 | "Non-main Kernel Routing Table\n" | |
12500 | "Instance ID/Table ID\n" | |
12501 | "Metric for redistributed routes\n" | |
12502 | "Default metric\n" | |
12503 | "Route map reference\n" | |
12504 | "Pointer to route-map entries\n") | |
596c17ba | 12505 | |
7c8ff89e DS |
12506 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
12507 | no_bgp_redistribute_ipv4_ospf_cmd, | |
e27957c0 | 12508 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
7c8ff89e DS |
12509 | NO_STR |
12510 | "Redistribute information from another routing protocol\n" | |
12511 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 12512 | "Non-main Kernel Routing Table\n" |
31500417 DW |
12513 | "Instance ID/Table ID\n" |
12514 | "Metric for redistributed routes\n" | |
12515 | "Default metric\n" | |
12516 | "Route map reference\n" | |
12517 | "Pointer to route-map entries\n") | |
7c8ff89e | 12518 | { |
d62a17ae | 12519 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12520 | int idx_ospf_table = 2; | |
12521 | int idx_number = 3; | |
d7c0a89a | 12522 | unsigned short instance; |
d62a17ae | 12523 | int protocol; |
12524 | ||
12525 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12526 | protocol = ZEBRA_ROUTE_OSPF; | |
12527 | else | |
12528 | protocol = ZEBRA_ROUTE_TABLE; | |
12529 | ||
12530 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12531 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
12532 | } | |
12533 | ||
12534 | ALIAS_HIDDEN( | |
12535 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
e27957c0 | 12536 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 12537 | NO_STR |
12538 | "Redistribute information from another routing protocol\n" | |
12539 | "Open Shortest Path First (OSPFv2)\n" | |
12540 | "Non-main Kernel Routing Table\n" | |
12541 | "Instance ID/Table ID\n" | |
12542 | "Metric for redistributed routes\n" | |
12543 | "Default metric\n" | |
12544 | "Route map reference\n" | |
12545 | "Pointer to route-map entries\n") | |
596c17ba | 12546 | |
718e3744 | 12547 | DEFUN (no_bgp_redistribute_ipv4, |
12548 | no_bgp_redistribute_ipv4_cmd, | |
e27957c0 | 12549 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", |
718e3744 | 12550 | NO_STR |
12551 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 12552 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
12553 | "Metric for redistributed routes\n" |
12554 | "Default metric\n" | |
12555 | "Route map reference\n" | |
12556 | "Pointer to route-map entries\n") | |
718e3744 | 12557 | { |
d62a17ae | 12558 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12559 | int idx_protocol = 2; | |
12560 | int type; | |
12561 | ||
12562 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
12563 | if (type < 0) { | |
12564 | vty_out(vty, "%% Invalid route type\n"); | |
12565 | return CMD_WARNING_CONFIG_FAILED; | |
12566 | } | |
12567 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
12568 | } | |
12569 | ||
12570 | ALIAS_HIDDEN( | |
12571 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
12572 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
e27957c0 | 12573 | " [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 12574 | NO_STR |
12575 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
12576 | "Metric for redistributed routes\n" | |
12577 | "Default metric\n" | |
12578 | "Route map reference\n" | |
12579 | "Pointer to route-map entries\n") | |
596c17ba | 12580 | |
718e3744 | 12581 | DEFUN (bgp_redistribute_ipv6, |
12582 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 12583 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 12584 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12585 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 12586 | { |
d62a17ae | 12587 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12588 | int idx_protocol = 1; | |
12589 | int type; | |
718e3744 | 12590 | |
d62a17ae | 12591 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
12592 | if (type < 0) { | |
12593 | vty_out(vty, "%% Invalid route type\n"); | |
12594 | return CMD_WARNING_CONFIG_FAILED; | |
12595 | } | |
718e3744 | 12596 | |
d62a17ae | 12597 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 12598 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, false); |
718e3744 | 12599 | } |
12600 | ||
12601 | DEFUN (bgp_redistribute_ipv6_rmap, | |
12602 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 12603 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 12604 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12605 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12606 | "Route map reference\n" |
12607 | "Pointer to route-map entries\n") | |
12608 | { | |
d62a17ae | 12609 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12610 | int idx_protocol = 1; | |
12611 | int idx_word = 3; | |
12612 | int type; | |
12613 | struct bgp_redist *red; | |
e923dd62 | 12614 | bool changed; |
1de27621 DA |
12615 | struct route_map *route_map = |
12616 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
718e3744 | 12617 | |
d62a17ae | 12618 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
12619 | if (type < 0) { | |
12620 | vty_out(vty, "%% Invalid route type\n"); | |
12621 | return CMD_WARNING_CONFIG_FAILED; | |
12622 | } | |
718e3744 | 12623 | |
d62a17ae | 12624 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
12625 | changed = |
12626 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12627 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 12628 | } |
12629 | ||
12630 | DEFUN (bgp_redistribute_ipv6_metric, | |
12631 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 12632 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 12633 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12634 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12635 | "Metric for redistributed routes\n" |
12636 | "Default metric\n") | |
12637 | { | |
d62a17ae | 12638 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12639 | int idx_protocol = 1; | |
12640 | int idx_number = 3; | |
12641 | int type; | |
d7c0a89a | 12642 | uint32_t metric; |
d62a17ae | 12643 | struct bgp_redist *red; |
e923dd62 | 12644 | bool changed; |
d62a17ae | 12645 | |
12646 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
12647 | if (type < 0) { | |
12648 | vty_out(vty, "%% Invalid route type\n"); | |
12649 | return CMD_WARNING_CONFIG_FAILED; | |
12650 | } | |
12651 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 12652 | |
d62a17ae | 12653 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 12654 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); |
12655 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 12656 | } |
12657 | ||
12658 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
12659 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 12660 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 12661 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12662 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12663 | "Route map reference\n" |
12664 | "Pointer to route-map entries\n" | |
12665 | "Metric for redistributed routes\n" | |
12666 | "Default metric\n") | |
12667 | { | |
d62a17ae | 12668 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12669 | int idx_protocol = 1; | |
12670 | int idx_word = 3; | |
12671 | int idx_number = 5; | |
12672 | int type; | |
d7c0a89a | 12673 | uint32_t metric; |
d62a17ae | 12674 | struct bgp_redist *red; |
e923dd62 | 12675 | bool changed; |
1de27621 DA |
12676 | struct route_map *route_map = |
12677 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12678 | |
12679 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
12680 | if (type < 0) { | |
12681 | vty_out(vty, "%% Invalid route type\n"); | |
12682 | return CMD_WARNING_CONFIG_FAILED; | |
12683 | } | |
12684 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 12685 | |
d62a17ae | 12686 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
12687 | changed = |
12688 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12689 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, |
12690 | metric); | |
12691 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 12692 | } |
12693 | ||
12694 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
12695 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 12696 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 12697 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12698 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12699 | "Metric for redistributed routes\n" |
12700 | "Default metric\n" | |
12701 | "Route map reference\n" | |
12702 | "Pointer to route-map entries\n") | |
12703 | { | |
d62a17ae | 12704 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12705 | int idx_protocol = 1; | |
12706 | int idx_number = 3; | |
12707 | int idx_word = 5; | |
12708 | int type; | |
d7c0a89a | 12709 | uint32_t metric; |
d62a17ae | 12710 | struct bgp_redist *red; |
e923dd62 | 12711 | bool changed; |
1de27621 DA |
12712 | struct route_map *route_map = |
12713 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12714 | |
12715 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
12716 | if (type < 0) { | |
12717 | vty_out(vty, "%% Invalid route type\n"); | |
12718 | return CMD_WARNING_CONFIG_FAILED; | |
12719 | } | |
12720 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 12721 | |
d62a17ae | 12722 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 12723 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, |
12724 | metric); | |
1de27621 DA |
12725 | changed |= |
12726 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12727 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 12728 | } |
12729 | ||
12730 | DEFUN (no_bgp_redistribute_ipv6, | |
12731 | no_bgp_redistribute_ipv6_cmd, | |
e27957c0 | 12732 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", |
718e3744 | 12733 | NO_STR |
12734 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 12735 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
12736 | "Metric for redistributed routes\n" |
12737 | "Default metric\n" | |
12738 | "Route map reference\n" | |
12739 | "Pointer to route-map entries\n") | |
718e3744 | 12740 | { |
d62a17ae | 12741 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12742 | int idx_protocol = 2; | |
12743 | int type; | |
718e3744 | 12744 | |
d62a17ae | 12745 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
12746 | if (type < 0) { | |
12747 | vty_out(vty, "%% Invalid route type\n"); | |
12748 | return CMD_WARNING_CONFIG_FAILED; | |
12749 | } | |
718e3744 | 12750 | |
d62a17ae | 12751 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
12752 | } | |
12753 | ||
2b791107 | 12754 | void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, afi_t afi, |
60466a63 | 12755 | safi_t safi) |
d62a17ae | 12756 | { |
12757 | int i; | |
12758 | ||
12759 | /* Unicast redistribution only. */ | |
12760 | if (safi != SAFI_UNICAST) | |
2b791107 | 12761 | return; |
d62a17ae | 12762 | |
12763 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
12764 | /* Redistribute BGP does not make sense. */ | |
12765 | if (i != ZEBRA_ROUTE_BGP) { | |
12766 | struct list *red_list; | |
12767 | struct listnode *node; | |
12768 | struct bgp_redist *red; | |
12769 | ||
12770 | red_list = bgp->redist[afi][i]; | |
12771 | if (!red_list) | |
12772 | continue; | |
12773 | ||
12774 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 12775 | /* "redistribute" configuration. */ |
12776 | vty_out(vty, " redistribute %s", | |
12777 | zebra_route_string(i)); | |
12778 | if (red->instance) | |
12779 | vty_out(vty, " %d", red->instance); | |
12780 | if (red->redist_metric_flag) | |
12781 | vty_out(vty, " metric %u", | |
12782 | red->redist_metric); | |
12783 | if (red->rmap.name) | |
12784 | vty_out(vty, " route-map %s", | |
12785 | red->rmap.name); | |
12786 | vty_out(vty, "\n"); | |
12787 | } | |
12788 | } | |
12789 | } | |
718e3744 | 12790 | } |
6b0655a2 | 12791 | |
b9c7bc5a PZ |
12792 | /* This is part of the address-family block (unicast only) */ |
12793 | void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, | |
ddb5b488 PZ |
12794 | afi_t afi) |
12795 | { | |
b9c7bc5a | 12796 | int indent = 2; |
ddb5b488 | 12797 | |
8a066a70 PG |
12798 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
12799 | if (listcount(bgp->vpn_policy[afi].import_vrf)) | |
12800 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", | |
12801 | bgp->vpn_policy[afi] | |
bb4f6190 | 12802 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
12803 | else |
12804 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
12805 | bgp->vpn_policy[afi] | |
12806 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
12807 | } | |
12a844a5 DS |
12808 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
12809 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
12810 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
12811 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
12812 | return; | |
12813 | ||
e70e9f8e PZ |
12814 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
12815 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
12816 | ||
12817 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
12818 | ||
12819 | } else { | |
12820 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
12821 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
12822 | bgp->vpn_policy[afi].tovpn_label); | |
12823 | } | |
ddb5b488 PZ |
12824 | } |
12825 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
12826 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
12827 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 12828 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
12829 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
12830 | sizeof(buf))); | |
12831 | } | |
12832 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
12833 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
12834 | ||
12835 | char buf[PREFIX_STRLEN]; | |
12836 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
12837 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
12838 | sizeof(buf))) { | |
12839 | ||
b9c7bc5a PZ |
12840 | vty_out(vty, "%*snexthop vpn export %s\n", |
12841 | indent, "", buf); | |
ddb5b488 PZ |
12842 | } |
12843 | } | |
12844 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
12845 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
12846 | && ecommunity_cmp( | |
12847 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
12848 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
12849 | ||
12850 | char *b = ecommunity_ecom2str( | |
12851 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
12852 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12853 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
12854 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12855 | } else { | |
12856 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
12857 | char *b = ecommunity_ecom2str( | |
12858 | bgp->vpn_policy[afi] | |
12859 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
12860 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12861 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12862 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
12863 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12864 | } | |
12865 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
12866 | char *b = ecommunity_ecom2str( | |
12867 | bgp->vpn_policy[afi] | |
12868 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
12869 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12870 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12871 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
12872 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12873 | } | |
12874 | } | |
bb4f6190 DS |
12875 | |
12876 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 12877 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
12878 | bgp->vpn_policy[afi] |
12879 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 12880 | |
301ad80a PG |
12881 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
12882 | char *b = ecommunity_ecom2str( | |
12883 | bgp->vpn_policy[afi] | |
12884 | .import_redirect_rtlist, | |
12885 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12886 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 12887 | |
301ad80a PG |
12888 | vty_out(vty, "%*srt redirect import %s\n", indent, "", b); |
12889 | XFREE(MTYPE_ECOMMUNITY_STR, b); | |
12890 | } | |
ddb5b488 PZ |
12891 | } |
12892 | ||
12893 | ||
718e3744 | 12894 | /* BGP node structure. */ |
d62a17ae | 12895 | static struct cmd_node bgp_node = { |
9d303b37 | 12896 | BGP_NODE, "%s(config-router)# ", 1, |
718e3744 | 12897 | }; |
12898 | ||
d62a17ae | 12899 | static struct cmd_node bgp_ipv4_unicast_node = { |
9d303b37 | 12900 | BGP_IPV4_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12901 | }; |
12902 | ||
d62a17ae | 12903 | static struct cmd_node bgp_ipv4_multicast_node = { |
9d303b37 | 12904 | BGP_IPV4M_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12905 | }; |
12906 | ||
d62a17ae | 12907 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
9d303b37 | 12908 | BGP_IPV4L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
12909 | }; |
12910 | ||
d62a17ae | 12911 | static struct cmd_node bgp_ipv6_unicast_node = { |
9d303b37 | 12912 | BGP_IPV6_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12913 | }; |
12914 | ||
d62a17ae | 12915 | static struct cmd_node bgp_ipv6_multicast_node = { |
9d303b37 | 12916 | BGP_IPV6M_NODE, "%s(config-router-af)# ", 1, |
25ffbdc1 | 12917 | }; |
12918 | ||
d62a17ae | 12919 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
9d303b37 | 12920 | BGP_IPV6L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
12921 | }; |
12922 | ||
d62a17ae | 12923 | static struct cmd_node bgp_vpnv4_node = {BGP_VPNV4_NODE, |
12924 | "%s(config-router-af)# ", 1}; | |
6b0655a2 | 12925 | |
d62a17ae | 12926 | static struct cmd_node bgp_vpnv6_node = {BGP_VPNV6_NODE, |
12927 | "%s(config-router-af-vpnv6)# ", 1}; | |
8ecd3266 | 12928 | |
d62a17ae | 12929 | static struct cmd_node bgp_evpn_node = {BGP_EVPN_NODE, |
12930 | "%s(config-router-evpn)# ", 1}; | |
4e0b7b6d | 12931 | |
d62a17ae | 12932 | static struct cmd_node bgp_evpn_vni_node = {BGP_EVPN_VNI_NODE, |
12933 | "%s(config-router-af-vni)# ", 1}; | |
90e60aa7 | 12934 | |
7c40bf39 | 12935 | static struct cmd_node bgp_flowspecv4_node = {BGP_FLOWSPECV4_NODE, |
12936 | "%s(config-router-af)# ", 1}; | |
12937 | ||
12938 | static struct cmd_node bgp_flowspecv6_node = {BGP_FLOWSPECV6_NODE, | |
12939 | "%s(config-router-af-vpnv6)# ", 1}; | |
12940 | ||
d62a17ae | 12941 | static void community_list_vty(void); |
1f8ae70b | 12942 | |
d62a17ae | 12943 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 12944 | { |
d62a17ae | 12945 | struct bgp *bgp; |
12946 | struct peer *peer; | |
d62a17ae | 12947 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 12948 | |
d62a17ae | 12949 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
12950 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
12951 | /* only provide suggestions on the appropriate input | |
12952 | * token type, | |
12953 | * they'll otherwise show up multiple times */ | |
12954 | enum cmd_token_type match_type; | |
12955 | char *name = peer->host; | |
d48ed3e0 | 12956 | |
d62a17ae | 12957 | if (peer->conf_if) { |
12958 | match_type = VARIABLE_TKN; | |
12959 | name = peer->conf_if; | |
12960 | } else if (strchr(peer->host, ':')) | |
12961 | match_type = IPV6_TKN; | |
12962 | else | |
12963 | match_type = IPV4_TKN; | |
d48ed3e0 | 12964 | |
d62a17ae | 12965 | if (token->type != match_type) |
12966 | continue; | |
d48ed3e0 | 12967 | |
d62a17ae | 12968 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
12969 | } | |
d62a17ae | 12970 | } |
b8a815e5 DL |
12971 | } |
12972 | ||
12973 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 12974 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
12975 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 12976 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 12977 | {.completions = NULL}}; |
12978 | ||
47a306a0 DS |
12979 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
12980 | { | |
12981 | struct bgp *bgp; | |
12982 | struct peer_group *group; | |
12983 | struct listnode *lnbgp, *lnpeer; | |
12984 | ||
12985 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
12986 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
12987 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
12988 | group->name)); | |
12989 | } | |
12990 | } | |
12991 | ||
12992 | static const struct cmd_variable_handler bgp_var_peergroup[] = { | |
12993 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
12994 | {.completions = NULL} }; | |
12995 | ||
d62a17ae | 12996 | void bgp_vty_init(void) |
12997 | { | |
12998 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 12999 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 13000 | |
13001 | /* Install bgp top node. */ | |
13002 | install_node(&bgp_node, bgp_config_write); | |
13003 | install_node(&bgp_ipv4_unicast_node, NULL); | |
13004 | install_node(&bgp_ipv4_multicast_node, NULL); | |
13005 | install_node(&bgp_ipv4_labeled_unicast_node, NULL); | |
13006 | install_node(&bgp_ipv6_unicast_node, NULL); | |
13007 | install_node(&bgp_ipv6_multicast_node, NULL); | |
13008 | install_node(&bgp_ipv6_labeled_unicast_node, NULL); | |
13009 | install_node(&bgp_vpnv4_node, NULL); | |
13010 | install_node(&bgp_vpnv6_node, NULL); | |
13011 | install_node(&bgp_evpn_node, NULL); | |
13012 | install_node(&bgp_evpn_vni_node, NULL); | |
7c40bf39 | 13013 | install_node(&bgp_flowspecv4_node, NULL); |
13014 | install_node(&bgp_flowspecv6_node, NULL); | |
d62a17ae | 13015 | |
13016 | /* Install default VTY commands to new nodes. */ | |
13017 | install_default(BGP_NODE); | |
13018 | install_default(BGP_IPV4_NODE); | |
13019 | install_default(BGP_IPV4M_NODE); | |
13020 | install_default(BGP_IPV4L_NODE); | |
13021 | install_default(BGP_IPV6_NODE); | |
13022 | install_default(BGP_IPV6M_NODE); | |
13023 | install_default(BGP_IPV6L_NODE); | |
13024 | install_default(BGP_VPNV4_NODE); | |
13025 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 13026 | install_default(BGP_FLOWSPECV4_NODE); |
13027 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 13028 | install_default(BGP_EVPN_NODE); |
13029 | install_default(BGP_EVPN_VNI_NODE); | |
13030 | ||
8029b216 AK |
13031 | /* "bgp local-mac" hidden commands. */ |
13032 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
13033 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
13034 | ||
d62a17ae | 13035 | /* bgp route-map delay-timer commands. */ |
13036 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
13037 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
13038 | ||
13039 | /* Dummy commands (Currently not supported) */ | |
13040 | install_element(BGP_NODE, &no_synchronization_cmd); | |
13041 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
13042 | ||
13043 | /* "router bgp" commands. */ | |
13044 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
13045 | ||
13046 | /* "no router bgp" commands. */ | |
13047 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
13048 | ||
13049 | /* "bgp router-id" commands. */ | |
13050 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
13051 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
13052 | ||
13053 | /* "bgp cluster-id" commands. */ | |
13054 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
13055 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
13056 | ||
13057 | /* "bgp confederation" commands. */ | |
13058 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
13059 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
13060 | ||
13061 | /* "bgp confederation peers" commands. */ | |
13062 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
13063 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
13064 | ||
13065 | /* bgp max-med command */ | |
13066 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
13067 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
13068 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
13069 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
13070 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
13071 | ||
13072 | /* bgp disable-ebgp-connected-nh-check */ | |
13073 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
13074 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
13075 | ||
13076 | /* bgp update-delay command */ | |
13077 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
13078 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
13079 | install_element(BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
13080 | ||
13081 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
555e09d4 | 13082 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
d62a17ae | 13083 | |
13084 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
13085 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
13086 | ||
13087 | /* "maximum-paths" commands. */ | |
13088 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
13089 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
13090 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
13091 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
13092 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
13093 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
13094 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
13095 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
13096 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
13097 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
13098 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
13099 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
13100 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
13101 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
13102 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
13103 | ||
13104 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); | |
13105 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
13106 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
13107 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
13108 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
13109 | ||
13110 | /* "timers bgp" commands. */ | |
13111 | install_element(BGP_NODE, &bgp_timers_cmd); | |
13112 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
13113 | ||
13114 | /* route-map delay-timer commands - per instance for backwards compat. | |
13115 | */ | |
13116 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
13117 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
13118 | ||
13119 | /* "bgp client-to-client reflection" commands */ | |
13120 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
13121 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
13122 | ||
13123 | /* "bgp always-compare-med" commands */ | |
13124 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
13125 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
13126 | ||
9dac9fc8 DA |
13127 | /* bgp ebgp-requires-policy */ |
13128 | install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd); | |
13129 | install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd); | |
13130 | ||
d62a17ae | 13131 | /* "bgp deterministic-med" commands */ |
13132 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
13133 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
13134 | ||
13135 | /* "bgp graceful-restart" commands */ | |
13136 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); | |
13137 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
13138 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); | |
13139 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
13140 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
13141 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
13142 | ||
13143 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); | |
13144 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
13145 | ||
7f323236 DW |
13146 | /* "bgp graceful-shutdown" commands */ |
13147 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
13148 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
13149 | ||
d62a17ae | 13150 | /* "bgp fast-external-failover" commands */ |
13151 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
13152 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
13153 | ||
d62a17ae | 13154 | /* "bgp bestpath compare-routerid" commands */ |
13155 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
13156 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
13157 | ||
13158 | /* "bgp bestpath as-path ignore" commands */ | |
13159 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
13160 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
13161 | ||
13162 | /* "bgp bestpath as-path confed" commands */ | |
13163 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
13164 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
13165 | ||
13166 | /* "bgp bestpath as-path multipath-relax" commands */ | |
13167 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
13168 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
13169 | ||
13170 | /* "bgp log-neighbor-changes" commands */ | |
13171 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
13172 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
13173 | ||
13174 | /* "bgp bestpath med" commands */ | |
13175 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
13176 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
13177 | ||
13178 | /* "no bgp default ipv4-unicast" commands. */ | |
13179 | install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
13180 | install_element(BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
13181 | ||
13182 | /* "bgp network import-check" commands. */ | |
13183 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
13184 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
13185 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
13186 | ||
13187 | /* "bgp default local-preference" commands. */ | |
13188 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
13189 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
13190 | ||
13191 | /* bgp default show-hostname */ | |
13192 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
13193 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
13194 | ||
13195 | /* "bgp default subgroup-pkt-queue-max" commands. */ | |
13196 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
13197 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
13198 | ||
13199 | /* bgp ibgp-allow-policy-mods command */ | |
13200 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
13201 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
13202 | ||
13203 | /* "bgp listen limit" commands. */ | |
13204 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
13205 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
13206 | ||
13207 | /* "bgp listen range" commands. */ | |
13208 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
13209 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
13210 | ||
8175f54a | 13211 | /* "bgp default shutdown" command */ |
f26845f9 QY |
13212 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
13213 | ||
d62a17ae | 13214 | /* "neighbor remote-as" commands. */ |
13215 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
13216 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
13217 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
13218 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
13219 | install_element(BGP_NODE, | |
13220 | &neighbor_interface_v6only_config_remote_as_cmd); | |
13221 | install_element(BGP_NODE, &no_neighbor_cmd); | |
13222 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
13223 | ||
13224 | /* "neighbor peer-group" commands. */ | |
13225 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
13226 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
13227 | install_element(BGP_NODE, | |
13228 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
13229 | ||
13230 | /* "neighbor local-as" commands. */ | |
13231 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
13232 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
13233 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
13234 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
13235 | ||
13236 | /* "neighbor solo" commands. */ | |
13237 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
13238 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
13239 | ||
13240 | /* "neighbor password" commands. */ | |
13241 | install_element(BGP_NODE, &neighbor_password_cmd); | |
13242 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
13243 | ||
13244 | /* "neighbor activate" commands. */ | |
13245 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
13246 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
13247 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
13248 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
13249 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
13250 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
13251 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
13252 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
13253 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 13254 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
13255 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 13256 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
13257 | ||
13258 | /* "no neighbor activate" commands. */ | |
13259 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
13260 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
13261 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
13262 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
13263 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
13264 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
13265 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
13266 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
13267 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 13268 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
13269 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 13270 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
13271 | ||
13272 | /* "neighbor peer-group" set commands. */ | |
13273 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
13274 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13275 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13276 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13277 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13278 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13279 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13280 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 13281 | install_element(BGP_FLOWSPECV4_NODE, |
13282 | &neighbor_set_peer_group_hidden_cmd); | |
13283 | install_element(BGP_FLOWSPECV6_NODE, | |
13284 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 13285 | |
13286 | /* "no neighbor peer-group unset" commands. */ | |
13287 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
13288 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13289 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13290 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13291 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13292 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13293 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13294 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 13295 | install_element(BGP_FLOWSPECV4_NODE, |
13296 | &no_neighbor_set_peer_group_hidden_cmd); | |
13297 | install_element(BGP_FLOWSPECV6_NODE, | |
13298 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 13299 | |
13300 | /* "neighbor softreconfiguration inbound" commands.*/ | |
13301 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
13302 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
13303 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
13304 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13305 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
13306 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13307 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
13308 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13309 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
13310 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13311 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
13312 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13313 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
13314 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13315 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
13316 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13317 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
13318 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 13319 | install_element(BGP_FLOWSPECV4_NODE, |
13320 | &neighbor_soft_reconfiguration_cmd); | |
13321 | install_element(BGP_FLOWSPECV4_NODE, | |
13322 | &no_neighbor_soft_reconfiguration_cmd); | |
13323 | install_element(BGP_FLOWSPECV6_NODE, | |
13324 | &neighbor_soft_reconfiguration_cmd); | |
13325 | install_element(BGP_FLOWSPECV6_NODE, | |
13326 | &no_neighbor_soft_reconfiguration_cmd); | |
616c6ee8 PG |
13327 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); |
13328 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 13329 | |
13330 | /* "neighbor attribute-unchanged" commands. */ | |
13331 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
13332 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
13333 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
13334 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
13335 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
13336 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
13337 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
13338 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
13339 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
13340 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
13341 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
13342 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
13343 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
13344 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
13345 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
13346 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
13347 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
13348 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
13349 | ||
13350 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
13351 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
13352 | ||
13353 | /* "nexthop-local unchanged" commands */ | |
13354 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
13355 | install_element(BGP_IPV6_NODE, | |
13356 | &no_neighbor_nexthop_local_unchanged_cmd); | |
13357 | ||
13358 | /* "neighbor next-hop-self" commands. */ | |
13359 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
13360 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
13361 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
13362 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
13363 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
13364 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
13365 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
13366 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
13367 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
13368 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
13369 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
13370 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
13371 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
13372 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
13373 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
13374 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
13375 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
13376 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
13377 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
13378 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 13379 | |
13380 | /* "neighbor next-hop-self force" commands. */ | |
13381 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
13382 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
1bc4e531 DA |
13383 | install_element(BGP_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
13384 | install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 13385 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
13386 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
13387 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
13388 | install_element(BGP_IPV4_NODE, | |
13389 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 13390 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); |
13391 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
13392 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
13393 | install_element(BGP_IPV4M_NODE, | |
13394 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 13395 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); |
13396 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
13397 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
13398 | install_element(BGP_IPV4L_NODE, | |
13399 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 13400 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); |
13401 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
13402 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
13403 | install_element(BGP_IPV6_NODE, | |
13404 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 13405 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); |
13406 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
13407 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
13408 | install_element(BGP_IPV6M_NODE, | |
13409 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 13410 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); |
13411 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
13412 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
13413 | install_element(BGP_IPV6L_NODE, | |
13414 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 13415 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); |
13416 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
13417 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
13418 | install_element(BGP_VPNV4_NODE, | |
13419 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 13420 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
13421 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
13422 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
13423 | install_element(BGP_VPNV6_NODE, | |
13424 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 13425 | |
13426 | /* "neighbor as-override" commands. */ | |
13427 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
13428 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
13429 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
13430 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
13431 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
13432 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
13433 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
13434 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
13435 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
13436 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
13437 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
13438 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
13439 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
13440 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
13441 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
13442 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
13443 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
13444 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
13445 | ||
13446 | /* "neighbor remove-private-AS" commands. */ | |
13447 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
13448 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
13449 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
13450 | install_element(BGP_NODE, | |
13451 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
13452 | install_element(BGP_NODE, | |
13453 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
13454 | install_element(BGP_NODE, | |
13455 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
13456 | install_element(BGP_NODE, | |
13457 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
13458 | install_element( | |
13459 | BGP_NODE, | |
13460 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
13461 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
13462 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
13463 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
13464 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13465 | install_element(BGP_IPV4_NODE, | |
13466 | &neighbor_remove_private_as_replace_as_cmd); | |
13467 | install_element(BGP_IPV4_NODE, | |
13468 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13469 | install_element(BGP_IPV4_NODE, | |
13470 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13471 | install_element(BGP_IPV4_NODE, | |
13472 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13473 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
13474 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
13475 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
13476 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13477 | install_element(BGP_IPV4M_NODE, | |
13478 | &neighbor_remove_private_as_replace_as_cmd); | |
13479 | install_element(BGP_IPV4M_NODE, | |
13480 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13481 | install_element(BGP_IPV4M_NODE, | |
13482 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13483 | install_element(BGP_IPV4M_NODE, | |
13484 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13485 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
13486 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
13487 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
13488 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13489 | install_element(BGP_IPV4L_NODE, | |
13490 | &neighbor_remove_private_as_replace_as_cmd); | |
13491 | install_element(BGP_IPV4L_NODE, | |
13492 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13493 | install_element(BGP_IPV4L_NODE, | |
13494 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13495 | install_element(BGP_IPV4L_NODE, | |
13496 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13497 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
13498 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
13499 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
13500 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13501 | install_element(BGP_IPV6_NODE, | |
13502 | &neighbor_remove_private_as_replace_as_cmd); | |
13503 | install_element(BGP_IPV6_NODE, | |
13504 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13505 | install_element(BGP_IPV6_NODE, | |
13506 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13507 | install_element(BGP_IPV6_NODE, | |
13508 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13509 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
13510 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
13511 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
13512 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13513 | install_element(BGP_IPV6M_NODE, | |
13514 | &neighbor_remove_private_as_replace_as_cmd); | |
13515 | install_element(BGP_IPV6M_NODE, | |
13516 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13517 | install_element(BGP_IPV6M_NODE, | |
13518 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13519 | install_element(BGP_IPV6M_NODE, | |
13520 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13521 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
13522 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
13523 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
13524 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13525 | install_element(BGP_IPV6L_NODE, | |
13526 | &neighbor_remove_private_as_replace_as_cmd); | |
13527 | install_element(BGP_IPV6L_NODE, | |
13528 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13529 | install_element(BGP_IPV6L_NODE, | |
13530 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13531 | install_element(BGP_IPV6L_NODE, | |
13532 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13533 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
13534 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
13535 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
13536 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13537 | install_element(BGP_VPNV4_NODE, | |
13538 | &neighbor_remove_private_as_replace_as_cmd); | |
13539 | install_element(BGP_VPNV4_NODE, | |
13540 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13541 | install_element(BGP_VPNV4_NODE, | |
13542 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13543 | install_element(BGP_VPNV4_NODE, | |
13544 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13545 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
13546 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
13547 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
13548 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13549 | install_element(BGP_VPNV6_NODE, | |
13550 | &neighbor_remove_private_as_replace_as_cmd); | |
13551 | install_element(BGP_VPNV6_NODE, | |
13552 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13553 | install_element(BGP_VPNV6_NODE, | |
13554 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13555 | install_element(BGP_VPNV6_NODE, | |
13556 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13557 | ||
13558 | /* "neighbor send-community" commands.*/ | |
13559 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
13560 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
13561 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
13562 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
13563 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
13564 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
13565 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
13566 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
13567 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
13568 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
13569 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
13570 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
13571 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
13572 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
13573 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
13574 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
13575 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
13576 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
13577 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
13578 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
13579 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
13580 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
13581 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
13582 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
13583 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
13584 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
13585 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
13586 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
13587 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
13588 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
13589 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
13590 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
13591 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
13592 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
13593 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
13594 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
13595 | ||
13596 | /* "neighbor route-reflector" commands.*/ | |
13597 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
13598 | install_element(BGP_NODE, | |
13599 | &no_neighbor_route_reflector_client_hidden_cmd); | |
13600 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
13601 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
13602 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
13603 | install_element(BGP_IPV4M_NODE, | |
13604 | &no_neighbor_route_reflector_client_cmd); | |
13605 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
13606 | install_element(BGP_IPV4L_NODE, | |
13607 | &no_neighbor_route_reflector_client_cmd); | |
13608 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
13609 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
13610 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
13611 | install_element(BGP_IPV6M_NODE, | |
13612 | &no_neighbor_route_reflector_client_cmd); | |
13613 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
13614 | install_element(BGP_IPV6L_NODE, | |
13615 | &no_neighbor_route_reflector_client_cmd); | |
13616 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
13617 | install_element(BGP_VPNV4_NODE, | |
13618 | &no_neighbor_route_reflector_client_cmd); | |
13619 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
13620 | install_element(BGP_VPNV6_NODE, | |
13621 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 13622 | install_element(BGP_FLOWSPECV4_NODE, |
13623 | &neighbor_route_reflector_client_cmd); | |
13624 | install_element(BGP_FLOWSPECV4_NODE, | |
13625 | &no_neighbor_route_reflector_client_cmd); | |
13626 | install_element(BGP_FLOWSPECV6_NODE, | |
13627 | &neighbor_route_reflector_client_cmd); | |
13628 | install_element(BGP_FLOWSPECV6_NODE, | |
13629 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 13630 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
13631 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
13632 | ||
13633 | /* "neighbor route-server" commands.*/ | |
13634 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
13635 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
13636 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
13637 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
13638 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
13639 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
13640 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
13641 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
13642 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
13643 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
13644 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
13645 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
13646 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
13647 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
13648 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
13649 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
13650 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
13651 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
13652 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
13653 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 13654 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
13655 | install_element(BGP_FLOWSPECV4_NODE, | |
13656 | &no_neighbor_route_server_client_cmd); | |
13657 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
13658 | install_element(BGP_FLOWSPECV6_NODE, | |
13659 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 13660 | |
13661 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
13662 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
13663 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
13664 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13665 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13666 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13667 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13668 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13669 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13670 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13671 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13672 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13673 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13674 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13675 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13676 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13677 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13678 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13679 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13680 | ||
13681 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
13682 | install_element(BGP_NODE, | |
13683 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
13684 | install_element(BGP_NODE, | |
13685 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
13686 | install_element(BGP_IPV4_NODE, | |
13687 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13688 | install_element(BGP_IPV4_NODE, | |
13689 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13690 | install_element(BGP_IPV4M_NODE, | |
13691 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13692 | install_element(BGP_IPV4M_NODE, | |
13693 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13694 | install_element(BGP_IPV4L_NODE, | |
13695 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13696 | install_element(BGP_IPV4L_NODE, | |
13697 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13698 | install_element(BGP_IPV6_NODE, | |
13699 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13700 | install_element(BGP_IPV6_NODE, | |
13701 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13702 | install_element(BGP_IPV6M_NODE, | |
13703 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13704 | install_element(BGP_IPV6M_NODE, | |
13705 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13706 | install_element(BGP_IPV6L_NODE, | |
13707 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13708 | install_element(BGP_IPV6L_NODE, | |
13709 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13710 | install_element(BGP_VPNV4_NODE, | |
13711 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13712 | install_element(BGP_VPNV4_NODE, | |
13713 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13714 | install_element(BGP_VPNV6_NODE, | |
13715 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13716 | install_element(BGP_VPNV6_NODE, | |
13717 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13718 | ||
2b31007c RZ |
13719 | /* "neighbor sender-as-path-loop-detection" commands. */ |
13720 | install_element(BGP_NODE, &neighbor_aspath_loop_detection_cmd); | |
13721 | install_element(BGP_NODE, &no_neighbor_aspath_loop_detection_cmd); | |
13722 | ||
d62a17ae | 13723 | /* "neighbor passive" commands. */ |
13724 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
13725 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
13726 | ||
13727 | ||
13728 | /* "neighbor shutdown" commands. */ | |
13729 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
13730 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
13731 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
13732 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
13733 | ||
13734 | /* "neighbor capability extended-nexthop" commands.*/ | |
13735 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
13736 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
13737 | ||
13738 | /* "neighbor capability orf prefix-list" commands.*/ | |
13739 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
13740 | install_element(BGP_NODE, | |
13741 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
13742 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
13743 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13744 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
13745 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13746 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
13747 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13748 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
13749 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13750 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
13751 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13752 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
13753 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13754 | ||
13755 | /* "neighbor capability dynamic" commands.*/ | |
13756 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
13757 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
13758 | ||
13759 | /* "neighbor dont-capability-negotiate" commands. */ | |
13760 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
13761 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
13762 | ||
13763 | /* "neighbor ebgp-multihop" commands. */ | |
13764 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
13765 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
13766 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
13767 | ||
13768 | /* "neighbor disable-connected-check" commands. */ | |
13769 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
13770 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
13771 | ||
47cbc09b PM |
13772 | /* "neighbor enforce-first-as" commands. */ |
13773 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
13774 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
13775 | ||
d62a17ae | 13776 | /* "neighbor description" commands. */ |
13777 | install_element(BGP_NODE, &neighbor_description_cmd); | |
13778 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 13779 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 13780 | |
13781 | /* "neighbor update-source" commands. "*/ | |
13782 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
13783 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
13784 | ||
13785 | /* "neighbor default-originate" commands. */ | |
13786 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
13787 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
13788 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
13789 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
13790 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
13791 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
13792 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
13793 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
13794 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
13795 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
13796 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
13797 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
13798 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
13799 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
13800 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
13801 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
13802 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
13803 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
13804 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
13805 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
13806 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
13807 | ||
13808 | /* "neighbor port" commands. */ | |
13809 | install_element(BGP_NODE, &neighbor_port_cmd); | |
13810 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
13811 | ||
13812 | /* "neighbor weight" commands. */ | |
13813 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
13814 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
13815 | ||
13816 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
13817 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
13818 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
13819 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
13820 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
13821 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
13822 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
13823 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
13824 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
13825 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
13826 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
13827 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
13828 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
13829 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
13830 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
13831 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
13832 | ||
13833 | /* "neighbor override-capability" commands. */ | |
13834 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
13835 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
13836 | ||
13837 | /* "neighbor strict-capability-match" commands. */ | |
13838 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
13839 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
13840 | ||
13841 | /* "neighbor timers" commands. */ | |
13842 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
13843 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
13844 | ||
13845 | /* "neighbor timers connect" commands. */ | |
13846 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
13847 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
13848 | ||
13849 | /* "neighbor advertisement-interval" commands. */ | |
13850 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
13851 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
13852 | ||
13853 | /* "neighbor interface" commands. */ | |
13854 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
13855 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
13856 | ||
13857 | /* "neighbor distribute" commands. */ | |
13858 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
13859 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
13860 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
13861 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
13862 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
13863 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
13864 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
13865 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
13866 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
13867 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
13868 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
13869 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
13870 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
13871 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
13872 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
13873 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
13874 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
13875 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
13876 | ||
13877 | /* "neighbor prefix-list" commands. */ | |
13878 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
13879 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
13880 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
13881 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
13882 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
13883 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
13884 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); | |
13885 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
13886 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
13887 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
13888 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); | |
13889 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
13890 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); | |
13891 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
13892 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); | |
13893 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
13894 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); | |
13895 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
7c40bf39 | 13896 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
13897 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); | |
13898 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); | |
13899 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); | |
d62a17ae | 13900 | |
13901 | /* "neighbor filter-list" commands. */ | |
13902 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
13903 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
13904 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
13905 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
13906 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
13907 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
13908 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
13909 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
13910 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
13911 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
13912 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
13913 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
13914 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
13915 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
13916 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
13917 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
13918 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
13919 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 13920 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
13921 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
13922 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
13923 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 13924 | |
13925 | /* "neighbor route-map" commands. */ | |
13926 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); | |
13927 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
13928 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
13929 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
13930 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
13931 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
13932 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); | |
13933 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
13934 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
13935 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
13936 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); | |
13937 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
13938 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); | |
13939 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
13940 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); | |
13941 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
13942 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); | |
13943 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
7c40bf39 | 13944 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
13945 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); | |
13946 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); | |
13947 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); | |
d37ba549 MK |
13948 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
13949 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); | |
d62a17ae | 13950 | |
13951 | /* "neighbor unsuppress-map" commands. */ | |
13952 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
13953 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
13954 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
13955 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
13956 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
13957 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
13958 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
13959 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
13960 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
13961 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
13962 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
13963 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
13964 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
13965 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
13966 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
13967 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
13968 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
13969 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
13970 | ||
13971 | /* "neighbor maximum-prefix" commands. */ | |
13972 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
13973 | install_element(BGP_NODE, | |
13974 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
13975 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
13976 | install_element(BGP_NODE, | |
13977 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
13978 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
13979 | install_element(BGP_NODE, | |
13980 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
13981 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
13982 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
13983 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13984 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13985 | install_element(BGP_IPV4_NODE, | |
13986 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13987 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13988 | install_element(BGP_IPV4_NODE, | |
13989 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13990 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
13991 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
13992 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13993 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13994 | install_element(BGP_IPV4M_NODE, | |
13995 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13996 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13997 | install_element(BGP_IPV4M_NODE, | |
13998 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13999 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
14000 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
14001 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
14002 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
14003 | install_element(BGP_IPV4L_NODE, | |
14004 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
14005 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
14006 | install_element(BGP_IPV4L_NODE, | |
14007 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
14008 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
14009 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
14010 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
14011 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
14012 | install_element(BGP_IPV6_NODE, | |
14013 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
14014 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
14015 | install_element(BGP_IPV6_NODE, | |
14016 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
14017 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
14018 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
14019 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
14020 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
14021 | install_element(BGP_IPV6M_NODE, | |
14022 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
14023 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
14024 | install_element(BGP_IPV6M_NODE, | |
14025 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
14026 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
14027 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
14028 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
14029 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
14030 | install_element(BGP_IPV6L_NODE, | |
14031 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
14032 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
14033 | install_element(BGP_IPV6L_NODE, | |
14034 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
14035 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
14036 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
14037 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
14038 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
14039 | install_element(BGP_VPNV4_NODE, | |
14040 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
14041 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
14042 | install_element(BGP_VPNV4_NODE, | |
14043 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
14044 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
14045 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
14046 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
14047 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
14048 | install_element(BGP_VPNV6_NODE, | |
14049 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
14050 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
14051 | install_element(BGP_VPNV6_NODE, | |
14052 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
14053 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
14054 | ||
14055 | /* "neighbor allowas-in" */ | |
14056 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
14057 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
14058 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
14059 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
14060 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
14061 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
14062 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
14063 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
14064 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
14065 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
14066 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
14067 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
14068 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
14069 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
14070 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
14071 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
14072 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
14073 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
14074 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
14075 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
14076 | ||
14077 | /* address-family commands. */ | |
14078 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
14079 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 14080 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 14081 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
14082 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 14083 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 14084 | |
d62a17ae | 14085 | install_element(BGP_NODE, &address_family_evpn_cmd); |
14086 | ||
14087 | /* "exit-address-family" command. */ | |
14088 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
14089 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
14090 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
14091 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
14092 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
14093 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
14094 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
14095 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 14096 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
14097 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 14098 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
14099 | ||
14100 | /* "clear ip bgp commands" */ | |
14101 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
14102 | ||
14103 | /* clear ip bgp prefix */ | |
14104 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
14105 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
14106 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
14107 | ||
14108 | /* "show [ip] bgp summary" commands. */ | |
14109 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 14110 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 14111 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 14112 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 14113 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
14114 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 14115 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
14116 | ||
14117 | /* "show [ip] bgp neighbors" commands. */ | |
14118 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
14119 | ||
14120 | /* "show [ip] bgp peer-group" commands. */ | |
14121 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
14122 | ||
14123 | /* "show [ip] bgp paths" commands. */ | |
14124 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
14125 | ||
14126 | /* "show [ip] bgp community" commands. */ | |
14127 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
14128 | ||
14129 | /* "show ip bgp large-community" commands. */ | |
14130 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
14131 | /* "show [ip] bgp attribute-info" commands. */ | |
14132 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 14133 | /* "show [ip] bgp route-leak" command */ |
14134 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 14135 | |
14136 | /* "redistribute" commands. */ | |
14137 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
14138 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
14139 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
14140 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
14141 | install_element(BGP_NODE, | |
14142 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
14143 | install_element(BGP_NODE, | |
14144 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
14145 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
14146 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
14147 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
14148 | install_element(BGP_NODE, | |
14149 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
14150 | install_element(BGP_NODE, | |
14151 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
14152 | install_element(BGP_NODE, | |
14153 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
14154 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
14155 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
14156 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
14157 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
14158 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
14159 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
14160 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
14161 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
14162 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
14163 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
14164 | install_element(BGP_IPV4_NODE, | |
14165 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
14166 | install_element(BGP_IPV4_NODE, | |
14167 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
14168 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
14169 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
14170 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
14171 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
14172 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
14173 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
14174 | ||
b9c7bc5a PZ |
14175 | /* import|export vpn [route-map WORD] */ |
14176 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
14177 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 14178 | |
12a844a5 DS |
14179 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
14180 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
14181 | ||
d62a17ae | 14182 | /* ttl_security commands */ |
14183 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
14184 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
14185 | ||
14186 | /* "show [ip] bgp memory" commands. */ | |
14187 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
14188 | ||
acf71666 MK |
14189 | /* "show bgp martian next-hop" */ |
14190 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
14191 | ||
48ecf8f5 DS |
14192 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); |
14193 | ||
d62a17ae | 14194 | /* "show [ip] bgp views" commands. */ |
14195 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
14196 | ||
14197 | /* "show [ip] bgp vrfs" commands. */ | |
14198 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
14199 | ||
14200 | /* Community-list. */ | |
14201 | community_list_vty(); | |
ddb5b488 PZ |
14202 | |
14203 | /* vpn-policy commands */ | |
b9c7bc5a PZ |
14204 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
14205 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
14206 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
14207 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
14208 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
14209 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
14210 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
14211 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
14212 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
14213 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
14214 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
14215 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 14216 | |
301ad80a PG |
14217 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
14218 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
14219 | ||
b9c7bc5a PZ |
14220 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
14221 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
14222 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
14223 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
14224 | install_element(BGP_IPV4_NODE, &af_no_nexthop_vpn_export_cmd); | |
14225 | install_element(BGP_IPV6_NODE, &af_no_nexthop_vpn_export_cmd); | |
14226 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); | |
14227 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
14228 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
14229 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
14230 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
14231 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
718e3744 | 14232 | } |
6b0655a2 | 14233 | |
718e3744 | 14234 | #include "memory.h" |
14235 | #include "bgp_regex.h" | |
14236 | #include "bgp_clist.h" | |
14237 | #include "bgp_ecommunity.h" | |
14238 | ||
14239 | /* VTY functions. */ | |
14240 | ||
14241 | /* Direction value to string conversion. */ | |
d62a17ae | 14242 | static const char *community_direct_str(int direct) |
14243 | { | |
14244 | switch (direct) { | |
14245 | case COMMUNITY_DENY: | |
14246 | return "deny"; | |
14247 | case COMMUNITY_PERMIT: | |
14248 | return "permit"; | |
14249 | default: | |
14250 | return "unknown"; | |
14251 | } | |
718e3744 | 14252 | } |
14253 | ||
14254 | /* Display error string. */ | |
d62a17ae | 14255 | static void community_list_perror(struct vty *vty, int ret) |
14256 | { | |
14257 | switch (ret) { | |
14258 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
14259 | vty_out(vty, "%% Can't find community-list\n"); | |
14260 | break; | |
14261 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
14262 | vty_out(vty, "%% Malformed community-list value\n"); | |
14263 | break; | |
14264 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
14265 | vty_out(vty, | |
14266 | "%% Community name conflict, previously defined as standard community\n"); | |
14267 | break; | |
14268 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
14269 | vty_out(vty, | |
14270 | "%% Community name conflict, previously defined as expanded community\n"); | |
14271 | break; | |
14272 | } | |
718e3744 | 14273 | } |
14274 | ||
5bf15956 DW |
14275 | /* "community-list" keyword help string. */ |
14276 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
14277 | ||
7336e101 SP |
14278 | /*community-list standard */ |
14279 | DEFUN (community_list_standard, | |
14280 | bgp_community_list_standard_cmd, | |
14281 | "bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
14282 | BGP_STR | |
718e3744 | 14283 | COMMUNITY_LIST_STR |
14284 | "Community list number (standard)\n" | |
5bf15956 | 14285 | "Add an standard community-list entry\n" |
718e3744 | 14286 | "Community list name\n" |
14287 | "Specify community to reject\n" | |
14288 | "Specify community to accept\n" | |
14289 | COMMUNITY_VAL_STR) | |
14290 | { | |
d62a17ae | 14291 | char *cl_name_or_number = NULL; |
14292 | int direct = 0; | |
14293 | int style = COMMUNITY_LIST_STANDARD; | |
d62a17ae | 14294 | int idx = 0; |
7336e101 | 14295 | |
d62a17ae | 14296 | argv_find(argv, argc, "(1-99)", &idx); |
14297 | argv_find(argv, argc, "WORD", &idx); | |
14298 | cl_name_or_number = argv[idx]->arg; | |
14299 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14300 | : COMMUNITY_DENY; | |
14301 | argv_find(argv, argc, "AA:NN", &idx); | |
14302 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14303 | |
d62a17ae | 14304 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
14305 | style); | |
42f914d4 | 14306 | |
d62a17ae | 14307 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14308 | |
d62a17ae | 14309 | if (ret < 0) { |
14310 | /* Display error string. */ | |
14311 | community_list_perror(vty, ret); | |
14312 | return CMD_WARNING_CONFIG_FAILED; | |
14313 | } | |
42f914d4 | 14314 | |
d62a17ae | 14315 | return CMD_SUCCESS; |
718e3744 | 14316 | } |
14317 | ||
7336e101 SP |
14318 | DEFUN (no_community_list_standard_all, |
14319 | no_bgp_community_list_standard_all_cmd, | |
14320 | "no bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
14321 | NO_STR | |
14322 | BGP_STR | |
14323 | COMMUNITY_LIST_STR | |
14324 | "Community list number (standard)\n" | |
14325 | "Add an standard community-list entry\n" | |
14326 | "Community list name\n" | |
14327 | "Specify community to reject\n" | |
14328 | "Specify community to accept\n" | |
14329 | COMMUNITY_VAL_STR) | |
718e3744 | 14330 | { |
d62a17ae | 14331 | char *cl_name_or_number = NULL; |
174b5cb9 | 14332 | char *str = NULL; |
d62a17ae | 14333 | int direct = 0; |
14334 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 14335 | |
d62a17ae | 14336 | int idx = 0; |
7336e101 | 14337 | |
174b5cb9 DA |
14338 | argv_find(argv, argc, "permit", &idx); |
14339 | argv_find(argv, argc, "deny", &idx); | |
14340 | ||
14341 | if (idx) { | |
14342 | direct = argv_find(argv, argc, "permit", &idx) | |
14343 | ? COMMUNITY_PERMIT | |
14344 | : COMMUNITY_DENY; | |
14345 | ||
14346 | idx = 0; | |
14347 | argv_find(argv, argc, "AA:NN", &idx); | |
14348 | str = argv_concat(argv, argc, idx); | |
14349 | } | |
14350 | ||
14351 | idx = 0; | |
d62a17ae | 14352 | argv_find(argv, argc, "(1-99)", &idx); |
14353 | argv_find(argv, argc, "WORD", &idx); | |
14354 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 14355 | |
d62a17ae | 14356 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
7298a8e1 | 14357 | direct, style); |
42f914d4 | 14358 | |
d62a17ae | 14359 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 14360 | |
d62a17ae | 14361 | if (ret < 0) { |
14362 | community_list_perror(vty, ret); | |
14363 | return CMD_WARNING_CONFIG_FAILED; | |
14364 | } | |
42f914d4 | 14365 | |
d62a17ae | 14366 | return CMD_SUCCESS; |
718e3744 | 14367 | } |
7336e101 | 14368 | |
174b5cb9 DA |
14369 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
14370 | "no bgp community-list <(1-99)|standard WORD>", | |
14371 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
14372 | "Community list number (standard)\n" | |
14373 | "Add an standard community-list entry\n" | |
14374 | "Community list name\n") | |
14375 | ||
7336e101 SP |
14376 | /*community-list expanded */ |
14377 | DEFUN (community_list_expanded_all, | |
14378 | bgp_community_list_expanded_all_cmd, | |
14379 | "bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
14380 | BGP_STR | |
14381 | COMMUNITY_LIST_STR | |
718e3744 | 14382 | "Community list number (expanded)\n" |
5bf15956 | 14383 | "Add an expanded community-list entry\n" |
718e3744 | 14384 | "Community list name\n" |
14385 | "Specify community to reject\n" | |
14386 | "Specify community to accept\n" | |
14387 | COMMUNITY_VAL_STR) | |
14388 | { | |
d62a17ae | 14389 | char *cl_name_or_number = NULL; |
14390 | int direct = 0; | |
14391 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 14392 | |
d62a17ae | 14393 | int idx = 0; |
7b9a4750 | 14394 | |
d62a17ae | 14395 | argv_find(argv, argc, "(100-500)", &idx); |
14396 | argv_find(argv, argc, "WORD", &idx); | |
14397 | cl_name_or_number = argv[idx]->arg; | |
14398 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14399 | : COMMUNITY_DENY; | |
14400 | argv_find(argv, argc, "AA:NN", &idx); | |
14401 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14402 | |
d62a17ae | 14403 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
14404 | style); | |
42f914d4 | 14405 | |
d62a17ae | 14406 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14407 | |
d62a17ae | 14408 | if (ret < 0) { |
14409 | /* Display error string. */ | |
14410 | community_list_perror(vty, ret); | |
14411 | return CMD_WARNING_CONFIG_FAILED; | |
14412 | } | |
42f914d4 | 14413 | |
d62a17ae | 14414 | return CMD_SUCCESS; |
718e3744 | 14415 | } |
14416 | ||
7336e101 SP |
14417 | DEFUN (no_community_list_expanded_all, |
14418 | no_bgp_community_list_expanded_all_cmd, | |
14419 | "no bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
14420 | NO_STR | |
14421 | BGP_STR | |
14422 | COMMUNITY_LIST_STR | |
14423 | "Community list number (expanded)\n" | |
14424 | "Add an expanded community-list entry\n" | |
14425 | "Community list name\n" | |
14426 | "Specify community to reject\n" | |
14427 | "Specify community to accept\n" | |
14428 | COMMUNITY_VAL_STR) | |
718e3744 | 14429 | { |
d62a17ae | 14430 | char *cl_name_or_number = NULL; |
174b5cb9 | 14431 | char *str = NULL; |
d62a17ae | 14432 | int direct = 0; |
14433 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 14434 | |
d62a17ae | 14435 | int idx = 0; |
174b5cb9 DA |
14436 | |
14437 | argv_find(argv, argc, "permit", &idx); | |
14438 | argv_find(argv, argc, "deny", &idx); | |
14439 | ||
14440 | if (idx) { | |
14441 | direct = argv_find(argv, argc, "permit", &idx) | |
14442 | ? COMMUNITY_PERMIT | |
14443 | : COMMUNITY_DENY; | |
14444 | ||
14445 | idx = 0; | |
14446 | argv_find(argv, argc, "AA:NN", &idx); | |
14447 | str = argv_concat(argv, argc, idx); | |
7336e101 | 14448 | } |
174b5cb9 DA |
14449 | |
14450 | idx = 0; | |
d62a17ae | 14451 | argv_find(argv, argc, "(100-500)", &idx); |
14452 | argv_find(argv, argc, "WORD", &idx); | |
14453 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 14454 | |
d62a17ae | 14455 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
7298a8e1 | 14456 | direct, style); |
42f914d4 | 14457 | |
d62a17ae | 14458 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 14459 | |
d62a17ae | 14460 | if (ret < 0) { |
14461 | community_list_perror(vty, ret); | |
14462 | return CMD_WARNING_CONFIG_FAILED; | |
14463 | } | |
42f914d4 | 14464 | |
d62a17ae | 14465 | return CMD_SUCCESS; |
718e3744 | 14466 | } |
14467 | ||
174b5cb9 DA |
14468 | ALIAS(no_community_list_expanded_all, no_bgp_community_list_expanded_all_list_cmd, |
14469 | "no bgp community-list <(100-500)|expanded WORD>", | |
14470 | NO_STR IP_STR COMMUNITY_LIST_STR | |
14471 | "Community list number (expanded)\n" | |
14472 | "Add an expanded community-list entry\n" | |
14473 | "Community list name\n") | |
14474 | ||
8d9b8ed9 PM |
14475 | /* Return configuration string of community-list entry. */ |
14476 | static const char *community_list_config_str(struct community_entry *entry) | |
14477 | { | |
14478 | const char *str; | |
14479 | ||
14480 | if (entry->any) | |
14481 | str = ""; | |
14482 | else { | |
14483 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
14484 | str = community_str(entry->u.com, false); | |
14485 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
14486 | str = lcommunity_str(entry->u.lcom, false); | |
14487 | else | |
14488 | str = entry->config; | |
14489 | } | |
14490 | return str; | |
14491 | } | |
14492 | ||
d62a17ae | 14493 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 14494 | { |
d62a17ae | 14495 | struct community_entry *entry; |
718e3744 | 14496 | |
d62a17ae | 14497 | for (entry = list->head; entry; entry = entry->next) { |
14498 | if (entry == list->head) { | |
14499 | if (all_digit(list->name)) | |
14500 | vty_out(vty, "Community %s list %s\n", | |
14501 | entry->style == COMMUNITY_LIST_STANDARD | |
14502 | ? "standard" | |
14503 | : "(expanded) access", | |
14504 | list->name); | |
14505 | else | |
14506 | vty_out(vty, "Named Community %s list %s\n", | |
14507 | entry->style == COMMUNITY_LIST_STANDARD | |
14508 | ? "standard" | |
14509 | : "expanded", | |
14510 | list->name); | |
14511 | } | |
14512 | if (entry->any) | |
14513 | vty_out(vty, " %s\n", | |
14514 | community_direct_str(entry->direct)); | |
14515 | else | |
14516 | vty_out(vty, " %s %s\n", | |
14517 | community_direct_str(entry->direct), | |
8d9b8ed9 | 14518 | community_list_config_str(entry)); |
d62a17ae | 14519 | } |
718e3744 | 14520 | } |
14521 | ||
7336e101 SP |
14522 | DEFUN (show_community_list, |
14523 | show_bgp_community_list_cmd, | |
14524 | "show bgp community-list", | |
718e3744 | 14525 | SHOW_STR |
7336e101 | 14526 | BGP_STR |
718e3744 | 14527 | "List community-list\n") |
14528 | { | |
d62a17ae | 14529 | struct community_list *list; |
14530 | struct community_list_master *cm; | |
718e3744 | 14531 | |
d62a17ae | 14532 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
14533 | if (!cm) | |
14534 | return CMD_SUCCESS; | |
718e3744 | 14535 | |
d62a17ae | 14536 | for (list = cm->num.head; list; list = list->next) |
14537 | community_list_show(vty, list); | |
718e3744 | 14538 | |
d62a17ae | 14539 | for (list = cm->str.head; list; list = list->next) |
14540 | community_list_show(vty, list); | |
718e3744 | 14541 | |
d62a17ae | 14542 | return CMD_SUCCESS; |
718e3744 | 14543 | } |
14544 | ||
7336e101 SP |
14545 | DEFUN (show_community_list_arg, |
14546 | show_bgp_community_list_arg_cmd, | |
960b69b9 | 14547 | "show bgp community-list <(1-500)|WORD> detail", |
7336e101 SP |
14548 | SHOW_STR |
14549 | BGP_STR | |
718e3744 | 14550 | "List community-list\n" |
14551 | "Community-list number\n" | |
960b69b9 | 14552 | "Community-list name\n" |
14553 | "Detailed information on community-list\n") | |
718e3744 | 14554 | { |
d62a17ae | 14555 | int idx_comm_list = 3; |
14556 | struct community_list *list; | |
718e3744 | 14557 | |
e237b0d2 | 14558 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 14559 | COMMUNITY_LIST_MASTER); |
14560 | if (!list) { | |
14561 | vty_out(vty, "%% Can't find community-list\n"); | |
14562 | return CMD_WARNING; | |
14563 | } | |
718e3744 | 14564 | |
d62a17ae | 14565 | community_list_show(vty, list); |
718e3744 | 14566 | |
d62a17ae | 14567 | return CMD_SUCCESS; |
718e3744 | 14568 | } |
6b0655a2 | 14569 | |
57d187bc JS |
14570 | /* |
14571 | * Large Community code. | |
14572 | */ | |
d62a17ae | 14573 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
14574 | struct cmd_token **argv, int style, | |
14575 | int reject_all_digit_name) | |
14576 | { | |
14577 | int ret; | |
14578 | int direct; | |
14579 | char *str; | |
14580 | int idx = 0; | |
14581 | char *cl_name; | |
14582 | ||
14583 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14584 | : COMMUNITY_DENY; | |
14585 | ||
14586 | /* All digit name check. */ | |
14587 | idx = 0; | |
14588 | argv_find(argv, argc, "WORD", &idx); | |
14589 | argv_find(argv, argc, "(1-99)", &idx); | |
14590 | argv_find(argv, argc, "(100-500)", &idx); | |
14591 | cl_name = argv[idx]->arg; | |
14592 | if (reject_all_digit_name && all_digit(cl_name)) { | |
14593 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
14594 | return CMD_WARNING_CONFIG_FAILED; | |
14595 | } | |
14596 | ||
14597 | idx = 0; | |
14598 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
14599 | argv_find(argv, argc, "LINE", &idx); | |
14600 | /* Concat community string argument. */ | |
14601 | if (idx) | |
14602 | str = argv_concat(argv, argc, idx); | |
14603 | else | |
14604 | str = NULL; | |
14605 | ||
14606 | ret = lcommunity_list_set(bgp_clist, cl_name, str, direct, style); | |
14607 | ||
14608 | /* Free temporary community list string allocated by | |
14609 | argv_concat(). */ | |
0a22ddfb | 14610 | XFREE(MTYPE_TMP, str); |
d62a17ae | 14611 | |
14612 | if (ret < 0) { | |
14613 | community_list_perror(vty, ret); | |
14614 | return CMD_WARNING_CONFIG_FAILED; | |
14615 | } | |
14616 | return CMD_SUCCESS; | |
14617 | } | |
14618 | ||
14619 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
14620 | struct cmd_token **argv, int style) | |
14621 | { | |
14622 | int ret; | |
14623 | int direct = 0; | |
14624 | char *str = NULL; | |
14625 | int idx = 0; | |
14626 | ||
14627 | argv_find(argv, argc, "permit", &idx); | |
14628 | argv_find(argv, argc, "deny", &idx); | |
14629 | ||
14630 | if (idx) { | |
14631 | /* Check the list direct. */ | |
14632 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
14633 | direct = COMMUNITY_PERMIT; | |
14634 | else | |
14635 | direct = COMMUNITY_DENY; | |
14636 | ||
14637 | idx = 0; | |
14638 | argv_find(argv, argc, "LINE", &idx); | |
14639 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
14640 | /* Concat community string argument. */ | |
14641 | str = argv_concat(argv, argc, idx); | |
14642 | } | |
14643 | ||
14644 | idx = 0; | |
14645 | argv_find(argv, argc, "(1-99)", &idx); | |
14646 | argv_find(argv, argc, "(100-500)", &idx); | |
14647 | argv_find(argv, argc, "WORD", &idx); | |
14648 | ||
14649 | /* Unset community list. */ | |
14650 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, direct, | |
14651 | style); | |
14652 | ||
14653 | /* Free temporary community list string allocated by | |
14654 | argv_concat(). */ | |
0a22ddfb | 14655 | XFREE(MTYPE_TMP, str); |
d62a17ae | 14656 | |
14657 | if (ret < 0) { | |
14658 | community_list_perror(vty, ret); | |
14659 | return CMD_WARNING_CONFIG_FAILED; | |
14660 | } | |
14661 | ||
14662 | return CMD_SUCCESS; | |
57d187bc JS |
14663 | } |
14664 | ||
14665 | /* "large-community-list" keyword help string. */ | |
14666 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
14667 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
14668 | ||
7336e101 SP |
14669 | DEFUN (lcommunity_list_standard, |
14670 | bgp_lcommunity_list_standard_cmd, | |
7336e101 SP |
14671 | "bgp large-community-list (1-99) <deny|permit> AA:BB:CC...", |
14672 | BGP_STR | |
14673 | LCOMMUNITY_LIST_STR | |
14674 | "Large Community list number (standard)\n" | |
14675 | "Specify large community to reject\n" | |
14676 | "Specify large community to accept\n" | |
14677 | LCOMMUNITY_VAL_STR) | |
52951b63 | 14678 | { |
d62a17ae | 14679 | return lcommunity_list_set_vty(vty, argc, argv, |
14680 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
14681 | } |
14682 | ||
7336e101 SP |
14683 | DEFUN (lcommunity_list_expanded, |
14684 | bgp_lcommunity_list_expanded_cmd, | |
14685 | "bgp large-community-list (100-500) <deny|permit> LINE...", | |
14686 | BGP_STR | |
14687 | LCOMMUNITY_LIST_STR | |
14688 | "Large Community list number (expanded)\n" | |
14689 | "Specify large community to reject\n" | |
14690 | "Specify large community to accept\n" | |
14691 | "An ordered list as a regular-expression\n") | |
57d187bc | 14692 | { |
d62a17ae | 14693 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 14694 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
14695 | } |
14696 | ||
7336e101 SP |
14697 | DEFUN (lcommunity_list_name_standard, |
14698 | bgp_lcommunity_list_name_standard_cmd, | |
7336e101 SP |
14699 | "bgp large-community-list standard WORD <deny|permit> AA:BB:CC...", |
14700 | BGP_STR | |
14701 | LCOMMUNITY_LIST_STR | |
14702 | "Specify standard large-community-list\n" | |
14703 | "Large Community list name\n" | |
14704 | "Specify large community to reject\n" | |
14705 | "Specify large community to accept\n" | |
14706 | LCOMMUNITY_VAL_STR) | |
52951b63 | 14707 | { |
d62a17ae | 14708 | return lcommunity_list_set_vty(vty, argc, argv, |
14709 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
14710 | } |
14711 | ||
7336e101 SP |
14712 | DEFUN (lcommunity_list_name_expanded, |
14713 | bgp_lcommunity_list_name_expanded_cmd, | |
14714 | "bgp large-community-list expanded WORD <deny|permit> LINE...", | |
14715 | BGP_STR | |
14716 | LCOMMUNITY_LIST_STR | |
14717 | "Specify expanded large-community-list\n" | |
14718 | "Large Community list name\n" | |
14719 | "Specify large community to reject\n" | |
14720 | "Specify large community to accept\n" | |
14721 | "An ordered list as a regular-expression\n") | |
57d187bc | 14722 | { |
d62a17ae | 14723 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 14724 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
14725 | } |
14726 | ||
7336e101 SP |
14727 | DEFUN (no_lcommunity_list_standard_all, |
14728 | no_bgp_lcommunity_list_standard_all_cmd, | |
14729 | "no bgp large-community-list <(1-99)|(100-500)|WORD>", | |
14730 | NO_STR | |
14731 | BGP_STR | |
14732 | LCOMMUNITY_LIST_STR | |
14733 | "Large Community list number (standard)\n" | |
14734 | "Large Community list number (expanded)\n" | |
14735 | "Large Community list name\n") | |
57d187bc | 14736 | { |
7336e101 SP |
14737 | return lcommunity_list_unset_vty(vty, argc, argv, |
14738 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
14739 | } |
14740 | ||
7336e101 SP |
14741 | DEFUN (no_lcommunity_list_name_expanded_all, |
14742 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
14743 | "no bgp large-community-list expanded WORD", | |
14744 | NO_STR | |
14745 | BGP_STR | |
14746 | LCOMMUNITY_LIST_STR | |
14747 | "Specify expanded large-community-list\n" | |
14748 | "Large Community list name\n") | |
57d187bc | 14749 | { |
d62a17ae | 14750 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14751 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
14752 | } |
14753 | ||
7336e101 SP |
14754 | DEFUN (no_lcommunity_list_standard, |
14755 | no_bgp_lcommunity_list_standard_cmd, | |
14756 | "no bgp large-community-list (1-99) <deny|permit> AA:AA:NN...", | |
14757 | NO_STR | |
14758 | BGP_STR | |
14759 | LCOMMUNITY_LIST_STR | |
14760 | "Large Community list number (standard)\n" | |
14761 | "Specify large community to reject\n" | |
14762 | "Specify large community to accept\n" | |
14763 | LCOMMUNITY_VAL_STR) | |
57d187bc | 14764 | { |
d62a17ae | 14765 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14766 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
14767 | } |
14768 | ||
7336e101 SP |
14769 | DEFUN (no_lcommunity_list_expanded, |
14770 | no_bgp_lcommunity_list_expanded_cmd, | |
14771 | "no bgp large-community-list (100-500) <deny|permit> LINE...", | |
14772 | NO_STR | |
14773 | BGP_STR | |
14774 | LCOMMUNITY_LIST_STR | |
14775 | "Large Community list number (expanded)\n" | |
14776 | "Specify large community to reject\n" | |
14777 | "Specify large community to accept\n" | |
14778 | "An ordered list as a regular-expression\n") | |
57d187bc | 14779 | { |
d62a17ae | 14780 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14781 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
14782 | } |
14783 | ||
7336e101 SP |
14784 | DEFUN (no_lcommunity_list_name_standard, |
14785 | no_bgp_lcommunity_list_name_standard_cmd, | |
14786 | "no bgp large-community-list standard WORD <deny|permit> AA:AA:NN...", | |
14787 | NO_STR | |
14788 | BGP_STR | |
14789 | LCOMMUNITY_LIST_STR | |
14790 | "Specify standard large-community-list\n" | |
14791 | "Large Community list name\n" | |
14792 | "Specify large community to reject\n" | |
14793 | "Specify large community to accept\n" | |
14794 | LCOMMUNITY_VAL_STR) | |
57d187bc | 14795 | { |
d62a17ae | 14796 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14797 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
14798 | } |
14799 | ||
7336e101 SP |
14800 | DEFUN (no_lcommunity_list_name_expanded, |
14801 | no_bgp_lcommunity_list_name_expanded_cmd, | |
14802 | "no bgp large-community-list expanded WORD <deny|permit> LINE...", | |
14803 | NO_STR | |
14804 | BGP_STR | |
14805 | LCOMMUNITY_LIST_STR | |
14806 | "Specify expanded large-community-list\n" | |
14807 | "Large community list name\n" | |
14808 | "Specify large community to reject\n" | |
14809 | "Specify large community to accept\n" | |
14810 | "An ordered list as a regular-expression\n") | |
57d187bc | 14811 | { |
d62a17ae | 14812 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14813 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
14814 | } |
14815 | ||
d62a17ae | 14816 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) |
14817 | { | |
14818 | struct community_entry *entry; | |
14819 | ||
14820 | for (entry = list->head; entry; entry = entry->next) { | |
14821 | if (entry == list->head) { | |
14822 | if (all_digit(list->name)) | |
14823 | vty_out(vty, "Large community %s list %s\n", | |
169b72c8 | 14824 | entry->style == |
14825 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 14826 | ? "standard" |
14827 | : "(expanded) access", | |
14828 | list->name); | |
14829 | else | |
14830 | vty_out(vty, | |
14831 | "Named large community %s list %s\n", | |
169b72c8 | 14832 | entry->style == |
14833 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 14834 | ? "standard" |
14835 | : "expanded", | |
14836 | list->name); | |
14837 | } | |
14838 | if (entry->any) | |
14839 | vty_out(vty, " %s\n", | |
14840 | community_direct_str(entry->direct)); | |
14841 | else | |
14842 | vty_out(vty, " %s %s\n", | |
14843 | community_direct_str(entry->direct), | |
8d9b8ed9 | 14844 | community_list_config_str(entry)); |
d62a17ae | 14845 | } |
57d187bc JS |
14846 | } |
14847 | ||
7336e101 SP |
14848 | DEFUN (show_lcommunity_list, |
14849 | show_bgp_lcommunity_list_cmd, | |
14850 | "show bgp large-community-list", | |
57d187bc | 14851 | SHOW_STR |
7336e101 | 14852 | BGP_STR |
57d187bc JS |
14853 | "List large-community list\n") |
14854 | { | |
d62a17ae | 14855 | struct community_list *list; |
14856 | struct community_list_master *cm; | |
57d187bc | 14857 | |
d62a17ae | 14858 | cm = community_list_master_lookup(bgp_clist, |
14859 | LARGE_COMMUNITY_LIST_MASTER); | |
14860 | if (!cm) | |
14861 | return CMD_SUCCESS; | |
57d187bc | 14862 | |
d62a17ae | 14863 | for (list = cm->num.head; list; list = list->next) |
14864 | lcommunity_list_show(vty, list); | |
57d187bc | 14865 | |
d62a17ae | 14866 | for (list = cm->str.head; list; list = list->next) |
14867 | lcommunity_list_show(vty, list); | |
57d187bc | 14868 | |
d62a17ae | 14869 | return CMD_SUCCESS; |
57d187bc JS |
14870 | } |
14871 | ||
7336e101 SP |
14872 | DEFUN (show_lcommunity_list_arg, |
14873 | show_bgp_lcommunity_list_arg_cmd, | |
960b69b9 | 14874 | "show bgp large-community-list <(1-500)|WORD> detail", |
7336e101 SP |
14875 | SHOW_STR |
14876 | BGP_STR | |
57d187bc | 14877 | "List large-community list\n" |
960b69b9 | 14878 | "Large-community-list number\n" |
14879 | "Large-community-list name\n" | |
14880 | "Detailed information on large-community-list\n") | |
57d187bc | 14881 | { |
d62a17ae | 14882 | struct community_list *list; |
57d187bc | 14883 | |
e237b0d2 | 14884 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, |
d62a17ae | 14885 | LARGE_COMMUNITY_LIST_MASTER); |
14886 | if (!list) { | |
960b69b9 | 14887 | vty_out(vty, "%% Can't find large-community-list\n"); |
d62a17ae | 14888 | return CMD_WARNING; |
14889 | } | |
57d187bc | 14890 | |
d62a17ae | 14891 | lcommunity_list_show(vty, list); |
57d187bc | 14892 | |
d62a17ae | 14893 | return CMD_SUCCESS; |
57d187bc JS |
14894 | } |
14895 | ||
718e3744 | 14896 | /* "extcommunity-list" keyword help string. */ |
14897 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
14898 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
14899 | ||
7336e101 SP |
14900 | DEFUN (extcommunity_list_standard, |
14901 | bgp_extcommunity_list_standard_cmd, | |
14902 | "bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
14903 | BGP_STR | |
718e3744 | 14904 | EXTCOMMUNITY_LIST_STR |
14905 | "Extended Community list number (standard)\n" | |
718e3744 | 14906 | "Specify standard extcommunity-list\n" |
5bf15956 | 14907 | "Community list name\n" |
718e3744 | 14908 | "Specify community to reject\n" |
14909 | "Specify community to accept\n" | |
14910 | EXTCOMMUNITY_VAL_STR) | |
14911 | { | |
d62a17ae | 14912 | int style = EXTCOMMUNITY_LIST_STANDARD; |
14913 | int direct = 0; | |
14914 | char *cl_number_or_name = NULL; | |
42f914d4 | 14915 | |
d62a17ae | 14916 | int idx = 0; |
7b9a4750 | 14917 | |
d62a17ae | 14918 | argv_find(argv, argc, "(1-99)", &idx); |
14919 | argv_find(argv, argc, "WORD", &idx); | |
14920 | cl_number_or_name = argv[idx]->arg; | |
14921 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14922 | : COMMUNITY_DENY; | |
14923 | argv_find(argv, argc, "AA:NN", &idx); | |
14924 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14925 | |
d62a17ae | 14926 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
14927 | direct, style); | |
42f914d4 | 14928 | |
d62a17ae | 14929 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14930 | |
d62a17ae | 14931 | if (ret < 0) { |
14932 | community_list_perror(vty, ret); | |
14933 | return CMD_WARNING_CONFIG_FAILED; | |
14934 | } | |
42f914d4 | 14935 | |
d62a17ae | 14936 | return CMD_SUCCESS; |
718e3744 | 14937 | } |
14938 | ||
7336e101 SP |
14939 | DEFUN (extcommunity_list_name_expanded, |
14940 | bgp_extcommunity_list_name_expanded_cmd, | |
14941 | "bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
14942 | BGP_STR | |
14943 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 14944 | "Extended Community list number (expanded)\n" |
718e3744 | 14945 | "Specify expanded extcommunity-list\n" |
14946 | "Extended Community list name\n" | |
14947 | "Specify community to reject\n" | |
14948 | "Specify community to accept\n" | |
14949 | "An ordered list as a regular-expression\n") | |
14950 | { | |
d62a17ae | 14951 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
14952 | int direct = 0; | |
14953 | char *cl_number_or_name = NULL; | |
d62a17ae | 14954 | int idx = 0; |
7336e101 | 14955 | |
d62a17ae | 14956 | argv_find(argv, argc, "(100-500)", &idx); |
14957 | argv_find(argv, argc, "WORD", &idx); | |
14958 | cl_number_or_name = argv[idx]->arg; | |
14959 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14960 | : COMMUNITY_DENY; | |
14961 | argv_find(argv, argc, "LINE", &idx); | |
14962 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14963 | |
d62a17ae | 14964 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
14965 | direct, style); | |
42f914d4 | 14966 | |
d62a17ae | 14967 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14968 | |
d62a17ae | 14969 | if (ret < 0) { |
14970 | community_list_perror(vty, ret); | |
14971 | return CMD_WARNING_CONFIG_FAILED; | |
14972 | } | |
42f914d4 | 14973 | |
d62a17ae | 14974 | return CMD_SUCCESS; |
718e3744 | 14975 | } |
14976 | ||
7336e101 SP |
14977 | DEFUN (no_extcommunity_list_standard_all, |
14978 | no_bgp_extcommunity_list_standard_all_cmd, | |
14979 | "no bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
14980 | NO_STR | |
14981 | BGP_STR | |
14982 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 14983 | "Extended Community list number (standard)\n" |
718e3744 | 14984 | "Specify standard extcommunity-list\n" |
5bf15956 | 14985 | "Community list name\n" |
718e3744 | 14986 | "Specify community to reject\n" |
14987 | "Specify community to accept\n" | |
14988 | EXTCOMMUNITY_VAL_STR) | |
14989 | { | |
d62a17ae | 14990 | int style = EXTCOMMUNITY_LIST_STANDARD; |
14991 | int direct = 0; | |
14992 | char *cl_number_or_name = NULL; | |
d4455c89 | 14993 | char *str = NULL; |
d62a17ae | 14994 | int idx = 0; |
d4455c89 | 14995 | |
d4455c89 DA |
14996 | argv_find(argv, argc, "permit", &idx); |
14997 | argv_find(argv, argc, "deny", &idx); | |
14998 | ||
14999 | if (idx) { | |
15000 | direct = argv_find(argv, argc, "permit", &idx) | |
15001 | ? COMMUNITY_PERMIT | |
15002 | : COMMUNITY_DENY; | |
15003 | ||
15004 | idx = 0; | |
15005 | argv_find(argv, argc, "AA:NN", &idx); | |
15006 | str = argv_concat(argv, argc, idx); | |
15007 | } | |
15008 | ||
15009 | idx = 0; | |
d62a17ae | 15010 | argv_find(argv, argc, "(1-99)", &idx); |
15011 | argv_find(argv, argc, "WORD", &idx); | |
15012 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 15013 | |
d62a17ae | 15014 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
7298a8e1 | 15015 | direct, style); |
42f914d4 | 15016 | |
d62a17ae | 15017 | XFREE(MTYPE_TMP, str); |
42f914d4 | 15018 | |
d62a17ae | 15019 | if (ret < 0) { |
15020 | community_list_perror(vty, ret); | |
15021 | return CMD_WARNING_CONFIG_FAILED; | |
15022 | } | |
42f914d4 | 15023 | |
d62a17ae | 15024 | return CMD_SUCCESS; |
718e3744 | 15025 | } |
15026 | ||
d4455c89 DA |
15027 | ALIAS(no_extcommunity_list_standard_all, |
15028 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
15029 | "no bgp extcommunity-list <(1-99)|standard WORD>", | |
15030 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
15031 | "Extended Community list number (standard)\n" | |
15032 | "Specify standard extcommunity-list\n" | |
15033 | "Community list name\n") | |
15034 | ||
7336e101 SP |
15035 | DEFUN (no_extcommunity_list_expanded_all, |
15036 | no_bgp_extcommunity_list_expanded_all_cmd, | |
15037 | "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
15038 | NO_STR | |
15039 | BGP_STR | |
15040 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 15041 | "Extended Community list number (expanded)\n" |
718e3744 | 15042 | "Specify expanded extcommunity-list\n" |
5bf15956 | 15043 | "Extended Community list name\n" |
718e3744 | 15044 | "Specify community to reject\n" |
15045 | "Specify community to accept\n" | |
15046 | "An ordered list as a regular-expression\n") | |
15047 | { | |
d62a17ae | 15048 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
15049 | int direct = 0; | |
15050 | char *cl_number_or_name = NULL; | |
d4455c89 | 15051 | char *str = NULL; |
d62a17ae | 15052 | int idx = 0; |
d4455c89 | 15053 | |
d4455c89 DA |
15054 | argv_find(argv, argc, "permit", &idx); |
15055 | argv_find(argv, argc, "deny", &idx); | |
15056 | ||
15057 | if (idx) { | |
15058 | direct = argv_find(argv, argc, "permit", &idx) | |
15059 | ? COMMUNITY_PERMIT | |
15060 | : COMMUNITY_DENY; | |
15061 | ||
15062 | idx = 0; | |
15063 | argv_find(argv, argc, "LINE", &idx); | |
15064 | str = argv_concat(argv, argc, idx); | |
15065 | } | |
15066 | ||
15067 | idx = 0; | |
d62a17ae | 15068 | argv_find(argv, argc, "(100-500)", &idx); |
15069 | argv_find(argv, argc, "WORD", &idx); | |
15070 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 15071 | |
d62a17ae | 15072 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
7298a8e1 | 15073 | direct, style); |
42f914d4 | 15074 | |
d62a17ae | 15075 | XFREE(MTYPE_TMP, str); |
42f914d4 | 15076 | |
d62a17ae | 15077 | if (ret < 0) { |
15078 | community_list_perror(vty, ret); | |
15079 | return CMD_WARNING_CONFIG_FAILED; | |
15080 | } | |
42f914d4 | 15081 | |
d62a17ae | 15082 | return CMD_SUCCESS; |
718e3744 | 15083 | } |
15084 | ||
d4455c89 DA |
15085 | ALIAS(no_extcommunity_list_expanded_all, |
15086 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
15087 | "no bgp extcommunity-list <(100-500)|expanded WORD>", | |
15088 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
15089 | "Extended Community list number (expanded)\n" | |
15090 | "Specify expanded extcommunity-list\n" | |
15091 | "Extended Community list name\n") | |
15092 | ||
d62a17ae | 15093 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 15094 | { |
d62a17ae | 15095 | struct community_entry *entry; |
718e3744 | 15096 | |
d62a17ae | 15097 | for (entry = list->head; entry; entry = entry->next) { |
15098 | if (entry == list->head) { | |
15099 | if (all_digit(list->name)) | |
15100 | vty_out(vty, "Extended community %s list %s\n", | |
15101 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
15102 | ? "standard" | |
15103 | : "(expanded) access", | |
15104 | list->name); | |
15105 | else | |
15106 | vty_out(vty, | |
15107 | "Named extended community %s list %s\n", | |
15108 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
15109 | ? "standard" | |
15110 | : "expanded", | |
15111 | list->name); | |
15112 | } | |
15113 | if (entry->any) | |
15114 | vty_out(vty, " %s\n", | |
15115 | community_direct_str(entry->direct)); | |
15116 | else | |
15117 | vty_out(vty, " %s %s\n", | |
15118 | community_direct_str(entry->direct), | |
8d9b8ed9 | 15119 | community_list_config_str(entry)); |
d62a17ae | 15120 | } |
718e3744 | 15121 | } |
15122 | ||
7336e101 SP |
15123 | DEFUN (show_extcommunity_list, |
15124 | show_bgp_extcommunity_list_cmd, | |
15125 | "show bgp extcommunity-list", | |
718e3744 | 15126 | SHOW_STR |
7336e101 | 15127 | BGP_STR |
718e3744 | 15128 | "List extended-community list\n") |
15129 | { | |
d62a17ae | 15130 | struct community_list *list; |
15131 | struct community_list_master *cm; | |
718e3744 | 15132 | |
d62a17ae | 15133 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
15134 | if (!cm) | |
15135 | return CMD_SUCCESS; | |
718e3744 | 15136 | |
d62a17ae | 15137 | for (list = cm->num.head; list; list = list->next) |
15138 | extcommunity_list_show(vty, list); | |
718e3744 | 15139 | |
d62a17ae | 15140 | for (list = cm->str.head; list; list = list->next) |
15141 | extcommunity_list_show(vty, list); | |
718e3744 | 15142 | |
d62a17ae | 15143 | return CMD_SUCCESS; |
718e3744 | 15144 | } |
15145 | ||
7336e101 SP |
15146 | DEFUN (show_extcommunity_list_arg, |
15147 | show_bgp_extcommunity_list_arg_cmd, | |
960b69b9 | 15148 | "show bgp extcommunity-list <(1-500)|WORD> detail", |
7336e101 SP |
15149 | SHOW_STR |
15150 | BGP_STR | |
718e3744 | 15151 | "List extended-community list\n" |
15152 | "Extcommunity-list number\n" | |
960b69b9 | 15153 | "Extcommunity-list name\n" |
15154 | "Detailed information on extcommunity-list\n") | |
718e3744 | 15155 | { |
d62a17ae | 15156 | int idx_comm_list = 3; |
15157 | struct community_list *list; | |
718e3744 | 15158 | |
e237b0d2 | 15159 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 15160 | EXTCOMMUNITY_LIST_MASTER); |
15161 | if (!list) { | |
15162 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
15163 | return CMD_WARNING; | |
15164 | } | |
718e3744 | 15165 | |
d62a17ae | 15166 | extcommunity_list_show(vty, list); |
718e3744 | 15167 | |
d62a17ae | 15168 | return CMD_SUCCESS; |
718e3744 | 15169 | } |
6b0655a2 | 15170 | |
718e3744 | 15171 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 15172 | static int community_list_config_write(struct vty *vty) |
15173 | { | |
15174 | struct community_list *list; | |
15175 | struct community_entry *entry; | |
15176 | struct community_list_master *cm; | |
15177 | int write = 0; | |
15178 | ||
15179 | /* Community-list. */ | |
15180 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
15181 | ||
15182 | for (list = cm->num.head; list; list = list->next) | |
15183 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15184 | vty_out(vty, "bgp community-list %s %s %s\n", list->name, |
d62a17ae | 15185 | community_direct_str(entry->direct), |
15186 | community_list_config_str(entry)); | |
15187 | write++; | |
15188 | } | |
15189 | for (list = cm->str.head; list; list = list->next) | |
15190 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15191 | vty_out(vty, "bgp community-list %s %s %s %s\n", |
d62a17ae | 15192 | entry->style == COMMUNITY_LIST_STANDARD |
15193 | ? "standard" | |
15194 | : "expanded", | |
15195 | list->name, community_direct_str(entry->direct), | |
15196 | community_list_config_str(entry)); | |
15197 | write++; | |
15198 | } | |
15199 | ||
15200 | /* Extcommunity-list. */ | |
15201 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
15202 | ||
15203 | for (list = cm->num.head; list; list = list->next) | |
15204 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15205 | vty_out(vty, "bgp extcommunity-list %s %s %s\n", |
d62a17ae | 15206 | list->name, community_direct_str(entry->direct), |
15207 | community_list_config_str(entry)); | |
15208 | write++; | |
15209 | } | |
15210 | for (list = cm->str.head; list; list = list->next) | |
15211 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15212 | vty_out(vty, "bgp extcommunity-list %s %s %s %s\n", |
d62a17ae | 15213 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
15214 | ? "standard" | |
15215 | : "expanded", | |
15216 | list->name, community_direct_str(entry->direct), | |
15217 | community_list_config_str(entry)); | |
15218 | write++; | |
15219 | } | |
15220 | ||
15221 | ||
15222 | /* lcommunity-list. */ | |
15223 | cm = community_list_master_lookup(bgp_clist, | |
15224 | LARGE_COMMUNITY_LIST_MASTER); | |
15225 | ||
15226 | for (list = cm->num.head; list; list = list->next) | |
15227 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15228 | vty_out(vty, "bgp large-community-list %s %s %s\n", |
d62a17ae | 15229 | list->name, community_direct_str(entry->direct), |
15230 | community_list_config_str(entry)); | |
15231 | write++; | |
15232 | } | |
15233 | for (list = cm->str.head; list; list = list->next) | |
15234 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15235 | vty_out(vty, "bgp large-community-list %s %s %s %s\n", |
d62a17ae | 15236 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
15237 | ? "standard" | |
15238 | : "expanded", | |
15239 | list->name, community_direct_str(entry->direct), | |
15240 | community_list_config_str(entry)); | |
15241 | write++; | |
15242 | } | |
15243 | ||
15244 | return write; | |
15245 | } | |
15246 | ||
15247 | static struct cmd_node community_list_node = { | |
15248 | COMMUNITY_LIST_NODE, "", 1 /* Export to vtysh. */ | |
718e3744 | 15249 | }; |
15250 | ||
d62a17ae | 15251 | static void community_list_vty(void) |
15252 | { | |
15253 | install_node(&community_list_node, community_list_config_write); | |
15254 | ||
15255 | /* Community-list. */ | |
7336e101 SP |
15256 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
15257 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
15258 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 15259 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 15260 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 15261 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
15262 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
15263 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 15264 | |
15265 | /* Extcommunity-list. */ | |
7336e101 SP |
15266 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
15267 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
15268 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
d4455c89 DA |
15269 | install_element(CONFIG_NODE, |
15270 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
7336e101 | 15271 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); |
d4455c89 DA |
15272 | install_element(CONFIG_NODE, |
15273 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
7336e101 SP |
15274 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); |
15275 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 15276 | |
15277 | /* Large Community List */ | |
7336e101 | 15278 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
7336e101 SP |
15279 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); |
15280 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
7336e101 SP |
15281 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); |
15282 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_all_cmd); | |
15283 | install_element(CONFIG_NODE, | |
15284 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
15285 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
15286 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
15287 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
15288 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
15289 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
15290 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
5bf15956 | 15291 | } |