]>
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"; | |
162 | else { | |
163 | flog_err(EC_LIB_DEVELOPMENT, "New afi/safi that needs to be taken care of?"); | |
164 | return "Unknown"; | |
165 | } | |
166 | } | |
167 | ||
168 | /* | |
169 | * Please note that we have intentionally camelCased | |
170 | * the return strings here. So if you want | |
171 | * to use this function, please ensure you | |
172 | * are doing this within json output | |
173 | */ | |
174 | static const char *get_afi_safi_json_str(afi_t afi, safi_t safi) | |
175 | { | |
176 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
177 | return "ipv4Unicast"; | |
178 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
179 | return "ipv4Multicast"; | |
180 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
181 | return "ipv4LabeledUnicast"; | |
182 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
183 | return "ipv4Vpn"; | |
184 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
185 | return "ipv4Encap"; | |
186 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) | |
187 | return "ipv4Flowspec"; | |
188 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
189 | return "ipv6Unicast"; | |
190 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
191 | return "ipv6Multicast"; | |
192 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
193 | return "ipv6LabeledUnicast"; | |
194 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
195 | return "ipv6Vpn"; | |
196 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
197 | return "ipv6Encap"; | |
198 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) | |
199 | return "ipv6Flowspec"; | |
200 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) | |
201 | return "l2VpnEvpn"; | |
202 | else { | |
203 | flog_err(EC_LIB_DEVELOPMENT, "New afi/safi that needs to be taken care of?"); | |
204 | return "Unknown"; | |
205 | } | |
206 | } | |
207 | ||
718e3744 | 208 | /* Utility function to get address family from current node. */ |
d62a17ae | 209 | afi_t bgp_node_afi(struct vty *vty) |
210 | { | |
211 | afi_t afi; | |
212 | switch (vty->node) { | |
213 | case BGP_IPV6_NODE: | |
214 | case BGP_IPV6M_NODE: | |
215 | case BGP_IPV6L_NODE: | |
216 | case BGP_VPNV6_NODE: | |
7c40bf39 | 217 | case BGP_FLOWSPECV6_NODE: |
d62a17ae | 218 | afi = AFI_IP6; |
219 | break; | |
220 | case BGP_EVPN_NODE: | |
221 | afi = AFI_L2VPN; | |
222 | break; | |
223 | default: | |
224 | afi = AFI_IP; | |
225 | break; | |
226 | } | |
227 | return afi; | |
718e3744 | 228 | } |
229 | ||
230 | /* Utility function to get subsequent address family from current | |
231 | node. */ | |
d62a17ae | 232 | safi_t bgp_node_safi(struct vty *vty) |
233 | { | |
234 | safi_t safi; | |
235 | switch (vty->node) { | |
236 | case BGP_VPNV4_NODE: | |
237 | case BGP_VPNV6_NODE: | |
238 | safi = SAFI_MPLS_VPN; | |
239 | break; | |
240 | case BGP_IPV4M_NODE: | |
241 | case BGP_IPV6M_NODE: | |
242 | safi = SAFI_MULTICAST; | |
243 | break; | |
244 | case BGP_EVPN_NODE: | |
245 | safi = SAFI_EVPN; | |
246 | break; | |
247 | case BGP_IPV4L_NODE: | |
248 | case BGP_IPV6L_NODE: | |
249 | safi = SAFI_LABELED_UNICAST; | |
250 | break; | |
7c40bf39 | 251 | case BGP_FLOWSPECV4_NODE: |
252 | case BGP_FLOWSPECV6_NODE: | |
253 | safi = SAFI_FLOWSPEC; | |
254 | break; | |
d62a17ae | 255 | default: |
256 | safi = SAFI_UNICAST; | |
257 | break; | |
258 | } | |
259 | return safi; | |
718e3744 | 260 | } |
261 | ||
55f91488 QY |
262 | /** |
263 | * Converts an AFI in string form to afi_t | |
264 | * | |
265 | * @param afi string, one of | |
266 | * - "ipv4" | |
267 | * - "ipv6" | |
81cf0de5 | 268 | * - "l2vpn" |
55f91488 QY |
269 | * @return the corresponding afi_t |
270 | */ | |
d62a17ae | 271 | afi_t bgp_vty_afi_from_str(const char *afi_str) |
272 | { | |
273 | afi_t afi = AFI_MAX; /* unknown */ | |
274 | if (strmatch(afi_str, "ipv4")) | |
275 | afi = AFI_IP; | |
276 | else if (strmatch(afi_str, "ipv6")) | |
277 | afi = AFI_IP6; | |
81cf0de5 CS |
278 | else if (strmatch(afi_str, "l2vpn")) |
279 | afi = AFI_L2VPN; | |
d62a17ae | 280 | return afi; |
281 | } | |
282 | ||
283 | int argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, | |
284 | afi_t *afi) | |
285 | { | |
286 | int ret = 0; | |
287 | if (argv_find(argv, argc, "ipv4", index)) { | |
288 | ret = 1; | |
289 | if (afi) | |
290 | *afi = AFI_IP; | |
291 | } else if (argv_find(argv, argc, "ipv6", index)) { | |
292 | ret = 1; | |
293 | if (afi) | |
294 | *afi = AFI_IP6; | |
8688b3e7 DS |
295 | } else if (argv_find(argv, argc, "l2vpn", index)) { |
296 | ret = 1; | |
297 | if (afi) | |
298 | *afi = AFI_L2VPN; | |
d62a17ae | 299 | } |
300 | return ret; | |
46f296b4 LB |
301 | } |
302 | ||
375a2e67 | 303 | /* supports <unicast|multicast|vpn|labeled-unicast> */ |
d62a17ae | 304 | safi_t bgp_vty_safi_from_str(const char *safi_str) |
305 | { | |
306 | safi_t safi = SAFI_MAX; /* unknown */ | |
307 | if (strmatch(safi_str, "multicast")) | |
308 | safi = SAFI_MULTICAST; | |
309 | else if (strmatch(safi_str, "unicast")) | |
310 | safi = SAFI_UNICAST; | |
311 | else if (strmatch(safi_str, "vpn")) | |
312 | safi = SAFI_MPLS_VPN; | |
81cf0de5 CS |
313 | else if (strmatch(safi_str, "evpn")) |
314 | safi = SAFI_EVPN; | |
d62a17ae | 315 | else if (strmatch(safi_str, "labeled-unicast")) |
316 | safi = SAFI_LABELED_UNICAST; | |
7c40bf39 | 317 | else if (strmatch(safi_str, "flowspec")) |
318 | safi = SAFI_FLOWSPEC; | |
d62a17ae | 319 | return safi; |
320 | } | |
321 | ||
322 | int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, | |
323 | safi_t *safi) | |
324 | { | |
325 | int ret = 0; | |
326 | if (argv_find(argv, argc, "unicast", index)) { | |
327 | ret = 1; | |
328 | if (safi) | |
329 | *safi = SAFI_UNICAST; | |
330 | } else if (argv_find(argv, argc, "multicast", index)) { | |
331 | ret = 1; | |
332 | if (safi) | |
333 | *safi = SAFI_MULTICAST; | |
334 | } else if (argv_find(argv, argc, "labeled-unicast", index)) { | |
335 | ret = 1; | |
336 | if (safi) | |
337 | *safi = SAFI_LABELED_UNICAST; | |
338 | } else if (argv_find(argv, argc, "vpn", index)) { | |
339 | ret = 1; | |
340 | if (safi) | |
341 | *safi = SAFI_MPLS_VPN; | |
8688b3e7 DS |
342 | } else if (argv_find(argv, argc, "evpn", index)) { |
343 | ret = 1; | |
344 | if (safi) | |
345 | *safi = SAFI_EVPN; | |
7c40bf39 | 346 | } else if (argv_find(argv, argc, "flowspec", index)) { |
347 | ret = 1; | |
348 | if (safi) | |
349 | *safi = SAFI_FLOWSPEC; | |
d62a17ae | 350 | } |
351 | return ret; | |
46f296b4 LB |
352 | } |
353 | ||
7eeee51e | 354 | /* |
f212a857 | 355 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 356 | * |
f212a857 DS |
357 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
358 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
359 | * to appropriate values for the calling function. This is to allow the |
360 | * calling function to make decisions appropriate for the show command | |
361 | * that is being parsed. | |
362 | * | |
363 | * The show commands are generally of the form: | |
d62a17ae | 364 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> |
365 | * [<unicast|multicast|vpn|labeled-unicast>]] ..." | |
7eeee51e DS |
366 | * |
367 | * Since we use argv_find if the show command in particular doesn't have: | |
368 | * [ip] | |
18c57037 | 369 | * [<view|vrf> VIEWVRFNAME] |
375a2e67 | 370 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] |
7eeee51e DS |
371 | * The command parsing should still be ok. |
372 | * | |
373 | * vty -> The vty for the command so we can output some useful data in | |
374 | * the event of a parse error in the vrf. | |
375 | * argv -> The command tokens | |
376 | * argc -> How many command tokens we have | |
d62a17ae | 377 | * idx -> The current place in the command, generally should be 0 for this |
378 | * function | |
7eeee51e DS |
379 | * afi -> The parsed afi if it was included in the show command, returned here |
380 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 381 | * bgp -> Pointer to the bgp data structure we need to fill in. |
52e5b8c4 | 382 | * use_json -> json is configured or not |
7eeee51e DS |
383 | * |
384 | * The function returns the correct location in the parse tree for the | |
385 | * last token found. | |
0e37c258 DS |
386 | * |
387 | * Returns 0 for failure to parse correctly, else the idx position of where | |
388 | * it found the last token. | |
7eeee51e | 389 | */ |
d62a17ae | 390 | int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, |
391 | struct cmd_token **argv, int argc, | |
392 | int *idx, afi_t *afi, safi_t *safi, | |
9f049418 | 393 | struct bgp **bgp, bool use_json) |
d62a17ae | 394 | { |
395 | char *vrf_name = NULL; | |
396 | ||
397 | assert(afi); | |
398 | assert(safi); | |
399 | assert(bgp); | |
400 | ||
401 | if (argv_find(argv, argc, "ip", idx)) | |
402 | *afi = AFI_IP; | |
403 | ||
9a8bdf1c | 404 | if (argv_find(argv, argc, "view", idx)) |
d62a17ae | 405 | vrf_name = argv[*idx + 1]->arg; |
9a8bdf1c PG |
406 | else if (argv_find(argv, argc, "vrf", idx)) { |
407 | vrf_name = argv[*idx + 1]->arg; | |
408 | if (strmatch(vrf_name, VRF_DEFAULT_NAME)) | |
409 | vrf_name = NULL; | |
410 | } | |
411 | if (vrf_name) { | |
d62a17ae | 412 | if (strmatch(vrf_name, "all")) |
413 | *bgp = NULL; | |
414 | else { | |
415 | *bgp = bgp_lookup_by_name(vrf_name); | |
416 | if (!*bgp) { | |
52e5b8c4 SP |
417 | if (use_json) { |
418 | json_object *json = NULL; | |
419 | json = json_object_new_object(); | |
420 | json_object_string_add( | |
421 | json, "warning", | |
422 | "View/Vrf is unknown"); | |
423 | vty_out(vty, "%s\n", | |
424 | json_object_to_json_string_ext(json, | |
425 | JSON_C_TO_STRING_PRETTY)); | |
426 | json_object_free(json); | |
427 | } | |
ca61fd25 DS |
428 | else |
429 | vty_out(vty, "View/Vrf %s is unknown\n", | |
430 | vrf_name); | |
d62a17ae | 431 | *idx = 0; |
432 | return 0; | |
433 | } | |
434 | } | |
435 | } else { | |
436 | *bgp = bgp_get_default(); | |
437 | if (!*bgp) { | |
52e5b8c4 SP |
438 | if (use_json) { |
439 | json_object *json = NULL; | |
440 | json = json_object_new_object(); | |
441 | json_object_string_add( | |
442 | json, "warning", | |
443 | "Default BGP instance not found"); | |
444 | vty_out(vty, "%s\n", | |
445 | json_object_to_json_string_ext(json, | |
446 | JSON_C_TO_STRING_PRETTY)); | |
447 | json_object_free(json); | |
448 | } | |
ca61fd25 DS |
449 | else |
450 | vty_out(vty, | |
451 | "Default BGP instance not found\n"); | |
d62a17ae | 452 | *idx = 0; |
453 | return 0; | |
454 | } | |
455 | } | |
456 | ||
457 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
458 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
459 | ||
460 | *idx += 1; | |
461 | return *idx; | |
462 | } | |
463 | ||
464 | static int peer_address_self_check(struct bgp *bgp, union sockunion *su) | |
465 | { | |
466 | struct interface *ifp = NULL; | |
467 | ||
468 | if (su->sa.sa_family == AF_INET) | |
469 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); | |
470 | else if (su->sa.sa_family == AF_INET6) | |
471 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, | |
472 | su->sin6.sin6_scope_id, | |
473 | bgp->vrf_id); | |
474 | ||
475 | if (ifp) | |
476 | return 1; | |
477 | ||
478 | return 0; | |
718e3744 | 479 | } |
480 | ||
481 | /* Utility function for looking up peer from VTY. */ | |
f14e6fdb DS |
482 | /* This is used only for configuration, so disallow if attempted on |
483 | * a dynamic neighbor. | |
484 | */ | |
d62a17ae | 485 | static struct peer *peer_lookup_vty(struct vty *vty, const char *ip_str) |
486 | { | |
487 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
488 | int ret; | |
489 | union sockunion su; | |
490 | struct peer *peer; | |
491 | ||
492 | if (!bgp) { | |
493 | return NULL; | |
494 | } | |
495 | ||
496 | ret = str2sockunion(ip_str, &su); | |
497 | if (ret < 0) { | |
498 | peer = peer_lookup_by_conf_if(bgp, ip_str); | |
499 | if (!peer) { | |
500 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) | |
501 | == NULL) { | |
502 | vty_out(vty, | |
503 | "%% Malformed address or name: %s\n", | |
504 | ip_str); | |
505 | return NULL; | |
506 | } | |
507 | } | |
508 | } else { | |
509 | peer = peer_lookup(bgp, &su); | |
510 | if (!peer) { | |
511 | vty_out(vty, | |
512 | "%% Specify remote-as or peer-group commands first\n"); | |
513 | return NULL; | |
514 | } | |
515 | if (peer_dynamic_neighbor(peer)) { | |
516 | vty_out(vty, | |
517 | "%% Operation not allowed on a dynamic neighbor\n"); | |
518 | return NULL; | |
519 | } | |
520 | } | |
521 | return peer; | |
718e3744 | 522 | } |
523 | ||
524 | /* Utility function for looking up peer or peer group. */ | |
f14e6fdb DS |
525 | /* This is used only for configuration, so disallow if attempted on |
526 | * a dynamic neighbor. | |
527 | */ | |
d62a17ae | 528 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) |
529 | { | |
530 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
531 | int ret; | |
532 | union sockunion su; | |
533 | struct peer *peer = NULL; | |
534 | struct peer_group *group = NULL; | |
535 | ||
536 | if (!bgp) { | |
537 | return NULL; | |
538 | } | |
539 | ||
540 | ret = str2sockunion(peer_str, &su); | |
541 | if (ret == 0) { | |
542 | /* IP address, locate peer. */ | |
543 | peer = peer_lookup(bgp, &su); | |
544 | } else { | |
545 | /* Not IP, could match either peer configured on interface or a | |
546 | * group. */ | |
547 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
548 | if (!peer) | |
549 | group = peer_group_lookup(bgp, peer_str); | |
550 | } | |
551 | ||
552 | if (peer) { | |
553 | if (peer_dynamic_neighbor(peer)) { | |
554 | vty_out(vty, | |
555 | "%% Operation not allowed on a dynamic neighbor\n"); | |
556 | return NULL; | |
557 | } | |
558 | ||
559 | return peer; | |
560 | } | |
561 | ||
562 | if (group) | |
563 | return group->conf; | |
564 | ||
565 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); | |
566 | ||
567 | return NULL; | |
568 | } | |
569 | ||
570 | int bgp_vty_return(struct vty *vty, int ret) | |
571 | { | |
572 | const char *str = NULL; | |
573 | ||
574 | switch (ret) { | |
575 | case BGP_ERR_INVALID_VALUE: | |
576 | str = "Invalid value"; | |
577 | break; | |
578 | case BGP_ERR_INVALID_FLAG: | |
579 | str = "Invalid flag"; | |
580 | break; | |
581 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
582 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
583 | break; | |
584 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
585 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
586 | break; | |
587 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
588 | str = "Specify remote-as or peer-group remote AS first"; | |
589 | break; | |
590 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
591 | str = "Cannot change the peer-group. Deconfigure first"; | |
592 | break; | |
593 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
594 | str = "Peer is not a member of this peer-group"; | |
595 | break; | |
596 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
597 | str = "Prefix/distribute list can not co-exist"; | |
598 | break; | |
599 | case BGP_ERR_NOT_INTERNAL_PEER: | |
600 | str = "Invalid command. Not an internal neighbor"; | |
601 | break; | |
602 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
603 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
604 | break; | |
605 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
606 | str = "Local-AS allowed only for EBGP peers"; | |
607 | break; | |
608 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
609 | str = "Cannot have local-as same as BGP AS number"; | |
610 | break; | |
611 | case BGP_ERR_TCPSIG_FAILED: | |
612 | str = "Error while applying TCP-Sig to session(s)"; | |
613 | break; | |
614 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
615 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
616 | break; | |
617 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
618 | str = "ttl-security only allowed for EBGP peers"; | |
619 | break; | |
620 | case BGP_ERR_AS_OVERRIDE: | |
621 | str = "as-override cannot be configured for IBGP peers"; | |
622 | break; | |
623 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
624 | str = "Invalid limit for number of dynamic neighbors"; | |
625 | break; | |
626 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
627 | str = "Dynamic neighbor listen range already exists"; | |
628 | break; | |
629 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
630 | str = "Operation not allowed on a dynamic neighbor"; | |
631 | break; | |
632 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
633 | str = "Operation not allowed on a directly connected neighbor"; | |
634 | break; | |
635 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
636 | str = "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'"; | |
637 | break; | |
638 | } | |
639 | if (str) { | |
640 | vty_out(vty, "%% %s\n", str); | |
641 | return CMD_WARNING_CONFIG_FAILED; | |
642 | } | |
643 | return CMD_SUCCESS; | |
718e3744 | 644 | } |
645 | ||
7aafcaca | 646 | /* BGP clear sort. */ |
d62a17ae | 647 | enum clear_sort { |
648 | clear_all, | |
649 | clear_peer, | |
650 | clear_group, | |
651 | clear_external, | |
652 | clear_as | |
7aafcaca DS |
653 | }; |
654 | ||
d62a17ae | 655 | static void bgp_clear_vty_error(struct vty *vty, struct peer *peer, afi_t afi, |
656 | safi_t safi, int error) | |
657 | { | |
658 | switch (error) { | |
659 | case BGP_ERR_AF_UNCONFIGURED: | |
660 | vty_out(vty, | |
661 | "%%BGP: Enable %s address family for the neighbor %s\n", | |
5cb5f4d0 | 662 | get_afi_safi_str(afi, safi, false), peer->host); |
d62a17ae | 663 | break; |
664 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
665 | vty_out(vty, | |
666 | "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n", | |
667 | peer->host); | |
668 | break; | |
669 | default: | |
670 | break; | |
671 | } | |
7aafcaca DS |
672 | } |
673 | ||
dc912615 DS |
674 | static int bgp_peer_clear(struct peer *peer, afi_t afi, safi_t safi, |
675 | struct listnode *nnode, enum bgp_clear_type stype) | |
676 | { | |
677 | int ret = 0; | |
678 | ||
679 | /* if afi/.safi not specified, spin thru all of them */ | |
680 | if ((afi == AFI_UNSPEC) && (safi == SAFI_UNSPEC)) { | |
681 | afi_t tmp_afi; | |
682 | safi_t tmp_safi; | |
683 | ||
684 | FOREACH_AFI_SAFI (tmp_afi, tmp_safi) { | |
685 | if (!peer->afc[tmp_afi][tmp_safi]) | |
686 | continue; | |
687 | ||
688 | if (stype == BGP_CLEAR_SOFT_NONE) | |
689 | ret = peer_clear(peer, &nnode); | |
690 | else | |
691 | ret = peer_clear_soft(peer, tmp_afi, tmp_safi, | |
692 | stype); | |
693 | } | |
694 | /* if afi specified and safi not, spin thru safis on this afi */ | |
695 | } else if (safi == SAFI_UNSPEC) { | |
696 | safi_t tmp_safi; | |
697 | ||
698 | for (tmp_safi = SAFI_UNICAST; | |
699 | tmp_safi < SAFI_MAX; tmp_safi++) { | |
700 | if (!peer->afc[afi][tmp_safi]) | |
701 | continue; | |
702 | ||
703 | if (stype == BGP_CLEAR_SOFT_NONE) | |
704 | ret = peer_clear(peer, &nnode); | |
705 | else | |
706 | ret = peer_clear_soft(peer, afi, | |
707 | tmp_safi, stype); | |
708 | } | |
709 | /* both afi/safi specified, let the caller know if not defined */ | |
710 | } else { | |
711 | if (!peer->afc[afi][safi]) | |
712 | return 1; | |
713 | ||
714 | if (stype == BGP_CLEAR_SOFT_NONE) | |
715 | ret = peer_clear(peer, &nnode); | |
716 | else | |
717 | ret = peer_clear_soft(peer, afi, safi, stype); | |
718 | } | |
719 | ||
720 | return ret; | |
721 | } | |
722 | ||
7aafcaca | 723 | /* `clear ip bgp' functions. */ |
d62a17ae | 724 | static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
725 | enum clear_sort sort, enum bgp_clear_type stype, | |
726 | const char *arg) | |
727 | { | |
dc912615 | 728 | int ret = 0; |
3ae8bfa5 | 729 | bool found = false; |
d62a17ae | 730 | struct peer *peer; |
731 | struct listnode *node, *nnode; | |
732 | ||
733 | /* Clear all neighbors. */ | |
734 | /* | |
735 | * Pass along pointer to next node to peer_clear() when walking all | |
3ae8bfa5 PM |
736 | * nodes on the BGP instance as that may get freed if it is a |
737 | * doppelganger | |
d62a17ae | 738 | */ |
739 | if (sort == clear_all) { | |
740 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
dc912615 DS |
741 | ret = bgp_peer_clear(peer, afi, safi, nnode, |
742 | stype); | |
d62a17ae | 743 | |
744 | if (ret < 0) | |
745 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
04b6bdc0 | 746 | } |
d62a17ae | 747 | |
748 | /* This is to apply read-only mode on this clear. */ | |
749 | if (stype == BGP_CLEAR_SOFT_NONE) | |
750 | bgp->update_delay_over = 0; | |
751 | ||
752 | return CMD_SUCCESS; | |
7aafcaca DS |
753 | } |
754 | ||
3ae8bfa5 | 755 | /* Clear specified neighbor. */ |
d62a17ae | 756 | if (sort == clear_peer) { |
757 | union sockunion su; | |
d62a17ae | 758 | |
759 | /* Make sockunion for lookup. */ | |
760 | ret = str2sockunion(arg, &su); | |
761 | if (ret < 0) { | |
762 | peer = peer_lookup_by_conf_if(bgp, arg); | |
763 | if (!peer) { | |
764 | peer = peer_lookup_by_hostname(bgp, arg); | |
765 | if (!peer) { | |
766 | vty_out(vty, | |
767 | "Malformed address or name: %s\n", | |
768 | arg); | |
769 | return CMD_WARNING; | |
770 | } | |
771 | } | |
772 | } else { | |
773 | peer = peer_lookup(bgp, &su); | |
774 | if (!peer) { | |
775 | vty_out(vty, | |
776 | "%%BGP: Unknown neighbor - \"%s\"\n", | |
777 | arg); | |
778 | return CMD_WARNING; | |
779 | } | |
780 | } | |
7aafcaca | 781 | |
dc912615 DS |
782 | ret = bgp_peer_clear(peer, afi, safi, NULL, stype); |
783 | ||
784 | /* if afi/safi not defined for this peer, let caller know */ | |
785 | if (ret == 1) | |
3ae8bfa5 | 786 | ret = BGP_ERR_AF_UNCONFIGURED; |
7aafcaca | 787 | |
d62a17ae | 788 | if (ret < 0) |
789 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
7aafcaca | 790 | |
d62a17ae | 791 | return CMD_SUCCESS; |
7aafcaca | 792 | } |
7aafcaca | 793 | |
3ae8bfa5 | 794 | /* Clear all neighbors belonging to a specific peer-group. */ |
d62a17ae | 795 | if (sort == clear_group) { |
796 | struct peer_group *group; | |
7aafcaca | 797 | |
d62a17ae | 798 | group = peer_group_lookup(bgp, arg); |
799 | if (!group) { | |
800 | vty_out(vty, "%%BGP: No such peer-group %s\n", arg); | |
801 | return CMD_WARNING; | |
802 | } | |
803 | ||
804 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
dc912615 | 805 | ret = bgp_peer_clear(peer, afi, safi, nnode, stype); |
7aafcaca | 806 | |
d62a17ae | 807 | if (ret < 0) |
808 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
809 | else |
810 | found = true; | |
d62a17ae | 811 | } |
3ae8bfa5 PM |
812 | |
813 | if (!found) | |
814 | vty_out(vty, | |
815 | "%%BGP: No %s peer belonging to peer-group %s is configured\n", | |
5cb5f4d0 | 816 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 817 | |
d62a17ae | 818 | return CMD_SUCCESS; |
7aafcaca | 819 | } |
7aafcaca | 820 | |
3ae8bfa5 | 821 | /* Clear all external (eBGP) neighbors. */ |
d62a17ae | 822 | if (sort == clear_external) { |
823 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
824 | if (peer->sort == BGP_PEER_IBGP) | |
825 | continue; | |
7aafcaca | 826 | |
dc912615 | 827 | ret = bgp_peer_clear(peer, afi, safi, nnode, stype); |
7aafcaca | 828 | |
d62a17ae | 829 | if (ret < 0) |
830 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
831 | else |
832 | found = true; | |
d62a17ae | 833 | } |
3ae8bfa5 PM |
834 | |
835 | if (!found) | |
836 | vty_out(vty, | |
837 | "%%BGP: No external %s peer is configured\n", | |
5cb5f4d0 | 838 | get_afi_safi_str(afi, safi, false)); |
3ae8bfa5 | 839 | |
d62a17ae | 840 | return CMD_SUCCESS; |
841 | } | |
842 | ||
3ae8bfa5 | 843 | /* Clear all neighbors belonging to a specific AS. */ |
d62a17ae | 844 | if (sort == clear_as) { |
3ae8bfa5 | 845 | as_t as = strtoul(arg, NULL, 10); |
d62a17ae | 846 | |
847 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
848 | if (peer->as != as) | |
849 | continue; | |
850 | ||
dc912615 | 851 | ret = bgp_peer_clear(peer, afi, safi, nnode, stype); |
d62a17ae | 852 | |
853 | if (ret < 0) | |
854 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
855 | else |
856 | found = true; | |
d62a17ae | 857 | } |
3ae8bfa5 PM |
858 | |
859 | if (!found) | |
d62a17ae | 860 | vty_out(vty, |
3ae8bfa5 | 861 | "%%BGP: No %s peer is configured with AS %s\n", |
5cb5f4d0 | 862 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 863 | |
d62a17ae | 864 | return CMD_SUCCESS; |
865 | } | |
866 | ||
867 | return CMD_SUCCESS; | |
868 | } | |
869 | ||
870 | static int bgp_clear_vty(struct vty *vty, const char *name, afi_t afi, | |
871 | safi_t safi, enum clear_sort sort, | |
872 | enum bgp_clear_type stype, const char *arg) | |
873 | { | |
874 | struct bgp *bgp; | |
875 | ||
876 | /* BGP structure lookup. */ | |
877 | if (name) { | |
878 | bgp = bgp_lookup_by_name(name); | |
879 | if (bgp == NULL) { | |
880 | vty_out(vty, "Can't find BGP instance %s\n", name); | |
881 | return CMD_WARNING; | |
882 | } | |
883 | } else { | |
884 | bgp = bgp_get_default(); | |
885 | if (bgp == NULL) { | |
886 | vty_out(vty, "No BGP process is configured\n"); | |
887 | return CMD_WARNING; | |
888 | } | |
889 | } | |
890 | ||
891 | return bgp_clear(vty, bgp, afi, safi, sort, stype, arg); | |
7aafcaca DS |
892 | } |
893 | ||
894 | /* clear soft inbound */ | |
d62a17ae | 895 | static void bgp_clear_star_soft_in(struct vty *vty, const char *name) |
7aafcaca | 896 | { |
99b3ebd3 NS |
897 | afi_t afi; |
898 | safi_t safi; | |
899 | ||
900 | FOREACH_AFI_SAFI (afi, safi) | |
901 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
902 | BGP_CLEAR_SOFT_IN, NULL); | |
7aafcaca DS |
903 | } |
904 | ||
905 | /* clear soft outbound */ | |
d62a17ae | 906 | static void bgp_clear_star_soft_out(struct vty *vty, const char *name) |
7aafcaca | 907 | { |
99b3ebd3 NS |
908 | afi_t afi; |
909 | safi_t safi; | |
910 | ||
911 | FOREACH_AFI_SAFI (afi, safi) | |
912 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
913 | BGP_CLEAR_SOFT_OUT, NULL); | |
7aafcaca DS |
914 | } |
915 | ||
916 | ||
f787d7a0 | 917 | #ifndef VTYSH_EXTRACT_PL |
2e4c2296 | 918 | #include "bgpd/bgp_vty_clippy.c" |
f787d7a0 DL |
919 | #endif |
920 | ||
8029b216 AK |
921 | DEFUN_HIDDEN (bgp_local_mac, |
922 | bgp_local_mac_cmd, | |
093e3f23 | 923 | "bgp local-mac vni " CMD_VNI_RANGE " mac WORD seq (0-4294967295)", |
8029b216 AK |
924 | BGP_STR |
925 | "Local MAC config\n" | |
926 | "VxLAN Network Identifier\n" | |
927 | "VNI number\n" | |
928 | "local mac\n" | |
929 | "mac address\n" | |
930 | "mac-mobility sequence\n" | |
931 | "seq number\n") | |
932 | { | |
933 | int rv; | |
934 | vni_t vni; | |
935 | struct ethaddr mac; | |
936 | struct ipaddr ip; | |
937 | uint32_t seq; | |
938 | struct bgp *bgp; | |
939 | ||
940 | vni = strtoul(argv[3]->arg, NULL, 10); | |
941 | if (!prefix_str2mac(argv[5]->arg, &mac)) { | |
942 | vty_out(vty, "%% Malformed MAC address\n"); | |
943 | return CMD_WARNING; | |
944 | } | |
945 | memset(&ip, 0, sizeof(ip)); | |
946 | seq = strtoul(argv[7]->arg, NULL, 10); | |
947 | ||
948 | bgp = bgp_get_default(); | |
949 | if (!bgp) { | |
950 | vty_out(vty, "Default BGP instance is not there\n"); | |
951 | return CMD_WARNING; | |
952 | } | |
953 | ||
954 | rv = bgp_evpn_local_macip_add(bgp, vni, &mac, &ip, 0 /* flags */, seq); | |
955 | if (rv < 0) { | |
956 | vty_out(vty, "Internal error\n"); | |
957 | return CMD_WARNING; | |
958 | } | |
959 | ||
960 | return CMD_SUCCESS; | |
961 | } | |
962 | ||
963 | DEFUN_HIDDEN (no_bgp_local_mac, | |
964 | no_bgp_local_mac_cmd, | |
093e3f23 | 965 | "no bgp local-mac vni " CMD_VNI_RANGE " mac WORD", |
8029b216 AK |
966 | NO_STR |
967 | BGP_STR | |
968 | "Local MAC config\n" | |
969 | "VxLAN Network Identifier\n" | |
970 | "VNI number\n" | |
971 | "local mac\n" | |
972 | "mac address\n") | |
973 | { | |
974 | int rv; | |
975 | vni_t vni; | |
976 | struct ethaddr mac; | |
977 | struct ipaddr ip; | |
978 | struct bgp *bgp; | |
979 | ||
980 | vni = strtoul(argv[4]->arg, NULL, 10); | |
981 | if (!prefix_str2mac(argv[6]->arg, &mac)) { | |
982 | vty_out(vty, "%% Malformed MAC address\n"); | |
983 | return CMD_WARNING; | |
984 | } | |
985 | memset(&ip, 0, sizeof(ip)); | |
986 | ||
987 | bgp = bgp_get_default(); | |
988 | if (!bgp) { | |
989 | vty_out(vty, "Default BGP instance is not there\n"); | |
990 | return CMD_WARNING; | |
991 | } | |
992 | ||
ec0ab544 | 993 | rv = bgp_evpn_local_macip_del(bgp, vni, &mac, &ip, ZEBRA_NEIGH_ACTIVE); |
8029b216 AK |
994 | if (rv < 0) { |
995 | vty_out(vty, "Internal error\n"); | |
996 | return CMD_WARNING; | |
997 | } | |
998 | ||
999 | return CMD_SUCCESS; | |
1000 | } | |
1001 | ||
718e3744 | 1002 | DEFUN (no_synchronization, |
1003 | no_synchronization_cmd, | |
1004 | "no synchronization", | |
1005 | NO_STR | |
1006 | "Perform IGP synchronization\n") | |
1007 | { | |
d62a17ae | 1008 | return CMD_SUCCESS; |
718e3744 | 1009 | } |
1010 | ||
1011 | DEFUN (no_auto_summary, | |
1012 | no_auto_summary_cmd, | |
1013 | "no auto-summary", | |
1014 | NO_STR | |
1015 | "Enable automatic network number summarization\n") | |
1016 | { | |
d62a17ae | 1017 | return CMD_SUCCESS; |
718e3744 | 1018 | } |
3d515fd9 | 1019 | |
718e3744 | 1020 | /* "router bgp" commands. */ |
505e5056 | 1021 | DEFUN_NOSH (router_bgp, |
f412b39a | 1022 | router_bgp_cmd, |
2ed9fe4a | 1023 | "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 1024 | ROUTER_STR |
1025 | BGP_STR | |
31500417 DW |
1026 | AS_STR |
1027 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1028 | { |
d62a17ae | 1029 | int idx_asn = 2; |
1030 | int idx_view_vrf = 3; | |
1031 | int idx_vrf = 4; | |
ecec9495 | 1032 | int is_new_bgp = 0; |
d62a17ae | 1033 | int ret; |
1034 | as_t as; | |
1035 | struct bgp *bgp; | |
1036 | const char *name = NULL; | |
1037 | enum bgp_instance_type inst_type; | |
1038 | ||
1039 | // "router bgp" without an ASN | |
1040 | if (argc == 2) { | |
1041 | // Pending: Make VRF option available for ASN less config | |
1042 | bgp = bgp_get_default(); | |
1043 | ||
1044 | if (bgp == NULL) { | |
1045 | vty_out(vty, "%% No BGP process is configured\n"); | |
1046 | return CMD_WARNING_CONFIG_FAILED; | |
1047 | } | |
1048 | ||
1049 | if (listcount(bm->bgp) > 1) { | |
996c9314 | 1050 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1051 | return CMD_WARNING_CONFIG_FAILED; |
1052 | } | |
1053 | } | |
1054 | ||
1055 | // "router bgp X" | |
1056 | else { | |
1057 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
1058 | ||
1059 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; | |
1060 | if (argc > 3) { | |
1061 | name = argv[idx_vrf]->arg; | |
1062 | ||
9a8bdf1c PG |
1063 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) { |
1064 | if (strmatch(name, VRF_DEFAULT_NAME)) | |
1065 | name = NULL; | |
1066 | else | |
1067 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
1068 | } else if (!strcmp(argv[idx_view_vrf]->text, "view")) | |
d62a17ae | 1069 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
1070 | } | |
1071 | ||
ecec9495 AD |
1072 | if (inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
1073 | is_new_bgp = (bgp_lookup(as, name) == NULL); | |
1074 | ||
d62a17ae | 1075 | ret = bgp_get(&bgp, &as, name, inst_type); |
1076 | switch (ret) { | |
d62a17ae | 1077 | case BGP_ERR_AS_MISMATCH: |
1078 | vty_out(vty, "BGP is already running; AS is %u\n", as); | |
1079 | return CMD_WARNING_CONFIG_FAILED; | |
1080 | case BGP_ERR_INSTANCE_MISMATCH: | |
1081 | vty_out(vty, | |
1082 | "BGP instance name and AS number mismatch\n"); | |
1083 | vty_out(vty, | |
1084 | "BGP instance is already running; AS is %u\n", | |
1085 | as); | |
1086 | return CMD_WARNING_CONFIG_FAILED; | |
1087 | } | |
1088 | ||
3bd70bf8 PZ |
1089 | /* |
1090 | * If we just instantiated the default instance, complete | |
1091 | * any pending VRF-VPN leaking that was configured via | |
1092 | * earlier "router bgp X vrf FOO" blocks. | |
1093 | */ | |
ecec9495 | 1094 | if (is_new_bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
3bd70bf8 PZ |
1095 | vpn_leak_postchange_all(); |
1096 | ||
48381346 CS |
1097 | if (inst_type == BGP_INSTANCE_TYPE_VRF) |
1098 | bgp_vpn_leak_export(bgp); | |
d62a17ae | 1099 | /* Pending: handle when user tries to change a view to vrf n vv. |
1100 | */ | |
1101 | } | |
1102 | ||
0b5131c9 MK |
1103 | /* unset the auto created flag as the user config is now present */ |
1104 | UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO); | |
d62a17ae | 1105 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); |
1106 | ||
1107 | return CMD_SUCCESS; | |
718e3744 | 1108 | } |
1109 | ||
718e3744 | 1110 | /* "no router bgp" commands. */ |
1111 | DEFUN (no_router_bgp, | |
1112 | no_router_bgp_cmd, | |
2ed9fe4a | 1113 | "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 1114 | NO_STR |
1115 | ROUTER_STR | |
1116 | BGP_STR | |
31500417 DW |
1117 | AS_STR |
1118 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1119 | { |
d62a17ae | 1120 | int idx_asn = 3; |
1121 | int idx_vrf = 5; | |
1122 | as_t as; | |
1123 | struct bgp *bgp; | |
1124 | const char *name = NULL; | |
718e3744 | 1125 | |
d62a17ae | 1126 | // "no router bgp" without an ASN |
1127 | if (argc == 3) { | |
1128 | // Pending: Make VRF option available for ASN less config | |
1129 | bgp = bgp_get_default(); | |
718e3744 | 1130 | |
d62a17ae | 1131 | if (bgp == NULL) { |
1132 | vty_out(vty, "%% No BGP process is configured\n"); | |
1133 | return CMD_WARNING_CONFIG_FAILED; | |
1134 | } | |
7fb21a9f | 1135 | |
d62a17ae | 1136 | if (listcount(bm->bgp) > 1) { |
996c9314 | 1137 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1138 | return CMD_WARNING_CONFIG_FAILED; |
1139 | } | |
0b5131c9 MK |
1140 | |
1141 | if (bgp->l3vni) { | |
1142 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
1143 | bgp->l3vni); | |
1144 | return CMD_WARNING_CONFIG_FAILED; | |
1145 | } | |
d62a17ae | 1146 | } else { |
1147 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
7fb21a9f | 1148 | |
d62a17ae | 1149 | if (argc > 4) |
1150 | name = argv[idx_vrf]->arg; | |
7fb21a9f | 1151 | |
d62a17ae | 1152 | /* Lookup bgp structure. */ |
1153 | bgp = bgp_lookup(as, name); | |
1154 | if (!bgp) { | |
1155 | vty_out(vty, "%% Can't find BGP instance\n"); | |
1156 | return CMD_WARNING_CONFIG_FAILED; | |
1157 | } | |
0b5131c9 MK |
1158 | |
1159 | if (bgp->l3vni) { | |
dd5868c2 | 1160 | vty_out(vty, "%% Please unconfigure l3vni %u\n", |
0b5131c9 MK |
1161 | bgp->l3vni); |
1162 | return CMD_WARNING_CONFIG_FAILED; | |
1163 | } | |
dd5868c2 DS |
1164 | |
1165 | /* Cannot delete default instance if vrf instances exist */ | |
1166 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
1167 | struct listnode *node; | |
1168 | struct bgp *tmp_bgp; | |
1169 | ||
1170 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, tmp_bgp)) { | |
1171 | if (tmp_bgp->inst_type | |
1172 | == BGP_INSTANCE_TYPE_VRF) { | |
1173 | vty_out(vty, | |
1174 | "%% Cannot delete default BGP instance. Dependent VRF instances exist\n"); | |
1175 | return CMD_WARNING_CONFIG_FAILED; | |
1176 | } | |
1177 | } | |
1178 | } | |
d62a17ae | 1179 | } |
718e3744 | 1180 | |
9ecf931b CS |
1181 | if (bgp_vpn_leak_unimport(bgp, vty)) |
1182 | return CMD_WARNING_CONFIG_FAILED; | |
1183 | ||
d62a17ae | 1184 | bgp_delete(bgp); |
718e3744 | 1185 | |
d62a17ae | 1186 | return CMD_SUCCESS; |
718e3744 | 1187 | } |
1188 | ||
6b0655a2 | 1189 | |
718e3744 | 1190 | /* BGP router-id. */ |
1191 | ||
f787d7a0 | 1192 | DEFPY (bgp_router_id, |
718e3744 | 1193 | bgp_router_id_cmd, |
1194 | "bgp router-id A.B.C.D", | |
1195 | BGP_STR | |
1196 | "Override configured router identifier\n" | |
1197 | "Manually configured router identifier\n") | |
1198 | { | |
d62a17ae | 1199 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1200 | bgp_router_id_static_set(bgp, router_id); | |
1201 | return CMD_SUCCESS; | |
718e3744 | 1202 | } |
1203 | ||
f787d7a0 | 1204 | DEFPY (no_bgp_router_id, |
718e3744 | 1205 | no_bgp_router_id_cmd, |
31500417 | 1206 | "no bgp router-id [A.B.C.D]", |
718e3744 | 1207 | NO_STR |
1208 | BGP_STR | |
31500417 DW |
1209 | "Override configured router identifier\n" |
1210 | "Manually configured router identifier\n") | |
718e3744 | 1211 | { |
d62a17ae | 1212 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1213 | |
d62a17ae | 1214 | if (router_id_str) { |
1215 | if (!IPV4_ADDR_SAME(&bgp->router_id_static, &router_id)) { | |
1216 | vty_out(vty, "%% BGP router-id doesn't match\n"); | |
1217 | return CMD_WARNING_CONFIG_FAILED; | |
1218 | } | |
e018c7cc | 1219 | } |
718e3744 | 1220 | |
d62a17ae | 1221 | router_id.s_addr = 0; |
1222 | bgp_router_id_static_set(bgp, router_id); | |
718e3744 | 1223 | |
d62a17ae | 1224 | return CMD_SUCCESS; |
718e3744 | 1225 | } |
1226 | ||
6b0655a2 | 1227 | |
718e3744 | 1228 | /* BGP Cluster ID. */ |
718e3744 | 1229 | DEFUN (bgp_cluster_id, |
1230 | bgp_cluster_id_cmd, | |
838758ac | 1231 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", |
718e3744 | 1232 | BGP_STR |
1233 | "Configure Route-Reflector Cluster-id\n" | |
838758ac DW |
1234 | "Route-Reflector Cluster-id in IP address format\n" |
1235 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1236 | { |
d62a17ae | 1237 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1238 | int idx_ipv4 = 2; | |
1239 | int ret; | |
1240 | struct in_addr cluster; | |
718e3744 | 1241 | |
d62a17ae | 1242 | ret = inet_aton(argv[idx_ipv4]->arg, &cluster); |
1243 | if (!ret) { | |
1244 | vty_out(vty, "%% Malformed bgp cluster identifier\n"); | |
1245 | return CMD_WARNING_CONFIG_FAILED; | |
1246 | } | |
718e3744 | 1247 | |
d62a17ae | 1248 | bgp_cluster_id_set(bgp, &cluster); |
1249 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1250 | |
d62a17ae | 1251 | return CMD_SUCCESS; |
718e3744 | 1252 | } |
1253 | ||
718e3744 | 1254 | DEFUN (no_bgp_cluster_id, |
1255 | no_bgp_cluster_id_cmd, | |
c7178fe7 | 1256 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", |
718e3744 | 1257 | NO_STR |
1258 | BGP_STR | |
838758ac DW |
1259 | "Configure Route-Reflector Cluster-id\n" |
1260 | "Route-Reflector Cluster-id in IP address format\n" | |
1261 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1262 | { |
d62a17ae | 1263 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1264 | bgp_cluster_id_unset(bgp); | |
1265 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1266 | |
d62a17ae | 1267 | return CMD_SUCCESS; |
718e3744 | 1268 | } |
1269 | ||
718e3744 | 1270 | DEFUN (bgp_confederation_identifier, |
1271 | bgp_confederation_identifier_cmd, | |
9ccf14f7 | 1272 | "bgp confederation identifier (1-4294967295)", |
718e3744 | 1273 | "BGP specific commands\n" |
1274 | "AS confederation parameters\n" | |
1275 | "AS number\n" | |
1276 | "Set routing domain confederation AS\n") | |
1277 | { | |
d62a17ae | 1278 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1279 | int idx_number = 3; | |
1280 | as_t as; | |
718e3744 | 1281 | |
d62a17ae | 1282 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 1283 | |
d62a17ae | 1284 | bgp_confederation_id_set(bgp, as); |
718e3744 | 1285 | |
d62a17ae | 1286 | return CMD_SUCCESS; |
718e3744 | 1287 | } |
1288 | ||
1289 | DEFUN (no_bgp_confederation_identifier, | |
1290 | no_bgp_confederation_identifier_cmd, | |
838758ac | 1291 | "no bgp confederation identifier [(1-4294967295)]", |
718e3744 | 1292 | NO_STR |
1293 | "BGP specific commands\n" | |
1294 | "AS confederation parameters\n" | |
3a2d747c QY |
1295 | "AS number\n" |
1296 | "Set routing domain confederation AS\n") | |
718e3744 | 1297 | { |
d62a17ae | 1298 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1299 | bgp_confederation_id_unset(bgp); | |
718e3744 | 1300 | |
d62a17ae | 1301 | return CMD_SUCCESS; |
718e3744 | 1302 | } |
1303 | ||
718e3744 | 1304 | DEFUN (bgp_confederation_peers, |
1305 | bgp_confederation_peers_cmd, | |
12dcf78e | 1306 | "bgp confederation peers (1-4294967295)...", |
718e3744 | 1307 | "BGP specific commands\n" |
1308 | "AS confederation parameters\n" | |
1309 | "Peer ASs in BGP confederation\n" | |
1310 | AS_STR) | |
1311 | { | |
d62a17ae | 1312 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1313 | int idx_asn = 3; | |
1314 | as_t as; | |
1315 | int i; | |
718e3744 | 1316 | |
d62a17ae | 1317 | for (i = idx_asn; i < argc; i++) { |
1318 | as = strtoul(argv[i]->arg, NULL, 10); | |
718e3744 | 1319 | |
d62a17ae | 1320 | if (bgp->as == as) { |
1321 | vty_out(vty, | |
1322 | "%% Local member-AS not allowed in confed peer list\n"); | |
1323 | continue; | |
1324 | } | |
718e3744 | 1325 | |
d62a17ae | 1326 | bgp_confederation_peers_add(bgp, as); |
1327 | } | |
1328 | return CMD_SUCCESS; | |
718e3744 | 1329 | } |
1330 | ||
1331 | DEFUN (no_bgp_confederation_peers, | |
1332 | no_bgp_confederation_peers_cmd, | |
e83a9414 | 1333 | "no bgp confederation peers (1-4294967295)...", |
718e3744 | 1334 | NO_STR |
1335 | "BGP specific commands\n" | |
1336 | "AS confederation parameters\n" | |
1337 | "Peer ASs in BGP confederation\n" | |
1338 | AS_STR) | |
1339 | { | |
d62a17ae | 1340 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1341 | int idx_asn = 4; | |
1342 | as_t as; | |
1343 | int i; | |
718e3744 | 1344 | |
d62a17ae | 1345 | for (i = idx_asn; i < argc; i++) { |
1346 | as = strtoul(argv[i]->arg, NULL, 10); | |
0b2aa3a0 | 1347 | |
d62a17ae | 1348 | bgp_confederation_peers_remove(bgp, as); |
1349 | } | |
1350 | return CMD_SUCCESS; | |
718e3744 | 1351 | } |
6b0655a2 | 1352 | |
5e242b0d DS |
1353 | /** |
1354 | * Central routine for maximum-paths configuration. | |
1355 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1356 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1357 | */ | |
d62a17ae | 1358 | static int bgp_maxpaths_config_vty(struct vty *vty, int peer_type, |
d7c0a89a | 1359 | const char *mpaths, uint16_t options, |
d62a17ae | 1360 | int set) |
1361 | { | |
1362 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
d7c0a89a | 1363 | uint16_t maxpaths = 0; |
d62a17ae | 1364 | int ret; |
1365 | afi_t afi; | |
1366 | safi_t safi; | |
1367 | ||
1368 | afi = bgp_node_afi(vty); | |
1369 | safi = bgp_node_safi(vty); | |
1370 | ||
1371 | if (set) { | |
1372 | maxpaths = strtol(mpaths, NULL, 10); | |
1373 | if (maxpaths > multipath_num) { | |
1374 | vty_out(vty, | |
1375 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", | |
1376 | maxpaths, multipath_num); | |
1377 | return CMD_WARNING_CONFIG_FAILED; | |
1378 | } | |
1379 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1380 | options); | |
1381 | } else | |
1382 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1383 | ||
1384 | if (ret < 0) { | |
1385 | vty_out(vty, | |
1386 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", | |
1387 | (set == 1) ? "" : "un", | |
1388 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1389 | maxpaths, afi, safi); | |
1390 | return CMD_WARNING_CONFIG_FAILED; | |
1391 | } | |
1392 | ||
1393 | bgp_recalculate_all_bestpaths(bgp); | |
1394 | ||
1395 | return CMD_SUCCESS; | |
165b5fff JB |
1396 | } |
1397 | ||
abc920f8 DS |
1398 | DEFUN (bgp_maxmed_admin, |
1399 | bgp_maxmed_admin_cmd, | |
1400 | "bgp max-med administrative ", | |
1401 | BGP_STR | |
1402 | "Advertise routes with max-med\n" | |
1403 | "Administratively applied, for an indefinite period\n") | |
1404 | { | |
d62a17ae | 1405 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1406 | |
d62a17ae | 1407 | bgp->v_maxmed_admin = 1; |
1408 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1409 | |
d62a17ae | 1410 | bgp_maxmed_update(bgp); |
abc920f8 | 1411 | |
d62a17ae | 1412 | return CMD_SUCCESS; |
abc920f8 DS |
1413 | } |
1414 | ||
1415 | DEFUN (bgp_maxmed_admin_medv, | |
1416 | bgp_maxmed_admin_medv_cmd, | |
4668a151 | 1417 | "bgp max-med administrative (0-4294967295)", |
abc920f8 DS |
1418 | BGP_STR |
1419 | "Advertise routes with max-med\n" | |
1420 | "Administratively applied, for an indefinite period\n" | |
1421 | "Max MED value to be used\n") | |
1422 | { | |
d62a17ae | 1423 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1424 | int idx_number = 3; | |
abc920f8 | 1425 | |
d62a17ae | 1426 | bgp->v_maxmed_admin = 1; |
1427 | bgp->maxmed_admin_value = strtoul(argv[idx_number]->arg, NULL, 10); | |
abc920f8 | 1428 | |
d62a17ae | 1429 | bgp_maxmed_update(bgp); |
abc920f8 | 1430 | |
d62a17ae | 1431 | return CMD_SUCCESS; |
abc920f8 DS |
1432 | } |
1433 | ||
1434 | DEFUN (no_bgp_maxmed_admin, | |
1435 | no_bgp_maxmed_admin_cmd, | |
4668a151 | 1436 | "no bgp max-med administrative [(0-4294967295)]", |
abc920f8 DS |
1437 | NO_STR |
1438 | BGP_STR | |
1439 | "Advertise routes with max-med\n" | |
838758ac DW |
1440 | "Administratively applied, for an indefinite period\n" |
1441 | "Max MED value to be used\n") | |
abc920f8 | 1442 | { |
d62a17ae | 1443 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1444 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; | |
1445 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1446 | bgp_maxmed_update(bgp); | |
abc920f8 | 1447 | |
d62a17ae | 1448 | return CMD_SUCCESS; |
abc920f8 DS |
1449 | } |
1450 | ||
abc920f8 DS |
1451 | DEFUN (bgp_maxmed_onstartup, |
1452 | bgp_maxmed_onstartup_cmd, | |
4668a151 | 1453 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", |
abc920f8 DS |
1454 | BGP_STR |
1455 | "Advertise routes with max-med\n" | |
1456 | "Effective on a startup\n" | |
1457 | "Time (seconds) period for max-med\n" | |
1458 | "Max MED value to be used\n") | |
1459 | { | |
d62a17ae | 1460 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1461 | int idx = 0; | |
4668a151 | 1462 | |
d62a17ae | 1463 | argv_find(argv, argc, "(5-86400)", &idx); |
1464 | bgp->v_maxmed_onstartup = strtoul(argv[idx]->arg, NULL, 10); | |
1465 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
1466 | bgp->maxmed_onstartup_value = strtoul(argv[idx]->arg, NULL, 10); | |
1467 | else | |
1468 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
4668a151 | 1469 | |
d62a17ae | 1470 | bgp_maxmed_update(bgp); |
abc920f8 | 1471 | |
d62a17ae | 1472 | return CMD_SUCCESS; |
abc920f8 DS |
1473 | } |
1474 | ||
1475 | DEFUN (no_bgp_maxmed_onstartup, | |
1476 | no_bgp_maxmed_onstartup_cmd, | |
4668a151 | 1477 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", |
abc920f8 DS |
1478 | NO_STR |
1479 | BGP_STR | |
1480 | "Advertise routes with max-med\n" | |
838758ac DW |
1481 | "Effective on a startup\n" |
1482 | "Time (seconds) period for max-med\n" | |
1483 | "Max MED value to be used\n") | |
abc920f8 | 1484 | { |
d62a17ae | 1485 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1486 | |
d62a17ae | 1487 | /* Cancel max-med onstartup if its on */ |
1488 | if (bgp->t_maxmed_onstartup) { | |
1489 | THREAD_TIMER_OFF(bgp->t_maxmed_onstartup); | |
1490 | bgp->maxmed_onstartup_over = 1; | |
1491 | } | |
abc920f8 | 1492 | |
d62a17ae | 1493 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; |
1494 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1495 | |
d62a17ae | 1496 | bgp_maxmed_update(bgp); |
abc920f8 | 1497 | |
d62a17ae | 1498 | return CMD_SUCCESS; |
abc920f8 DS |
1499 | } |
1500 | ||
d62a17ae | 1501 | static int bgp_update_delay_config_vty(struct vty *vty, const char *delay, |
1502 | const char *wait) | |
f188f2c4 | 1503 | { |
d62a17ae | 1504 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d7c0a89a QY |
1505 | uint16_t update_delay; |
1506 | uint16_t establish_wait; | |
f188f2c4 | 1507 | |
d62a17ae | 1508 | update_delay = strtoul(delay, NULL, 10); |
f188f2c4 | 1509 | |
d62a17ae | 1510 | if (!wait) /* update-delay <delay> */ |
1511 | { | |
1512 | bgp->v_update_delay = update_delay; | |
1513 | bgp->v_establish_wait = bgp->v_update_delay; | |
1514 | return CMD_SUCCESS; | |
1515 | } | |
f188f2c4 | 1516 | |
d62a17ae | 1517 | /* update-delay <delay> <establish-wait> */ |
1518 | establish_wait = atoi(wait); | |
1519 | if (update_delay < establish_wait) { | |
1520 | vty_out(vty, | |
1521 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1522 | return CMD_WARNING_CONFIG_FAILED; | |
1523 | } | |
f188f2c4 | 1524 | |
d62a17ae | 1525 | bgp->v_update_delay = update_delay; |
1526 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 1527 | |
d62a17ae | 1528 | return CMD_SUCCESS; |
f188f2c4 DS |
1529 | } |
1530 | ||
d62a17ae | 1531 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 1532 | { |
d62a17ae | 1533 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 1534 | |
d62a17ae | 1535 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
1536 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 1537 | |
d62a17ae | 1538 | return CMD_SUCCESS; |
f188f2c4 DS |
1539 | } |
1540 | ||
2b791107 | 1541 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 1542 | { |
d62a17ae | 1543 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
1544 | vty_out(vty, " update-delay %d", bgp->v_update_delay); | |
1545 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1546 | vty_out(vty, " %d", bgp->v_establish_wait); | |
1547 | vty_out(vty, "\n"); | |
1548 | } | |
f188f2c4 DS |
1549 | } |
1550 | ||
1551 | ||
1552 | /* Update-delay configuration */ | |
1553 | DEFUN (bgp_update_delay, | |
1554 | bgp_update_delay_cmd, | |
6147e2c6 | 1555 | "update-delay (0-3600)", |
f188f2c4 DS |
1556 | "Force initial delay for best-path and updates\n" |
1557 | "Seconds\n") | |
1558 | { | |
d62a17ae | 1559 | int idx_number = 1; |
1560 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); | |
f188f2c4 DS |
1561 | } |
1562 | ||
1563 | DEFUN (bgp_update_delay_establish_wait, | |
1564 | bgp_update_delay_establish_wait_cmd, | |
6147e2c6 | 1565 | "update-delay (0-3600) (1-3600)", |
f188f2c4 DS |
1566 | "Force initial delay for best-path and updates\n" |
1567 | "Seconds\n" | |
f188f2c4 DS |
1568 | "Seconds\n") |
1569 | { | |
d62a17ae | 1570 | int idx_number = 1; |
1571 | int idx_number_2 = 2; | |
1572 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, | |
1573 | argv[idx_number_2]->arg); | |
f188f2c4 DS |
1574 | } |
1575 | ||
1576 | /* Update-delay deconfiguration */ | |
1577 | DEFUN (no_bgp_update_delay, | |
1578 | no_bgp_update_delay_cmd, | |
838758ac DW |
1579 | "no update-delay [(0-3600) [(1-3600)]]", |
1580 | NO_STR | |
f188f2c4 | 1581 | "Force initial delay for best-path and updates\n" |
838758ac | 1582 | "Seconds\n" |
7111c1a0 | 1583 | "Seconds\n") |
f188f2c4 | 1584 | { |
d62a17ae | 1585 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
1586 | } |
1587 | ||
5e242b0d | 1588 | |
d62a17ae | 1589 | static int bgp_wpkt_quanta_config_vty(struct vty *vty, const char *num, |
1590 | char set) | |
cb1faec9 | 1591 | { |
d62a17ae | 1592 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
cb1faec9 | 1593 | |
555e09d4 QY |
1594 | if (set) { |
1595 | uint32_t quanta = strtoul(num, NULL, 10); | |
1596 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, | |
1597 | memory_order_relaxed); | |
1598 | } else { | |
1599 | atomic_store_explicit(&bgp->wpkt_quanta, BGP_WRITE_PACKET_MAX, | |
1600 | memory_order_relaxed); | |
1601 | } | |
1602 | ||
1603 | return CMD_SUCCESS; | |
1604 | } | |
1605 | ||
1606 | static int bgp_rpkt_quanta_config_vty(struct vty *vty, const char *num, | |
1607 | char set) | |
1608 | { | |
1609 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1610 | ||
1611 | if (set) { | |
1612 | uint32_t quanta = strtoul(num, NULL, 10); | |
1613 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, | |
1614 | memory_order_relaxed); | |
1615 | } else { | |
1616 | atomic_store_explicit(&bgp->rpkt_quanta, BGP_READ_PACKET_MAX, | |
1617 | memory_order_relaxed); | |
1618 | } | |
cb1faec9 | 1619 | |
d62a17ae | 1620 | return CMD_SUCCESS; |
cb1faec9 DS |
1621 | } |
1622 | ||
2b791107 | 1623 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 1624 | { |
555e09d4 QY |
1625 | uint32_t quanta = |
1626 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
1627 | if (quanta != BGP_WRITE_PACKET_MAX) | |
152456fe | 1628 | vty_out(vty, " write-quanta %d\n", quanta); |
cb1faec9 DS |
1629 | } |
1630 | ||
555e09d4 QY |
1631 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) |
1632 | { | |
1633 | uint32_t quanta = | |
1634 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
1635 | if (quanta != BGP_READ_PACKET_MAX) | |
152456fe | 1636 | vty_out(vty, " read-quanta %d\n", quanta); |
555e09d4 | 1637 | } |
cb1faec9 | 1638 | |
555e09d4 | 1639 | /* Packet quanta configuration */ |
cb1faec9 DS |
1640 | DEFUN (bgp_wpkt_quanta, |
1641 | bgp_wpkt_quanta_cmd, | |
555e09d4 | 1642 | "write-quanta (1-10)", |
cb1faec9 DS |
1643 | "How many packets to write to peer socket per run\n" |
1644 | "Number of packets\n") | |
1645 | { | |
d62a17ae | 1646 | int idx_number = 1; |
1647 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
cb1faec9 DS |
1648 | } |
1649 | ||
cb1faec9 DS |
1650 | DEFUN (no_bgp_wpkt_quanta, |
1651 | no_bgp_wpkt_quanta_cmd, | |
555e09d4 | 1652 | "no write-quanta (1-10)", |
d7fa34c1 | 1653 | NO_STR |
555e09d4 | 1654 | "How many packets to write to peer socket per I/O cycle\n" |
cb1faec9 DS |
1655 | "Number of packets\n") |
1656 | { | |
d62a17ae | 1657 | int idx_number = 2; |
1658 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
cb1faec9 DS |
1659 | } |
1660 | ||
555e09d4 QY |
1661 | DEFUN (bgp_rpkt_quanta, |
1662 | bgp_rpkt_quanta_cmd, | |
1663 | "read-quanta (1-10)", | |
1664 | "How many packets to read from peer socket per I/O cycle\n" | |
1665 | "Number of packets\n") | |
1666 | { | |
1667 | int idx_number = 1; | |
1668 | return bgp_rpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
1669 | } | |
1670 | ||
1671 | DEFUN (no_bgp_rpkt_quanta, | |
1672 | no_bgp_rpkt_quanta_cmd, | |
1673 | "no read-quanta (1-10)", | |
1674 | NO_STR | |
1675 | "How many packets to read from peer socket per I/O cycle\n" | |
1676 | "Number of packets\n") | |
1677 | { | |
1678 | int idx_number = 2; | |
1679 | return bgp_rpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
1680 | } | |
1681 | ||
2b791107 | 1682 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 1683 | { |
37a333fe | 1684 | if (!bgp->heuristic_coalesce) |
d62a17ae | 1685 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); |
3f9c7369 DS |
1686 | } |
1687 | ||
1688 | ||
1689 | DEFUN (bgp_coalesce_time, | |
1690 | bgp_coalesce_time_cmd, | |
6147e2c6 | 1691 | "coalesce-time (0-4294967295)", |
3f9c7369 DS |
1692 | "Subgroup coalesce timer\n" |
1693 | "Subgroup coalesce timer value (in ms)\n") | |
1694 | { | |
d62a17ae | 1695 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1696 | |
d62a17ae | 1697 | int idx = 0; |
1698 | argv_find(argv, argc, "(0-4294967295)", &idx); | |
37a333fe | 1699 | bgp->heuristic_coalesce = false; |
d62a17ae | 1700 | bgp->coalesce_time = strtoul(argv[idx]->arg, NULL, 10); |
1701 | return CMD_SUCCESS; | |
3f9c7369 DS |
1702 | } |
1703 | ||
1704 | DEFUN (no_bgp_coalesce_time, | |
1705 | no_bgp_coalesce_time_cmd, | |
6147e2c6 | 1706 | "no coalesce-time (0-4294967295)", |
3a2d747c | 1707 | NO_STR |
3f9c7369 DS |
1708 | "Subgroup coalesce timer\n" |
1709 | "Subgroup coalesce timer value (in ms)\n") | |
1710 | { | |
d62a17ae | 1711 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1712 | |
37a333fe | 1713 | bgp->heuristic_coalesce = true; |
d62a17ae | 1714 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; |
1715 | return CMD_SUCCESS; | |
3f9c7369 DS |
1716 | } |
1717 | ||
5e242b0d DS |
1718 | /* Maximum-paths configuration */ |
1719 | DEFUN (bgp_maxpaths, | |
1720 | bgp_maxpaths_cmd, | |
6319fd63 | 1721 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), |
5e242b0d DS |
1722 | "Forward packets over multiple paths\n" |
1723 | "Number of paths\n") | |
1724 | { | |
d62a17ae | 1725 | int idx_number = 1; |
1726 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, | |
1727 | argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
1728 | } |
1729 | ||
d62a17ae | 1730 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
1731 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1732 | "Forward packets over multiple paths\n" | |
1733 | "Number of paths\n") | |
596c17ba | 1734 | |
165b5fff JB |
1735 | DEFUN (bgp_maxpaths_ibgp, |
1736 | bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1737 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), |
165b5fff JB |
1738 | "Forward packets over multiple paths\n" |
1739 | "iBGP-multipath\n" | |
1740 | "Number of paths\n") | |
1741 | { | |
d62a17ae | 1742 | int idx_number = 2; |
1743 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, | |
1744 | argv[idx_number]->arg, 0, 1); | |
5e242b0d | 1745 | } |
165b5fff | 1746 | |
d62a17ae | 1747 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
1748 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1749 | "Forward packets over multiple paths\n" | |
1750 | "iBGP-multipath\n" | |
1751 | "Number of paths\n") | |
596c17ba | 1752 | |
5e242b0d DS |
1753 | DEFUN (bgp_maxpaths_ibgp_cluster, |
1754 | bgp_maxpaths_ibgp_cluster_cmd, | |
6319fd63 | 1755 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", |
5e242b0d DS |
1756 | "Forward packets over multiple paths\n" |
1757 | "iBGP-multipath\n" | |
1758 | "Number of paths\n" | |
1759 | "Match the cluster length\n") | |
1760 | { | |
d62a17ae | 1761 | int idx_number = 2; |
1762 | return bgp_maxpaths_config_vty( | |
1763 | vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
1764 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); | |
165b5fff JB |
1765 | } |
1766 | ||
d62a17ae | 1767 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
1768 | "maximum-paths ibgp " CMD_RANGE_STR( | |
1769 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
1770 | "Forward packets over multiple paths\n" | |
1771 | "iBGP-multipath\n" | |
1772 | "Number of paths\n" | |
1773 | "Match the cluster length\n") | |
596c17ba | 1774 | |
165b5fff JB |
1775 | DEFUN (no_bgp_maxpaths, |
1776 | no_bgp_maxpaths_cmd, | |
6319fd63 | 1777 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", |
165b5fff JB |
1778 | NO_STR |
1779 | "Forward packets over multiple paths\n" | |
1780 | "Number of paths\n") | |
1781 | { | |
d62a17ae | 1782 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
1783 | } |
1784 | ||
d62a17ae | 1785 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
996c9314 | 1786 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 1787 | "Forward packets over multiple paths\n" |
1788 | "Number of paths\n") | |
596c17ba | 1789 | |
165b5fff JB |
1790 | DEFUN (no_bgp_maxpaths_ibgp, |
1791 | no_bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1792 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", |
165b5fff JB |
1793 | NO_STR |
1794 | "Forward packets over multiple paths\n" | |
1795 | "iBGP-multipath\n" | |
838758ac DW |
1796 | "Number of paths\n" |
1797 | "Match the cluster length\n") | |
165b5fff | 1798 | { |
d62a17ae | 1799 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1800 | } |
1801 | ||
d62a17ae | 1802 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
1803 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
1804 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
1805 | NO_STR | |
1806 | "Forward packets over multiple paths\n" | |
1807 | "iBGP-multipath\n" | |
1808 | "Number of paths\n" | |
1809 | "Match the cluster length\n") | |
596c17ba | 1810 | |
2b791107 | 1811 | void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, afi_t afi, |
60466a63 | 1812 | safi_t safi) |
165b5fff | 1813 | { |
d62a17ae | 1814 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) { |
d62a17ae | 1815 | vty_out(vty, " maximum-paths %d\n", |
1816 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
1817 | } | |
165b5fff | 1818 | |
d62a17ae | 1819 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) { |
d62a17ae | 1820 | vty_out(vty, " maximum-paths ibgp %d", |
1821 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
1822 | if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, | |
1823 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1824 | vty_out(vty, " equal-cluster-length"); | |
1825 | vty_out(vty, "\n"); | |
1826 | } | |
165b5fff | 1827 | } |
6b0655a2 | 1828 | |
718e3744 | 1829 | /* BGP timers. */ |
1830 | ||
1831 | DEFUN (bgp_timers, | |
1832 | bgp_timers_cmd, | |
6147e2c6 | 1833 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1834 | "Adjust routing timers\n" |
1835 | "BGP timers\n" | |
1836 | "Keepalive interval\n" | |
1837 | "Holdtime\n") | |
1838 | { | |
d62a17ae | 1839 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1840 | int idx_number = 2; | |
1841 | int idx_number_2 = 3; | |
1842 | unsigned long keepalive = 0; | |
1843 | unsigned long holdtime = 0; | |
718e3744 | 1844 | |
d62a17ae | 1845 | keepalive = strtoul(argv[idx_number]->arg, NULL, 10); |
1846 | holdtime = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
718e3744 | 1847 | |
d62a17ae | 1848 | /* Holdtime value check. */ |
1849 | if (holdtime < 3 && holdtime != 0) { | |
1850 | vty_out(vty, | |
1851 | "%% hold time value must be either 0 or greater than 3\n"); | |
1852 | return CMD_WARNING_CONFIG_FAILED; | |
1853 | } | |
718e3744 | 1854 | |
d62a17ae | 1855 | bgp_timers_set(bgp, keepalive, holdtime); |
718e3744 | 1856 | |
d62a17ae | 1857 | return CMD_SUCCESS; |
718e3744 | 1858 | } |
1859 | ||
1860 | DEFUN (no_bgp_timers, | |
1861 | no_bgp_timers_cmd, | |
838758ac | 1862 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1863 | NO_STR |
1864 | "Adjust routing timers\n" | |
838758ac DW |
1865 | "BGP timers\n" |
1866 | "Keepalive interval\n" | |
1867 | "Holdtime\n") | |
718e3744 | 1868 | { |
d62a17ae | 1869 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1870 | bgp_timers_unset(bgp); | |
718e3744 | 1871 | |
d62a17ae | 1872 | return CMD_SUCCESS; |
718e3744 | 1873 | } |
1874 | ||
6b0655a2 | 1875 | |
718e3744 | 1876 | DEFUN (bgp_client_to_client_reflection, |
1877 | bgp_client_to_client_reflection_cmd, | |
1878 | "bgp client-to-client reflection", | |
1879 | "BGP specific commands\n" | |
1880 | "Configure client to client route reflection\n" | |
1881 | "reflection of routes allowed\n") | |
1882 | { | |
d62a17ae | 1883 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1884 | bgp_flag_unset(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1885 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1886 | |
d62a17ae | 1887 | return CMD_SUCCESS; |
718e3744 | 1888 | } |
1889 | ||
1890 | DEFUN (no_bgp_client_to_client_reflection, | |
1891 | no_bgp_client_to_client_reflection_cmd, | |
1892 | "no bgp client-to-client reflection", | |
1893 | NO_STR | |
1894 | "BGP specific commands\n" | |
1895 | "Configure client to client route reflection\n" | |
1896 | "reflection of routes allowed\n") | |
1897 | { | |
d62a17ae | 1898 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1899 | bgp_flag_set(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1900 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1901 | |
d62a17ae | 1902 | return CMD_SUCCESS; |
718e3744 | 1903 | } |
1904 | ||
1905 | /* "bgp always-compare-med" configuration. */ | |
1906 | DEFUN (bgp_always_compare_med, | |
1907 | bgp_always_compare_med_cmd, | |
1908 | "bgp always-compare-med", | |
1909 | "BGP specific commands\n" | |
1910 | "Allow comparing MED from different neighbors\n") | |
1911 | { | |
d62a17ae | 1912 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1913 | bgp_flag_set(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1914 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1915 | |
d62a17ae | 1916 | return CMD_SUCCESS; |
718e3744 | 1917 | } |
1918 | ||
1919 | DEFUN (no_bgp_always_compare_med, | |
1920 | no_bgp_always_compare_med_cmd, | |
1921 | "no bgp always-compare-med", | |
1922 | NO_STR | |
1923 | "BGP specific commands\n" | |
1924 | "Allow comparing MED from different neighbors\n") | |
1925 | { | |
d62a17ae | 1926 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1927 | bgp_flag_unset(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1928 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1929 | |
d62a17ae | 1930 | return CMD_SUCCESS; |
718e3744 | 1931 | } |
6b0655a2 | 1932 | |
9dac9fc8 DA |
1933 | |
1934 | DEFUN(bgp_ebgp_requires_policy, bgp_ebgp_requires_policy_cmd, | |
1935 | "bgp ebgp-requires-policy", | |
1936 | "BGP specific commands\n" | |
1937 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
1938 | { | |
1939 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1940 | bgp->ebgp_requires_policy = DEFAULT_EBGP_POLICY_ENABLED; | |
1941 | return CMD_SUCCESS; | |
1942 | } | |
1943 | ||
1944 | DEFUN(no_bgp_ebgp_requires_policy, no_bgp_ebgp_requires_policy_cmd, | |
1945 | "no bgp ebgp-requires-policy", | |
1946 | NO_STR | |
1947 | "BGP specific commands\n" | |
1948 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
1949 | { | |
1950 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1951 | bgp->ebgp_requires_policy = DEFAULT_EBGP_POLICY_DISABLED; | |
1952 | return CMD_SUCCESS; | |
1953 | } | |
1954 | ||
1955 | ||
718e3744 | 1956 | /* "bgp deterministic-med" configuration. */ |
1957 | DEFUN (bgp_deterministic_med, | |
1958 | bgp_deterministic_med_cmd, | |
1959 | "bgp deterministic-med", | |
1960 | "BGP specific commands\n" | |
1961 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1962 | { | |
d62a17ae | 1963 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1475ac87 | 1964 | |
d62a17ae | 1965 | if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { |
1966 | bgp_flag_set(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1967 | bgp_recalculate_all_bestpaths(bgp); | |
1968 | } | |
7aafcaca | 1969 | |
d62a17ae | 1970 | return CMD_SUCCESS; |
718e3744 | 1971 | } |
1972 | ||
1973 | DEFUN (no_bgp_deterministic_med, | |
1974 | no_bgp_deterministic_med_cmd, | |
1975 | "no bgp deterministic-med", | |
1976 | NO_STR | |
1977 | "BGP specific commands\n" | |
1978 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1979 | { | |
d62a17ae | 1980 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1981 | int bestpath_per_as_used; | |
1982 | afi_t afi; | |
1983 | safi_t safi; | |
1984 | struct peer *peer; | |
1985 | struct listnode *node, *nnode; | |
1986 | ||
1987 | if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { | |
1988 | bestpath_per_as_used = 0; | |
1989 | ||
1990 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
05c7a1cc | 1991 | FOREACH_AFI_SAFI (afi, safi) |
dcc68b5e MS |
1992 | if (bgp_addpath_dmed_required( |
1993 | peer->addpath_type[afi][safi])) { | |
05c7a1cc QY |
1994 | bestpath_per_as_used = 1; |
1995 | break; | |
1996 | } | |
d62a17ae | 1997 | |
1998 | if (bestpath_per_as_used) | |
1999 | break; | |
2000 | } | |
2001 | ||
2002 | if (bestpath_per_as_used) { | |
2003 | vty_out(vty, | |
2004 | "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n"); | |
2005 | return CMD_WARNING_CONFIG_FAILED; | |
2006 | } else { | |
2007 | bgp_flag_unset(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
2008 | bgp_recalculate_all_bestpaths(bgp); | |
2009 | } | |
2010 | } | |
2011 | ||
2012 | return CMD_SUCCESS; | |
718e3744 | 2013 | } |
538621f2 | 2014 | |
2015 | /* "bgp graceful-restart" configuration. */ | |
2016 | DEFUN (bgp_graceful_restart, | |
2017 | bgp_graceful_restart_cmd, | |
2018 | "bgp graceful-restart", | |
2019 | "BGP specific commands\n" | |
2020 | "Graceful restart capability parameters\n") | |
2021 | { | |
d62a17ae | 2022 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2023 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
2024 | return CMD_SUCCESS; | |
538621f2 | 2025 | } |
2026 | ||
2027 | DEFUN (no_bgp_graceful_restart, | |
2028 | no_bgp_graceful_restart_cmd, | |
2029 | "no bgp graceful-restart", | |
2030 | NO_STR | |
2031 | "BGP specific commands\n" | |
2032 | "Graceful restart capability parameters\n") | |
2033 | { | |
d62a17ae | 2034 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2035 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
2036 | return CMD_SUCCESS; | |
538621f2 | 2037 | } |
2038 | ||
93406d87 | 2039 | DEFUN (bgp_graceful_restart_stalepath_time, |
2040 | bgp_graceful_restart_stalepath_time_cmd, | |
c1779b7d | 2041 | "bgp graceful-restart stalepath-time (1-4095)", |
93406d87 | 2042 | "BGP specific commands\n" |
2043 | "Graceful restart capability parameters\n" | |
2044 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2045 | "Delay value (seconds)\n") | |
2046 | { | |
d62a17ae | 2047 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2048 | int idx_number = 3; | |
d7c0a89a | 2049 | uint32_t stalepath; |
93406d87 | 2050 | |
d62a17ae | 2051 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
2052 | bgp->stalepath_time = stalepath; | |
2053 | return CMD_SUCCESS; | |
93406d87 | 2054 | } |
2055 | ||
eb6f1b41 PG |
2056 | DEFUN (bgp_graceful_restart_restart_time, |
2057 | bgp_graceful_restart_restart_time_cmd, | |
c72d0314 | 2058 | "bgp graceful-restart restart-time (1-4095)", |
eb6f1b41 PG |
2059 | "BGP specific commands\n" |
2060 | "Graceful restart capability parameters\n" | |
2061 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2062 | "Delay value (seconds)\n") | |
2063 | { | |
d62a17ae | 2064 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2065 | int idx_number = 3; | |
d7c0a89a | 2066 | uint32_t restart; |
eb6f1b41 | 2067 | |
d62a17ae | 2068 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
2069 | bgp->restart_time = restart; | |
2070 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2071 | } |
2072 | ||
93406d87 | 2073 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
2074 | no_bgp_graceful_restart_stalepath_time_cmd, | |
c1779b7d | 2075 | "no bgp graceful-restart stalepath-time [(1-4095)]", |
93406d87 | 2076 | NO_STR |
2077 | "BGP specific commands\n" | |
2078 | "Graceful restart capability parameters\n" | |
838758ac DW |
2079 | "Set the max time to hold onto restarting peer's stale paths\n" |
2080 | "Delay value (seconds)\n") | |
93406d87 | 2081 | { |
d62a17ae | 2082 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 2083 | |
d62a17ae | 2084 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
2085 | return CMD_SUCCESS; | |
93406d87 | 2086 | } |
2087 | ||
eb6f1b41 PG |
2088 | DEFUN (no_bgp_graceful_restart_restart_time, |
2089 | no_bgp_graceful_restart_restart_time_cmd, | |
c72d0314 | 2090 | "no bgp graceful-restart restart-time [(1-4095)]", |
eb6f1b41 PG |
2091 | NO_STR |
2092 | "BGP specific commands\n" | |
2093 | "Graceful restart capability parameters\n" | |
838758ac DW |
2094 | "Set the time to wait to delete stale routes before a BGP open message is received\n" |
2095 | "Delay value (seconds)\n") | |
eb6f1b41 | 2096 | { |
d62a17ae | 2097 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 2098 | |
d62a17ae | 2099 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
2100 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2101 | } |
2102 | ||
43fc21b3 JC |
2103 | DEFUN (bgp_graceful_restart_preserve_fw, |
2104 | bgp_graceful_restart_preserve_fw_cmd, | |
2105 | "bgp graceful-restart preserve-fw-state", | |
2106 | "BGP specific commands\n" | |
2107 | "Graceful restart capability parameters\n" | |
2108 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
2109 | { | |
d62a17ae | 2110 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2111 | bgp_flag_set(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
2112 | return CMD_SUCCESS; | |
43fc21b3 JC |
2113 | } |
2114 | ||
2115 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
2116 | no_bgp_graceful_restart_preserve_fw_cmd, | |
2117 | "no bgp graceful-restart preserve-fw-state", | |
2118 | NO_STR | |
2119 | "BGP specific commands\n" | |
2120 | "Graceful restart capability parameters\n" | |
2121 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
2122 | { | |
d62a17ae | 2123 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2124 | bgp_flag_unset(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
2125 | return CMD_SUCCESS; | |
43fc21b3 JC |
2126 | } |
2127 | ||
7f323236 DW |
2128 | /* "bgp graceful-shutdown" configuration */ |
2129 | DEFUN (bgp_graceful_shutdown, | |
2130 | bgp_graceful_shutdown_cmd, | |
2131 | "bgp graceful-shutdown", | |
2132 | BGP_STR | |
2133 | "Graceful shutdown parameters\n") | |
2134 | { | |
2135 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2136 | ||
2137 | if (!bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
2138 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
2139 | bgp_static_redo_import_check(bgp); | |
2140 | bgp_redistribute_redo(bgp); | |
2141 | bgp_clear_star_soft_out(vty, bgp->name); | |
2142 | bgp_clear_star_soft_in(vty, bgp->name); | |
2143 | } | |
2144 | ||
2145 | return CMD_SUCCESS; | |
2146 | } | |
2147 | ||
2148 | DEFUN (no_bgp_graceful_shutdown, | |
2149 | no_bgp_graceful_shutdown_cmd, | |
2150 | "no bgp graceful-shutdown", | |
2151 | NO_STR | |
2152 | BGP_STR | |
2153 | "Graceful shutdown parameters\n") | |
2154 | { | |
2155 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2156 | ||
2157 | if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
2158 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
2159 | bgp_static_redo_import_check(bgp); | |
2160 | bgp_redistribute_redo(bgp); | |
2161 | bgp_clear_star_soft_out(vty, bgp->name); | |
2162 | bgp_clear_star_soft_in(vty, bgp->name); | |
2163 | } | |
2164 | ||
2165 | return CMD_SUCCESS; | |
2166 | } | |
2167 | ||
718e3744 | 2168 | /* "bgp fast-external-failover" configuration. */ |
2169 | DEFUN (bgp_fast_external_failover, | |
2170 | bgp_fast_external_failover_cmd, | |
2171 | "bgp fast-external-failover", | |
2172 | BGP_STR | |
2173 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2174 | { | |
d62a17ae | 2175 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2176 | bgp_flag_unset(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
2177 | return CMD_SUCCESS; | |
718e3744 | 2178 | } |
2179 | ||
2180 | DEFUN (no_bgp_fast_external_failover, | |
2181 | no_bgp_fast_external_failover_cmd, | |
2182 | "no bgp fast-external-failover", | |
2183 | NO_STR | |
2184 | BGP_STR | |
2185 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2186 | { | |
d62a17ae | 2187 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2188 | bgp_flag_set(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
2189 | return CMD_SUCCESS; | |
718e3744 | 2190 | } |
6b0655a2 | 2191 | |
718e3744 | 2192 | /* "bgp bestpath compare-routerid" configuration. */ |
2193 | DEFUN (bgp_bestpath_compare_router_id, | |
2194 | bgp_bestpath_compare_router_id_cmd, | |
2195 | "bgp bestpath compare-routerid", | |
2196 | "BGP specific commands\n" | |
2197 | "Change the default bestpath selection\n" | |
2198 | "Compare router-id for identical EBGP paths\n") | |
2199 | { | |
d62a17ae | 2200 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2201 | bgp_flag_set(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
2202 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2203 | |
d62a17ae | 2204 | return CMD_SUCCESS; |
718e3744 | 2205 | } |
2206 | ||
2207 | DEFUN (no_bgp_bestpath_compare_router_id, | |
2208 | no_bgp_bestpath_compare_router_id_cmd, | |
2209 | "no bgp bestpath compare-routerid", | |
2210 | NO_STR | |
2211 | "BGP specific commands\n" | |
2212 | "Change the default bestpath selection\n" | |
2213 | "Compare router-id for identical EBGP paths\n") | |
2214 | { | |
d62a17ae | 2215 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2216 | bgp_flag_unset(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
2217 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2218 | |
d62a17ae | 2219 | return CMD_SUCCESS; |
718e3744 | 2220 | } |
6b0655a2 | 2221 | |
718e3744 | 2222 | /* "bgp bestpath as-path ignore" configuration. */ |
2223 | DEFUN (bgp_bestpath_aspath_ignore, | |
2224 | bgp_bestpath_aspath_ignore_cmd, | |
2225 | "bgp bestpath as-path ignore", | |
2226 | "BGP specific commands\n" | |
2227 | "Change the default bestpath selection\n" | |
2228 | "AS-path attribute\n" | |
2229 | "Ignore as-path length in selecting a route\n") | |
2230 | { | |
d62a17ae | 2231 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2232 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2233 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2234 | |
d62a17ae | 2235 | return CMD_SUCCESS; |
718e3744 | 2236 | } |
2237 | ||
2238 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
2239 | no_bgp_bestpath_aspath_ignore_cmd, | |
2240 | "no bgp bestpath as-path ignore", | |
2241 | NO_STR | |
2242 | "BGP specific commands\n" | |
2243 | "Change the default bestpath selection\n" | |
2244 | "AS-path attribute\n" | |
2245 | "Ignore as-path length in selecting a route\n") | |
2246 | { | |
d62a17ae | 2247 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2248 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2249 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2250 | |
d62a17ae | 2251 | return CMD_SUCCESS; |
718e3744 | 2252 | } |
6b0655a2 | 2253 | |
6811845b | 2254 | /* "bgp bestpath as-path confed" configuration. */ |
2255 | DEFUN (bgp_bestpath_aspath_confed, | |
2256 | bgp_bestpath_aspath_confed_cmd, | |
2257 | "bgp bestpath as-path confed", | |
2258 | "BGP specific commands\n" | |
2259 | "Change the default bestpath selection\n" | |
2260 | "AS-path attribute\n" | |
2261 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2262 | { | |
d62a17ae | 2263 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2264 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_CONFED); | |
2265 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2266 | |
d62a17ae | 2267 | return CMD_SUCCESS; |
6811845b | 2268 | } |
2269 | ||
2270 | DEFUN (no_bgp_bestpath_aspath_confed, | |
2271 | no_bgp_bestpath_aspath_confed_cmd, | |
2272 | "no bgp bestpath as-path confed", | |
2273 | NO_STR | |
2274 | "BGP specific commands\n" | |
2275 | "Change the default bestpath selection\n" | |
2276 | "AS-path attribute\n" | |
2277 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2278 | { | |
d62a17ae | 2279 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2280 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_CONFED); | |
2281 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2282 | |
d62a17ae | 2283 | return CMD_SUCCESS; |
6811845b | 2284 | } |
6b0655a2 | 2285 | |
2fdd455c PM |
2286 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
2287 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
2288 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2289 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2290 | "BGP specific commands\n" |
2291 | "Change the default bestpath selection\n" | |
2292 | "AS-path attribute\n" | |
2293 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2294 | "Generate an AS_SET\n" |
16fc1eec DS |
2295 | "Do not generate an AS_SET\n") |
2296 | { | |
d62a17ae | 2297 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2298 | int idx = 0; | |
2299 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
219178b6 | 2300 | |
d62a17ae | 2301 | /* no-as-set is now the default behavior so we can silently |
2302 | * ignore it */ | |
2303 | if (argv_find(argv, argc, "as-set", &idx)) | |
2304 | bgp_flag_set(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2305 | else | |
2306 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
219178b6 | 2307 | |
d62a17ae | 2308 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2309 | |
d62a17ae | 2310 | return CMD_SUCCESS; |
16fc1eec DS |
2311 | } |
2312 | ||
219178b6 DW |
2313 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
2314 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2315 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2316 | NO_STR |
2317 | "BGP specific commands\n" | |
2318 | "Change the default bestpath selection\n" | |
2319 | "AS-path attribute\n" | |
2320 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2321 | "Generate an AS_SET\n" |
16fc1eec DS |
2322 | "Do not generate an AS_SET\n") |
2323 | { | |
d62a17ae | 2324 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2325 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
2326 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2327 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2328 | |
d62a17ae | 2329 | return CMD_SUCCESS; |
2fdd455c | 2330 | } |
6b0655a2 | 2331 | |
848973c7 | 2332 | /* "bgp log-neighbor-changes" configuration. */ |
2333 | DEFUN (bgp_log_neighbor_changes, | |
2334 | bgp_log_neighbor_changes_cmd, | |
2335 | "bgp log-neighbor-changes", | |
2336 | "BGP specific commands\n" | |
2337 | "Log neighbor up/down and reset reason\n") | |
2338 | { | |
d62a17ae | 2339 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2340 | bgp_flag_set(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2341 | return CMD_SUCCESS; | |
848973c7 | 2342 | } |
2343 | ||
2344 | DEFUN (no_bgp_log_neighbor_changes, | |
2345 | no_bgp_log_neighbor_changes_cmd, | |
2346 | "no bgp log-neighbor-changes", | |
2347 | NO_STR | |
2348 | "BGP specific commands\n" | |
2349 | "Log neighbor up/down and reset reason\n") | |
2350 | { | |
d62a17ae | 2351 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2352 | bgp_flag_unset(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2353 | return CMD_SUCCESS; | |
848973c7 | 2354 | } |
6b0655a2 | 2355 | |
718e3744 | 2356 | /* "bgp bestpath med" configuration. */ |
2357 | DEFUN (bgp_bestpath_med, | |
2358 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 2359 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2360 | "BGP specific commands\n" |
2361 | "Change the default bestpath selection\n" | |
2362 | "MED attribute\n" | |
2363 | "Compare MED among confederation paths\n" | |
838758ac DW |
2364 | "Treat missing MED as the least preferred one\n" |
2365 | "Treat missing MED as the least preferred one\n" | |
2366 | "Compare MED among confederation paths\n") | |
718e3744 | 2367 | { |
d62a17ae | 2368 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6cbd1915 | 2369 | |
d62a17ae | 2370 | int idx = 0; |
2371 | if (argv_find(argv, argc, "confed", &idx)) | |
2372 | bgp_flag_set(bgp, BGP_FLAG_MED_CONFED); | |
2373 | idx = 0; | |
2374 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2375 | bgp_flag_set(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
e52702f2 | 2376 | |
d62a17ae | 2377 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2378 | |
d62a17ae | 2379 | return CMD_SUCCESS; |
718e3744 | 2380 | } |
2381 | ||
718e3744 | 2382 | DEFUN (no_bgp_bestpath_med, |
2383 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2384 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2385 | NO_STR |
2386 | "BGP specific commands\n" | |
2387 | "Change the default bestpath selection\n" | |
2388 | "MED attribute\n" | |
2389 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2390 | "Treat missing MED as the least preferred one\n" |
2391 | "Treat missing MED as the least preferred one\n" | |
2392 | "Compare MED among confederation paths\n") | |
718e3744 | 2393 | { |
d62a17ae | 2394 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
e52702f2 | 2395 | |
d62a17ae | 2396 | int idx = 0; |
2397 | if (argv_find(argv, argc, "confed", &idx)) | |
2398 | bgp_flag_unset(bgp, BGP_FLAG_MED_CONFED); | |
2399 | idx = 0; | |
2400 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2401 | bgp_flag_unset(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
718e3744 | 2402 | |
d62a17ae | 2403 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2404 | |
d62a17ae | 2405 | return CMD_SUCCESS; |
718e3744 | 2406 | } |
2407 | ||
718e3744 | 2408 | /* "no bgp default ipv4-unicast". */ |
2409 | DEFUN (no_bgp_default_ipv4_unicast, | |
2410 | no_bgp_default_ipv4_unicast_cmd, | |
2411 | "no bgp default ipv4-unicast", | |
2412 | NO_STR | |
2413 | "BGP specific commands\n" | |
2414 | "Configure BGP defaults\n" | |
2415 | "Activate ipv4-unicast for a peer by default\n") | |
2416 | { | |
d62a17ae | 2417 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2418 | bgp_flag_set(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2419 | return CMD_SUCCESS; | |
718e3744 | 2420 | } |
2421 | ||
2422 | DEFUN (bgp_default_ipv4_unicast, | |
2423 | bgp_default_ipv4_unicast_cmd, | |
2424 | "bgp default ipv4-unicast", | |
2425 | "BGP specific commands\n" | |
2426 | "Configure BGP defaults\n" | |
2427 | "Activate ipv4-unicast for a peer by default\n") | |
2428 | { | |
d62a17ae | 2429 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2430 | bgp_flag_unset(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2431 | return CMD_SUCCESS; | |
718e3744 | 2432 | } |
6b0655a2 | 2433 | |
04b6bdc0 DW |
2434 | /* Display hostname in certain command outputs */ |
2435 | DEFUN (bgp_default_show_hostname, | |
2436 | bgp_default_show_hostname_cmd, | |
2437 | "bgp default show-hostname", | |
2438 | "BGP specific commands\n" | |
2439 | "Configure BGP defaults\n" | |
0437e105 | 2440 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 2441 | { |
d62a17ae | 2442 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2443 | bgp_flag_set(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2444 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2445 | } |
2446 | ||
2447 | DEFUN (no_bgp_default_show_hostname, | |
2448 | no_bgp_default_show_hostname_cmd, | |
2449 | "no bgp default show-hostname", | |
2450 | NO_STR | |
2451 | "BGP specific commands\n" | |
2452 | "Configure BGP defaults\n" | |
0437e105 | 2453 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 2454 | { |
d62a17ae | 2455 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2456 | bgp_flag_unset(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2457 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2458 | } |
2459 | ||
8233ef81 | 2460 | /* "bgp network import-check" configuration. */ |
718e3744 | 2461 | DEFUN (bgp_network_import_check, |
2462 | bgp_network_import_check_cmd, | |
5623e905 | 2463 | "bgp network import-check", |
718e3744 | 2464 | "BGP specific commands\n" |
2465 | "BGP network command\n" | |
5623e905 | 2466 | "Check BGP network route exists in IGP\n") |
718e3744 | 2467 | { |
d62a17ae | 2468 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2469 | if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2470 | bgp_flag_set(bgp, BGP_FLAG_IMPORT_CHECK); | |
2471 | bgp_static_redo_import_check(bgp); | |
2472 | } | |
078430f6 | 2473 | |
d62a17ae | 2474 | return CMD_SUCCESS; |
718e3744 | 2475 | } |
2476 | ||
d62a17ae | 2477 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
2478 | "bgp network import-check exact", | |
2479 | "BGP specific commands\n" | |
2480 | "BGP network command\n" | |
2481 | "Check BGP network route exists in IGP\n" | |
2482 | "Match route precisely\n") | |
8233ef81 | 2483 | |
718e3744 | 2484 | DEFUN (no_bgp_network_import_check, |
2485 | no_bgp_network_import_check_cmd, | |
5623e905 | 2486 | "no bgp network import-check", |
718e3744 | 2487 | NO_STR |
2488 | "BGP specific commands\n" | |
2489 | "BGP network command\n" | |
2490 | "Check BGP network route exists in IGP\n") | |
2491 | { | |
d62a17ae | 2492 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2493 | if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2494 | bgp_flag_unset(bgp, BGP_FLAG_IMPORT_CHECK); | |
2495 | bgp_static_redo_import_check(bgp); | |
2496 | } | |
5623e905 | 2497 | |
d62a17ae | 2498 | return CMD_SUCCESS; |
718e3744 | 2499 | } |
6b0655a2 | 2500 | |
718e3744 | 2501 | DEFUN (bgp_default_local_preference, |
2502 | bgp_default_local_preference_cmd, | |
6147e2c6 | 2503 | "bgp default local-preference (0-4294967295)", |
718e3744 | 2504 | "BGP specific commands\n" |
2505 | "Configure BGP defaults\n" | |
2506 | "local preference (higher=more preferred)\n" | |
2507 | "Configure default local preference value\n") | |
2508 | { | |
d62a17ae | 2509 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2510 | int idx_number = 3; | |
d7c0a89a | 2511 | uint32_t local_pref; |
718e3744 | 2512 | |
d62a17ae | 2513 | local_pref = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 2514 | |
d62a17ae | 2515 | bgp_default_local_preference_set(bgp, local_pref); |
2516 | bgp_clear_star_soft_in(vty, bgp->name); | |
718e3744 | 2517 | |
d62a17ae | 2518 | return CMD_SUCCESS; |
718e3744 | 2519 | } |
2520 | ||
2521 | DEFUN (no_bgp_default_local_preference, | |
2522 | no_bgp_default_local_preference_cmd, | |
838758ac | 2523 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 2524 | NO_STR |
2525 | "BGP specific commands\n" | |
2526 | "Configure BGP defaults\n" | |
838758ac DW |
2527 | "local preference (higher=more preferred)\n" |
2528 | "Configure default local preference value\n") | |
718e3744 | 2529 | { |
d62a17ae | 2530 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2531 | bgp_default_local_preference_unset(bgp); | |
2532 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2533 | |
d62a17ae | 2534 | return CMD_SUCCESS; |
718e3744 | 2535 | } |
2536 | ||
6b0655a2 | 2537 | |
3f9c7369 DS |
2538 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
2539 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 2540 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
2541 | "BGP specific commands\n" |
2542 | "Configure BGP defaults\n" | |
2543 | "subgroup-pkt-queue-max\n" | |
2544 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 2545 | { |
d62a17ae | 2546 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2547 | int idx_number = 3; | |
d7c0a89a | 2548 | uint32_t max_size; |
8bd9d948 | 2549 | |
d62a17ae | 2550 | max_size = strtoul(argv[idx_number]->arg, NULL, 10); |
3f9c7369 | 2551 | |
d62a17ae | 2552 | bgp_default_subgroup_pkt_queue_max_set(bgp, max_size); |
3f9c7369 | 2553 | |
d62a17ae | 2554 | return CMD_SUCCESS; |
3f9c7369 DS |
2555 | } |
2556 | ||
2557 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
2558 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 2559 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
2560 | NO_STR |
2561 | "BGP specific commands\n" | |
2562 | "Configure BGP defaults\n" | |
838758ac DW |
2563 | "subgroup-pkt-queue-max\n" |
2564 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 2565 | { |
d62a17ae | 2566 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2567 | bgp_default_subgroup_pkt_queue_max_unset(bgp); | |
2568 | return CMD_SUCCESS; | |
8bd9d948 DS |
2569 | } |
2570 | ||
813d4307 | 2571 | |
8bd9d948 DS |
2572 | DEFUN (bgp_rr_allow_outbound_policy, |
2573 | bgp_rr_allow_outbound_policy_cmd, | |
2574 | "bgp route-reflector allow-outbound-policy", | |
2575 | "BGP specific commands\n" | |
2576 | "Allow modifications made by out route-map\n" | |
2577 | "on ibgp neighbors\n") | |
2578 | { | |
d62a17ae | 2579 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2580 | |
d62a17ae | 2581 | if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2582 | bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2583 | update_group_announce_rrclients(bgp); | |
2584 | bgp_clear_star_soft_out(vty, bgp->name); | |
2585 | } | |
8bd9d948 | 2586 | |
d62a17ae | 2587 | return CMD_SUCCESS; |
8bd9d948 DS |
2588 | } |
2589 | ||
2590 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
2591 | no_bgp_rr_allow_outbound_policy_cmd, | |
2592 | "no bgp route-reflector allow-outbound-policy", | |
2593 | NO_STR | |
2594 | "BGP specific commands\n" | |
2595 | "Allow modifications made by out route-map\n" | |
2596 | "on ibgp neighbors\n") | |
2597 | { | |
d62a17ae | 2598 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2599 | |
d62a17ae | 2600 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2601 | bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2602 | update_group_announce_rrclients(bgp); | |
2603 | bgp_clear_star_soft_out(vty, bgp->name); | |
2604 | } | |
8bd9d948 | 2605 | |
d62a17ae | 2606 | return CMD_SUCCESS; |
8bd9d948 DS |
2607 | } |
2608 | ||
f14e6fdb DS |
2609 | DEFUN (bgp_listen_limit, |
2610 | bgp_listen_limit_cmd, | |
9ccf14f7 | 2611 | "bgp listen limit (1-5000)", |
f14e6fdb DS |
2612 | "BGP specific commands\n" |
2613 | "Configure BGP defaults\n" | |
2614 | "maximum number of BGP Dynamic Neighbors that can be created\n" | |
2615 | "Configure Dynamic Neighbors listen limit value\n") | |
2616 | { | |
d62a17ae | 2617 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2618 | int idx_number = 3; | |
2619 | int listen_limit; | |
f14e6fdb | 2620 | |
d62a17ae | 2621 | listen_limit = strtoul(argv[idx_number]->arg, NULL, 10); |
f14e6fdb | 2622 | |
d62a17ae | 2623 | bgp_listen_limit_set(bgp, listen_limit); |
f14e6fdb | 2624 | |
d62a17ae | 2625 | return CMD_SUCCESS; |
f14e6fdb DS |
2626 | } |
2627 | ||
2628 | DEFUN (no_bgp_listen_limit, | |
2629 | no_bgp_listen_limit_cmd, | |
838758ac | 2630 | "no bgp listen limit [(1-5000)]", |
f14e6fdb DS |
2631 | "BGP specific commands\n" |
2632 | "Configure BGP defaults\n" | |
2633 | "unset maximum number of BGP Dynamic Neighbors that can be created\n" | |
838758ac DW |
2634 | "Configure Dynamic Neighbors listen limit value to default\n" |
2635 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 2636 | { |
d62a17ae | 2637 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2638 | bgp_listen_limit_unset(bgp); | |
2639 | return CMD_SUCCESS; | |
f14e6fdb DS |
2640 | } |
2641 | ||
2642 | ||
20eb8864 | 2643 | /* |
2644 | * Check if this listen range is already configured. Check for exact | |
2645 | * match or overlap based on input. | |
2646 | */ | |
d62a17ae | 2647 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
2648 | struct prefix *range, int exact) | |
2649 | { | |
2650 | struct listnode *node, *nnode; | |
2651 | struct listnode *node1, *nnode1; | |
2652 | struct peer_group *group; | |
2653 | struct prefix *lr; | |
2654 | afi_t afi; | |
2655 | int match; | |
2656 | ||
2657 | afi = family2afi(range->family); | |
2658 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2659 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
2660 | lr)) { | |
2661 | if (exact) | |
2662 | match = prefix_same(range, lr); | |
2663 | else | |
2664 | match = (prefix_match(range, lr) | |
2665 | || prefix_match(lr, range)); | |
2666 | if (match) | |
2667 | return group; | |
2668 | } | |
2669 | } | |
2670 | ||
2671 | return NULL; | |
20eb8864 | 2672 | } |
2673 | ||
f14e6fdb DS |
2674 | DEFUN (bgp_listen_range, |
2675 | bgp_listen_range_cmd, | |
d7b9898c | 2676 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
f14e6fdb | 2677 | "BGP specific commands\n" |
d7fa34c1 QY |
2678 | "Configure BGP dynamic neighbors listen range\n" |
2679 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
2680 | NEIGHBOR_ADDR_STR |
2681 | "Member of the peer-group\n" | |
2682 | "Peer-group name\n") | |
f14e6fdb | 2683 | { |
d62a17ae | 2684 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2685 | struct prefix range; | |
2686 | struct peer_group *group, *existing_group; | |
2687 | afi_t afi; | |
2688 | int ret; | |
2689 | int idx = 0; | |
2690 | ||
2691 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2692 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2693 | char *prefix = argv[idx]->arg; | |
d7b9898c | 2694 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 2695 | char *peergroup = argv[idx]->arg; |
2696 | ||
2697 | /* Convert IP prefix string to struct prefix. */ | |
2698 | ret = str2prefix(prefix, &range); | |
2699 | if (!ret) { | |
2700 | vty_out(vty, "%% Malformed listen range\n"); | |
2701 | return CMD_WARNING_CONFIG_FAILED; | |
2702 | } | |
2703 | ||
2704 | afi = family2afi(range.family); | |
2705 | ||
2706 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2707 | vty_out(vty, | |
2708 | "%% Malformed listen range (link-local address)\n"); | |
2709 | return CMD_WARNING_CONFIG_FAILED; | |
2710 | } | |
2711 | ||
2712 | apply_mask(&range); | |
2713 | ||
2714 | /* Check if same listen range is already configured. */ | |
2715 | existing_group = listen_range_exists(bgp, &range, 1); | |
2716 | if (existing_group) { | |
2717 | if (strcmp(existing_group->name, peergroup) == 0) | |
2718 | return CMD_SUCCESS; | |
2719 | else { | |
2720 | vty_out(vty, | |
2721 | "%% Same listen range is attached to peer-group %s\n", | |
2722 | existing_group->name); | |
2723 | return CMD_WARNING_CONFIG_FAILED; | |
2724 | } | |
2725 | } | |
2726 | ||
2727 | /* Check if an overlapping listen range exists. */ | |
2728 | if (listen_range_exists(bgp, &range, 0)) { | |
2729 | vty_out(vty, | |
2730 | "%% Listen range overlaps with existing listen range\n"); | |
2731 | return CMD_WARNING_CONFIG_FAILED; | |
2732 | } | |
2733 | ||
2734 | group = peer_group_lookup(bgp, peergroup); | |
2735 | if (!group) { | |
2736 | vty_out(vty, "%% Configure the peer-group first\n"); | |
2737 | return CMD_WARNING_CONFIG_FAILED; | |
2738 | } | |
2739 | ||
2740 | ret = peer_group_listen_range_add(group, &range); | |
2741 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
2742 | } |
2743 | ||
2744 | DEFUN (no_bgp_listen_range, | |
2745 | no_bgp_listen_range_cmd, | |
d7b9898c | 2746 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
d7fa34c1 | 2747 | NO_STR |
f14e6fdb | 2748 | "BGP specific commands\n" |
d7fa34c1 QY |
2749 | "Unconfigure BGP dynamic neighbors listen range\n" |
2750 | "Unconfigure BGP dynamic neighbors listen range\n" | |
2751 | NEIGHBOR_ADDR_STR | |
2752 | "Member of the peer-group\n" | |
2753 | "Peer-group name\n") | |
f14e6fdb | 2754 | { |
d62a17ae | 2755 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2756 | struct prefix range; | |
2757 | struct peer_group *group; | |
2758 | afi_t afi; | |
2759 | int ret; | |
2760 | int idx = 0; | |
2761 | ||
2762 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2763 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2764 | char *prefix = argv[idx]->arg; | |
2765 | argv_find(argv, argc, "WORD", &idx); | |
2766 | char *peergroup = argv[idx]->arg; | |
2767 | ||
2768 | /* Convert IP prefix string to struct prefix. */ | |
2769 | ret = str2prefix(prefix, &range); | |
2770 | if (!ret) { | |
2771 | vty_out(vty, "%% Malformed listen range\n"); | |
2772 | return CMD_WARNING_CONFIG_FAILED; | |
2773 | } | |
2774 | ||
2775 | afi = family2afi(range.family); | |
2776 | ||
2777 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2778 | vty_out(vty, | |
2779 | "%% Malformed listen range (link-local address)\n"); | |
2780 | return CMD_WARNING_CONFIG_FAILED; | |
2781 | } | |
2782 | ||
2783 | apply_mask(&range); | |
2784 | ||
2785 | group = peer_group_lookup(bgp, peergroup); | |
2786 | if (!group) { | |
2787 | vty_out(vty, "%% Peer-group does not exist\n"); | |
2788 | return CMD_WARNING_CONFIG_FAILED; | |
2789 | } | |
2790 | ||
2791 | ret = peer_group_listen_range_del(group, &range); | |
2792 | return bgp_vty_return(vty, ret); | |
2793 | } | |
2794 | ||
2b791107 | 2795 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 2796 | { |
2797 | struct peer_group *group; | |
2798 | struct listnode *node, *nnode, *rnode, *nrnode; | |
2799 | struct prefix *range; | |
2800 | afi_t afi; | |
2801 | char buf[PREFIX2STR_BUFFER]; | |
2802 | ||
2803 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
2804 | vty_out(vty, " bgp listen limit %d\n", | |
2805 | bgp->dynamic_neighbors_limit); | |
2806 | ||
2807 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2808 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
2809 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
2810 | nrnode, range)) { | |
2811 | prefix2str(range, buf, sizeof(buf)); | |
2812 | vty_out(vty, | |
2813 | " bgp listen range %s peer-group %s\n", | |
2814 | buf, group->name); | |
2815 | } | |
2816 | } | |
2817 | } | |
f14e6fdb DS |
2818 | } |
2819 | ||
2820 | ||
907f92c8 DS |
2821 | DEFUN (bgp_disable_connected_route_check, |
2822 | bgp_disable_connected_route_check_cmd, | |
2823 | "bgp disable-ebgp-connected-route-check", | |
2824 | "BGP specific commands\n" | |
2825 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2826 | { | |
d62a17ae | 2827 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2828 | bgp_flag_set(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2829 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2830 | |
d62a17ae | 2831 | return CMD_SUCCESS; |
907f92c8 DS |
2832 | } |
2833 | ||
2834 | DEFUN (no_bgp_disable_connected_route_check, | |
2835 | no_bgp_disable_connected_route_check_cmd, | |
2836 | "no bgp disable-ebgp-connected-route-check", | |
2837 | NO_STR | |
2838 | "BGP specific commands\n" | |
2839 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2840 | { | |
d62a17ae | 2841 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2842 | bgp_flag_unset(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2843 | bgp_clear_star_soft_in(vty, bgp->name); | |
2844 | ||
2845 | return CMD_SUCCESS; | |
2846 | } | |
2847 | ||
2848 | ||
2849 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, | |
2850 | const char *as_str, afi_t afi, safi_t safi) | |
2851 | { | |
2852 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2853 | int ret; | |
2854 | as_t as; | |
2855 | int as_type = AS_SPECIFIED; | |
2856 | union sockunion su; | |
2857 | ||
2858 | if (as_str[0] == 'i') { | |
2859 | as = 0; | |
2860 | as_type = AS_INTERNAL; | |
2861 | } else if (as_str[0] == 'e') { | |
2862 | as = 0; | |
2863 | as_type = AS_EXTERNAL; | |
2864 | } else { | |
2865 | /* Get AS number. */ | |
2866 | as = strtoul(as_str, NULL, 10); | |
2867 | } | |
2868 | ||
390485fd | 2869 | /* If peer is peer group or interface peer, call proper function. */ |
d62a17ae | 2870 | ret = str2sockunion(peer_str, &su); |
2871 | if (ret < 0) { | |
390485fd DS |
2872 | struct peer *peer; |
2873 | ||
2874 | /* Check if existing interface peer */ | |
2875 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
2876 | ||
d62a17ae | 2877 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type, afi, |
2878 | safi); | |
390485fd DS |
2879 | |
2880 | /* if not interface peer, check peer-group settings */ | |
2881 | if (ret < 0 && !peer) { | |
d62a17ae | 2882 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); |
2883 | if (ret < 0) { | |
2884 | vty_out(vty, | |
390485fd | 2885 | "%% Create the peer-group or interface first\n"); |
d62a17ae | 2886 | return CMD_WARNING_CONFIG_FAILED; |
2887 | } | |
2888 | return CMD_SUCCESS; | |
2889 | } | |
2890 | } else { | |
2891 | if (peer_address_self_check(bgp, &su)) { | |
2892 | vty_out(vty, | |
2893 | "%% Can not configure the local system as neighbor\n"); | |
2894 | return CMD_WARNING_CONFIG_FAILED; | |
2895 | } | |
2896 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type, afi, safi); | |
2897 | } | |
2898 | ||
2899 | /* This peer belongs to peer group. */ | |
2900 | switch (ret) { | |
2901 | case BGP_ERR_PEER_GROUP_MEMBER: | |
2902 | vty_out(vty, | |
faa16034 | 2903 | "%% Peer-group member cannot override remote-as of peer-group\n"); |
d62a17ae | 2904 | return CMD_WARNING_CONFIG_FAILED; |
2905 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
2906 | vty_out(vty, | |
faa16034 | 2907 | "%% Peer-group members must be all internal or all external\n"); |
d62a17ae | 2908 | return CMD_WARNING_CONFIG_FAILED; |
2909 | } | |
2910 | return bgp_vty_return(vty, ret); | |
718e3744 | 2911 | } |
2912 | ||
f26845f9 QY |
2913 | DEFUN (bgp_default_shutdown, |
2914 | bgp_default_shutdown_cmd, | |
2915 | "[no] bgp default shutdown", | |
2916 | NO_STR | |
2917 | BGP_STR | |
2918 | "Configure BGP defaults\n" | |
b012cbe2 | 2919 | "Apply administrative shutdown to newly configured peers\n") |
f26845f9 QY |
2920 | { |
2921 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2922 | bgp->autoshutdown = !strmatch(argv[0]->text, "no"); | |
2923 | return CMD_SUCCESS; | |
2924 | } | |
2925 | ||
718e3744 | 2926 | DEFUN (neighbor_remote_as, |
2927 | neighbor_remote_as_cmd, | |
3a2d747c | 2928 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2929 | NEIGHBOR_STR |
2930 | NEIGHBOR_ADDR_STR2 | |
2931 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 2932 | AS_STR |
3a2d747c QY |
2933 | "Internal BGP peer\n" |
2934 | "External BGP peer\n") | |
718e3744 | 2935 | { |
d62a17ae | 2936 | int idx_peer = 1; |
2937 | int idx_remote_as = 3; | |
2938 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, | |
2939 | argv[idx_remote_as]->arg, AFI_IP, | |
2940 | SAFI_UNICAST); | |
2941 | } | |
2942 | ||
2943 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, | |
2944 | afi_t afi, safi_t safi, int v6only, | |
2945 | const char *peer_group_name, | |
2946 | const char *as_str) | |
2947 | { | |
2948 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2949 | as_t as = 0; | |
2950 | int as_type = AS_UNSPECIFIED; | |
2951 | struct peer *peer; | |
2952 | struct peer_group *group; | |
2953 | int ret = 0; | |
2954 | union sockunion su; | |
2955 | ||
2956 | group = peer_group_lookup(bgp, conf_if); | |
2957 | ||
2958 | if (group) { | |
2959 | vty_out(vty, "%% Name conflict with peer-group \n"); | |
2960 | return CMD_WARNING_CONFIG_FAILED; | |
2961 | } | |
2962 | ||
2963 | if (as_str) { | |
2964 | if (as_str[0] == 'i') { | |
2965 | as_type = AS_INTERNAL; | |
2966 | } else if (as_str[0] == 'e') { | |
2967 | as_type = AS_EXTERNAL; | |
2968 | } else { | |
2969 | /* Get AS number. */ | |
2970 | as = strtoul(as_str, NULL, 10); | |
2971 | as_type = AS_SPECIFIED; | |
2972 | } | |
2973 | } | |
2974 | ||
2975 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
2976 | if (peer) { | |
2977 | if (as_str) | |
cc4d4ce8 | 2978 | ret = peer_remote_as(bgp, NULL, conf_if, &as, as_type, |
d62a17ae | 2979 | afi, safi); |
2980 | } else { | |
2981 | if (bgp_flag_check(bgp, BGP_FLAG_NO_DEFAULT_IPV4) | |
2982 | && afi == AFI_IP && safi == SAFI_UNICAST) | |
2983 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
2984 | as_type, 0, 0, NULL); | |
2985 | else | |
2986 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
2987 | as_type, afi, safi, NULL); | |
2988 | ||
2989 | if (!peer) { | |
2990 | vty_out(vty, "%% BGP failed to create peer\n"); | |
2991 | return CMD_WARNING_CONFIG_FAILED; | |
2992 | } | |
2993 | ||
2994 | if (v6only) | |
527de3dc | 2995 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 2996 | |
2997 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
2998 | * this | |
2999 | * any unnumbered peer in order to not worry about run-time | |
3000 | * transitions | |
3001 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
3002 | * address | |
3003 | * gets deleted later etc.) | |
3004 | */ | |
3005 | if (peer->ifp) | |
3006 | bgp_zebra_initiate_radv(bgp, peer); | |
3007 | } | |
3008 | ||
3009 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
3010 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
3011 | if (v6only) | |
527de3dc | 3012 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 3013 | else |
527de3dc | 3014 | peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 3015 | |
3016 | /* v6only flag changed. Reset bgp seesion */ | |
3017 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
3018 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
3019 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
3020 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
3021 | } else | |
3022 | bgp_session_reset(peer); | |
3023 | } | |
3024 | ||
9fb964de PM |
3025 | if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) { |
3026 | SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE); | |
3027 | SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE); | |
dc2f50f3 | 3028 | SET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE); |
9fb964de | 3029 | } |
d62a17ae | 3030 | |
3031 | if (peer_group_name) { | |
3032 | group = peer_group_lookup(bgp, peer_group_name); | |
3033 | if (!group) { | |
3034 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3035 | return CMD_WARNING_CONFIG_FAILED; | |
3036 | } | |
3037 | ||
3038 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
3039 | } | |
3040 | ||
3041 | return bgp_vty_return(vty, ret); | |
a80beece DS |
3042 | } |
3043 | ||
4c48cf63 DW |
3044 | DEFUN (neighbor_interface_config, |
3045 | neighbor_interface_config_cmd, | |
d7b9898c | 3046 | "neighbor WORD interface [peer-group PGNAME]", |
4c48cf63 DW |
3047 | NEIGHBOR_STR |
3048 | "Interface name or neighbor tag\n" | |
31500417 DW |
3049 | "Enable BGP on interface\n" |
3050 | "Member of the peer-group\n" | |
16cedbb0 | 3051 | "Peer-group name\n") |
4c48cf63 | 3052 | { |
d62a17ae | 3053 | int idx_word = 1; |
3054 | int idx_peer_group_word = 4; | |
31500417 | 3055 | |
d62a17ae | 3056 | if (argc > idx_peer_group_word) |
3057 | return peer_conf_interface_get( | |
3058 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
3059 | argv[idx_peer_group_word]->arg, NULL); | |
3060 | else | |
3061 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3062 | SAFI_UNICAST, 0, NULL, NULL); | |
4c48cf63 DW |
3063 | } |
3064 | ||
4c48cf63 DW |
3065 | DEFUN (neighbor_interface_config_v6only, |
3066 | neighbor_interface_config_v6only_cmd, | |
d7b9898c | 3067 | "neighbor WORD interface v6only [peer-group PGNAME]", |
4c48cf63 DW |
3068 | NEIGHBOR_STR |
3069 | "Interface name or neighbor tag\n" | |
3070 | "Enable BGP on interface\n" | |
31500417 DW |
3071 | "Enable BGP with v6 link-local only\n" |
3072 | "Member of the peer-group\n" | |
16cedbb0 | 3073 | "Peer-group name\n") |
4c48cf63 | 3074 | { |
d62a17ae | 3075 | int idx_word = 1; |
3076 | int idx_peer_group_word = 5; | |
31500417 | 3077 | |
d62a17ae | 3078 | if (argc > idx_peer_group_word) |
3079 | return peer_conf_interface_get( | |
3080 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
3081 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 3082 | |
d62a17ae | 3083 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, |
3084 | SAFI_UNICAST, 1, NULL, NULL); | |
4c48cf63 DW |
3085 | } |
3086 | ||
a80beece | 3087 | |
b3a39dc5 DD |
3088 | DEFUN (neighbor_interface_config_remote_as, |
3089 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 3090 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
3091 | NEIGHBOR_STR |
3092 | "Interface name or neighbor tag\n" | |
3093 | "Enable BGP on interface\n" | |
3a2d747c | 3094 | "Specify a BGP neighbor\n" |
d7fa34c1 | 3095 | AS_STR |
3a2d747c QY |
3096 | "Internal BGP peer\n" |
3097 | "External BGP peer\n") | |
b3a39dc5 | 3098 | { |
d62a17ae | 3099 | int idx_word = 1; |
3100 | int idx_remote_as = 4; | |
3101 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3102 | SAFI_UNICAST, 0, NULL, | |
3103 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
3104 | } |
3105 | ||
3106 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
3107 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 3108 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
3109 | NEIGHBOR_STR |
3110 | "Interface name or neighbor tag\n" | |
3a2d747c | 3111 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 3112 | "Enable BGP on interface\n" |
3a2d747c | 3113 | "Specify a BGP neighbor\n" |
d7fa34c1 | 3114 | AS_STR |
3a2d747c QY |
3115 | "Internal BGP peer\n" |
3116 | "External BGP peer\n") | |
b3a39dc5 | 3117 | { |
d62a17ae | 3118 | int idx_word = 1; |
3119 | int idx_remote_as = 5; | |
3120 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3121 | SAFI_UNICAST, 1, NULL, | |
3122 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
3123 | } |
3124 | ||
718e3744 | 3125 | DEFUN (neighbor_peer_group, |
3126 | neighbor_peer_group_cmd, | |
3127 | "neighbor WORD peer-group", | |
3128 | NEIGHBOR_STR | |
a80beece | 3129 | "Interface name or neighbor tag\n" |
718e3744 | 3130 | "Configure peer-group\n") |
3131 | { | |
d62a17ae | 3132 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3133 | int idx_word = 1; | |
3134 | struct peer *peer; | |
3135 | struct peer_group *group; | |
718e3744 | 3136 | |
d62a17ae | 3137 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
3138 | if (peer) { | |
3139 | vty_out(vty, "%% Name conflict with interface: \n"); | |
3140 | return CMD_WARNING_CONFIG_FAILED; | |
3141 | } | |
718e3744 | 3142 | |
d62a17ae | 3143 | group = peer_group_get(bgp, argv[idx_word]->arg); |
3144 | if (!group) { | |
3145 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
3146 | return CMD_WARNING_CONFIG_FAILED; | |
3147 | } | |
718e3744 | 3148 | |
d62a17ae | 3149 | return CMD_SUCCESS; |
718e3744 | 3150 | } |
3151 | ||
3152 | DEFUN (no_neighbor, | |
3153 | no_neighbor_cmd, | |
dab8cd00 | 3154 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 3155 | NO_STR |
3156 | NEIGHBOR_STR | |
3a2d747c QY |
3157 | NEIGHBOR_ADDR_STR2 |
3158 | "Specify a BGP neighbor\n" | |
3159 | AS_STR | |
3160 | "Internal BGP peer\n" | |
3161 | "External BGP peer\n") | |
718e3744 | 3162 | { |
d62a17ae | 3163 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3164 | int idx_peer = 2; | |
3165 | int ret; | |
3166 | union sockunion su; | |
3167 | struct peer_group *group; | |
3168 | struct peer *peer; | |
3169 | struct peer *other; | |
3170 | ||
3171 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
3172 | if (ret < 0) { | |
3173 | /* look up for neighbor by interface name config. */ | |
3174 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3175 | if (peer) { | |
3176 | /* Request zebra to terminate IPv6 RAs on this | |
3177 | * interface. */ | |
3178 | if (peer->ifp) | |
3179 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
3180 | peer_delete(peer); | |
3181 | return CMD_SUCCESS; | |
3182 | } | |
f14e6fdb | 3183 | |
d62a17ae | 3184 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); |
3185 | if (group) | |
3186 | peer_group_delete(group); | |
3187 | else { | |
3188 | vty_out(vty, "%% Create the peer-group first\n"); | |
3189 | return CMD_WARNING_CONFIG_FAILED; | |
3190 | } | |
3191 | } else { | |
3192 | peer = peer_lookup(bgp, &su); | |
3193 | if (peer) { | |
3194 | if (peer_dynamic_neighbor(peer)) { | |
3195 | vty_out(vty, | |
3196 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3197 | return CMD_WARNING_CONFIG_FAILED; | |
3198 | } | |
3199 | ||
3200 | other = peer->doppelganger; | |
3201 | peer_delete(peer); | |
3202 | if (other && other->status != Deleted) | |
3203 | peer_delete(other); | |
3204 | } | |
1ff9a340 | 3205 | } |
718e3744 | 3206 | |
d62a17ae | 3207 | return CMD_SUCCESS; |
718e3744 | 3208 | } |
3209 | ||
a80beece DS |
3210 | DEFUN (no_neighbor_interface_config, |
3211 | no_neighbor_interface_config_cmd, | |
d7b9898c | 3212 | "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
3213 | NO_STR |
3214 | NEIGHBOR_STR | |
3215 | "Interface name\n" | |
31500417 DW |
3216 | "Configure BGP on interface\n" |
3217 | "Enable BGP with v6 link-local only\n" | |
3218 | "Member of the peer-group\n" | |
16cedbb0 | 3219 | "Peer-group name\n" |
3a2d747c QY |
3220 | "Specify a BGP neighbor\n" |
3221 | AS_STR | |
3222 | "Internal BGP peer\n" | |
3223 | "External BGP peer\n") | |
a80beece | 3224 | { |
d62a17ae | 3225 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3226 | int idx_word = 2; | |
3227 | struct peer *peer; | |
3228 | ||
3229 | /* look up for neighbor by interface name config. */ | |
3230 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3231 | if (peer) { | |
3232 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
3233 | if (peer->ifp) | |
3234 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
3235 | peer_delete(peer); | |
3236 | } else { | |
3237 | vty_out(vty, "%% Create the bgp interface first\n"); | |
3238 | return CMD_WARNING_CONFIG_FAILED; | |
3239 | } | |
3240 | return CMD_SUCCESS; | |
a80beece DS |
3241 | } |
3242 | ||
718e3744 | 3243 | DEFUN (no_neighbor_peer_group, |
3244 | no_neighbor_peer_group_cmd, | |
3245 | "no neighbor WORD peer-group", | |
3246 | NO_STR | |
3247 | NEIGHBOR_STR | |
3248 | "Neighbor tag\n" | |
3249 | "Configure peer-group\n") | |
3250 | { | |
d62a17ae | 3251 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3252 | int idx_word = 2; | |
3253 | struct peer_group *group; | |
718e3744 | 3254 | |
d62a17ae | 3255 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
3256 | if (group) | |
3257 | peer_group_delete(group); | |
3258 | else { | |
3259 | vty_out(vty, "%% Create the peer-group first\n"); | |
3260 | return CMD_WARNING_CONFIG_FAILED; | |
3261 | } | |
3262 | return CMD_SUCCESS; | |
718e3744 | 3263 | } |
3264 | ||
a80beece DS |
3265 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
3266 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 3267 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3268 | NO_STR |
3269 | NEIGHBOR_STR | |
a80beece | 3270 | "Interface name or neighbor tag\n" |
718e3744 | 3271 | "Specify a BGP neighbor\n" |
3a2d747c QY |
3272 | AS_STR |
3273 | "Internal BGP peer\n" | |
3274 | "External BGP peer\n") | |
718e3744 | 3275 | { |
d62a17ae | 3276 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3277 | int idx_word = 2; | |
3278 | struct peer_group *group; | |
3279 | struct peer *peer; | |
3280 | ||
3281 | /* look up for neighbor by interface name config. */ | |
3282 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3283 | if (peer) { | |
390485fd | 3284 | peer_as_change(peer, 0, AS_UNSPECIFIED); |
d62a17ae | 3285 | return CMD_SUCCESS; |
3286 | } | |
3287 | ||
3288 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3289 | if (group) | |
3290 | peer_group_remote_as_delete(group); | |
3291 | else { | |
3292 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
3293 | return CMD_WARNING_CONFIG_FAILED; | |
3294 | } | |
3295 | return CMD_SUCCESS; | |
718e3744 | 3296 | } |
6b0655a2 | 3297 | |
718e3744 | 3298 | DEFUN (neighbor_local_as, |
3299 | neighbor_local_as_cmd, | |
9ccf14f7 | 3300 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 3301 | NEIGHBOR_STR |
3302 | NEIGHBOR_ADDR_STR2 | |
3303 | "Specify a local-as number\n" | |
3304 | "AS number used as local AS\n") | |
3305 | { | |
d62a17ae | 3306 | int idx_peer = 1; |
3307 | int idx_number = 3; | |
3308 | struct peer *peer; | |
3309 | int ret; | |
3310 | as_t as; | |
718e3744 | 3311 | |
d62a17ae | 3312 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3313 | if (!peer) | |
3314 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3315 | |
d62a17ae | 3316 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3317 | ret = peer_local_as_set(peer, as, 0, 0); | |
3318 | return bgp_vty_return(vty, ret); | |
718e3744 | 3319 | } |
3320 | ||
3321 | DEFUN (neighbor_local_as_no_prepend, | |
3322 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 3323 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 3324 | NEIGHBOR_STR |
3325 | NEIGHBOR_ADDR_STR2 | |
3326 | "Specify a local-as number\n" | |
3327 | "AS number used as local AS\n" | |
3328 | "Do not prepend local-as to updates from ebgp peers\n") | |
3329 | { | |
d62a17ae | 3330 | int idx_peer = 1; |
3331 | int idx_number = 3; | |
3332 | struct peer *peer; | |
3333 | int ret; | |
3334 | as_t as; | |
718e3744 | 3335 | |
d62a17ae | 3336 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3337 | if (!peer) | |
3338 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3339 | |
d62a17ae | 3340 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3341 | ret = peer_local_as_set(peer, as, 1, 0); | |
3342 | return bgp_vty_return(vty, ret); | |
718e3744 | 3343 | } |
3344 | ||
9d3f9705 AC |
3345 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
3346 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 3347 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
3348 | NEIGHBOR_STR |
3349 | NEIGHBOR_ADDR_STR2 | |
3350 | "Specify a local-as number\n" | |
3351 | "AS number used as local AS\n" | |
3352 | "Do not prepend local-as to updates from ebgp peers\n" | |
3353 | "Do not prepend local-as to updates from ibgp peers\n") | |
3354 | { | |
d62a17ae | 3355 | int idx_peer = 1; |
3356 | int idx_number = 3; | |
3357 | struct peer *peer; | |
3358 | int ret; | |
3359 | as_t as; | |
9d3f9705 | 3360 | |
d62a17ae | 3361 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3362 | if (!peer) | |
3363 | return CMD_WARNING_CONFIG_FAILED; | |
9d3f9705 | 3364 | |
d62a17ae | 3365 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3366 | ret = peer_local_as_set(peer, as, 1, 1); | |
3367 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
3368 | } |
3369 | ||
718e3744 | 3370 | DEFUN (no_neighbor_local_as, |
3371 | no_neighbor_local_as_cmd, | |
a636c635 | 3372 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 3373 | NO_STR |
3374 | NEIGHBOR_STR | |
3375 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
3376 | "Specify a local-as number\n" |
3377 | "AS number used as local AS\n" | |
3378 | "Do not prepend local-as to updates from ebgp peers\n" | |
3379 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 3380 | { |
d62a17ae | 3381 | int idx_peer = 2; |
3382 | struct peer *peer; | |
3383 | int ret; | |
718e3744 | 3384 | |
d62a17ae | 3385 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3386 | if (!peer) | |
3387 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3388 | |
d62a17ae | 3389 | ret = peer_local_as_unset(peer); |
3390 | return bgp_vty_return(vty, ret); | |
718e3744 | 3391 | } |
3392 | ||
718e3744 | 3393 | |
3f9c7369 DS |
3394 | DEFUN (neighbor_solo, |
3395 | neighbor_solo_cmd, | |
9ccf14f7 | 3396 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3397 | NEIGHBOR_STR |
3398 | NEIGHBOR_ADDR_STR2 | |
3399 | "Solo peer - part of its own update group\n") | |
3400 | { | |
d62a17ae | 3401 | int idx_peer = 1; |
3402 | struct peer *peer; | |
3403 | int ret; | |
3f9c7369 | 3404 | |
d62a17ae | 3405 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3406 | if (!peer) | |
3407 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3408 | |
d62a17ae | 3409 | ret = update_group_adjust_soloness(peer, 1); |
3410 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3411 | } |
3412 | ||
3413 | DEFUN (no_neighbor_solo, | |
3414 | no_neighbor_solo_cmd, | |
9ccf14f7 | 3415 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3416 | NO_STR |
3417 | NEIGHBOR_STR | |
3418 | NEIGHBOR_ADDR_STR2 | |
3419 | "Solo peer - part of its own update group\n") | |
3420 | { | |
d62a17ae | 3421 | int idx_peer = 2; |
3422 | struct peer *peer; | |
3423 | int ret; | |
3f9c7369 | 3424 | |
d62a17ae | 3425 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3426 | if (!peer) | |
3427 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3428 | |
d62a17ae | 3429 | ret = update_group_adjust_soloness(peer, 0); |
3430 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3431 | } |
3432 | ||
0df7c91f PJ |
3433 | DEFUN (neighbor_password, |
3434 | neighbor_password_cmd, | |
9ccf14f7 | 3435 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
3436 | NEIGHBOR_STR |
3437 | NEIGHBOR_ADDR_STR2 | |
3438 | "Set a password\n" | |
3439 | "The password\n") | |
3440 | { | |
d62a17ae | 3441 | int idx_peer = 1; |
3442 | int idx_line = 3; | |
3443 | struct peer *peer; | |
3444 | int ret; | |
0df7c91f | 3445 | |
d62a17ae | 3446 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3447 | if (!peer) | |
3448 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3449 | |
d62a17ae | 3450 | ret = peer_password_set(peer, argv[idx_line]->arg); |
3451 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
3452 | } |
3453 | ||
3454 | DEFUN (no_neighbor_password, | |
3455 | no_neighbor_password_cmd, | |
a636c635 | 3456 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
3457 | NO_STR |
3458 | NEIGHBOR_STR | |
3459 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
3460 | "Set a password\n" |
3461 | "The password\n") | |
0df7c91f | 3462 | { |
d62a17ae | 3463 | int idx_peer = 2; |
3464 | struct peer *peer; | |
3465 | int ret; | |
0df7c91f | 3466 | |
d62a17ae | 3467 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3468 | if (!peer) | |
3469 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3470 | |
d62a17ae | 3471 | ret = peer_password_unset(peer); |
3472 | return bgp_vty_return(vty, ret); | |
0df7c91f | 3473 | } |
6b0655a2 | 3474 | |
718e3744 | 3475 | DEFUN (neighbor_activate, |
3476 | neighbor_activate_cmd, | |
9ccf14f7 | 3477 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3478 | NEIGHBOR_STR |
3479 | NEIGHBOR_ADDR_STR2 | |
3480 | "Enable the Address Family for this Neighbor\n") | |
3481 | { | |
d62a17ae | 3482 | int idx_peer = 1; |
3483 | int ret; | |
3484 | struct peer *peer; | |
718e3744 | 3485 | |
d62a17ae | 3486 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3487 | if (!peer) | |
3488 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3489 | |
d62a17ae | 3490 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3491 | return bgp_vty_return(vty, ret); | |
718e3744 | 3492 | } |
3493 | ||
d62a17ae | 3494 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
3495 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3496 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3497 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3498 | |
718e3744 | 3499 | DEFUN (no_neighbor_activate, |
3500 | no_neighbor_activate_cmd, | |
9ccf14f7 | 3501 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3502 | NO_STR |
3503 | NEIGHBOR_STR | |
3504 | NEIGHBOR_ADDR_STR2 | |
3505 | "Enable the Address Family for this Neighbor\n") | |
3506 | { | |
d62a17ae | 3507 | int idx_peer = 2; |
3508 | int ret; | |
3509 | struct peer *peer; | |
718e3744 | 3510 | |
d62a17ae | 3511 | /* Lookup peer. */ |
3512 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3513 | if (!peer) | |
3514 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3515 | |
d62a17ae | 3516 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3517 | return bgp_vty_return(vty, ret); | |
718e3744 | 3518 | } |
6b0655a2 | 3519 | |
d62a17ae | 3520 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
3521 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3522 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3523 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3524 | |
718e3744 | 3525 | DEFUN (neighbor_set_peer_group, |
3526 | neighbor_set_peer_group_cmd, | |
d7b9898c | 3527 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
718e3744 | 3528 | NEIGHBOR_STR |
a80beece | 3529 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3530 | "Member of the peer-group\n" |
16cedbb0 | 3531 | "Peer-group name\n") |
718e3744 | 3532 | { |
d62a17ae | 3533 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3534 | int idx_peer = 1; | |
3535 | int idx_word = 3; | |
3536 | int ret; | |
3537 | as_t as; | |
3538 | union sockunion su; | |
3539 | struct peer *peer; | |
3540 | struct peer_group *group; | |
3541 | ||
d62a17ae | 3542 | ret = str2sockunion(argv[idx_peer]->arg, &su); |
3543 | if (ret < 0) { | |
3544 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3545 | if (!peer) { | |
3546 | vty_out(vty, "%% Malformed address or name: %s\n", | |
3547 | argv[idx_peer]->arg); | |
3548 | return CMD_WARNING_CONFIG_FAILED; | |
3549 | } | |
3550 | } else { | |
3551 | if (peer_address_self_check(bgp, &su)) { | |
3552 | vty_out(vty, | |
3553 | "%% Can not configure the local system as neighbor\n"); | |
3554 | return CMD_WARNING_CONFIG_FAILED; | |
3555 | } | |
3556 | ||
3557 | /* Disallow for dynamic neighbor. */ | |
3558 | peer = peer_lookup(bgp, &su); | |
3559 | if (peer && peer_dynamic_neighbor(peer)) { | |
3560 | vty_out(vty, | |
3561 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3562 | return CMD_WARNING_CONFIG_FAILED; | |
3563 | } | |
3564 | } | |
3565 | ||
3566 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3567 | if (!group) { | |
3568 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3569 | return CMD_WARNING_CONFIG_FAILED; | |
3570 | } | |
3571 | ||
3572 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
3573 | ||
3574 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { | |
3575 | vty_out(vty, | |
3576 | "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", | |
3577 | as); | |
3578 | return CMD_WARNING_CONFIG_FAILED; | |
3579 | } | |
3580 | ||
3581 | return bgp_vty_return(vty, ret); | |
3582 | } | |
3583 | ||
3584 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
d7b9898c | 3585 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 3586 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
3587 | "Member of the peer-group\n" | |
3588 | "Peer-group name\n") | |
596c17ba | 3589 | |
718e3744 | 3590 | DEFUN (no_neighbor_set_peer_group, |
3591 | no_neighbor_set_peer_group_cmd, | |
d7b9898c | 3592 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
718e3744 | 3593 | NO_STR |
3594 | NEIGHBOR_STR | |
a80beece | 3595 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3596 | "Member of the peer-group\n" |
16cedbb0 | 3597 | "Peer-group name\n") |
718e3744 | 3598 | { |
d62a17ae | 3599 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3600 | int idx_peer = 2; | |
3601 | int idx_word = 4; | |
3602 | int ret; | |
3603 | struct peer *peer; | |
3604 | struct peer_group *group; | |
3605 | ||
3606 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); | |
3607 | if (!peer) | |
3608 | return CMD_WARNING_CONFIG_FAILED; | |
3609 | ||
3610 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3611 | if (!group) { | |
3612 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3613 | return CMD_WARNING_CONFIG_FAILED; | |
3614 | } | |
718e3744 | 3615 | |
827ed707 | 3616 | ret = peer_delete(peer); |
718e3744 | 3617 | |
d62a17ae | 3618 | return bgp_vty_return(vty, ret); |
718e3744 | 3619 | } |
6b0655a2 | 3620 | |
d62a17ae | 3621 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
d7b9898c | 3622 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 3623 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
3624 | "Member of the peer-group\n" | |
3625 | "Peer-group name\n") | |
596c17ba | 3626 | |
d62a17ae | 3627 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 3628 | uint32_t flag, int set) |
718e3744 | 3629 | { |
d62a17ae | 3630 | int ret; |
3631 | struct peer *peer; | |
718e3744 | 3632 | |
d62a17ae | 3633 | peer = peer_and_group_lookup_vty(vty, ip_str); |
3634 | if (!peer) | |
3635 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3636 | |
7ebe625c QY |
3637 | /* |
3638 | * If 'neighbor <interface>', then this is for directly connected peers, | |
3639 | * we should not accept disable-connected-check. | |
3640 | */ | |
3641 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
3642 | vty_out(vty, | |
3643 | "%s is directly connected peer, cannot accept disable-" | |
3644 | "connected-check\n", | |
3645 | ip_str); | |
3646 | return CMD_WARNING_CONFIG_FAILED; | |
3647 | } | |
3648 | ||
d62a17ae | 3649 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
3650 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 3651 | |
d62a17ae | 3652 | if (set) |
3653 | ret = peer_flag_set(peer, flag); | |
3654 | else | |
3655 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 3656 | |
d62a17ae | 3657 | return bgp_vty_return(vty, ret); |
718e3744 | 3658 | } |
3659 | ||
47cbc09b | 3660 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint32_t flag) |
718e3744 | 3661 | { |
d62a17ae | 3662 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 3663 | } |
3664 | ||
d62a17ae | 3665 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 3666 | uint32_t flag) |
718e3744 | 3667 | { |
d62a17ae | 3668 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 3669 | } |
3670 | ||
3671 | /* neighbor passive. */ | |
3672 | DEFUN (neighbor_passive, | |
3673 | neighbor_passive_cmd, | |
9ccf14f7 | 3674 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3675 | NEIGHBOR_STR |
3676 | NEIGHBOR_ADDR_STR2 | |
3677 | "Don't send open messages to this neighbor\n") | |
3678 | { | |
d62a17ae | 3679 | int idx_peer = 1; |
3680 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3681 | } |
3682 | ||
3683 | DEFUN (no_neighbor_passive, | |
3684 | no_neighbor_passive_cmd, | |
9ccf14f7 | 3685 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3686 | NO_STR |
3687 | NEIGHBOR_STR | |
3688 | NEIGHBOR_ADDR_STR2 | |
3689 | "Don't send open messages to this neighbor\n") | |
3690 | { | |
d62a17ae | 3691 | int idx_peer = 2; |
3692 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3693 | } |
6b0655a2 | 3694 | |
718e3744 | 3695 | /* neighbor shutdown. */ |
73d70fa6 DL |
3696 | DEFUN (neighbor_shutdown_msg, |
3697 | neighbor_shutdown_msg_cmd, | |
3698 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
718e3744 | 3699 | NEIGHBOR_STR |
3700 | NEIGHBOR_ADDR_STR2 | |
73d70fa6 DL |
3701 | "Administratively shut down this neighbor\n" |
3702 | "Add a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3703 | "Shutdown message\n") | |
718e3744 | 3704 | { |
d62a17ae | 3705 | int idx_peer = 1; |
73d70fa6 | 3706 | |
d62a17ae | 3707 | if (argc >= 5) { |
3708 | struct peer *peer = | |
3709 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3710 | char *message; | |
73d70fa6 | 3711 | |
d62a17ae | 3712 | if (!peer) |
3713 | return CMD_WARNING_CONFIG_FAILED; | |
3714 | message = argv_concat(argv, argc, 4); | |
3715 | peer_tx_shutdown_message_set(peer, message); | |
3716 | XFREE(MTYPE_TMP, message); | |
3717 | } | |
73d70fa6 | 3718 | |
d62a17ae | 3719 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 3720 | } |
3721 | ||
d62a17ae | 3722 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
3723 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3724 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3725 | "Administratively shut down this neighbor\n") | |
73d70fa6 DL |
3726 | |
3727 | DEFUN (no_neighbor_shutdown_msg, | |
3728 | no_neighbor_shutdown_msg_cmd, | |
3729 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
3730 | NO_STR | |
3731 | NEIGHBOR_STR | |
3732 | NEIGHBOR_ADDR_STR2 | |
3733 | "Administratively shut down this neighbor\n" | |
3734 | "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3735 | "Shutdown message\n") | |
718e3744 | 3736 | { |
d62a17ae | 3737 | int idx_peer = 2; |
73d70fa6 | 3738 | |
d62a17ae | 3739 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
3740 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 3741 | } |
6b0655a2 | 3742 | |
d62a17ae | 3743 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
3744 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3745 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3746 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 3747 | |
718e3744 | 3748 | /* neighbor capability dynamic. */ |
3749 | DEFUN (neighbor_capability_dynamic, | |
3750 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3751 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3752 | NEIGHBOR_STR |
3753 | NEIGHBOR_ADDR_STR2 | |
3754 | "Advertise capability to the peer\n" | |
3755 | "Advertise dynamic capability to this neighbor\n") | |
3756 | { | |
d62a17ae | 3757 | int idx_peer = 1; |
3758 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3759 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3760 | } |
3761 | ||
3762 | DEFUN (no_neighbor_capability_dynamic, | |
3763 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3764 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3765 | NO_STR |
3766 | NEIGHBOR_STR | |
3767 | NEIGHBOR_ADDR_STR2 | |
3768 | "Advertise capability to the peer\n" | |
3769 | "Advertise dynamic capability to this neighbor\n") | |
3770 | { | |
d62a17ae | 3771 | int idx_peer = 2; |
3772 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3773 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3774 | } |
6b0655a2 | 3775 | |
718e3744 | 3776 | /* neighbor dont-capability-negotiate */ |
3777 | DEFUN (neighbor_dont_capability_negotiate, | |
3778 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3779 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3780 | NEIGHBOR_STR |
3781 | NEIGHBOR_ADDR_STR2 | |
3782 | "Do not perform capability negotiation\n") | |
3783 | { | |
d62a17ae | 3784 | int idx_peer = 1; |
3785 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3786 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3787 | } |
3788 | ||
3789 | DEFUN (no_neighbor_dont_capability_negotiate, | |
3790 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3791 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3792 | NO_STR |
3793 | NEIGHBOR_STR | |
3794 | NEIGHBOR_ADDR_STR2 | |
3795 | "Do not perform capability negotiation\n") | |
3796 | { | |
d62a17ae | 3797 | int idx_peer = 2; |
3798 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3799 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3800 | } |
6b0655a2 | 3801 | |
8a92a8a0 DS |
3802 | /* neighbor capability extended next hop encoding */ |
3803 | DEFUN (neighbor_capability_enhe, | |
3804 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3805 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3806 | NEIGHBOR_STR |
3807 | NEIGHBOR_ADDR_STR2 | |
3808 | "Advertise capability to the peer\n" | |
3809 | "Advertise extended next-hop capability to the peer\n") | |
3810 | { | |
d62a17ae | 3811 | int idx_peer = 1; |
3812 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3813 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3814 | } |
3815 | ||
3816 | DEFUN (no_neighbor_capability_enhe, | |
3817 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3818 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3819 | NO_STR |
3820 | NEIGHBOR_STR | |
3821 | NEIGHBOR_ADDR_STR2 | |
3822 | "Advertise capability to the peer\n" | |
3823 | "Advertise extended next-hop capability to the peer\n") | |
3824 | { | |
d62a17ae | 3825 | int idx_peer = 2; |
3826 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3827 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3828 | } |
3829 | ||
d62a17ae | 3830 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3831 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 3832 | int set) |
718e3744 | 3833 | { |
d62a17ae | 3834 | int ret; |
3835 | struct peer *peer; | |
718e3744 | 3836 | |
d62a17ae | 3837 | peer = peer_and_group_lookup_vty(vty, peer_str); |
3838 | if (!peer) | |
3839 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3840 | |
d62a17ae | 3841 | if (set) |
3842 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
3843 | else | |
3844 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 3845 | |
d62a17ae | 3846 | return bgp_vty_return(vty, ret); |
718e3744 | 3847 | } |
3848 | ||
d62a17ae | 3849 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3850 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 3851 | { |
d62a17ae | 3852 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 3853 | } |
3854 | ||
d62a17ae | 3855 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3856 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 3857 | { |
d62a17ae | 3858 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 3859 | } |
6b0655a2 | 3860 | |
718e3744 | 3861 | /* neighbor capability orf prefix-list. */ |
3862 | DEFUN (neighbor_capability_orf_prefix, | |
3863 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3864 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3865 | NEIGHBOR_STR |
3866 | 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") | |
3873 | { | |
d62a17ae | 3874 | int idx_peer = 1; |
3875 | int idx_send_recv = 5; | |
d7c0a89a | 3876 | uint16_t flag = 0; |
d62a17ae | 3877 | |
3878 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3879 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3880 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3881 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3882 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3883 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3884 | else { | |
3885 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3886 | return CMD_WARNING_CONFIG_FAILED; | |
3887 | } | |
3888 | ||
3889 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3890 | bgp_node_safi(vty), flag); | |
3891 | } | |
3892 | ||
3893 | ALIAS_HIDDEN( | |
3894 | neighbor_capability_orf_prefix, | |
3895 | neighbor_capability_orf_prefix_hidden_cmd, | |
3896 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3897 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3898 | "Advertise capability to the peer\n" | |
3899 | "Advertise ORF capability to the peer\n" | |
3900 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3901 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3902 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3903 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 3904 | |
718e3744 | 3905 | DEFUN (no_neighbor_capability_orf_prefix, |
3906 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3907 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3908 | NO_STR |
3909 | NEIGHBOR_STR | |
3910 | NEIGHBOR_ADDR_STR2 | |
3911 | "Advertise capability to the peer\n" | |
3912 | "Advertise ORF capability to the peer\n" | |
3913 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3914 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3915 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3916 | "Capability to SEND the ORF to this neighbor\n") | |
3917 | { | |
d62a17ae | 3918 | int idx_peer = 2; |
3919 | int idx_send_recv = 6; | |
d7c0a89a | 3920 | uint16_t flag = 0; |
d62a17ae | 3921 | |
3922 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3923 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3924 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3925 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3926 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3927 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3928 | else { | |
3929 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3930 | return CMD_WARNING_CONFIG_FAILED; | |
3931 | } | |
3932 | ||
3933 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3934 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3935 | flag); | |
3936 | } | |
3937 | ||
3938 | ALIAS_HIDDEN( | |
3939 | no_neighbor_capability_orf_prefix, | |
3940 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
3941 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3942 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3943 | "Advertise capability to the peer\n" | |
3944 | "Advertise ORF capability to the peer\n" | |
3945 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3946 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3947 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3948 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 3949 | |
718e3744 | 3950 | /* neighbor next-hop-self. */ |
3951 | DEFUN (neighbor_nexthop_self, | |
3952 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3953 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3954 | NEIGHBOR_STR |
3955 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3956 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3957 | { |
d62a17ae | 3958 | int idx_peer = 1; |
3959 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3960 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 3961 | } |
9e7a53c1 | 3962 | |
d62a17ae | 3963 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
3964 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3965 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3966 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 3967 | |
a538debe DS |
3968 | /* neighbor next-hop-self. */ |
3969 | DEFUN (neighbor_nexthop_self_force, | |
3970 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 3971 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3972 | NEIGHBOR_STR |
3973 | NEIGHBOR_ADDR_STR2 | |
3974 | "Disable the next hop calculation for this neighbor\n" | |
3975 | "Set the next hop to self for reflected routes\n") | |
3976 | { | |
d62a17ae | 3977 | int idx_peer = 1; |
3978 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3979 | bgp_node_safi(vty), | |
3980 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 3981 | } |
3982 | ||
d62a17ae | 3983 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
3984 | neighbor_nexthop_self_force_hidden_cmd, | |
3985 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3986 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3987 | "Disable the next hop calculation for this neighbor\n" | |
3988 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 3989 | |
1bc4e531 DA |
3990 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
3991 | neighbor_nexthop_self_all_hidden_cmd, | |
3992 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
3993 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3994 | "Disable the next hop calculation for this neighbor\n" | |
3995 | "Set the next hop to self for reflected routes\n") | |
3996 | ||
718e3744 | 3997 | DEFUN (no_neighbor_nexthop_self, |
3998 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3999 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 4000 | NO_STR |
4001 | NEIGHBOR_STR | |
4002 | NEIGHBOR_ADDR_STR2 | |
a538debe | 4003 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 4004 | { |
d62a17ae | 4005 | int idx_peer = 2; |
4006 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4007 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4008 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 4009 | } |
6b0655a2 | 4010 | |
d62a17ae | 4011 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
4012 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
4013 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4014 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 4015 | |
88b8ed8d | 4016 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 4017 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 4018 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
4019 | NO_STR |
4020 | NEIGHBOR_STR | |
4021 | NEIGHBOR_ADDR_STR2 | |
4022 | "Disable the next hop calculation for this neighbor\n" | |
4023 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 4024 | { |
d62a17ae | 4025 | int idx_peer = 2; |
4026 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4027 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4028 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 4029 | } |
a538debe | 4030 | |
d62a17ae | 4031 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
4032 | no_neighbor_nexthop_self_force_hidden_cmd, | |
4033 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
4034 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4035 | "Disable the next hop calculation for this neighbor\n" | |
4036 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 4037 | |
1bc4e531 DA |
4038 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
4039 | no_neighbor_nexthop_self_all_hidden_cmd, | |
4040 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
4041 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4042 | "Disable the next hop calculation for this neighbor\n" | |
4043 | "Set the next hop to self for reflected routes\n") | |
4044 | ||
c7122e14 DS |
4045 | /* neighbor as-override */ |
4046 | DEFUN (neighbor_as_override, | |
4047 | neighbor_as_override_cmd, | |
9ccf14f7 | 4048 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
4049 | NEIGHBOR_STR |
4050 | NEIGHBOR_ADDR_STR2 | |
4051 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
4052 | { | |
d62a17ae | 4053 | int idx_peer = 1; |
4054 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4055 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
4056 | } |
4057 | ||
d62a17ae | 4058 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
4059 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
4060 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4061 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 4062 | |
c7122e14 DS |
4063 | DEFUN (no_neighbor_as_override, |
4064 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 4065 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
4066 | NO_STR |
4067 | NEIGHBOR_STR | |
4068 | NEIGHBOR_ADDR_STR2 | |
4069 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
4070 | { | |
d62a17ae | 4071 | int idx_peer = 2; |
4072 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4073 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4074 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
4075 | } |
4076 | ||
d62a17ae | 4077 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
4078 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
4079 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4080 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 4081 | |
718e3744 | 4082 | /* neighbor remove-private-AS. */ |
4083 | DEFUN (neighbor_remove_private_as, | |
4084 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4085 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4086 | NEIGHBOR_STR |
4087 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4088 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4089 | { |
d62a17ae | 4090 | int idx_peer = 1; |
4091 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4092 | bgp_node_safi(vty), | |
4093 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4094 | } |
4095 | ||
d62a17ae | 4096 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
4097 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4098 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4099 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4100 | |
5000f21c DS |
4101 | DEFUN (neighbor_remove_private_as_all, |
4102 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 4103 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4104 | NEIGHBOR_STR |
4105 | NEIGHBOR_ADDR_STR2 | |
4106 | "Remove private ASNs in outbound updates\n" | |
efd7904e | 4107 | "Apply to all AS numbers\n") |
5000f21c | 4108 | { |
d62a17ae | 4109 | int idx_peer = 1; |
4110 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4111 | bgp_node_safi(vty), | |
4112 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
4113 | } |
4114 | ||
d62a17ae | 4115 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
4116 | neighbor_remove_private_as_all_hidden_cmd, | |
4117 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4118 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4119 | "Remove private ASNs in outbound updates\n" | |
4120 | "Apply to all AS numbers") | |
596c17ba | 4121 | |
5000f21c DS |
4122 | DEFUN (neighbor_remove_private_as_replace_as, |
4123 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 4124 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4125 | NEIGHBOR_STR |
4126 | NEIGHBOR_ADDR_STR2 | |
4127 | "Remove private ASNs in outbound updates\n" | |
4128 | "Replace private ASNs with our ASN in outbound updates\n") | |
4129 | { | |
d62a17ae | 4130 | int idx_peer = 1; |
4131 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4132 | bgp_node_safi(vty), | |
4133 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
4134 | } |
4135 | ||
d62a17ae | 4136 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
4137 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
4138 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4139 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4140 | "Remove private ASNs in outbound updates\n" | |
4141 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4142 | |
5000f21c DS |
4143 | DEFUN (neighbor_remove_private_as_all_replace_as, |
4144 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 4145 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4146 | NEIGHBOR_STR |
4147 | NEIGHBOR_ADDR_STR2 | |
4148 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4149 | "Apply to all AS numbers\n" |
5000f21c DS |
4150 | "Replace private ASNs with our ASN in outbound updates\n") |
4151 | { | |
d62a17ae | 4152 | int idx_peer = 1; |
4153 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4154 | bgp_node_safi(vty), | |
4155 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
4156 | } |
4157 | ||
d62a17ae | 4158 | ALIAS_HIDDEN( |
4159 | neighbor_remove_private_as_all_replace_as, | |
4160 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4161 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4162 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4163 | "Remove private ASNs in outbound updates\n" | |
4164 | "Apply to all AS numbers\n" | |
4165 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4166 | |
718e3744 | 4167 | DEFUN (no_neighbor_remove_private_as, |
4168 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4169 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4170 | NO_STR |
4171 | NEIGHBOR_STR | |
4172 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4173 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4174 | { |
d62a17ae | 4175 | int idx_peer = 2; |
4176 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4177 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4178 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4179 | } |
6b0655a2 | 4180 | |
d62a17ae | 4181 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
4182 | no_neighbor_remove_private_as_hidden_cmd, | |
4183 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4184 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4185 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4186 | |
88b8ed8d | 4187 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 4188 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 4189 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4190 | NO_STR |
4191 | NEIGHBOR_STR | |
4192 | NEIGHBOR_ADDR_STR2 | |
4193 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4194 | "Apply to all AS numbers\n") |
88b8ed8d | 4195 | { |
d62a17ae | 4196 | int idx_peer = 2; |
4197 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4198 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4199 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 4200 | } |
5000f21c | 4201 | |
d62a17ae | 4202 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
4203 | no_neighbor_remove_private_as_all_hidden_cmd, | |
4204 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4205 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4206 | "Remove private ASNs in outbound updates\n" | |
4207 | "Apply to all AS numbers\n") | |
596c17ba | 4208 | |
88b8ed8d | 4209 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 4210 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 4211 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4212 | NO_STR |
4213 | NEIGHBOR_STR | |
4214 | NEIGHBOR_ADDR_STR2 | |
4215 | "Remove private ASNs in outbound updates\n" | |
4216 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 4217 | { |
d62a17ae | 4218 | int idx_peer = 2; |
4219 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4220 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4221 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 4222 | } |
5000f21c | 4223 | |
d62a17ae | 4224 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
4225 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
4226 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4227 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4228 | "Remove private ASNs in outbound updates\n" | |
4229 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4230 | |
88b8ed8d | 4231 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 4232 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 4233 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4234 | NO_STR |
4235 | NEIGHBOR_STR | |
4236 | NEIGHBOR_ADDR_STR2 | |
4237 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4238 | "Apply to all AS numbers\n" |
5000f21c | 4239 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 4240 | { |
d62a17ae | 4241 | int idx_peer = 2; |
4242 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4243 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4244 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 4245 | } |
5000f21c | 4246 | |
d62a17ae | 4247 | ALIAS_HIDDEN( |
4248 | no_neighbor_remove_private_as_all_replace_as, | |
4249 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4250 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4251 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4252 | "Remove private ASNs in outbound updates\n" | |
4253 | "Apply to all AS numbers\n" | |
4254 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4255 | |
5000f21c | 4256 | |
718e3744 | 4257 | /* neighbor send-community. */ |
4258 | DEFUN (neighbor_send_community, | |
4259 | neighbor_send_community_cmd, | |
9ccf14f7 | 4260 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4261 | NEIGHBOR_STR |
4262 | NEIGHBOR_ADDR_STR2 | |
4263 | "Send Community attribute to this neighbor\n") | |
4264 | { | |
d62a17ae | 4265 | int idx_peer = 1; |
27c05d4d | 4266 | |
d62a17ae | 4267 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4268 | bgp_node_safi(vty), | |
4269 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4270 | } |
4271 | ||
d62a17ae | 4272 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
4273 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4274 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4275 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4276 | |
718e3744 | 4277 | DEFUN (no_neighbor_send_community, |
4278 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 4279 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4280 | NO_STR |
4281 | NEIGHBOR_STR | |
4282 | NEIGHBOR_ADDR_STR2 | |
4283 | "Send Community attribute to this neighbor\n") | |
4284 | { | |
d62a17ae | 4285 | int idx_peer = 2; |
27c05d4d | 4286 | |
d62a17ae | 4287 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
4288 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4289 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4290 | } |
6b0655a2 | 4291 | |
d62a17ae | 4292 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
4293 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4294 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4295 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4296 | |
718e3744 | 4297 | /* neighbor send-community extended. */ |
4298 | DEFUN (neighbor_send_community_type, | |
4299 | neighbor_send_community_type_cmd, | |
57d187bc | 4300 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4301 | NEIGHBOR_STR |
4302 | NEIGHBOR_ADDR_STR2 | |
4303 | "Send Community attribute to this neighbor\n" | |
4304 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4305 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4306 | "Send Extended Community attributes\n" |
57d187bc JS |
4307 | "Send Standard Community attributes\n" |
4308 | "Send Large Community attributes\n") | |
718e3744 | 4309 | { |
27c05d4d | 4310 | int idx_peer = 1; |
d7c0a89a | 4311 | uint32_t flag = 0; |
27c05d4d | 4312 | const char *type = argv[argc - 1]->text; |
d62a17ae | 4313 | |
27c05d4d | 4314 | if (strmatch(type, "standard")) { |
d62a17ae | 4315 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
27c05d4d | 4316 | } else if (strmatch(type, "extended")) { |
d62a17ae | 4317 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); |
27c05d4d | 4318 | } else if (strmatch(type, "large")) { |
d62a17ae | 4319 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); |
27c05d4d | 4320 | } else if (strmatch(type, "both")) { |
d62a17ae | 4321 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4322 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
27c05d4d | 4323 | } else { /* if (strmatch(type, "all")) */ |
d62a17ae | 4324 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4325 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4326 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4327 | } | |
4328 | ||
27c05d4d | 4329 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
d62a17ae | 4330 | bgp_node_safi(vty), flag); |
4331 | } | |
4332 | ||
4333 | ALIAS_HIDDEN( | |
4334 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
4335 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4336 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4337 | "Send Community attribute to this neighbor\n" | |
4338 | "Send Standard and Extended Community attributes\n" | |
4339 | "Send Standard, Large and Extended Community attributes\n" | |
4340 | "Send Extended Community attributes\n" | |
4341 | "Send Standard Community attributes\n" | |
4342 | "Send Large Community attributes\n") | |
596c17ba | 4343 | |
718e3744 | 4344 | DEFUN (no_neighbor_send_community_type, |
4345 | no_neighbor_send_community_type_cmd, | |
57d187bc | 4346 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4347 | NO_STR |
4348 | NEIGHBOR_STR | |
4349 | NEIGHBOR_ADDR_STR2 | |
4350 | "Send Community attribute to this neighbor\n" | |
4351 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4352 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4353 | "Send Extended Community attributes\n" |
57d187bc JS |
4354 | "Send Standard Community attributes\n" |
4355 | "Send Large Community attributes\n") | |
718e3744 | 4356 | { |
d62a17ae | 4357 | int idx_peer = 2; |
27c05d4d | 4358 | uint32_t flag = 0; |
d62a17ae | 4359 | const char *type = argv[argc - 1]->text; |
4360 | ||
27c05d4d PM |
4361 | if (strmatch(type, "standard")) { |
4362 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4363 | } else if (strmatch(type, "extended")) { | |
4364 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4365 | } else if (strmatch(type, "large")) { | |
4366 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4367 | } else if (strmatch(type, "both")) { | |
4368 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4369 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4370 | } else { /* if (strmatch(type, "all")) */ | |
4371 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4372 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4373 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4374 | } | |
4375 | ||
4376 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4377 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4378 | flag); | |
d62a17ae | 4379 | } |
4380 | ||
4381 | ALIAS_HIDDEN( | |
4382 | no_neighbor_send_community_type, | |
4383 | no_neighbor_send_community_type_hidden_cmd, | |
4384 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4385 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4386 | "Send Community attribute to this neighbor\n" | |
4387 | "Send Standard and Extended Community attributes\n" | |
4388 | "Send Standard, Large and Extended Community attributes\n" | |
4389 | "Send Extended Community attributes\n" | |
4390 | "Send Standard Community attributes\n" | |
4391 | "Send Large Community attributes\n") | |
596c17ba | 4392 | |
718e3744 | 4393 | /* neighbor soft-reconfig. */ |
4394 | DEFUN (neighbor_soft_reconfiguration, | |
4395 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4396 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4397 | NEIGHBOR_STR |
4398 | NEIGHBOR_ADDR_STR2 | |
4399 | "Per neighbor soft reconfiguration\n" | |
4400 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4401 | { | |
d62a17ae | 4402 | int idx_peer = 1; |
4403 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4404 | bgp_node_safi(vty), | |
4405 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4406 | } |
4407 | ||
d62a17ae | 4408 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
4409 | neighbor_soft_reconfiguration_hidden_cmd, | |
4410 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4411 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4412 | "Per neighbor soft reconfiguration\n" | |
4413 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4414 | |
718e3744 | 4415 | DEFUN (no_neighbor_soft_reconfiguration, |
4416 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4417 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4418 | NO_STR |
4419 | NEIGHBOR_STR | |
4420 | NEIGHBOR_ADDR_STR2 | |
4421 | "Per neighbor soft reconfiguration\n" | |
4422 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4423 | { | |
d62a17ae | 4424 | int idx_peer = 2; |
4425 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4426 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4427 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4428 | } |
6b0655a2 | 4429 | |
d62a17ae | 4430 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
4431 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
4432 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4433 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4434 | "Per neighbor soft reconfiguration\n" | |
4435 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4436 | |
718e3744 | 4437 | DEFUN (neighbor_route_reflector_client, |
4438 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4439 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4440 | NEIGHBOR_STR |
4441 | NEIGHBOR_ADDR_STR2 | |
4442 | "Configure a neighbor as Route Reflector client\n") | |
4443 | { | |
d62a17ae | 4444 | int idx_peer = 1; |
4445 | struct peer *peer; | |
718e3744 | 4446 | |
4447 | ||
d62a17ae | 4448 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4449 | if (!peer) | |
4450 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4451 | |
d62a17ae | 4452 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4453 | bgp_node_safi(vty), | |
4454 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4455 | } |
4456 | ||
d62a17ae | 4457 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
4458 | neighbor_route_reflector_client_hidden_cmd, | |
4459 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4460 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4461 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4462 | |
718e3744 | 4463 | DEFUN (no_neighbor_route_reflector_client, |
4464 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4465 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4466 | NO_STR |
4467 | NEIGHBOR_STR | |
4468 | NEIGHBOR_ADDR_STR2 | |
4469 | "Configure a neighbor as Route Reflector client\n") | |
4470 | { | |
d62a17ae | 4471 | int idx_peer = 2; |
4472 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4473 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4474 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4475 | } |
6b0655a2 | 4476 | |
d62a17ae | 4477 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
4478 | no_neighbor_route_reflector_client_hidden_cmd, | |
4479 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4480 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4481 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4482 | |
718e3744 | 4483 | /* neighbor route-server-client. */ |
4484 | DEFUN (neighbor_route_server_client, | |
4485 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 4486 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4487 | NEIGHBOR_STR |
4488 | NEIGHBOR_ADDR_STR2 | |
4489 | "Configure a neighbor as Route Server client\n") | |
4490 | { | |
d62a17ae | 4491 | int idx_peer = 1; |
4492 | struct peer *peer; | |
2a3d5731 | 4493 | |
d62a17ae | 4494 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4495 | if (!peer) | |
4496 | return CMD_WARNING_CONFIG_FAILED; | |
4497 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4498 | bgp_node_safi(vty), | |
4499 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 4500 | } |
4501 | ||
d62a17ae | 4502 | ALIAS_HIDDEN(neighbor_route_server_client, |
4503 | neighbor_route_server_client_hidden_cmd, | |
4504 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4505 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4506 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4507 | |
718e3744 | 4508 | DEFUN (no_neighbor_route_server_client, |
4509 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 4510 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4511 | NO_STR |
4512 | NEIGHBOR_STR | |
4513 | NEIGHBOR_ADDR_STR2 | |
4514 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 4515 | { |
d62a17ae | 4516 | int idx_peer = 2; |
4517 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4518 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4519 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 4520 | } |
6b0655a2 | 4521 | |
d62a17ae | 4522 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
4523 | no_neighbor_route_server_client_hidden_cmd, | |
4524 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4525 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4526 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4527 | |
fee0f4c6 | 4528 | DEFUN (neighbor_nexthop_local_unchanged, |
4529 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4530 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4531 | NEIGHBOR_STR |
4532 | NEIGHBOR_ADDR_STR2 | |
4533 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
4534 | "Leave link-local nexthop unchanged for this peer\n") | |
4535 | { | |
d62a17ae | 4536 | int idx_peer = 1; |
4537 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4538 | bgp_node_safi(vty), | |
4539 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 4540 | } |
6b0655a2 | 4541 | |
fee0f4c6 | 4542 | DEFUN (no_neighbor_nexthop_local_unchanged, |
4543 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4544 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4545 | NO_STR |
4546 | NEIGHBOR_STR | |
4547 | NEIGHBOR_ADDR_STR2 | |
4548 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
4549 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 4550 | { |
d62a17ae | 4551 | int idx_peer = 2; |
4552 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4553 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4554 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 4555 | } |
6b0655a2 | 4556 | |
718e3744 | 4557 | DEFUN (neighbor_attr_unchanged, |
4558 | neighbor_attr_unchanged_cmd, | |
a8206004 | 4559 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
718e3744 | 4560 | NEIGHBOR_STR |
4561 | NEIGHBOR_ADDR_STR2 | |
4562 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4563 | "As-path attribute\n" | |
4564 | "Nexthop attribute\n" | |
a8206004 | 4565 | "Med attribute\n") |
718e3744 | 4566 | { |
d62a17ae | 4567 | int idx = 0; |
8eeb0335 DW |
4568 | char *peer_str = argv[1]->arg; |
4569 | struct peer *peer; | |
d7c0a89a | 4570 | uint16_t flags = 0; |
8eeb0335 DW |
4571 | afi_t afi = bgp_node_afi(vty); |
4572 | safi_t safi = bgp_node_safi(vty); | |
4573 | ||
4574 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
4575 | if (!peer) | |
4576 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4577 | |
4578 | if (argv_find(argv, argc, "as-path", &idx)) | |
4579 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4580 | idx = 0; | |
4581 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4582 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4583 | idx = 0; | |
4584 | if (argv_find(argv, argc, "med", &idx)) | |
4585 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4586 | ||
8eeb0335 DW |
4587 | /* no flags means all of them! */ |
4588 | if (!flags) { | |
d62a17ae | 4589 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); |
4590 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4591 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 | 4592 | } else { |
a4d82a8a PZ |
4593 | if (!CHECK_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED) |
4594 | && peer_af_flag_check(peer, afi, safi, | |
4595 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
8eeb0335 DW |
4596 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4597 | PEER_FLAG_AS_PATH_UNCHANGED); | |
4598 | } | |
4599 | ||
a4d82a8a PZ |
4600 | if (!CHECK_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED) |
4601 | && peer_af_flag_check(peer, afi, safi, | |
4602 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
8eeb0335 DW |
4603 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4604 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
4605 | } | |
4606 | ||
a4d82a8a PZ |
4607 | if (!CHECK_FLAG(flags, PEER_FLAG_MED_UNCHANGED) |
4608 | && peer_af_flag_check(peer, afi, safi, | |
4609 | PEER_FLAG_MED_UNCHANGED)) { | |
8eeb0335 DW |
4610 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4611 | PEER_FLAG_MED_UNCHANGED); | |
4612 | } | |
d62a17ae | 4613 | } |
4614 | ||
8eeb0335 | 4615 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, flags); |
d62a17ae | 4616 | } |
4617 | ||
4618 | ALIAS_HIDDEN( | |
4619 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
4620 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4621 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4622 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4623 | "As-path attribute\n" | |
4624 | "Nexthop attribute\n" | |
4625 | "Med attribute\n") | |
596c17ba | 4626 | |
718e3744 | 4627 | DEFUN (no_neighbor_attr_unchanged, |
4628 | no_neighbor_attr_unchanged_cmd, | |
a8206004 | 4629 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
e52702f2 | 4630 | NO_STR |
718e3744 | 4631 | NEIGHBOR_STR |
4632 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
4633 | "BGP attribute is propagated unchanged to this neighbor\n" |
4634 | "As-path attribute\n" | |
40e718b5 | 4635 | "Nexthop attribute\n" |
a8206004 | 4636 | "Med attribute\n") |
718e3744 | 4637 | { |
d62a17ae | 4638 | int idx = 0; |
4639 | char *peer = argv[2]->arg; | |
d7c0a89a | 4640 | uint16_t flags = 0; |
d62a17ae | 4641 | |
4642 | if (argv_find(argv, argc, "as-path", &idx)) | |
4643 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4644 | idx = 0; | |
4645 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4646 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4647 | idx = 0; | |
4648 | if (argv_find(argv, argc, "med", &idx)) | |
4649 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4650 | ||
4651 | if (!flags) // no flags means all of them! | |
4652 | { | |
4653 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4654 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4655 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4656 | } | |
4657 | ||
4658 | return peer_af_flag_unset_vty(vty, peer, bgp_node_afi(vty), | |
4659 | bgp_node_safi(vty), flags); | |
4660 | } | |
4661 | ||
4662 | ALIAS_HIDDEN( | |
4663 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
4664 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4665 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4666 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4667 | "As-path attribute\n" | |
4668 | "Nexthop attribute\n" | |
4669 | "Med attribute\n") | |
718e3744 | 4670 | |
718e3744 | 4671 | /* EBGP multihop configuration. */ |
d62a17ae | 4672 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, |
4673 | const char *ttl_str) | |
718e3744 | 4674 | { |
d62a17ae | 4675 | struct peer *peer; |
4676 | unsigned int ttl; | |
718e3744 | 4677 | |
d62a17ae | 4678 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4679 | if (!peer) | |
4680 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4681 | |
d62a17ae | 4682 | if (peer->conf_if) |
4683 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
63fa10b5 | 4684 | |
d62a17ae | 4685 | if (!ttl_str) |
4686 | ttl = MAXTTL; | |
4687 | else | |
4688 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 4689 | |
d62a17ae | 4690 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 4691 | } |
4692 | ||
d62a17ae | 4693 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 4694 | { |
d62a17ae | 4695 | struct peer *peer; |
718e3744 | 4696 | |
d62a17ae | 4697 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4698 | if (!peer) | |
4699 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4700 | |
d62a17ae | 4701 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 4702 | } |
4703 | ||
4704 | /* neighbor ebgp-multihop. */ | |
4705 | DEFUN (neighbor_ebgp_multihop, | |
4706 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 4707 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 4708 | NEIGHBOR_STR |
4709 | NEIGHBOR_ADDR_STR2 | |
4710 | "Allow EBGP neighbors not on directly connected networks\n") | |
4711 | { | |
d62a17ae | 4712 | int idx_peer = 1; |
4713 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4714 | } |
4715 | ||
4716 | DEFUN (neighbor_ebgp_multihop_ttl, | |
4717 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 4718 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 4719 | NEIGHBOR_STR |
4720 | NEIGHBOR_ADDR_STR2 | |
4721 | "Allow EBGP neighbors not on directly connected networks\n" | |
4722 | "maximum hop count\n") | |
4723 | { | |
d62a17ae | 4724 | int idx_peer = 1; |
4725 | int idx_number = 3; | |
4726 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
4727 | argv[idx_number]->arg); | |
718e3744 | 4728 | } |
4729 | ||
4730 | DEFUN (no_neighbor_ebgp_multihop, | |
4731 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 4732 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 4733 | NO_STR |
4734 | NEIGHBOR_STR | |
4735 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4736 | "Allow EBGP neighbors not on directly connected networks\n" |
4737 | "maximum hop count\n") | |
718e3744 | 4738 | { |
d62a17ae | 4739 | int idx_peer = 2; |
4740 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 4741 | } |
4742 | ||
6b0655a2 | 4743 | |
6ffd2079 | 4744 | /* disable-connected-check */ |
4745 | DEFUN (neighbor_disable_connected_check, | |
4746 | neighbor_disable_connected_check_cmd, | |
7ebe625c | 4747 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4748 | NEIGHBOR_STR |
7ebe625c | 4749 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
4750 | "one-hop away EBGP peer using loopback address\n" |
4751 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4752 | { |
d62a17ae | 4753 | int idx_peer = 1; |
4754 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4755 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4756 | } |
4757 | ||
4758 | DEFUN (no_neighbor_disable_connected_check, | |
4759 | no_neighbor_disable_connected_check_cmd, | |
7ebe625c | 4760 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4761 | NO_STR |
4762 | NEIGHBOR_STR | |
7ebe625c | 4763 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
4764 | "one-hop away EBGP peer using loopback address\n" |
4765 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4766 | { |
d62a17ae | 4767 | int idx_peer = 2; |
4768 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4769 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4770 | } |
4771 | ||
47cbc09b PM |
4772 | |
4773 | /* enforce-first-as */ | |
4774 | DEFUN (neighbor_enforce_first_as, | |
4775 | neighbor_enforce_first_as_cmd, | |
4776 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
4777 | NEIGHBOR_STR | |
4778 | NEIGHBOR_ADDR_STR2 | |
4779 | "Enforce the first AS for EBGP routes\n") | |
4780 | { | |
4781 | int idx_peer = 1; | |
4782 | ||
4783 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4784 | PEER_FLAG_ENFORCE_FIRST_AS); | |
4785 | } | |
4786 | ||
4787 | DEFUN (no_neighbor_enforce_first_as, | |
4788 | no_neighbor_enforce_first_as_cmd, | |
4789 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
4790 | NO_STR | |
4791 | NEIGHBOR_STR | |
4792 | NEIGHBOR_ADDR_STR2 | |
4793 | "Enforce the first AS for EBGP routes\n") | |
4794 | { | |
4795 | int idx_peer = 2; | |
4796 | ||
4797 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4798 | PEER_FLAG_ENFORCE_FIRST_AS); | |
4799 | } | |
4800 | ||
4801 | ||
718e3744 | 4802 | DEFUN (neighbor_description, |
4803 | neighbor_description_cmd, | |
e961923c | 4804 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 4805 | NEIGHBOR_STR |
4806 | NEIGHBOR_ADDR_STR2 | |
4807 | "Neighbor specific description\n" | |
4808 | "Up to 80 characters describing this neighbor\n") | |
4809 | { | |
d62a17ae | 4810 | int idx_peer = 1; |
4811 | int idx_line = 3; | |
4812 | struct peer *peer; | |
4813 | char *str; | |
718e3744 | 4814 | |
d62a17ae | 4815 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4816 | if (!peer) | |
4817 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4818 | |
d62a17ae | 4819 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 4820 | |
d62a17ae | 4821 | peer_description_set(peer, str); |
718e3744 | 4822 | |
d62a17ae | 4823 | XFREE(MTYPE_TMP, str); |
718e3744 | 4824 | |
d62a17ae | 4825 | return CMD_SUCCESS; |
718e3744 | 4826 | } |
4827 | ||
4828 | DEFUN (no_neighbor_description, | |
4829 | no_neighbor_description_cmd, | |
a14810f4 | 4830 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", |
718e3744 | 4831 | NO_STR |
4832 | NEIGHBOR_STR | |
4833 | NEIGHBOR_ADDR_STR2 | |
a14810f4 | 4834 | "Neighbor specific description\n") |
718e3744 | 4835 | { |
d62a17ae | 4836 | int idx_peer = 2; |
4837 | struct peer *peer; | |
718e3744 | 4838 | |
d62a17ae | 4839 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4840 | if (!peer) | |
4841 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4842 | |
d62a17ae | 4843 | peer_description_unset(peer); |
718e3744 | 4844 | |
d62a17ae | 4845 | return CMD_SUCCESS; |
718e3744 | 4846 | } |
4847 | ||
a14810f4 PM |
4848 | ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd, |
4849 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
4850 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4851 | "Neighbor specific description\n" | |
4852 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 4853 | |
718e3744 | 4854 | /* Neighbor update-source. */ |
d62a17ae | 4855 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, |
4856 | const char *source_str) | |
4857 | { | |
4858 | struct peer *peer; | |
4859 | struct prefix p; | |
a14810f4 | 4860 | union sockunion su; |
d62a17ae | 4861 | |
4862 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
4863 | if (!peer) | |
4864 | return CMD_WARNING_CONFIG_FAILED; | |
4865 | ||
4866 | if (peer->conf_if) | |
4867 | return CMD_WARNING; | |
4868 | ||
4869 | if (source_str) { | |
a14810f4 | 4870 | if (str2sockunion(source_str, &su) == 0) |
d62a17ae | 4871 | peer_update_source_addr_set(peer, &su); |
4872 | else { | |
4873 | if (str2prefix(source_str, &p)) { | |
4874 | vty_out(vty, | |
4875 | "%% Invalid update-source, remove prefix length \n"); | |
4876 | return CMD_WARNING_CONFIG_FAILED; | |
4877 | } else | |
4878 | peer_update_source_if_set(peer, source_str); | |
4879 | } | |
4880 | } else | |
4881 | peer_update_source_unset(peer); | |
4882 | ||
4883 | return CMD_SUCCESS; | |
4884 | } | |
4885 | ||
4886 | #define BGP_UPDATE_SOURCE_HELP_STR \ | |
4887 | "IPv4 address\n" \ | |
4888 | "IPv6 address\n" \ | |
4889 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 4890 | |
718e3744 | 4891 | DEFUN (neighbor_update_source, |
4892 | neighbor_update_source_cmd, | |
9ccf14f7 | 4893 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 4894 | NEIGHBOR_STR |
4895 | NEIGHBOR_ADDR_STR2 | |
4896 | "Source of routing updates\n" | |
369688c0 | 4897 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 4898 | { |
d62a17ae | 4899 | int idx_peer = 1; |
4900 | int idx_peer_2 = 3; | |
4901 | return peer_update_source_vty(vty, argv[idx_peer]->arg, | |
4902 | argv[idx_peer_2]->arg); | |
718e3744 | 4903 | } |
4904 | ||
4905 | DEFUN (no_neighbor_update_source, | |
4906 | no_neighbor_update_source_cmd, | |
c7178fe7 | 4907 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 4908 | NO_STR |
4909 | NEIGHBOR_STR | |
4910 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
4911 | "Source of routing updates\n" |
4912 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 4913 | { |
d62a17ae | 4914 | int idx_peer = 2; |
4915 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4916 | } |
6b0655a2 | 4917 | |
d62a17ae | 4918 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
4919 | afi_t afi, safi_t safi, | |
4920 | const char *rmap, int set) | |
718e3744 | 4921 | { |
d62a17ae | 4922 | int ret; |
4923 | struct peer *peer; | |
80912664 | 4924 | struct route_map *route_map = NULL; |
718e3744 | 4925 | |
d62a17ae | 4926 | peer = peer_and_group_lookup_vty(vty, peer_str); |
4927 | if (!peer) | |
4928 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4929 | |
1de27621 | 4930 | if (set) { |
80912664 DS |
4931 | if (rmap) |
4932 | route_map = route_map_lookup_warn_noexist(vty, rmap); | |
1de27621 DA |
4933 | ret = peer_default_originate_set(peer, afi, safi, |
4934 | rmap, route_map); | |
4935 | } else | |
d62a17ae | 4936 | ret = peer_default_originate_unset(peer, afi, safi); |
718e3744 | 4937 | |
d62a17ae | 4938 | return bgp_vty_return(vty, ret); |
718e3744 | 4939 | } |
4940 | ||
4941 | /* neighbor default-originate. */ | |
4942 | DEFUN (neighbor_default_originate, | |
4943 | neighbor_default_originate_cmd, | |
9ccf14f7 | 4944 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 4945 | NEIGHBOR_STR |
4946 | NEIGHBOR_ADDR_STR2 | |
4947 | "Originate default route to this neighbor\n") | |
4948 | { | |
d62a17ae | 4949 | int idx_peer = 1; |
4950 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
4951 | bgp_node_afi(vty), | |
4952 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 4953 | } |
4954 | ||
d62a17ae | 4955 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
4956 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
4957 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4958 | "Originate default route to this neighbor\n") | |
596c17ba | 4959 | |
718e3744 | 4960 | DEFUN (neighbor_default_originate_rmap, |
4961 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 4962 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 4963 | NEIGHBOR_STR |
4964 | NEIGHBOR_ADDR_STR2 | |
4965 | "Originate default route to this neighbor\n" | |
4966 | "Route-map to specify criteria to originate default\n" | |
4967 | "route-map name\n") | |
4968 | { | |
d62a17ae | 4969 | int idx_peer = 1; |
4970 | int idx_word = 4; | |
4971 | return peer_default_originate_set_vty( | |
4972 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
4973 | argv[idx_word]->arg, 1); | |
718e3744 | 4974 | } |
4975 | ||
d62a17ae | 4976 | ALIAS_HIDDEN( |
4977 | neighbor_default_originate_rmap, | |
4978 | neighbor_default_originate_rmap_hidden_cmd, | |
4979 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
4980 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4981 | "Originate default route to this neighbor\n" | |
4982 | "Route-map to specify criteria to originate default\n" | |
4983 | "route-map name\n") | |
596c17ba | 4984 | |
718e3744 | 4985 | DEFUN (no_neighbor_default_originate, |
4986 | no_neighbor_default_originate_cmd, | |
a636c635 | 4987 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 4988 | NO_STR |
4989 | NEIGHBOR_STR | |
4990 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4991 | "Originate default route to this neighbor\n" |
4992 | "Route-map to specify criteria to originate default\n" | |
4993 | "route-map name\n") | |
718e3744 | 4994 | { |
d62a17ae | 4995 | int idx_peer = 2; |
4996 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
4997 | bgp_node_afi(vty), | |
4998 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 4999 | } |
5000 | ||
d62a17ae | 5001 | ALIAS_HIDDEN( |
5002 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
5003 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
5004 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5005 | "Originate default route to this neighbor\n" | |
5006 | "Route-map to specify criteria to originate default\n" | |
5007 | "route-map name\n") | |
596c17ba | 5008 | |
6b0655a2 | 5009 | |
718e3744 | 5010 | /* Set neighbor's BGP port. */ |
d62a17ae | 5011 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, |
5012 | const char *port_str) | |
5013 | { | |
5014 | struct peer *peer; | |
d7c0a89a | 5015 | uint16_t port; |
d62a17ae | 5016 | struct servent *sp; |
5017 | ||
5018 | peer = peer_lookup_vty(vty, ip_str); | |
5019 | if (!peer) | |
5020 | return CMD_WARNING_CONFIG_FAILED; | |
5021 | ||
5022 | if (!port_str) { | |
5023 | sp = getservbyname("bgp", "tcp"); | |
5024 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
5025 | } else { | |
5026 | port = strtoul(port_str, NULL, 10); | |
5027 | } | |
718e3744 | 5028 | |
d62a17ae | 5029 | peer_port_set(peer, port); |
718e3744 | 5030 | |
d62a17ae | 5031 | return CMD_SUCCESS; |
718e3744 | 5032 | } |
5033 | ||
f418446b | 5034 | /* Set specified peer's BGP port. */ |
718e3744 | 5035 | DEFUN (neighbor_port, |
5036 | neighbor_port_cmd, | |
9ccf14f7 | 5037 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 5038 | NEIGHBOR_STR |
5039 | NEIGHBOR_ADDR_STR | |
5040 | "Neighbor's BGP port\n" | |
5041 | "TCP port number\n") | |
5042 | { | |
d62a17ae | 5043 | int idx_ip = 1; |
5044 | int idx_number = 3; | |
5045 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
5046 | argv[idx_number]->arg); | |
718e3744 | 5047 | } |
5048 | ||
5049 | DEFUN (no_neighbor_port, | |
5050 | no_neighbor_port_cmd, | |
9ccf14f7 | 5051 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 5052 | NO_STR |
5053 | NEIGHBOR_STR | |
5054 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
5055 | "Neighbor's BGP port\n" |
5056 | "TCP port number\n") | |
718e3744 | 5057 | { |
d62a17ae | 5058 | int idx_ip = 2; |
5059 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 5060 | } |
5061 | ||
6b0655a2 | 5062 | |
718e3744 | 5063 | /* neighbor weight. */ |
d62a17ae | 5064 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5065 | safi_t safi, const char *weight_str) | |
718e3744 | 5066 | { |
d62a17ae | 5067 | int ret; |
5068 | struct peer *peer; | |
5069 | unsigned long weight; | |
718e3744 | 5070 | |
d62a17ae | 5071 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5072 | if (!peer) | |
5073 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5074 | |
d62a17ae | 5075 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 5076 | |
d62a17ae | 5077 | ret = peer_weight_set(peer, afi, safi, weight); |
5078 | return bgp_vty_return(vty, ret); | |
718e3744 | 5079 | } |
5080 | ||
d62a17ae | 5081 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5082 | safi_t safi) | |
718e3744 | 5083 | { |
d62a17ae | 5084 | int ret; |
5085 | struct peer *peer; | |
718e3744 | 5086 | |
d62a17ae | 5087 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5088 | if (!peer) | |
5089 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5090 | |
d62a17ae | 5091 | ret = peer_weight_unset(peer, afi, safi); |
5092 | return bgp_vty_return(vty, ret); | |
718e3744 | 5093 | } |
5094 | ||
5095 | DEFUN (neighbor_weight, | |
5096 | neighbor_weight_cmd, | |
9ccf14f7 | 5097 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 5098 | NEIGHBOR_STR |
5099 | NEIGHBOR_ADDR_STR2 | |
5100 | "Set default weight for routes from this neighbor\n" | |
5101 | "default weight\n") | |
5102 | { | |
d62a17ae | 5103 | int idx_peer = 1; |
5104 | int idx_number = 3; | |
5105 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5106 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 5107 | } |
5108 | ||
d62a17ae | 5109 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
5110 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
5111 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5112 | "Set default weight for routes from this neighbor\n" | |
5113 | "default weight\n") | |
596c17ba | 5114 | |
718e3744 | 5115 | DEFUN (no_neighbor_weight, |
5116 | no_neighbor_weight_cmd, | |
9ccf14f7 | 5117 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 5118 | NO_STR |
5119 | NEIGHBOR_STR | |
5120 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5121 | "Set default weight for routes from this neighbor\n" |
5122 | "default weight\n") | |
718e3744 | 5123 | { |
d62a17ae | 5124 | int idx_peer = 2; |
5125 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, | |
5126 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 5127 | } |
5128 | ||
d62a17ae | 5129 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
5130 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
5131 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5132 | "Set default weight for routes from this neighbor\n" | |
5133 | "default weight\n") | |
596c17ba | 5134 | |
6b0655a2 | 5135 | |
718e3744 | 5136 | /* Override capability negotiation. */ |
5137 | DEFUN (neighbor_override_capability, | |
5138 | neighbor_override_capability_cmd, | |
9ccf14f7 | 5139 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5140 | NEIGHBOR_STR |
5141 | NEIGHBOR_ADDR_STR2 | |
5142 | "Override capability negotiation result\n") | |
5143 | { | |
d62a17ae | 5144 | int idx_peer = 1; |
5145 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5146 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5147 | } |
5148 | ||
5149 | DEFUN (no_neighbor_override_capability, | |
5150 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 5151 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5152 | NO_STR |
5153 | NEIGHBOR_STR | |
5154 | NEIGHBOR_ADDR_STR2 | |
5155 | "Override capability negotiation result\n") | |
5156 | { | |
d62a17ae | 5157 | int idx_peer = 2; |
5158 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5159 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5160 | } |
6b0655a2 | 5161 | |
718e3744 | 5162 | DEFUN (neighbor_strict_capability, |
5163 | neighbor_strict_capability_cmd, | |
9fb964de | 5164 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5165 | NEIGHBOR_STR |
9fb964de | 5166 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5167 | "Strict capability negotiation match\n") |
5168 | { | |
9fb964de PM |
5169 | int idx_peer = 1; |
5170 | ||
5171 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5172 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5173 | } |
5174 | ||
5175 | DEFUN (no_neighbor_strict_capability, | |
5176 | no_neighbor_strict_capability_cmd, | |
9fb964de | 5177 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5178 | NO_STR |
5179 | NEIGHBOR_STR | |
9fb964de | 5180 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5181 | "Strict capability negotiation match\n") |
5182 | { | |
9fb964de PM |
5183 | int idx_peer = 2; |
5184 | ||
5185 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5186 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5187 | } |
6b0655a2 | 5188 | |
d62a17ae | 5189 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
5190 | const char *keep_str, const char *hold_str) | |
718e3744 | 5191 | { |
d62a17ae | 5192 | int ret; |
5193 | struct peer *peer; | |
d7c0a89a QY |
5194 | uint32_t keepalive; |
5195 | uint32_t holdtime; | |
718e3744 | 5196 | |
d62a17ae | 5197 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5198 | if (!peer) | |
5199 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5200 | |
d62a17ae | 5201 | keepalive = strtoul(keep_str, NULL, 10); |
5202 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 5203 | |
d62a17ae | 5204 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 5205 | |
d62a17ae | 5206 | return bgp_vty_return(vty, ret); |
718e3744 | 5207 | } |
6b0655a2 | 5208 | |
d62a17ae | 5209 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5210 | { |
d62a17ae | 5211 | int ret; |
5212 | struct peer *peer; | |
718e3744 | 5213 | |
d62a17ae | 5214 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5215 | if (!peer) | |
5216 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5217 | |
d62a17ae | 5218 | ret = peer_timers_unset(peer); |
718e3744 | 5219 | |
d62a17ae | 5220 | return bgp_vty_return(vty, ret); |
718e3744 | 5221 | } |
5222 | ||
5223 | DEFUN (neighbor_timers, | |
5224 | neighbor_timers_cmd, | |
9ccf14f7 | 5225 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 5226 | NEIGHBOR_STR |
5227 | NEIGHBOR_ADDR_STR2 | |
5228 | "BGP per neighbor timers\n" | |
5229 | "Keepalive interval\n" | |
5230 | "Holdtime\n") | |
5231 | { | |
d62a17ae | 5232 | int idx_peer = 1; |
5233 | int idx_number = 3; | |
5234 | int idx_number_2 = 4; | |
5235 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
5236 | argv[idx_number]->arg, | |
5237 | argv[idx_number_2]->arg); | |
718e3744 | 5238 | } |
5239 | ||
5240 | DEFUN (no_neighbor_timers, | |
5241 | no_neighbor_timers_cmd, | |
9ccf14f7 | 5242 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 5243 | NO_STR |
5244 | NEIGHBOR_STR | |
5245 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5246 | "BGP per neighbor timers\n" |
5247 | "Keepalive interval\n" | |
5248 | "Holdtime\n") | |
718e3744 | 5249 | { |
d62a17ae | 5250 | int idx_peer = 2; |
5251 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5252 | } |
6b0655a2 | 5253 | |
813d4307 | 5254 | |
d62a17ae | 5255 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, |
5256 | const char *time_str) | |
718e3744 | 5257 | { |
d62a17ae | 5258 | int ret; |
5259 | struct peer *peer; | |
d7c0a89a | 5260 | uint32_t connect; |
718e3744 | 5261 | |
d62a17ae | 5262 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5263 | if (!peer) | |
5264 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5265 | |
d62a17ae | 5266 | connect = strtoul(time_str, NULL, 10); |
718e3744 | 5267 | |
d62a17ae | 5268 | ret = peer_timers_connect_set(peer, connect); |
718e3744 | 5269 | |
d62a17ae | 5270 | return bgp_vty_return(vty, ret); |
718e3744 | 5271 | } |
5272 | ||
d62a17ae | 5273 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5274 | { |
d62a17ae | 5275 | int ret; |
5276 | struct peer *peer; | |
718e3744 | 5277 | |
d62a17ae | 5278 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5279 | if (!peer) | |
5280 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5281 | |
d62a17ae | 5282 | ret = peer_timers_connect_unset(peer); |
718e3744 | 5283 | |
d62a17ae | 5284 | return bgp_vty_return(vty, ret); |
718e3744 | 5285 | } |
5286 | ||
5287 | DEFUN (neighbor_timers_connect, | |
5288 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 5289 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 5290 | NEIGHBOR_STR |
966f821c | 5291 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5292 | "BGP per neighbor timers\n" |
5293 | "BGP connect timer\n" | |
5294 | "Connect timer\n") | |
5295 | { | |
d62a17ae | 5296 | int idx_peer = 1; |
5297 | int idx_number = 4; | |
5298 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
5299 | argv[idx_number]->arg); | |
718e3744 | 5300 | } |
5301 | ||
5302 | DEFUN (no_neighbor_timers_connect, | |
5303 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 5304 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 5305 | NO_STR |
5306 | NEIGHBOR_STR | |
966f821c | 5307 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5308 | "BGP per neighbor timers\n" |
8334fd5a DW |
5309 | "BGP connect timer\n" |
5310 | "Connect timer\n") | |
718e3744 | 5311 | { |
d62a17ae | 5312 | int idx_peer = 2; |
5313 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5314 | } |
5315 | ||
6b0655a2 | 5316 | |
d62a17ae | 5317 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
5318 | const char *time_str, int set) | |
718e3744 | 5319 | { |
d62a17ae | 5320 | int ret; |
5321 | struct peer *peer; | |
d7c0a89a | 5322 | uint32_t routeadv = 0; |
718e3744 | 5323 | |
d62a17ae | 5324 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5325 | if (!peer) | |
5326 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5327 | |
d62a17ae | 5328 | if (time_str) |
5329 | routeadv = strtoul(time_str, NULL, 10); | |
718e3744 | 5330 | |
d62a17ae | 5331 | if (set) |
5332 | ret = peer_advertise_interval_set(peer, routeadv); | |
5333 | else | |
5334 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 5335 | |
d62a17ae | 5336 | return bgp_vty_return(vty, ret); |
718e3744 | 5337 | } |
5338 | ||
5339 | DEFUN (neighbor_advertise_interval, | |
5340 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5341 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 5342 | NEIGHBOR_STR |
966f821c | 5343 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5344 | "Minimum interval between sending BGP routing updates\n" |
5345 | "time in seconds\n") | |
5346 | { | |
d62a17ae | 5347 | int idx_peer = 1; |
5348 | int idx_number = 3; | |
5349 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
5350 | argv[idx_number]->arg, 1); | |
718e3744 | 5351 | } |
5352 | ||
5353 | DEFUN (no_neighbor_advertise_interval, | |
5354 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5355 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 5356 | NO_STR |
5357 | NEIGHBOR_STR | |
966f821c | 5358 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
5359 | "Minimum interval between sending BGP routing updates\n" |
5360 | "time in seconds\n") | |
718e3744 | 5361 | { |
d62a17ae | 5362 | int idx_peer = 2; |
5363 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 5364 | } |
5365 | ||
6b0655a2 | 5366 | |
518f0eb1 DS |
5367 | /* Time to wait before processing route-map updates */ |
5368 | DEFUN (bgp_set_route_map_delay_timer, | |
5369 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 5370 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
5371 | SET_STR |
5372 | "BGP route-map delay timer\n" | |
5373 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 5374 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 5375 | { |
d62a17ae | 5376 | int idx_number = 3; |
d7c0a89a | 5377 | uint32_t rmap_delay_timer; |
d62a17ae | 5378 | |
5379 | if (argv[idx_number]->arg) { | |
5380 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
5381 | bm->rmap_update_timer = rmap_delay_timer; | |
5382 | ||
5383 | /* if the dynamic update handling is being disabled, and a timer | |
5384 | * is | |
5385 | * running, stop the timer and act as if the timer has already | |
5386 | * fired. | |
5387 | */ | |
5388 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
5389 | BGP_TIMER_OFF(bm->t_rmap_update); | |
5390 | thread_execute(bm->master, bgp_route_map_update_timer, | |
5391 | NULL, 0); | |
5392 | } | |
5393 | return CMD_SUCCESS; | |
5394 | } else { | |
5395 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
5396 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 5397 | } |
518f0eb1 DS |
5398 | } |
5399 | ||
5400 | DEFUN (no_bgp_set_route_map_delay_timer, | |
5401 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 5402 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 5403 | NO_STR |
3a2d747c | 5404 | BGP_STR |
518f0eb1 | 5405 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
5406 | "Reset to default time to wait for processing route-map changes\n" |
5407 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 5408 | { |
518f0eb1 | 5409 | |
d62a17ae | 5410 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 5411 | |
d62a17ae | 5412 | return CMD_SUCCESS; |
518f0eb1 DS |
5413 | } |
5414 | ||
f414725f | 5415 | |
718e3744 | 5416 | /* neighbor interface */ |
d62a17ae | 5417 | static int peer_interface_vty(struct vty *vty, const char *ip_str, |
5418 | const char *str) | |
718e3744 | 5419 | { |
d62a17ae | 5420 | struct peer *peer; |
718e3744 | 5421 | |
d62a17ae | 5422 | peer = peer_lookup_vty(vty, ip_str); |
5423 | if (!peer || peer->conf_if) { | |
5424 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
5425 | return CMD_WARNING_CONFIG_FAILED; | |
5426 | } | |
718e3744 | 5427 | |
d62a17ae | 5428 | if (str) |
5429 | peer_interface_set(peer, str); | |
5430 | else | |
5431 | peer_interface_unset(peer); | |
718e3744 | 5432 | |
d62a17ae | 5433 | return CMD_SUCCESS; |
718e3744 | 5434 | } |
5435 | ||
5436 | DEFUN (neighbor_interface, | |
5437 | neighbor_interface_cmd, | |
9ccf14f7 | 5438 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 5439 | NEIGHBOR_STR |
5440 | NEIGHBOR_ADDR_STR | |
5441 | "Interface\n" | |
5442 | "Interface name\n") | |
5443 | { | |
d62a17ae | 5444 | int idx_ip = 1; |
5445 | int idx_word = 3; | |
5446 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); | |
718e3744 | 5447 | } |
5448 | ||
5449 | DEFUN (no_neighbor_interface, | |
5450 | no_neighbor_interface_cmd, | |
9ccf14f7 | 5451 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 5452 | NO_STR |
5453 | NEIGHBOR_STR | |
16cedbb0 | 5454 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5455 | "Interface\n" |
5456 | "Interface name\n") | |
5457 | { | |
d62a17ae | 5458 | int idx_peer = 2; |
5459 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5460 | } |
6b0655a2 | 5461 | |
718e3744 | 5462 | DEFUN (neighbor_distribute_list, |
5463 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 5464 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5465 | NEIGHBOR_STR |
5466 | NEIGHBOR_ADDR_STR2 | |
5467 | "Filter updates to/from this neighbor\n" | |
5468 | "IP access-list number\n" | |
5469 | "IP access-list number (expanded range)\n" | |
5470 | "IP Access-list name\n" | |
5471 | "Filter incoming updates\n" | |
5472 | "Filter outgoing updates\n") | |
5473 | { | |
d62a17ae | 5474 | int idx_peer = 1; |
5475 | int idx_acl = 3; | |
5476 | int direct, ret; | |
5477 | struct peer *peer; | |
a8206004 | 5478 | |
d62a17ae | 5479 | const char *pstr = argv[idx_peer]->arg; |
5480 | const char *acl = argv[idx_acl]->arg; | |
5481 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5482 | |
d62a17ae | 5483 | peer = peer_and_group_lookup_vty(vty, pstr); |
5484 | if (!peer) | |
5485 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5486 | |
d62a17ae | 5487 | /* Check filter direction. */ |
5488 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5489 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5490 | direct, acl); | |
a8206004 | 5491 | |
d62a17ae | 5492 | return bgp_vty_return(vty, ret); |
718e3744 | 5493 | } |
5494 | ||
d62a17ae | 5495 | ALIAS_HIDDEN( |
5496 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
5497 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5498 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5499 | "Filter updates to/from this neighbor\n" | |
5500 | "IP access-list number\n" | |
5501 | "IP access-list number (expanded range)\n" | |
5502 | "IP Access-list name\n" | |
5503 | "Filter incoming updates\n" | |
5504 | "Filter outgoing updates\n") | |
596c17ba | 5505 | |
718e3744 | 5506 | DEFUN (no_neighbor_distribute_list, |
5507 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 5508 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5509 | NO_STR |
5510 | NEIGHBOR_STR | |
5511 | NEIGHBOR_ADDR_STR2 | |
5512 | "Filter updates to/from this neighbor\n" | |
5513 | "IP access-list number\n" | |
5514 | "IP access-list number (expanded range)\n" | |
5515 | "IP Access-list name\n" | |
5516 | "Filter incoming updates\n" | |
5517 | "Filter outgoing updates\n") | |
5518 | { | |
d62a17ae | 5519 | int idx_peer = 2; |
5520 | int direct, ret; | |
5521 | struct peer *peer; | |
a8206004 | 5522 | |
d62a17ae | 5523 | const char *pstr = argv[idx_peer]->arg; |
5524 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5525 | |
d62a17ae | 5526 | peer = peer_and_group_lookup_vty(vty, pstr); |
5527 | if (!peer) | |
5528 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5529 | |
d62a17ae | 5530 | /* Check filter direction. */ |
5531 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5532 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5533 | direct); | |
a8206004 | 5534 | |
d62a17ae | 5535 | return bgp_vty_return(vty, ret); |
718e3744 | 5536 | } |
6b0655a2 | 5537 | |
d62a17ae | 5538 | ALIAS_HIDDEN( |
5539 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
5540 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5541 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5542 | "Filter updates to/from this neighbor\n" | |
5543 | "IP access-list number\n" | |
5544 | "IP access-list number (expanded range)\n" | |
5545 | "IP Access-list name\n" | |
5546 | "Filter incoming updates\n" | |
5547 | "Filter outgoing updates\n") | |
596c17ba | 5548 | |
718e3744 | 5549 | /* Set prefix list to the peer. */ |
d62a17ae | 5550 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
5551 | afi_t afi, safi_t safi, | |
5552 | const char *name_str, | |
5553 | const char *direct_str) | |
718e3744 | 5554 | { |
d62a17ae | 5555 | int ret; |
d62a17ae | 5556 | int direct = FILTER_IN; |
cf9ac8bf | 5557 | struct peer *peer; |
718e3744 | 5558 | |
d62a17ae | 5559 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5560 | if (!peer) | |
5561 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5562 | |
d62a17ae | 5563 | /* Check filter direction. */ |
5564 | if (strncmp(direct_str, "i", 1) == 0) | |
5565 | direct = FILTER_IN; | |
5566 | else if (strncmp(direct_str, "o", 1) == 0) | |
5567 | direct = FILTER_OUT; | |
718e3744 | 5568 | |
d62a17ae | 5569 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 5570 | |
d62a17ae | 5571 | return bgp_vty_return(vty, ret); |
718e3744 | 5572 | } |
5573 | ||
d62a17ae | 5574 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, |
5575 | afi_t afi, safi_t safi, | |
5576 | const char *direct_str) | |
718e3744 | 5577 | { |
d62a17ae | 5578 | int ret; |
5579 | struct peer *peer; | |
5580 | int direct = FILTER_IN; | |
718e3744 | 5581 | |
d62a17ae | 5582 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5583 | if (!peer) | |
5584 | return CMD_WARNING_CONFIG_FAILED; | |
e52702f2 | 5585 | |
d62a17ae | 5586 | /* Check filter direction. */ |
5587 | if (strncmp(direct_str, "i", 1) == 0) | |
5588 | direct = FILTER_IN; | |
5589 | else if (strncmp(direct_str, "o", 1) == 0) | |
5590 | direct = FILTER_OUT; | |
718e3744 | 5591 | |
d62a17ae | 5592 | ret = peer_prefix_list_unset(peer, afi, safi, direct); |
718e3744 | 5593 | |
d62a17ae | 5594 | return bgp_vty_return(vty, ret); |
718e3744 | 5595 | } |
5596 | ||
5597 | DEFUN (neighbor_prefix_list, | |
5598 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 5599 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5600 | NEIGHBOR_STR |
5601 | NEIGHBOR_ADDR_STR2 | |
5602 | "Filter updates to/from this neighbor\n" | |
5603 | "Name of a prefix list\n" | |
5604 | "Filter incoming updates\n" | |
5605 | "Filter outgoing updates\n") | |
5606 | { | |
d62a17ae | 5607 | int idx_peer = 1; |
5608 | int idx_word = 3; | |
5609 | int idx_in_out = 4; | |
5610 | return peer_prefix_list_set_vty( | |
5611 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5612 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5613 | } |
5614 | ||
d62a17ae | 5615 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
5616 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5617 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5618 | "Filter updates to/from this neighbor\n" | |
5619 | "Name of a prefix list\n" | |
5620 | "Filter incoming updates\n" | |
5621 | "Filter outgoing updates\n") | |
596c17ba | 5622 | |
718e3744 | 5623 | DEFUN (no_neighbor_prefix_list, |
5624 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 5625 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5626 | NO_STR |
5627 | NEIGHBOR_STR | |
5628 | NEIGHBOR_ADDR_STR2 | |
5629 | "Filter updates to/from this neighbor\n" | |
5630 | "Name of a prefix list\n" | |
5631 | "Filter incoming updates\n" | |
5632 | "Filter outgoing updates\n") | |
5633 | { | |
d62a17ae | 5634 | int idx_peer = 2; |
5635 | int idx_in_out = 5; | |
5636 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
5637 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5638 | argv[idx_in_out]->arg); | |
718e3744 | 5639 | } |
6b0655a2 | 5640 | |
d62a17ae | 5641 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, |
5642 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5643 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5644 | "Filter updates to/from this neighbor\n" | |
5645 | "Name of a prefix list\n" | |
5646 | "Filter incoming updates\n" | |
5647 | "Filter outgoing updates\n") | |
596c17ba | 5648 | |
d62a17ae | 5649 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5650 | safi_t safi, const char *name_str, | |
5651 | const char *direct_str) | |
718e3744 | 5652 | { |
d62a17ae | 5653 | int ret; |
5654 | struct peer *peer; | |
5655 | int direct = FILTER_IN; | |
718e3744 | 5656 | |
d62a17ae | 5657 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5658 | if (!peer) | |
5659 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5660 | |
d62a17ae | 5661 | /* Check filter direction. */ |
5662 | if (strncmp(direct_str, "i", 1) == 0) | |
5663 | direct = FILTER_IN; | |
5664 | else if (strncmp(direct_str, "o", 1) == 0) | |
5665 | direct = FILTER_OUT; | |
718e3744 | 5666 | |
d62a17ae | 5667 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 5668 | |
d62a17ae | 5669 | return bgp_vty_return(vty, ret); |
718e3744 | 5670 | } |
5671 | ||
d62a17ae | 5672 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5673 | safi_t safi, const char *direct_str) | |
718e3744 | 5674 | { |
d62a17ae | 5675 | int ret; |
5676 | struct peer *peer; | |
5677 | int direct = FILTER_IN; | |
718e3744 | 5678 | |
d62a17ae | 5679 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5680 | if (!peer) | |
5681 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5682 | |
d62a17ae | 5683 | /* Check filter direction. */ |
5684 | if (strncmp(direct_str, "i", 1) == 0) | |
5685 | direct = FILTER_IN; | |
5686 | else if (strncmp(direct_str, "o", 1) == 0) | |
5687 | direct = FILTER_OUT; | |
718e3744 | 5688 | |
d62a17ae | 5689 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 5690 | |
d62a17ae | 5691 | return bgp_vty_return(vty, ret); |
718e3744 | 5692 | } |
5693 | ||
5694 | DEFUN (neighbor_filter_list, | |
5695 | neighbor_filter_list_cmd, | |
9ccf14f7 | 5696 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5697 | NEIGHBOR_STR |
5698 | NEIGHBOR_ADDR_STR2 | |
5699 | "Establish BGP filters\n" | |
5700 | "AS path access-list name\n" | |
5701 | "Filter incoming routes\n" | |
5702 | "Filter outgoing routes\n") | |
5703 | { | |
d62a17ae | 5704 | int idx_peer = 1; |
5705 | int idx_word = 3; | |
5706 | int idx_in_out = 4; | |
5707 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5708 | bgp_node_safi(vty), argv[idx_word]->arg, | |
5709 | argv[idx_in_out]->arg); | |
718e3744 | 5710 | } |
5711 | ||
d62a17ae | 5712 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
5713 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5714 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5715 | "Establish BGP filters\n" | |
5716 | "AS path access-list name\n" | |
5717 | "Filter incoming routes\n" | |
5718 | "Filter outgoing routes\n") | |
596c17ba | 5719 | |
718e3744 | 5720 | DEFUN (no_neighbor_filter_list, |
5721 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 5722 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5723 | NO_STR |
5724 | NEIGHBOR_STR | |
5725 | NEIGHBOR_ADDR_STR2 | |
5726 | "Establish BGP filters\n" | |
5727 | "AS path access-list name\n" | |
5728 | "Filter incoming routes\n" | |
5729 | "Filter outgoing routes\n") | |
5730 | { | |
d62a17ae | 5731 | int idx_peer = 2; |
5732 | int idx_in_out = 5; | |
5733 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
5734 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5735 | argv[idx_in_out]->arg); | |
718e3744 | 5736 | } |
6b0655a2 | 5737 | |
d62a17ae | 5738 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
5739 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5740 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5741 | "Establish BGP filters\n" | |
5742 | "AS path access-list name\n" | |
5743 | "Filter incoming routes\n" | |
5744 | "Filter outgoing routes\n") | |
596c17ba | 5745 | |
718e3744 | 5746 | /* Set route-map to the peer. */ |
d62a17ae | 5747 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
5748 | afi_t afi, safi_t safi, const char *name_str, | |
5749 | const char *direct_str) | |
718e3744 | 5750 | { |
d62a17ae | 5751 | int ret; |
5752 | struct peer *peer; | |
5753 | int direct = RMAP_IN; | |
1de27621 | 5754 | struct route_map *route_map; |
718e3744 | 5755 | |
d62a17ae | 5756 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5757 | if (!peer) | |
5758 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5759 | |
d62a17ae | 5760 | /* Check filter direction. */ |
5761 | if (strncmp(direct_str, "in", 2) == 0) | |
5762 | direct = RMAP_IN; | |
5763 | else if (strncmp(direct_str, "o", 1) == 0) | |
5764 | direct = RMAP_OUT; | |
718e3744 | 5765 | |
1de27621 DA |
5766 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
5767 | ret = peer_route_map_set(peer, afi, safi, direct, name_str, route_map); | |
718e3744 | 5768 | |
d62a17ae | 5769 | return bgp_vty_return(vty, ret); |
718e3744 | 5770 | } |
5771 | ||
d62a17ae | 5772 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, |
5773 | afi_t afi, safi_t safi, | |
5774 | const char *direct_str) | |
718e3744 | 5775 | { |
d62a17ae | 5776 | int ret; |
5777 | struct peer *peer; | |
5778 | int direct = RMAP_IN; | |
718e3744 | 5779 | |
d62a17ae | 5780 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5781 | if (!peer) | |
5782 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5783 | |
d62a17ae | 5784 | /* Check filter direction. */ |
5785 | if (strncmp(direct_str, "in", 2) == 0) | |
5786 | direct = RMAP_IN; | |
5787 | else if (strncmp(direct_str, "o", 1) == 0) | |
5788 | direct = RMAP_OUT; | |
718e3744 | 5789 | |
d62a17ae | 5790 | ret = peer_route_map_unset(peer, afi, safi, direct); |
718e3744 | 5791 | |
d62a17ae | 5792 | return bgp_vty_return(vty, ret); |
718e3744 | 5793 | } |
5794 | ||
5795 | DEFUN (neighbor_route_map, | |
5796 | neighbor_route_map_cmd, | |
9ccf14f7 | 5797 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5798 | NEIGHBOR_STR |
5799 | NEIGHBOR_ADDR_STR2 | |
5800 | "Apply route map to neighbor\n" | |
5801 | "Name of route map\n" | |
5802 | "Apply map to incoming routes\n" | |
2a3d5731 | 5803 | "Apply map to outbound routes\n") |
718e3744 | 5804 | { |
d62a17ae | 5805 | int idx_peer = 1; |
5806 | int idx_word = 3; | |
5807 | int idx_in_out = 4; | |
5808 | return peer_route_map_set_vty( | |
5809 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5810 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5811 | } |
5812 | ||
d62a17ae | 5813 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
5814 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5815 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5816 | "Apply route map to neighbor\n" | |
5817 | "Name of route map\n" | |
5818 | "Apply map to incoming routes\n" | |
5819 | "Apply map to outbound routes\n") | |
596c17ba | 5820 | |
718e3744 | 5821 | DEFUN (no_neighbor_route_map, |
5822 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 5823 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5824 | NO_STR |
5825 | NEIGHBOR_STR | |
5826 | NEIGHBOR_ADDR_STR2 | |
5827 | "Apply route map to neighbor\n" | |
5828 | "Name of route map\n" | |
5829 | "Apply map to incoming routes\n" | |
2a3d5731 | 5830 | "Apply map to outbound routes\n") |
718e3744 | 5831 | { |
d62a17ae | 5832 | int idx_peer = 2; |
5833 | int idx_in_out = 5; | |
5834 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
5835 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5836 | argv[idx_in_out]->arg); | |
718e3744 | 5837 | } |
6b0655a2 | 5838 | |
d62a17ae | 5839 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, |
5840 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5841 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5842 | "Apply route map to neighbor\n" | |
5843 | "Name of route map\n" | |
5844 | "Apply map to incoming routes\n" | |
5845 | "Apply map to outbound routes\n") | |
596c17ba | 5846 | |
718e3744 | 5847 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 5848 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
5849 | afi_t afi, safi_t safi, | |
5850 | const char *name_str) | |
718e3744 | 5851 | { |
d62a17ae | 5852 | int ret; |
5853 | struct peer *peer; | |
1de27621 | 5854 | struct route_map *route_map; |
718e3744 | 5855 | |
d62a17ae | 5856 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5857 | if (!peer) | |
5858 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5859 | |
1de27621 DA |
5860 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
5861 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str, route_map); | |
718e3744 | 5862 | |
d62a17ae | 5863 | return bgp_vty_return(vty, ret); |
718e3744 | 5864 | } |
5865 | ||
5866 | /* Unset route-map from the peer. */ | |
d62a17ae | 5867 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
5868 | afi_t afi, safi_t safi) | |
718e3744 | 5869 | { |
d62a17ae | 5870 | int ret; |
5871 | struct peer *peer; | |
718e3744 | 5872 | |
d62a17ae | 5873 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5874 | if (!peer) | |
5875 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5876 | |
d62a17ae | 5877 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 5878 | |
d62a17ae | 5879 | return bgp_vty_return(vty, ret); |
718e3744 | 5880 | } |
5881 | ||
5882 | DEFUN (neighbor_unsuppress_map, | |
5883 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5884 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5885 | NEIGHBOR_STR |
5886 | NEIGHBOR_ADDR_STR2 | |
5887 | "Route-map to selectively unsuppress suppressed routes\n" | |
5888 | "Name of route map\n") | |
5889 | { | |
d62a17ae | 5890 | int idx_peer = 1; |
5891 | int idx_word = 3; | |
5892 | return peer_unsuppress_map_set_vty( | |
5893 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5894 | argv[idx_word]->arg); | |
718e3744 | 5895 | } |
5896 | ||
d62a17ae | 5897 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
5898 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5899 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5900 | "Route-map to selectively unsuppress suppressed routes\n" | |
5901 | "Name of route map\n") | |
596c17ba | 5902 | |
718e3744 | 5903 | DEFUN (no_neighbor_unsuppress_map, |
5904 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5905 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5906 | NO_STR |
5907 | NEIGHBOR_STR | |
5908 | NEIGHBOR_ADDR_STR2 | |
5909 | "Route-map to selectively unsuppress suppressed routes\n" | |
5910 | "Name of route map\n") | |
5911 | { | |
d62a17ae | 5912 | int idx_peer = 2; |
5913 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
5914 | bgp_node_afi(vty), | |
5915 | bgp_node_safi(vty)); | |
718e3744 | 5916 | } |
6b0655a2 | 5917 | |
d62a17ae | 5918 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
5919 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5920 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5921 | "Route-map to selectively unsuppress suppressed routes\n" | |
5922 | "Name of route map\n") | |
596c17ba | 5923 | |
d62a17ae | 5924 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
5925 | afi_t afi, safi_t safi, | |
5926 | const char *num_str, | |
5927 | const char *threshold_str, int warning, | |
5928 | const char *restart_str) | |
718e3744 | 5929 | { |
d62a17ae | 5930 | int ret; |
5931 | struct peer *peer; | |
d7c0a89a QY |
5932 | uint32_t max; |
5933 | uint8_t threshold; | |
5934 | uint16_t restart; | |
718e3744 | 5935 | |
d62a17ae | 5936 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5937 | if (!peer) | |
5938 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5939 | |
d62a17ae | 5940 | max = strtoul(num_str, NULL, 10); |
5941 | if (threshold_str) | |
5942 | threshold = atoi(threshold_str); | |
5943 | else | |
5944 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 5945 | |
d62a17ae | 5946 | if (restart_str) |
5947 | restart = atoi(restart_str); | |
5948 | else | |
5949 | restart = 0; | |
0a486e5f | 5950 | |
d62a17ae | 5951 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, |
5952 | restart); | |
718e3744 | 5953 | |
d62a17ae | 5954 | return bgp_vty_return(vty, ret); |
718e3744 | 5955 | } |
5956 | ||
d62a17ae | 5957 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, |
5958 | afi_t afi, safi_t safi) | |
718e3744 | 5959 | { |
d62a17ae | 5960 | int ret; |
5961 | struct peer *peer; | |
718e3744 | 5962 | |
d62a17ae | 5963 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5964 | if (!peer) | |
5965 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5966 | |
d62a17ae | 5967 | ret = peer_maximum_prefix_unset(peer, afi, safi); |
718e3744 | 5968 | |
d62a17ae | 5969 | return bgp_vty_return(vty, ret); |
718e3744 | 5970 | } |
5971 | ||
5972 | /* Maximum number of prefix configuration. prefix count is different | |
5973 | for each peer configuration. So this configuration can be set for | |
5974 | each peer configuration. */ | |
5975 | DEFUN (neighbor_maximum_prefix, | |
5976 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 5977 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 5978 | NEIGHBOR_STR |
5979 | NEIGHBOR_ADDR_STR2 | |
5980 | "Maximum number of prefix accept from this peer\n" | |
5981 | "maximum no. of prefix limit\n") | |
5982 | { | |
d62a17ae | 5983 | int idx_peer = 1; |
5984 | int idx_number = 3; | |
5985 | return peer_maximum_prefix_set_vty( | |
5986 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5987 | argv[idx_number]->arg, NULL, 0, NULL); | |
718e3744 | 5988 | } |
5989 | ||
d62a17ae | 5990 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
5991 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", | |
5992 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5993 | "Maximum number of prefix accept from this peer\n" | |
5994 | "maximum no. of prefix limit\n") | |
596c17ba | 5995 | |
e0701b79 | 5996 | DEFUN (neighbor_maximum_prefix_threshold, |
5997 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 5998 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 5999 | NEIGHBOR_STR |
6000 | NEIGHBOR_ADDR_STR2 | |
6001 | "Maximum number of prefix accept from this peer\n" | |
6002 | "maximum no. of prefix limit\n" | |
6003 | "Threshold value (%) at which to generate a warning msg\n") | |
6004 | { | |
d62a17ae | 6005 | int idx_peer = 1; |
6006 | int idx_number = 3; | |
6007 | int idx_number_2 = 4; | |
6008 | return peer_maximum_prefix_set_vty( | |
6009 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6010 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL); | |
0a486e5f | 6011 | } |
e0701b79 | 6012 | |
d62a17ae | 6013 | ALIAS_HIDDEN( |
6014 | neighbor_maximum_prefix_threshold, | |
6015 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
6016 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", | |
6017 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6018 | "Maximum number of prefix accept from this peer\n" | |
6019 | "maximum no. of prefix limit\n" | |
6020 | "Threshold value (%) at which to generate a warning msg\n") | |
596c17ba | 6021 | |
718e3744 | 6022 | DEFUN (neighbor_maximum_prefix_warning, |
6023 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 6024 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 6025 | NEIGHBOR_STR |
6026 | NEIGHBOR_ADDR_STR2 | |
6027 | "Maximum number of prefix accept from this peer\n" | |
6028 | "maximum no. of prefix limit\n" | |
6029 | "Only give warning message when limit is exceeded\n") | |
6030 | { | |
d62a17ae | 6031 | int idx_peer = 1; |
6032 | int idx_number = 3; | |
6033 | return peer_maximum_prefix_set_vty( | |
6034 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6035 | argv[idx_number]->arg, NULL, 1, NULL); | |
718e3744 | 6036 | } |
6037 | ||
d62a17ae | 6038 | ALIAS_HIDDEN( |
6039 | neighbor_maximum_prefix_warning, | |
6040 | neighbor_maximum_prefix_warning_hidden_cmd, | |
6041 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", | |
6042 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6043 | "Maximum number of prefix accept from this peer\n" | |
6044 | "maximum no. of prefix limit\n" | |
6045 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6046 | |
e0701b79 | 6047 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
6048 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 6049 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 6050 | NEIGHBOR_STR |
6051 | NEIGHBOR_ADDR_STR2 | |
6052 | "Maximum number of prefix accept from this peer\n" | |
6053 | "maximum no. of prefix limit\n" | |
6054 | "Threshold value (%) at which to generate a warning msg\n" | |
6055 | "Only give warning message when limit is exceeded\n") | |
6056 | { | |
d62a17ae | 6057 | int idx_peer = 1; |
6058 | int idx_number = 3; | |
6059 | int idx_number_2 = 4; | |
6060 | return peer_maximum_prefix_set_vty( | |
6061 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6062 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 6063 | } |
6064 | ||
d62a17ae | 6065 | ALIAS_HIDDEN( |
6066 | neighbor_maximum_prefix_threshold_warning, | |
6067 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
6068 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", | |
6069 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6070 | "Maximum number of prefix accept from this peer\n" | |
6071 | "maximum no. of prefix limit\n" | |
6072 | "Threshold value (%) at which to generate a warning msg\n" | |
6073 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6074 | |
0a486e5f | 6075 | DEFUN (neighbor_maximum_prefix_restart, |
6076 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 6077 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 6078 | NEIGHBOR_STR |
6079 | NEIGHBOR_ADDR_STR2 | |
6080 | "Maximum number of prefix accept from this peer\n" | |
6081 | "maximum no. of prefix limit\n" | |
6082 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 6083 | "Restart interval in minutes\n") |
0a486e5f | 6084 | { |
d62a17ae | 6085 | int idx_peer = 1; |
6086 | int idx_number = 3; | |
6087 | int idx_number_2 = 5; | |
6088 | return peer_maximum_prefix_set_vty( | |
6089 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6090 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 6091 | } |
6092 | ||
d62a17ae | 6093 | ALIAS_HIDDEN( |
6094 | neighbor_maximum_prefix_restart, | |
6095 | neighbor_maximum_prefix_restart_hidden_cmd, | |
6096 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", | |
6097 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6098 | "Maximum number of prefix accept from this peer\n" | |
6099 | "maximum no. of prefix limit\n" | |
6100 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 6101 | "Restart interval in minutes\n") |
596c17ba | 6102 | |
0a486e5f | 6103 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
6104 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 6105 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 6106 | NEIGHBOR_STR |
6107 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6108 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 6109 | "maximum no. of prefix limit\n" |
6110 | "Threshold value (%) at which to generate a warning msg\n" | |
6111 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6112 | "Restart interval in minutes\n") |
0a486e5f | 6113 | { |
d62a17ae | 6114 | int idx_peer = 1; |
6115 | int idx_number = 3; | |
6116 | int idx_number_2 = 4; | |
6117 | int idx_number_3 = 6; | |
6118 | return peer_maximum_prefix_set_vty( | |
6119 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6120 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
6121 | argv[idx_number_3]->arg); | |
6122 | } | |
6123 | ||
6124 | ALIAS_HIDDEN( | |
6125 | neighbor_maximum_prefix_threshold_restart, | |
6126 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
6127 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", | |
6128 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6129 | "Maximum number of prefixes to accept from this peer\n" | |
6130 | "maximum no. of prefix limit\n" | |
6131 | "Threshold value (%) at which to generate a warning msg\n" | |
6132 | "Restart bgp connection after limit is exceeded\n" | |
6133 | "Restart interval in minutes\n") | |
596c17ba | 6134 | |
718e3744 | 6135 | DEFUN (no_neighbor_maximum_prefix, |
6136 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 6137 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 6138 | NO_STR |
6139 | NEIGHBOR_STR | |
6140 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6141 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
6142 | "maximum no. of prefix limit\n" |
6143 | "Threshold value (%) at which to generate a warning msg\n" | |
6144 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6145 | "Restart interval in minutes\n" |
31500417 | 6146 | "Only give warning message when limit is exceeded\n") |
718e3744 | 6147 | { |
d62a17ae | 6148 | int idx_peer = 2; |
6149 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, | |
6150 | bgp_node_afi(vty), | |
6151 | bgp_node_safi(vty)); | |
718e3744 | 6152 | } |
e52702f2 | 6153 | |
d62a17ae | 6154 | ALIAS_HIDDEN( |
6155 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
6156 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", | |
6157 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6158 | "Maximum number of prefixes to accept from this peer\n" | |
6159 | "maximum no. of prefix limit\n" | |
6160 | "Threshold value (%) at which to generate a warning msg\n" | |
6161 | "Restart bgp connection after limit is exceeded\n" | |
6162 | "Restart interval in minutes\n" | |
6163 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6164 | |
718e3744 | 6165 | |
718e3744 | 6166 | /* "neighbor allowas-in" */ |
6167 | DEFUN (neighbor_allowas_in, | |
6168 | neighbor_allowas_in_cmd, | |
fd8503f5 | 6169 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6170 | NEIGHBOR_STR |
6171 | NEIGHBOR_ADDR_STR2 | |
31500417 | 6172 | "Accept as-path with my AS present in it\n" |
f79f7a7b | 6173 | "Number of occurrences of AS number\n" |
fd8503f5 | 6174 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 6175 | { |
d62a17ae | 6176 | int idx_peer = 1; |
6177 | int idx_number_origin = 3; | |
6178 | int ret; | |
6179 | int origin = 0; | |
6180 | struct peer *peer; | |
6181 | int allow_num = 0; | |
6182 | ||
6183 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6184 | if (!peer) | |
6185 | return CMD_WARNING_CONFIG_FAILED; | |
6186 | ||
6187 | if (argc <= idx_number_origin) | |
6188 | allow_num = 3; | |
6189 | else { | |
6190 | if (argv[idx_number_origin]->type == WORD_TKN) | |
6191 | origin = 1; | |
6192 | else | |
6193 | allow_num = atoi(argv[idx_number_origin]->arg); | |
6194 | } | |
6195 | ||
6196 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6197 | allow_num, origin); | |
6198 | ||
6199 | return bgp_vty_return(vty, ret); | |
6200 | } | |
6201 | ||
6202 | ALIAS_HIDDEN( | |
6203 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
6204 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6205 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6206 | "Accept as-path with my AS present in it\n" | |
f79f7a7b | 6207 | "Number of occurrences of AS number\n" |
d62a17ae | 6208 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 6209 | |
718e3744 | 6210 | DEFUN (no_neighbor_allowas_in, |
6211 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 6212 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6213 | NO_STR |
6214 | NEIGHBOR_STR | |
6215 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 6216 | "allow local ASN appears in aspath attribute\n" |
f79f7a7b | 6217 | "Number of occurrences of AS number\n" |
fd8503f5 | 6218 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 6219 | { |
d62a17ae | 6220 | int idx_peer = 2; |
6221 | int ret; | |
6222 | struct peer *peer; | |
718e3744 | 6223 | |
d62a17ae | 6224 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6225 | if (!peer) | |
6226 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6227 | |
d62a17ae | 6228 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
6229 | bgp_node_safi(vty)); | |
718e3744 | 6230 | |
d62a17ae | 6231 | return bgp_vty_return(vty, ret); |
718e3744 | 6232 | } |
6b0655a2 | 6233 | |
d62a17ae | 6234 | ALIAS_HIDDEN( |
6235 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
6236 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6237 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6238 | "allow local ASN appears in aspath attribute\n" | |
f79f7a7b | 6239 | "Number of occurrences of AS number\n" |
d62a17ae | 6240 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 6241 | |
fa411a21 NH |
6242 | DEFUN (neighbor_ttl_security, |
6243 | neighbor_ttl_security_cmd, | |
7ebe625c | 6244 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 | 6245 | NEIGHBOR_STR |
7ebe625c | 6246 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6247 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
6248 | "Specify the maximum number of hops to the BGP peer\n" |
6249 | "Number of hops to BGP peer\n") | |
fa411a21 | 6250 | { |
d62a17ae | 6251 | int idx_peer = 1; |
6252 | int idx_number = 4; | |
6253 | struct peer *peer; | |
6254 | int gtsm_hops; | |
6255 | ||
6256 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6257 | if (!peer) | |
6258 | return CMD_WARNING_CONFIG_FAILED; | |
6259 | ||
6260 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); | |
6261 | ||
7ebe625c QY |
6262 | /* |
6263 | * If 'neighbor swpX', then this is for directly connected peers, | |
6264 | * we should not accept a ttl-security hops value greater than 1. | |
6265 | */ | |
6266 | if (peer->conf_if && (gtsm_hops > 1)) { | |
6267 | vty_out(vty, | |
6268 | "%s is directly connected peer, hops cannot exceed 1\n", | |
6269 | argv[idx_peer]->arg); | |
6270 | return CMD_WARNING_CONFIG_FAILED; | |
6271 | } | |
6272 | ||
d62a17ae | 6273 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
6274 | } |
6275 | ||
6276 | DEFUN (no_neighbor_ttl_security, | |
6277 | no_neighbor_ttl_security_cmd, | |
7ebe625c | 6278 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
6279 | NO_STR |
6280 | NEIGHBOR_STR | |
7ebe625c | 6281 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6282 | "BGP ttl-security parameters\n" |
3a2d747c QY |
6283 | "Specify the maximum number of hops to the BGP peer\n" |
6284 | "Number of hops to BGP peer\n") | |
fa411a21 | 6285 | { |
d62a17ae | 6286 | int idx_peer = 2; |
6287 | struct peer *peer; | |
fa411a21 | 6288 | |
d62a17ae | 6289 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6290 | if (!peer) | |
6291 | return CMD_WARNING_CONFIG_FAILED; | |
fa411a21 | 6292 | |
d62a17ae | 6293 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 6294 | } |
6b0655a2 | 6295 | |
adbac85e DW |
6296 | DEFUN (neighbor_addpath_tx_all_paths, |
6297 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6298 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6299 | NEIGHBOR_STR |
6300 | NEIGHBOR_ADDR_STR2 | |
6301 | "Use addpath to advertise all paths to a neighbor\n") | |
6302 | { | |
d62a17ae | 6303 | int idx_peer = 1; |
6304 | struct peer *peer; | |
adbac85e | 6305 | |
d62a17ae | 6306 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6307 | if (!peer) | |
6308 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 6309 | |
dcc68b5e MS |
6310 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
6311 | BGP_ADDPATH_ALL); | |
6312 | return CMD_SUCCESS; | |
adbac85e DW |
6313 | } |
6314 | ||
d62a17ae | 6315 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
6316 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
6317 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6318 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6319 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6320 | |
adbac85e DW |
6321 | DEFUN (no_neighbor_addpath_tx_all_paths, |
6322 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6323 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6324 | NO_STR |
6325 | NEIGHBOR_STR | |
6326 | NEIGHBOR_ADDR_STR2 | |
6327 | "Use addpath to advertise all paths to a neighbor\n") | |
6328 | { | |
d62a17ae | 6329 | int idx_peer = 2; |
dcc68b5e MS |
6330 | struct peer *peer; |
6331 | ||
6332 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6333 | if (!peer) | |
6334 | return CMD_WARNING_CONFIG_FAILED; | |
6335 | ||
6336 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
6337 | != BGP_ADDPATH_ALL) { | |
6338 | vty_out(vty, | |
6339 | "%% Peer not currently configured to transmit all paths."); | |
6340 | return CMD_WARNING_CONFIG_FAILED; | |
6341 | } | |
6342 | ||
6343 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6344 | BGP_ADDPATH_NONE); | |
6345 | ||
6346 | return CMD_SUCCESS; | |
adbac85e DW |
6347 | } |
6348 | ||
d62a17ae | 6349 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
6350 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
6351 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6352 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6353 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6354 | |
06370dac DW |
6355 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
6356 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6357 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6358 | NEIGHBOR_STR |
6359 | NEIGHBOR_ADDR_STR2 | |
6360 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6361 | { | |
d62a17ae | 6362 | int idx_peer = 1; |
6363 | struct peer *peer; | |
06370dac | 6364 | |
d62a17ae | 6365 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6366 | if (!peer) | |
6367 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 6368 | |
dcc68b5e MS |
6369 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
6370 | BGP_ADDPATH_BEST_PER_AS); | |
6371 | ||
6372 | return CMD_SUCCESS; | |
06370dac DW |
6373 | } |
6374 | ||
d62a17ae | 6375 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
6376 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6377 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6378 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6379 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 6380 | |
06370dac DW |
6381 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
6382 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6383 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6384 | NO_STR |
6385 | NEIGHBOR_STR | |
6386 | NEIGHBOR_ADDR_STR2 | |
6387 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6388 | { | |
d62a17ae | 6389 | int idx_peer = 2; |
dcc68b5e MS |
6390 | struct peer *peer; |
6391 | ||
6392 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6393 | if (!peer) | |
6394 | return CMD_WARNING_CONFIG_FAILED; | |
6395 | ||
6396 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
6397 | != BGP_ADDPATH_BEST_PER_AS) { | |
6398 | vty_out(vty, | |
6399 | "%% Peer not currently configured to transmit all best path per as."); | |
6400 | return CMD_WARNING_CONFIG_FAILED; | |
6401 | } | |
6402 | ||
6403 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6404 | BGP_ADDPATH_NONE); | |
6405 | ||
6406 | return CMD_SUCCESS; | |
06370dac DW |
6407 | } |
6408 | ||
d62a17ae | 6409 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
6410 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6411 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6412 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6413 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 6414 | |
b9c7bc5a PZ |
6415 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
6416 | struct ecommunity **list) | |
ddb5b488 | 6417 | { |
b9c7bc5a PZ |
6418 | struct ecommunity *ecom = NULL; |
6419 | struct ecommunity *ecomadd; | |
ddb5b488 | 6420 | |
b9c7bc5a | 6421 | for (; argc; --argc, ++argv) { |
ddb5b488 | 6422 | |
b9c7bc5a PZ |
6423 | ecomadd = ecommunity_str2com(argv[0]->arg, |
6424 | ECOMMUNITY_ROUTE_TARGET, 0); | |
6425 | if (!ecomadd) { | |
6426 | vty_out(vty, "Malformed community-list value\n"); | |
6427 | if (ecom) | |
6428 | ecommunity_free(&ecom); | |
6429 | return CMD_WARNING_CONFIG_FAILED; | |
6430 | } | |
ddb5b488 | 6431 | |
b9c7bc5a PZ |
6432 | if (ecom) { |
6433 | ecommunity_merge(ecom, ecomadd); | |
6434 | ecommunity_free(&ecomadd); | |
6435 | } else { | |
6436 | ecom = ecomadd; | |
6437 | } | |
6438 | } | |
6439 | ||
6440 | if (*list) { | |
6441 | ecommunity_free(&*list); | |
ddb5b488 | 6442 | } |
b9c7bc5a PZ |
6443 | *list = ecom; |
6444 | ||
6445 | return CMD_SUCCESS; | |
ddb5b488 PZ |
6446 | } |
6447 | ||
0ca70ba5 DS |
6448 | /* |
6449 | * v2vimport is true if we are handling a `import vrf ...` command | |
6450 | */ | |
6451 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 6452 | { |
0ca70ba5 DS |
6453 | afi_t afi; |
6454 | ||
ddb5b488 | 6455 | switch (vty->node) { |
b9c7bc5a | 6456 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
6457 | afi = AFI_IP; |
6458 | break; | |
b9c7bc5a | 6459 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
6460 | afi = AFI_IP6; |
6461 | break; | |
ddb5b488 PZ |
6462 | default: |
6463 | vty_out(vty, | |
b9c7bc5a | 6464 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 6465 | return AFI_MAX; |
ddb5b488 | 6466 | } |
69b07479 | 6467 | |
0ca70ba5 DS |
6468 | if (!v2vimport) { |
6469 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6470 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
6471 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6472 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
6473 | vty_out(vty, | |
6474 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
6475 | return AFI_MAX; | |
6476 | } | |
6477 | } else { | |
6478 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6479 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
6480 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6481 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
6482 | vty_out(vty, | |
6483 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
6484 | return AFI_MAX; | |
6485 | } | |
6486 | } | |
6487 | return afi; | |
ddb5b488 PZ |
6488 | } |
6489 | ||
b9c7bc5a PZ |
6490 | DEFPY (af_rd_vpn_export, |
6491 | af_rd_vpn_export_cmd, | |
6492 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
6493 | NO_STR | |
ddb5b488 | 6494 | "Specify route distinguisher\n" |
b9c7bc5a PZ |
6495 | "Between current address-family and vpn\n" |
6496 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6497 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") |
6498 | { | |
6499 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6500 | struct prefix_rd prd; | |
6501 | int ret; | |
ddb5b488 | 6502 | afi_t afi; |
b9c7bc5a PZ |
6503 | int idx = 0; |
6504 | int yes = 1; | |
ddb5b488 | 6505 | |
b9c7bc5a | 6506 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6507 | yes = 0; |
b9c7bc5a PZ |
6508 | |
6509 | if (yes) { | |
6510 | ret = str2prefix_rd(rd_str, &prd); | |
6511 | if (!ret) { | |
6512 | vty_out(vty, "%% Malformed rd\n"); | |
6513 | return CMD_WARNING_CONFIG_FAILED; | |
6514 | } | |
ddb5b488 PZ |
6515 | } |
6516 | ||
0ca70ba5 | 6517 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6518 | if (afi == AFI_MAX) |
6519 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6520 | |
69b07479 DS |
6521 | /* |
6522 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6523 | */ | |
6524 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6525 | bgp_get_default(), bgp); | |
ddb5b488 | 6526 | |
69b07479 DS |
6527 | if (yes) { |
6528 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
6529 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6530 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
6531 | } else { | |
6532 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
6533 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
ddb5b488 PZ |
6534 | } |
6535 | ||
69b07479 DS |
6536 | /* post-change: re-export vpn routes */ |
6537 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6538 | bgp_get_default(), bgp); | |
6539 | ||
ddb5b488 PZ |
6540 | return CMD_SUCCESS; |
6541 | } | |
6542 | ||
b9c7bc5a PZ |
6543 | ALIAS (af_rd_vpn_export, |
6544 | af_no_rd_vpn_export_cmd, | |
6545 | "no rd vpn export", | |
ddb5b488 | 6546 | NO_STR |
b9c7bc5a PZ |
6547 | "Specify route distinguisher\n" |
6548 | "Between current address-family and vpn\n" | |
6549 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6550 | |
b9c7bc5a PZ |
6551 | DEFPY (af_label_vpn_export, |
6552 | af_label_vpn_export_cmd, | |
e70e9f8e | 6553 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 6554 | NO_STR |
ddb5b488 | 6555 | "label value for VRF\n" |
b9c7bc5a PZ |
6556 | "Between current address-family and vpn\n" |
6557 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
6558 | "Label Value <0-1048575>\n" |
6559 | "Automatically assign a label\n") | |
ddb5b488 PZ |
6560 | { |
6561 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 6562 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 6563 | afi_t afi; |
b9c7bc5a PZ |
6564 | int idx = 0; |
6565 | int yes = 1; | |
6566 | ||
6567 | if (argv_find(argv, argc, "no", &idx)) | |
d555f3e9 | 6568 | yes = 0; |
ddb5b488 | 6569 | |
21a16cc2 PZ |
6570 | /* If "no ...", squash trailing parameter */ |
6571 | if (!yes) | |
6572 | label_auto = NULL; | |
6573 | ||
e70e9f8e PZ |
6574 | if (yes) { |
6575 | if (!label_auto) | |
6576 | label = label_val; /* parser should force unsigned */ | |
6577 | } | |
ddb5b488 | 6578 | |
0ca70ba5 | 6579 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6580 | if (afi == AFI_MAX) |
6581 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 6582 | |
e70e9f8e | 6583 | |
69b07479 DS |
6584 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
6585 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
6586 | /* no change */ | |
6587 | return CMD_SUCCESS; | |
e70e9f8e | 6588 | |
69b07479 DS |
6589 | /* |
6590 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6591 | */ | |
6592 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6593 | bgp_get_default(), bgp); | |
6594 | ||
6595 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
6596 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
6597 | ||
6598 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
6599 | ||
6600 | /* | |
6601 | * label has previously been automatically | |
6602 | * assigned by labelpool: release it | |
6603 | * | |
6604 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
6605 | * means the automatic assignment is in flight | |
6606 | * and therefore the labelpool callback must | |
6607 | * detect that the auto label is not needed. | |
6608 | */ | |
6609 | ||
6610 | bgp_lp_release(LP_TYPE_VRF, | |
6611 | &bgp->vpn_policy[afi], | |
6612 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 6613 | } |
69b07479 DS |
6614 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
6615 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
6616 | } | |
ddb5b488 | 6617 | |
69b07479 DS |
6618 | bgp->vpn_policy[afi].tovpn_label = label; |
6619 | if (label_auto) { | |
6620 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6621 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
6622 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
6623 | vpn_leak_label_callback); | |
ddb5b488 PZ |
6624 | } |
6625 | ||
69b07479 DS |
6626 | /* post-change: re-export vpn routes */ |
6627 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6628 | bgp_get_default(), bgp); | |
6629 | ||
ddb5b488 PZ |
6630 | return CMD_SUCCESS; |
6631 | } | |
6632 | ||
b9c7bc5a PZ |
6633 | ALIAS (af_label_vpn_export, |
6634 | af_no_label_vpn_export_cmd, | |
6635 | "no label vpn export", | |
6636 | NO_STR | |
6637 | "label value for VRF\n" | |
6638 | "Between current address-family and vpn\n" | |
6639 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6640 | |
b9c7bc5a PZ |
6641 | DEFPY (af_nexthop_vpn_export, |
6642 | af_nexthop_vpn_export_cmd, | |
6643 | "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str", | |
6644 | NO_STR | |
ddb5b488 | 6645 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
6646 | "Between current address-family and vpn\n" |
6647 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6648 | "IPv4 prefix\n" |
6649 | "IPv6 prefix\n") | |
6650 | { | |
6651 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
ddb5b488 | 6652 | afi_t afi; |
ddb5b488 | 6653 | struct prefix p; |
b9c7bc5a PZ |
6654 | int idx = 0; |
6655 | int yes = 1; | |
ddb5b488 | 6656 | |
b9c7bc5a | 6657 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6658 | yes = 0; |
b9c7bc5a PZ |
6659 | |
6660 | if (yes) { | |
6661 | if (!sockunion2hostprefix(nexthop_str, &p)) | |
6662 | return CMD_WARNING_CONFIG_FAILED; | |
6663 | } | |
ddb5b488 | 6664 | |
0ca70ba5 | 6665 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6666 | if (afi == AFI_MAX) |
6667 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6668 | |
69b07479 DS |
6669 | /* |
6670 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6671 | */ | |
6672 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6673 | bgp_get_default(), bgp); | |
ddb5b488 | 6674 | |
69b07479 DS |
6675 | if (yes) { |
6676 | bgp->vpn_policy[afi].tovpn_nexthop = p; | |
6677 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6678 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
6679 | } else { | |
6680 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
6681 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
ddb5b488 PZ |
6682 | } |
6683 | ||
69b07479 DS |
6684 | /* post-change: re-export vpn routes */ |
6685 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6686 | bgp_get_default(), bgp); | |
6687 | ||
ddb5b488 PZ |
6688 | return CMD_SUCCESS; |
6689 | } | |
6690 | ||
b9c7bc5a PZ |
6691 | ALIAS (af_nexthop_vpn_export, |
6692 | af_no_nexthop_vpn_export_cmd, | |
6693 | "no nexthop vpn export", | |
ddb5b488 | 6694 | NO_STR |
b9c7bc5a PZ |
6695 | "Specify next hop to use for VRF advertised prefixes\n" |
6696 | "Between current address-family and vpn\n" | |
6697 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6698 | |
b9c7bc5a | 6699 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 6700 | { |
b9c7bc5a PZ |
6701 | if (!strcmp(dstr, "import")) { |
6702 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
6703 | } else if (!strcmp(dstr, "export")) { | |
6704 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
6705 | } else if (!strcmp(dstr, "both")) { | |
6706 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
6707 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
6708 | } else { | |
6709 | vty_out(vty, "%% direction parse error\n"); | |
6710 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6711 | } |
ddb5b488 PZ |
6712 | return CMD_SUCCESS; |
6713 | } | |
6714 | ||
b9c7bc5a PZ |
6715 | DEFPY (af_rt_vpn_imexport, |
6716 | af_rt_vpn_imexport_cmd, | |
6717 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
6718 | NO_STR | |
6719 | "Specify route target list\n" | |
ddb5b488 | 6720 | "Specify route target list\n" |
b9c7bc5a PZ |
6721 | "Between current address-family and vpn\n" |
6722 | "For routes leaked from vpn to current address-family: match any\n" | |
6723 | "For routes leaked from current address-family to vpn: set\n" | |
6724 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
6725 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
6726 | { | |
6727 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6728 | int ret; | |
6729 | struct ecommunity *ecom = NULL; | |
6730 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
6731 | vpn_policy_direction_t dir; |
6732 | afi_t afi; | |
6733 | int idx = 0; | |
b9c7bc5a | 6734 | int yes = 1; |
ddb5b488 | 6735 | |
b9c7bc5a | 6736 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6737 | yes = 0; |
b9c7bc5a | 6738 | |
0ca70ba5 | 6739 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6740 | if (afi == AFI_MAX) |
6741 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6742 | |
b9c7bc5a | 6743 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
6744 | if (ret != CMD_SUCCESS) |
6745 | return ret; | |
6746 | ||
b9c7bc5a PZ |
6747 | if (yes) { |
6748 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
6749 | vty_out(vty, "%% Missing RTLIST\n"); | |
6750 | return CMD_WARNING_CONFIG_FAILED; | |
6751 | } | |
6752 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
6753 | if (ret != CMD_SUCCESS) { | |
6754 | return ret; | |
6755 | } | |
ddb5b488 PZ |
6756 | } |
6757 | ||
69b07479 DS |
6758 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
6759 | if (!dodir[dir]) | |
ddb5b488 | 6760 | continue; |
ddb5b488 | 6761 | |
69b07479 | 6762 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 6763 | |
69b07479 DS |
6764 | if (yes) { |
6765 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
6766 | ecommunity_free( | |
6767 | &bgp->vpn_policy[afi].rtlist[dir]); | |
6768 | bgp->vpn_policy[afi].rtlist[dir] = | |
6769 | ecommunity_dup(ecom); | |
6770 | } else { | |
6771 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
6772 | ecommunity_free( | |
6773 | &bgp->vpn_policy[afi].rtlist[dir]); | |
6774 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 6775 | } |
69b07479 DS |
6776 | |
6777 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 6778 | } |
69b07479 | 6779 | |
d555f3e9 PZ |
6780 | if (ecom) |
6781 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
6782 | |
6783 | return CMD_SUCCESS; | |
6784 | } | |
6785 | ||
b9c7bc5a PZ |
6786 | ALIAS (af_rt_vpn_imexport, |
6787 | af_no_rt_vpn_imexport_cmd, | |
6788 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
6789 | NO_STR |
6790 | "Specify route target list\n" | |
b9c7bc5a PZ |
6791 | "Specify route target list\n" |
6792 | "Between current address-family and vpn\n" | |
6793 | "For routes leaked from vpn to current address-family\n" | |
6794 | "For routes leaked from current address-family to vpn\n" | |
6795 | "both import and export\n") | |
6796 | ||
6797 | DEFPY (af_route_map_vpn_imexport, | |
6798 | af_route_map_vpn_imexport_cmd, | |
6799 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
6800 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
6801 | NO_STR | |
ddb5b488 | 6802 | "Specify route map\n" |
b9c7bc5a PZ |
6803 | "Between current address-family and vpn\n" |
6804 | "For routes leaked from vpn to current address-family\n" | |
6805 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6806 | "name of route-map\n") |
6807 | { | |
6808 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6809 | int ret; | |
6810 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
6811 | vpn_policy_direction_t dir; |
6812 | afi_t afi; | |
ddb5b488 | 6813 | int idx = 0; |
b9c7bc5a | 6814 | int yes = 1; |
ddb5b488 | 6815 | |
b9c7bc5a | 6816 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6817 | yes = 0; |
b9c7bc5a | 6818 | |
0ca70ba5 | 6819 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6820 | if (afi == AFI_MAX) |
6821 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6822 | |
b9c7bc5a | 6823 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
6824 | if (ret != CMD_SUCCESS) |
6825 | return ret; | |
6826 | ||
69b07479 DS |
6827 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
6828 | if (!dodir[dir]) | |
ddb5b488 | 6829 | continue; |
ddb5b488 | 6830 | |
69b07479 | 6831 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 6832 | |
69b07479 DS |
6833 | if (yes) { |
6834 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6835 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6836 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6837 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
6838 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
6839 | bgp->vpn_policy[afi].rmap[dir] = | |
1de27621 | 6840 | route_map_lookup_warn_noexist(vty, rmap_str); |
69b07479 DS |
6841 | if (!bgp->vpn_policy[afi].rmap[dir]) |
6842 | return CMD_SUCCESS; | |
6843 | } else { | |
6844 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6845 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6846 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6847 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
6848 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
ddb5b488 | 6849 | } |
69b07479 DS |
6850 | |
6851 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 PZ |
6852 | } |
6853 | ||
6854 | return CMD_SUCCESS; | |
6855 | } | |
6856 | ||
b9c7bc5a PZ |
6857 | ALIAS (af_route_map_vpn_imexport, |
6858 | af_no_route_map_vpn_imexport_cmd, | |
6859 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
6860 | NO_STR |
6861 | "Specify route map\n" | |
b9c7bc5a PZ |
6862 | "Between current address-family and vpn\n" |
6863 | "For routes leaked from vpn to current address-family\n" | |
6864 | "For routes leaked from current address-family to vpn\n") | |
6865 | ||
bb4f6190 DS |
6866 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
6867 | "[no] import vrf route-map RMAP$rmap_str", | |
6868 | NO_STR | |
6869 | "Import routes from another VRF\n" | |
6870 | "Vrf routes being filtered\n" | |
6871 | "Specify route map\n" | |
6872 | "name of route-map\n") | |
6873 | { | |
6874 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
bb4f6190 DS |
6875 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; |
6876 | afi_t afi; | |
6877 | int idx = 0; | |
6878 | int yes = 1; | |
6879 | struct bgp *bgp_default; | |
6880 | ||
6881 | if (argv_find(argv, argc, "no", &idx)) | |
6882 | yes = 0; | |
6883 | ||
0ca70ba5 | 6884 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
6885 | if (afi == AFI_MAX) |
6886 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
6887 | |
6888 | bgp_default = bgp_get_default(); | |
6889 | if (!bgp_default) { | |
6890 | int32_t ret; | |
6891 | as_t as = bgp->as; | |
6892 | ||
6893 | /* Auto-create assuming the same AS */ | |
6894 | ret = bgp_get(&bgp_default, &as, NULL, | |
6895 | BGP_INSTANCE_TYPE_DEFAULT); | |
6896 | ||
6897 | if (ret) { | |
6898 | vty_out(vty, | |
6899 | "VRF default is not configured as a bgp instance\n"); | |
6900 | return CMD_WARNING; | |
6901 | } | |
6902 | } | |
6903 | ||
69b07479 | 6904 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 6905 | |
69b07479 DS |
6906 | if (yes) { |
6907 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6908 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6909 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6910 | bgp->vpn_policy[afi].rmap_name[dir] = | |
6911 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
6912 | bgp->vpn_policy[afi].rmap[dir] = | |
1de27621 | 6913 | route_map_lookup_warn_noexist(vty, rmap_str); |
69b07479 DS |
6914 | if (!bgp->vpn_policy[afi].rmap[dir]) |
6915 | return CMD_SUCCESS; | |
6916 | } else { | |
6917 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6918 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6919 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6920 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
6921 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
bb4f6190 DS |
6922 | } |
6923 | ||
69b07479 DS |
6924 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
6925 | ||
bb4f6190 DS |
6926 | return CMD_SUCCESS; |
6927 | } | |
6928 | ||
6929 | ALIAS(af_import_vrf_route_map, af_no_import_vrf_route_map_cmd, | |
6930 | "no import vrf route-map", | |
6931 | NO_STR | |
6932 | "Import routes from another VRF\n" | |
6933 | "Vrf routes being filtered\n" | |
6934 | "Specify route map\n") | |
6935 | ||
4d1b335c DA |
6936 | DEFPY(bgp_imexport_vrf, bgp_imexport_vrf_cmd, |
6937 | "[no] import vrf VIEWVRFNAME$import_name", | |
6938 | NO_STR | |
6939 | "Import routes from another VRF\n" | |
6940 | "VRF to import from\n" | |
6941 | "The name of the VRF\n") | |
12a844a5 DS |
6942 | { |
6943 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6944 | struct listnode *node; | |
79ef8664 DS |
6945 | struct bgp *vrf_bgp, *bgp_default; |
6946 | int32_t ret = 0; | |
6947 | as_t as = bgp->as; | |
12a844a5 DS |
6948 | bool remove = false; |
6949 | int32_t idx = 0; | |
6950 | char *vname; | |
a8dadcf6 | 6951 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; |
12a844a5 DS |
6952 | safi_t safi; |
6953 | afi_t afi; | |
6954 | ||
867f0cca | 6955 | if (import_name == NULL) { |
6956 | vty_out(vty, "%% Missing import name\n"); | |
6957 | return CMD_WARNING; | |
6958 | } | |
6959 | ||
12a844a5 DS |
6960 | if (argv_find(argv, argc, "no", &idx)) |
6961 | remove = true; | |
6962 | ||
0ca70ba5 DS |
6963 | afi = vpn_policy_getafi(vty, bgp, true); |
6964 | if (afi == AFI_MAX) | |
6965 | return CMD_WARNING_CONFIG_FAILED; | |
6966 | ||
12a844a5 DS |
6967 | safi = bgp_node_safi(vty); |
6968 | ||
25679caa | 6969 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) |
5742e42b | 6970 | && (strcmp(import_name, VRF_DEFAULT_NAME) == 0)) |
25679caa DS |
6971 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { |
6972 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
6973 | remove ? "unimport" : "import", import_name); | |
6974 | return CMD_WARNING; | |
6975 | } | |
6976 | ||
79ef8664 DS |
6977 | bgp_default = bgp_get_default(); |
6978 | if (!bgp_default) { | |
6979 | /* Auto-create assuming the same AS */ | |
6980 | ret = bgp_get(&bgp_default, &as, NULL, | |
6981 | BGP_INSTANCE_TYPE_DEFAULT); | |
6982 | ||
6983 | if (ret) { | |
6984 | vty_out(vty, | |
6985 | "VRF default is not configured as a bgp instance\n"); | |
6986 | return CMD_WARNING; | |
6987 | } | |
6988 | } | |
6989 | ||
12a844a5 DS |
6990 | vrf_bgp = bgp_lookup_by_name(import_name); |
6991 | if (!vrf_bgp) { | |
5742e42b | 6992 | if (strcmp(import_name, VRF_DEFAULT_NAME) == 0) |
79ef8664 DS |
6993 | vrf_bgp = bgp_default; |
6994 | else | |
0fb8d6e6 DS |
6995 | /* Auto-create assuming the same AS */ |
6996 | ret = bgp_get(&vrf_bgp, &as, import_name, bgp_type); | |
a8dadcf6 | 6997 | |
6e2c7fe6 | 6998 | if (ret) { |
020a3f60 DS |
6999 | vty_out(vty, |
7000 | "VRF %s is not configured as a bgp instance\n", | |
6e2c7fe6 DS |
7001 | import_name); |
7002 | return CMD_WARNING; | |
7003 | } | |
12a844a5 DS |
7004 | } |
7005 | ||
12a844a5 | 7006 | if (remove) { |
44338987 | 7007 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 | 7008 | } else { |
44338987 | 7009 | /* Already importing from "import_vrf"? */ |
12a844a5 DS |
7010 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, |
7011 | vname)) { | |
7012 | if (strcmp(vname, import_name) == 0) | |
7013 | return CMD_WARNING; | |
7014 | } | |
7015 | ||
44338987 | 7016 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 DS |
7017 | } |
7018 | ||
7019 | return CMD_SUCCESS; | |
7020 | } | |
7021 | ||
b9c7bc5a PZ |
7022 | /* This command is valid only in a bgp vrf instance or the default instance */ |
7023 | DEFPY (bgp_imexport_vpn, | |
7024 | bgp_imexport_vpn_cmd, | |
7025 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
7026 | NO_STR |
7027 | "Import routes to this address-family\n" | |
7028 | "Export routes from this address-family\n" | |
7029 | "to/from default instance VPN RIB\n") | |
ddb5b488 PZ |
7030 | { |
7031 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 7032 | int previous_state; |
ddb5b488 | 7033 | afi_t afi; |
b9c7bc5a | 7034 | safi_t safi; |
ddb5b488 | 7035 | int idx = 0; |
b9c7bc5a PZ |
7036 | int yes = 1; |
7037 | int flag; | |
7038 | vpn_policy_direction_t dir; | |
ddb5b488 | 7039 | |
b9c7bc5a | 7040 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7041 | yes = 0; |
ddb5b488 | 7042 | |
b9c7bc5a PZ |
7043 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && |
7044 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
ddb5b488 | 7045 | |
b9c7bc5a PZ |
7046 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); |
7047 | return CMD_WARNING_CONFIG_FAILED; | |
7048 | } | |
ddb5b488 | 7049 | |
b9c7bc5a PZ |
7050 | afi = bgp_node_afi(vty); |
7051 | safi = bgp_node_safi(vty); | |
7052 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { | |
7053 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
7054 | return CMD_WARNING_CONFIG_FAILED; | |
7055 | } | |
ddb5b488 | 7056 | |
b9c7bc5a PZ |
7057 | if (!strcmp(direction_str, "import")) { |
7058 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; | |
7059 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
7060 | } else if (!strcmp(direction_str, "export")) { | |
7061 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; | |
7062 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
7063 | } else { | |
7064 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
7065 | return CMD_WARNING_CONFIG_FAILED; | |
7066 | } | |
7067 | ||
7068 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 | 7069 | |
b9c7bc5a PZ |
7070 | if (yes) { |
7071 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
7072 | if (!previous_state) { | |
7073 | /* trigger export current vrf */ | |
ddb5b488 PZ |
7074 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
7075 | } | |
b9c7bc5a PZ |
7076 | } else { |
7077 | if (previous_state) { | |
7078 | /* trigger un-export current vrf */ | |
7079 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
7080 | } | |
7081 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 PZ |
7082 | } |
7083 | ||
7084 | return CMD_SUCCESS; | |
7085 | } | |
7086 | ||
301ad80a PG |
7087 | DEFPY (af_routetarget_import, |
7088 | af_routetarget_import_cmd, | |
7089 | "[no] <rt|route-target> redirect import RTLIST...", | |
7090 | NO_STR | |
7091 | "Specify route target list\n" | |
7092 | "Specify route target list\n" | |
7093 | "Flow-spec redirect type route target\n" | |
7094 | "Import routes to this address-family\n" | |
7095 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") | |
7096 | { | |
7097 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7098 | int ret; | |
7099 | struct ecommunity *ecom = NULL; | |
301ad80a PG |
7100 | afi_t afi; |
7101 | int idx = 0; | |
7102 | int yes = 1; | |
7103 | ||
7104 | if (argv_find(argv, argc, "no", &idx)) | |
7105 | yes = 0; | |
7106 | ||
0ca70ba5 | 7107 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7108 | if (afi == AFI_MAX) |
7109 | return CMD_WARNING_CONFIG_FAILED; | |
7110 | ||
301ad80a PG |
7111 | if (yes) { |
7112 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
7113 | vty_out(vty, "%% Missing RTLIST\n"); | |
7114 | return CMD_WARNING_CONFIG_FAILED; | |
7115 | } | |
7116 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
7117 | if (ret != CMD_SUCCESS) | |
7118 | return ret; | |
7119 | } | |
69b07479 DS |
7120 | |
7121 | if (yes) { | |
7122 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
7123 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 7124 | .import_redirect_rtlist); |
69b07479 DS |
7125 | bgp->vpn_policy[afi].import_redirect_rtlist = |
7126 | ecommunity_dup(ecom); | |
7127 | } else { | |
7128 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
7129 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 7130 | .import_redirect_rtlist); |
69b07479 | 7131 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 7132 | } |
69b07479 | 7133 | |
301ad80a PG |
7134 | if (ecom) |
7135 | ecommunity_free(&ecom); | |
7136 | ||
7137 | return CMD_SUCCESS; | |
7138 | } | |
7139 | ||
505e5056 | 7140 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 7141 | address_family_ipv4_safi_cmd, |
7142 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
7143 | "Enter Address Family command mode\n" | |
7144 | "Address Family\n" | |
7145 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
718e3744 | 7146 | { |
f51bae9c | 7147 | |
d62a17ae | 7148 | if (argc == 3) { |
2131d5cf | 7149 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7150 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
7151 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
7152 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 7153 | && safi != SAFI_EVPN) { |
31947174 MK |
7154 | vty_out(vty, |
7155 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
7156 | return CMD_WARNING_CONFIG_FAILED; |
7157 | } | |
d62a17ae | 7158 | vty->node = bgp_node_type(AFI_IP, safi); |
7159 | } else | |
7160 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 7161 | |
d62a17ae | 7162 | return CMD_SUCCESS; |
718e3744 | 7163 | } |
7164 | ||
505e5056 | 7165 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 7166 | address_family_ipv6_safi_cmd, |
7167 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
7168 | "Enter Address Family command mode\n" | |
7169 | "Address Family\n" | |
7170 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
25ffbdc1 | 7171 | { |
d62a17ae | 7172 | if (argc == 3) { |
2131d5cf | 7173 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7174 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
7175 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
7176 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 7177 | && safi != SAFI_EVPN) { |
31947174 MK |
7178 | vty_out(vty, |
7179 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
7180 | return CMD_WARNING_CONFIG_FAILED; |
7181 | } | |
d62a17ae | 7182 | vty->node = bgp_node_type(AFI_IP6, safi); |
7183 | } else | |
7184 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 7185 | |
d62a17ae | 7186 | return CMD_SUCCESS; |
25ffbdc1 | 7187 | } |
718e3744 | 7188 | |
d6902373 | 7189 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 7190 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 7191 | address_family_vpnv4_cmd, |
8334fd5a | 7192 | "address-family vpnv4 [unicast]", |
718e3744 | 7193 | "Enter Address Family command mode\n" |
8c3deaae | 7194 | "Address Family\n" |
3a2d747c | 7195 | "Address Family modifier\n") |
718e3744 | 7196 | { |
d62a17ae | 7197 | vty->node = BGP_VPNV4_NODE; |
7198 | return CMD_SUCCESS; | |
718e3744 | 7199 | } |
7200 | ||
505e5056 | 7201 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 7202 | address_family_vpnv6_cmd, |
8334fd5a | 7203 | "address-family vpnv6 [unicast]", |
8ecd3266 | 7204 | "Enter Address Family command mode\n" |
8c3deaae | 7205 | "Address Family\n" |
3a2d747c | 7206 | "Address Family modifier\n") |
8ecd3266 | 7207 | { |
d62a17ae | 7208 | vty->node = BGP_VPNV6_NODE; |
7209 | return CMD_SUCCESS; | |
8ecd3266 | 7210 | } |
64e4a6c5 | 7211 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
d6902373 | 7212 | |
505e5056 | 7213 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 7214 | address_family_evpn_cmd, |
7111c1a0 | 7215 | "address-family l2vpn evpn", |
4e0b7b6d | 7216 | "Enter Address Family command mode\n" |
7111c1a0 QY |
7217 | "Address Family\n" |
7218 | "Address Family modifier\n") | |
4e0b7b6d | 7219 | { |
2131d5cf | 7220 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7221 | vty->node = BGP_EVPN_NODE; |
7222 | return CMD_SUCCESS; | |
4e0b7b6d PG |
7223 | } |
7224 | ||
505e5056 | 7225 | DEFUN_NOSH (exit_address_family, |
718e3744 | 7226 | exit_address_family_cmd, |
7227 | "exit-address-family", | |
7228 | "Exit from Address Family configuration mode\n") | |
7229 | { | |
d62a17ae | 7230 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
7231 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
7232 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
7233 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
7234 | || vty->node == BGP_EVPN_NODE |
7235 | || vty->node == BGP_FLOWSPECV4_NODE | |
7236 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 7237 | vty->node = BGP_NODE; |
7238 | return CMD_SUCCESS; | |
718e3744 | 7239 | } |
6b0655a2 | 7240 | |
8ad7271d | 7241 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 7242 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
7243 | const char *ip_str, afi_t afi, safi_t safi, | |
7244 | struct prefix_rd *prd) | |
7245 | { | |
7246 | int ret; | |
7247 | struct prefix match; | |
7248 | struct bgp_node *rn; | |
7249 | struct bgp_node *rm; | |
7250 | struct bgp *bgp; | |
7251 | struct bgp_table *table; | |
7252 | struct bgp_table *rib; | |
7253 | ||
7254 | /* BGP structure lookup. */ | |
7255 | if (view_name) { | |
7256 | bgp = bgp_lookup_by_name(view_name); | |
7257 | if (bgp == NULL) { | |
7258 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
7259 | view_name); | |
7260 | return CMD_WARNING; | |
7261 | } | |
7262 | } else { | |
7263 | bgp = bgp_get_default(); | |
7264 | if (bgp == NULL) { | |
7265 | vty_out(vty, "%% No BGP process is configured\n"); | |
7266 | return CMD_WARNING; | |
7267 | } | |
7268 | } | |
7269 | ||
7270 | /* Check IP address argument. */ | |
7271 | ret = str2prefix(ip_str, &match); | |
7272 | if (!ret) { | |
7273 | vty_out(vty, "%% address is malformed\n"); | |
7274 | return CMD_WARNING; | |
7275 | } | |
7276 | ||
7277 | match.family = afi2family(afi); | |
7278 | rib = bgp->rib[afi][safi]; | |
7279 | ||
7280 | if (safi == SAFI_MPLS_VPN) { | |
7281 | for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) { | |
7282 | if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0) | |
7283 | continue; | |
7284 | ||
67009e22 DS |
7285 | table = bgp_node_get_bgp_table_info(rn); |
7286 | if (table != NULL) { | |
7287 | ||
d62a17ae | 7288 | if ((rm = bgp_node_match(table, &match)) |
7289 | != NULL) { | |
7290 | if (rm->p.prefixlen | |
7291 | == match.prefixlen) { | |
343cdb61 | 7292 | SET_FLAG(rm->flags, |
d62a17ae | 7293 | BGP_NODE_USER_CLEAR); |
7294 | bgp_process(bgp, rm, afi, safi); | |
7295 | } | |
7296 | bgp_unlock_node(rm); | |
7297 | } | |
7298 | } | |
7299 | } | |
7300 | } else { | |
7301 | if ((rn = bgp_node_match(rib, &match)) != NULL) { | |
7302 | if (rn->p.prefixlen == match.prefixlen) { | |
7303 | SET_FLAG(rn->flags, BGP_NODE_USER_CLEAR); | |
7304 | bgp_process(bgp, rn, afi, safi); | |
7305 | } | |
7306 | bgp_unlock_node(rn); | |
7307 | } | |
7308 | } | |
7309 | ||
7310 | return CMD_SUCCESS; | |
8ad7271d DS |
7311 | } |
7312 | ||
b09b5ae0 | 7313 | /* one clear bgp command to rule them all */ |
718e3744 | 7314 | DEFUN (clear_ip_bgp_all, |
7315 | clear_ip_bgp_all_cmd, | |
d7b9898c | 7316 | "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 | 7317 | CLEAR_STR |
7318 | IP_STR | |
7319 | BGP_STR | |
838758ac | 7320 | BGP_INSTANCE_HELP_STR |
510afcd6 | 7321 | BGP_AFI_HELP_STR |
fd5e7b70 | 7322 | "Address Family\n" |
510afcd6 | 7323 | BGP_SAFI_WITH_LABEL_HELP_STR |
fd5e7b70 | 7324 | "Address Family modifier\n" |
b09b5ae0 DW |
7325 | "Clear all peers\n" |
7326 | "BGP neighbor address to clear\n" | |
a80beece | 7327 | "BGP IPv6 neighbor to clear\n" |
838758ac | 7328 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
7329 | "Clear peers with the AS number\n" |
7330 | "Clear all external peers\n" | |
718e3744 | 7331 | "Clear all members of peer-group\n" |
b09b5ae0 | 7332 | "BGP peer-group name\n" |
b09b5ae0 DW |
7333 | BGP_SOFT_STR |
7334 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
7335 | BGP_SOFT_OUT_STR |
7336 | BGP_SOFT_IN_STR | |
7337 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 7338 | BGP_SOFT_OUT_STR) |
718e3744 | 7339 | { |
d62a17ae | 7340 | char *vrf = NULL; |
7341 | ||
dc912615 DS |
7342 | afi_t afi = AFI_UNSPEC; |
7343 | safi_t safi = SAFI_UNSPEC; | |
d62a17ae | 7344 | enum clear_sort clr_sort = clear_peer; |
7345 | enum bgp_clear_type clr_type; | |
7346 | char *clr_arg = NULL; | |
7347 | ||
7348 | int idx = 0; | |
7349 | ||
7350 | /* clear [ip] bgp */ | |
7351 | if (argv_find(argv, argc, "ip", &idx)) | |
7352 | afi = AFI_IP; | |
7353 | ||
9a8bdf1c PG |
7354 | /* [<vrf> VIEWVRFNAME] */ |
7355 | if (argv_find(argv, argc, "vrf", &idx)) { | |
7356 | vrf = argv[idx + 1]->arg; | |
7357 | idx += 2; | |
7358 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
7359 | vrf = NULL; | |
7360 | } else if (argv_find(argv, argc, "view", &idx)) { | |
7361 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 7362 | vrf = argv[idx + 1]->arg; |
7363 | idx += 2; | |
7364 | } | |
d62a17ae | 7365 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
7366 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
7367 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
7368 | ||
d7b9898c | 7369 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */ |
d62a17ae | 7370 | if (argv_find(argv, argc, "*", &idx)) { |
7371 | clr_sort = clear_all; | |
7372 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
7373 | clr_sort = clear_peer; | |
7374 | clr_arg = argv[idx]->arg; | |
7375 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
7376 | clr_sort = clear_peer; | |
7377 | clr_arg = argv[idx]->arg; | |
7378 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
7379 | clr_sort = clear_group; | |
7380 | idx++; | |
7381 | clr_arg = argv[idx]->arg; | |
d7b9898c | 7382 | } else if (argv_find(argv, argc, "PGNAME", &idx)) { |
d62a17ae | 7383 | clr_sort = clear_peer; |
7384 | clr_arg = argv[idx]->arg; | |
8fa7d444 DS |
7385 | } else if (argv_find(argv, argc, "WORD", &idx)) { |
7386 | clr_sort = clear_peer; | |
7387 | clr_arg = argv[idx]->arg; | |
d62a17ae | 7388 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { |
7389 | clr_sort = clear_as; | |
7390 | clr_arg = argv[idx]->arg; | |
7391 | } else if (argv_find(argv, argc, "external", &idx)) { | |
7392 | clr_sort = clear_external; | |
7393 | } | |
7394 | ||
7395 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
7396 | if (argv_find(argv, argc, "soft", &idx)) { | |
7397 | if (argv_find(argv, argc, "in", &idx) | |
7398 | || argv_find(argv, argc, "out", &idx)) | |
7399 | clr_type = strmatch(argv[idx]->text, "in") | |
7400 | ? BGP_CLEAR_SOFT_IN | |
7401 | : BGP_CLEAR_SOFT_OUT; | |
7402 | else | |
7403 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
7404 | } else if (argv_find(argv, argc, "in", &idx)) { | |
7405 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
7406 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
7407 | : BGP_CLEAR_SOFT_IN; | |
7408 | } else if (argv_find(argv, argc, "out", &idx)) { | |
7409 | clr_type = BGP_CLEAR_SOFT_OUT; | |
7410 | } else | |
7411 | clr_type = BGP_CLEAR_SOFT_NONE; | |
7412 | ||
7413 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); | |
838758ac | 7414 | } |
01080f7c | 7415 | |
8ad7271d DS |
7416 | DEFUN (clear_ip_bgp_prefix, |
7417 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 7418 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
7419 | CLEAR_STR |
7420 | IP_STR | |
7421 | BGP_STR | |
838758ac | 7422 | BGP_INSTANCE_HELP_STR |
8ad7271d | 7423 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7424 | "IPv4 prefix\n") |
8ad7271d | 7425 | { |
d62a17ae | 7426 | char *vrf = NULL; |
7427 | char *prefix = NULL; | |
8ad7271d | 7428 | |
d62a17ae | 7429 | int idx = 0; |
01080f7c | 7430 | |
d62a17ae | 7431 | /* [<view|vrf> VIEWVRFNAME] */ |
9a8bdf1c PG |
7432 | if (argv_find(argv, argc, "vrf", &idx)) { |
7433 | vrf = argv[idx + 1]->arg; | |
7434 | idx += 2; | |
7435 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
7436 | vrf = NULL; | |
7437 | } else if (argv_find(argv, argc, "view", &idx)) { | |
7438 | /* [<view> VIEWVRFNAME] */ | |
7439 | vrf = argv[idx + 1]->arg; | |
7440 | idx += 2; | |
7441 | } | |
0c7b1b01 | 7442 | |
d62a17ae | 7443 | prefix = argv[argc - 1]->arg; |
8ad7271d | 7444 | |
d62a17ae | 7445 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 7446 | } |
8ad7271d | 7447 | |
b09b5ae0 DW |
7448 | DEFUN (clear_bgp_ipv6_safi_prefix, |
7449 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 7450 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 7451 | CLEAR_STR |
3a2d747c | 7452 | IP_STR |
718e3744 | 7453 | BGP_STR |
8c3deaae | 7454 | "Address Family\n" |
46f296b4 | 7455 | BGP_SAFI_HELP_STR |
b09b5ae0 | 7456 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7457 | "IPv6 prefix\n") |
718e3744 | 7458 | { |
9b475e76 PG |
7459 | int idx_safi = 0; |
7460 | int idx_ipv6_prefix = 0; | |
7461 | safi_t safi = SAFI_UNICAST; | |
7462 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
7463 | argv[idx_ipv6_prefix]->arg : NULL; | |
7464 | ||
7465 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 7466 | return bgp_clear_prefix( |
9b475e76 PG |
7467 | vty, NULL, prefix, AFI_IP6, |
7468 | safi, NULL); | |
838758ac | 7469 | } |
01080f7c | 7470 | |
b09b5ae0 DW |
7471 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
7472 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 7473 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 7474 | CLEAR_STR |
3a2d747c | 7475 | IP_STR |
718e3744 | 7476 | BGP_STR |
838758ac | 7477 | BGP_INSTANCE_HELP_STR |
8c3deaae | 7478 | "Address Family\n" |
46f296b4 | 7479 | BGP_SAFI_HELP_STR |
b09b5ae0 | 7480 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7481 | "IPv6 prefix\n") |
718e3744 | 7482 | { |
9b475e76 | 7483 | int idx_safi = 0; |
9a8bdf1c | 7484 | int idx_vrfview = 0; |
9b475e76 PG |
7485 | int idx_ipv6_prefix = 0; |
7486 | safi_t safi = SAFI_UNICAST; | |
7487 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
7488 | argv[idx_ipv6_prefix]->arg : NULL; | |
9a8bdf1c | 7489 | char *vrfview = NULL; |
9b475e76 | 7490 | |
9a8bdf1c PG |
7491 | /* [<view|vrf> VIEWVRFNAME] */ |
7492 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
7493 | vrfview = argv[idx_vrfview + 1]->arg; | |
7494 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
7495 | vrfview = NULL; | |
7496 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
7497 | /* [<view> VIEWVRFNAME] */ | |
7498 | vrfview = argv[idx_vrfview + 1]->arg; | |
7499 | } | |
9b475e76 PG |
7500 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); |
7501 | ||
d62a17ae | 7502 | return bgp_clear_prefix( |
9b475e76 PG |
7503 | vty, vrfview, prefix, |
7504 | AFI_IP6, safi, NULL); | |
718e3744 | 7505 | } |
7506 | ||
b09b5ae0 DW |
7507 | DEFUN (show_bgp_views, |
7508 | show_bgp_views_cmd, | |
d6e3c605 | 7509 | "show [ip] bgp views", |
b09b5ae0 | 7510 | SHOW_STR |
d6e3c605 | 7511 | IP_STR |
01080f7c | 7512 | BGP_STR |
b09b5ae0 | 7513 | "Show the defined BGP views\n") |
01080f7c | 7514 | { |
d62a17ae | 7515 | struct list *inst = bm->bgp; |
7516 | struct listnode *node; | |
7517 | struct bgp *bgp; | |
01080f7c | 7518 | |
d62a17ae | 7519 | vty_out(vty, "Defined BGP views:\n"); |
7520 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
7521 | /* Skip VRFs. */ | |
7522 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
7523 | continue; | |
7524 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
7525 | bgp->as); | |
7526 | } | |
e52702f2 | 7527 | |
d62a17ae | 7528 | return CMD_SUCCESS; |
e0081f70 ML |
7529 | } |
7530 | ||
8386ac43 | 7531 | DEFUN (show_bgp_vrfs, |
7532 | show_bgp_vrfs_cmd, | |
d6e3c605 | 7533 | "show [ip] bgp vrfs [json]", |
8386ac43 | 7534 | SHOW_STR |
d6e3c605 | 7535 | IP_STR |
8386ac43 | 7536 | BGP_STR |
7537 | "Show BGP VRFs\n" | |
9973d184 | 7538 | JSON_STR) |
8386ac43 | 7539 | { |
fe1dc5a3 | 7540 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 7541 | struct list *inst = bm->bgp; |
7542 | struct listnode *node; | |
7543 | struct bgp *bgp; | |
9f049418 | 7544 | bool uj = use_json(argc, argv); |
d62a17ae | 7545 | json_object *json = NULL; |
7546 | json_object *json_vrfs = NULL; | |
7547 | int count = 0; | |
d62a17ae | 7548 | |
d62a17ae | 7549 | if (uj) { |
7550 | json = json_object_new_object(); | |
7551 | json_vrfs = json_object_new_object(); | |
7552 | } | |
7553 | ||
7554 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
7555 | const char *name, *type; | |
7556 | struct peer *peer; | |
7fe96307 | 7557 | struct listnode *node2, *nnode2; |
d62a17ae | 7558 | int peers_cfg, peers_estb; |
7559 | json_object *json_vrf = NULL; | |
d62a17ae | 7560 | |
7561 | /* Skip Views. */ | |
7562 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
7563 | continue; | |
7564 | ||
7565 | count++; | |
efb4077a | 7566 | if (!uj && count == 1) { |
fe1dc5a3 | 7567 | vty_out(vty, |
efb4077a | 7568 | "%4s %-5s %-16s %9s %10s %-37s\n", |
a4d82a8a | 7569 | "Type", "Id", "routerId", "#PeersVfg", |
efb4077a CS |
7570 | "#PeersEstb", "Name"); |
7571 | vty_out(vty, "%11s %-16s %-21s %-6s\n", " ", | |
7572 | "L3-VNI", "RouterMAC", "Interface"); | |
7573 | } | |
d62a17ae | 7574 | |
7575 | peers_cfg = peers_estb = 0; | |
7576 | if (uj) | |
7577 | json_vrf = json_object_new_object(); | |
7578 | ||
7579 | ||
7fe96307 | 7580 | for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { |
d62a17ae | 7581 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
7582 | continue; | |
7583 | peers_cfg++; | |
7584 | if (peer->status == Established) | |
7585 | peers_estb++; | |
7586 | } | |
7587 | ||
7588 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
5742e42b | 7589 | name = VRF_DEFAULT_NAME; |
d62a17ae | 7590 | type = "DFLT"; |
7591 | } else { | |
7592 | name = bgp->name; | |
7593 | type = "VRF"; | |
7594 | } | |
7595 | ||
a8bf7d9c | 7596 | |
d62a17ae | 7597 | if (uj) { |
a4d82a8a PZ |
7598 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
7599 | ? -1 | |
7600 | : (int64_t)bgp->vrf_id; | |
d62a17ae | 7601 | json_object_string_add(json_vrf, "type", type); |
7602 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
7603 | json_object_string_add(json_vrf, "routerId", | |
7604 | inet_ntoa(bgp->router_id)); | |
7605 | json_object_int_add(json_vrf, "numConfiguredPeers", | |
7606 | peers_cfg); | |
7607 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
7608 | peers_estb); | |
7609 | ||
fe1dc5a3 | 7610 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
7611 | json_object_string_add( |
7612 | json_vrf, "rmac", | |
7613 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
efb4077a CS |
7614 | json_object_string_add(json_vrf, "interface", |
7615 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
7616 | bgp->vrf_id)); | |
d62a17ae | 7617 | json_object_object_add(json_vrfs, name, json_vrf); |
efb4077a | 7618 | } else { |
fe1dc5a3 | 7619 | vty_out(vty, |
efb4077a | 7620 | "%4s %-5d %-16s %-9u %-10u %-37s\n", |
a4d82a8a PZ |
7621 | type, |
7622 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
7623 | : (int)bgp->vrf_id, | |
7624 | inet_ntoa(bgp->router_id), peers_cfg, | |
efb4077a CS |
7625 | peers_estb, name); |
7626 | vty_out(vty,"%11s %-16u %-21s %-20s\n", " ", | |
7627 | bgp->l3vni, | |
7628 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf)), | |
7629 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
7630 | bgp->vrf_id)); | |
7631 | } | |
d62a17ae | 7632 | } |
7633 | ||
7634 | if (uj) { | |
7635 | json_object_object_add(json, "vrfs", json_vrfs); | |
7636 | ||
7637 | json_object_int_add(json, "totalVrfs", count); | |
7638 | ||
996c9314 LB |
7639 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
7640 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 7641 | json_object_free(json); |
7642 | } else { | |
7643 | if (count) | |
7644 | vty_out(vty, | |
7645 | "\nTotal number of VRFs (including default): %d\n", | |
7646 | count); | |
7647 | } | |
7648 | ||
7649 | return CMD_SUCCESS; | |
8386ac43 | 7650 | } |
7651 | ||
48ecf8f5 DS |
7652 | DEFUN (show_bgp_mac_hash, |
7653 | show_bgp_mac_hash_cmd, | |
7654 | "show bgp mac hash", | |
7655 | SHOW_STR | |
7656 | BGP_STR | |
7657 | "Mac Address\n" | |
7658 | "Mac Address database\n") | |
7659 | { | |
7660 | bgp_mac_dump_table(vty); | |
7661 | ||
7662 | return CMD_SUCCESS; | |
7663 | } | |
acf71666 | 7664 | |
e3b78da8 | 7665 | static void show_tip_entry(struct hash_bucket *bucket, void *args) |
acf71666 | 7666 | { |
0291c246 | 7667 | struct vty *vty = (struct vty *)args; |
e3b78da8 | 7668 | struct tip_addr *tip = (struct tip_addr *)bucket->data; |
acf71666 | 7669 | |
60466a63 | 7670 | vty_out(vty, "addr: %s, count: %d\n", inet_ntoa(tip->addr), |
acf71666 MK |
7671 | tip->refcnt); |
7672 | } | |
7673 | ||
7674 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
7675 | { | |
7676 | vty_out(vty, "self nexthop database:\n"); | |
af97a18b | 7677 | bgp_nexthop_show_address_hash(vty, bgp); |
acf71666 MK |
7678 | |
7679 | vty_out(vty, "Tunnel-ip database:\n"); | |
7680 | hash_iterate(bgp->tip_hash, | |
e3b78da8 | 7681 | (void (*)(struct hash_bucket *, void *))show_tip_entry, |
acf71666 MK |
7682 | vty); |
7683 | } | |
7684 | ||
15c81ca4 DS |
7685 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
7686 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
7687 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
7688 | "martian next-hops\n" |
7689 | "martian next-hop database\n") | |
acf71666 | 7690 | { |
0291c246 | 7691 | struct bgp *bgp = NULL; |
15c81ca4 | 7692 | int idx = 0; |
9a8bdf1c PG |
7693 | char *name = NULL; |
7694 | ||
7695 | /* [<vrf> VIEWVRFNAME] */ | |
7696 | if (argv_find(argv, argc, "vrf", &idx)) { | |
7697 | name = argv[idx + 1]->arg; | |
7698 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
7699 | name = NULL; | |
7700 | } else if (argv_find(argv, argc, "view", &idx)) | |
7701 | /* [<view> VIEWVRFNAME] */ | |
7702 | name = argv[idx + 1]->arg; | |
7703 | if (name) | |
7704 | bgp = bgp_lookup_by_name(name); | |
15c81ca4 DS |
7705 | else |
7706 | bgp = bgp_get_default(); | |
acf71666 | 7707 | |
acf71666 MK |
7708 | if (!bgp) { |
7709 | vty_out(vty, "%% No BGP process is configured\n"); | |
7710 | return CMD_WARNING; | |
7711 | } | |
7712 | bgp_show_martian_nexthops(vty, bgp); | |
7713 | ||
7714 | return CMD_SUCCESS; | |
7715 | } | |
7716 | ||
f412b39a | 7717 | DEFUN (show_bgp_memory, |
4bf6a362 | 7718 | show_bgp_memory_cmd, |
7fa12b13 | 7719 | "show [ip] bgp memory", |
4bf6a362 | 7720 | SHOW_STR |
3a2d747c | 7721 | IP_STR |
4bf6a362 PJ |
7722 | BGP_STR |
7723 | "Global BGP memory statistics\n") | |
7724 | { | |
d62a17ae | 7725 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
7726 | unsigned long count; | |
7727 | ||
7728 | /* RIB related usage stats */ | |
7729 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
7730 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
7731 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7732 | count * sizeof(struct bgp_node))); | |
7733 | ||
7734 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
7735 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
7736 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
4b7e6066 | 7737 | count * sizeof(struct bgp_path_info))); |
d62a17ae | 7738 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) |
7739 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
7740 | count, | |
4b7e6066 DS |
7741 | mtype_memstr( |
7742 | memstrbuf, sizeof(memstrbuf), | |
7743 | count * sizeof(struct bgp_path_info_extra))); | |
d62a17ae | 7744 | |
7745 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
7746 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
7747 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7748 | count * sizeof(struct bgp_static))); | |
7749 | ||
7750 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
7751 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
7752 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7753 | count * sizeof(struct bpacket))); | |
7754 | ||
7755 | /* Adj-In/Out */ | |
7756 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
7757 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
7758 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7759 | count * sizeof(struct bgp_adj_in))); | |
7760 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
7761 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
7762 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7763 | count * sizeof(struct bgp_adj_out))); | |
7764 | ||
7765 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
7766 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
7767 | count, | |
7768 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7769 | count * sizeof(struct bgp_nexthop_cache))); | |
7770 | ||
7771 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
7772 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
7773 | count, | |
7774 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7775 | count * sizeof(struct bgp_damp_info))); | |
7776 | ||
7777 | /* Attributes */ | |
7778 | count = attr_count(); | |
7779 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
7780 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7781 | count * sizeof(struct attr))); | |
7782 | ||
7783 | if ((count = attr_unknown_count())) | |
7784 | vty_out(vty, "%ld unknown attributes\n", count); | |
7785 | ||
7786 | /* AS_PATH attributes */ | |
7787 | count = aspath_count(); | |
7788 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
7789 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7790 | count * sizeof(struct aspath))); | |
7791 | ||
7792 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
7793 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
7794 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7795 | count * sizeof(struct assegment))); | |
7796 | ||
7797 | /* Other attributes */ | |
7798 | if ((count = community_count())) | |
7799 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
7800 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7801 | count * sizeof(struct community))); | |
d62a17ae | 7802 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
7803 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
7804 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7805 | count * sizeof(struct ecommunity))); | |
d62a17ae | 7806 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
7807 | vty_out(vty, | |
7808 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
7809 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7810 | count * sizeof(struct lcommunity))); | |
d62a17ae | 7811 | |
7812 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
7813 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
7814 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7815 | count * sizeof(struct cluster_list))); | |
7816 | ||
7817 | /* Peer related usage */ | |
7818 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
7819 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
7820 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7821 | count * sizeof(struct peer))); | |
7822 | ||
7823 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
7824 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
7825 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7826 | count * sizeof(struct peer_group))); | |
7827 | ||
7828 | /* Other */ | |
d62a17ae | 7829 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) |
7830 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
7831 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7832 | count * sizeof(regex_t))); | |
d62a17ae | 7833 | return CMD_SUCCESS; |
4bf6a362 | 7834 | } |
fee0f4c6 | 7835 | |
57a9c8a8 DS |
7836 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
7837 | { | |
7838 | json_object *bestpath = json_object_new_object(); | |
7839 | ||
7840 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_IGNORE)) | |
7841 | json_object_string_add(bestpath, "asPath", "ignore"); | |
7842 | ||
7843 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_CONFED)) | |
7844 | json_object_string_add(bestpath, "asPath", "confed"); | |
7845 | ||
7846 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { | |
a4d82a8a PZ |
7847 | if (bgp_flag_check(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) |
7848 | json_object_string_add(bestpath, "multiPathRelax", | |
57a9c8a8 DS |
7849 | "as-set"); |
7850 | else | |
a4d82a8a | 7851 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
7852 | "true"); |
7853 | } else | |
a4d82a8a | 7854 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 DS |
7855 | |
7856 | if (bgp_flag_check(bgp, BGP_FLAG_COMPARE_ROUTER_ID)) | |
7857 | json_object_string_add(bestpath, "compareRouterId", "true"); | |
7858 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED) | |
7859 | || bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
7860 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 7861 | json_object_string_add(bestpath, "med", "confed"); |
57a9c8a8 DS |
7862 | if (bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) |
7863 | json_object_string_add(bestpath, "med", | |
7864 | "missing-as-worst"); | |
7865 | else | |
7866 | json_object_string_add(bestpath, "med", "true"); | |
7867 | } | |
7868 | ||
7869 | json_object_object_add(json, "bestPath", bestpath); | |
7870 | } | |
7871 | ||
3577f1c5 DD |
7872 | /* Print the error code/subcode for why the peer is down */ |
7873 | static void bgp_show_peer_reset(struct vty * vty, struct peer *peer, | |
7874 | json_object *json_peer, bool use_json) | |
7875 | { | |
7876 | const char *code_str; | |
7877 | const char *subcode_str; | |
7878 | ||
7879 | if (use_json) { | |
7880 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
7881 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
7882 | char errorcodesubcode_hexstr[5]; | |
7883 | char errorcodesubcode_str[256]; | |
7884 | ||
7885 | code_str = bgp_notify_code_str(peer->notify.code); | |
7886 | subcode_str = bgp_notify_subcode_str( | |
7887 | peer->notify.code, | |
7888 | peer->notify.subcode); | |
7889 | ||
7890 | sprintf(errorcodesubcode_hexstr, "%02X%02X", | |
7891 | peer->notify.code, peer->notify.subcode); | |
7892 | json_object_string_add(json_peer, | |
7893 | "lastErrorCodeSubcode", | |
7894 | errorcodesubcode_hexstr); | |
7895 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
7896 | code_str, subcode_str); | |
7897 | json_object_string_add(json_peer, | |
7898 | "lastNotificationReason", | |
7899 | errorcodesubcode_str); | |
7900 | if (peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
7901 | && peer->notify.code == BGP_NOTIFY_CEASE | |
7902 | && (peer->notify.subcode | |
7903 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
7904 | || peer->notify.subcode | |
7905 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
7906 | && peer->notify.length) { | |
7907 | char msgbuf[1024]; | |
7908 | const char *msg_str; | |
7909 | ||
7910 | msg_str = bgp_notify_admin_message( | |
7911 | msgbuf, sizeof(msgbuf), | |
7912 | (uint8_t *)peer->notify.data, | |
7913 | peer->notify.length); | |
7914 | if (msg_str) | |
7915 | json_object_string_add( | |
7916 | json_peer, | |
7917 | "lastShutdownDescription", | |
7918 | msg_str); | |
7919 | } | |
7920 | ||
7921 | } | |
7922 | json_object_string_add(json_peer, "lastResetDueTo", | |
7923 | peer_down_str[(int)peer->last_reset]); | |
7924 | } else { | |
7925 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
7926 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
7927 | code_str = bgp_notify_code_str(peer->notify.code); | |
7928 | subcode_str = | |
7929 | bgp_notify_subcode_str(peer->notify.code, | |
7930 | peer->notify.subcode); | |
7931 | vty_out(vty, " Notification %s (%s%s)\n", | |
7932 | peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
7933 | ? "sent" | |
7934 | : "received", | |
7935 | code_str, subcode_str); | |
7936 | } else { | |
7937 | vty_out(vty, " %s\n", | |
7938 | peer_down_str[(int)peer->last_reset]); | |
7939 | } | |
7940 | } | |
7941 | } | |
7942 | ||
7943 | static inline bool bgp_has_peer_failed(struct peer *peer, afi_t afi, | |
7944 | safi_t safi) | |
7945 | { | |
7946 | return ((peer->status != Established) || | |
7947 | !peer->afc_recv[afi][safi]); | |
7948 | } | |
7949 | ||
7950 | static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp, | |
7951 | struct peer *peer, json_object *json_peer, | |
7952 | int max_neighbor_width, bool use_json) | |
7953 | { | |
7954 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
7955 | int len; | |
7956 | ||
7957 | if (use_json) { | |
7958 | if (peer_dynamic_neighbor(peer)) | |
7959 | json_object_boolean_true_add(json_peer, | |
7960 | "dynamicPeer"); | |
7961 | if (peer->hostname) | |
7962 | json_object_string_add(json_peer, "hostname", | |
7963 | peer->hostname); | |
7964 | ||
7965 | if (peer->domainname) | |
7966 | json_object_string_add(json_peer, "domainname", | |
7967 | peer->domainname); | |
7968 | json_object_int_add(json_peer, "connectionsEstablished", | |
7969 | peer->established); | |
7970 | json_object_int_add(json_peer, "connectionsDropped", | |
7971 | peer->dropped); | |
7972 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
7973 | use_json, json_peer); | |
7974 | if (peer->status == Established) | |
7975 | json_object_string_add(json_peer, "lastResetDueTo", | |
7976 | "AFI/SAFI Not Negotiated"); | |
7977 | else | |
7978 | bgp_show_peer_reset(NULL, peer, json_peer, true); | |
7979 | } else { | |
7980 | dn_flag[1] = '\0'; | |
7981 | dn_flag[0] = peer_dynamic_neighbor(peer) ? '*' : '\0'; | |
7982 | if (peer->hostname | |
7983 | && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) | |
7984 | len = vty_out(vty, "%s%s(%s)", dn_flag, | |
7985 | peer->hostname, peer->host); | |
7986 | else | |
7987 | len = vty_out(vty, "%s%s", dn_flag, peer->host); | |
7988 | ||
7989 | /* pad the neighbor column with spaces */ | |
7990 | if (len < max_neighbor_width) | |
7991 | vty_out(vty, "%*s", max_neighbor_width - len, | |
7992 | " "); | |
7993 | vty_out(vty, "%7d %7d %8s", peer->established, | |
7994 | peer->dropped, | |
7995 | peer_uptime(peer->uptime, timebuf, | |
7996 | BGP_UPTIME_LEN, 0, NULL)); | |
7997 | if (peer->status == Established) | |
7998 | vty_out(vty, " AFI/SAFI Not Negotiated\n"); | |
7999 | else | |
8000 | bgp_show_peer_reset(vty, peer, NULL, | |
8001 | false); | |
8002 | } | |
8003 | } | |
8004 | ||
8005 | ||
718e3744 | 8006 | /* Show BGP peer's summary information. */ |
d62a17ae | 8007 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
3577f1c5 | 8008 | bool show_failed, bool use_json) |
d62a17ae | 8009 | { |
8010 | struct peer *peer; | |
8011 | struct listnode *node, *nnode; | |
8012 | unsigned int count = 0, dn_count = 0; | |
8013 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
8014 | char neighbor_buf[VTY_BUFSIZ]; | |
8015 | int neighbor_col_default_width = 16; | |
3577f1c5 | 8016 | int len, failed_count = 0; |
d62a17ae | 8017 | int max_neighbor_width = 0; |
8018 | int pfx_rcd_safi; | |
3c13337d | 8019 | json_object *json = NULL; |
d62a17ae | 8020 | json_object *json_peer = NULL; |
8021 | json_object *json_peers = NULL; | |
50e05855 | 8022 | struct peer_af *paf; |
d62a17ae | 8023 | |
8024 | /* labeled-unicast routes are installed in the unicast table so in order | |
8025 | * to | |
8026 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
8027 | */ | |
3577f1c5 | 8028 | |
d62a17ae | 8029 | if (safi == SAFI_LABELED_UNICAST) |
8030 | pfx_rcd_safi = SAFI_UNICAST; | |
8031 | else | |
8032 | pfx_rcd_safi = safi; | |
8033 | ||
8034 | if (use_json) { | |
3c13337d | 8035 | json = json_object_new_object(); |
d62a17ae | 8036 | json_peers = json_object_new_object(); |
3577f1c5 DD |
8037 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
8038 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
8039 | continue; | |
8040 | ||
8041 | if (peer->afc[afi][safi]) { | |
8042 | /* See if we have at least a single failed peer */ | |
8043 | if (bgp_has_peer_failed(peer, afi, safi)) | |
8044 | failed_count++; | |
8045 | count++; | |
8046 | } | |
8047 | if (peer_dynamic_neighbor(peer)) | |
8048 | dn_count++; | |
8049 | } | |
8050 | ||
d62a17ae | 8051 | } else { |
8052 | /* Loop over all neighbors that will be displayed to determine | |
8053 | * how many | |
8054 | * characters are needed for the Neighbor column | |
8055 | */ | |
8056 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
8057 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
8058 | continue; | |
8059 | ||
8060 | if (peer->afc[afi][safi]) { | |
8061 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
8062 | if (peer_dynamic_neighbor(peer)) | |
8063 | dn_flag[0] = '*'; | |
8064 | ||
8065 | if (peer->hostname | |
8066 | && bgp_flag_check(bgp, | |
8067 | BGP_FLAG_SHOW_HOSTNAME)) | |
8068 | sprintf(neighbor_buf, "%s%s(%s) ", | |
8069 | dn_flag, peer->hostname, | |
8070 | peer->host); | |
8071 | else | |
8072 | sprintf(neighbor_buf, "%s%s ", dn_flag, | |
8073 | peer->host); | |
8074 | ||
8075 | len = strlen(neighbor_buf); | |
8076 | ||
8077 | if (len > max_neighbor_width) | |
8078 | max_neighbor_width = len; | |
3577f1c5 DD |
8079 | |
8080 | /* See if we have at least a single failed peer */ | |
8081 | if (bgp_has_peer_failed(peer, afi, safi)) | |
8082 | failed_count++; | |
8083 | count++; | |
d62a17ae | 8084 | } |
8085 | } | |
f933309e | 8086 | |
d62a17ae | 8087 | /* Originally we displayed the Neighbor column as 16 |
8088 | * characters wide so make that the default | |
8089 | */ | |
8090 | if (max_neighbor_width < neighbor_col_default_width) | |
8091 | max_neighbor_width = neighbor_col_default_width; | |
8092 | } | |
f933309e | 8093 | |
3577f1c5 DD |
8094 | if (show_failed && !failed_count) { |
8095 | if (use_json) { | |
8096 | json_object_int_add(json, "failedPeersCount", 0); | |
8097 | json_object_int_add(json, "dynamicPeers", dn_count); | |
8098 | json_object_int_add(json, "totalPeers", count); | |
8099 | ||
8100 | vty_out(vty, "%s\n", json_object_to_json_string_ext( | |
8101 | json, JSON_C_TO_STRING_PRETTY)); | |
8102 | json_object_free(json); | |
8103 | } else { | |
8104 | vty_out(vty, "%% No failed BGP neighbors found\n"); | |
8105 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
8106 | } | |
8107 | return CMD_SUCCESS; | |
8108 | } | |
8109 | ||
8110 | count = 0; /* Reset the value as its used again */ | |
d62a17ae | 8111 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
8112 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
8113 | continue; | |
8114 | ||
ea47320b DL |
8115 | if (!peer->afc[afi][safi]) |
8116 | continue; | |
d62a17ae | 8117 | |
ea47320b DL |
8118 | if (!count) { |
8119 | unsigned long ents; | |
8120 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 8121 | int64_t vrf_id_ui; |
d62a17ae | 8122 | |
a4d82a8a PZ |
8123 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
8124 | ? -1 | |
8125 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
8126 | |
8127 | /* Usage summary and header */ | |
8128 | if (use_json) { | |
8129 | json_object_string_add( | |
8130 | json, "routerId", | |
8131 | inet_ntoa(bgp->router_id)); | |
60466a63 QY |
8132 | json_object_int_add(json, "as", bgp->as); |
8133 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
8134 | json_object_string_add( |
8135 | json, "vrfName", | |
8136 | (bgp->inst_type | |
8137 | == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 8138 | ? VRF_DEFAULT_NAME |
ea47320b DL |
8139 | : bgp->name); |
8140 | } else { | |
8141 | vty_out(vty, | |
8142 | "BGP router identifier %s, local AS number %u vrf-id %d", | |
60466a63 | 8143 | inet_ntoa(bgp->router_id), bgp->as, |
a4d82a8a PZ |
8144 | bgp->vrf_id == VRF_UNKNOWN |
8145 | ? -1 | |
8146 | : (int)bgp->vrf_id); | |
ea47320b DL |
8147 | vty_out(vty, "\n"); |
8148 | } | |
d62a17ae | 8149 | |
ea47320b | 8150 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 8151 | if (use_json) { |
ea47320b | 8152 | json_object_int_add( |
60466a63 | 8153 | json, "updateDelayLimit", |
ea47320b | 8154 | bgp->v_update_delay); |
d62a17ae | 8155 | |
ea47320b DL |
8156 | if (bgp->v_update_delay |
8157 | != bgp->v_establish_wait) | |
d62a17ae | 8158 | json_object_int_add( |
8159 | json, | |
ea47320b DL |
8160 | "updateDelayEstablishWait", |
8161 | bgp->v_establish_wait); | |
d62a17ae | 8162 | |
60466a63 | 8163 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
8164 | json_object_string_add( |
8165 | json, | |
8166 | "updateDelayFirstNeighbor", | |
8167 | bgp->update_delay_begin_time); | |
8168 | json_object_boolean_true_add( | |
8169 | json, | |
8170 | "updateDelayInProgress"); | |
8171 | } else { | |
8172 | if (bgp->update_delay_over) { | |
d62a17ae | 8173 | json_object_string_add( |
8174 | json, | |
8175 | "updateDelayFirstNeighbor", | |
8176 | bgp->update_delay_begin_time); | |
ea47320b | 8177 | json_object_string_add( |
d62a17ae | 8178 | json, |
ea47320b DL |
8179 | "updateDelayBestpathResumed", |
8180 | bgp->update_delay_end_time); | |
8181 | json_object_string_add( | |
d62a17ae | 8182 | json, |
ea47320b DL |
8183 | "updateDelayZebraUpdateResume", |
8184 | bgp->update_delay_zebra_resume_time); | |
8185 | json_object_string_add( | |
8186 | json, | |
8187 | "updateDelayPeerUpdateResume", | |
8188 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 8189 | } |
ea47320b DL |
8190 | } |
8191 | } else { | |
8192 | vty_out(vty, | |
8193 | "Read-only mode update-delay limit: %d seconds\n", | |
8194 | bgp->v_update_delay); | |
8195 | if (bgp->v_update_delay | |
8196 | != bgp->v_establish_wait) | |
d62a17ae | 8197 | vty_out(vty, |
ea47320b DL |
8198 | " Establish wait: %d seconds\n", |
8199 | bgp->v_establish_wait); | |
d62a17ae | 8200 | |
60466a63 | 8201 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
8202 | vty_out(vty, |
8203 | " First neighbor established: %s\n", | |
8204 | bgp->update_delay_begin_time); | |
8205 | vty_out(vty, | |
8206 | " Delay in progress\n"); | |
8207 | } else { | |
8208 | if (bgp->update_delay_over) { | |
d62a17ae | 8209 | vty_out(vty, |
8210 | " First neighbor established: %s\n", | |
8211 | bgp->update_delay_begin_time); | |
8212 | vty_out(vty, | |
ea47320b DL |
8213 | " Best-paths resumed: %s\n", |
8214 | bgp->update_delay_end_time); | |
8215 | vty_out(vty, | |
8216 | " zebra update resumed: %s\n", | |
8217 | bgp->update_delay_zebra_resume_time); | |
8218 | vty_out(vty, | |
8219 | " peers update resumed: %s\n", | |
8220 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 8221 | } |
8222 | } | |
8223 | } | |
ea47320b | 8224 | } |
d62a17ae | 8225 | |
ea47320b DL |
8226 | if (use_json) { |
8227 | if (bgp_maxmed_onstartup_configured(bgp) | |
8228 | && bgp->maxmed_active) | |
8229 | json_object_boolean_true_add( | |
60466a63 | 8230 | json, "maxMedOnStartup"); |
ea47320b DL |
8231 | if (bgp->v_maxmed_admin) |
8232 | json_object_boolean_true_add( | |
60466a63 | 8233 | json, "maxMedAdministrative"); |
d62a17ae | 8234 | |
ea47320b DL |
8235 | json_object_int_add( |
8236 | json, "tableVersion", | |
60466a63 | 8237 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 8238 | |
60466a63 QY |
8239 | ents = bgp_table_count(bgp->rib[afi][safi]); |
8240 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
8241 | json_object_int_add( |
8242 | json, "ribMemory", | |
8243 | ents * sizeof(struct bgp_node)); | |
d62a17ae | 8244 | |
210ec2a0 | 8245 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 QY |
8246 | json_object_int_add(json, "peerCount", ents); |
8247 | json_object_int_add(json, "peerMemory", | |
8248 | ents * sizeof(struct peer)); | |
d62a17ae | 8249 | |
ea47320b DL |
8250 | if ((ents = listcount(bgp->group))) { |
8251 | json_object_int_add( | |
60466a63 | 8252 | json, "peerGroupCount", ents); |
ea47320b DL |
8253 | json_object_int_add( |
8254 | json, "peerGroupMemory", | |
996c9314 LB |
8255 | ents * sizeof(struct |
8256 | peer_group)); | |
ea47320b | 8257 | } |
d62a17ae | 8258 | |
ea47320b DL |
8259 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
8260 | BGP_CONFIG_DAMPENING)) | |
8261 | json_object_boolean_true_add( | |
60466a63 | 8262 | json, "dampeningEnabled"); |
ea47320b DL |
8263 | } else { |
8264 | if (bgp_maxmed_onstartup_configured(bgp) | |
8265 | && bgp->maxmed_active) | |
d62a17ae | 8266 | vty_out(vty, |
ea47320b DL |
8267 | "Max-med on-startup active\n"); |
8268 | if (bgp->v_maxmed_admin) | |
d62a17ae | 8269 | vty_out(vty, |
ea47320b | 8270 | "Max-med administrative active\n"); |
d62a17ae | 8271 | |
60466a63 QY |
8272 | vty_out(vty, "BGP table version %" PRIu64 "\n", |
8273 | bgp_table_version(bgp->rib[afi][safi])); | |
d62a17ae | 8274 | |
60466a63 | 8275 | ents = bgp_table_count(bgp->rib[afi][safi]); |
ea47320b DL |
8276 | vty_out(vty, |
8277 | "RIB entries %ld, using %s of memory\n", | |
8278 | ents, | |
996c9314 LB |
8279 | mtype_memstr(memstrbuf, |
8280 | sizeof(memstrbuf), | |
8281 | ents * sizeof(struct | |
8282 | bgp_node))); | |
ea47320b DL |
8283 | |
8284 | /* Peer related usage */ | |
210ec2a0 | 8285 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 | 8286 | vty_out(vty, "Peers %ld, using %s of memory\n", |
ea47320b DL |
8287 | ents, |
8288 | mtype_memstr( | |
60466a63 QY |
8289 | memstrbuf, sizeof(memstrbuf), |
8290 | ents * sizeof(struct peer))); | |
ea47320b DL |
8291 | |
8292 | if ((ents = listcount(bgp->group))) | |
d62a17ae | 8293 | vty_out(vty, |
ea47320b | 8294 | "Peer groups %ld, using %s of memory\n", |
d62a17ae | 8295 | ents, |
8296 | mtype_memstr( | |
8297 | memstrbuf, | |
8298 | sizeof(memstrbuf), | |
996c9314 LB |
8299 | ents * sizeof(struct |
8300 | peer_group))); | |
d62a17ae | 8301 | |
ea47320b DL |
8302 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
8303 | BGP_CONFIG_DAMPENING)) | |
60466a63 | 8304 | vty_out(vty, "Dampening enabled.\n"); |
ea47320b | 8305 | vty_out(vty, "\n"); |
d62a17ae | 8306 | |
ea47320b DL |
8307 | /* Subtract 8 here because 'Neighbor' is |
8308 | * 8 characters */ | |
8309 | vty_out(vty, "Neighbor"); | |
60466a63 QY |
8310 | vty_out(vty, "%*s", max_neighbor_width - 8, |
8311 | " "); | |
3577f1c5 DD |
8312 | if (show_failed) |
8313 | vty_out(vty, "EstdCnt DropCnt ResetTime Reason\n"); | |
8314 | else | |
8315 | vty_out(vty, | |
ea47320b | 8316 | "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n"); |
d62a17ae | 8317 | } |
ea47320b | 8318 | } |
d62a17ae | 8319 | |
ea47320b | 8320 | count++; |
3577f1c5 DD |
8321 | /* Works for both failed & successful cases */ |
8322 | if (peer_dynamic_neighbor(peer)) | |
8323 | dn_count++; | |
d62a17ae | 8324 | |
ea47320b | 8325 | if (use_json) { |
3577f1c5 DD |
8326 | json_peer = NULL; |
8327 | ||
8328 | if (show_failed && | |
8329 | bgp_has_peer_failed(peer, afi, safi)) { | |
8330 | json_peer = json_object_new_object(); | |
8331 | bgp_show_failed_summary(vty, bgp, peer, | |
8332 | json_peer, 0, use_json); | |
8333 | } else if (!show_failed) { | |
8334 | json_peer = json_object_new_object(); | |
8335 | if (peer_dynamic_neighbor(peer)) { | |
8336 | json_object_boolean_true_add(json_peer, | |
8337 | "dynamicPeer"); | |
8338 | } | |
d62a17ae | 8339 | |
3577f1c5 DD |
8340 | if (peer->hostname) |
8341 | json_object_string_add(json_peer, "hostname", | |
8342 | peer->hostname); | |
8343 | ||
8344 | if (peer->domainname) | |
8345 | json_object_string_add(json_peer, "domainname", | |
8346 | peer->domainname); | |
8347 | ||
8348 | json_object_int_add(json_peer, "remoteAs", peer->as); | |
8349 | json_object_int_add(json_peer, "version", 4); | |
8350 | json_object_int_add(json_peer, "msgRcvd", | |
8351 | PEER_TOTAL_RX(peer)); | |
8352 | json_object_int_add(json_peer, "msgSent", | |
8353 | PEER_TOTAL_TX(peer)); | |
8354 | ||
8355 | json_object_int_add(json_peer, "tableVersion", | |
8356 | peer->version[afi][safi]); | |
8357 | json_object_int_add(json_peer, "outq", | |
8358 | peer->obuf->count); | |
8359 | json_object_int_add(json_peer, "inq", 0); | |
8360 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
8361 | use_json, json_peer); | |
8362 | ||
8363 | /* | |
8364 | * Adding "pfxRcd" field to match with the corresponding | |
8365 | * CLI. "prefixReceivedCount" will be deprecated in | |
8366 | * future. | |
8367 | */ | |
8368 | json_object_int_add(json_peer, "prefixReceivedCount", | |
8369 | peer->pcount[afi][pfx_rcd_safi]); | |
8370 | json_object_int_add(json_peer, "pfxRcd", | |
8371 | peer->pcount[afi][pfx_rcd_safi]); | |
8372 | ||
8373 | paf = peer_af_find(peer, afi, pfx_rcd_safi); | |
8374 | if (paf && PAF_SUBGRP(paf)) | |
8375 | json_object_int_add(json_peer, | |
8376 | "pfxSnt", | |
8377 | (PAF_SUBGRP(paf))->scount); | |
8378 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
8379 | json_object_string_add(json_peer, "state", | |
8380 | "Idle (Admin)"); | |
8381 | else if (peer->afc_recv[afi][safi]) | |
8382 | json_object_string_add( | |
8383 | json_peer, "state", | |
8384 | lookup_msg(bgp_status_msg, peer->status, | |
8385 | NULL)); | |
8386 | else if (CHECK_FLAG(peer->sflags, | |
8387 | PEER_STATUS_PREFIX_OVERFLOW)) | |
8388 | json_object_string_add(json_peer, "state", | |
8389 | "Idle (PfxCt)"); | |
8390 | else | |
8391 | json_object_string_add( | |
8392 | json_peer, "state", | |
8393 | lookup_msg(bgp_status_msg, peer->status, | |
8394 | NULL)); | |
200116db DD |
8395 | json_object_int_add(json_peer, "connectionsEstablished", |
8396 | peer->established); | |
8397 | json_object_int_add(json_peer, "connectionsDropped", | |
8398 | peer->dropped); | |
b4e9dcba | 8399 | } |
3577f1c5 DD |
8400 | /* Avoid creating empty peer dicts in JSON */ |
8401 | if (json_peer == NULL) | |
8402 | continue; | |
ea47320b DL |
8403 | |
8404 | if (peer->conf_if) | |
60466a63 | 8405 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
8406 | "interface"); |
8407 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
8408 | json_object_string_add(json_peer, "idType", |
8409 | "ipv4"); | |
ea47320b | 8410 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
8411 | json_object_string_add(json_peer, "idType", |
8412 | "ipv6"); | |
ea47320b DL |
8413 | json_object_object_add(json_peers, peer->host, |
8414 | json_peer); | |
8415 | } else { | |
3577f1c5 DD |
8416 | if (show_failed && |
8417 | bgp_has_peer_failed(peer, afi, safi)) { | |
8418 | bgp_show_failed_summary(vty, bgp, peer, NULL, | |
8419 | max_neighbor_width, | |
8420 | use_json); | |
8421 | } else if (!show_failed) { | |
8422 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
8423 | if (peer_dynamic_neighbor(peer)) { | |
8424 | dn_flag[0] = '*'; | |
8425 | } | |
d62a17ae | 8426 | |
3577f1c5 DD |
8427 | if (peer->hostname |
8428 | && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) | |
8429 | len = vty_out(vty, "%s%s(%s)", dn_flag, | |
8430 | peer->hostname, peer->host); | |
d62a17ae | 8431 | else |
3577f1c5 DD |
8432 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
8433 | ||
8434 | /* pad the neighbor column with spaces */ | |
8435 | if (len < max_neighbor_width) | |
8436 | vty_out(vty, "%*s", max_neighbor_width - len, | |
8437 | " "); | |
8438 | ||
8439 | vty_out(vty, "4 %10u %7u %7u %8" PRIu64 " %4d %4zd %8s", | |
8440 | peer->as, PEER_TOTAL_RX(peer), | |
8441 | PEER_TOTAL_TX(peer), peer->version[afi][safi], | |
8442 | 0, peer->obuf->count, | |
8443 | peer_uptime(peer->uptime, timebuf, | |
8444 | BGP_UPTIME_LEN, 0, NULL)); | |
8445 | ||
8446 | if (peer->status == Established) | |
8447 | if (peer->afc_recv[afi][safi]) | |
8448 | vty_out(vty, " %12ld", | |
8449 | peer->pcount[afi] | |
8450 | [pfx_rcd_safi]); | |
8451 | else | |
8452 | vty_out(vty, " NoNeg"); | |
8453 | else { | |
8454 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
8455 | vty_out(vty, " Idle (Admin)"); | |
8456 | else if (CHECK_FLAG( | |
8457 | peer->sflags, | |
8458 | PEER_STATUS_PREFIX_OVERFLOW)) | |
8459 | vty_out(vty, " Idle (PfxCt)"); | |
8460 | else | |
8461 | vty_out(vty, " %12s", | |
8462 | lookup_msg(bgp_status_msg, | |
8463 | peer->status, NULL)); | |
8464 | } | |
8465 | vty_out(vty, "\n"); | |
d62a17ae | 8466 | } |
3577f1c5 | 8467 | |
d62a17ae | 8468 | } |
8469 | } | |
f933309e | 8470 | |
d62a17ae | 8471 | if (use_json) { |
8472 | json_object_object_add(json, "peers", json_peers); | |
3577f1c5 | 8473 | json_object_int_add(json, "failedPeers", failed_count); |
d62a17ae | 8474 | json_object_int_add(json, "totalPeers", count); |
8475 | json_object_int_add(json, "dynamicPeers", dn_count); | |
8476 | ||
3577f1c5 DD |
8477 | if (!show_failed) |
8478 | bgp_show_bestpath_json(bgp, json); | |
57a9c8a8 | 8479 | |
996c9314 LB |
8480 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
8481 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 8482 | json_object_free(json); |
8483 | } else { | |
8484 | if (count) | |
8485 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
8486 | else { | |
d6ceaca3 | 8487 | vty_out(vty, "No %s neighbor is configured\n", |
5cb5f4d0 | 8488 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 8489 | } |
b05a1c8b | 8490 | |
d6ceaca3 | 8491 | if (dn_count) { |
d62a17ae | 8492 | vty_out(vty, "* - dynamic neighbor\n"); |
8493 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
8494 | dn_count, bgp->dynamic_neighbors_limit); | |
8495 | } | |
8496 | } | |
1ff9a340 | 8497 | |
d62a17ae | 8498 | return CMD_SUCCESS; |
718e3744 | 8499 | } |
8500 | ||
d62a17ae | 8501 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
3577f1c5 | 8502 | int safi, bool show_failed, bool use_json) |
d62a17ae | 8503 | { |
8504 | int is_first = 1; | |
8505 | int afi_wildcard = (afi == AFI_MAX); | |
8506 | int safi_wildcard = (safi == SAFI_MAX); | |
8507 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 8508 | bool nbr_output = false; |
d62a17ae | 8509 | |
8510 | if (use_json && is_wildcard) | |
8511 | vty_out(vty, "{\n"); | |
8512 | if (afi_wildcard) | |
8513 | afi = 1; /* AFI_IP */ | |
8514 | while (afi < AFI_MAX) { | |
8515 | if (safi_wildcard) | |
8516 | safi = 1; /* SAFI_UNICAST */ | |
8517 | while (safi < SAFI_MAX) { | |
318cac96 | 8518 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 8519 | nbr_output = true; |
f86897b9 | 8520 | |
d62a17ae | 8521 | if (is_wildcard) { |
8522 | /* | |
8523 | * So limit output to those afi/safi | |
8524 | * pairs that | |
8525 | * actualy have something interesting in | |
8526 | * them | |
8527 | */ | |
8528 | if (use_json) { | |
d62a17ae | 8529 | if (!is_first) |
8530 | vty_out(vty, ",\n"); | |
8531 | else | |
8532 | is_first = 0; | |
8533 | ||
8534 | vty_out(vty, "\"%s\":", | |
5cb5f4d0 DD |
8535 | get_afi_safi_str(afi, |
8536 | safi, | |
8537 | true)); | |
d62a17ae | 8538 | } else { |
8539 | vty_out(vty, "\n%s Summary:\n", | |
5cb5f4d0 DD |
8540 | get_afi_safi_str(afi, |
8541 | safi, | |
8542 | false)); | |
d62a17ae | 8543 | } |
8544 | } | |
3577f1c5 DD |
8545 | bgp_show_summary(vty, bgp, afi, safi, show_failed, |
8546 | use_json); | |
d62a17ae | 8547 | } |
8548 | safi++; | |
d62a17ae | 8549 | if (!safi_wildcard) |
8550 | safi = SAFI_MAX; | |
8551 | } | |
8552 | afi++; | |
ee851c8c | 8553 | if (!afi_wildcard) |
d62a17ae | 8554 | afi = AFI_MAX; |
8555 | } | |
8556 | ||
8557 | if (use_json && is_wildcard) | |
8558 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
8559 | else if (!nbr_output) { |
8560 | if (use_json) | |
8561 | vty_out(vty, "{}\n"); | |
8562 | else | |
8563 | vty_out(vty, "%% No BGP neighbors found\n"); | |
8564 | } | |
d62a17ae | 8565 | } |
8566 | ||
8567 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
3577f1c5 DD |
8568 | safi_t safi, bool show_failed, |
8569 | bool use_json) | |
d62a17ae | 8570 | { |
8571 | struct listnode *node, *nnode; | |
8572 | struct bgp *bgp; | |
d62a17ae | 8573 | int is_first = 1; |
9f049418 | 8574 | bool nbr_output = false; |
d62a17ae | 8575 | |
8576 | if (use_json) | |
8577 | vty_out(vty, "{\n"); | |
8578 | ||
8579 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 8580 | nbr_output = true; |
d62a17ae | 8581 | if (use_json) { |
d62a17ae | 8582 | if (!is_first) |
8583 | vty_out(vty, ",\n"); | |
8584 | else | |
8585 | is_first = 0; | |
8586 | ||
8587 | vty_out(vty, "\"%s\":", | |
8588 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 8589 | ? VRF_DEFAULT_NAME |
d62a17ae | 8590 | : bgp->name); |
8591 | } else { | |
8592 | vty_out(vty, "\nInstance %s:\n", | |
8593 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 8594 | ? VRF_DEFAULT_NAME |
d62a17ae | 8595 | : bgp->name); |
8596 | } | |
3577f1c5 DD |
8597 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
8598 | use_json); | |
d62a17ae | 8599 | } |
8600 | ||
8601 | if (use_json) | |
8602 | vty_out(vty, "}\n"); | |
9f049418 DS |
8603 | else if (!nbr_output) |
8604 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 8605 | } |
8606 | ||
8607 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
3577f1c5 | 8608 | safi_t safi, bool show_failed, bool use_json) |
d62a17ae | 8609 | { |
8610 | struct bgp *bgp; | |
8611 | ||
8612 | if (name) { | |
8613 | if (strmatch(name, "all")) { | |
8614 | bgp_show_all_instances_summary_vty(vty, afi, safi, | |
3577f1c5 | 8615 | show_failed, |
d62a17ae | 8616 | use_json); |
8617 | return CMD_SUCCESS; | |
8618 | } else { | |
8619 | bgp = bgp_lookup_by_name(name); | |
8620 | ||
8621 | if (!bgp) { | |
8622 | if (use_json) | |
8623 | vty_out(vty, "{}\n"); | |
8624 | else | |
8625 | vty_out(vty, | |
ca61fd25 | 8626 | "%% BGP instance not found\n"); |
d62a17ae | 8627 | return CMD_WARNING; |
8628 | } | |
8629 | ||
f86897b9 | 8630 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, |
3577f1c5 | 8631 | show_failed, use_json); |
d62a17ae | 8632 | return CMD_SUCCESS; |
8633 | } | |
8634 | } | |
8635 | ||
8636 | bgp = bgp_get_default(); | |
8637 | ||
8638 | if (bgp) | |
3577f1c5 DD |
8639 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
8640 | use_json); | |
9f049418 | 8641 | else { |
ca61fd25 DS |
8642 | if (use_json) |
8643 | vty_out(vty, "{}\n"); | |
8644 | else | |
8645 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
8646 | return CMD_WARNING; |
8647 | } | |
d62a17ae | 8648 | |
8649 | return CMD_SUCCESS; | |
4fb25c53 DW |
8650 | } |
8651 | ||
716b2d8a | 8652 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 8653 | DEFUN (show_ip_bgp_summary, |
718e3744 | 8654 | show_ip_bgp_summary_cmd, |
3577f1c5 | 8655 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] summary [failed] [json]", |
718e3744 | 8656 | SHOW_STR |
8657 | IP_STR | |
8658 | BGP_STR | |
8386ac43 | 8659 | BGP_INSTANCE_HELP_STR |
46f296b4 | 8660 | BGP_AFI_HELP_STR |
dd6bd0f1 | 8661 | BGP_SAFI_WITH_LABEL_HELP_STR |
b05a1c8b | 8662 | "Summary of BGP neighbor status\n" |
3577f1c5 | 8663 | "Show only sessions not in Established state\n" |
9973d184 | 8664 | JSON_STR) |
718e3744 | 8665 | { |
d62a17ae | 8666 | char *vrf = NULL; |
8667 | afi_t afi = AFI_MAX; | |
8668 | safi_t safi = SAFI_MAX; | |
3577f1c5 | 8669 | bool show_failed = false; |
d62a17ae | 8670 | |
8671 | int idx = 0; | |
8672 | ||
8673 | /* show [ip] bgp */ | |
8674 | if (argv_find(argv, argc, "ip", &idx)) | |
8675 | afi = AFI_IP; | |
9a8bdf1c PG |
8676 | /* [<vrf> VIEWVRFNAME] */ |
8677 | if (argv_find(argv, argc, "vrf", &idx)) { | |
8678 | vrf = argv[idx + 1]->arg; | |
8679 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
8680 | vrf = NULL; | |
8681 | } else if (argv_find(argv, argc, "view", &idx)) | |
8682 | /* [<view> VIEWVRFNAME] */ | |
8683 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 8684 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
8685 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
8686 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
8687 | } | |
8688 | ||
3577f1c5 DD |
8689 | if (argv_find(argv, argc, "failed", &idx)) |
8690 | show_failed = true; | |
8691 | ||
9f049418 | 8692 | bool uj = use_json(argc, argv); |
d62a17ae | 8693 | |
3577f1c5 | 8694 | return bgp_show_summary_vty(vty, vrf, afi, safi, show_failed, uj); |
d62a17ae | 8695 | } |
8696 | ||
5cb5f4d0 | 8697 | const char *get_afi_safi_str(afi_t afi, safi_t safi, bool for_json) |
d62a17ae | 8698 | { |
5cb5f4d0 DD |
8699 | if (for_json) |
8700 | return get_afi_safi_json_str(afi, safi); | |
d62a17ae | 8701 | else |
5cb5f4d0 | 8702 | return get_afi_safi_vty_str(afi, safi); |
27162734 LB |
8703 | } |
8704 | ||
718e3744 | 8705 | /* Show BGP peer's information. */ |
d1927ebe | 8706 | enum show_type { show_all, show_peer, show_ipv4_all, show_ipv6_all, show_ipv4_peer, show_ipv6_peer }; |
d62a17ae | 8707 | |
8708 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
8709 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
8710 | uint16_t adv_smcap, uint16_t adv_rmcap, |
8711 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 8712 | bool use_json, json_object *json_pref) |
d62a17ae | 8713 | { |
8714 | /* Send-Mode */ | |
8715 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
8716 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
8717 | if (use_json) { | |
8718 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
8719 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8720 | json_object_string_add(json_pref, "sendMode", | |
8721 | "advertisedAndReceived"); | |
8722 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
8723 | json_object_string_add(json_pref, "sendMode", | |
8724 | "advertised"); | |
8725 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8726 | json_object_string_add(json_pref, "sendMode", | |
8727 | "received"); | |
8728 | } else { | |
8729 | vty_out(vty, " Send-mode: "); | |
8730 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
8731 | vty_out(vty, "advertised"); | |
8732 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8733 | vty_out(vty, "%sreceived", | |
8734 | CHECK_FLAG(p->af_cap[afi][safi], | |
8735 | adv_smcap) | |
8736 | ? ", " | |
8737 | : ""); | |
8738 | vty_out(vty, "\n"); | |
8739 | } | |
8740 | } | |
8741 | ||
8742 | /* Receive-Mode */ | |
8743 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
8744 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
8745 | if (use_json) { | |
8746 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
8747 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8748 | json_object_string_add(json_pref, "recvMode", | |
8749 | "advertisedAndReceived"); | |
8750 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
8751 | json_object_string_add(json_pref, "recvMode", | |
8752 | "advertised"); | |
8753 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8754 | json_object_string_add(json_pref, "recvMode", | |
8755 | "received"); | |
8756 | } else { | |
8757 | vty_out(vty, " Receive-mode: "); | |
8758 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
8759 | vty_out(vty, "advertised"); | |
8760 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8761 | vty_out(vty, "%sreceived", | |
8762 | CHECK_FLAG(p->af_cap[afi][safi], | |
8763 | adv_rmcap) | |
8764 | ? ", " | |
8765 | : ""); | |
8766 | vty_out(vty, "\n"); | |
8767 | } | |
8768 | } | |
8769 | } | |
8770 | ||
8771 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, | |
9f049418 | 8772 | safi_t safi, bool use_json, |
d62a17ae | 8773 | json_object *json_neigh) |
8774 | { | |
0291c246 MK |
8775 | struct bgp_filter *filter; |
8776 | struct peer_af *paf; | |
8777 | char orf_pfx_name[BUFSIZ]; | |
8778 | int orf_pfx_count; | |
8779 | json_object *json_af = NULL; | |
8780 | json_object *json_prefA = NULL; | |
8781 | json_object *json_prefB = NULL; | |
8782 | json_object *json_addr = NULL; | |
d62a17ae | 8783 | |
8784 | if (use_json) { | |
8785 | json_addr = json_object_new_object(); | |
8786 | json_af = json_object_new_object(); | |
8787 | filter = &p->filter[afi][safi]; | |
8788 | ||
8789 | if (peer_group_active(p)) | |
8790 | json_object_string_add(json_addr, "peerGroupMember", | |
8791 | p->group->name); | |
8792 | ||
8793 | paf = peer_af_find(p, afi, safi); | |
8794 | if (paf && PAF_SUBGRP(paf)) { | |
8795 | json_object_int_add(json_addr, "updateGroupId", | |
8796 | PAF_UPDGRP(paf)->id); | |
8797 | json_object_int_add(json_addr, "subGroupId", | |
8798 | PAF_SUBGRP(paf)->id); | |
8799 | json_object_int_add(json_addr, "packetQueueLength", | |
8800 | bpacket_queue_virtual_length(paf)); | |
8801 | } | |
8802 | ||
8803 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8804 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8805 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8806 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8807 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8808 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8809 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
8810 | json_object_int_add(json_af, "orfType", | |
8811 | ORF_TYPE_PREFIX); | |
8812 | json_prefA = json_object_new_object(); | |
8813 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
8814 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
8815 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8816 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
8817 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
8818 | use_json, json_prefA); | |
8819 | json_object_object_add(json_af, "orfPrefixList", | |
8820 | json_prefA); | |
8821 | } | |
8822 | ||
8823 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8824 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8825 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8826 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8827 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8828 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8829 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
8830 | json_object_int_add(json_af, "orfOldType", | |
8831 | ORF_TYPE_PREFIX_OLD); | |
8832 | json_prefB = json_object_new_object(); | |
8833 | bgp_show_peer_afi_orf_cap( | |
8834 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
8835 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8836 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
8837 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
8838 | json_prefB); | |
8839 | json_object_object_add(json_af, "orfOldPrefixList", | |
8840 | json_prefB); | |
8841 | } | |
8842 | ||
8843 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8844 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8845 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8846 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8847 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8848 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8849 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8850 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8851 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
8852 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8853 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
8854 | json_object_object_add(json_addr, "afDependentCap", | |
8855 | json_af); | |
8856 | else | |
8857 | json_object_free(json_af); | |
8858 | ||
8859 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
8860 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
8861 | NULL, afi, orf_pfx_name, use_json); | |
8862 | ||
8863 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8864 | PEER_STATUS_ORF_PREFIX_SEND) | |
8865 | || orf_pfx_count) { | |
8866 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8867 | PEER_STATUS_ORF_PREFIX_SEND)) | |
8868 | json_object_boolean_true_add(json_neigh, | |
8869 | "orfSent"); | |
8870 | if (orf_pfx_count) | |
8871 | json_object_int_add(json_addr, "orfRecvCounter", | |
8872 | orf_pfx_count); | |
8873 | } | |
8874 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8875 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
8876 | json_object_string_add( | |
8877 | json_addr, "orfFirstUpdate", | |
8878 | "deferredUntilORFOrRouteRefreshRecvd"); | |
8879 | ||
8880 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8881 | PEER_FLAG_REFLECTOR_CLIENT)) | |
8882 | json_object_boolean_true_add(json_addr, | |
8883 | "routeReflectorClient"); | |
8884 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8885 | PEER_FLAG_RSERVER_CLIENT)) | |
8886 | json_object_boolean_true_add(json_addr, | |
8887 | "routeServerClient"); | |
8888 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
8889 | json_object_boolean_true_add(json_addr, | |
8890 | "inboundSoftConfigPermit"); | |
8891 | ||
8892 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8893 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
8894 | json_object_boolean_true_add( | |
8895 | json_addr, | |
8896 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
8897 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8898 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
8899 | json_object_boolean_true_add( | |
8900 | json_addr, | |
8901 | "privateAsNumsReplacedInUpdatesToNbr"); | |
8902 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8903 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
8904 | json_object_boolean_true_add( | |
8905 | json_addr, | |
8906 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
8907 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8908 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
8909 | json_object_boolean_true_add( | |
8910 | json_addr, | |
8911 | "privateAsNumsRemovedInUpdatesToNbr"); | |
8912 | ||
dcc68b5e MS |
8913 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
8914 | json_object_boolean_true_add( | |
8915 | json_addr, | |
8916 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
8917 | ->type_json_name); | |
d62a17ae | 8918 | |
8919 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
8920 | json_object_string_add(json_addr, | |
8921 | "overrideASNsInOutboundUpdates", | |
8922 | "ifAspathEqualRemoteAs"); | |
8923 | ||
8924 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
8925 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8926 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
8927 | json_object_boolean_true_add(json_addr, | |
8928 | "routerAlwaysNextHop"); | |
8929 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8930 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
8931 | json_object_boolean_true_add( | |
8932 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
8933 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8934 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
8935 | json_object_boolean_true_add( | |
8936 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
8937 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
8938 | json_object_boolean_true_add( | |
8939 | json_addr, "unchangedMedPropogatedToNbr"); | |
8940 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
8941 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8942 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
8943 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8944 | PEER_FLAG_SEND_COMMUNITY) | |
8945 | && CHECK_FLAG(p->af_flags[afi][safi], | |
8946 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
8947 | json_object_string_add(json_addr, | |
8948 | "commAttriSentToNbr", | |
8949 | "extendedAndStandard"); | |
8950 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8951 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
8952 | json_object_string_add(json_addr, | |
8953 | "commAttriSentToNbr", | |
8954 | "extended"); | |
8955 | else | |
8956 | json_object_string_add(json_addr, | |
8957 | "commAttriSentToNbr", | |
8958 | "standard"); | |
8959 | } | |
8960 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8961 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
8962 | if (p->default_rmap[afi][safi].name) | |
8963 | json_object_string_add( | |
8964 | json_addr, "defaultRouteMap", | |
8965 | p->default_rmap[afi][safi].name); | |
8966 | ||
8967 | if (paf && PAF_SUBGRP(paf) | |
8968 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
8969 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
8970 | json_object_boolean_true_add(json_addr, | |
8971 | "defaultSent"); | |
8972 | else | |
8973 | json_object_boolean_true_add(json_addr, | |
8974 | "defaultNotSent"); | |
8975 | } | |
8976 | ||
dff8f48d | 8977 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 8978 | if (is_evpn_enabled()) |
60466a63 QY |
8979 | json_object_boolean_true_add( |
8980 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
8981 | } |
8982 | ||
d62a17ae | 8983 | if (filter->plist[FILTER_IN].name |
8984 | || filter->dlist[FILTER_IN].name | |
8985 | || filter->aslist[FILTER_IN].name | |
8986 | || filter->map[RMAP_IN].name) | |
8987 | json_object_boolean_true_add(json_addr, | |
8988 | "inboundPathPolicyConfig"); | |
8989 | if (filter->plist[FILTER_OUT].name | |
8990 | || filter->dlist[FILTER_OUT].name | |
8991 | || filter->aslist[FILTER_OUT].name | |
8992 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
8993 | json_object_boolean_true_add( | |
8994 | json_addr, "outboundPathPolicyConfig"); | |
8995 | ||
8996 | /* prefix-list */ | |
8997 | if (filter->plist[FILTER_IN].name) | |
8998 | json_object_string_add(json_addr, | |
8999 | "incomingUpdatePrefixFilterList", | |
9000 | filter->plist[FILTER_IN].name); | |
9001 | if (filter->plist[FILTER_OUT].name) | |
9002 | json_object_string_add(json_addr, | |
9003 | "outgoingUpdatePrefixFilterList", | |
9004 | filter->plist[FILTER_OUT].name); | |
9005 | ||
9006 | /* distribute-list */ | |
9007 | if (filter->dlist[FILTER_IN].name) | |
9008 | json_object_string_add( | |
9009 | json_addr, "incomingUpdateNetworkFilterList", | |
9010 | filter->dlist[FILTER_IN].name); | |
9011 | if (filter->dlist[FILTER_OUT].name) | |
9012 | json_object_string_add( | |
9013 | json_addr, "outgoingUpdateNetworkFilterList", | |
9014 | filter->dlist[FILTER_OUT].name); | |
9015 | ||
9016 | /* filter-list. */ | |
9017 | if (filter->aslist[FILTER_IN].name) | |
9018 | json_object_string_add(json_addr, | |
9019 | "incomingUpdateAsPathFilterList", | |
9020 | filter->aslist[FILTER_IN].name); | |
9021 | if (filter->aslist[FILTER_OUT].name) | |
9022 | json_object_string_add(json_addr, | |
9023 | "outgoingUpdateAsPathFilterList", | |
9024 | filter->aslist[FILTER_OUT].name); | |
9025 | ||
9026 | /* route-map. */ | |
9027 | if (filter->map[RMAP_IN].name) | |
9028 | json_object_string_add( | |
9029 | json_addr, "routeMapForIncomingAdvertisements", | |
9030 | filter->map[RMAP_IN].name); | |
9031 | if (filter->map[RMAP_OUT].name) | |
9032 | json_object_string_add( | |
9033 | json_addr, "routeMapForOutgoingAdvertisements", | |
9034 | filter->map[RMAP_OUT].name); | |
9035 | ||
9dac9fc8 DA |
9036 | /* ebgp-requires-policy (inbound) */ |
9037 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
9038 | && !bgp_inbound_policy_exists(p, filter)) | |
9039 | json_object_string_add( | |
9040 | json_addr, "inboundEbgpRequiresPolicy", | |
9041 | "Inbound updates discarded due to missing policy"); | |
9042 | ||
9043 | /* ebgp-requires-policy (outbound) */ | |
9044 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
9045 | && (!bgp_outbound_policy_exists(p, filter))) | |
9046 | json_object_string_add( | |
9047 | json_addr, "outboundEbgpRequiresPolicy", | |
9048 | "Outbound updates discarded due to missing policy"); | |
9049 | ||
d62a17ae | 9050 | /* unsuppress-map */ |
9051 | if (filter->usmap.name) | |
9052 | json_object_string_add(json_addr, | |
9053 | "selectiveUnsuppressRouteMap", | |
9054 | filter->usmap.name); | |
9055 | ||
9056 | /* Receive prefix count */ | |
9057 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
9058 | p->pcount[afi][safi]); | |
50e05855 AD |
9059 | if (paf && PAF_SUBGRP(paf)) |
9060 | json_object_int_add(json_addr, "sentPrefixCounter", | |
9061 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 9062 | |
9063 | /* Maximum prefix */ | |
9064 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
9065 | json_object_int_add(json_addr, "prefixAllowedMax", | |
9066 | p->pmax[afi][safi]); | |
9067 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9068 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
9069 | json_object_boolean_true_add( | |
9070 | json_addr, "prefixAllowedMaxWarning"); | |
9071 | json_object_int_add(json_addr, | |
9072 | "prefixAllowedWarningThresh", | |
9073 | p->pmax_threshold[afi][safi]); | |
9074 | if (p->pmax_restart[afi][safi]) | |
9075 | json_object_int_add( | |
9076 | json_addr, | |
9077 | "prefixAllowedRestartIntervalMsecs", | |
9078 | p->pmax_restart[afi][safi] * 60000); | |
9079 | } | |
5cb5f4d0 | 9080 | json_object_object_add(json_neigh, get_afi_safi_str(afi, safi, true), |
d62a17ae | 9081 | json_addr); |
9082 | ||
9083 | } else { | |
9084 | filter = &p->filter[afi][safi]; | |
9085 | ||
9086 | vty_out(vty, " For address family: %s\n", | |
5cb5f4d0 | 9087 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 9088 | |
9089 | if (peer_group_active(p)) | |
9090 | vty_out(vty, " %s peer-group member\n", | |
9091 | p->group->name); | |
9092 | ||
9093 | paf = peer_af_find(p, afi, safi); | |
9094 | if (paf && PAF_SUBGRP(paf)) { | |
996c9314 LB |
9095 | vty_out(vty, " Update group %" PRIu64 |
9096 | ", subgroup %" PRIu64 "\n", | |
d62a17ae | 9097 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
9098 | vty_out(vty, " Packet Queue length %d\n", | |
9099 | bpacket_queue_virtual_length(paf)); | |
9100 | } else { | |
9101 | vty_out(vty, " Not part of any update group\n"); | |
9102 | } | |
9103 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
9104 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9105 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
9106 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9107 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
9108 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9109 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
9110 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9111 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
9112 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9113 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
9114 | vty_out(vty, " AF-dependant capabilities:\n"); | |
9115 | ||
9116 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
9117 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9118 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
9119 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9120 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
9121 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9122 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
9123 | vty_out(vty, | |
9124 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
9125 | ORF_TYPE_PREFIX); | |
9126 | bgp_show_peer_afi_orf_cap( | |
9127 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
9128 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
9129 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
9130 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
9131 | } | |
9132 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
9133 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9134 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
9135 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9136 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
9137 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9138 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
9139 | vty_out(vty, | |
9140 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
9141 | ORF_TYPE_PREFIX_OLD); | |
9142 | bgp_show_peer_afi_orf_cap( | |
9143 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
9144 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
9145 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
9146 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
9147 | } | |
9148 | ||
9149 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
9150 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
9151 | NULL, afi, orf_pfx_name, use_json); | |
9152 | ||
9153 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
9154 | PEER_STATUS_ORF_PREFIX_SEND) | |
9155 | || orf_pfx_count) { | |
9156 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
9157 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
9158 | PEER_STATUS_ORF_PREFIX_SEND)) | |
9159 | vty_out(vty, " sent;"); | |
9160 | if (orf_pfx_count) | |
9161 | vty_out(vty, " received (%d entries)", | |
9162 | orf_pfx_count); | |
9163 | vty_out(vty, "\n"); | |
9164 | } | |
9165 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
9166 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
9167 | vty_out(vty, | |
9168 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
9169 | ||
9170 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9171 | PEER_FLAG_REFLECTOR_CLIENT)) | |
9172 | vty_out(vty, " Route-Reflector Client\n"); | |
9173 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9174 | PEER_FLAG_RSERVER_CLIENT)) | |
9175 | vty_out(vty, " Route-Server Client\n"); | |
9176 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
9177 | vty_out(vty, | |
9178 | " Inbound soft reconfiguration allowed\n"); | |
9179 | ||
9180 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9181 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
9182 | vty_out(vty, | |
9183 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
9184 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9185 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
9186 | vty_out(vty, | |
9187 | " Private AS numbers replaced in updates to this neighbor\n"); | |
9188 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9189 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
9190 | vty_out(vty, | |
9191 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
9192 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9193 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
9194 | vty_out(vty, | |
9195 | " Private AS numbers removed in updates to this neighbor\n"); | |
9196 | ||
dcc68b5e MS |
9197 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
9198 | vty_out(vty, " %s\n", | |
9199 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
9200 | ->human_description); | |
d62a17ae | 9201 | |
9202 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
9203 | vty_out(vty, | |
9204 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
9205 | ||
9206 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
9207 | || CHECK_FLAG(p->af_flags[afi][safi], | |
9208 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
9209 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
9210 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9211 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
9212 | vty_out(vty, | |
9213 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
9214 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9215 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
9216 | vty_out(vty, | |
9217 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
9218 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
9219 | vty_out(vty, | |
9220 | " MED is propagated unchanged to this neighbor\n"); | |
9221 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
9222 | || CHECK_FLAG(p->af_flags[afi][safi], | |
9223 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
9224 | || CHECK_FLAG(p->af_flags[afi][safi], | |
9225 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
9226 | vty_out(vty, | |
9227 | " Community attribute sent to this neighbor"); | |
9228 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9229 | PEER_FLAG_SEND_COMMUNITY) | |
9230 | && CHECK_FLAG(p->af_flags[afi][safi], | |
9231 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
9232 | && CHECK_FLAG(p->af_flags[afi][safi], | |
9233 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
9234 | vty_out(vty, "(all)\n"); | |
9235 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9236 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
9237 | vty_out(vty, "(large)\n"); | |
9238 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9239 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
9240 | vty_out(vty, "(extended)\n"); | |
9241 | else | |
9242 | vty_out(vty, "(standard)\n"); | |
9243 | } | |
9244 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9245 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
9246 | vty_out(vty, " Default information originate,"); | |
9247 | ||
9248 | if (p->default_rmap[afi][safi].name) | |
9249 | vty_out(vty, " default route-map %s%s,", | |
9250 | p->default_rmap[afi][safi].map ? "*" | |
9251 | : "", | |
9252 | p->default_rmap[afi][safi].name); | |
9253 | if (paf && PAF_SUBGRP(paf) | |
9254 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
9255 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
9256 | vty_out(vty, " default sent\n"); | |
9257 | else | |
9258 | vty_out(vty, " default not sent\n"); | |
9259 | } | |
9260 | ||
dff8f48d MK |
9261 | /* advertise-vni-all */ |
9262 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 9263 | if (is_evpn_enabled()) |
dff8f48d MK |
9264 | vty_out(vty, " advertise-all-vni\n"); |
9265 | } | |
9266 | ||
d62a17ae | 9267 | if (filter->plist[FILTER_IN].name |
9268 | || filter->dlist[FILTER_IN].name | |
9269 | || filter->aslist[FILTER_IN].name | |
9270 | || filter->map[RMAP_IN].name) | |
9271 | vty_out(vty, " Inbound path policy configured\n"); | |
9272 | if (filter->plist[FILTER_OUT].name | |
9273 | || filter->dlist[FILTER_OUT].name | |
9274 | || filter->aslist[FILTER_OUT].name | |
9275 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
9276 | vty_out(vty, " Outbound path policy configured\n"); | |
9277 | ||
9278 | /* prefix-list */ | |
9279 | if (filter->plist[FILTER_IN].name) | |
9280 | vty_out(vty, | |
9281 | " Incoming update prefix filter list is %s%s\n", | |
9282 | filter->plist[FILTER_IN].plist ? "*" : "", | |
9283 | filter->plist[FILTER_IN].name); | |
9284 | if (filter->plist[FILTER_OUT].name) | |
9285 | vty_out(vty, | |
9286 | " Outgoing update prefix filter list is %s%s\n", | |
9287 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
9288 | filter->plist[FILTER_OUT].name); | |
9289 | ||
9290 | /* distribute-list */ | |
9291 | if (filter->dlist[FILTER_IN].name) | |
9292 | vty_out(vty, | |
9293 | " Incoming update network filter list is %s%s\n", | |
9294 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
9295 | filter->dlist[FILTER_IN].name); | |
9296 | if (filter->dlist[FILTER_OUT].name) | |
9297 | vty_out(vty, | |
9298 | " Outgoing update network filter list is %s%s\n", | |
9299 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
9300 | filter->dlist[FILTER_OUT].name); | |
9301 | ||
9302 | /* filter-list. */ | |
9303 | if (filter->aslist[FILTER_IN].name) | |
9304 | vty_out(vty, | |
9305 | " Incoming update AS path filter list is %s%s\n", | |
9306 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
9307 | filter->aslist[FILTER_IN].name); | |
9308 | if (filter->aslist[FILTER_OUT].name) | |
9309 | vty_out(vty, | |
9310 | " Outgoing update AS path filter list is %s%s\n", | |
9311 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
9312 | filter->aslist[FILTER_OUT].name); | |
9313 | ||
9314 | /* route-map. */ | |
9315 | if (filter->map[RMAP_IN].name) | |
9316 | vty_out(vty, | |
9317 | " Route map for incoming advertisements is %s%s\n", | |
9318 | filter->map[RMAP_IN].map ? "*" : "", | |
9319 | filter->map[RMAP_IN].name); | |
9320 | if (filter->map[RMAP_OUT].name) | |
9321 | vty_out(vty, | |
9322 | " Route map for outgoing advertisements is %s%s\n", | |
9323 | filter->map[RMAP_OUT].map ? "*" : "", | |
9324 | filter->map[RMAP_OUT].name); | |
9325 | ||
9dac9fc8 DA |
9326 | /* ebgp-requires-policy (inbound) */ |
9327 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
9328 | && !bgp_inbound_policy_exists(p, filter)) | |
9329 | vty_out(vty, | |
9330 | " Inbound updates discarded due to missing policy\n"); | |
9331 | ||
9332 | /* ebgp-requires-policy (outbound) */ | |
9333 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
9334 | && !bgp_outbound_policy_exists(p, filter)) | |
9335 | vty_out(vty, | |
9336 | " Outbound updates discarded due to missing policy\n"); | |
9337 | ||
d62a17ae | 9338 | /* unsuppress-map */ |
9339 | if (filter->usmap.name) | |
9340 | vty_out(vty, | |
9341 | " Route map for selective unsuppress is %s%s\n", | |
9342 | filter->usmap.map ? "*" : "", | |
9343 | filter->usmap.name); | |
9344 | ||
9345 | /* Receive prefix count */ | |
9346 | vty_out(vty, " %ld accepted prefixes\n", p->pcount[afi][safi]); | |
9347 | ||
9348 | /* Maximum prefix */ | |
9349 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
9350 | vty_out(vty, " Maximum prefixes allowed %ld%s\n", | |
9351 | p->pmax[afi][safi], | |
9352 | CHECK_FLAG(p->af_flags[afi][safi], | |
9353 | PEER_FLAG_MAX_PREFIX_WARNING) | |
9354 | ? " (warning-only)" | |
9355 | : ""); | |
9356 | vty_out(vty, " Threshold for warning message %d%%", | |
9357 | p->pmax_threshold[afi][safi]); | |
9358 | if (p->pmax_restart[afi][safi]) | |
9359 | vty_out(vty, ", restart interval %d min", | |
9360 | p->pmax_restart[afi][safi]); | |
9361 | vty_out(vty, "\n"); | |
9362 | } | |
9363 | ||
9364 | vty_out(vty, "\n"); | |
9365 | } | |
9366 | } | |
9367 | ||
9f049418 | 9368 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 9369 | json_object *json) |
718e3744 | 9370 | { |
d62a17ae | 9371 | struct bgp *bgp; |
9372 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
9373 | char timebuf[BGP_UPTIME_LEN]; | |
9374 | char dn_flag[2]; | |
d62a17ae | 9375 | afi_t afi; |
9376 | safi_t safi; | |
d7c0a89a QY |
9377 | uint16_t i; |
9378 | uint8_t *msg; | |
d62a17ae | 9379 | json_object *json_neigh = NULL; |
9380 | time_t epoch_tbuf; | |
718e3744 | 9381 | |
d62a17ae | 9382 | bgp = p->bgp; |
9383 | ||
9384 | if (use_json) | |
9385 | json_neigh = json_object_new_object(); | |
9386 | ||
9387 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
9388 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
9389 | dn_flag[0] = '*'; | |
9390 | ||
9391 | if (!use_json) { | |
9392 | if (p->conf_if) /* Configured interface name. */ | |
9393 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
9394 | BGP_PEER_SU_UNSPEC(p) | |
9395 | ? "None" | |
9396 | : sockunion2str(&p->su, buf, | |
9397 | SU_ADDRSTRLEN)); | |
9398 | else /* Configured IP address. */ | |
9399 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
9400 | p->host); | |
9401 | } | |
9402 | ||
9403 | if (use_json) { | |
9404 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
9405 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
9406 | "none"); | |
9407 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
9408 | json_object_string_add( | |
9409 | json_neigh, "bgpNeighborAddr", | |
9410 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
9411 | ||
9412 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
9413 | ||
9414 | if (p->change_local_as) | |
9415 | json_object_int_add(json_neigh, "localAs", | |
9416 | p->change_local_as); | |
9417 | else | |
9418 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
9419 | ||
9420 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
9421 | json_object_boolean_true_add(json_neigh, | |
9422 | "localAsNoPrepend"); | |
9423 | ||
9424 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
9425 | json_object_boolean_true_add(json_neigh, | |
9426 | "localAsReplaceAs"); | |
9427 | } else { | |
9428 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
9429 | || (p->as_type == AS_INTERNAL)) | |
9430 | vty_out(vty, "remote AS %u, ", p->as); | |
9431 | else | |
9432 | vty_out(vty, "remote AS Unspecified, "); | |
9433 | vty_out(vty, "local AS %u%s%s, ", | |
9434 | p->change_local_as ? p->change_local_as : p->local_as, | |
9435 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
9436 | ? " no-prepend" | |
9437 | : "", | |
9438 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
9439 | ? " replace-as" | |
9440 | : ""); | |
9441 | } | |
faa16034 DS |
9442 | /* peer type internal or confed-internal */ |
9443 | if ((p->as == p->local_as) || (p->as_type == AS_INTERNAL)) { | |
d62a17ae | 9444 | if (use_json) { |
9445 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9446 | json_object_boolean_true_add( | |
9447 | json_neigh, "nbrConfedInternalLink"); | |
9448 | else | |
9449 | json_object_boolean_true_add(json_neigh, | |
9450 | "nbrInternalLink"); | |
9451 | } else { | |
9452 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9453 | vty_out(vty, "confed-internal link\n"); | |
9454 | else | |
9455 | vty_out(vty, "internal link\n"); | |
9456 | } | |
faa16034 DS |
9457 | /* peer type external or confed-external */ |
9458 | } else if (p->as || (p->as_type == AS_EXTERNAL)) { | |
d62a17ae | 9459 | if (use_json) { |
9460 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9461 | json_object_boolean_true_add( | |
9462 | json_neigh, "nbrConfedExternalLink"); | |
9463 | else | |
9464 | json_object_boolean_true_add(json_neigh, | |
9465 | "nbrExternalLink"); | |
9466 | } else { | |
9467 | if (bgp_confederation_peers_check(bgp, p->as)) | |
9468 | vty_out(vty, "confed-external link\n"); | |
9469 | else | |
9470 | vty_out(vty, "external link\n"); | |
9471 | } | |
faa16034 DS |
9472 | } else { |
9473 | if (use_json) | |
9474 | json_object_boolean_true_add(json_neigh, | |
9475 | "nbrUnspecifiedLink"); | |
9476 | else | |
9477 | vty_out(vty, "unspecified link\n"); | |
d62a17ae | 9478 | } |
9479 | ||
9480 | /* Description. */ | |
9481 | if (p->desc) { | |
9482 | if (use_json) | |
9483 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
9484 | else | |
9485 | vty_out(vty, " Description: %s\n", p->desc); | |
9486 | } | |
9487 | ||
9488 | if (p->hostname) { | |
9489 | if (use_json) { | |
9490 | if (p->hostname) | |
9491 | json_object_string_add(json_neigh, "hostname", | |
9492 | p->hostname); | |
9493 | ||
9494 | if (p->domainname) | |
9495 | json_object_string_add(json_neigh, "domainname", | |
9496 | p->domainname); | |
9497 | } else { | |
9498 | if (p->domainname && (p->domainname[0] != '\0')) | |
9499 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
9500 | p->domainname); | |
9501 | else | |
9502 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
9503 | } | |
9504 | } | |
9505 | ||
9506 | /* Peer-group */ | |
9507 | if (p->group) { | |
9508 | if (use_json) { | |
9509 | json_object_string_add(json_neigh, "peerGroup", | |
9510 | p->group->name); | |
9511 | ||
9512 | if (dn_flag[0]) { | |
9513 | struct prefix prefix, *range = NULL; | |
9514 | ||
9515 | sockunion2hostprefix(&(p->su), &prefix); | |
9516 | range = peer_group_lookup_dynamic_neighbor_range( | |
9517 | p->group, &prefix); | |
9518 | ||
9519 | if (range) { | |
9520 | prefix2str(range, buf1, sizeof(buf1)); | |
9521 | json_object_string_add( | |
9522 | json_neigh, | |
9523 | "peerSubnetRangeGroup", buf1); | |
9524 | } | |
9525 | } | |
9526 | } else { | |
9527 | vty_out(vty, | |
9528 | " Member of peer-group %s for session parameters\n", | |
9529 | p->group->name); | |
9530 | ||
9531 | if (dn_flag[0]) { | |
9532 | struct prefix prefix, *range = NULL; | |
9533 | ||
9534 | sockunion2hostprefix(&(p->su), &prefix); | |
9535 | range = peer_group_lookup_dynamic_neighbor_range( | |
9536 | p->group, &prefix); | |
9537 | ||
9538 | if (range) { | |
9539 | prefix2str(range, buf1, sizeof(buf1)); | |
9540 | vty_out(vty, | |
9541 | " Belongs to the subnet range group: %s\n", | |
9542 | buf1); | |
9543 | } | |
9544 | } | |
9545 | } | |
9546 | } | |
9547 | ||
9548 | if (use_json) { | |
9549 | /* Administrative shutdown. */ | |
9550 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
9551 | json_object_boolean_true_add(json_neigh, | |
9552 | "adminShutDown"); | |
9553 | ||
9554 | /* BGP Version. */ | |
9555 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
9556 | json_object_string_add( | |
9557 | json_neigh, "remoteRouterId", | |
9558 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
d0086e8e AD |
9559 | json_object_string_add( |
9560 | json_neigh, "localRouterId", | |
9561 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
9562 | sizeof(buf1))); | |
d62a17ae | 9563 | |
9564 | /* Confederation */ | |
9565 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
9566 | && bgp_confederation_peers_check(bgp, p->as)) | |
9567 | json_object_boolean_true_add(json_neigh, | |
9568 | "nbrCommonAdmin"); | |
9569 | ||
9570 | /* Status. */ | |
9571 | json_object_string_add( | |
9572 | json_neigh, "bgpState", | |
9573 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
9574 | ||
9575 | if (p->status == Established) { | |
9576 | time_t uptime; | |
d62a17ae | 9577 | |
9578 | uptime = bgp_clock(); | |
9579 | uptime -= p->uptime; | |
d62a17ae | 9580 | epoch_tbuf = time(NULL) - uptime; |
9581 | ||
bee57a7a | 9582 | #if CONFDATE > 20200101 |
a4d82a8a PZ |
9583 | CPP_NOTICE( |
9584 | "bgpTimerUp should be deprecated and can be removed now"); | |
d3c7efed DS |
9585 | #endif |
9586 | /* | |
9587 | * bgpTimerUp was miliseconds that was accurate | |
9588 | * up to 1 day, then the value returned | |
9589 | * became garbage. So in order to provide | |
9590 | * some level of backwards compatability, | |
9591 | * we still provde the data, but now | |
9592 | * we are returning the correct value | |
9593 | * and also adding a new bgpTimerUpMsec | |
9594 | * which will allow us to deprecate | |
9595 | * this eventually | |
9596 | */ | |
d62a17ae | 9597 | json_object_int_add(json_neigh, "bgpTimerUp", |
e0330274 | 9598 | uptime * 1000); |
d3c7efed DS |
9599 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
9600 | uptime * 1000); | |
d62a17ae | 9601 | json_object_string_add(json_neigh, "bgpTimerUpString", |
9602 | peer_uptime(p->uptime, timebuf, | |
9603 | BGP_UPTIME_LEN, 0, | |
9604 | NULL)); | |
9605 | json_object_int_add(json_neigh, | |
9606 | "bgpTimerUpEstablishedEpoch", | |
9607 | epoch_tbuf); | |
9608 | } | |
9609 | ||
9610 | else if (p->status == Active) { | |
9611 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
9612 | json_object_string_add(json_neigh, "bgpStateIs", | |
9613 | "passive"); | |
9614 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
9615 | json_object_string_add(json_neigh, "bgpStateIs", | |
9616 | "passiveNSF"); | |
9617 | } | |
9618 | ||
9619 | /* read timer */ | |
9620 | time_t uptime; | |
9621 | struct tm *tm; | |
9622 | ||
9623 | uptime = bgp_clock(); | |
9624 | uptime -= p->readtime; | |
9625 | tm = gmtime(&uptime); | |
9626 | json_object_int_add(json_neigh, "bgpTimerLastRead", | |
9627 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9628 | + (tm->tm_hour * 3600000)); | |
9629 | ||
9630 | uptime = bgp_clock(); | |
9631 | uptime -= p->last_write; | |
9632 | tm = gmtime(&uptime); | |
9633 | json_object_int_add(json_neigh, "bgpTimerLastWrite", | |
9634 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9635 | + (tm->tm_hour * 3600000)); | |
9636 | ||
9637 | uptime = bgp_clock(); | |
9638 | uptime -= p->update_time; | |
9639 | tm = gmtime(&uptime); | |
9640 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", | |
9641 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9642 | + (tm->tm_hour * 3600000)); | |
9643 | ||
9644 | /* Configured timer values. */ | |
9645 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
9646 | p->v_holdtime * 1000); | |
9647 | json_object_int_add(json_neigh, | |
9648 | "bgpTimerKeepAliveIntervalMsecs", | |
9649 | p->v_keepalive * 1000); | |
b90a8e13 | 9650 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 9651 | json_object_int_add(json_neigh, |
9652 | "bgpTimerConfiguredHoldTimeMsecs", | |
9653 | p->holdtime * 1000); | |
9654 | json_object_int_add( | |
9655 | json_neigh, | |
9656 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
9657 | p->keepalive * 1000); | |
d25e4efc | 9658 | } else if ((bgp->default_holdtime != BGP_DEFAULT_HOLDTIME) |
a4d82a8a PZ |
9659 | || (bgp->default_keepalive |
9660 | != BGP_DEFAULT_KEEPALIVE)) { | |
d25e4efc DS |
9661 | json_object_int_add(json_neigh, |
9662 | "bgpTimerConfiguredHoldTimeMsecs", | |
9663 | bgp->default_holdtime); | |
9664 | json_object_int_add( | |
9665 | json_neigh, | |
9666 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
9667 | bgp->default_keepalive); | |
d62a17ae | 9668 | } |
9669 | } else { | |
9670 | /* Administrative shutdown. */ | |
9671 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
9672 | vty_out(vty, " Administratively shut down\n"); | |
9673 | ||
9674 | /* BGP Version. */ | |
9675 | vty_out(vty, " BGP version 4"); | |
0e38aeb4 | 9676 | vty_out(vty, ", remote router ID %s", |
d62a17ae | 9677 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
0e38aeb4 AD |
9678 | vty_out(vty, ", local router ID %s\n", |
9679 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
9680 | sizeof(buf1))); | |
d62a17ae | 9681 | |
9682 | /* Confederation */ | |
9683 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
9684 | && bgp_confederation_peers_check(bgp, p->as)) | |
9685 | vty_out(vty, | |
9686 | " Neighbor under common administration\n"); | |
9687 | ||
9688 | /* Status. */ | |
9689 | vty_out(vty, " BGP state = %s", | |
9690 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
9691 | ||
9692 | if (p->status == Established) | |
9693 | vty_out(vty, ", up for %8s", | |
9694 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
9695 | 0, NULL)); | |
9696 | ||
9697 | else if (p->status == Active) { | |
9698 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
9699 | vty_out(vty, " (passive)"); | |
9700 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
9701 | vty_out(vty, " (NSF passive)"); | |
9702 | } | |
9703 | vty_out(vty, "\n"); | |
9704 | ||
9705 | /* read timer */ | |
9706 | vty_out(vty, " Last read %s", | |
9707 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
9708 | NULL)); | |
9709 | vty_out(vty, ", Last write %s\n", | |
9710 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
9711 | NULL)); | |
9712 | ||
9713 | /* Configured timer values. */ | |
9714 | vty_out(vty, | |
9715 | " Hold time is %d, keepalive interval is %d seconds\n", | |
9716 | p->v_holdtime, p->v_keepalive); | |
b90a8e13 | 9717 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 9718 | vty_out(vty, " Configured hold time is %d", |
9719 | p->holdtime); | |
9720 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
9721 | p->keepalive); | |
d25e4efc | 9722 | } else if ((bgp->default_holdtime != BGP_DEFAULT_HOLDTIME) |
a4d82a8a PZ |
9723 | || (bgp->default_keepalive |
9724 | != BGP_DEFAULT_KEEPALIVE)) { | |
d25e4efc DS |
9725 | vty_out(vty, " Configured hold time is %d", |
9726 | bgp->default_holdtime); | |
9727 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
9728 | bgp->default_keepalive); | |
d62a17ae | 9729 | } |
9730 | } | |
9731 | /* Capability. */ | |
9732 | if (p->status == Established) { | |
9733 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] | |
9734 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
9735 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
9736 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
9737 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
9738 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
9739 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
9740 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
9741 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
9742 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
9743 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
9744 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
7c40bf39 | 9745 | || p->afc_adv[AFI_IP6][SAFI_FLOWSPEC] |
9746 | || p->afc_recv[AFI_IP6][SAFI_FLOWSPEC] | |
d62a17ae | 9747 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
9748 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
7c40bf39 | 9749 | || p->afc_adv[AFI_IP][SAFI_FLOWSPEC] |
9750 | || p->afc_recv[AFI_IP][SAFI_FLOWSPEC] | |
d62a17ae | 9751 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
9752 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
9753 | if (use_json) { | |
9754 | json_object *json_cap = NULL; | |
9755 | ||
9756 | json_cap = json_object_new_object(); | |
9757 | ||
9758 | /* AS4 */ | |
9759 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
9760 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
9761 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
9762 | && CHECK_FLAG(p->cap, | |
9763 | PEER_CAP_AS4_RCV)) | |
9764 | json_object_string_add( | |
9765 | json_cap, "4byteAs", | |
9766 | "advertisedAndReceived"); | |
9767 | else if (CHECK_FLAG(p->cap, | |
9768 | PEER_CAP_AS4_ADV)) | |
9769 | json_object_string_add( | |
9770 | json_cap, "4byteAs", | |
9771 | "advertised"); | |
9772 | else if (CHECK_FLAG(p->cap, | |
9773 | PEER_CAP_AS4_RCV)) | |
9774 | json_object_string_add( | |
9775 | json_cap, "4byteAs", | |
9776 | "received"); | |
9777 | } | |
9778 | ||
9779 | /* AddPath */ | |
9780 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
9781 | || CHECK_FLAG(p->cap, | |
9782 | PEER_CAP_ADDPATH_ADV)) { | |
9783 | json_object *json_add = NULL; | |
9784 | const char *print_store; | |
9785 | ||
9786 | json_add = json_object_new_object(); | |
9787 | ||
05c7a1cc QY |
9788 | FOREACH_AFI_SAFI (afi, safi) { |
9789 | json_object *json_sub = NULL; | |
9790 | json_sub = | |
9791 | json_object_new_object(); | |
5cb5f4d0 DD |
9792 | print_store = get_afi_safi_str( |
9793 | afi, safi, true); | |
d62a17ae | 9794 | |
05c7a1cc QY |
9795 | if (CHECK_FLAG( |
9796 | p->af_cap[afi] | |
9797 | [safi], | |
9798 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9799 | || CHECK_FLAG( | |
9800 | p->af_cap[afi] | |
9801 | [safi], | |
9802 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 9803 | if (CHECK_FLAG( |
9804 | p->af_cap | |
9805 | [afi] | |
9806 | [safi], | |
9807 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 9808 | && CHECK_FLAG( |
d62a17ae | 9809 | p->af_cap |
9810 | [afi] | |
9811 | [safi], | |
05c7a1cc QY |
9812 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
9813 | json_object_boolean_true_add( | |
9814 | json_sub, | |
9815 | "txAdvertisedAndReceived"); | |
9816 | else if ( | |
9817 | CHECK_FLAG( | |
9818 | p->af_cap | |
9819 | [afi] | |
9820 | [safi], | |
9821 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
9822 | json_object_boolean_true_add( | |
9823 | json_sub, | |
9824 | "txAdvertised"); | |
9825 | else if ( | |
9826 | CHECK_FLAG( | |
9827 | p->af_cap | |
9828 | [afi] | |
9829 | [safi], | |
9830 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
9831 | json_object_boolean_true_add( | |
9832 | json_sub, | |
9833 | "txReceived"); | |
9834 | } | |
d62a17ae | 9835 | |
05c7a1cc QY |
9836 | if (CHECK_FLAG( |
9837 | p->af_cap[afi] | |
9838 | [safi], | |
9839 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9840 | || CHECK_FLAG( | |
9841 | p->af_cap[afi] | |
9842 | [safi], | |
9843 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 9844 | if (CHECK_FLAG( |
9845 | p->af_cap | |
9846 | [afi] | |
9847 | [safi], | |
9848 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 9849 | && CHECK_FLAG( |
d62a17ae | 9850 | p->af_cap |
9851 | [afi] | |
9852 | [safi], | |
9853 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
9854 | json_object_boolean_true_add( |
9855 | json_sub, | |
9856 | "rxAdvertisedAndReceived"); | |
9857 | else if ( | |
9858 | CHECK_FLAG( | |
9859 | p->af_cap | |
9860 | [afi] | |
9861 | [safi], | |
9862 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
9863 | json_object_boolean_true_add( | |
9864 | json_sub, | |
9865 | "rxAdvertised"); | |
9866 | else if ( | |
9867 | CHECK_FLAG( | |
9868 | p->af_cap | |
9869 | [afi] | |
9870 | [safi], | |
9871 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
9872 | json_object_boolean_true_add( | |
9873 | json_sub, | |
9874 | "rxReceived"); | |
d62a17ae | 9875 | } |
9876 | ||
05c7a1cc QY |
9877 | if (CHECK_FLAG( |
9878 | p->af_cap[afi] | |
9879 | [safi], | |
9880 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9881 | || CHECK_FLAG( | |
9882 | p->af_cap[afi] | |
9883 | [safi], | |
9884 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
9885 | || CHECK_FLAG( | |
9886 | p->af_cap[afi] | |
9887 | [safi], | |
9888 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9889 | || CHECK_FLAG( | |
9890 | p->af_cap[afi] | |
9891 | [safi], | |
9892 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
9893 | json_object_object_add( | |
9894 | json_add, | |
9895 | print_store, | |
9896 | json_sub); | |
9897 | else | |
9898 | json_object_free( | |
9899 | json_sub); | |
9900 | } | |
9901 | ||
d62a17ae | 9902 | json_object_object_add( |
9903 | json_cap, "addPath", json_add); | |
9904 | } | |
9905 | ||
9906 | /* Dynamic */ | |
9907 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
9908 | || CHECK_FLAG(p->cap, | |
9909 | PEER_CAP_DYNAMIC_ADV)) { | |
9910 | if (CHECK_FLAG(p->cap, | |
9911 | PEER_CAP_DYNAMIC_ADV) | |
9912 | && CHECK_FLAG(p->cap, | |
9913 | PEER_CAP_DYNAMIC_RCV)) | |
9914 | json_object_string_add( | |
9915 | json_cap, "dynamic", | |
9916 | "advertisedAndReceived"); | |
9917 | else if (CHECK_FLAG( | |
9918 | p->cap, | |
9919 | PEER_CAP_DYNAMIC_ADV)) | |
9920 | json_object_string_add( | |
9921 | json_cap, "dynamic", | |
9922 | "advertised"); | |
9923 | else if (CHECK_FLAG( | |
9924 | p->cap, | |
9925 | PEER_CAP_DYNAMIC_RCV)) | |
9926 | json_object_string_add( | |
9927 | json_cap, "dynamic", | |
9928 | "received"); | |
9929 | } | |
9930 | ||
9931 | /* Extended nexthop */ | |
9932 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
9933 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
9934 | json_object *json_nxt = NULL; | |
9935 | const char *print_store; | |
9936 | ||
9937 | ||
9938 | if (CHECK_FLAG(p->cap, | |
9939 | PEER_CAP_ENHE_ADV) | |
9940 | && CHECK_FLAG(p->cap, | |
9941 | PEER_CAP_ENHE_RCV)) | |
9942 | json_object_string_add( | |
9943 | json_cap, | |
9944 | "extendedNexthop", | |
9945 | "advertisedAndReceived"); | |
9946 | else if (CHECK_FLAG(p->cap, | |
9947 | PEER_CAP_ENHE_ADV)) | |
9948 | json_object_string_add( | |
9949 | json_cap, | |
9950 | "extendedNexthop", | |
9951 | "advertised"); | |
9952 | else if (CHECK_FLAG(p->cap, | |
9953 | PEER_CAP_ENHE_RCV)) | |
9954 | json_object_string_add( | |
9955 | json_cap, | |
9956 | "extendedNexthop", | |
9957 | "received"); | |
9958 | ||
9959 | if (CHECK_FLAG(p->cap, | |
9960 | PEER_CAP_ENHE_RCV)) { | |
9961 | json_nxt = | |
9962 | json_object_new_object(); | |
9963 | ||
9964 | for (safi = SAFI_UNICAST; | |
9965 | safi < SAFI_MAX; safi++) { | |
9966 | if (CHECK_FLAG( | |
9967 | p->af_cap | |
9968 | [AFI_IP] | |
9969 | [safi], | |
9970 | PEER_CAP_ENHE_AF_RCV)) { | |
5cb5f4d0 | 9971 | print_store = get_afi_safi_str( |
d62a17ae | 9972 | AFI_IP, |
5cb5f4d0 | 9973 | safi, true); |
d62a17ae | 9974 | json_object_string_add( |
9975 | json_nxt, | |
9976 | print_store, | |
54f29523 | 9977 | "recieved"); /* misspelled for compatibility */ |
d62a17ae | 9978 | } |
9979 | } | |
9980 | json_object_object_add( | |
9981 | json_cap, | |
9982 | "extendedNexthopFamililesByPeer", | |
9983 | json_nxt); | |
9984 | } | |
9985 | } | |
9986 | ||
9987 | /* Route Refresh */ | |
9988 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
9989 | || CHECK_FLAG(p->cap, | |
9990 | PEER_CAP_REFRESH_NEW_RCV) | |
9991 | || CHECK_FLAG(p->cap, | |
9992 | PEER_CAP_REFRESH_OLD_RCV)) { | |
9993 | if (CHECK_FLAG(p->cap, | |
9994 | PEER_CAP_REFRESH_ADV) | |
9995 | && (CHECK_FLAG( | |
9996 | p->cap, | |
9997 | PEER_CAP_REFRESH_NEW_RCV) | |
9998 | || CHECK_FLAG( | |
9999 | p->cap, | |
10000 | PEER_CAP_REFRESH_OLD_RCV))) { | |
10001 | if (CHECK_FLAG( | |
10002 | p->cap, | |
10003 | PEER_CAP_REFRESH_OLD_RCV) | |
10004 | && CHECK_FLAG( | |
10005 | p->cap, | |
10006 | PEER_CAP_REFRESH_NEW_RCV)) | |
10007 | json_object_string_add( | |
10008 | json_cap, | |
10009 | "routeRefresh", | |
10010 | "advertisedAndReceivedOldNew"); | |
10011 | else { | |
10012 | if (CHECK_FLAG( | |
10013 | p->cap, | |
10014 | PEER_CAP_REFRESH_OLD_RCV)) | |
10015 | json_object_string_add( | |
10016 | json_cap, | |
10017 | "routeRefresh", | |
10018 | "advertisedAndReceivedOld"); | |
10019 | else | |
10020 | json_object_string_add( | |
10021 | json_cap, | |
10022 | "routeRefresh", | |
10023 | "advertisedAndReceivedNew"); | |
10024 | } | |
10025 | } else if ( | |
10026 | CHECK_FLAG( | |
10027 | p->cap, | |
10028 | PEER_CAP_REFRESH_ADV)) | |
10029 | json_object_string_add( | |
10030 | json_cap, | |
10031 | "routeRefresh", | |
10032 | "advertised"); | |
10033 | else if ( | |
10034 | CHECK_FLAG( | |
10035 | p->cap, | |
10036 | PEER_CAP_REFRESH_NEW_RCV) | |
10037 | || CHECK_FLAG( | |
10038 | p->cap, | |
10039 | PEER_CAP_REFRESH_OLD_RCV)) | |
10040 | json_object_string_add( | |
10041 | json_cap, | |
10042 | "routeRefresh", | |
10043 | "received"); | |
10044 | } | |
10045 | ||
10046 | /* Multiprotocol Extensions */ | |
10047 | json_object *json_multi = NULL; | |
10048 | json_multi = json_object_new_object(); | |
10049 | ||
05c7a1cc QY |
10050 | FOREACH_AFI_SAFI (afi, safi) { |
10051 | if (p->afc_adv[afi][safi] | |
10052 | || p->afc_recv[afi][safi]) { | |
10053 | json_object *json_exten = NULL; | |
10054 | json_exten = | |
10055 | json_object_new_object(); | |
10056 | ||
d62a17ae | 10057 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
10058 | && p->afc_recv[afi][safi]) |
10059 | json_object_boolean_true_add( | |
10060 | json_exten, | |
10061 | "advertisedAndReceived"); | |
10062 | else if (p->afc_adv[afi][safi]) | |
10063 | json_object_boolean_true_add( | |
10064 | json_exten, | |
10065 | "advertised"); | |
10066 | else if (p->afc_recv[afi][safi]) | |
10067 | json_object_boolean_true_add( | |
10068 | json_exten, | |
10069 | "received"); | |
d62a17ae | 10070 | |
05c7a1cc QY |
10071 | json_object_object_add( |
10072 | json_multi, | |
5cb5f4d0 DD |
10073 | get_afi_safi_str(afi, |
10074 | safi, | |
10075 | true), | |
05c7a1cc | 10076 | json_exten); |
d62a17ae | 10077 | } |
10078 | } | |
10079 | json_object_object_add( | |
10080 | json_cap, "multiprotocolExtensions", | |
10081 | json_multi); | |
10082 | ||
d77114b7 | 10083 | /* Hostname capabilities */ |
60466a63 | 10084 | json_object *json_hname = NULL; |
d77114b7 MK |
10085 | |
10086 | json_hname = json_object_new_object(); | |
10087 | ||
10088 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
10089 | json_object_string_add( | |
60466a63 QY |
10090 | json_hname, "advHostName", |
10091 | bgp->peer_self->hostname | |
10092 | ? bgp->peer_self | |
10093 | ->hostname | |
d77114b7 MK |
10094 | : "n/a"); |
10095 | json_object_string_add( | |
60466a63 QY |
10096 | json_hname, "advDomainName", |
10097 | bgp->peer_self->domainname | |
10098 | ? bgp->peer_self | |
10099 | ->domainname | |
d77114b7 MK |
10100 | : "n/a"); |
10101 | } | |
10102 | ||
10103 | ||
10104 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
10105 | json_object_string_add( | |
60466a63 QY |
10106 | json_hname, "rcvHostName", |
10107 | p->hostname ? p->hostname | |
10108 | : "n/a"); | |
d77114b7 | 10109 | json_object_string_add( |
60466a63 QY |
10110 | json_hname, "rcvDomainName", |
10111 | p->domainname ? p->domainname | |
10112 | : "n/a"); | |
d77114b7 MK |
10113 | } |
10114 | ||
60466a63 | 10115 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
10116 | json_hname); |
10117 | ||
d62a17ae | 10118 | /* Gracefull Restart */ |
10119 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
10120 | || CHECK_FLAG(p->cap, | |
10121 | PEER_CAP_RESTART_ADV)) { | |
10122 | if (CHECK_FLAG(p->cap, | |
10123 | PEER_CAP_RESTART_ADV) | |
10124 | && CHECK_FLAG(p->cap, | |
10125 | PEER_CAP_RESTART_RCV)) | |
10126 | json_object_string_add( | |
10127 | json_cap, | |
10128 | "gracefulRestart", | |
10129 | "advertisedAndReceived"); | |
10130 | else if (CHECK_FLAG( | |
10131 | p->cap, | |
10132 | PEER_CAP_RESTART_ADV)) | |
10133 | json_object_string_add( | |
10134 | json_cap, | |
10135 | "gracefulRestartCapability", | |
10136 | "advertised"); | |
10137 | else if (CHECK_FLAG( | |
10138 | p->cap, | |
10139 | PEER_CAP_RESTART_RCV)) | |
10140 | json_object_string_add( | |
10141 | json_cap, | |
10142 | "gracefulRestartCapability", | |
10143 | "received"); | |
10144 | ||
10145 | if (CHECK_FLAG(p->cap, | |
10146 | PEER_CAP_RESTART_RCV)) { | |
10147 | int restart_af_count = 0; | |
10148 | json_object *json_restart = | |
10149 | NULL; | |
10150 | json_restart = | |
10151 | json_object_new_object(); | |
10152 | ||
10153 | json_object_int_add( | |
10154 | json_cap, | |
10155 | "gracefulRestartRemoteTimerMsecs", | |
10156 | p->v_gr_restart * 1000); | |
10157 | ||
05c7a1cc QY |
10158 | FOREACH_AFI_SAFI (afi, safi) { |
10159 | if (CHECK_FLAG( | |
10160 | p->af_cap | |
10161 | [afi] | |
10162 | [safi], | |
10163 | PEER_CAP_RESTART_AF_RCV)) { | |
10164 | json_object * | |
10165 | json_sub = | |
10166 | NULL; | |
10167 | json_sub = | |
10168 | json_object_new_object(); | |
10169 | ||
d62a17ae | 10170 | if (CHECK_FLAG( |
10171 | p->af_cap | |
10172 | [afi] | |
10173 | [safi], | |
05c7a1cc QY |
10174 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
10175 | json_object_boolean_true_add( | |
10176 | json_sub, | |
10177 | "preserved"); | |
10178 | restart_af_count++; | |
10179 | json_object_object_add( | |
10180 | json_restart, | |
5cb5f4d0 | 10181 | get_afi_safi_str( |
05c7a1cc | 10182 | afi, |
5cb5f4d0 DD |
10183 | safi, |
10184 | true), | |
05c7a1cc | 10185 | json_sub); |
d62a17ae | 10186 | } |
10187 | } | |
10188 | if (!restart_af_count) { | |
10189 | json_object_string_add( | |
10190 | json_cap, | |
10191 | "addressFamiliesByPeer", | |
10192 | "none"); | |
10193 | json_object_free( | |
10194 | json_restart); | |
10195 | } else | |
10196 | json_object_object_add( | |
10197 | json_cap, | |
10198 | "addressFamiliesByPeer", | |
10199 | json_restart); | |
10200 | } | |
10201 | } | |
10202 | json_object_object_add(json_neigh, | |
10203 | "neighborCapabilities", | |
10204 | json_cap); | |
10205 | } else { | |
10206 | vty_out(vty, " Neighbor capabilities:\n"); | |
10207 | ||
10208 | /* AS4 */ | |
10209 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
10210 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
10211 | vty_out(vty, " 4 Byte AS:"); | |
10212 | if (CHECK_FLAG(p->cap, | |
10213 | PEER_CAP_AS4_ADV)) | |
10214 | vty_out(vty, " advertised"); | |
10215 | if (CHECK_FLAG(p->cap, | |
10216 | PEER_CAP_AS4_RCV)) | |
10217 | vty_out(vty, " %sreceived", | |
10218 | CHECK_FLAG( | |
10219 | p->cap, | |
10220 | PEER_CAP_AS4_ADV) | |
10221 | ? "and " | |
10222 | : ""); | |
10223 | vty_out(vty, "\n"); | |
10224 | } | |
10225 | ||
10226 | /* AddPath */ | |
10227 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
10228 | || CHECK_FLAG(p->cap, | |
10229 | PEER_CAP_ADDPATH_ADV)) { | |
10230 | vty_out(vty, " AddPath:\n"); | |
10231 | ||
05c7a1cc QY |
10232 | FOREACH_AFI_SAFI (afi, safi) { |
10233 | if (CHECK_FLAG( | |
10234 | p->af_cap[afi] | |
10235 | [safi], | |
10236 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
10237 | || CHECK_FLAG( | |
10238 | p->af_cap[afi] | |
10239 | [safi], | |
10240 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
10241 | vty_out(vty, | |
10242 | " %s: TX ", | |
5cb5f4d0 | 10243 | get_afi_safi_str( |
05c7a1cc | 10244 | afi, |
5cb5f4d0 DD |
10245 | safi, |
10246 | false)); | |
05c7a1cc | 10247 | |
d62a17ae | 10248 | if (CHECK_FLAG( |
10249 | p->af_cap | |
10250 | [afi] | |
10251 | [safi], | |
05c7a1cc | 10252 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 10253 | vty_out(vty, |
05c7a1cc | 10254 | "advertised %s", |
5cb5f4d0 | 10255 | get_afi_safi_str( |
d62a17ae | 10256 | afi, |
5cb5f4d0 DD |
10257 | safi, |
10258 | false)); | |
d62a17ae | 10259 | |
05c7a1cc QY |
10260 | if (CHECK_FLAG( |
10261 | p->af_cap | |
10262 | [afi] | |
10263 | [safi], | |
10264 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
10265 | vty_out(vty, | |
10266 | "%sreceived", | |
10267 | CHECK_FLAG( | |
10268 | p->af_cap | |
10269 | [afi] | |
10270 | [safi], | |
10271 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
10272 | ? " and " | |
10273 | : ""); | |
d62a17ae | 10274 | |
05c7a1cc QY |
10275 | vty_out(vty, "\n"); |
10276 | } | |
d62a17ae | 10277 | |
05c7a1cc QY |
10278 | if (CHECK_FLAG( |
10279 | p->af_cap[afi] | |
10280 | [safi], | |
10281 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
10282 | || CHECK_FLAG( | |
10283 | p->af_cap[afi] | |
10284 | [safi], | |
10285 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
10286 | vty_out(vty, | |
10287 | " %s: RX ", | |
5cb5f4d0 | 10288 | get_afi_safi_str( |
05c7a1cc | 10289 | afi, |
5cb5f4d0 DD |
10290 | safi, |
10291 | false)); | |
d62a17ae | 10292 | |
10293 | if (CHECK_FLAG( | |
10294 | p->af_cap | |
10295 | [afi] | |
10296 | [safi], | |
05c7a1cc | 10297 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 10298 | vty_out(vty, |
05c7a1cc | 10299 | "advertised %s", |
5cb5f4d0 | 10300 | get_afi_safi_str( |
d62a17ae | 10301 | afi, |
5cb5f4d0 DD |
10302 | safi, |
10303 | false)); | |
d62a17ae | 10304 | |
05c7a1cc QY |
10305 | if (CHECK_FLAG( |
10306 | p->af_cap | |
10307 | [afi] | |
10308 | [safi], | |
10309 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 10310 | vty_out(vty, |
05c7a1cc QY |
10311 | "%sreceived", |
10312 | CHECK_FLAG( | |
10313 | p->af_cap | |
10314 | [afi] | |
10315 | [safi], | |
10316 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
10317 | ? " and " | |
10318 | : ""); | |
10319 | ||
10320 | vty_out(vty, "\n"); | |
d62a17ae | 10321 | } |
05c7a1cc | 10322 | } |
d62a17ae | 10323 | } |
10324 | ||
10325 | /* Dynamic */ | |
10326 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
10327 | || CHECK_FLAG(p->cap, | |
10328 | PEER_CAP_DYNAMIC_ADV)) { | |
10329 | vty_out(vty, " Dynamic:"); | |
10330 | if (CHECK_FLAG(p->cap, | |
10331 | PEER_CAP_DYNAMIC_ADV)) | |
10332 | vty_out(vty, " advertised"); | |
10333 | if (CHECK_FLAG(p->cap, | |
10334 | PEER_CAP_DYNAMIC_RCV)) | |
10335 | vty_out(vty, " %sreceived", | |
10336 | CHECK_FLAG( | |
10337 | p->cap, | |
10338 | PEER_CAP_DYNAMIC_ADV) | |
10339 | ? "and " | |
10340 | : ""); | |
10341 | vty_out(vty, "\n"); | |
10342 | } | |
10343 | ||
10344 | /* Extended nexthop */ | |
10345 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
10346 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
10347 | vty_out(vty, " Extended nexthop:"); | |
10348 | if (CHECK_FLAG(p->cap, | |
10349 | PEER_CAP_ENHE_ADV)) | |
10350 | vty_out(vty, " advertised"); | |
10351 | if (CHECK_FLAG(p->cap, | |
10352 | PEER_CAP_ENHE_RCV)) | |
10353 | vty_out(vty, " %sreceived", | |
10354 | CHECK_FLAG( | |
10355 | p->cap, | |
10356 | PEER_CAP_ENHE_ADV) | |
10357 | ? "and " | |
10358 | : ""); | |
10359 | vty_out(vty, "\n"); | |
10360 | ||
10361 | if (CHECK_FLAG(p->cap, | |
10362 | PEER_CAP_ENHE_RCV)) { | |
10363 | vty_out(vty, | |
10364 | " Address families by peer:\n "); | |
10365 | for (safi = SAFI_UNICAST; | |
10366 | safi < SAFI_MAX; safi++) | |
10367 | if (CHECK_FLAG( | |
10368 | p->af_cap | |
10369 | [AFI_IP] | |
10370 | [safi], | |
10371 | PEER_CAP_ENHE_AF_RCV)) | |
10372 | vty_out(vty, | |
10373 | " %s\n", | |
5cb5f4d0 | 10374 | get_afi_safi_str( |
d62a17ae | 10375 | AFI_IP, |
5cb5f4d0 DD |
10376 | safi, |
10377 | false)); | |
d62a17ae | 10378 | } |
10379 | } | |
10380 | ||
10381 | /* Route Refresh */ | |
10382 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
10383 | || CHECK_FLAG(p->cap, | |
10384 | PEER_CAP_REFRESH_NEW_RCV) | |
10385 | || CHECK_FLAG(p->cap, | |
10386 | PEER_CAP_REFRESH_OLD_RCV)) { | |
10387 | vty_out(vty, " Route refresh:"); | |
10388 | if (CHECK_FLAG(p->cap, | |
10389 | PEER_CAP_REFRESH_ADV)) | |
10390 | vty_out(vty, " advertised"); | |
10391 | if (CHECK_FLAG(p->cap, | |
10392 | PEER_CAP_REFRESH_NEW_RCV) | |
10393 | || CHECK_FLAG( | |
10394 | p->cap, | |
10395 | PEER_CAP_REFRESH_OLD_RCV)) | |
10396 | vty_out(vty, " %sreceived(%s)", | |
10397 | CHECK_FLAG( | |
10398 | p->cap, | |
10399 | PEER_CAP_REFRESH_ADV) | |
10400 | ? "and " | |
10401 | : "", | |
10402 | (CHECK_FLAG( | |
10403 | p->cap, | |
10404 | PEER_CAP_REFRESH_OLD_RCV) | |
10405 | && CHECK_FLAG( | |
10406 | p->cap, | |
10407 | PEER_CAP_REFRESH_NEW_RCV)) | |
10408 | ? "old & new" | |
10409 | : CHECK_FLAG( | |
10410 | p->cap, | |
10411 | PEER_CAP_REFRESH_OLD_RCV) | |
10412 | ? "old" | |
10413 | : "new"); | |
10414 | ||
10415 | vty_out(vty, "\n"); | |
10416 | } | |
10417 | ||
10418 | /* Multiprotocol Extensions */ | |
05c7a1cc QY |
10419 | FOREACH_AFI_SAFI (afi, safi) |
10420 | if (p->afc_adv[afi][safi] | |
10421 | || p->afc_recv[afi][safi]) { | |
10422 | vty_out(vty, | |
10423 | " Address Family %s:", | |
5cb5f4d0 DD |
10424 | get_afi_safi_str( |
10425 | afi, | |
10426 | safi, | |
10427 | false)); | |
05c7a1cc | 10428 | if (p->afc_adv[afi][safi]) |
d62a17ae | 10429 | vty_out(vty, |
05c7a1cc QY |
10430 | " advertised"); |
10431 | if (p->afc_recv[afi][safi]) | |
10432 | vty_out(vty, | |
10433 | " %sreceived", | |
10434 | p->afc_adv[afi] | |
10435 | [safi] | |
10436 | ? "and " | |
10437 | : ""); | |
10438 | vty_out(vty, "\n"); | |
10439 | } | |
d62a17ae | 10440 | |
10441 | /* Hostname capability */ | |
60466a63 | 10442 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
10443 | |
10444 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
10445 | vty_out(vty, |
10446 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
10447 | bgp->peer_self->hostname |
10448 | ? bgp->peer_self | |
10449 | ->hostname | |
d77114b7 | 10450 | : "n/a", |
60466a63 QY |
10451 | bgp->peer_self->domainname |
10452 | ? bgp->peer_self | |
10453 | ->domainname | |
d77114b7 MK |
10454 | : "n/a"); |
10455 | } else { | |
10456 | vty_out(vty, " not advertised"); | |
d62a17ae | 10457 | } |
10458 | ||
d77114b7 | 10459 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
10460 | vty_out(vty, |
10461 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
10462 | p->hostname ? p->hostname |
10463 | : "n/a", | |
10464 | p->domainname ? p->domainname | |
10465 | : "n/a"); | |
d77114b7 MK |
10466 | } else { |
10467 | vty_out(vty, " not received"); | |
10468 | } | |
10469 | ||
10470 | vty_out(vty, "\n"); | |
10471 | ||
d62a17ae | 10472 | /* Gracefull Restart */ |
10473 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
10474 | || CHECK_FLAG(p->cap, | |
10475 | PEER_CAP_RESTART_ADV)) { | |
10476 | vty_out(vty, | |
10477 | " Graceful Restart Capabilty:"); | |
10478 | if (CHECK_FLAG(p->cap, | |
10479 | PEER_CAP_RESTART_ADV)) | |
10480 | vty_out(vty, " advertised"); | |
10481 | if (CHECK_FLAG(p->cap, | |
10482 | PEER_CAP_RESTART_RCV)) | |
10483 | vty_out(vty, " %sreceived", | |
10484 | CHECK_FLAG( | |
10485 | p->cap, | |
10486 | PEER_CAP_RESTART_ADV) | |
10487 | ? "and " | |
10488 | : ""); | |
10489 | vty_out(vty, "\n"); | |
10490 | ||
10491 | if (CHECK_FLAG(p->cap, | |
10492 | PEER_CAP_RESTART_RCV)) { | |
10493 | int restart_af_count = 0; | |
10494 | ||
10495 | vty_out(vty, | |
10496 | " Remote Restart timer is %d seconds\n", | |
10497 | p->v_gr_restart); | |
10498 | vty_out(vty, | |
10499 | " Address families by peer:\n "); | |
10500 | ||
05c7a1cc QY |
10501 | FOREACH_AFI_SAFI (afi, safi) |
10502 | if (CHECK_FLAG( | |
10503 | p->af_cap | |
10504 | [afi] | |
10505 | [safi], | |
10506 | PEER_CAP_RESTART_AF_RCV)) { | |
10507 | vty_out(vty, | |
10508 | "%s%s(%s)", | |
10509 | restart_af_count | |
10510 | ? ", " | |
10511 | : "", | |
5cb5f4d0 | 10512 | get_afi_safi_str( |
05c7a1cc | 10513 | afi, |
5cb5f4d0 DD |
10514 | safi, |
10515 | false), | |
05c7a1cc QY |
10516 | CHECK_FLAG( |
10517 | p->af_cap | |
10518 | [afi] | |
10519 | [safi], | |
10520 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
10521 | ? "preserved" | |
10522 | : "not preserved"); | |
10523 | restart_af_count++; | |
10524 | } | |
d62a17ae | 10525 | if (!restart_af_count) |
10526 | vty_out(vty, "none"); | |
10527 | vty_out(vty, "\n"); | |
10528 | } | |
10529 | } | |
10530 | } | |
10531 | } | |
10532 | } | |
10533 | ||
10534 | /* graceful restart information */ | |
10535 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) || p->t_gr_restart | |
10536 | || p->t_gr_stale) { | |
10537 | json_object *json_grace = NULL; | |
10538 | json_object *json_grace_send = NULL; | |
10539 | json_object *json_grace_recv = NULL; | |
10540 | int eor_send_af_count = 0; | |
10541 | int eor_receive_af_count = 0; | |
10542 | ||
10543 | if (use_json) { | |
10544 | json_grace = json_object_new_object(); | |
10545 | json_grace_send = json_object_new_object(); | |
10546 | json_grace_recv = json_object_new_object(); | |
10547 | ||
10548 | if (p->status == Established) { | |
05c7a1cc QY |
10549 | FOREACH_AFI_SAFI (afi, safi) { |
10550 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10551 | PEER_STATUS_EOR_SEND)) { | |
10552 | json_object_boolean_true_add( | |
10553 | json_grace_send, | |
5cb5f4d0 DD |
10554 | get_afi_safi_str(afi, |
10555 | safi, | |
10556 | true)); | |
05c7a1cc | 10557 | eor_send_af_count++; |
d62a17ae | 10558 | } |
10559 | } | |
05c7a1cc QY |
10560 | FOREACH_AFI_SAFI (afi, safi) { |
10561 | if (CHECK_FLAG( | |
10562 | p->af_sflags[afi][safi], | |
10563 | PEER_STATUS_EOR_RECEIVED)) { | |
10564 | json_object_boolean_true_add( | |
10565 | json_grace_recv, | |
5cb5f4d0 DD |
10566 | get_afi_safi_str(afi, |
10567 | safi, | |
10568 | true)); | |
05c7a1cc | 10569 | eor_receive_af_count++; |
d62a17ae | 10570 | } |
10571 | } | |
10572 | } | |
10573 | ||
10574 | json_object_object_add(json_grace, "endOfRibSend", | |
10575 | json_grace_send); | |
10576 | json_object_object_add(json_grace, "endOfRibRecv", | |
10577 | json_grace_recv); | |
10578 | ||
10579 | if (p->t_gr_restart) | |
10580 | json_object_int_add(json_grace, | |
10581 | "gracefulRestartTimerMsecs", | |
10582 | thread_timer_remain_second( | |
10583 | p->t_gr_restart) | |
10584 | * 1000); | |
10585 | ||
10586 | if (p->t_gr_stale) | |
10587 | json_object_int_add( | |
10588 | json_grace, | |
10589 | "gracefulStalepathTimerMsecs", | |
10590 | thread_timer_remain_second( | |
10591 | p->t_gr_stale) | |
10592 | * 1000); | |
10593 | ||
10594 | json_object_object_add( | |
10595 | json_neigh, "gracefulRestartInfo", json_grace); | |
10596 | } else { | |
0437e105 | 10597 | vty_out(vty, " Graceful restart information:\n"); |
d62a17ae | 10598 | if (p->status == Established) { |
10599 | vty_out(vty, " End-of-RIB send: "); | |
05c7a1cc QY |
10600 | FOREACH_AFI_SAFI (afi, safi) { |
10601 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10602 | PEER_STATUS_EOR_SEND)) { | |
10603 | vty_out(vty, "%s%s", | |
10604 | eor_send_af_count ? ", " | |
10605 | : "", | |
5cb5f4d0 DD |
10606 | get_afi_safi_str(afi, |
10607 | safi, | |
10608 | false)); | |
05c7a1cc | 10609 | eor_send_af_count++; |
d62a17ae | 10610 | } |
10611 | } | |
10612 | vty_out(vty, "\n"); | |
10613 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
10614 | FOREACH_AFI_SAFI (afi, safi) { |
10615 | if (CHECK_FLAG( | |
10616 | p->af_sflags[afi][safi], | |
10617 | PEER_STATUS_EOR_RECEIVED)) { | |
10618 | vty_out(vty, "%s%s", | |
10619 | eor_receive_af_count | |
10620 | ? ", " | |
10621 | : "", | |
5cb5f4d0 DD |
10622 | get_afi_safi_str(afi, |
10623 | safi, | |
10624 | false)); | |
05c7a1cc | 10625 | eor_receive_af_count++; |
d62a17ae | 10626 | } |
10627 | } | |
10628 | vty_out(vty, "\n"); | |
10629 | } | |
10630 | ||
10631 | if (p->t_gr_restart) | |
10632 | vty_out(vty, | |
10633 | " The remaining time of restart timer is %ld\n", | |
10634 | thread_timer_remain_second( | |
10635 | p->t_gr_restart)); | |
10636 | ||
10637 | if (p->t_gr_stale) | |
10638 | vty_out(vty, | |
10639 | " The remaining time of stalepath timer is %ld\n", | |
10640 | thread_timer_remain_second( | |
10641 | p->t_gr_stale)); | |
10642 | } | |
10643 | } | |
10644 | if (use_json) { | |
10645 | json_object *json_stat = NULL; | |
10646 | json_stat = json_object_new_object(); | |
10647 | /* Packet counts. */ | |
10648 | json_object_int_add(json_stat, "depthInq", 0); | |
10649 | json_object_int_add(json_stat, "depthOutq", | |
10650 | (unsigned long)p->obuf->count); | |
0112e9e0 QY |
10651 | json_object_int_add(json_stat, "opensSent", |
10652 | atomic_load_explicit(&p->open_out, | |
10653 | memory_order_relaxed)); | |
10654 | json_object_int_add(json_stat, "opensRecv", | |
10655 | atomic_load_explicit(&p->open_in, | |
10656 | memory_order_relaxed)); | |
d62a17ae | 10657 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
10658 | atomic_load_explicit(&p->notify_out, |
10659 | memory_order_relaxed)); | |
d62a17ae | 10660 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
10661 | atomic_load_explicit(&p->notify_in, |
10662 | memory_order_relaxed)); | |
10663 | json_object_int_add(json_stat, "updatesSent", | |
10664 | atomic_load_explicit(&p->update_out, | |
10665 | memory_order_relaxed)); | |
10666 | json_object_int_add(json_stat, "updatesRecv", | |
10667 | atomic_load_explicit(&p->update_in, | |
10668 | memory_order_relaxed)); | |
d62a17ae | 10669 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
10670 | atomic_load_explicit(&p->keepalive_out, |
10671 | memory_order_relaxed)); | |
d62a17ae | 10672 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
10673 | atomic_load_explicit(&p->keepalive_in, |
10674 | memory_order_relaxed)); | |
d62a17ae | 10675 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
10676 | atomic_load_explicit(&p->refresh_out, |
10677 | memory_order_relaxed)); | |
d62a17ae | 10678 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
10679 | atomic_load_explicit(&p->refresh_in, |
10680 | memory_order_relaxed)); | |
d62a17ae | 10681 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
10682 | atomic_load_explicit(&p->dynamic_cap_out, |
10683 | memory_order_relaxed)); | |
d62a17ae | 10684 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
10685 | atomic_load_explicit(&p->dynamic_cap_in, |
10686 | memory_order_relaxed)); | |
10687 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
10688 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 10689 | json_object_object_add(json_neigh, "messageStats", json_stat); |
10690 | } else { | |
10691 | /* Packet counts. */ | |
10692 | vty_out(vty, " Message statistics:\n"); | |
10693 | vty_out(vty, " Inq depth is 0\n"); | |
10694 | vty_out(vty, " Outq depth is %lu\n", | |
10695 | (unsigned long)p->obuf->count); | |
10696 | vty_out(vty, " Sent Rcvd\n"); | |
0112e9e0 QY |
10697 | vty_out(vty, " Opens: %10d %10d\n", |
10698 | atomic_load_explicit(&p->open_out, | |
10699 | memory_order_relaxed), | |
10700 | atomic_load_explicit(&p->open_in, | |
10701 | memory_order_relaxed)); | |
10702 | vty_out(vty, " Notifications: %10d %10d\n", | |
10703 | atomic_load_explicit(&p->notify_out, | |
10704 | memory_order_relaxed), | |
10705 | atomic_load_explicit(&p->notify_in, | |
10706 | memory_order_relaxed)); | |
10707 | vty_out(vty, " Updates: %10d %10d\n", | |
10708 | atomic_load_explicit(&p->update_out, | |
10709 | memory_order_relaxed), | |
10710 | atomic_load_explicit(&p->update_in, | |
10711 | memory_order_relaxed)); | |
10712 | vty_out(vty, " Keepalives: %10d %10d\n", | |
10713 | atomic_load_explicit(&p->keepalive_out, | |
10714 | memory_order_relaxed), | |
10715 | atomic_load_explicit(&p->keepalive_in, | |
10716 | memory_order_relaxed)); | |
10717 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
10718 | atomic_load_explicit(&p->refresh_out, | |
10719 | memory_order_relaxed), | |
10720 | atomic_load_explicit(&p->refresh_in, | |
10721 | memory_order_relaxed)); | |
d62a17ae | 10722 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
10723 | atomic_load_explicit(&p->dynamic_cap_out, |
10724 | memory_order_relaxed), | |
10725 | atomic_load_explicit(&p->dynamic_cap_in, | |
10726 | memory_order_relaxed)); | |
10727 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
10728 | PEER_TOTAL_RX(p)); | |
d62a17ae | 10729 | } |
10730 | ||
10731 | if (use_json) { | |
10732 | /* advertisement-interval */ | |
10733 | json_object_int_add(json_neigh, | |
10734 | "minBtwnAdvertisementRunsTimerMsecs", | |
10735 | p->v_routeadv * 1000); | |
10736 | ||
10737 | /* Update-source. */ | |
10738 | if (p->update_if || p->update_source) { | |
10739 | if (p->update_if) | |
10740 | json_object_string_add(json_neigh, | |
10741 | "updateSource", | |
10742 | p->update_if); | |
10743 | else if (p->update_source) | |
10744 | json_object_string_add( | |
10745 | json_neigh, "updateSource", | |
10746 | sockunion2str(p->update_source, buf1, | |
10747 | SU_ADDRSTRLEN)); | |
10748 | } | |
10749 | } else { | |
10750 | /* advertisement-interval */ | |
10751 | vty_out(vty, | |
10752 | " Minimum time between advertisement runs is %d seconds\n", | |
10753 | p->v_routeadv); | |
10754 | ||
10755 | /* Update-source. */ | |
10756 | if (p->update_if || p->update_source) { | |
10757 | vty_out(vty, " Update source is "); | |
10758 | if (p->update_if) | |
10759 | vty_out(vty, "%s", p->update_if); | |
10760 | else if (p->update_source) | |
10761 | vty_out(vty, "%s", | |
10762 | sockunion2str(p->update_source, buf1, | |
10763 | SU_ADDRSTRLEN)); | |
10764 | vty_out(vty, "\n"); | |
10765 | } | |
10766 | ||
10767 | vty_out(vty, "\n"); | |
10768 | } | |
10769 | ||
10770 | /* Address Family Information */ | |
10771 | json_object *json_hold = NULL; | |
10772 | ||
10773 | if (use_json) | |
10774 | json_hold = json_object_new_object(); | |
10775 | ||
05c7a1cc QY |
10776 | FOREACH_AFI_SAFI (afi, safi) |
10777 | if (p->afc[afi][safi]) | |
10778 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
10779 | json_hold); | |
d62a17ae | 10780 | |
10781 | if (use_json) { | |
10782 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
10783 | json_hold); | |
10784 | json_object_int_add(json_neigh, "connectionsEstablished", | |
10785 | p->established); | |
10786 | json_object_int_add(json_neigh, "connectionsDropped", | |
10787 | p->dropped); | |
10788 | } else | |
10789 | vty_out(vty, " Connections established %d; dropped %d\n", | |
10790 | p->established, p->dropped); | |
10791 | ||
10792 | if (!p->last_reset) { | |
10793 | if (use_json) | |
10794 | json_object_string_add(json_neigh, "lastReset", | |
10795 | "never"); | |
10796 | else | |
10797 | vty_out(vty, " Last reset never\n"); | |
10798 | } else { | |
10799 | if (use_json) { | |
10800 | time_t uptime; | |
10801 | struct tm *tm; | |
10802 | ||
10803 | uptime = bgp_clock(); | |
10804 | uptime -= p->resettime; | |
10805 | tm = gmtime(&uptime); | |
10806 | json_object_int_add(json_neigh, "lastResetTimerMsecs", | |
10807 | (tm->tm_sec * 1000) | |
10808 | + (tm->tm_min * 60000) | |
10809 | + (tm->tm_hour * 3600000)); | |
3577f1c5 | 10810 | bgp_show_peer_reset(NULL, p, json_neigh, true); |
d62a17ae | 10811 | } else { |
10812 | vty_out(vty, " Last reset %s, ", | |
10813 | peer_uptime(p->resettime, timebuf, | |
10814 | BGP_UPTIME_LEN, 0, NULL)); | |
10815 | ||
3577f1c5 | 10816 | bgp_show_peer_reset(vty, p, NULL, false); |
d62a17ae | 10817 | if (p->last_reset_cause_size) { |
10818 | msg = p->last_reset_cause; | |
10819 | vty_out(vty, | |
10820 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
10821 | for (i = 1; i <= p->last_reset_cause_size; | |
10822 | i++) { | |
10823 | vty_out(vty, "%02X", *msg++); | |
10824 | ||
10825 | if (i != p->last_reset_cause_size) { | |
10826 | if (i % 16 == 0) { | |
10827 | vty_out(vty, "\n "); | |
10828 | } else if (i % 4 == 0) { | |
10829 | vty_out(vty, " "); | |
10830 | } | |
10831 | } | |
10832 | } | |
10833 | vty_out(vty, "\n"); | |
10834 | } | |
10835 | } | |
10836 | } | |
10837 | ||
10838 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
10839 | if (use_json) | |
10840 | json_object_boolean_true_add(json_neigh, | |
10841 | "prefixesConfigExceedMax"); | |
10842 | else | |
10843 | vty_out(vty, | |
10844 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
10845 | ||
10846 | if (p->t_pmax_restart) { | |
10847 | if (use_json) { | |
10848 | json_object_boolean_true_add( | |
10849 | json_neigh, "reducePrefixNumFrom"); | |
10850 | json_object_int_add(json_neigh, | |
10851 | "restartInTimerMsec", | |
10852 | thread_timer_remain_second( | |
10853 | p->t_pmax_restart) | |
10854 | * 1000); | |
10855 | } else | |
10856 | vty_out(vty, | |
10857 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
10858 | p->host, thread_timer_remain_second( |
10859 | p->t_pmax_restart)); | |
d62a17ae | 10860 | } else { |
10861 | if (use_json) | |
10862 | json_object_boolean_true_add( | |
10863 | json_neigh, | |
10864 | "reducePrefixNumAndClearIpBgp"); | |
10865 | else | |
10866 | vty_out(vty, | |
10867 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
10868 | p->host); | |
10869 | } | |
10870 | } | |
10871 | ||
10872 | /* EBGP Multihop and GTSM */ | |
10873 | if (p->sort != BGP_PEER_IBGP) { | |
10874 | if (use_json) { | |
10875 | if (p->gtsm_hops > 0) | |
10876 | json_object_int_add(json_neigh, | |
10877 | "externalBgpNbrMaxHopsAway", | |
10878 | p->gtsm_hops); | |
10879 | else if (p->ttl > 1) | |
10880 | json_object_int_add(json_neigh, | |
10881 | "externalBgpNbrMaxHopsAway", | |
10882 | p->ttl); | |
10883 | } else { | |
10884 | if (p->gtsm_hops > 0) | |
10885 | vty_out(vty, | |
10886 | " External BGP neighbor may be up to %d hops away.\n", | |
10887 | p->gtsm_hops); | |
10888 | else if (p->ttl > 1) | |
10889 | vty_out(vty, | |
10890 | " External BGP neighbor may be up to %d hops away.\n", | |
10891 | p->ttl); | |
10892 | } | |
10893 | } else { | |
10894 | if (p->gtsm_hops > 0) { | |
10895 | if (use_json) | |
10896 | json_object_int_add(json_neigh, | |
10897 | "internalBgpNbrMaxHopsAway", | |
10898 | p->gtsm_hops); | |
10899 | else | |
10900 | vty_out(vty, | |
10901 | " Internal BGP neighbor may be up to %d hops away.\n", | |
10902 | p->gtsm_hops); | |
10903 | } | |
10904 | } | |
10905 | ||
10906 | /* Local address. */ | |
10907 | if (p->su_local) { | |
10908 | if (use_json) { | |
10909 | json_object_string_add(json_neigh, "hostLocal", | |
10910 | sockunion2str(p->su_local, buf1, | |
10911 | SU_ADDRSTRLEN)); | |
10912 | json_object_int_add(json_neigh, "portLocal", | |
10913 | ntohs(p->su_local->sin.sin_port)); | |
10914 | } else | |
10915 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
10916 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
10917 | ntohs(p->su_local->sin.sin_port)); | |
10918 | } | |
10919 | ||
10920 | /* Remote address. */ | |
10921 | if (p->su_remote) { | |
10922 | if (use_json) { | |
10923 | json_object_string_add(json_neigh, "hostForeign", | |
10924 | sockunion2str(p->su_remote, buf1, | |
10925 | SU_ADDRSTRLEN)); | |
10926 | json_object_int_add(json_neigh, "portForeign", | |
10927 | ntohs(p->su_remote->sin.sin_port)); | |
10928 | } else | |
10929 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
10930 | sockunion2str(p->su_remote, buf1, | |
10931 | SU_ADDRSTRLEN), | |
10932 | ntohs(p->su_remote->sin.sin_port)); | |
10933 | } | |
10934 | ||
10935 | /* Nexthop display. */ | |
10936 | if (p->su_local) { | |
10937 | if (use_json) { | |
10938 | json_object_string_add(json_neigh, "nexthop", | |
10939 | inet_ntop(AF_INET, | |
10940 | &p->nexthop.v4, buf1, | |
10941 | sizeof(buf1))); | |
10942 | json_object_string_add(json_neigh, "nexthopGlobal", | |
10943 | inet_ntop(AF_INET6, | |
10944 | &p->nexthop.v6_global, | |
10945 | buf1, sizeof(buf1))); | |
10946 | json_object_string_add(json_neigh, "nexthopLocal", | |
10947 | inet_ntop(AF_INET6, | |
10948 | &p->nexthop.v6_local, | |
10949 | buf1, sizeof(buf1))); | |
10950 | if (p->shared_network) | |
10951 | json_object_string_add(json_neigh, | |
10952 | "bgpConnection", | |
10953 | "sharedNetwork"); | |
10954 | else | |
10955 | json_object_string_add(json_neigh, | |
10956 | "bgpConnection", | |
10957 | "nonSharedNetwork"); | |
10958 | } else { | |
10959 | vty_out(vty, "Nexthop: %s\n", | |
10960 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
10961 | sizeof(buf1))); | |
10962 | vty_out(vty, "Nexthop global: %s\n", | |
10963 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
10964 | sizeof(buf1))); | |
10965 | vty_out(vty, "Nexthop local: %s\n", | |
10966 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
10967 | sizeof(buf1))); | |
10968 | vty_out(vty, "BGP connection: %s\n", | |
10969 | p->shared_network ? "shared network" | |
10970 | : "non shared network"); | |
10971 | } | |
10972 | } | |
10973 | ||
10974 | /* Timer information. */ | |
10975 | if (use_json) { | |
10976 | json_object_int_add(json_neigh, "connectRetryTimer", | |
10977 | p->v_connect); | |
10978 | if (p->status == Established && p->rtt) | |
10979 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
10980 | p->rtt); | |
10981 | if (p->t_start) | |
10982 | json_object_int_add( | |
10983 | json_neigh, "nextStartTimerDueInMsecs", | |
10984 | thread_timer_remain_second(p->t_start) * 1000); | |
10985 | if (p->t_connect) | |
10986 | json_object_int_add( | |
10987 | json_neigh, "nextConnectTimerDueInMsecs", | |
10988 | thread_timer_remain_second(p->t_connect) | |
10989 | * 1000); | |
10990 | if (p->t_routeadv) { | |
10991 | json_object_int_add(json_neigh, "mraiInterval", | |
10992 | p->v_routeadv); | |
10993 | json_object_int_add( | |
10994 | json_neigh, "mraiTimerExpireInMsecs", | |
10995 | thread_timer_remain_second(p->t_routeadv) | |
10996 | * 1000); | |
10997 | } | |
10998 | if (p->password) | |
10999 | json_object_int_add(json_neigh, "authenticationEnabled", | |
11000 | 1); | |
11001 | ||
11002 | if (p->t_read) | |
11003 | json_object_string_add(json_neigh, "readThread", "on"); | |
11004 | else | |
11005 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
11006 | |
11007 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 11008 | json_object_string_add(json_neigh, "writeThread", "on"); |
11009 | else | |
11010 | json_object_string_add(json_neigh, "writeThread", | |
11011 | "off"); | |
11012 | } else { | |
11013 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
11014 | p->v_connect); | |
11015 | if (p->status == Established && p->rtt) | |
11016 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
11017 | p->rtt); | |
11018 | if (p->t_start) | |
11019 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
11020 | thread_timer_remain_second(p->t_start)); | |
11021 | if (p->t_connect) | |
11022 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
11023 | thread_timer_remain_second(p->t_connect)); | |
11024 | if (p->t_routeadv) | |
11025 | vty_out(vty, | |
11026 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
11027 | p->v_routeadv, | |
11028 | thread_timer_remain_second(p->t_routeadv)); | |
11029 | if (p->password) | |
11030 | vty_out(vty, "Peer Authentication Enabled\n"); | |
11031 | ||
cac9e917 | 11032 | vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n", |
49507a6f QY |
11033 | p->t_read ? "on" : "off", |
11034 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
11035 | ? "on" | |
cac9e917 | 11036 | : "off", p->fd); |
d62a17ae | 11037 | } |
11038 | ||
11039 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
11040 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
11041 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
11042 | ||
11043 | if (!use_json) | |
11044 | vty_out(vty, "\n"); | |
11045 | ||
11046 | /* BFD information. */ | |
11047 | bgp_bfd_show_info(vty, p, use_json, json_neigh); | |
11048 | ||
11049 | if (use_json) { | |
11050 | if (p->conf_if) /* Configured interface name. */ | |
11051 | json_object_object_add(json, p->conf_if, json_neigh); | |
11052 | else /* Configured IP address. */ | |
11053 | json_object_object_add(json, p->host, json_neigh); | |
11054 | } | |
11055 | } | |
11056 | ||
11057 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, | |
11058 | enum show_type type, union sockunion *su, | |
9f049418 | 11059 | const char *conf_if, bool use_json, |
d62a17ae | 11060 | json_object *json) |
11061 | { | |
11062 | struct listnode *node, *nnode; | |
11063 | struct peer *peer; | |
11064 | int find = 0; | |
9f049418 | 11065 | bool nbr_output = false; |
d1927ebe AS |
11066 | afi_t afi = AFI_MAX; |
11067 | safi_t safi = SAFI_MAX; | |
11068 | ||
11069 | if (type == show_ipv4_peer || type == show_ipv4_all) { | |
11070 | afi = AFI_IP; | |
11071 | } else if (type == show_ipv6_peer || type == show_ipv6_all) { | |
11072 | afi = AFI_IP6; | |
11073 | } | |
d62a17ae | 11074 | |
11075 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
11076 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
11077 | continue; | |
11078 | ||
11079 | switch (type) { | |
11080 | case show_all: | |
11081 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 11082 | nbr_output = true; |
d62a17ae | 11083 | break; |
11084 | case show_peer: | |
11085 | if (conf_if) { | |
11086 | if ((peer->conf_if | |
11087 | && !strcmp(peer->conf_if, conf_if)) | |
11088 | || (peer->hostname | |
11089 | && !strcmp(peer->hostname, conf_if))) { | |
11090 | find = 1; | |
11091 | bgp_show_peer(vty, peer, use_json, | |
11092 | json); | |
11093 | } | |
11094 | } else { | |
11095 | if (sockunion_same(&peer->su, su)) { | |
11096 | find = 1; | |
11097 | bgp_show_peer(vty, peer, use_json, | |
11098 | json); | |
11099 | } | |
11100 | } | |
11101 | break; | |
d1927ebe AS |
11102 | case show_ipv4_peer: |
11103 | case show_ipv6_peer: | |
11104 | FOREACH_SAFI (safi) { | |
11105 | if (peer->afc[afi][safi]) { | |
11106 | if (conf_if) { | |
11107 | if ((peer->conf_if | |
11108 | && !strcmp(peer->conf_if, conf_if)) | |
11109 | || (peer->hostname | |
11110 | && !strcmp(peer->hostname, conf_if))) { | |
11111 | find = 1; | |
11112 | bgp_show_peer(vty, peer, use_json, | |
11113 | json); | |
11114 | break; | |
11115 | } | |
11116 | } else { | |
11117 | if (sockunion_same(&peer->su, su)) { | |
11118 | find = 1; | |
11119 | bgp_show_peer(vty, peer, use_json, | |
11120 | json); | |
11121 | break; | |
11122 | } | |
11123 | } | |
11124 | } | |
11125 | } | |
11126 | break; | |
11127 | case show_ipv4_all: | |
11128 | case show_ipv6_all: | |
11129 | FOREACH_SAFI (safi) { | |
11130 | if (peer->afc[afi][safi]) { | |
11131 | bgp_show_peer(vty, peer, use_json, json); | |
11132 | nbr_output = true; | |
11133 | break; | |
11134 | } | |
11135 | } | |
11136 | break; | |
d62a17ae | 11137 | } |
11138 | } | |
11139 | ||
d1927ebe AS |
11140 | if ((type == show_peer || type == show_ipv4_peer || |
11141 | type == show_ipv6_peer) && !find) { | |
d62a17ae | 11142 | if (use_json) |
11143 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
11144 | else | |
88b7d255 | 11145 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 11146 | } |
11147 | ||
d1927ebe AS |
11148 | if (type != show_peer && type != show_ipv4_peer && |
11149 | type != show_ipv6_peer && !nbr_output && !use_json) | |
94d4c685 | 11150 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 11151 | |
d62a17ae | 11152 | if (use_json) { |
996c9314 LB |
11153 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
11154 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 11155 | } else { |
11156 | vty_out(vty, "\n"); | |
11157 | } | |
11158 | ||
11159 | return CMD_SUCCESS; | |
11160 | } | |
11161 | ||
11162 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, | |
71aedaa3 DS |
11163 | enum show_type type, |
11164 | const char *ip_str, | |
9f049418 | 11165 | bool use_json) |
d62a17ae | 11166 | { |
0291c246 MK |
11167 | struct listnode *node, *nnode; |
11168 | struct bgp *bgp; | |
71aedaa3 | 11169 | union sockunion su; |
0291c246 | 11170 | json_object *json = NULL; |
71aedaa3 | 11171 | int ret, is_first = 1; |
9f049418 | 11172 | bool nbr_output = false; |
d62a17ae | 11173 | |
11174 | if (use_json) | |
11175 | vty_out(vty, "{\n"); | |
11176 | ||
11177 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 11178 | nbr_output = true; |
d62a17ae | 11179 | if (use_json) { |
11180 | if (!(json = json_object_new_object())) { | |
af4c2728 | 11181 | flog_err( |
e50f7cfd | 11182 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 11183 | "Unable to allocate memory for JSON object"); |
11184 | vty_out(vty, | |
11185 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
11186 | return; | |
11187 | } | |
11188 | ||
11189 | json_object_int_add(json, "vrfId", | |
11190 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
11191 | ? -1 |
11192 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 11193 | json_object_string_add( |
11194 | json, "vrfName", | |
11195 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11196 | ? VRF_DEFAULT_NAME |
d62a17ae | 11197 | : bgp->name); |
11198 | ||
11199 | if (!is_first) | |
11200 | vty_out(vty, ",\n"); | |
11201 | else | |
11202 | is_first = 0; | |
11203 | ||
11204 | vty_out(vty, "\"%s\":", | |
11205 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11206 | ? VRF_DEFAULT_NAME |
d62a17ae | 11207 | : bgp->name); |
11208 | } else { | |
11209 | vty_out(vty, "\nInstance %s:\n", | |
11210 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11211 | ? VRF_DEFAULT_NAME |
d62a17ae | 11212 | : bgp->name); |
11213 | } | |
71aedaa3 | 11214 | |
d1927ebe AS |
11215 | if (type == show_peer || type == show_ipv4_peer || |
11216 | type == show_ipv6_peer) { | |
71aedaa3 DS |
11217 | ret = str2sockunion(ip_str, &su); |
11218 | if (ret < 0) | |
11219 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
11220 | use_json, json); | |
11221 | else | |
11222 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
11223 | use_json, json); | |
11224 | } else { | |
d1927ebe | 11225 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, |
71aedaa3 DS |
11226 | use_json, json); |
11227 | } | |
b77004d6 | 11228 | json_object_free(json); |
d62a17ae | 11229 | } |
11230 | ||
01cbfd04 | 11231 | if (use_json) { |
d62a17ae | 11232 | vty_out(vty, "}\n"); |
01cbfd04 QY |
11233 | json_object_free(json); |
11234 | } | |
9f049418 DS |
11235 | else if (!nbr_output) |
11236 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 11237 | } |
11238 | ||
11239 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
11240 | enum show_type type, const char *ip_str, | |
9f049418 | 11241 | bool use_json) |
d62a17ae | 11242 | { |
11243 | int ret; | |
11244 | struct bgp *bgp; | |
11245 | union sockunion su; | |
11246 | json_object *json = NULL; | |
11247 | ||
11248 | if (name) { | |
11249 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
11250 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
11251 | use_json); | |
d62a17ae | 11252 | return CMD_SUCCESS; |
11253 | } else { | |
11254 | bgp = bgp_lookup_by_name(name); | |
11255 | if (!bgp) { | |
11256 | if (use_json) { | |
11257 | json = json_object_new_object(); | |
d62a17ae | 11258 | vty_out(vty, "%s\n", |
11259 | json_object_to_json_string_ext( | |
11260 | json, | |
11261 | JSON_C_TO_STRING_PRETTY)); | |
11262 | json_object_free(json); | |
11263 | } else | |
11264 | vty_out(vty, | |
9f049418 | 11265 | "%% BGP instance not found\n"); |
d62a17ae | 11266 | |
11267 | return CMD_WARNING; | |
11268 | } | |
11269 | } | |
11270 | } else { | |
11271 | bgp = bgp_get_default(); | |
11272 | } | |
11273 | ||
11274 | if (bgp) { | |
11275 | json = json_object_new_object(); | |
11276 | if (ip_str) { | |
11277 | ret = str2sockunion(ip_str, &su); | |
11278 | if (ret < 0) | |
11279 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
11280 | use_json, json); | |
11281 | else | |
11282 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
11283 | use_json, json); | |
11284 | } else { | |
11285 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
11286 | json); | |
11287 | } | |
11288 | json_object_free(json); | |
ca61fd25 DS |
11289 | } else { |
11290 | if (use_json) | |
11291 | vty_out(vty, "{}\n"); | |
11292 | else | |
11293 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 11294 | } |
11295 | ||
11296 | return CMD_SUCCESS; | |
4fb25c53 DW |
11297 | } |
11298 | ||
716b2d8a | 11299 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 11300 | DEFUN (show_ip_bgp_neighbors, |
11301 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 11302 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 11303 | SHOW_STR |
11304 | IP_STR | |
11305 | BGP_STR | |
f2a8972b | 11306 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
11307 | "Address Family\n" |
11308 | "Address Family\n" | |
718e3744 | 11309 | "Detailed information on TCP and BGP neighbor connections\n" |
11310 | "Neighbor to display information about\n" | |
a80beece | 11311 | "Neighbor to display information about\n" |
91d37724 | 11312 | "Neighbor on BGP configured interface\n" |
9973d184 | 11313 | JSON_STR) |
718e3744 | 11314 | { |
d62a17ae | 11315 | char *vrf = NULL; |
11316 | char *sh_arg = NULL; | |
11317 | enum show_type sh_type; | |
d1927ebe | 11318 | afi_t afi = AFI_MAX; |
718e3744 | 11319 | |
9f049418 | 11320 | bool uj = use_json(argc, argv); |
718e3744 | 11321 | |
d62a17ae | 11322 | int idx = 0; |
718e3744 | 11323 | |
9a8bdf1c PG |
11324 | /* [<vrf> VIEWVRFNAME] */ |
11325 | if (argv_find(argv, argc, "vrf", &idx)) { | |
11326 | vrf = argv[idx + 1]->arg; | |
11327 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11328 | vrf = NULL; | |
11329 | } else if (argv_find(argv, argc, "view", &idx)) | |
11330 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 11331 | vrf = argv[idx + 1]->arg; |
718e3744 | 11332 | |
d62a17ae | 11333 | idx++; |
d1927ebe AS |
11334 | |
11335 | if (argv_find(argv, argc, "ipv4", &idx)) { | |
11336 | sh_type = show_ipv4_all; | |
11337 | afi = AFI_IP; | |
11338 | } else if (argv_find(argv, argc, "ipv6", &idx)) { | |
11339 | sh_type = show_ipv6_all; | |
11340 | afi = AFI_IP6; | |
11341 | } else { | |
11342 | sh_type = show_all; | |
11343 | } | |
11344 | ||
d62a17ae | 11345 | if (argv_find(argv, argc, "A.B.C.D", &idx) |
11346 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
11347 | || argv_find(argv, argc, "WORD", &idx)) { | |
11348 | sh_type = show_peer; | |
11349 | sh_arg = argv[idx]->arg; | |
d1927ebe AS |
11350 | } |
11351 | ||
11352 | if (sh_type == show_peer && afi == AFI_IP) { | |
11353 | sh_type = show_ipv4_peer; | |
11354 | } else if (sh_type == show_peer && afi == AFI_IP6) { | |
11355 | sh_type = show_ipv6_peer; | |
11356 | } | |
856ca177 | 11357 | |
d62a17ae | 11358 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 11359 | } |
11360 | ||
716b2d8a | 11361 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 11362 | paths' and `show ip mbgp paths'. Those functions results are the |
11363 | same.*/ | |
f412b39a | 11364 | DEFUN (show_ip_bgp_paths, |
718e3744 | 11365 | show_ip_bgp_paths_cmd, |
46f296b4 | 11366 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 11367 | SHOW_STR |
11368 | IP_STR | |
11369 | BGP_STR | |
46f296b4 | 11370 | BGP_SAFI_HELP_STR |
718e3744 | 11371 | "Path information\n") |
11372 | { | |
d62a17ae | 11373 | vty_out(vty, "Address Refcnt Path\n"); |
11374 | aspath_print_all_vty(vty); | |
11375 | return CMD_SUCCESS; | |
718e3744 | 11376 | } |
11377 | ||
718e3744 | 11378 | #include "hash.h" |
11379 | ||
e3b78da8 | 11380 | static void community_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 11381 | struct vty *vty) |
718e3744 | 11382 | { |
d62a17ae | 11383 | struct community *com; |
718e3744 | 11384 | |
e3b78da8 | 11385 | com = (struct community *)bucket->data; |
3f65c5b1 | 11386 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 11387 | community_str(com, false)); |
718e3744 | 11388 | } |
11389 | ||
11390 | /* Show BGP's community internal data. */ | |
f412b39a | 11391 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 11392 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 11393 | "show [ip] bgp community-info", |
718e3744 | 11394 | SHOW_STR |
11395 | IP_STR | |
11396 | BGP_STR | |
11397 | "List all bgp community information\n") | |
11398 | { | |
d62a17ae | 11399 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 11400 | |
d62a17ae | 11401 | hash_iterate(community_hash(), |
e3b78da8 | 11402 | (void (*)(struct hash_bucket *, |
d62a17ae | 11403 | void *))community_show_all_iterator, |
11404 | vty); | |
718e3744 | 11405 | |
d62a17ae | 11406 | return CMD_SUCCESS; |
718e3744 | 11407 | } |
11408 | ||
e3b78da8 | 11409 | static void lcommunity_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 11410 | struct vty *vty) |
57d187bc | 11411 | { |
d62a17ae | 11412 | struct lcommunity *lcom; |
57d187bc | 11413 | |
e3b78da8 | 11414 | lcom = (struct lcommunity *)bucket->data; |
3f65c5b1 | 11415 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
8d9b8ed9 | 11416 | lcommunity_str(lcom, false)); |
57d187bc JS |
11417 | } |
11418 | ||
11419 | /* Show BGP's community internal data. */ | |
11420 | DEFUN (show_ip_bgp_lcommunity_info, | |
11421 | show_ip_bgp_lcommunity_info_cmd, | |
11422 | "show ip bgp large-community-info", | |
11423 | SHOW_STR | |
11424 | IP_STR | |
11425 | BGP_STR | |
11426 | "List all bgp large-community information\n") | |
11427 | { | |
d62a17ae | 11428 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 11429 | |
d62a17ae | 11430 | hash_iterate(lcommunity_hash(), |
e3b78da8 | 11431 | (void (*)(struct hash_bucket *, |
d62a17ae | 11432 | void *))lcommunity_show_all_iterator, |
11433 | vty); | |
57d187bc | 11434 | |
d62a17ae | 11435 | return CMD_SUCCESS; |
57d187bc JS |
11436 | } |
11437 | ||
11438 | ||
f412b39a | 11439 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 11440 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 11441 | "show [ip] bgp attribute-info", |
718e3744 | 11442 | SHOW_STR |
11443 | IP_STR | |
11444 | BGP_STR | |
11445 | "List all bgp attribute information\n") | |
11446 | { | |
d62a17ae | 11447 | attr_show_all(vty); |
11448 | return CMD_SUCCESS; | |
718e3744 | 11449 | } |
6b0655a2 | 11450 | |
03915806 CS |
11451 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
11452 | afi_t afi, safi_t safi, | |
11453 | bool use_json, json_object *json) | |
53089bec | 11454 | { |
11455 | struct bgp *bgp; | |
11456 | struct listnode *node; | |
11457 | char *vname; | |
11458 | char buf1[INET6_ADDRSTRLEN]; | |
11459 | char *ecom_str; | |
11460 | vpn_policy_direction_t dir; | |
11461 | ||
03915806 | 11462 | if (json) { |
b46dfd20 DS |
11463 | json_object *json_import_vrfs = NULL; |
11464 | json_object *json_export_vrfs = NULL; | |
11465 | ||
b46dfd20 DS |
11466 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
11467 | ||
53089bec | 11468 | if (!bgp) { |
b46dfd20 DS |
11469 | vty_out(vty, "%s\n", |
11470 | json_object_to_json_string_ext( | |
11471 | json, | |
11472 | JSON_C_TO_STRING_PRETTY)); | |
11473 | json_object_free(json); | |
11474 | ||
53089bec | 11475 | return CMD_WARNING; |
11476 | } | |
b46dfd20 | 11477 | |
94d4c685 DS |
11478 | /* Provide context for the block */ |
11479 | json_object_string_add(json, "vrf", name ? name : "default"); | |
11480 | json_object_string_add(json, "afiSafi", | |
5cb5f4d0 | 11481 | get_afi_safi_str(afi, safi, true)); |
94d4c685 | 11482 | |
b46dfd20 DS |
11483 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
11484 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
11485 | json_object_string_add(json, "importFromVrfs", "none"); | |
11486 | json_object_string_add(json, "importRts", "none"); | |
11487 | } else { | |
6ce24e52 DS |
11488 | json_import_vrfs = json_object_new_array(); |
11489 | ||
b46dfd20 DS |
11490 | for (ALL_LIST_ELEMENTS_RO( |
11491 | bgp->vpn_policy[afi].import_vrf, | |
11492 | node, vname)) | |
11493 | json_object_array_add(json_import_vrfs, | |
11494 | json_object_new_string(vname)); | |
11495 | ||
b20875ea CS |
11496 | json_object_object_add(json, "importFromVrfs", |
11497 | json_import_vrfs); | |
b46dfd20 | 11498 | dir = BGP_VPN_POLICY_DIR_FROMVPN; |
b20875ea CS |
11499 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
11500 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
11501 | bgp->vpn_policy[afi].rtlist[dir], |
11502 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
11503 | json_object_string_add(json, "importRts", |
11504 | ecom_str); | |
11505 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
11506 | } else | |
11507 | json_object_string_add(json, "importRts", | |
11508 | "none"); | |
b46dfd20 DS |
11509 | } |
11510 | ||
11511 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
11512 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
11513 | json_object_string_add(json, "exportToVrfs", "none"); | |
11514 | json_object_string_add(json, "routeDistinguisher", | |
11515 | "none"); | |
11516 | json_object_string_add(json, "exportRts", "none"); | |
11517 | } else { | |
6ce24e52 DS |
11518 | json_export_vrfs = json_object_new_array(); |
11519 | ||
b46dfd20 DS |
11520 | for (ALL_LIST_ELEMENTS_RO( |
11521 | bgp->vpn_policy[afi].export_vrf, | |
11522 | node, vname)) | |
11523 | json_object_array_add(json_export_vrfs, | |
11524 | json_object_new_string(vname)); | |
11525 | json_object_object_add(json, "exportToVrfs", | |
11526 | json_export_vrfs); | |
11527 | json_object_string_add(json, "routeDistinguisher", | |
11528 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
11529 | buf1, RD_ADDRSTRLEN)); | |
11530 | ||
11531 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
11532 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
11533 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
11534 | bgp->vpn_policy[afi].rtlist[dir], |
11535 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
11536 | json_object_string_add(json, "exportRts", |
11537 | ecom_str); | |
11538 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
11539 | } else | |
11540 | json_object_string_add(json, "exportRts", | |
11541 | "none"); | |
b46dfd20 DS |
11542 | } |
11543 | ||
03915806 CS |
11544 | if (use_json) { |
11545 | vty_out(vty, "%s\n", | |
11546 | json_object_to_json_string_ext(json, | |
b46dfd20 | 11547 | JSON_C_TO_STRING_PRETTY)); |
03915806 CS |
11548 | json_object_free(json); |
11549 | } | |
53089bec | 11550 | } else { |
b46dfd20 DS |
11551 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
11552 | ||
53089bec | 11553 | if (!bgp) { |
b46dfd20 | 11554 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 11555 | return CMD_WARNING; |
11556 | } | |
53089bec | 11557 | |
b46dfd20 DS |
11558 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
11559 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
11560 | vty_out(vty, | |
11561 | "This VRF is not importing %s routes from any other VRF\n", | |
5cb5f4d0 | 11562 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
11563 | else { |
11564 | vty_out(vty, | |
11565 | "This VRF is importing %s routes from the following VRFs:\n", | |
5cb5f4d0 | 11566 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
11567 | |
11568 | for (ALL_LIST_ELEMENTS_RO( | |
11569 | bgp->vpn_policy[afi].import_vrf, | |
11570 | node, vname)) | |
11571 | vty_out(vty, " %s\n", vname); | |
11572 | ||
11573 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b20875ea CS |
11574 | ecom_str = NULL; |
11575 | if (bgp->vpn_policy[afi].rtlist[dir]) { | |
11576 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
11577 | bgp->vpn_policy[afi].rtlist[dir], |
11578 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea | 11579 | vty_out(vty, "Import RT(s): %s\n", ecom_str); |
b46dfd20 | 11580 | |
b20875ea CS |
11581 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
11582 | } else | |
11583 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 11584 | } |
53089bec | 11585 | |
b46dfd20 DS |
11586 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
11587 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
11588 | vty_out(vty, | |
11589 | "This VRF is not exporting %s routes to any other VRF\n", | |
5cb5f4d0 | 11590 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
11591 | else { |
11592 | vty_out(vty, | |
04c9077f | 11593 | "This VRF is exporting %s routes to the following VRFs:\n", |
5cb5f4d0 | 11594 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
11595 | |
11596 | for (ALL_LIST_ELEMENTS_RO( | |
11597 | bgp->vpn_policy[afi].export_vrf, | |
11598 | node, vname)) | |
11599 | vty_out(vty, " %s\n", vname); | |
11600 | ||
11601 | vty_out(vty, "RD: %s\n", | |
11602 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
11603 | buf1, RD_ADDRSTRLEN)); | |
11604 | ||
11605 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
11606 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
11607 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
11608 | bgp->vpn_policy[afi].rtlist[dir], |
11609 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
11610 | vty_out(vty, "Export RT: %s\n", ecom_str); |
11611 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
11612 | } else | |
11613 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 11614 | } |
53089bec | 11615 | } |
11616 | ||
11617 | return CMD_SUCCESS; | |
11618 | } | |
11619 | ||
03915806 CS |
11620 | static int bgp_show_all_instance_route_leak_vty(struct vty *vty, afi_t afi, |
11621 | safi_t safi, bool use_json) | |
11622 | { | |
11623 | struct listnode *node, *nnode; | |
11624 | struct bgp *bgp; | |
11625 | char *vrf_name = NULL; | |
11626 | json_object *json = NULL; | |
11627 | json_object *json_vrf = NULL; | |
11628 | json_object *json_vrfs = NULL; | |
11629 | ||
11630 | if (use_json) { | |
11631 | json = json_object_new_object(); | |
11632 | json_vrfs = json_object_new_object(); | |
11633 | } | |
11634 | ||
11635 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
11636 | ||
11637 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) | |
11638 | vrf_name = bgp->name; | |
11639 | ||
11640 | if (use_json) { | |
11641 | json_vrf = json_object_new_object(); | |
11642 | } else { | |
11643 | vty_out(vty, "\nInstance %s:\n", | |
11644 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
11645 | ? VRF_DEFAULT_NAME : bgp->name); | |
11646 | } | |
11647 | bgp_show_route_leak_vty(vty, vrf_name, afi, safi, 0, json_vrf); | |
11648 | if (use_json) { | |
11649 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
11650 | json_object_object_add(json_vrfs, | |
11651 | VRF_DEFAULT_NAME, json_vrf); | |
11652 | else | |
11653 | json_object_object_add(json_vrfs, vrf_name, | |
11654 | json_vrf); | |
11655 | } | |
11656 | } | |
11657 | ||
11658 | if (use_json) { | |
11659 | json_object_object_add(json, "vrfs", json_vrfs); | |
11660 | vty_out(vty, "%s\n", json_object_to_json_string_ext(json, | |
11661 | JSON_C_TO_STRING_PRETTY)); | |
11662 | json_object_free(json); | |
11663 | } | |
11664 | ||
11665 | return CMD_SUCCESS; | |
11666 | } | |
11667 | ||
53089bec | 11668 | /* "show [ip] bgp route-leak" command. */ |
11669 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
11670 | show_ip_bgp_route_leak_cmd, |
11671 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
11672 | SHOW_STR |
11673 | IP_STR | |
11674 | BGP_STR | |
11675 | BGP_INSTANCE_HELP_STR | |
11676 | BGP_AFI_HELP_STR | |
11677 | BGP_SAFI_HELP_STR | |
11678 | "Route leaking information\n" | |
11679 | JSON_STR) | |
53089bec | 11680 | { |
11681 | char *vrf = NULL; | |
11682 | afi_t afi = AFI_MAX; | |
11683 | safi_t safi = SAFI_MAX; | |
11684 | ||
9f049418 | 11685 | bool uj = use_json(argc, argv); |
53089bec | 11686 | int idx = 0; |
03915806 | 11687 | json_object *json = NULL; |
53089bec | 11688 | |
11689 | /* show [ip] bgp */ | |
11690 | if (argv_find(argv, argc, "ip", &idx)) { | |
11691 | afi = AFI_IP; | |
11692 | safi = SAFI_UNICAST; | |
11693 | } | |
11694 | /* [vrf VIEWVRFNAME] */ | |
11695 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
11696 | vty_out(vty, |
11697 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 11698 | return CMD_WARNING; |
11699 | } | |
11700 | ||
9a8bdf1c PG |
11701 | if (argv_find(argv, argc, "vrf", &idx)) { |
11702 | vrf = argv[idx + 1]->arg; | |
11703 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11704 | vrf = NULL; | |
11705 | } | |
53089bec | 11706 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
11707 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11708 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11709 | } | |
11710 | ||
11711 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
11712 | vty_out(vty, |
11713 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 11714 | return CMD_WARNING; |
11715 | } | |
11716 | ||
03915806 CS |
11717 | if (vrf && strmatch(vrf, "all")) |
11718 | return bgp_show_all_instance_route_leak_vty(vty, afi, safi, uj); | |
11719 | ||
11720 | if (uj) | |
11721 | json = json_object_new_object(); | |
11722 | ||
11723 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj, json); | |
53089bec | 11724 | } |
11725 | ||
d62a17ae | 11726 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
11727 | safi_t safi) | |
f186de26 | 11728 | { |
d62a17ae | 11729 | struct listnode *node, *nnode; |
11730 | struct bgp *bgp; | |
f186de26 | 11731 | |
d62a17ae | 11732 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
11733 | vty_out(vty, "\nInstance %s:\n", | |
11734 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11735 | ? VRF_DEFAULT_NAME |
d62a17ae | 11736 | : bgp->name); |
11737 | update_group_show(bgp, afi, safi, vty, 0); | |
11738 | } | |
f186de26 | 11739 | } |
11740 | ||
d62a17ae | 11741 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
11742 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 11743 | { |
d62a17ae | 11744 | struct bgp *bgp; |
4fb25c53 | 11745 | |
d62a17ae | 11746 | if (name) { |
11747 | if (strmatch(name, "all")) { | |
11748 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
11749 | return CMD_SUCCESS; | |
11750 | } else { | |
11751 | bgp = bgp_lookup_by_name(name); | |
11752 | } | |
11753 | } else { | |
11754 | bgp = bgp_get_default(); | |
11755 | } | |
4fb25c53 | 11756 | |
d62a17ae | 11757 | if (bgp) |
11758 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
11759 | return CMD_SUCCESS; | |
4fb25c53 DW |
11760 | } |
11761 | ||
8fe8a7f6 DS |
11762 | DEFUN (show_ip_bgp_updgrps, |
11763 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 11764 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 11765 | SHOW_STR |
11766 | IP_STR | |
11767 | BGP_STR | |
11768 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 11769 | BGP_AFI_HELP_STR |
9bedbb1e | 11770 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
11771 | "Detailed info about dynamic update groups\n" |
11772 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 11773 | { |
d62a17ae | 11774 | char *vrf = NULL; |
11775 | afi_t afi = AFI_IP6; | |
11776 | safi_t safi = SAFI_UNICAST; | |
11777 | uint64_t subgrp_id = 0; | |
11778 | ||
11779 | int idx = 0; | |
11780 | ||
11781 | /* show [ip] bgp */ | |
11782 | if (argv_find(argv, argc, "ip", &idx)) | |
11783 | afi = AFI_IP; | |
9a8bdf1c PG |
11784 | /* [<vrf> VIEWVRFNAME] */ |
11785 | if (argv_find(argv, argc, "vrf", &idx)) { | |
11786 | vrf = argv[idx + 1]->arg; | |
11787 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11788 | vrf = NULL; | |
11789 | } else if (argv_find(argv, argc, "view", &idx)) | |
11790 | /* [<view> VIEWVRFNAME] */ | |
11791 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 11792 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
11793 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11794 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11795 | } | |
5bf15956 | 11796 | |
d62a17ae | 11797 | /* get subgroup id, if provided */ |
11798 | idx = argc - 1; | |
11799 | if (argv[idx]->type == VARIABLE_TKN) | |
11800 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 11801 | |
d62a17ae | 11802 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
11803 | } |
11804 | ||
f186de26 | 11805 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
11806 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 11807 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 11808 | SHOW_STR |
716b2d8a | 11809 | IP_STR |
f186de26 | 11810 | BGP_STR |
11811 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 11812 | "Detailed info about dynamic update groups\n") |
f186de26 | 11813 | { |
d62a17ae | 11814 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
11815 | return CMD_SUCCESS; | |
f186de26 | 11816 | } |
11817 | ||
43d3f4fc DS |
11818 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
11819 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
11820 | "show [ip] bgp l2vpn evpn update-groups", | |
11821 | SHOW_STR | |
11822 | IP_STR | |
11823 | BGP_STR | |
11824 | "l2vpn address family\n" | |
11825 | "evpn sub-address family\n" | |
11826 | "Detailed info about dynamic update groups\n") | |
11827 | { | |
11828 | char *vrf = NULL; | |
11829 | uint64_t subgrp_id = 0; | |
11830 | ||
11831 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id); | |
11832 | return CMD_SUCCESS; | |
11833 | } | |
11834 | ||
5bf15956 DW |
11835 | DEFUN (show_bgp_updgrps_stats, |
11836 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 11837 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 11838 | SHOW_STR |
716b2d8a | 11839 | IP_STR |
3f9c7369 | 11840 | BGP_STR |
0c7b1b01 | 11841 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
11842 | "Statistics\n") |
11843 | { | |
d62a17ae | 11844 | struct bgp *bgp; |
3f9c7369 | 11845 | |
d62a17ae | 11846 | bgp = bgp_get_default(); |
11847 | if (bgp) | |
11848 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 11849 | |
d62a17ae | 11850 | return CMD_SUCCESS; |
3f9c7369 DS |
11851 | } |
11852 | ||
8386ac43 | 11853 | DEFUN (show_bgp_instance_updgrps_stats, |
11854 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 11855 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 11856 | SHOW_STR |
716b2d8a | 11857 | IP_STR |
8386ac43 | 11858 | BGP_STR |
11859 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 11860 | "Detailed info about dynamic update groups\n" |
8386ac43 | 11861 | "Statistics\n") |
11862 | { | |
d62a17ae | 11863 | int idx_word = 3; |
11864 | struct bgp *bgp; | |
8386ac43 | 11865 | |
d62a17ae | 11866 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
11867 | if (bgp) | |
11868 | update_group_show_stats(bgp, vty); | |
8386ac43 | 11869 | |
d62a17ae | 11870 | return CMD_SUCCESS; |
8386ac43 | 11871 | } |
11872 | ||
d62a17ae | 11873 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
11874 | afi_t afi, safi_t safi, | |
11875 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 11876 | { |
d62a17ae | 11877 | struct bgp *bgp; |
8386ac43 | 11878 | |
d62a17ae | 11879 | if (name) |
11880 | bgp = bgp_lookup_by_name(name); | |
11881 | else | |
11882 | bgp = bgp_get_default(); | |
8386ac43 | 11883 | |
d62a17ae | 11884 | if (bgp) { |
11885 | if (!strcmp(what, "advertise-queue")) | |
11886 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
11887 | subgrp_id); | |
11888 | else if (!strcmp(what, "advertised-routes")) | |
11889 | update_group_show_advertised(bgp, afi, safi, vty, | |
11890 | subgrp_id); | |
11891 | else if (!strcmp(what, "packet-queue")) | |
11892 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
11893 | subgrp_id); | |
11894 | } | |
3f9c7369 DS |
11895 | } |
11896 | ||
dc64bdec QY |
11897 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
11898 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
11899 | "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", | |
11900 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
11901 | BGP_SAFI_HELP_STR | |
11902 | "Detailed info about dynamic update groups\n" | |
11903 | "Specific subgroup to display info for\n" | |
11904 | "Advertisement queue\n" | |
11905 | "Announced routes\n" | |
11906 | "Packet queue\n") | |
3f9c7369 | 11907 | { |
dc64bdec QY |
11908 | uint64_t subgrp_id = 0; |
11909 | afi_t afiz; | |
11910 | safi_t safiz; | |
11911 | if (sgid) | |
11912 | subgrp_id = strtoull(sgid, NULL, 10); | |
11913 | ||
11914 | if (!ip && !afi) | |
11915 | afiz = AFI_IP6; | |
11916 | if (!ip && afi) | |
11917 | afiz = bgp_vty_afi_from_str(afi); | |
11918 | if (ip && !afi) | |
11919 | afiz = AFI_IP; | |
11920 | if (ip && afi) { | |
11921 | afiz = bgp_vty_afi_from_str(afi); | |
11922 | if (afiz != AFI_IP) | |
11923 | vty_out(vty, | |
11924 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
11925 | return CMD_WARNING; | |
11926 | } | |
d62a17ae | 11927 | |
dc64bdec | 11928 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 11929 | |
dc64bdec | 11930 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 11931 | return CMD_SUCCESS; |
11932 | } | |
11933 | ||
d62a17ae | 11934 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group) |
11935 | { | |
11936 | struct listnode *node, *nnode; | |
11937 | struct prefix *range; | |
11938 | struct peer *conf; | |
11939 | struct peer *peer; | |
11940 | char buf[PREFIX2STR_BUFFER]; | |
11941 | afi_t afi; | |
11942 | safi_t safi; | |
11943 | const char *peer_status; | |
11944 | const char *af_str; | |
11945 | int lr_count; | |
11946 | int dynamic; | |
11947 | int af_cfgd; | |
11948 | ||
11949 | conf = group->conf; | |
11950 | ||
11951 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
3b61f610 QY |
11952 | vty_out(vty, "\nBGP peer-group %s, remote AS %" PRIu32 "\n", |
11953 | group->name, conf->as); | |
d62a17ae | 11954 | } else if (conf->as_type == AS_INTERNAL) { |
3b61f610 QY |
11955 | vty_out(vty, "\nBGP peer-group %s, remote AS %" PRIu32 "\n", |
11956 | group->name, group->bgp->as); | |
d62a17ae | 11957 | } else { |
11958 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
11959 | } | |
f14e6fdb | 11960 | |
d62a17ae | 11961 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
11962 | vty_out(vty, " Peer-group type is internal\n"); | |
11963 | else | |
11964 | vty_out(vty, " Peer-group type is external\n"); | |
11965 | ||
11966 | /* Display AFs configured. */ | |
11967 | vty_out(vty, " Configured address-families:"); | |
05c7a1cc QY |
11968 | FOREACH_AFI_SAFI (afi, safi) { |
11969 | if (conf->afc[afi][safi]) { | |
11970 | af_cfgd = 1; | |
5cb5f4d0 | 11971 | vty_out(vty, " %s;", get_afi_safi_str(afi, safi, false)); |
d62a17ae | 11972 | } |
05c7a1cc | 11973 | } |
d62a17ae | 11974 | if (!af_cfgd) |
11975 | vty_out(vty, " none\n"); | |
11976 | else | |
11977 | vty_out(vty, "\n"); | |
11978 | ||
11979 | /* Display listen ranges (for dynamic neighbors), if any */ | |
11980 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
11981 | if (afi == AFI_IP) | |
11982 | af_str = "IPv4"; | |
11983 | else if (afi == AFI_IP6) | |
11984 | af_str = "IPv6"; | |
11985 | else | |
11986 | af_str = "???"; | |
11987 | lr_count = listcount(group->listen_range[afi]); | |
11988 | if (lr_count) { | |
11989 | vty_out(vty, " %d %s listen range(s)\n", lr_count, | |
11990 | af_str); | |
11991 | ||
11992 | ||
11993 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
11994 | nnode, range)) { | |
11995 | prefix2str(range, buf, sizeof(buf)); | |
11996 | vty_out(vty, " %s\n", buf); | |
11997 | } | |
11998 | } | |
11999 | } | |
f14e6fdb | 12000 | |
d62a17ae | 12001 | /* Display group members and their status */ |
12002 | if (listcount(group->peer)) { | |
12003 | vty_out(vty, " Peer-group members:\n"); | |
12004 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
12005 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
12006 | peer_status = "Idle (Admin)"; | |
12007 | else if (CHECK_FLAG(peer->sflags, | |
12008 | PEER_STATUS_PREFIX_OVERFLOW)) | |
12009 | peer_status = "Idle (PfxCt)"; | |
12010 | else | |
12011 | peer_status = lookup_msg(bgp_status_msg, | |
12012 | peer->status, NULL); | |
12013 | ||
12014 | dynamic = peer_dynamic_neighbor(peer); | |
12015 | vty_out(vty, " %s %s %s \n", peer->host, | |
12016 | dynamic ? "(dynamic)" : "", peer_status); | |
12017 | } | |
12018 | } | |
f14e6fdb | 12019 | |
d62a17ae | 12020 | return CMD_SUCCESS; |
12021 | } | |
12022 | ||
ff9959b0 QY |
12023 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
12024 | const char *group_name) | |
d62a17ae | 12025 | { |
ff9959b0 | 12026 | struct bgp *bgp; |
d62a17ae | 12027 | struct listnode *node, *nnode; |
12028 | struct peer_group *group; | |
ff9959b0 QY |
12029 | bool found = false; |
12030 | ||
12031 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
12032 | ||
12033 | if (!bgp) { | |
9f049418 | 12034 | vty_out(vty, "%% BGP instance not found\n"); |
ff9959b0 QY |
12035 | return CMD_WARNING; |
12036 | } | |
d62a17ae | 12037 | |
12038 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
12039 | if (group_name) { |
12040 | if (strmatch(group->name, group_name)) { | |
d62a17ae | 12041 | bgp_show_one_peer_group(vty, group); |
ff9959b0 QY |
12042 | found = true; |
12043 | break; | |
d62a17ae | 12044 | } |
ff9959b0 QY |
12045 | } else { |
12046 | bgp_show_one_peer_group(vty, group); | |
d62a17ae | 12047 | } |
f14e6fdb | 12048 | } |
f14e6fdb | 12049 | |
ff9959b0 | 12050 | if (group_name && !found) |
d62a17ae | 12051 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 12052 | |
d62a17ae | 12053 | return CMD_SUCCESS; |
f14e6fdb DS |
12054 | } |
12055 | ||
f14e6fdb DS |
12056 | DEFUN (show_ip_bgp_peer_groups, |
12057 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 12058 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
12059 | SHOW_STR |
12060 | IP_STR | |
12061 | BGP_STR | |
8386ac43 | 12062 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
12063 | "Detailed information on BGP peer groups\n" |
12064 | "Peer group name\n") | |
f14e6fdb | 12065 | { |
d62a17ae | 12066 | char *vrf, *pg; |
d62a17ae | 12067 | int idx = 0; |
f14e6fdb | 12068 | |
a4d82a8a PZ |
12069 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
12070 | : NULL; | |
d62a17ae | 12071 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 12072 | |
ff9959b0 | 12073 | return bgp_show_peer_group_vty(vty, vrf, pg); |
f14e6fdb | 12074 | } |
3f9c7369 | 12075 | |
d6e3c605 | 12076 | |
718e3744 | 12077 | /* Redistribute VTY commands. */ |
12078 | ||
718e3744 | 12079 | DEFUN (bgp_redistribute_ipv4, |
12080 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 12081 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 12082 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12083 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 12084 | { |
d62a17ae | 12085 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12086 | int idx_protocol = 1; | |
12087 | int type; | |
718e3744 | 12088 | |
d62a17ae | 12089 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
12090 | if (type < 0) { | |
12091 | vty_out(vty, "%% Invalid route type\n"); | |
12092 | return CMD_WARNING_CONFIG_FAILED; | |
12093 | } | |
7f323236 | 12094 | |
d62a17ae | 12095 | bgp_redist_add(bgp, AFI_IP, type, 0); |
e923dd62 | 12096 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, false); |
718e3744 | 12097 | } |
12098 | ||
d62a17ae | 12099 | ALIAS_HIDDEN( |
12100 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
12101 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
12102 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 12103 | |
718e3744 | 12104 | DEFUN (bgp_redistribute_ipv4_rmap, |
12105 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 12106 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 12107 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12108 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 12109 | "Route map reference\n" |
12110 | "Pointer to route-map entries\n") | |
12111 | { | |
d62a17ae | 12112 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12113 | int idx_protocol = 1; | |
12114 | int idx_word = 3; | |
12115 | int type; | |
12116 | struct bgp_redist *red; | |
e923dd62 | 12117 | bool changed; |
1de27621 DA |
12118 | struct route_map *route_map = route_map_lookup_warn_noexist( |
12119 | vty, argv[idx_word]->arg); | |
718e3744 | 12120 | |
d62a17ae | 12121 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
12122 | if (type < 0) { | |
12123 | vty_out(vty, "%% Invalid route type\n"); | |
12124 | return CMD_WARNING_CONFIG_FAILED; | |
12125 | } | |
718e3744 | 12126 | |
d62a17ae | 12127 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
1de27621 DA |
12128 | changed = |
12129 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12130 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
718e3744 | 12131 | } |
12132 | ||
d62a17ae | 12133 | ALIAS_HIDDEN( |
12134 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
12135 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
12136 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
12137 | "Route map reference\n" | |
12138 | "Pointer to route-map entries\n") | |
596c17ba | 12139 | |
718e3744 | 12140 | DEFUN (bgp_redistribute_ipv4_metric, |
12141 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 12142 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 12143 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12144 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 12145 | "Metric for redistributed routes\n" |
12146 | "Default metric\n") | |
12147 | { | |
d62a17ae | 12148 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12149 | int idx_protocol = 1; | |
12150 | int idx_number = 3; | |
12151 | int type; | |
d7c0a89a | 12152 | uint32_t metric; |
d62a17ae | 12153 | struct bgp_redist *red; |
e923dd62 | 12154 | bool changed; |
d62a17ae | 12155 | |
12156 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
12157 | if (type < 0) { | |
12158 | vty_out(vty, "%% Invalid route type\n"); | |
12159 | return CMD_WARNING_CONFIG_FAILED; | |
12160 | } | |
12161 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
12162 | ||
12163 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 12164 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
12165 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 12166 | } |
12167 | ||
12168 | ALIAS_HIDDEN( | |
12169 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
12170 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
12171 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
12172 | "Metric for redistributed routes\n" | |
12173 | "Default metric\n") | |
596c17ba | 12174 | |
718e3744 | 12175 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
12176 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 12177 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 12178 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12179 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 12180 | "Route map reference\n" |
12181 | "Pointer to route-map entries\n" | |
12182 | "Metric for redistributed routes\n" | |
12183 | "Default metric\n") | |
12184 | { | |
d62a17ae | 12185 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12186 | int idx_protocol = 1; | |
12187 | int idx_word = 3; | |
12188 | int idx_number = 5; | |
12189 | int type; | |
d7c0a89a | 12190 | uint32_t metric; |
d62a17ae | 12191 | struct bgp_redist *red; |
e923dd62 | 12192 | bool changed; |
1de27621 DA |
12193 | struct route_map *route_map = |
12194 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12195 | |
12196 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
12197 | if (type < 0) { | |
12198 | vty_out(vty, "%% Invalid route type\n"); | |
12199 | return CMD_WARNING_CONFIG_FAILED; | |
12200 | } | |
12201 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
12202 | ||
12203 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
1de27621 DA |
12204 | changed = |
12205 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12206 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
12207 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 12208 | } |
12209 | ||
12210 | ALIAS_HIDDEN( | |
12211 | bgp_redistribute_ipv4_rmap_metric, | |
12212 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
12213 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
12214 | " route-map WORD metric (0-4294967295)", | |
12215 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
12216 | "Route map reference\n" | |
12217 | "Pointer to route-map entries\n" | |
12218 | "Metric for redistributed routes\n" | |
12219 | "Default metric\n") | |
596c17ba | 12220 | |
718e3744 | 12221 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
12222 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 12223 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 12224 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12225 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 12226 | "Metric for redistributed routes\n" |
12227 | "Default metric\n" | |
12228 | "Route map reference\n" | |
12229 | "Pointer to route-map entries\n") | |
12230 | { | |
d62a17ae | 12231 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12232 | int idx_protocol = 1; | |
12233 | int idx_number = 3; | |
12234 | int idx_word = 5; | |
12235 | int type; | |
d7c0a89a | 12236 | uint32_t metric; |
d62a17ae | 12237 | struct bgp_redist *red; |
e923dd62 | 12238 | bool changed; |
1de27621 DA |
12239 | struct route_map *route_map = |
12240 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12241 | |
12242 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
12243 | if (type < 0) { | |
12244 | vty_out(vty, "%% Invalid route type\n"); | |
12245 | return CMD_WARNING_CONFIG_FAILED; | |
12246 | } | |
12247 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
12248 | ||
12249 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 12250 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
1de27621 DA |
12251 | changed |= |
12252 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12253 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
d62a17ae | 12254 | } |
12255 | ||
12256 | ALIAS_HIDDEN( | |
12257 | bgp_redistribute_ipv4_metric_rmap, | |
12258 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
12259 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
12260 | " metric (0-4294967295) route-map WORD", | |
12261 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
12262 | "Metric for redistributed routes\n" | |
12263 | "Default metric\n" | |
12264 | "Route map reference\n" | |
12265 | "Pointer to route-map entries\n") | |
596c17ba | 12266 | |
7c8ff89e DS |
12267 | DEFUN (bgp_redistribute_ipv4_ospf, |
12268 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 12269 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
12270 | "Redistribute information from another routing protocol\n" |
12271 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12272 | "Non-main Kernel Routing Table\n" |
12273 | "Instance ID/Table ID\n") | |
7c8ff89e | 12274 | { |
d62a17ae | 12275 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12276 | int idx_ospf_table = 1; | |
12277 | int idx_number = 2; | |
d7c0a89a QY |
12278 | unsigned short instance; |
12279 | unsigned short protocol; | |
7c8ff89e | 12280 | |
d62a17ae | 12281 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 12282 | |
d62a17ae | 12283 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
12284 | protocol = ZEBRA_ROUTE_OSPF; | |
12285 | else | |
12286 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 12287 | |
d62a17ae | 12288 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
e923dd62 | 12289 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, false); |
7c8ff89e DS |
12290 | } |
12291 | ||
d62a17ae | 12292 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
12293 | "redistribute <ospf|table> (1-65535)", | |
12294 | "Redistribute information from another routing protocol\n" | |
12295 | "Open Shortest Path First (OSPFv2)\n" | |
12296 | "Non-main Kernel Routing Table\n" | |
12297 | "Instance ID/Table ID\n") | |
596c17ba | 12298 | |
7c8ff89e DS |
12299 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
12300 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 12301 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
12302 | "Redistribute information from another routing protocol\n" |
12303 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12304 | "Non-main Kernel Routing Table\n" |
12305 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12306 | "Route map reference\n" |
12307 | "Pointer to route-map entries\n") | |
12308 | { | |
d62a17ae | 12309 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12310 | int idx_ospf_table = 1; | |
12311 | int idx_number = 2; | |
12312 | int idx_word = 4; | |
12313 | struct bgp_redist *red; | |
d7c0a89a | 12314 | unsigned short instance; |
d62a17ae | 12315 | int protocol; |
e923dd62 | 12316 | bool changed; |
1de27621 DA |
12317 | struct route_map *route_map = |
12318 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12319 | |
12320 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12321 | protocol = ZEBRA_ROUTE_OSPF; | |
12322 | else | |
12323 | protocol = ZEBRA_ROUTE_TABLE; | |
12324 | ||
12325 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12326 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
12327 | changed = |
12328 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12329 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 12330 | } |
12331 | ||
12332 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
12333 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
12334 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
12335 | "Redistribute information from another routing protocol\n" | |
12336 | "Open Shortest Path First (OSPFv2)\n" | |
12337 | "Non-main Kernel Routing Table\n" | |
12338 | "Instance ID/Table ID\n" | |
12339 | "Route map reference\n" | |
12340 | "Pointer to route-map entries\n") | |
596c17ba | 12341 | |
7c8ff89e DS |
12342 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
12343 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 12344 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
12345 | "Redistribute information from another routing protocol\n" |
12346 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12347 | "Non-main Kernel Routing Table\n" |
12348 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12349 | "Metric for redistributed routes\n" |
12350 | "Default metric\n") | |
12351 | { | |
d62a17ae | 12352 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12353 | int idx_ospf_table = 1; | |
12354 | int idx_number = 2; | |
12355 | int idx_number_2 = 4; | |
d7c0a89a | 12356 | uint32_t metric; |
d62a17ae | 12357 | struct bgp_redist *red; |
d7c0a89a | 12358 | unsigned short instance; |
d62a17ae | 12359 | int protocol; |
e923dd62 | 12360 | bool changed; |
d62a17ae | 12361 | |
12362 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12363 | protocol = ZEBRA_ROUTE_OSPF; | |
12364 | else | |
12365 | protocol = ZEBRA_ROUTE_TABLE; | |
12366 | ||
12367 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12368 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
12369 | ||
12370 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 12371 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
12372 | metric); | |
12373 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 12374 | } |
12375 | ||
12376 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
12377 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
12378 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
12379 | "Redistribute information from another routing protocol\n" | |
12380 | "Open Shortest Path First (OSPFv2)\n" | |
12381 | "Non-main Kernel Routing Table\n" | |
12382 | "Instance ID/Table ID\n" | |
12383 | "Metric for redistributed routes\n" | |
12384 | "Default metric\n") | |
596c17ba | 12385 | |
7c8ff89e DS |
12386 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
12387 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 12388 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
12389 | "Redistribute information from another routing protocol\n" |
12390 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12391 | "Non-main Kernel Routing Table\n" |
12392 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12393 | "Route map reference\n" |
12394 | "Pointer to route-map entries\n" | |
12395 | "Metric for redistributed routes\n" | |
12396 | "Default metric\n") | |
12397 | { | |
d62a17ae | 12398 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12399 | int idx_ospf_table = 1; | |
12400 | int idx_number = 2; | |
12401 | int idx_word = 4; | |
12402 | int idx_number_2 = 6; | |
d7c0a89a | 12403 | uint32_t metric; |
d62a17ae | 12404 | struct bgp_redist *red; |
d7c0a89a | 12405 | unsigned short instance; |
d62a17ae | 12406 | int protocol; |
e923dd62 | 12407 | bool changed; |
1de27621 DA |
12408 | struct route_map *route_map = |
12409 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12410 | |
12411 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12412 | protocol = ZEBRA_ROUTE_OSPF; | |
12413 | else | |
12414 | protocol = ZEBRA_ROUTE_TABLE; | |
12415 | ||
12416 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12417 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
12418 | ||
12419 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
12420 | changed = |
12421 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12422 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
12423 | metric); | |
12424 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 12425 | } |
12426 | ||
12427 | ALIAS_HIDDEN( | |
12428 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
12429 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
12430 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
12431 | "Redistribute information from another routing protocol\n" | |
12432 | "Open Shortest Path First (OSPFv2)\n" | |
12433 | "Non-main Kernel Routing Table\n" | |
12434 | "Instance ID/Table ID\n" | |
12435 | "Route map reference\n" | |
12436 | "Pointer to route-map entries\n" | |
12437 | "Metric for redistributed routes\n" | |
12438 | "Default metric\n") | |
596c17ba | 12439 | |
7c8ff89e DS |
12440 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
12441 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 12442 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
12443 | "Redistribute information from another routing protocol\n" |
12444 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12445 | "Non-main Kernel Routing Table\n" |
12446 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12447 | "Metric for redistributed routes\n" |
12448 | "Default metric\n" | |
12449 | "Route map reference\n" | |
12450 | "Pointer to route-map entries\n") | |
12451 | { | |
d62a17ae | 12452 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12453 | int idx_ospf_table = 1; | |
12454 | int idx_number = 2; | |
12455 | int idx_number_2 = 4; | |
12456 | int idx_word = 6; | |
d7c0a89a | 12457 | uint32_t metric; |
d62a17ae | 12458 | struct bgp_redist *red; |
d7c0a89a | 12459 | unsigned short instance; |
d62a17ae | 12460 | int protocol; |
e923dd62 | 12461 | bool changed; |
1de27621 DA |
12462 | struct route_map *route_map = |
12463 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12464 | |
12465 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12466 | protocol = ZEBRA_ROUTE_OSPF; | |
12467 | else | |
12468 | protocol = ZEBRA_ROUTE_TABLE; | |
12469 | ||
12470 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12471 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
12472 | ||
12473 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 12474 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
12475 | metric); | |
1de27621 DA |
12476 | changed |= |
12477 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12478 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 12479 | } |
12480 | ||
12481 | ALIAS_HIDDEN( | |
12482 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
12483 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
12484 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
12485 | "Redistribute information from another routing protocol\n" | |
12486 | "Open Shortest Path First (OSPFv2)\n" | |
12487 | "Non-main Kernel Routing Table\n" | |
12488 | "Instance ID/Table ID\n" | |
12489 | "Metric for redistributed routes\n" | |
12490 | "Default metric\n" | |
12491 | "Route map reference\n" | |
12492 | "Pointer to route-map entries\n") | |
596c17ba | 12493 | |
7c8ff89e DS |
12494 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
12495 | no_bgp_redistribute_ipv4_ospf_cmd, | |
e27957c0 | 12496 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
7c8ff89e DS |
12497 | NO_STR |
12498 | "Redistribute information from another routing protocol\n" | |
12499 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 12500 | "Non-main Kernel Routing Table\n" |
31500417 DW |
12501 | "Instance ID/Table ID\n" |
12502 | "Metric for redistributed routes\n" | |
12503 | "Default metric\n" | |
12504 | "Route map reference\n" | |
12505 | "Pointer to route-map entries\n") | |
7c8ff89e | 12506 | { |
d62a17ae | 12507 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12508 | int idx_ospf_table = 2; | |
12509 | int idx_number = 3; | |
d7c0a89a | 12510 | unsigned short instance; |
d62a17ae | 12511 | int protocol; |
12512 | ||
12513 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12514 | protocol = ZEBRA_ROUTE_OSPF; | |
12515 | else | |
12516 | protocol = ZEBRA_ROUTE_TABLE; | |
12517 | ||
12518 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12519 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
12520 | } | |
12521 | ||
12522 | ALIAS_HIDDEN( | |
12523 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
e27957c0 | 12524 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 12525 | NO_STR |
12526 | "Redistribute information from another routing protocol\n" | |
12527 | "Open Shortest Path First (OSPFv2)\n" | |
12528 | "Non-main Kernel Routing Table\n" | |
12529 | "Instance ID/Table ID\n" | |
12530 | "Metric for redistributed routes\n" | |
12531 | "Default metric\n" | |
12532 | "Route map reference\n" | |
12533 | "Pointer to route-map entries\n") | |
596c17ba | 12534 | |
718e3744 | 12535 | DEFUN (no_bgp_redistribute_ipv4, |
12536 | no_bgp_redistribute_ipv4_cmd, | |
e27957c0 | 12537 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", |
718e3744 | 12538 | NO_STR |
12539 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 12540 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
12541 | "Metric for redistributed routes\n" |
12542 | "Default metric\n" | |
12543 | "Route map reference\n" | |
12544 | "Pointer to route-map entries\n") | |
718e3744 | 12545 | { |
d62a17ae | 12546 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12547 | int idx_protocol = 2; | |
12548 | int type; | |
12549 | ||
12550 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
12551 | if (type < 0) { | |
12552 | vty_out(vty, "%% Invalid route type\n"); | |
12553 | return CMD_WARNING_CONFIG_FAILED; | |
12554 | } | |
12555 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
12556 | } | |
12557 | ||
12558 | ALIAS_HIDDEN( | |
12559 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
12560 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
e27957c0 | 12561 | " [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 12562 | NO_STR |
12563 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
12564 | "Metric for redistributed routes\n" | |
12565 | "Default metric\n" | |
12566 | "Route map reference\n" | |
12567 | "Pointer to route-map entries\n") | |
596c17ba | 12568 | |
718e3744 | 12569 | DEFUN (bgp_redistribute_ipv6, |
12570 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 12571 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 12572 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12573 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 12574 | { |
d62a17ae | 12575 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12576 | int idx_protocol = 1; | |
12577 | int type; | |
718e3744 | 12578 | |
d62a17ae | 12579 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
12580 | if (type < 0) { | |
12581 | vty_out(vty, "%% Invalid route type\n"); | |
12582 | return CMD_WARNING_CONFIG_FAILED; | |
12583 | } | |
718e3744 | 12584 | |
d62a17ae | 12585 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 12586 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, false); |
718e3744 | 12587 | } |
12588 | ||
12589 | DEFUN (bgp_redistribute_ipv6_rmap, | |
12590 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 12591 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 12592 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12593 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12594 | "Route map reference\n" |
12595 | "Pointer to route-map entries\n") | |
12596 | { | |
d62a17ae | 12597 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12598 | int idx_protocol = 1; | |
12599 | int idx_word = 3; | |
12600 | int type; | |
12601 | struct bgp_redist *red; | |
e923dd62 | 12602 | bool changed; |
1de27621 DA |
12603 | struct route_map *route_map = |
12604 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
718e3744 | 12605 | |
d62a17ae | 12606 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
12607 | if (type < 0) { | |
12608 | vty_out(vty, "%% Invalid route type\n"); | |
12609 | return CMD_WARNING_CONFIG_FAILED; | |
12610 | } | |
718e3744 | 12611 | |
d62a17ae | 12612 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
12613 | changed = |
12614 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12615 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 12616 | } |
12617 | ||
12618 | DEFUN (bgp_redistribute_ipv6_metric, | |
12619 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 12620 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 12621 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12622 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12623 | "Metric for redistributed routes\n" |
12624 | "Default metric\n") | |
12625 | { | |
d62a17ae | 12626 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12627 | int idx_protocol = 1; | |
12628 | int idx_number = 3; | |
12629 | int type; | |
d7c0a89a | 12630 | uint32_t metric; |
d62a17ae | 12631 | struct bgp_redist *red; |
e923dd62 | 12632 | bool changed; |
d62a17ae | 12633 | |
12634 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
12635 | if (type < 0) { | |
12636 | vty_out(vty, "%% Invalid route type\n"); | |
12637 | return CMD_WARNING_CONFIG_FAILED; | |
12638 | } | |
12639 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 12640 | |
d62a17ae | 12641 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 12642 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); |
12643 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 12644 | } |
12645 | ||
12646 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
12647 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 12648 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 12649 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12650 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12651 | "Route map reference\n" |
12652 | "Pointer to route-map entries\n" | |
12653 | "Metric for redistributed routes\n" | |
12654 | "Default metric\n") | |
12655 | { | |
d62a17ae | 12656 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12657 | int idx_protocol = 1; | |
12658 | int idx_word = 3; | |
12659 | int idx_number = 5; | |
12660 | int type; | |
d7c0a89a | 12661 | uint32_t metric; |
d62a17ae | 12662 | struct bgp_redist *red; |
e923dd62 | 12663 | bool changed; |
1de27621 DA |
12664 | struct route_map *route_map = |
12665 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12666 | |
12667 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
12668 | if (type < 0) { | |
12669 | vty_out(vty, "%% Invalid route type\n"); | |
12670 | return CMD_WARNING_CONFIG_FAILED; | |
12671 | } | |
12672 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 12673 | |
d62a17ae | 12674 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
12675 | changed = |
12676 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12677 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, |
12678 | metric); | |
12679 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 12680 | } |
12681 | ||
12682 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
12683 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 12684 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 12685 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12686 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12687 | "Metric for redistributed routes\n" |
12688 | "Default metric\n" | |
12689 | "Route map reference\n" | |
12690 | "Pointer to route-map entries\n") | |
12691 | { | |
d62a17ae | 12692 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12693 | int idx_protocol = 1; | |
12694 | int idx_number = 3; | |
12695 | int idx_word = 5; | |
12696 | int type; | |
d7c0a89a | 12697 | uint32_t metric; |
d62a17ae | 12698 | struct bgp_redist *red; |
e923dd62 | 12699 | bool changed; |
1de27621 DA |
12700 | struct route_map *route_map = |
12701 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12702 | |
12703 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
12704 | if (type < 0) { | |
12705 | vty_out(vty, "%% Invalid route type\n"); | |
12706 | return CMD_WARNING_CONFIG_FAILED; | |
12707 | } | |
12708 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 12709 | |
d62a17ae | 12710 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 12711 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, |
12712 | metric); | |
1de27621 DA |
12713 | changed |= |
12714 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12715 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 12716 | } |
12717 | ||
12718 | DEFUN (no_bgp_redistribute_ipv6, | |
12719 | no_bgp_redistribute_ipv6_cmd, | |
e27957c0 | 12720 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", |
718e3744 | 12721 | NO_STR |
12722 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 12723 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
12724 | "Metric for redistributed routes\n" |
12725 | "Default metric\n" | |
12726 | "Route map reference\n" | |
12727 | "Pointer to route-map entries\n") | |
718e3744 | 12728 | { |
d62a17ae | 12729 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12730 | int idx_protocol = 2; | |
12731 | int type; | |
718e3744 | 12732 | |
d62a17ae | 12733 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
12734 | if (type < 0) { | |
12735 | vty_out(vty, "%% Invalid route type\n"); | |
12736 | return CMD_WARNING_CONFIG_FAILED; | |
12737 | } | |
718e3744 | 12738 | |
d62a17ae | 12739 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
12740 | } | |
12741 | ||
2b791107 | 12742 | void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, afi_t afi, |
60466a63 | 12743 | safi_t safi) |
d62a17ae | 12744 | { |
12745 | int i; | |
12746 | ||
12747 | /* Unicast redistribution only. */ | |
12748 | if (safi != SAFI_UNICAST) | |
2b791107 | 12749 | return; |
d62a17ae | 12750 | |
12751 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
12752 | /* Redistribute BGP does not make sense. */ | |
12753 | if (i != ZEBRA_ROUTE_BGP) { | |
12754 | struct list *red_list; | |
12755 | struct listnode *node; | |
12756 | struct bgp_redist *red; | |
12757 | ||
12758 | red_list = bgp->redist[afi][i]; | |
12759 | if (!red_list) | |
12760 | continue; | |
12761 | ||
12762 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 12763 | /* "redistribute" configuration. */ |
12764 | vty_out(vty, " redistribute %s", | |
12765 | zebra_route_string(i)); | |
12766 | if (red->instance) | |
12767 | vty_out(vty, " %d", red->instance); | |
12768 | if (red->redist_metric_flag) | |
12769 | vty_out(vty, " metric %u", | |
12770 | red->redist_metric); | |
12771 | if (red->rmap.name) | |
12772 | vty_out(vty, " route-map %s", | |
12773 | red->rmap.name); | |
12774 | vty_out(vty, "\n"); | |
12775 | } | |
12776 | } | |
12777 | } | |
718e3744 | 12778 | } |
6b0655a2 | 12779 | |
b9c7bc5a PZ |
12780 | /* This is part of the address-family block (unicast only) */ |
12781 | void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, | |
ddb5b488 PZ |
12782 | afi_t afi) |
12783 | { | |
b9c7bc5a | 12784 | int indent = 2; |
ddb5b488 | 12785 | |
8a066a70 PG |
12786 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
12787 | if (listcount(bgp->vpn_policy[afi].import_vrf)) | |
12788 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", | |
12789 | bgp->vpn_policy[afi] | |
bb4f6190 | 12790 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
12791 | else |
12792 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
12793 | bgp->vpn_policy[afi] | |
12794 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
12795 | } | |
12a844a5 DS |
12796 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
12797 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
12798 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
12799 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
12800 | return; | |
12801 | ||
e70e9f8e PZ |
12802 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
12803 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
12804 | ||
12805 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
12806 | ||
12807 | } else { | |
12808 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
12809 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
12810 | bgp->vpn_policy[afi].tovpn_label); | |
12811 | } | |
ddb5b488 PZ |
12812 | } |
12813 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
12814 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
12815 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 12816 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
12817 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
12818 | sizeof(buf))); | |
12819 | } | |
12820 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
12821 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
12822 | ||
12823 | char buf[PREFIX_STRLEN]; | |
12824 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
12825 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
12826 | sizeof(buf))) { | |
12827 | ||
b9c7bc5a PZ |
12828 | vty_out(vty, "%*snexthop vpn export %s\n", |
12829 | indent, "", buf); | |
ddb5b488 PZ |
12830 | } |
12831 | } | |
12832 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
12833 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
12834 | && ecommunity_cmp( | |
12835 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
12836 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
12837 | ||
12838 | char *b = ecommunity_ecom2str( | |
12839 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
12840 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12841 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
12842 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12843 | } else { | |
12844 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
12845 | char *b = ecommunity_ecom2str( | |
12846 | bgp->vpn_policy[afi] | |
12847 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
12848 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12849 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12850 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
12851 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12852 | } | |
12853 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
12854 | char *b = ecommunity_ecom2str( | |
12855 | bgp->vpn_policy[afi] | |
12856 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
12857 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12858 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12859 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
12860 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12861 | } | |
12862 | } | |
bb4f6190 DS |
12863 | |
12864 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 12865 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
12866 | bgp->vpn_policy[afi] |
12867 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 12868 | |
301ad80a PG |
12869 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
12870 | char *b = ecommunity_ecom2str( | |
12871 | bgp->vpn_policy[afi] | |
12872 | .import_redirect_rtlist, | |
12873 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12874 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 12875 | |
301ad80a PG |
12876 | vty_out(vty, "%*srt redirect import %s\n", indent, "", b); |
12877 | XFREE(MTYPE_ECOMMUNITY_STR, b); | |
12878 | } | |
ddb5b488 PZ |
12879 | } |
12880 | ||
12881 | ||
718e3744 | 12882 | /* BGP node structure. */ |
d62a17ae | 12883 | static struct cmd_node bgp_node = { |
9d303b37 | 12884 | BGP_NODE, "%s(config-router)# ", 1, |
718e3744 | 12885 | }; |
12886 | ||
d62a17ae | 12887 | static struct cmd_node bgp_ipv4_unicast_node = { |
9d303b37 | 12888 | BGP_IPV4_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12889 | }; |
12890 | ||
d62a17ae | 12891 | static struct cmd_node bgp_ipv4_multicast_node = { |
9d303b37 | 12892 | BGP_IPV4M_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12893 | }; |
12894 | ||
d62a17ae | 12895 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
9d303b37 | 12896 | BGP_IPV4L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
12897 | }; |
12898 | ||
d62a17ae | 12899 | static struct cmd_node bgp_ipv6_unicast_node = { |
9d303b37 | 12900 | BGP_IPV6_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12901 | }; |
12902 | ||
d62a17ae | 12903 | static struct cmd_node bgp_ipv6_multicast_node = { |
9d303b37 | 12904 | BGP_IPV6M_NODE, "%s(config-router-af)# ", 1, |
25ffbdc1 | 12905 | }; |
12906 | ||
d62a17ae | 12907 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
9d303b37 | 12908 | BGP_IPV6L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
12909 | }; |
12910 | ||
d62a17ae | 12911 | static struct cmd_node bgp_vpnv4_node = {BGP_VPNV4_NODE, |
12912 | "%s(config-router-af)# ", 1}; | |
6b0655a2 | 12913 | |
d62a17ae | 12914 | static struct cmd_node bgp_vpnv6_node = {BGP_VPNV6_NODE, |
12915 | "%s(config-router-af-vpnv6)# ", 1}; | |
8ecd3266 | 12916 | |
d62a17ae | 12917 | static struct cmd_node bgp_evpn_node = {BGP_EVPN_NODE, |
12918 | "%s(config-router-evpn)# ", 1}; | |
4e0b7b6d | 12919 | |
d62a17ae | 12920 | static struct cmd_node bgp_evpn_vni_node = {BGP_EVPN_VNI_NODE, |
12921 | "%s(config-router-af-vni)# ", 1}; | |
90e60aa7 | 12922 | |
7c40bf39 | 12923 | static struct cmd_node bgp_flowspecv4_node = {BGP_FLOWSPECV4_NODE, |
12924 | "%s(config-router-af)# ", 1}; | |
12925 | ||
12926 | static struct cmd_node bgp_flowspecv6_node = {BGP_FLOWSPECV6_NODE, | |
12927 | "%s(config-router-af-vpnv6)# ", 1}; | |
12928 | ||
d62a17ae | 12929 | static void community_list_vty(void); |
1f8ae70b | 12930 | |
d62a17ae | 12931 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 12932 | { |
d62a17ae | 12933 | struct bgp *bgp; |
12934 | struct peer *peer; | |
d62a17ae | 12935 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 12936 | |
d62a17ae | 12937 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
12938 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
12939 | /* only provide suggestions on the appropriate input | |
12940 | * token type, | |
12941 | * they'll otherwise show up multiple times */ | |
12942 | enum cmd_token_type match_type; | |
12943 | char *name = peer->host; | |
d48ed3e0 | 12944 | |
d62a17ae | 12945 | if (peer->conf_if) { |
12946 | match_type = VARIABLE_TKN; | |
12947 | name = peer->conf_if; | |
12948 | } else if (strchr(peer->host, ':')) | |
12949 | match_type = IPV6_TKN; | |
12950 | else | |
12951 | match_type = IPV4_TKN; | |
d48ed3e0 | 12952 | |
d62a17ae | 12953 | if (token->type != match_type) |
12954 | continue; | |
d48ed3e0 | 12955 | |
d62a17ae | 12956 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
12957 | } | |
d62a17ae | 12958 | } |
b8a815e5 DL |
12959 | } |
12960 | ||
12961 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 12962 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
12963 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 12964 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 12965 | {.completions = NULL}}; |
12966 | ||
47a306a0 DS |
12967 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
12968 | { | |
12969 | struct bgp *bgp; | |
12970 | struct peer_group *group; | |
12971 | struct listnode *lnbgp, *lnpeer; | |
12972 | ||
12973 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
12974 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
12975 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
12976 | group->name)); | |
12977 | } | |
12978 | } | |
12979 | ||
12980 | static const struct cmd_variable_handler bgp_var_peergroup[] = { | |
12981 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
12982 | {.completions = NULL} }; | |
12983 | ||
d62a17ae | 12984 | void bgp_vty_init(void) |
12985 | { | |
12986 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 12987 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 12988 | |
12989 | /* Install bgp top node. */ | |
12990 | install_node(&bgp_node, bgp_config_write); | |
12991 | install_node(&bgp_ipv4_unicast_node, NULL); | |
12992 | install_node(&bgp_ipv4_multicast_node, NULL); | |
12993 | install_node(&bgp_ipv4_labeled_unicast_node, NULL); | |
12994 | install_node(&bgp_ipv6_unicast_node, NULL); | |
12995 | install_node(&bgp_ipv6_multicast_node, NULL); | |
12996 | install_node(&bgp_ipv6_labeled_unicast_node, NULL); | |
12997 | install_node(&bgp_vpnv4_node, NULL); | |
12998 | install_node(&bgp_vpnv6_node, NULL); | |
12999 | install_node(&bgp_evpn_node, NULL); | |
13000 | install_node(&bgp_evpn_vni_node, NULL); | |
7c40bf39 | 13001 | install_node(&bgp_flowspecv4_node, NULL); |
13002 | install_node(&bgp_flowspecv6_node, NULL); | |
d62a17ae | 13003 | |
13004 | /* Install default VTY commands to new nodes. */ | |
13005 | install_default(BGP_NODE); | |
13006 | install_default(BGP_IPV4_NODE); | |
13007 | install_default(BGP_IPV4M_NODE); | |
13008 | install_default(BGP_IPV4L_NODE); | |
13009 | install_default(BGP_IPV6_NODE); | |
13010 | install_default(BGP_IPV6M_NODE); | |
13011 | install_default(BGP_IPV6L_NODE); | |
13012 | install_default(BGP_VPNV4_NODE); | |
13013 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 13014 | install_default(BGP_FLOWSPECV4_NODE); |
13015 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 13016 | install_default(BGP_EVPN_NODE); |
13017 | install_default(BGP_EVPN_VNI_NODE); | |
13018 | ||
8029b216 AK |
13019 | /* "bgp local-mac" hidden commands. */ |
13020 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
13021 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
13022 | ||
d62a17ae | 13023 | /* bgp route-map delay-timer commands. */ |
13024 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
13025 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
13026 | ||
13027 | /* Dummy commands (Currently not supported) */ | |
13028 | install_element(BGP_NODE, &no_synchronization_cmd); | |
13029 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
13030 | ||
13031 | /* "router bgp" commands. */ | |
13032 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
13033 | ||
13034 | /* "no router bgp" commands. */ | |
13035 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
13036 | ||
13037 | /* "bgp router-id" commands. */ | |
13038 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
13039 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
13040 | ||
13041 | /* "bgp cluster-id" commands. */ | |
13042 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
13043 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
13044 | ||
13045 | /* "bgp confederation" commands. */ | |
13046 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
13047 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
13048 | ||
13049 | /* "bgp confederation peers" commands. */ | |
13050 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
13051 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
13052 | ||
13053 | /* bgp max-med command */ | |
13054 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
13055 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
13056 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
13057 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
13058 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
13059 | ||
13060 | /* bgp disable-ebgp-connected-nh-check */ | |
13061 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
13062 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
13063 | ||
13064 | /* bgp update-delay command */ | |
13065 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
13066 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
13067 | install_element(BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
13068 | ||
13069 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
13070 | install_element(BGP_NODE, &no_bgp_wpkt_quanta_cmd); | |
555e09d4 QY |
13071 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
13072 | install_element(BGP_NODE, &no_bgp_rpkt_quanta_cmd); | |
d62a17ae | 13073 | |
13074 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
13075 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
13076 | ||
13077 | /* "maximum-paths" commands. */ | |
13078 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
13079 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
13080 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
13081 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
13082 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
13083 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
13084 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
13085 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
13086 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
13087 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
13088 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
13089 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
13090 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
13091 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
13092 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
13093 | ||
13094 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); | |
13095 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
13096 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
13097 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
13098 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
13099 | ||
13100 | /* "timers bgp" commands. */ | |
13101 | install_element(BGP_NODE, &bgp_timers_cmd); | |
13102 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
13103 | ||
13104 | /* route-map delay-timer commands - per instance for backwards compat. | |
13105 | */ | |
13106 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
13107 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
13108 | ||
13109 | /* "bgp client-to-client reflection" commands */ | |
13110 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
13111 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
13112 | ||
13113 | /* "bgp always-compare-med" commands */ | |
13114 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
13115 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
13116 | ||
9dac9fc8 DA |
13117 | /* bgp ebgp-requires-policy */ |
13118 | install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd); | |
13119 | install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd); | |
13120 | ||
d62a17ae | 13121 | /* "bgp deterministic-med" commands */ |
13122 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
13123 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
13124 | ||
13125 | /* "bgp graceful-restart" commands */ | |
13126 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); | |
13127 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
13128 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); | |
13129 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
13130 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
13131 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
13132 | ||
13133 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); | |
13134 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
13135 | ||
7f323236 DW |
13136 | /* "bgp graceful-shutdown" commands */ |
13137 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
13138 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
13139 | ||
d62a17ae | 13140 | /* "bgp fast-external-failover" commands */ |
13141 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
13142 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
13143 | ||
d62a17ae | 13144 | /* "bgp bestpath compare-routerid" commands */ |
13145 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
13146 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
13147 | ||
13148 | /* "bgp bestpath as-path ignore" commands */ | |
13149 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
13150 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
13151 | ||
13152 | /* "bgp bestpath as-path confed" commands */ | |
13153 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
13154 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
13155 | ||
13156 | /* "bgp bestpath as-path multipath-relax" commands */ | |
13157 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
13158 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
13159 | ||
13160 | /* "bgp log-neighbor-changes" commands */ | |
13161 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
13162 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
13163 | ||
13164 | /* "bgp bestpath med" commands */ | |
13165 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
13166 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
13167 | ||
13168 | /* "no bgp default ipv4-unicast" commands. */ | |
13169 | install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
13170 | install_element(BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
13171 | ||
13172 | /* "bgp network import-check" commands. */ | |
13173 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
13174 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
13175 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
13176 | ||
13177 | /* "bgp default local-preference" commands. */ | |
13178 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
13179 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
13180 | ||
13181 | /* bgp default show-hostname */ | |
13182 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
13183 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
13184 | ||
13185 | /* "bgp default subgroup-pkt-queue-max" commands. */ | |
13186 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
13187 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
13188 | ||
13189 | /* bgp ibgp-allow-policy-mods command */ | |
13190 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
13191 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
13192 | ||
13193 | /* "bgp listen limit" commands. */ | |
13194 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
13195 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
13196 | ||
13197 | /* "bgp listen range" commands. */ | |
13198 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
13199 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
13200 | ||
8175f54a | 13201 | /* "bgp default shutdown" command */ |
f26845f9 QY |
13202 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
13203 | ||
d62a17ae | 13204 | /* "neighbor remote-as" commands. */ |
13205 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
13206 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
13207 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
13208 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
13209 | install_element(BGP_NODE, | |
13210 | &neighbor_interface_v6only_config_remote_as_cmd); | |
13211 | install_element(BGP_NODE, &no_neighbor_cmd); | |
13212 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
13213 | ||
13214 | /* "neighbor peer-group" commands. */ | |
13215 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
13216 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
13217 | install_element(BGP_NODE, | |
13218 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
13219 | ||
13220 | /* "neighbor local-as" commands. */ | |
13221 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
13222 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
13223 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
13224 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
13225 | ||
13226 | /* "neighbor solo" commands. */ | |
13227 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
13228 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
13229 | ||
13230 | /* "neighbor password" commands. */ | |
13231 | install_element(BGP_NODE, &neighbor_password_cmd); | |
13232 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
13233 | ||
13234 | /* "neighbor activate" commands. */ | |
13235 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
13236 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
13237 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
13238 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
13239 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
13240 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
13241 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
13242 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
13243 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 13244 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
13245 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 13246 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
13247 | ||
13248 | /* "no neighbor activate" commands. */ | |
13249 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
13250 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
13251 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
13252 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
13253 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
13254 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
13255 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
13256 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
13257 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 13258 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
13259 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 13260 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
13261 | ||
13262 | /* "neighbor peer-group" set commands. */ | |
13263 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
13264 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13265 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13266 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13267 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13268 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13269 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13270 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 13271 | install_element(BGP_FLOWSPECV4_NODE, |
13272 | &neighbor_set_peer_group_hidden_cmd); | |
13273 | install_element(BGP_FLOWSPECV6_NODE, | |
13274 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 13275 | |
13276 | /* "no neighbor peer-group unset" commands. */ | |
13277 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
13278 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13279 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13280 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13281 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13282 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13283 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13284 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 13285 | install_element(BGP_FLOWSPECV4_NODE, |
13286 | &no_neighbor_set_peer_group_hidden_cmd); | |
13287 | install_element(BGP_FLOWSPECV6_NODE, | |
13288 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 13289 | |
13290 | /* "neighbor softreconfiguration inbound" commands.*/ | |
13291 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
13292 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
13293 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
13294 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13295 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
13296 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13297 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
13298 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13299 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
13300 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13301 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
13302 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13303 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
13304 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13305 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
13306 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13307 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
13308 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 13309 | install_element(BGP_FLOWSPECV4_NODE, |
13310 | &neighbor_soft_reconfiguration_cmd); | |
13311 | install_element(BGP_FLOWSPECV4_NODE, | |
13312 | &no_neighbor_soft_reconfiguration_cmd); | |
13313 | install_element(BGP_FLOWSPECV6_NODE, | |
13314 | &neighbor_soft_reconfiguration_cmd); | |
13315 | install_element(BGP_FLOWSPECV6_NODE, | |
13316 | &no_neighbor_soft_reconfiguration_cmd); | |
616c6ee8 PG |
13317 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); |
13318 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 13319 | |
13320 | /* "neighbor attribute-unchanged" commands. */ | |
13321 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
13322 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
13323 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
13324 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
13325 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
13326 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
13327 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
13328 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
13329 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
13330 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
13331 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
13332 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
13333 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
13334 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
13335 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
13336 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
13337 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
13338 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
13339 | ||
13340 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
13341 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
13342 | ||
13343 | /* "nexthop-local unchanged" commands */ | |
13344 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
13345 | install_element(BGP_IPV6_NODE, | |
13346 | &no_neighbor_nexthop_local_unchanged_cmd); | |
13347 | ||
13348 | /* "neighbor next-hop-self" commands. */ | |
13349 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
13350 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
13351 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
13352 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
13353 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
13354 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
13355 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
13356 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
13357 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
13358 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
13359 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
13360 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
13361 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
13362 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
13363 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
13364 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
13365 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
13366 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
13367 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
13368 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 13369 | |
13370 | /* "neighbor next-hop-self force" commands. */ | |
13371 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
13372 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
1bc4e531 DA |
13373 | install_element(BGP_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
13374 | install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 13375 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
13376 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
13377 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
13378 | install_element(BGP_IPV4_NODE, | |
13379 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 13380 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); |
13381 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
13382 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
13383 | install_element(BGP_IPV4M_NODE, | |
13384 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 13385 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); |
13386 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
13387 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
13388 | install_element(BGP_IPV4L_NODE, | |
13389 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 13390 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); |
13391 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
13392 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
13393 | install_element(BGP_IPV6_NODE, | |
13394 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 13395 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); |
13396 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
13397 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
13398 | install_element(BGP_IPV6M_NODE, | |
13399 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 13400 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); |
13401 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
13402 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
13403 | install_element(BGP_IPV6L_NODE, | |
13404 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 13405 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); |
13406 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
13407 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
13408 | install_element(BGP_VPNV4_NODE, | |
13409 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 13410 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
13411 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
13412 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
13413 | install_element(BGP_VPNV6_NODE, | |
13414 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 13415 | |
13416 | /* "neighbor as-override" commands. */ | |
13417 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
13418 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
13419 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
13420 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
13421 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
13422 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
13423 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
13424 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
13425 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
13426 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
13427 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
13428 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
13429 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
13430 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
13431 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
13432 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
13433 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
13434 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
13435 | ||
13436 | /* "neighbor remove-private-AS" commands. */ | |
13437 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
13438 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
13439 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
13440 | install_element(BGP_NODE, | |
13441 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
13442 | install_element(BGP_NODE, | |
13443 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
13444 | install_element(BGP_NODE, | |
13445 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
13446 | install_element(BGP_NODE, | |
13447 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
13448 | install_element( | |
13449 | BGP_NODE, | |
13450 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
13451 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
13452 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
13453 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
13454 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13455 | install_element(BGP_IPV4_NODE, | |
13456 | &neighbor_remove_private_as_replace_as_cmd); | |
13457 | install_element(BGP_IPV4_NODE, | |
13458 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13459 | install_element(BGP_IPV4_NODE, | |
13460 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13461 | install_element(BGP_IPV4_NODE, | |
13462 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13463 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
13464 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
13465 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
13466 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13467 | install_element(BGP_IPV4M_NODE, | |
13468 | &neighbor_remove_private_as_replace_as_cmd); | |
13469 | install_element(BGP_IPV4M_NODE, | |
13470 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13471 | install_element(BGP_IPV4M_NODE, | |
13472 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13473 | install_element(BGP_IPV4M_NODE, | |
13474 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13475 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
13476 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
13477 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
13478 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13479 | install_element(BGP_IPV4L_NODE, | |
13480 | &neighbor_remove_private_as_replace_as_cmd); | |
13481 | install_element(BGP_IPV4L_NODE, | |
13482 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13483 | install_element(BGP_IPV4L_NODE, | |
13484 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13485 | install_element(BGP_IPV4L_NODE, | |
13486 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13487 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
13488 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
13489 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
13490 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13491 | install_element(BGP_IPV6_NODE, | |
13492 | &neighbor_remove_private_as_replace_as_cmd); | |
13493 | install_element(BGP_IPV6_NODE, | |
13494 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13495 | install_element(BGP_IPV6_NODE, | |
13496 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13497 | install_element(BGP_IPV6_NODE, | |
13498 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13499 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
13500 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
13501 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
13502 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13503 | install_element(BGP_IPV6M_NODE, | |
13504 | &neighbor_remove_private_as_replace_as_cmd); | |
13505 | install_element(BGP_IPV6M_NODE, | |
13506 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13507 | install_element(BGP_IPV6M_NODE, | |
13508 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13509 | install_element(BGP_IPV6M_NODE, | |
13510 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13511 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
13512 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
13513 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
13514 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13515 | install_element(BGP_IPV6L_NODE, | |
13516 | &neighbor_remove_private_as_replace_as_cmd); | |
13517 | install_element(BGP_IPV6L_NODE, | |
13518 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13519 | install_element(BGP_IPV6L_NODE, | |
13520 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13521 | install_element(BGP_IPV6L_NODE, | |
13522 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13523 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
13524 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
13525 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
13526 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13527 | install_element(BGP_VPNV4_NODE, | |
13528 | &neighbor_remove_private_as_replace_as_cmd); | |
13529 | install_element(BGP_VPNV4_NODE, | |
13530 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13531 | install_element(BGP_VPNV4_NODE, | |
13532 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13533 | install_element(BGP_VPNV4_NODE, | |
13534 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13535 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
13536 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
13537 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
13538 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13539 | install_element(BGP_VPNV6_NODE, | |
13540 | &neighbor_remove_private_as_replace_as_cmd); | |
13541 | install_element(BGP_VPNV6_NODE, | |
13542 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13543 | install_element(BGP_VPNV6_NODE, | |
13544 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13545 | install_element(BGP_VPNV6_NODE, | |
13546 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13547 | ||
13548 | /* "neighbor send-community" commands.*/ | |
13549 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
13550 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
13551 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
13552 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
13553 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
13554 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
13555 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
13556 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
13557 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
13558 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
13559 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
13560 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
13561 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
13562 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
13563 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
13564 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
13565 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
13566 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
13567 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
13568 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
13569 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
13570 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
13571 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
13572 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
13573 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
13574 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
13575 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
13576 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
13577 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
13578 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
13579 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
13580 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
13581 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
13582 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
13583 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
13584 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
13585 | ||
13586 | /* "neighbor route-reflector" commands.*/ | |
13587 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
13588 | install_element(BGP_NODE, | |
13589 | &no_neighbor_route_reflector_client_hidden_cmd); | |
13590 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
13591 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
13592 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
13593 | install_element(BGP_IPV4M_NODE, | |
13594 | &no_neighbor_route_reflector_client_cmd); | |
13595 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
13596 | install_element(BGP_IPV4L_NODE, | |
13597 | &no_neighbor_route_reflector_client_cmd); | |
13598 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
13599 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
13600 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
13601 | install_element(BGP_IPV6M_NODE, | |
13602 | &no_neighbor_route_reflector_client_cmd); | |
13603 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
13604 | install_element(BGP_IPV6L_NODE, | |
13605 | &no_neighbor_route_reflector_client_cmd); | |
13606 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
13607 | install_element(BGP_VPNV4_NODE, | |
13608 | &no_neighbor_route_reflector_client_cmd); | |
13609 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
13610 | install_element(BGP_VPNV6_NODE, | |
13611 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 13612 | install_element(BGP_FLOWSPECV4_NODE, |
13613 | &neighbor_route_reflector_client_cmd); | |
13614 | install_element(BGP_FLOWSPECV4_NODE, | |
13615 | &no_neighbor_route_reflector_client_cmd); | |
13616 | install_element(BGP_FLOWSPECV6_NODE, | |
13617 | &neighbor_route_reflector_client_cmd); | |
13618 | install_element(BGP_FLOWSPECV6_NODE, | |
13619 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 13620 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
13621 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
13622 | ||
13623 | /* "neighbor route-server" commands.*/ | |
13624 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
13625 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
13626 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
13627 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
13628 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
13629 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
13630 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
13631 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
13632 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
13633 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
13634 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
13635 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
13636 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
13637 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
13638 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
13639 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
13640 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
13641 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
13642 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
13643 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 13644 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
13645 | install_element(BGP_FLOWSPECV4_NODE, | |
13646 | &no_neighbor_route_server_client_cmd); | |
13647 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
13648 | install_element(BGP_FLOWSPECV6_NODE, | |
13649 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 13650 | |
13651 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
13652 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
13653 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
13654 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13655 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13656 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13657 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13658 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13659 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13660 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13661 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13662 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13663 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13664 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13665 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13666 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13667 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13668 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13669 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13670 | ||
13671 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
13672 | install_element(BGP_NODE, | |
13673 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
13674 | install_element(BGP_NODE, | |
13675 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
13676 | install_element(BGP_IPV4_NODE, | |
13677 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13678 | install_element(BGP_IPV4_NODE, | |
13679 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13680 | install_element(BGP_IPV4M_NODE, | |
13681 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13682 | install_element(BGP_IPV4M_NODE, | |
13683 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13684 | install_element(BGP_IPV4L_NODE, | |
13685 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13686 | install_element(BGP_IPV4L_NODE, | |
13687 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13688 | install_element(BGP_IPV6_NODE, | |
13689 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13690 | install_element(BGP_IPV6_NODE, | |
13691 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13692 | install_element(BGP_IPV6M_NODE, | |
13693 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13694 | install_element(BGP_IPV6M_NODE, | |
13695 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13696 | install_element(BGP_IPV6L_NODE, | |
13697 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13698 | install_element(BGP_IPV6L_NODE, | |
13699 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13700 | install_element(BGP_VPNV4_NODE, | |
13701 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13702 | install_element(BGP_VPNV4_NODE, | |
13703 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13704 | install_element(BGP_VPNV6_NODE, | |
13705 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13706 | install_element(BGP_VPNV6_NODE, | |
13707 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13708 | ||
13709 | /* "neighbor passive" commands. */ | |
13710 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
13711 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
13712 | ||
13713 | ||
13714 | /* "neighbor shutdown" commands. */ | |
13715 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
13716 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
13717 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
13718 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
13719 | ||
13720 | /* "neighbor capability extended-nexthop" commands.*/ | |
13721 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
13722 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
13723 | ||
13724 | /* "neighbor capability orf prefix-list" commands.*/ | |
13725 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
13726 | install_element(BGP_NODE, | |
13727 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
13728 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
13729 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13730 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
13731 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13732 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
13733 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13734 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
13735 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13736 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
13737 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13738 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
13739 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13740 | ||
13741 | /* "neighbor capability dynamic" commands.*/ | |
13742 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
13743 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
13744 | ||
13745 | /* "neighbor dont-capability-negotiate" commands. */ | |
13746 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
13747 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
13748 | ||
13749 | /* "neighbor ebgp-multihop" commands. */ | |
13750 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
13751 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
13752 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
13753 | ||
13754 | /* "neighbor disable-connected-check" commands. */ | |
13755 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
13756 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
13757 | ||
47cbc09b PM |
13758 | /* "neighbor enforce-first-as" commands. */ |
13759 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
13760 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
13761 | ||
d62a17ae | 13762 | /* "neighbor description" commands. */ |
13763 | install_element(BGP_NODE, &neighbor_description_cmd); | |
13764 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 13765 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 13766 | |
13767 | /* "neighbor update-source" commands. "*/ | |
13768 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
13769 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
13770 | ||
13771 | /* "neighbor default-originate" commands. */ | |
13772 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
13773 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
13774 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
13775 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
13776 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
13777 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
13778 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
13779 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
13780 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
13781 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
13782 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
13783 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
13784 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
13785 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
13786 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
13787 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
13788 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
13789 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
13790 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
13791 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
13792 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
13793 | ||
13794 | /* "neighbor port" commands. */ | |
13795 | install_element(BGP_NODE, &neighbor_port_cmd); | |
13796 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
13797 | ||
13798 | /* "neighbor weight" commands. */ | |
13799 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
13800 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
13801 | ||
13802 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
13803 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
13804 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
13805 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
13806 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
13807 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
13808 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
13809 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
13810 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
13811 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
13812 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
13813 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
13814 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
13815 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
13816 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
13817 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
13818 | ||
13819 | /* "neighbor override-capability" commands. */ | |
13820 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
13821 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
13822 | ||
13823 | /* "neighbor strict-capability-match" commands. */ | |
13824 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
13825 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
13826 | ||
13827 | /* "neighbor timers" commands. */ | |
13828 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
13829 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
13830 | ||
13831 | /* "neighbor timers connect" commands. */ | |
13832 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
13833 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
13834 | ||
13835 | /* "neighbor advertisement-interval" commands. */ | |
13836 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
13837 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
13838 | ||
13839 | /* "neighbor interface" commands. */ | |
13840 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
13841 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
13842 | ||
13843 | /* "neighbor distribute" commands. */ | |
13844 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
13845 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
13846 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
13847 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
13848 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
13849 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
13850 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
13851 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
13852 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
13853 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
13854 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
13855 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
13856 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
13857 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
13858 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
13859 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
13860 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
13861 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
13862 | ||
13863 | /* "neighbor prefix-list" commands. */ | |
13864 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
13865 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
13866 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
13867 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
13868 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
13869 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
13870 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); | |
13871 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
13872 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
13873 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
13874 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); | |
13875 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
13876 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); | |
13877 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
13878 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); | |
13879 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
13880 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); | |
13881 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
7c40bf39 | 13882 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
13883 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); | |
13884 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); | |
13885 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); | |
d62a17ae | 13886 | |
13887 | /* "neighbor filter-list" commands. */ | |
13888 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
13889 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
13890 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
13891 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
13892 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
13893 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
13894 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
13895 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
13896 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
13897 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
13898 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
13899 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
13900 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
13901 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
13902 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
13903 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
13904 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
13905 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 13906 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
13907 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
13908 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
13909 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 13910 | |
13911 | /* "neighbor route-map" commands. */ | |
13912 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); | |
13913 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
13914 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
13915 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
13916 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
13917 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
13918 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); | |
13919 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
13920 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
13921 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
13922 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); | |
13923 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
13924 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); | |
13925 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
13926 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); | |
13927 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
13928 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); | |
13929 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
7c40bf39 | 13930 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
13931 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); | |
13932 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); | |
13933 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); | |
d37ba549 MK |
13934 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
13935 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); | |
d62a17ae | 13936 | |
13937 | /* "neighbor unsuppress-map" commands. */ | |
13938 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
13939 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
13940 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
13941 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
13942 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
13943 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
13944 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
13945 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
13946 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
13947 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
13948 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
13949 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
13950 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
13951 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
13952 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
13953 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
13954 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
13955 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
13956 | ||
13957 | /* "neighbor maximum-prefix" commands. */ | |
13958 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
13959 | install_element(BGP_NODE, | |
13960 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
13961 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
13962 | install_element(BGP_NODE, | |
13963 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
13964 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
13965 | install_element(BGP_NODE, | |
13966 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
13967 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
13968 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
13969 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13970 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13971 | install_element(BGP_IPV4_NODE, | |
13972 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13973 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13974 | install_element(BGP_IPV4_NODE, | |
13975 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13976 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
13977 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
13978 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13979 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13980 | install_element(BGP_IPV4M_NODE, | |
13981 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13982 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13983 | install_element(BGP_IPV4M_NODE, | |
13984 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13985 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
13986 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
13987 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13988 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13989 | install_element(BGP_IPV4L_NODE, | |
13990 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13991 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13992 | install_element(BGP_IPV4L_NODE, | |
13993 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13994 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
13995 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
13996 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13997 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13998 | install_element(BGP_IPV6_NODE, | |
13999 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
14000 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
14001 | install_element(BGP_IPV6_NODE, | |
14002 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
14003 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
14004 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
14005 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
14006 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
14007 | install_element(BGP_IPV6M_NODE, | |
14008 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
14009 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
14010 | install_element(BGP_IPV6M_NODE, | |
14011 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
14012 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
14013 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
14014 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
14015 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
14016 | install_element(BGP_IPV6L_NODE, | |
14017 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
14018 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
14019 | install_element(BGP_IPV6L_NODE, | |
14020 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
14021 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
14022 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
14023 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
14024 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
14025 | install_element(BGP_VPNV4_NODE, | |
14026 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
14027 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
14028 | install_element(BGP_VPNV4_NODE, | |
14029 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
14030 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
14031 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
14032 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
14033 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
14034 | install_element(BGP_VPNV6_NODE, | |
14035 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
14036 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
14037 | install_element(BGP_VPNV6_NODE, | |
14038 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
14039 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
14040 | ||
14041 | /* "neighbor allowas-in" */ | |
14042 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
14043 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
14044 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
14045 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
14046 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
14047 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
14048 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
14049 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
14050 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
14051 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
14052 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
14053 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
14054 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
14055 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
14056 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
14057 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
14058 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
14059 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
14060 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
14061 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
14062 | ||
14063 | /* address-family commands. */ | |
14064 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
14065 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 14066 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 14067 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
14068 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 14069 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 14070 | |
d62a17ae | 14071 | install_element(BGP_NODE, &address_family_evpn_cmd); |
14072 | ||
14073 | /* "exit-address-family" command. */ | |
14074 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
14075 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
14076 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
14077 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
14078 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
14079 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
14080 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
14081 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 14082 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
14083 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 14084 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
14085 | ||
14086 | /* "clear ip bgp commands" */ | |
14087 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
14088 | ||
14089 | /* clear ip bgp prefix */ | |
14090 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
14091 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
14092 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
14093 | ||
14094 | /* "show [ip] bgp summary" commands. */ | |
14095 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 14096 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 14097 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 14098 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 14099 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
14100 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 14101 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
14102 | ||
14103 | /* "show [ip] bgp neighbors" commands. */ | |
14104 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
14105 | ||
14106 | /* "show [ip] bgp peer-group" commands. */ | |
14107 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
14108 | ||
14109 | /* "show [ip] bgp paths" commands. */ | |
14110 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
14111 | ||
14112 | /* "show [ip] bgp community" commands. */ | |
14113 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
14114 | ||
14115 | /* "show ip bgp large-community" commands. */ | |
14116 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
14117 | /* "show [ip] bgp attribute-info" commands. */ | |
14118 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 14119 | /* "show [ip] bgp route-leak" command */ |
14120 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 14121 | |
14122 | /* "redistribute" commands. */ | |
14123 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
14124 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
14125 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
14126 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
14127 | install_element(BGP_NODE, | |
14128 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
14129 | install_element(BGP_NODE, | |
14130 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
14131 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
14132 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
14133 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
14134 | install_element(BGP_NODE, | |
14135 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
14136 | install_element(BGP_NODE, | |
14137 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
14138 | install_element(BGP_NODE, | |
14139 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
14140 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
14141 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
14142 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
14143 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
14144 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
14145 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
14146 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
14147 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
14148 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
14149 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
14150 | install_element(BGP_IPV4_NODE, | |
14151 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
14152 | install_element(BGP_IPV4_NODE, | |
14153 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
14154 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
14155 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
14156 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
14157 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
14158 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
14159 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
14160 | ||
b9c7bc5a PZ |
14161 | /* import|export vpn [route-map WORD] */ |
14162 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
14163 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 14164 | |
12a844a5 DS |
14165 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
14166 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
14167 | ||
d62a17ae | 14168 | /* ttl_security commands */ |
14169 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
14170 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
14171 | ||
14172 | /* "show [ip] bgp memory" commands. */ | |
14173 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
14174 | ||
acf71666 MK |
14175 | /* "show bgp martian next-hop" */ |
14176 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
14177 | ||
48ecf8f5 DS |
14178 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); |
14179 | ||
d62a17ae | 14180 | /* "show [ip] bgp views" commands. */ |
14181 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
14182 | ||
14183 | /* "show [ip] bgp vrfs" commands. */ | |
14184 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
14185 | ||
14186 | /* Community-list. */ | |
14187 | community_list_vty(); | |
ddb5b488 PZ |
14188 | |
14189 | /* vpn-policy commands */ | |
b9c7bc5a PZ |
14190 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
14191 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
14192 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
14193 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
14194 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
14195 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
14196 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
14197 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
14198 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
14199 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
14200 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
14201 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 14202 | |
301ad80a PG |
14203 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
14204 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
14205 | ||
b9c7bc5a PZ |
14206 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
14207 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
14208 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
14209 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
14210 | install_element(BGP_IPV4_NODE, &af_no_nexthop_vpn_export_cmd); | |
14211 | install_element(BGP_IPV6_NODE, &af_no_nexthop_vpn_export_cmd); | |
14212 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); | |
14213 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
14214 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
14215 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
14216 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
14217 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
718e3744 | 14218 | } |
6b0655a2 | 14219 | |
718e3744 | 14220 | #include "memory.h" |
14221 | #include "bgp_regex.h" | |
14222 | #include "bgp_clist.h" | |
14223 | #include "bgp_ecommunity.h" | |
14224 | ||
14225 | /* VTY functions. */ | |
14226 | ||
14227 | /* Direction value to string conversion. */ | |
d62a17ae | 14228 | static const char *community_direct_str(int direct) |
14229 | { | |
14230 | switch (direct) { | |
14231 | case COMMUNITY_DENY: | |
14232 | return "deny"; | |
14233 | case COMMUNITY_PERMIT: | |
14234 | return "permit"; | |
14235 | default: | |
14236 | return "unknown"; | |
14237 | } | |
718e3744 | 14238 | } |
14239 | ||
14240 | /* Display error string. */ | |
d62a17ae | 14241 | static void community_list_perror(struct vty *vty, int ret) |
14242 | { | |
14243 | switch (ret) { | |
14244 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
14245 | vty_out(vty, "%% Can't find community-list\n"); | |
14246 | break; | |
14247 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
14248 | vty_out(vty, "%% Malformed community-list value\n"); | |
14249 | break; | |
14250 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
14251 | vty_out(vty, | |
14252 | "%% Community name conflict, previously defined as standard community\n"); | |
14253 | break; | |
14254 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
14255 | vty_out(vty, | |
14256 | "%% Community name conflict, previously defined as expanded community\n"); | |
14257 | break; | |
14258 | } | |
718e3744 | 14259 | } |
14260 | ||
5bf15956 DW |
14261 | /* "community-list" keyword help string. */ |
14262 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
14263 | ||
7336e101 SP |
14264 | /*community-list standard */ |
14265 | DEFUN (community_list_standard, | |
14266 | bgp_community_list_standard_cmd, | |
14267 | "bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
14268 | BGP_STR | |
718e3744 | 14269 | COMMUNITY_LIST_STR |
14270 | "Community list number (standard)\n" | |
5bf15956 | 14271 | "Add an standard community-list entry\n" |
718e3744 | 14272 | "Community list name\n" |
14273 | "Specify community to reject\n" | |
14274 | "Specify community to accept\n" | |
14275 | COMMUNITY_VAL_STR) | |
14276 | { | |
d62a17ae | 14277 | char *cl_name_or_number = NULL; |
14278 | int direct = 0; | |
14279 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 14280 | |
d62a17ae | 14281 | int idx = 0; |
7336e101 SP |
14282 | |
14283 | if (argv_find(argv, argc, "ip", &idx)) { | |
14284 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14285 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14286 | vty_out(vty, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n"); | |
14287 | zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used"); | |
14288 | } | |
14289 | ||
d62a17ae | 14290 | argv_find(argv, argc, "(1-99)", &idx); |
14291 | argv_find(argv, argc, "WORD", &idx); | |
14292 | cl_name_or_number = argv[idx]->arg; | |
14293 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14294 | : COMMUNITY_DENY; | |
14295 | argv_find(argv, argc, "AA:NN", &idx); | |
14296 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14297 | |
d62a17ae | 14298 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
14299 | style); | |
42f914d4 | 14300 | |
d62a17ae | 14301 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14302 | |
d62a17ae | 14303 | if (ret < 0) { |
14304 | /* Display error string. */ | |
14305 | community_list_perror(vty, ret); | |
14306 | return CMD_WARNING_CONFIG_FAILED; | |
14307 | } | |
42f914d4 | 14308 | |
d62a17ae | 14309 | return CMD_SUCCESS; |
718e3744 | 14310 | } |
14311 | ||
7336e101 SP |
14312 | #if CONFDATE > 20191005 |
14313 | CPP_NOTICE("bgpd: remove deprecated 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' command") | |
14314 | #endif | |
14315 | ALIAS (community_list_standard, | |
14316 | ip_community_list_standard_cmd, | |
14317 | "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
718e3744 | 14318 | IP_STR |
14319 | COMMUNITY_LIST_STR | |
14320 | "Community list number (standard)\n" | |
5bf15956 DW |
14321 | "Add an standard community-list entry\n" |
14322 | "Community list name\n" | |
718e3744 | 14323 | "Specify community to reject\n" |
14324 | "Specify community to accept\n" | |
14325 | COMMUNITY_VAL_STR) | |
7336e101 SP |
14326 | |
14327 | DEFUN (no_community_list_standard_all, | |
14328 | no_bgp_community_list_standard_all_cmd, | |
14329 | "no bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
14330 | NO_STR | |
14331 | BGP_STR | |
14332 | COMMUNITY_LIST_STR | |
14333 | "Community list number (standard)\n" | |
14334 | "Add an standard community-list entry\n" | |
14335 | "Community list name\n" | |
14336 | "Specify community to reject\n" | |
14337 | "Specify community to accept\n" | |
14338 | COMMUNITY_VAL_STR) | |
718e3744 | 14339 | { |
d62a17ae | 14340 | char *cl_name_or_number = NULL; |
174b5cb9 | 14341 | char *str = NULL; |
d62a17ae | 14342 | int direct = 0; |
14343 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 14344 | |
d62a17ae | 14345 | int idx = 0; |
7336e101 SP |
14346 | |
14347 | if (argv_find(argv, argc, "ip", &idx)) { | |
14348 | vty_out(vty, "This config option is deprecated, and is scheduled for removal\n"); | |
14349 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14350 | vty_out(vty, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n"); | |
14351 | zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> |AA:NN' being used"); | |
14352 | } | |
14353 | ||
174b5cb9 DA |
14354 | argv_find(argv, argc, "permit", &idx); |
14355 | argv_find(argv, argc, "deny", &idx); | |
14356 | ||
14357 | if (idx) { | |
14358 | direct = argv_find(argv, argc, "permit", &idx) | |
14359 | ? COMMUNITY_PERMIT | |
14360 | : COMMUNITY_DENY; | |
14361 | ||
14362 | idx = 0; | |
14363 | argv_find(argv, argc, "AA:NN", &idx); | |
14364 | str = argv_concat(argv, argc, idx); | |
14365 | } | |
14366 | ||
14367 | idx = 0; | |
d62a17ae | 14368 | argv_find(argv, argc, "(1-99)", &idx); |
14369 | argv_find(argv, argc, "WORD", &idx); | |
14370 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 14371 | |
d62a17ae | 14372 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
7298a8e1 | 14373 | direct, style); |
42f914d4 | 14374 | |
d62a17ae | 14375 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 14376 | |
d62a17ae | 14377 | if (ret < 0) { |
14378 | community_list_perror(vty, ret); | |
14379 | return CMD_WARNING_CONFIG_FAILED; | |
14380 | } | |
42f914d4 | 14381 | |
d62a17ae | 14382 | return CMD_SUCCESS; |
718e3744 | 14383 | } |
7336e101 SP |
14384 | ALIAS (no_community_list_standard_all, |
14385 | no_ip_community_list_standard_all_cmd, | |
14386 | "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
14387 | NO_STR | |
718e3744 | 14388 | IP_STR |
14389 | COMMUNITY_LIST_STR | |
7336e101 SP |
14390 | "Community list number (standard)\n" |
14391 | "Add an standard community-list entry\n" | |
14392 | "Community list name\n" | |
14393 | "Specify community to reject\n" | |
14394 | "Specify community to accept\n" | |
14395 | COMMUNITY_VAL_STR) | |
14396 | ||
174b5cb9 DA |
14397 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
14398 | "no bgp community-list <(1-99)|standard WORD>", | |
14399 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
14400 | "Community list number (standard)\n" | |
14401 | "Add an standard community-list entry\n" | |
14402 | "Community list name\n") | |
14403 | ||
14404 | ALIAS(no_community_list_standard_all, no_ip_community_list_standard_all_list_cmd, | |
14405 | "no ip community-list <(1-99)|standard WORD>", | |
14406 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
14407 | "Community list number (standard)\n" | |
14408 | "Add an standard community-list entry\n" | |
14409 | "Community list name\n") | |
14410 | ||
7336e101 SP |
14411 | /*community-list expanded */ |
14412 | DEFUN (community_list_expanded_all, | |
14413 | bgp_community_list_expanded_all_cmd, | |
14414 | "bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
14415 | BGP_STR | |
14416 | COMMUNITY_LIST_STR | |
718e3744 | 14417 | "Community list number (expanded)\n" |
5bf15956 | 14418 | "Add an expanded community-list entry\n" |
718e3744 | 14419 | "Community list name\n" |
14420 | "Specify community to reject\n" | |
14421 | "Specify community to accept\n" | |
14422 | COMMUNITY_VAL_STR) | |
14423 | { | |
d62a17ae | 14424 | char *cl_name_or_number = NULL; |
14425 | int direct = 0; | |
14426 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 14427 | |
d62a17ae | 14428 | int idx = 0; |
7336e101 SP |
14429 | if (argv_find(argv, argc, "ip", &idx)) { |
14430 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14431 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14432 | vty_out(vty, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n"); | |
14433 | zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used"); | |
14434 | } | |
d62a17ae | 14435 | argv_find(argv, argc, "(100-500)", &idx); |
14436 | argv_find(argv, argc, "WORD", &idx); | |
14437 | cl_name_or_number = argv[idx]->arg; | |
14438 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14439 | : COMMUNITY_DENY; | |
14440 | argv_find(argv, argc, "AA:NN", &idx); | |
14441 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14442 | |
d62a17ae | 14443 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
14444 | style); | |
42f914d4 | 14445 | |
d62a17ae | 14446 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14447 | |
d62a17ae | 14448 | if (ret < 0) { |
14449 | /* Display error string. */ | |
14450 | community_list_perror(vty, ret); | |
14451 | return CMD_WARNING_CONFIG_FAILED; | |
14452 | } | |
42f914d4 | 14453 | |
d62a17ae | 14454 | return CMD_SUCCESS; |
718e3744 | 14455 | } |
14456 | ||
7336e101 SP |
14457 | ALIAS (community_list_expanded_all, |
14458 | ip_community_list_expanded_all_cmd, | |
14459 | "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
718e3744 | 14460 | IP_STR |
14461 | COMMUNITY_LIST_STR | |
5bf15956 DW |
14462 | "Community list number (expanded)\n" |
14463 | "Add an expanded community-list entry\n" | |
718e3744 | 14464 | "Community list name\n" |
14465 | "Specify community to reject\n" | |
14466 | "Specify community to accept\n" | |
5bf15956 | 14467 | COMMUNITY_VAL_STR) |
7336e101 SP |
14468 | |
14469 | DEFUN (no_community_list_expanded_all, | |
14470 | no_bgp_community_list_expanded_all_cmd, | |
14471 | "no bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
14472 | NO_STR | |
14473 | BGP_STR | |
14474 | COMMUNITY_LIST_STR | |
14475 | "Community list number (expanded)\n" | |
14476 | "Add an expanded community-list entry\n" | |
14477 | "Community list name\n" | |
14478 | "Specify community to reject\n" | |
14479 | "Specify community to accept\n" | |
14480 | COMMUNITY_VAL_STR) | |
718e3744 | 14481 | { |
d62a17ae | 14482 | char *cl_name_or_number = NULL; |
174b5cb9 | 14483 | char *str = NULL; |
d62a17ae | 14484 | int direct = 0; |
14485 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 14486 | |
d62a17ae | 14487 | int idx = 0; |
7336e101 SP |
14488 | if (argv_find(argv, argc, "ip", &idx)) { |
14489 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14490 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
174b5cb9 DA |
14491 | vty_out(vty, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n"); |
14492 | zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used"); | |
14493 | } | |
14494 | ||
3c4b8fe2 | 14495 | idx = 0; |
174b5cb9 DA |
14496 | argv_find(argv, argc, "permit", &idx); |
14497 | argv_find(argv, argc, "deny", &idx); | |
14498 | ||
14499 | if (idx) { | |
14500 | direct = argv_find(argv, argc, "permit", &idx) | |
14501 | ? COMMUNITY_PERMIT | |
14502 | : COMMUNITY_DENY; | |
14503 | ||
14504 | idx = 0; | |
14505 | argv_find(argv, argc, "AA:NN", &idx); | |
14506 | str = argv_concat(argv, argc, idx); | |
7336e101 | 14507 | } |
174b5cb9 DA |
14508 | |
14509 | idx = 0; | |
d62a17ae | 14510 | argv_find(argv, argc, "(100-500)", &idx); |
14511 | argv_find(argv, argc, "WORD", &idx); | |
14512 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 14513 | |
d62a17ae | 14514 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
7298a8e1 | 14515 | direct, style); |
42f914d4 | 14516 | |
d62a17ae | 14517 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 14518 | |
d62a17ae | 14519 | if (ret < 0) { |
14520 | community_list_perror(vty, ret); | |
14521 | return CMD_WARNING_CONFIG_FAILED; | |
14522 | } | |
42f914d4 | 14523 | |
d62a17ae | 14524 | return CMD_SUCCESS; |
718e3744 | 14525 | } |
14526 | ||
7336e101 SP |
14527 | ALIAS (no_community_list_expanded_all, |
14528 | no_ip_community_list_expanded_all_cmd, | |
14529 | "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
14530 | NO_STR | |
14531 | IP_STR | |
14532 | COMMUNITY_LIST_STR | |
14533 | "Community list number (expanded)\n" | |
14534 | "Add an expanded community-list entry\n" | |
14535 | "Community list name\n" | |
14536 | "Specify community to reject\n" | |
14537 | "Specify community to accept\n" | |
14538 | COMMUNITY_VAL_STR) | |
14539 | ||
174b5cb9 DA |
14540 | ALIAS(no_community_list_expanded_all, no_bgp_community_list_expanded_all_list_cmd, |
14541 | "no bgp community-list <(100-500)|expanded WORD>", | |
14542 | NO_STR IP_STR COMMUNITY_LIST_STR | |
14543 | "Community list number (expanded)\n" | |
14544 | "Add an expanded community-list entry\n" | |
14545 | "Community list name\n") | |
14546 | ||
14547 | ALIAS(no_community_list_expanded_all, no_ip_community_list_expanded_all_list_cmd, | |
14548 | "no ip community-list <(100-500)|expanded WORD>", | |
14549 | NO_STR IP_STR COMMUNITY_LIST_STR | |
14550 | "Community list number (expanded)\n" | |
14551 | "Add an expanded community-list entry\n" | |
14552 | "Community list name\n") | |
14553 | ||
8d9b8ed9 PM |
14554 | /* Return configuration string of community-list entry. */ |
14555 | static const char *community_list_config_str(struct community_entry *entry) | |
14556 | { | |
14557 | const char *str; | |
14558 | ||
14559 | if (entry->any) | |
14560 | str = ""; | |
14561 | else { | |
14562 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
14563 | str = community_str(entry->u.com, false); | |
14564 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
14565 | str = lcommunity_str(entry->u.lcom, false); | |
14566 | else | |
14567 | str = entry->config; | |
14568 | } | |
14569 | return str; | |
14570 | } | |
14571 | ||
d62a17ae | 14572 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 14573 | { |
d62a17ae | 14574 | struct community_entry *entry; |
718e3744 | 14575 | |
d62a17ae | 14576 | for (entry = list->head; entry; entry = entry->next) { |
14577 | if (entry == list->head) { | |
14578 | if (all_digit(list->name)) | |
14579 | vty_out(vty, "Community %s list %s\n", | |
14580 | entry->style == COMMUNITY_LIST_STANDARD | |
14581 | ? "standard" | |
14582 | : "(expanded) access", | |
14583 | list->name); | |
14584 | else | |
14585 | vty_out(vty, "Named Community %s list %s\n", | |
14586 | entry->style == COMMUNITY_LIST_STANDARD | |
14587 | ? "standard" | |
14588 | : "expanded", | |
14589 | list->name); | |
14590 | } | |
14591 | if (entry->any) | |
14592 | vty_out(vty, " %s\n", | |
14593 | community_direct_str(entry->direct)); | |
14594 | else | |
14595 | vty_out(vty, " %s %s\n", | |
14596 | community_direct_str(entry->direct), | |
8d9b8ed9 | 14597 | community_list_config_str(entry)); |
d62a17ae | 14598 | } |
718e3744 | 14599 | } |
14600 | ||
7336e101 SP |
14601 | DEFUN (show_community_list, |
14602 | show_bgp_community_list_cmd, | |
14603 | "show bgp community-list", | |
718e3744 | 14604 | SHOW_STR |
7336e101 | 14605 | BGP_STR |
718e3744 | 14606 | "List community-list\n") |
14607 | { | |
d62a17ae | 14608 | struct community_list *list; |
14609 | struct community_list_master *cm; | |
718e3744 | 14610 | |
7336e101 SP |
14611 | int idx = 0; |
14612 | if (argv_find(argv, argc, "ip", &idx)) { | |
14613 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14614 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14615 | vty_out(vty, "'show bgp community-list <(1-500)|WORD>'\n"); | |
14616 | zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used"); | |
14617 | } | |
d62a17ae | 14618 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
14619 | if (!cm) | |
14620 | return CMD_SUCCESS; | |
718e3744 | 14621 | |
d62a17ae | 14622 | for (list = cm->num.head; list; list = list->next) |
14623 | community_list_show(vty, list); | |
718e3744 | 14624 | |
d62a17ae | 14625 | for (list = cm->str.head; list; list = list->next) |
14626 | community_list_show(vty, list); | |
718e3744 | 14627 | |
d62a17ae | 14628 | return CMD_SUCCESS; |
718e3744 | 14629 | } |
14630 | ||
7336e101 SP |
14631 | ALIAS (show_community_list, |
14632 | show_ip_community_list_cmd, | |
14633 | "show ip community-list", | |
718e3744 | 14634 | SHOW_STR |
14635 | IP_STR | |
7336e101 SP |
14636 | "List community-list\n") |
14637 | ||
14638 | DEFUN (show_community_list_arg, | |
14639 | show_bgp_community_list_arg_cmd, | |
960b69b9 | 14640 | "show bgp community-list <(1-500)|WORD> detail", |
7336e101 SP |
14641 | SHOW_STR |
14642 | BGP_STR | |
718e3744 | 14643 | "List community-list\n" |
14644 | "Community-list number\n" | |
960b69b9 | 14645 | "Community-list name\n" |
14646 | "Detailed information on community-list\n") | |
718e3744 | 14647 | { |
d62a17ae | 14648 | int idx_comm_list = 3; |
14649 | struct community_list *list; | |
718e3744 | 14650 | |
7336e101 SP |
14651 | int idx = 0; |
14652 | if (argv_find(argv, argc, "ip", &idx)) { | |
14653 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14654 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
960b69b9 | 14655 | vty_out(vty, "'show bgp community-list <(1-500)|WORD> detail'\n"); |
14656 | zlog_warn("Deprecated option: 'show ip community-list <(1-500)|WORD>' being used"); | |
7336e101 | 14657 | } |
e237b0d2 | 14658 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 14659 | COMMUNITY_LIST_MASTER); |
14660 | if (!list) { | |
14661 | vty_out(vty, "%% Can't find community-list\n"); | |
14662 | return CMD_WARNING; | |
14663 | } | |
718e3744 | 14664 | |
d62a17ae | 14665 | community_list_show(vty, list); |
718e3744 | 14666 | |
d62a17ae | 14667 | return CMD_SUCCESS; |
718e3744 | 14668 | } |
6b0655a2 | 14669 | |
7336e101 SP |
14670 | ALIAS (show_community_list_arg, |
14671 | show_ip_community_list_arg_cmd, | |
14672 | "show ip community-list <(1-500)|WORD>", | |
14673 | SHOW_STR | |
14674 | IP_STR | |
14675 | "List community-list\n" | |
14676 | "Community-list number\n" | |
14677 | "Community-list name\n") | |
14678 | ||
57d187bc JS |
14679 | /* |
14680 | * Large Community code. | |
14681 | */ | |
d62a17ae | 14682 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
14683 | struct cmd_token **argv, int style, | |
14684 | int reject_all_digit_name) | |
14685 | { | |
14686 | int ret; | |
14687 | int direct; | |
14688 | char *str; | |
14689 | int idx = 0; | |
14690 | char *cl_name; | |
14691 | ||
7336e101 SP |
14692 | if (argv_find(argv, argc, "ip", &idx)) { |
14693 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14694 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14695 | vty_out(vty, "'bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n"); | |
14696 | zlog_warn("Deprecated option: 'large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used"); | |
14697 | } | |
d62a17ae | 14698 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
14699 | : COMMUNITY_DENY; | |
14700 | ||
14701 | /* All digit name check. */ | |
14702 | idx = 0; | |
14703 | argv_find(argv, argc, "WORD", &idx); | |
14704 | argv_find(argv, argc, "(1-99)", &idx); | |
14705 | argv_find(argv, argc, "(100-500)", &idx); | |
14706 | cl_name = argv[idx]->arg; | |
14707 | if (reject_all_digit_name && all_digit(cl_name)) { | |
14708 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
14709 | return CMD_WARNING_CONFIG_FAILED; | |
14710 | } | |
14711 | ||
14712 | idx = 0; | |
14713 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
14714 | argv_find(argv, argc, "LINE", &idx); | |
14715 | /* Concat community string argument. */ | |
14716 | if (idx) | |
14717 | str = argv_concat(argv, argc, idx); | |
14718 | else | |
14719 | str = NULL; | |
14720 | ||
14721 | ret = lcommunity_list_set(bgp_clist, cl_name, str, direct, style); | |
14722 | ||
14723 | /* Free temporary community list string allocated by | |
14724 | argv_concat(). */ | |
0a22ddfb | 14725 | XFREE(MTYPE_TMP, str); |
d62a17ae | 14726 | |
14727 | if (ret < 0) { | |
14728 | community_list_perror(vty, ret); | |
14729 | return CMD_WARNING_CONFIG_FAILED; | |
14730 | } | |
14731 | return CMD_SUCCESS; | |
14732 | } | |
14733 | ||
14734 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
14735 | struct cmd_token **argv, int style) | |
14736 | { | |
14737 | int ret; | |
14738 | int direct = 0; | |
14739 | char *str = NULL; | |
14740 | int idx = 0; | |
14741 | ||
7336e101 SP |
14742 | if (argv_find(argv, argc, "ip", &idx)) { |
14743 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14744 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14745 | vty_out(vty, "'no bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n"); | |
16941c05 | 14746 | zlog_warn("Deprecated option: 'no ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used"); |
7336e101 | 14747 | } |
d62a17ae | 14748 | argv_find(argv, argc, "permit", &idx); |
14749 | argv_find(argv, argc, "deny", &idx); | |
14750 | ||
14751 | if (idx) { | |
14752 | /* Check the list direct. */ | |
14753 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
14754 | direct = COMMUNITY_PERMIT; | |
14755 | else | |
14756 | direct = COMMUNITY_DENY; | |
14757 | ||
14758 | idx = 0; | |
14759 | argv_find(argv, argc, "LINE", &idx); | |
14760 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
14761 | /* Concat community string argument. */ | |
14762 | str = argv_concat(argv, argc, idx); | |
14763 | } | |
14764 | ||
14765 | idx = 0; | |
14766 | argv_find(argv, argc, "(1-99)", &idx); | |
14767 | argv_find(argv, argc, "(100-500)", &idx); | |
14768 | argv_find(argv, argc, "WORD", &idx); | |
14769 | ||
14770 | /* Unset community list. */ | |
14771 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, direct, | |
14772 | style); | |
14773 | ||
14774 | /* Free temporary community list string allocated by | |
14775 | argv_concat(). */ | |
0a22ddfb | 14776 | XFREE(MTYPE_TMP, str); |
d62a17ae | 14777 | |
14778 | if (ret < 0) { | |
14779 | community_list_perror(vty, ret); | |
14780 | return CMD_WARNING_CONFIG_FAILED; | |
14781 | } | |
14782 | ||
14783 | return CMD_SUCCESS; | |
57d187bc JS |
14784 | } |
14785 | ||
14786 | /* "large-community-list" keyword help string. */ | |
14787 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
14788 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
14789 | ||
7336e101 SP |
14790 | #if CONFDATE > 20191005 |
14791 | CPP_NOTICE("bgpd: remove deprecated 'ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' command") | |
14792 | #endif | |
14793 | DEFUN (lcommunity_list_standard, | |
14794 | bgp_lcommunity_list_standard_cmd, | |
7336e101 SP |
14795 | "bgp large-community-list (1-99) <deny|permit> AA:BB:CC...", |
14796 | BGP_STR | |
14797 | LCOMMUNITY_LIST_STR | |
14798 | "Large Community list number (standard)\n" | |
14799 | "Specify large community to reject\n" | |
14800 | "Specify large community to accept\n" | |
14801 | LCOMMUNITY_VAL_STR) | |
52951b63 | 14802 | { |
d62a17ae | 14803 | return lcommunity_list_set_vty(vty, argc, argv, |
14804 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
14805 | } |
14806 | ||
82cdf28d NT |
14807 | ALIAS (lcommunity_list_standard, |
14808 | ip_lcommunity_list_standard_cmd, | |
52951b63 | 14809 | "ip large-community-list (1-99) <deny|permit> AA:BB:CC...", |
57d187bc JS |
14810 | IP_STR |
14811 | LCOMMUNITY_LIST_STR | |
14812 | "Large Community list number (standard)\n" | |
14813 | "Specify large community to reject\n" | |
14814 | "Specify large community to accept\n" | |
14815 | LCOMMUNITY_VAL_STR) | |
7336e101 SP |
14816 | |
14817 | DEFUN (lcommunity_list_expanded, | |
14818 | bgp_lcommunity_list_expanded_cmd, | |
14819 | "bgp large-community-list (100-500) <deny|permit> LINE...", | |
14820 | BGP_STR | |
14821 | LCOMMUNITY_LIST_STR | |
14822 | "Large Community list number (expanded)\n" | |
14823 | "Specify large community to reject\n" | |
14824 | "Specify large community to accept\n" | |
14825 | "An ordered list as a regular-expression\n") | |
57d187bc | 14826 | { |
d62a17ae | 14827 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 14828 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
14829 | } |
14830 | ||
7336e101 | 14831 | ALIAS (lcommunity_list_expanded, |
57d187bc JS |
14832 | ip_lcommunity_list_expanded_cmd, |
14833 | "ip large-community-list (100-500) <deny|permit> LINE...", | |
14834 | IP_STR | |
14835 | LCOMMUNITY_LIST_STR | |
14836 | "Large Community list number (expanded)\n" | |
14837 | "Specify large community to reject\n" | |
14838 | "Specify large community to accept\n" | |
14839 | "An ordered list as a regular-expression\n") | |
7336e101 SP |
14840 | |
14841 | DEFUN (lcommunity_list_name_standard, | |
14842 | bgp_lcommunity_list_name_standard_cmd, | |
7336e101 SP |
14843 | "bgp large-community-list standard WORD <deny|permit> AA:BB:CC...", |
14844 | BGP_STR | |
14845 | LCOMMUNITY_LIST_STR | |
14846 | "Specify standard large-community-list\n" | |
14847 | "Large Community list name\n" | |
14848 | "Specify large community to reject\n" | |
14849 | "Specify large community to accept\n" | |
14850 | LCOMMUNITY_VAL_STR) | |
52951b63 | 14851 | { |
d62a17ae | 14852 | return lcommunity_list_set_vty(vty, argc, argv, |
14853 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
14854 | } |
14855 | ||
82cdf28d NT |
14856 | ALIAS (lcommunity_list_name_standard, |
14857 | ip_lcommunity_list_name_standard_cmd, | |
52951b63 | 14858 | "ip large-community-list standard WORD <deny|permit> AA:BB:CC...", |
57d187bc JS |
14859 | IP_STR |
14860 | LCOMMUNITY_LIST_STR | |
14861 | "Specify standard large-community-list\n" | |
14862 | "Large Community list name\n" | |
14863 | "Specify large community to reject\n" | |
14864 | "Specify large community to accept\n" | |
14865 | LCOMMUNITY_VAL_STR) | |
7336e101 SP |
14866 | |
14867 | DEFUN (lcommunity_list_name_expanded, | |
14868 | bgp_lcommunity_list_name_expanded_cmd, | |
14869 | "bgp large-community-list expanded WORD <deny|permit> LINE...", | |
14870 | BGP_STR | |
14871 | LCOMMUNITY_LIST_STR | |
14872 | "Specify expanded large-community-list\n" | |
14873 | "Large Community list name\n" | |
14874 | "Specify large community to reject\n" | |
14875 | "Specify large community to accept\n" | |
14876 | "An ordered list as a regular-expression\n") | |
57d187bc | 14877 | { |
d62a17ae | 14878 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 14879 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
14880 | } |
14881 | ||
7336e101 | 14882 | ALIAS (lcommunity_list_name_expanded, |
57d187bc JS |
14883 | ip_lcommunity_list_name_expanded_cmd, |
14884 | "ip large-community-list expanded WORD <deny|permit> LINE...", | |
14885 | IP_STR | |
14886 | LCOMMUNITY_LIST_STR | |
14887 | "Specify expanded large-community-list\n" | |
14888 | "Large Community list name\n" | |
14889 | "Specify large community to reject\n" | |
14890 | "Specify large community to accept\n" | |
14891 | "An ordered list as a regular-expression\n") | |
7336e101 SP |
14892 | |
14893 | DEFUN (no_lcommunity_list_standard_all, | |
14894 | no_bgp_lcommunity_list_standard_all_cmd, | |
14895 | "no bgp large-community-list <(1-99)|(100-500)|WORD>", | |
14896 | NO_STR | |
14897 | BGP_STR | |
14898 | LCOMMUNITY_LIST_STR | |
14899 | "Large Community list number (standard)\n" | |
14900 | "Large Community list number (expanded)\n" | |
14901 | "Large Community list name\n") | |
57d187bc | 14902 | { |
7336e101 SP |
14903 | return lcommunity_list_unset_vty(vty, argc, argv, |
14904 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
14905 | } |
14906 | ||
7336e101 | 14907 | ALIAS (no_lcommunity_list_standard_all, |
57d187bc JS |
14908 | no_ip_lcommunity_list_standard_all_cmd, |
14909 | "no ip large-community-list <(1-99)|(100-500)|WORD>", | |
14910 | NO_STR | |
14911 | IP_STR | |
14912 | LCOMMUNITY_LIST_STR | |
14913 | "Large Community list number (standard)\n" | |
14914 | "Large Community list number (expanded)\n" | |
14915 | "Large Community list name\n") | |
7336e101 SP |
14916 | |
14917 | DEFUN (no_lcommunity_list_name_expanded_all, | |
14918 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
14919 | "no bgp large-community-list expanded WORD", | |
14920 | NO_STR | |
14921 | BGP_STR | |
14922 | LCOMMUNITY_LIST_STR | |
14923 | "Specify expanded large-community-list\n" | |
14924 | "Large Community list name\n") | |
57d187bc | 14925 | { |
d62a17ae | 14926 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14927 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
14928 | } |
14929 | ||
7336e101 | 14930 | ALIAS (no_lcommunity_list_name_expanded_all, |
57d187bc JS |
14931 | no_ip_lcommunity_list_name_expanded_all_cmd, |
14932 | "no ip large-community-list expanded WORD", | |
14933 | NO_STR | |
14934 | IP_STR | |
14935 | LCOMMUNITY_LIST_STR | |
14936 | "Specify expanded large-community-list\n" | |
14937 | "Large Community list name\n") | |
7336e101 SP |
14938 | |
14939 | DEFUN (no_lcommunity_list_standard, | |
14940 | no_bgp_lcommunity_list_standard_cmd, | |
14941 | "no bgp large-community-list (1-99) <deny|permit> AA:AA:NN...", | |
14942 | NO_STR | |
14943 | BGP_STR | |
14944 | LCOMMUNITY_LIST_STR | |
14945 | "Large Community list number (standard)\n" | |
14946 | "Specify large community to reject\n" | |
14947 | "Specify large community to accept\n" | |
14948 | LCOMMUNITY_VAL_STR) | |
57d187bc | 14949 | { |
d62a17ae | 14950 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14951 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
14952 | } |
14953 | ||
7336e101 | 14954 | ALIAS (no_lcommunity_list_standard, |
57d187bc JS |
14955 | no_ip_lcommunity_list_standard_cmd, |
14956 | "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...", | |
14957 | NO_STR | |
14958 | IP_STR | |
14959 | LCOMMUNITY_LIST_STR | |
14960 | "Large Community list number (standard)\n" | |
14961 | "Specify large community to reject\n" | |
14962 | "Specify large community to accept\n" | |
14963 | LCOMMUNITY_VAL_STR) | |
7336e101 SP |
14964 | |
14965 | DEFUN (no_lcommunity_list_expanded, | |
14966 | no_bgp_lcommunity_list_expanded_cmd, | |
14967 | "no bgp large-community-list (100-500) <deny|permit> LINE...", | |
14968 | NO_STR | |
14969 | BGP_STR | |
14970 | LCOMMUNITY_LIST_STR | |
14971 | "Large Community list number (expanded)\n" | |
14972 | "Specify large community to reject\n" | |
14973 | "Specify large community to accept\n" | |
14974 | "An ordered list as a regular-expression\n") | |
57d187bc | 14975 | { |
d62a17ae | 14976 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14977 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
14978 | } |
14979 | ||
7336e101 | 14980 | ALIAS (no_lcommunity_list_expanded, |
57d187bc JS |
14981 | no_ip_lcommunity_list_expanded_cmd, |
14982 | "no ip large-community-list (100-500) <deny|permit> LINE...", | |
14983 | NO_STR | |
14984 | IP_STR | |
14985 | LCOMMUNITY_LIST_STR | |
14986 | "Large Community list number (expanded)\n" | |
14987 | "Specify large community to reject\n" | |
14988 | "Specify large community to accept\n" | |
14989 | "An ordered list as a regular-expression\n") | |
7336e101 SP |
14990 | |
14991 | DEFUN (no_lcommunity_list_name_standard, | |
14992 | no_bgp_lcommunity_list_name_standard_cmd, | |
14993 | "no bgp large-community-list standard WORD <deny|permit> AA:AA:NN...", | |
14994 | NO_STR | |
14995 | BGP_STR | |
14996 | LCOMMUNITY_LIST_STR | |
14997 | "Specify standard large-community-list\n" | |
14998 | "Large Community list name\n" | |
14999 | "Specify large community to reject\n" | |
15000 | "Specify large community to accept\n" | |
15001 | LCOMMUNITY_VAL_STR) | |
57d187bc | 15002 | { |
d62a17ae | 15003 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 15004 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
15005 | } |
15006 | ||
7336e101 | 15007 | ALIAS (no_lcommunity_list_name_standard, |
57d187bc JS |
15008 | no_ip_lcommunity_list_name_standard_cmd, |
15009 | "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...", | |
15010 | NO_STR | |
15011 | IP_STR | |
15012 | LCOMMUNITY_LIST_STR | |
15013 | "Specify standard large-community-list\n" | |
15014 | "Large Community list name\n" | |
15015 | "Specify large community to reject\n" | |
15016 | "Specify large community to accept\n" | |
15017 | LCOMMUNITY_VAL_STR) | |
7336e101 SP |
15018 | |
15019 | DEFUN (no_lcommunity_list_name_expanded, | |
15020 | no_bgp_lcommunity_list_name_expanded_cmd, | |
15021 | "no bgp large-community-list expanded WORD <deny|permit> LINE...", | |
15022 | NO_STR | |
15023 | BGP_STR | |
15024 | LCOMMUNITY_LIST_STR | |
15025 | "Specify expanded large-community-list\n" | |
15026 | "Large community list name\n" | |
15027 | "Specify large community to reject\n" | |
15028 | "Specify large community to accept\n" | |
15029 | "An ordered list as a regular-expression\n") | |
57d187bc | 15030 | { |
d62a17ae | 15031 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 15032 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
15033 | } |
15034 | ||
7336e101 | 15035 | ALIAS (no_lcommunity_list_name_expanded, |
57d187bc JS |
15036 | no_ip_lcommunity_list_name_expanded_cmd, |
15037 | "no ip large-community-list expanded WORD <deny|permit> LINE...", | |
15038 | NO_STR | |
15039 | IP_STR | |
15040 | LCOMMUNITY_LIST_STR | |
15041 | "Specify expanded large-community-list\n" | |
15042 | "Large community list name\n" | |
15043 | "Specify large community to reject\n" | |
15044 | "Specify large community to accept\n" | |
15045 | "An ordered list as a regular-expression\n") | |
d62a17ae | 15046 | |
15047 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) | |
15048 | { | |
15049 | struct community_entry *entry; | |
15050 | ||
15051 | for (entry = list->head; entry; entry = entry->next) { | |
15052 | if (entry == list->head) { | |
15053 | if (all_digit(list->name)) | |
15054 | vty_out(vty, "Large community %s list %s\n", | |
169b72c8 | 15055 | entry->style == |
15056 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 15057 | ? "standard" |
15058 | : "(expanded) access", | |
15059 | list->name); | |
15060 | else | |
15061 | vty_out(vty, | |
15062 | "Named large community %s list %s\n", | |
169b72c8 | 15063 | entry->style == |
15064 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 15065 | ? "standard" |
15066 | : "expanded", | |
15067 | list->name); | |
15068 | } | |
15069 | if (entry->any) | |
15070 | vty_out(vty, " %s\n", | |
15071 | community_direct_str(entry->direct)); | |
15072 | else | |
15073 | vty_out(vty, " %s %s\n", | |
15074 | community_direct_str(entry->direct), | |
8d9b8ed9 | 15075 | community_list_config_str(entry)); |
d62a17ae | 15076 | } |
57d187bc JS |
15077 | } |
15078 | ||
7336e101 SP |
15079 | DEFUN (show_lcommunity_list, |
15080 | show_bgp_lcommunity_list_cmd, | |
15081 | "show bgp large-community-list", | |
57d187bc | 15082 | SHOW_STR |
7336e101 | 15083 | BGP_STR |
57d187bc JS |
15084 | "List large-community list\n") |
15085 | { | |
d62a17ae | 15086 | struct community_list *list; |
15087 | struct community_list_master *cm; | |
7336e101 SP |
15088 | int idx = 0; |
15089 | ||
15090 | if (argv_find(argv, argc, "ip", &idx)) { | |
15091 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
15092 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15093 | vty_out(vty, "'show bgp large-community-list <(1-500)|WORD>'\n"); | |
15094 | zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used"); | |
15095 | } | |
57d187bc | 15096 | |
d62a17ae | 15097 | cm = community_list_master_lookup(bgp_clist, |
15098 | LARGE_COMMUNITY_LIST_MASTER); | |
15099 | if (!cm) | |
15100 | return CMD_SUCCESS; | |
57d187bc | 15101 | |
d62a17ae | 15102 | for (list = cm->num.head; list; list = list->next) |
15103 | lcommunity_list_show(vty, list); | |
57d187bc | 15104 | |
d62a17ae | 15105 | for (list = cm->str.head; list; list = list->next) |
15106 | lcommunity_list_show(vty, list); | |
57d187bc | 15107 | |
d62a17ae | 15108 | return CMD_SUCCESS; |
57d187bc JS |
15109 | } |
15110 | ||
7336e101 SP |
15111 | ALIAS (show_lcommunity_list, |
15112 | show_ip_lcommunity_list_cmd, | |
15113 | "show ip large-community-list", | |
57d187bc JS |
15114 | SHOW_STR |
15115 | IP_STR | |
7336e101 SP |
15116 | "List large-community list\n") |
15117 | ||
15118 | DEFUN (show_lcommunity_list_arg, | |
15119 | show_bgp_lcommunity_list_arg_cmd, | |
960b69b9 | 15120 | "show bgp large-community-list <(1-500)|WORD> detail", |
7336e101 SP |
15121 | SHOW_STR |
15122 | BGP_STR | |
57d187bc | 15123 | "List large-community list\n" |
960b69b9 | 15124 | "Large-community-list number\n" |
15125 | "Large-community-list name\n" | |
15126 | "Detailed information on large-community-list\n") | |
57d187bc | 15127 | { |
d62a17ae | 15128 | struct community_list *list; |
7336e101 SP |
15129 | int idx = 0; |
15130 | ||
15131 | if (argv_find(argv, argc, "ip", &idx)) { | |
15132 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
15133 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
960b69b9 | 15134 | vty_out(vty, "'show bgp large-community-list <(1-500)|WORD> detail'\n"); |
15135 | zlog_warn("Deprecated option: 'show ip large-community-list <(1-500)|WORD>' being used"); | |
7336e101 | 15136 | } |
57d187bc | 15137 | |
e237b0d2 | 15138 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, |
d62a17ae | 15139 | LARGE_COMMUNITY_LIST_MASTER); |
15140 | if (!list) { | |
960b69b9 | 15141 | vty_out(vty, "%% Can't find large-community-list\n"); |
d62a17ae | 15142 | return CMD_WARNING; |
15143 | } | |
57d187bc | 15144 | |
d62a17ae | 15145 | lcommunity_list_show(vty, list); |
57d187bc | 15146 | |
d62a17ae | 15147 | return CMD_SUCCESS; |
57d187bc JS |
15148 | } |
15149 | ||
7336e101 SP |
15150 | ALIAS (show_lcommunity_list_arg, |
15151 | show_ip_lcommunity_list_arg_cmd, | |
15152 | "show ip large-community-list <(1-500)|WORD>", | |
15153 | SHOW_STR | |
15154 | IP_STR | |
15155 | "List large-community list\n" | |
15156 | "large-community-list number\n" | |
15157 | "large-community-list name\n") | |
15158 | ||
718e3744 | 15159 | /* "extcommunity-list" keyword help string. */ |
15160 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
15161 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
15162 | ||
7336e101 SP |
15163 | DEFUN (extcommunity_list_standard, |
15164 | bgp_extcommunity_list_standard_cmd, | |
15165 | "bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
15166 | BGP_STR | |
718e3744 | 15167 | EXTCOMMUNITY_LIST_STR |
15168 | "Extended Community list number (standard)\n" | |
718e3744 | 15169 | "Specify standard extcommunity-list\n" |
5bf15956 | 15170 | "Community list name\n" |
718e3744 | 15171 | "Specify community to reject\n" |
15172 | "Specify community to accept\n" | |
15173 | EXTCOMMUNITY_VAL_STR) | |
15174 | { | |
d62a17ae | 15175 | int style = EXTCOMMUNITY_LIST_STANDARD; |
15176 | int direct = 0; | |
15177 | char *cl_number_or_name = NULL; | |
42f914d4 | 15178 | |
d62a17ae | 15179 | int idx = 0; |
7336e101 SP |
15180 | if (argv_find(argv, argc, "ip", &idx)) { |
15181 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
15182 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15183 | vty_out(vty, "'bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n"); | |
15184 | zlog_warn("Deprecated option: 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used"); | |
15185 | } | |
d62a17ae | 15186 | argv_find(argv, argc, "(1-99)", &idx); |
15187 | argv_find(argv, argc, "WORD", &idx); | |
15188 | cl_number_or_name = argv[idx]->arg; | |
15189 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
15190 | : COMMUNITY_DENY; | |
15191 | argv_find(argv, argc, "AA:NN", &idx); | |
15192 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 15193 | |
d62a17ae | 15194 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
15195 | direct, style); | |
42f914d4 | 15196 | |
d62a17ae | 15197 | XFREE(MTYPE_TMP, str); |
42f914d4 | 15198 | |
d62a17ae | 15199 | if (ret < 0) { |
15200 | community_list_perror(vty, ret); | |
15201 | return CMD_WARNING_CONFIG_FAILED; | |
15202 | } | |
42f914d4 | 15203 | |
d62a17ae | 15204 | return CMD_SUCCESS; |
718e3744 | 15205 | } |
15206 | ||
7336e101 SP |
15207 | #if CONFDATE > 20191005 |
15208 | CPP_NOTICE("bgpd: remove deprecated 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' command") | |
15209 | #endif | |
15210 | ALIAS (extcommunity_list_standard, | |
15211 | ip_extcommunity_list_standard_cmd, | |
15212 | "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
718e3744 | 15213 | IP_STR |
15214 | EXTCOMMUNITY_LIST_STR | |
7336e101 SP |
15215 | "Extended Community list number (standard)\n" |
15216 | "Specify standard extcommunity-list\n" | |
15217 | "Community list name\n" | |
15218 | "Specify community to reject\n" | |
15219 | "Specify community to accept\n" | |
15220 | EXTCOMMUNITY_VAL_STR) | |
15221 | ||
15222 | DEFUN (extcommunity_list_name_expanded, | |
15223 | bgp_extcommunity_list_name_expanded_cmd, | |
15224 | "bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
15225 | BGP_STR | |
15226 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 15227 | "Extended Community list number (expanded)\n" |
718e3744 | 15228 | "Specify expanded extcommunity-list\n" |
15229 | "Extended Community list name\n" | |
15230 | "Specify community to reject\n" | |
15231 | "Specify community to accept\n" | |
15232 | "An ordered list as a regular-expression\n") | |
15233 | { | |
d62a17ae | 15234 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
15235 | int direct = 0; | |
15236 | char *cl_number_or_name = NULL; | |
42f914d4 | 15237 | |
d62a17ae | 15238 | int idx = 0; |
7336e101 SP |
15239 | if (argv_find(argv, argc, "ip", &idx)) { |
15240 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
15241 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15242 | vty_out(vty, "'extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n"); | |
15243 | zlog_warn("Deprecated option: ‘ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used"); | |
15244 | } | |
15245 | ||
d62a17ae | 15246 | argv_find(argv, argc, "(100-500)", &idx); |
15247 | argv_find(argv, argc, "WORD", &idx); | |
15248 | cl_number_or_name = argv[idx]->arg; | |
15249 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
15250 | : COMMUNITY_DENY; | |
15251 | argv_find(argv, argc, "LINE", &idx); | |
15252 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 15253 | |
d62a17ae | 15254 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
15255 | direct, style); | |
42f914d4 | 15256 | |
d62a17ae | 15257 | XFREE(MTYPE_TMP, str); |
42f914d4 | 15258 | |
d62a17ae | 15259 | if (ret < 0) { |
15260 | community_list_perror(vty, ret); | |
15261 | return CMD_WARNING_CONFIG_FAILED; | |
15262 | } | |
42f914d4 | 15263 | |
d62a17ae | 15264 | return CMD_SUCCESS; |
718e3744 | 15265 | } |
15266 | ||
7336e101 SP |
15267 | ALIAS (extcommunity_list_name_expanded, |
15268 | ip_extcommunity_list_name_expanded_cmd, | |
15269 | "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
813d4307 DW |
15270 | IP_STR |
15271 | EXTCOMMUNITY_LIST_STR | |
7336e101 SP |
15272 | "Extended Community list number (expanded)\n" |
15273 | "Specify expanded extcommunity-list\n" | |
15274 | "Extended Community list name\n" | |
15275 | "Specify community to reject\n" | |
15276 | "Specify community to accept\n" | |
15277 | "An ordered list as a regular-expression\n") | |
15278 | ||
15279 | DEFUN (no_extcommunity_list_standard_all, | |
15280 | no_bgp_extcommunity_list_standard_all_cmd, | |
15281 | "no bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
15282 | NO_STR | |
15283 | BGP_STR | |
15284 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 15285 | "Extended Community list number (standard)\n" |
718e3744 | 15286 | "Specify standard extcommunity-list\n" |
5bf15956 | 15287 | "Community list name\n" |
718e3744 | 15288 | "Specify community to reject\n" |
15289 | "Specify community to accept\n" | |
15290 | EXTCOMMUNITY_VAL_STR) | |
15291 | { | |
d62a17ae | 15292 | int style = EXTCOMMUNITY_LIST_STANDARD; |
15293 | int direct = 0; | |
15294 | char *cl_number_or_name = NULL; | |
d4455c89 | 15295 | char *str = NULL; |
42f914d4 | 15296 | |
d62a17ae | 15297 | int idx = 0; |
7336e101 SP |
15298 | if (argv_find(argv, argc, "ip", &idx)) { |
15299 | vty_out(vty, "This config option is deprecated, and is scheduled for removal\n"); | |
15300 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15301 | vty_out(vty, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n"); | |
15302 | zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used"); | |
15303 | } | |
d4455c89 DA |
15304 | |
15305 | idx = 0; | |
15306 | argv_find(argv, argc, "permit", &idx); | |
15307 | argv_find(argv, argc, "deny", &idx); | |
15308 | ||
15309 | if (idx) { | |
15310 | direct = argv_find(argv, argc, "permit", &idx) | |
15311 | ? COMMUNITY_PERMIT | |
15312 | : COMMUNITY_DENY; | |
15313 | ||
15314 | idx = 0; | |
15315 | argv_find(argv, argc, "AA:NN", &idx); | |
15316 | str = argv_concat(argv, argc, idx); | |
15317 | } | |
15318 | ||
15319 | idx = 0; | |
d62a17ae | 15320 | argv_find(argv, argc, "(1-99)", &idx); |
15321 | argv_find(argv, argc, "WORD", &idx); | |
15322 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 15323 | |
d62a17ae | 15324 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
7298a8e1 | 15325 | direct, style); |
42f914d4 | 15326 | |
d62a17ae | 15327 | XFREE(MTYPE_TMP, str); |
42f914d4 | 15328 | |
d62a17ae | 15329 | if (ret < 0) { |
15330 | community_list_perror(vty, ret); | |
15331 | return CMD_WARNING_CONFIG_FAILED; | |
15332 | } | |
42f914d4 | 15333 | |
d62a17ae | 15334 | return CMD_SUCCESS; |
718e3744 | 15335 | } |
15336 | ||
7336e101 SP |
15337 | ALIAS (no_extcommunity_list_standard_all, |
15338 | no_ip_extcommunity_list_standard_all_cmd, | |
15339 | "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
718e3744 | 15340 | NO_STR |
15341 | IP_STR | |
15342 | EXTCOMMUNITY_LIST_STR | |
7336e101 SP |
15343 | "Extended Community list number (standard)\n" |
15344 | "Specify standard extcommunity-list\n" | |
15345 | "Community list name\n" | |
15346 | "Specify community to reject\n" | |
15347 | "Specify community to accept\n" | |
15348 | EXTCOMMUNITY_VAL_STR) | |
15349 | ||
d4455c89 DA |
15350 | ALIAS(no_extcommunity_list_standard_all, |
15351 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
15352 | "no bgp extcommunity-list <(1-99)|standard WORD>", | |
15353 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
15354 | "Extended Community list number (standard)\n" | |
15355 | "Specify standard extcommunity-list\n" | |
15356 | "Community list name\n") | |
15357 | ||
15358 | ALIAS(no_extcommunity_list_standard_all, | |
15359 | no_ip_extcommunity_list_standard_all_list_cmd, | |
15360 | "no ip extcommunity-list <(1-99)|standard WORD>", | |
15361 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
15362 | "Extended Community list number (standard)\n" | |
15363 | "Specify standard extcommunity-list\n" | |
15364 | "Community list name\n") | |
15365 | ||
7336e101 SP |
15366 | DEFUN (no_extcommunity_list_expanded_all, |
15367 | no_bgp_extcommunity_list_expanded_all_cmd, | |
15368 | "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
15369 | NO_STR | |
15370 | BGP_STR | |
15371 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 15372 | "Extended Community list number (expanded)\n" |
718e3744 | 15373 | "Specify expanded extcommunity-list\n" |
5bf15956 | 15374 | "Extended Community list name\n" |
718e3744 | 15375 | "Specify community to reject\n" |
15376 | "Specify community to accept\n" | |
15377 | "An ordered list as a regular-expression\n") | |
15378 | { | |
d62a17ae | 15379 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
15380 | int direct = 0; | |
15381 | char *cl_number_or_name = NULL; | |
d4455c89 | 15382 | char *str = NULL; |
42f914d4 | 15383 | |
d62a17ae | 15384 | int idx = 0; |
7336e101 SP |
15385 | if (argv_find(argv, argc, "ip", &idx)) { |
15386 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
15387 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15388 | vty_out(vty, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n"); | |
15389 | zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used"); | |
15390 | } | |
d4455c89 DA |
15391 | |
15392 | idx = 0; | |
15393 | argv_find(argv, argc, "permit", &idx); | |
15394 | argv_find(argv, argc, "deny", &idx); | |
15395 | ||
15396 | if (idx) { | |
15397 | direct = argv_find(argv, argc, "permit", &idx) | |
15398 | ? COMMUNITY_PERMIT | |
15399 | : COMMUNITY_DENY; | |
15400 | ||
15401 | idx = 0; | |
15402 | argv_find(argv, argc, "LINE", &idx); | |
15403 | str = argv_concat(argv, argc, idx); | |
15404 | } | |
15405 | ||
15406 | idx = 0; | |
d62a17ae | 15407 | argv_find(argv, argc, "(100-500)", &idx); |
15408 | argv_find(argv, argc, "WORD", &idx); | |
15409 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 15410 | |
d62a17ae | 15411 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
7298a8e1 | 15412 | direct, style); |
42f914d4 | 15413 | |
d62a17ae | 15414 | XFREE(MTYPE_TMP, str); |
42f914d4 | 15415 | |
d62a17ae | 15416 | if (ret < 0) { |
15417 | community_list_perror(vty, ret); | |
15418 | return CMD_WARNING_CONFIG_FAILED; | |
15419 | } | |
42f914d4 | 15420 | |
d62a17ae | 15421 | return CMD_SUCCESS; |
718e3744 | 15422 | } |
15423 | ||
7336e101 SP |
15424 | ALIAS (no_extcommunity_list_expanded_all, |
15425 | no_ip_extcommunity_list_expanded_all_cmd, | |
15426 | "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
15427 | NO_STR | |
15428 | IP_STR | |
15429 | EXTCOMMUNITY_LIST_STR | |
15430 | "Extended Community list number (expanded)\n" | |
15431 | "Specify expanded extcommunity-list\n" | |
15432 | "Extended Community list name\n" | |
15433 | "Specify community to reject\n" | |
15434 | "Specify community to accept\n" | |
15435 | "An ordered list as a regular-expression\n") | |
15436 | ||
d4455c89 DA |
15437 | ALIAS(no_extcommunity_list_expanded_all, |
15438 | no_ip_extcommunity_list_expanded_all_list_cmd, | |
15439 | "no ip extcommunity-list <(100-500)|expanded WORD>", | |
15440 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
15441 | "Extended Community list number (expanded)\n" | |
15442 | "Specify expanded extcommunity-list\n" | |
15443 | "Extended Community list name\n") | |
15444 | ||
15445 | ALIAS(no_extcommunity_list_expanded_all, | |
15446 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
15447 | "no bgp extcommunity-list <(100-500)|expanded WORD>", | |
15448 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
15449 | "Extended Community list number (expanded)\n" | |
15450 | "Specify expanded extcommunity-list\n" | |
15451 | "Extended Community list name\n") | |
15452 | ||
d62a17ae | 15453 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 15454 | { |
d62a17ae | 15455 | struct community_entry *entry; |
718e3744 | 15456 | |
d62a17ae | 15457 | for (entry = list->head; entry; entry = entry->next) { |
15458 | if (entry == list->head) { | |
15459 | if (all_digit(list->name)) | |
15460 | vty_out(vty, "Extended community %s list %s\n", | |
15461 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
15462 | ? "standard" | |
15463 | : "(expanded) access", | |
15464 | list->name); | |
15465 | else | |
15466 | vty_out(vty, | |
15467 | "Named extended community %s list %s\n", | |
15468 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
15469 | ? "standard" | |
15470 | : "expanded", | |
15471 | list->name); | |
15472 | } | |
15473 | if (entry->any) | |
15474 | vty_out(vty, " %s\n", | |
15475 | community_direct_str(entry->direct)); | |
15476 | else | |
15477 | vty_out(vty, " %s %s\n", | |
15478 | community_direct_str(entry->direct), | |
8d9b8ed9 | 15479 | community_list_config_str(entry)); |
d62a17ae | 15480 | } |
718e3744 | 15481 | } |
15482 | ||
7336e101 SP |
15483 | DEFUN (show_extcommunity_list, |
15484 | show_bgp_extcommunity_list_cmd, | |
15485 | "show bgp extcommunity-list", | |
718e3744 | 15486 | SHOW_STR |
7336e101 | 15487 | BGP_STR |
718e3744 | 15488 | "List extended-community list\n") |
15489 | { | |
d62a17ae | 15490 | struct community_list *list; |
15491 | struct community_list_master *cm; | |
7336e101 | 15492 | int idx = 0; |
718e3744 | 15493 | |
7336e101 SP |
15494 | if (argv_find(argv, argc, "ip", &idx)) { |
15495 | vty_out(vty, "This config option is deprecated, and is scheduled for removal\n"); | |
15496 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15497 | vty_out(vty, "'show bgp extcommunity-list <(1-500)|WORD>'\n"); | |
15498 | zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used"); | |
15499 | } | |
d62a17ae | 15500 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
15501 | if (!cm) | |
15502 | return CMD_SUCCESS; | |
718e3744 | 15503 | |
d62a17ae | 15504 | for (list = cm->num.head; list; list = list->next) |
15505 | extcommunity_list_show(vty, list); | |
718e3744 | 15506 | |
d62a17ae | 15507 | for (list = cm->str.head; list; list = list->next) |
15508 | extcommunity_list_show(vty, list); | |
718e3744 | 15509 | |
d62a17ae | 15510 | return CMD_SUCCESS; |
718e3744 | 15511 | } |
15512 | ||
7336e101 SP |
15513 | ALIAS (show_extcommunity_list, |
15514 | show_ip_extcommunity_list_cmd, | |
15515 | "show ip extcommunity-list", | |
718e3744 | 15516 | SHOW_STR |
15517 | IP_STR | |
7336e101 SP |
15518 | "List extended-community list\n") |
15519 | ||
15520 | DEFUN (show_extcommunity_list_arg, | |
15521 | show_bgp_extcommunity_list_arg_cmd, | |
960b69b9 | 15522 | "show bgp extcommunity-list <(1-500)|WORD> detail", |
7336e101 SP |
15523 | SHOW_STR |
15524 | BGP_STR | |
718e3744 | 15525 | "List extended-community list\n" |
15526 | "Extcommunity-list number\n" | |
960b69b9 | 15527 | "Extcommunity-list name\n" |
15528 | "Detailed information on extcommunity-list\n") | |
718e3744 | 15529 | { |
d62a17ae | 15530 | int idx_comm_list = 3; |
15531 | struct community_list *list; | |
7336e101 | 15532 | int idx = 0; |
718e3744 | 15533 | |
7336e101 SP |
15534 | if (argv_find(argv, argc, "ip", &idx)) { |
15535 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
15536 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
960b69b9 | 15537 | vty_out(vty, "'show bgp extcommunity-list <(1-500)|WORD> detail'\n"); |
15538 | zlog_warn("Deprecated option: 'show ip extcommunity-list <(1-500)|WORD>' being used"); | |
7336e101 | 15539 | } |
e237b0d2 | 15540 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 15541 | EXTCOMMUNITY_LIST_MASTER); |
15542 | if (!list) { | |
15543 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
15544 | return CMD_WARNING; | |
15545 | } | |
718e3744 | 15546 | |
d62a17ae | 15547 | extcommunity_list_show(vty, list); |
718e3744 | 15548 | |
d62a17ae | 15549 | return CMD_SUCCESS; |
718e3744 | 15550 | } |
6b0655a2 | 15551 | |
7336e101 SP |
15552 | ALIAS (show_extcommunity_list_arg, |
15553 | show_ip_extcommunity_list_arg_cmd, | |
15554 | "show ip extcommunity-list <(1-500)|WORD>", | |
15555 | SHOW_STR | |
15556 | IP_STR | |
15557 | "List extended-community list\n" | |
15558 | "Extcommunity-list number\n" | |
15559 | "Extcommunity-list name\n") | |
15560 | ||
718e3744 | 15561 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 15562 | static int community_list_config_write(struct vty *vty) |
15563 | { | |
15564 | struct community_list *list; | |
15565 | struct community_entry *entry; | |
15566 | struct community_list_master *cm; | |
15567 | int write = 0; | |
15568 | ||
15569 | /* Community-list. */ | |
15570 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
15571 | ||
15572 | for (list = cm->num.head; list; list = list->next) | |
15573 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15574 | vty_out(vty, "bgp community-list %s %s %s\n", list->name, |
d62a17ae | 15575 | community_direct_str(entry->direct), |
15576 | community_list_config_str(entry)); | |
15577 | write++; | |
15578 | } | |
15579 | for (list = cm->str.head; list; list = list->next) | |
15580 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15581 | vty_out(vty, "bgp community-list %s %s %s %s\n", |
d62a17ae | 15582 | entry->style == COMMUNITY_LIST_STANDARD |
15583 | ? "standard" | |
15584 | : "expanded", | |
15585 | list->name, community_direct_str(entry->direct), | |
15586 | community_list_config_str(entry)); | |
15587 | write++; | |
15588 | } | |
15589 | ||
15590 | /* Extcommunity-list. */ | |
15591 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
15592 | ||
15593 | for (list = cm->num.head; list; list = list->next) | |
15594 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15595 | vty_out(vty, "bgp extcommunity-list %s %s %s\n", |
d62a17ae | 15596 | list->name, community_direct_str(entry->direct), |
15597 | community_list_config_str(entry)); | |
15598 | write++; | |
15599 | } | |
15600 | for (list = cm->str.head; list; list = list->next) | |
15601 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15602 | vty_out(vty, "bgp extcommunity-list %s %s %s %s\n", |
d62a17ae | 15603 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
15604 | ? "standard" | |
15605 | : "expanded", | |
15606 | list->name, community_direct_str(entry->direct), | |
15607 | community_list_config_str(entry)); | |
15608 | write++; | |
15609 | } | |
15610 | ||
15611 | ||
15612 | /* lcommunity-list. */ | |
15613 | cm = community_list_master_lookup(bgp_clist, | |
15614 | LARGE_COMMUNITY_LIST_MASTER); | |
15615 | ||
15616 | for (list = cm->num.head; list; list = list->next) | |
15617 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15618 | vty_out(vty, "bgp large-community-list %s %s %s\n", |
d62a17ae | 15619 | list->name, community_direct_str(entry->direct), |
15620 | community_list_config_str(entry)); | |
15621 | write++; | |
15622 | } | |
15623 | for (list = cm->str.head; list; list = list->next) | |
15624 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15625 | vty_out(vty, "bgp large-community-list %s %s %s %s\n", |
d62a17ae | 15626 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
15627 | ? "standard" | |
15628 | : "expanded", | |
15629 | list->name, community_direct_str(entry->direct), | |
15630 | community_list_config_str(entry)); | |
15631 | write++; | |
15632 | } | |
15633 | ||
15634 | return write; | |
15635 | } | |
15636 | ||
15637 | static struct cmd_node community_list_node = { | |
15638 | COMMUNITY_LIST_NODE, "", 1 /* Export to vtysh. */ | |
718e3744 | 15639 | }; |
15640 | ||
d62a17ae | 15641 | static void community_list_vty(void) |
15642 | { | |
15643 | install_node(&community_list_node, community_list_config_write); | |
15644 | ||
15645 | /* Community-list. */ | |
7336e101 SP |
15646 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
15647 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
15648 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 15649 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 15650 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 15651 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
15652 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
15653 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 15654 | install_element(CONFIG_NODE, &ip_community_list_standard_cmd); |
15655 | install_element(CONFIG_NODE, &ip_community_list_expanded_all_cmd); | |
15656 | install_element(CONFIG_NODE, &no_ip_community_list_standard_all_cmd); | |
174b5cb9 | 15657 | install_element(CONFIG_NODE, &no_ip_community_list_standard_all_list_cmd); |
d62a17ae | 15658 | install_element(CONFIG_NODE, &no_ip_community_list_expanded_all_cmd); |
174b5cb9 | 15659 | install_element(CONFIG_NODE, &no_ip_community_list_expanded_all_list_cmd); |
d62a17ae | 15660 | install_element(VIEW_NODE, &show_ip_community_list_cmd); |
15661 | install_element(VIEW_NODE, &show_ip_community_list_arg_cmd); | |
15662 | ||
15663 | /* Extcommunity-list. */ | |
7336e101 SP |
15664 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
15665 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
15666 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
d4455c89 DA |
15667 | install_element(CONFIG_NODE, |
15668 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
7336e101 | 15669 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); |
d4455c89 DA |
15670 | install_element(CONFIG_NODE, |
15671 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
7336e101 SP |
15672 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); |
15673 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 15674 | install_element(CONFIG_NODE, &ip_extcommunity_list_standard_cmd); |
15675 | install_element(CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd); | |
15676 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd); | |
d4455c89 | 15677 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_standard_all_list_cmd); |
d62a17ae | 15678 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd); |
d4455c89 | 15679 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_list_cmd); |
d62a17ae | 15680 | install_element(VIEW_NODE, &show_ip_extcommunity_list_cmd); |
15681 | install_element(VIEW_NODE, &show_ip_extcommunity_list_arg_cmd); | |
15682 | ||
15683 | /* Large Community List */ | |
7336e101 | 15684 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
7336e101 SP |
15685 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); |
15686 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
7336e101 SP |
15687 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); |
15688 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_all_cmd); | |
15689 | install_element(CONFIG_NODE, | |
15690 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
15691 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
15692 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
15693 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
15694 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
15695 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
15696 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
d62a17ae | 15697 | install_element(CONFIG_NODE, &ip_lcommunity_list_standard_cmd); |
d62a17ae | 15698 | install_element(CONFIG_NODE, &ip_lcommunity_list_expanded_cmd); |
15699 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_standard_cmd); | |
d62a17ae | 15700 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_expanded_cmd); |
15701 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_standard_all_cmd); | |
15702 | install_element(CONFIG_NODE, | |
15703 | &no_ip_lcommunity_list_name_expanded_all_cmd); | |
15704 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_standard_cmd); | |
15705 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_expanded_cmd); | |
15706 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_name_standard_cmd); | |
15707 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_cmd); | |
15708 | install_element(VIEW_NODE, &show_ip_lcommunity_list_cmd); | |
15709 | install_element(VIEW_NODE, &show_ip_lcommunity_list_arg_cmd); | |
5bf15956 | 15710 | } |